Permalink
Fetching contributors…
Cannot retrieve contributors at this time
67 lines (50 sloc) 1.47 KB
#!/bin/bash -l
# redirect output
exec 3>&1
exec &>> "@OUTDIR@/logfile.txt"
TIMESTAMP=`date +%Y/%m/%d_%H:%M:%S`
echo "Logging on "$TIMESTAMP
# host specific setup
@HOST_SETUP@
# create output folder
mkdir -p "@OUTDIR@"
@SCRATCH_MKDIR@
# @REMOVE_HISTXML@ : tag to remove "history.xml" on remote for restarts, commented out on purpose
# flag needed for ubuntu
export GFORTRAN_UNBUFFERED_PRECONNECTED=yes
# see if application needs running
if [ ! -e "@OUTDIR@/history.xml" ]; then
cd "@RUNDIR@"
"@BINARY@"
STATUS=$?
if [ $STATUS == 0 ]; then
if grep -Fq '=== Time integration ends; Total elapsed time=' "@OUTDIR@/logfile.txt"; then
STATUS=0
else
STATUS=1
fi
fi
# copy scratch if needed
@SCRATCH_COPY@
@SCRATCH_CLEAR@
# check the status
if [ $STATUS -ne 0 ]; then
echo -e "ERROR IN MODEL RUN\nLogfile is located at '@OUTDIR@/logfile.txt'"
echo "************************************************* End Log $TIMESTAMP"
echo ""
exit $STATUS
fi
# convert to MsTMIP
echo "require (PEcAn.ED2)
model2netcdf.ED2('@OUTDIR@', @SITE_LAT@, @SITE_LON@, '@START_DATE@', '@END_DATE@', @PFT_NAMES@)
" | R --vanilla
fi
# copy readme with specs to output
cp "@RUNDIR@/README.txt" "@OUTDIR@/README.txt"
# run getdata to extract right variables
# host specific teardown
@HOST_TEARDOWN@
# all done
echo -e "MODEL FINISHED\nLogfile is located at '@OUTDIR@/logfile.txt'"
echo "************************************************* End Log $TIMESTAMP"
echo ""