Skip to content

Commit bbc1b51

Browse files
authored
Merge pull request #13 from drroe/fix.status
Ensure status is properly reported when no status file is specified
2 parents b046bca + 92f804e commit bbc1b51

1 file changed

Lines changed: 15 additions & 9 deletions

File tree

AmberMdPrep.sh

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# NIH/NHLBI
77
# 2020-08-07
88

9-
VERSION='0.7 (beta)'
9+
VERSION='0.8 (beta)'
1010
MPIRUN=`which mpirun`
1111
CPPTRAJ=`which cpptraj`
1212

@@ -51,6 +51,15 @@ PRODUCTION_DT='0.002' # Default time step for 'production' steps (9 and final)
5151
STATUSFILE=''
5252

5353
# ------------------------------------------------------------------------------
54+
# ReportStatus <message>
55+
# Report job status to stdout and STATUSFILE if not blank.
56+
ReportStatus() {
57+
echo $1
58+
if [ ! -z "$STATUSFILE" ] ; then
59+
echo $1 > $STATUSFILE
60+
fi
61+
}
62+
5463
# DetectSystemType <topology file>
5564
# Use cpptraj to print out residues from a topology file. Determine the
5665
# type of each residue and keep track.
@@ -497,9 +506,7 @@ if [ ! -z "$PRODUCTIONMASK" -a -z "$PRODUCTIONWT" ] ; then
497506
exit 1
498507
fi
499508

500-
if [ -z "$STATUSFILE" ] ; then
501-
STATUSFILE=/dev/stdout
502-
else
509+
if [ ! -z "$STATUSFILE" ] ; then
503510
echo "Status file is $STATUSFILE"
504511
fi
505512

@@ -855,7 +862,7 @@ EOF
855862
fi
856863
if [ $? -ne 0 ] ; then
857864
echo "Error: MD failed: $MDIN" >> /dev/stderr
858-
echo "Equilibration failed" > $STATUSFILE
865+
ReportStatus "Equilibration failed"
859866
exit 1
860867
fi
861868
else
@@ -979,19 +986,18 @@ EOF
979986
echo "Complete."
980987
DONE=1
981988
if [ $TEST -eq 0 ] ; then
982-
echo "Equilibration success" > $STATUSFILE
989+
ReportStatus "Equilibration success"
983990
fi
984991
elif [ $ERR -eq 2 ] ; then
985-
echo "Equlibration eval failed"
986-
echo "Equlibration eval failed" > $STATUSFILE
992+
ReportStatus "Equlibration eval failed"
987993
break
988994
else
989995
INPCRD="final.$num.ncrst"
990996
((num++))
991997
# Safety valve
992998
if [ $num -gt 20 ] ; then
993999
echo "More than 20 iterations of final density equil required. Bailing out."
994-
echo "Too many final iterations" > $STATUSFILE
1000+
ReportStatus "Too many final iterations"
9951001
DONE=1
9961002
continue
9971003
fi

0 commit comments

Comments
 (0)