#!/bin/sh ####################################################### # JMAG_CLEANUP -- performs cleanup for MAG development # # P. Freeman 2/2019 - Phase 3 migration. # Use $LOGROOT and $DATAROOT # Remove reference to /tmpnwprd1 (no long exists) # Keep $DATA dir if $KEEPDATA == yes # P. Freeman 4/2019 - Redefine $COMOUT to use same definition # as .bashrc, so we can run exmag_cleanup.sh.ecf # at the command line. Also define $COMOUTstatus # same as .bashrc, for use in exmag_cleanup.sh.ecf ####################################################### export job="jmag_cleanup" set -xa export PS4='$SECONDS + ' date ####################################################### # The following variables could be defined in the # submission script (the ecf script), if # not they will take the default values which is set # for the NCO running enviroment ####################################################### export COMROOT=${COMROOT:-/gpfs/dell1/nco/sdb/noscrub/mag.dev/com} export DATAROOT=${DATAROOT:-/gpfs/dell1/ptmp/mag.dev/data} export NWROOT=${NWROOT:-/gpfs/dell1/nco/sdb/noscrub/mag.dev/nwtest} export envir=${envir:-test} export COMOUT=${COMROOT}/mag/${envir}/gifs export COMOUTstatus=$COMROOT/mag/test/status ####################################################### # obtain unique process id (pid) and make temp directory ####################################################### export pid=$$ export DATA=${DATAROOT}/${job}.${pid} rm -rf $DATA mkdir -p $DATA cd $DATA #################################### # Specify Execution Areas #################################### set -x export HOMEmag=${HOMEmag:-$NWROOT/mag.${mag_ver}} export EXECmag=${EXECmag:-$HOMEmag/exec} export USHmag=${USHmag:-$HOMEmag/ush} export FIXmag=${FIXmag:-$HOMEmag/fix} export PARMmag=${PARMmag:-$HOMEmag/parm} export SCRIPTSmag=${SCRIPTSmag:-$HOMEmag/scripts} msg="HAS BEGUN on `hostname`" postmsg $logfile "$msg" echo "$msg" # Clean up directories on local WCOSS $SCRIPTSmag/exmag_cleanup.sh.ecf # Clean up directories on ncorzdm in CP and Boulder /usr/bin/ssh -t -t $username@ncorzdm.ncep.noaa.gov "bash /home/people/nco/mag/bin/exmag_cleanup_test.sh.ecf" /usr/bin/ssh -t -t $username@ncorzdm-bldr.ncep.noaa.gov "bash /home/people/nco/mag/bin/exmag_cleanup_test.sh.ecf" ############################################################# if [ "${KEEPDATA^^}" != 'YES' ]; then rm -rf ${DATA:?} fi