[Swift-commit] r3689 - trunk/libexec

noreply at svn.ci.uchicago.edu noreply at svn.ci.uchicago.edu
Tue Oct 26 14:00:33 CDT 2010


Author: wozniak
Date: 2010-10-26 14:00:33 -0500 (Tue, 26 Oct 2010)
New Revision: 3689

Modified:
   trunk/libexec/_swiftwrap
Log:
Enable basic MPICH/Coasters functionality


Modified: trunk/libexec/_swiftwrap
===================================================================
--- trunk/libexec/_swiftwrap	2010-10-26 18:34:20 UTC (rev 3688)
+++ trunk/libexec/_swiftwrap	2010-10-26 19:00:33 UTC (rev 3689)
@@ -2,6 +2,9 @@
 # this script must be invoked inside of bash, not plain sh
 # note that this script modifies $IFS
 
+# Toggle debugging output from debug()
+DEBUG=1
+
 infosection() {
         echo >& "$INFO"
 	echo "_____________________________________________________________________________" >& "$INFO"
@@ -12,6 +15,8 @@
 }
 
 info() {
+	infosection "command line"
+	echo $COMMANDLINE 2>&1 >& "$INFO"
 	infosection "uname -a"
 	uname -a 2>&1 >& "$INFO"
 	infosection "id"
@@ -28,8 +33,6 @@
 		infosection "/proc/meminfo"
 		cat /proc/meminfo 2>&1 >& "$INFO"
 	fi
-	infosection "command line"
-	echo $COMMANDLINE 2>&1 >& "$INFO"
 	if [ -f "$STDOUT" ] ; then
 		infosection "stdout"
 		cat $STDOUT >& "$INFO"
@@ -48,6 +51,10 @@
 	echo "$@" >& "$INFO"
 }
 
+debug() {
+	[ $DEBUG == 1 ] && echo "$@" >& "$INFO"
+}
+
 fail() {
 	EC=$1
 	shift
@@ -135,7 +142,7 @@
     	echo -n "\"$CMDARG\" " >> run.sh
 	done
 	echo "1>\"$STDOUT\" 2>\"$STDERR\"" >> run.sh
-	chmod +x run.sh	
+	chmod +x run.sh
 }
 
 cdm_local_output()
@@ -222,8 +229,13 @@
 mkdir -p $INFODIR
 closeinfo
 
-rm -f "$INFODIR/${ID}-info"
-openinfo "$INFODIR/${ID}-info"
+if [ -z $MPI_RANK ]; then
+	INFOFILE="$INFODIR/${ID}-info"
+else
+	INFOFILE="$INFODIR/${ID}-${MPI_RANK}-info"
+fi
+rm -f $INFOFILE
+openinfo "$INFOFILE"
 
 logstate "LOG_START"
 infosection "Wrapper"
@@ -328,6 +340,7 @@
 	fi
 fi
 
+debug "PID=$$"
 log "PWD=$PWD"
 log "DIR=$DIR"
 log "EXEC=$EXEC"
@@ -349,6 +362,8 @@
 checkError 254 "Failed to create job directory $DIR"
 log "Created job directory: $DIR"
 
+if [[ $MPI_RANK == "" || $MPI_RANK == 0 ]]; then
+
 logstate "CREATE_INPUTDIR"
 for D in $DIRS ; do
 	mkdir -p "$DIR/$D" 2>&1 >>"$INFO"
@@ -400,10 +415,17 @@
 	done
 fi
 
+fi # MPI_RANK==0
+
+debug "Moving to jobdir: $DIR"
+cd $DIR
+if [ $? != 0 ]; then
+	log "PWD: $PWD"
+	log $( find . )
+	fail 254 "Could not cd to: $DIR"
+fi
 logstate "EXECUTE"
-cd $DIR
 
-
 if [ ! -f "$EXEC" ]; then
 	fail 254 "The executable $EXEC does not exist"
 fi
@@ -447,12 +469,17 @@
 	fi
 fi
 
+log "Moving back to workflow directory $WFDIR"
 cd $WFDIR
+if [ $? != 0 ]; then
+	fail 254 "Could not cd to workflow directory: $WFDIR"
+fi
 
-log "Moving back to workflow directory $WFDIR"
 logstate "EXECUTE_DONE"
 log "Job ran successfully"
 
+if [[ $MPI_RANK == "" || $MPI_RANK == 0 ]]; then
+
 MISSING=
 for O in $OUTF ; do
 	if [ ! -f "$DIR/$O" ]; then
@@ -464,6 +491,7 @@
 	fi
 done
 if [ "$MISSING" != "" ]; then
+	log $( find . )
 	fail 254 "The following output files were not created by the application: $MISSING"
 fi
 
@@ -487,12 +515,17 @@
 	touch $WFDIR/status/${JOBDIR}/${ID}-success
 fi
 
+else
+	# Allow rank 0 to write output
+	sleep 1
+fi # MPI_RANK==0
+
 logstate "END"
 
 closeinfo
 
 if [ "X$PROGRESSIVE_INFO" == "X" ] && [ "X$SCRATCH" != "X" ]; then
-        mkdir -p "$WFDIR/info/$JOBDIR"
+	mkdir -p "$WFDIR/info/$JOBDIR"
 	mv "$INFODIR/${ID}-info" "$WFDIR/info/$JOBDIR/${ID}-info"
 fi
 




More information about the Swift-commit mailing list