Skip to content

Commit

Permalink
Added scp transport for hotstart resolves #715
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonfleming committed Oct 29, 2023
1 parent 478df27 commit d3e4716
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions asgs_main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1745,15 +1745,23 @@ hotstartBase=fort.${LUN}
hotstartSuffix=.nc
hotstartPath=${LASTSUBDIR}/nowcast # only for reading from local filesystem
hotstartURL=null
hotstartDownloadExecutable="curl"
hotstartDownloadRedirect="--output"
if [[ $HOTORCOLD = hotstart ]]; then
# check to see if the LASTSUBDIR is actually a URL
urlCheck=$(expr match "$LASTSUBDIR" 'http')
if [[ $urlCheck -eq 4 ]]; then
if [[ $LASTSUBDIR =~ "http://" || $LASTSUBDIR =~ "https://" || $LASTSUBDIR =~ "scp://" ]]; then
# always look for fort.68.nc from a URL because only a forecast
# will be posted to a URL, and only the hotstart file that was used
# to start the forecast will be posted ... asgs always hotstarts from
# a fort.68 file and always writes a fort.67 file
hotstartURL=$LASTSUBDIR
# If scp is to be used, the host where the hotstart (and run.properties) files
# are downloaded from must support public key authentication. The URL is expected
# to be in the form scp://tacc_tds3//full/path/to/hotstart/file
if [[ $LASTSUBDIR =~ "scp://" ]]; then
hotstartDownloadExecutable="scp"
hotstartDownloadRedirect=""
fi
else
# we are reading the hotstart file from the local filesystem, determine
# whether it is from a nowcast or hindcast
Expand All @@ -1778,25 +1786,25 @@ if [[ $HOTORCOLD = hotstart ]]; then
debugMessage "The run directory is ${RUNDIR}."
logMessage "Downloading run.properties file associated with hotstart file from ${hotstartURL}."
# get cold start time from the run.properties file
curl $hotstartURL/run.properties > $RUNDIR/from.run.properties
$hotstartDownloadExecutable $hotstartURL/run.properties $hotstartDownloadRedirect $RUNDIR/from.run.properties
logMessage "$THIS: Detecting cold start date from $RUNDIR/from.run.properties."
COLDSTARTDATE=`sed -n 's/[ ^]*$//;s/ColdStartTime\s*:\s*//p' ${RUNDIR}/from.run.properties`
logMessage "The cold start datetime associated with the remote hotstart file is ${COLDSTARTDATE}."
# pull down fort.68 file and save as fort.67 just because that
# is what the rest of asgs_main.sh is expecting
if [[ $HOTSTARTFORMAT = "binary" ]]; then
mkdir -p $RUNDIR/PE0000 2>> $SYSLOG
curl ${hotstartURL}/fort.68${hotstartSuffix} > ${RUNDIR}/PE0000/${hotstartFile}
$hotstartDownloadExecutable ${hotstartURL}/fort.68${hotstartSuffix} $hotstartDownloadRedirect ${RUNDIR}/PE0000/${hotstartFile}
logMessage "Downloaded hotstart file fort.68$hotstartSuffix from $hotstartURL to $RUNDIR/PE0000/${hotstartFile}."
else
curl ${hotstartURL}/fort.68${hotstartSuffix} > ${RUNDIR}/${hotstartFile}
$hotstartDownloadExecutable ${hotstartURL}/fort.68${hotstartSuffix} $hotstartDownloadRedirect ${RUNDIR}/${hotstartFile}
logMessage "Downloaded hotstart file fort.68$hotstartSuffix from $hotstartURL to $RUNDIR/${hotstartFile}."
fi

logMessage "Now checking hotstart file content."
checkHotstart $RUNDIR $HOTSTARTFORMAT 67
# get cold start time from the run.properties file
curl $hotstartURL/run.properties > from.run.properties
$hotstartDownloadExecutable $hotstartURL/run.properties $hotstartDownloadRedirect from.run.properties
else
# starting from a hotstart file on the local filesystem, not from a URL
checkDirExistence $LASTSUBDIR "local subdirectory containing hotstart file from the previous run"
Expand Down

0 comments on commit d3e4716

Please sign in to comment.