#!/bin/csh -f # +-======-+ # Copyright (c) 2003-2007 United States Government as represented by # the Admistrator of the National Aeronautics and Space Administration. # All Rights Reserved. # # THIS OPEN SOURCE AGREEMENT ("AGREEMENT") DEFINES THE RIGHTS OF USE, # REPRODUCTION, DISTRIBUTION, MODIFICATION AND REDISTRIBUTION OF CERTAIN # COMPUTER SOFTWARE ORIGINALLY RELEASED BY THE UNITED STATES GOVERNMENT AS # REPRESENTED BY THE GOVERNMENT AGENCY LISTED BELOW ("GOVERNMENT AGENCY"). # THE UNITED STATES GOVERNMENT, AS REPRESENTED BY GOVERNMENT AGENCY, IS AN # INTENDED THIRD-PARTY BENEFICIARY OF ALL SUBSEQUENT DISTRIBUTIONS OR # REDISTRIBUTIONS OF THE SUBJECT SOFTWARE. ANYONE WHO USES, REPRODUCES, # DISTRIBUTES, MODIFIES OR REDISTRIBUTES THE SUBJECT SOFTWARE, AS DEFINED # HEREIN, OR ANY PART THEREOF, IS, BY THAT ACTION, ACCEPTING IN FULL THE # RESPONSIBILITIES AND OBLIGATIONS CONTAINED IN THIS AGREEMENT. # # Government Agency: National Aeronautics and Space Administration # Government Agency Original Software Designation: GSC-15354-1 # Government Agency Original Software Title: GEOS-5 GCM Modeling Software # User Registration Requested. Please Visit http://opensource.gsfc.nasa.gov # Government Agency Point of Contact for Original Software: # Dale Hithon, SRA Assistant, (301) 286-2691 # # +-======-+ # This script performs post-processing of files which have been created from: gcm_run.j # It performs the following tasks: # # 1) Parses files within the ../holding/$stream directories to the appropriate YYYYMM # 2) Performs monthly means if the YYYYMM directories are complete (ie, contains all required files) # 3) Spawns ARCHIVE job if monthly means are successful. # 4) Spawns PLOT job if DJF or JJA has just been completed. # # ------------------------------------------------------------------------- @ nmax = $#argv # Usage # ----- if( $nmax == 0 ) then echo " " echo "Usage:" echo "-----" echo "gcmpost -source SOURCE_DIRECTORY" echo " where: SOURCE_DIRECTORY is the source directory for experiment" echo " " echo " <-recover YYYYMM Optional Argument to Recover and Repeat YYYYMM>" echo " <-ddf clim Optional Argument to Use clim.tabl for plots>" echo " " exit 1 endif # Process Input String # -------------------- set EXPID = 'NULL' set NCPUS = 'NULL' set CLIMO = 'FALSE' set DDF = 'NULL' setenv RECDATE "NULL" @ n = 1 while( $n <= $nmax ) if( "$argv[$n]" == "-source" ) then @ n = $n + 1 setenv SOURCE $argv[$n] endif if( "$argv[$n]" == "-recover" ) then @ n = $n + 1 setenv RECDATE $argv[$n] endif if( "$argv[$n]" == "-ncpus" ) then @ n = $n + 1 set NCPUS = $argv[$n] endif if( "$argv[$n]" == "-expid" ) then @ n = $n + 1 set EXPID = $argv[$n] endif if( "$argv[$n]" == "-clim" ) then set CLIMO = 'TRUE' endif if( "$argv[$n]" == "-ddf" ) then @ n = $n + 1 set DDF = $argv[$n] endif @ n = $n + 1 end # Set HOMDIR # ---------- if( -e $SOURCE/.HOMDIR ) then setenv HOMDIR `cat $SOURCE/.HOMDIR` else setenv HOMDIR $SOURCE endif # Determine Machine ID # -------------------- setenv ARCH ` uname` setenv HOST `hostname` set name = `echo $HOST` ; if ( ($name =~ pfe*) || ($name =~ p4fe*) || ($name =~ r[0-9]*i[0-9]*n[0-9]*) || ($name =~ bridge*) ) setenv HOST pleiades set name = `echo $HOST | cut -b 1-8` ; if( $name == 'columbia' ) setenv HOST $name set name = `echo $HOST | cut -b 1-8` ; if( $name == 'discover' ) setenv HOST $name set name = `echo $HOST | cut -b 1-4` ; if( $name == 'borg' ) setenv HOST discover set name = `echo $HOST | cut -b 1-4` ; if( $name == 'warp' ) setenv HOST discover set name = `echo $HOST | cut -b 1-4` ; if( $name == 'dali' ) setenv HOST discover if( $name == 'cfe1' ) setenv HOST columbia if( $name == 'cfe2' ) setenv HOST columbia # Extract EXPID from SOURCE (assuming last node) # ----------------------------------------------- if( $EXPID == "NULL" ) then set expid = `basename $SOURCE` else set expid = $EXPID endif # Determine Number of Nodes if running in BATCH # --------------------------------------------- if( $NCPUS == "NULL" ) then if ($?PBS_NODEFILE & $?BATCHNAME) then set BATCHJOB = `qstat | grep $BATCHNAME | grep $LOGNAME | cut -d' ' -f1` set numjobs = $#BATCHJOB if( $numjobs != 0 ) then set NCPUS = `qstat -f $BATCHJOB[1] | grep -i Resource_List.ncpus | cut -d'=' -f2` endif endif endif echo Use: NCPUS = $NCPUS # Set Architecture Speicific Variables # ------------------------------------ if( $ARCH == 'Linux' ) then if( $HOST == 'pleiades' ) then setenv MASTOR lou setenv MASDIR $expid setenv BATCHQ normal set scpvar = "bbscp -p 2 -z" set mytar = "mtar" endif if( $HOST == 'columbia' ) then setenv MASTOR lou.nas.nasa.gov setenv MASDIR $expid setenv BATCHQ normal set scpvar = "bbscp -p 2 -z" set mytar = "mtar" endif if( $HOST == 'discover' ) then setenv MASTOR dirac setenv MASDIR /archive/u/$LOGNAME/GEOS5.0/$expid setenv BATCHQ general set scpvar = "bbscp -z" set mytar = "tar" endif endif setenv GROUP `cat $HOME/.GROUProot` set check_plot = FALSE # Check for Post-Processing Executables # ------------------------------------- set execs = "time_ave" foreach exec ($execs) if( ! -e $GEOSUTIL/post/${exec}.x ) then echo "Error! Post-Processing Utility ${exec}.x is not found." exit 7 endif end # Determine Collection Names and Archive Locations from HISTORY RC File # --------------------------------------------------------------------- set collections = `$GEOSUTIL/post/get_streams $HOMDIR/HISTORY.rc` set archives = `$GEOSUTIL/post/get_archive $HOMDIR/HISTORY.rc` # Count Number of "Dots" in Collection Name to Find Location of Date Node # ----------------------------------------------------------------------- @ m = 0 set ndots = '' foreach collection ( $collections ) @ n = 0 @ b = 1 set bit = `echo ${collection} | cut -b $b` while( "${bit}" != '' ) if( "${bit}" == '.' ) then @ n = $n + 1 endif @ b = $b + 1 set bit = `echo ${collection} | cut -b $b` end set ndots = `echo $ndots $n` @ m = $m + 1 end # Check for RECDATE Option # ------------------------ if( $RECDATE != "NULL" ) then foreach collection ( $collections ) if( -e $SOURCE/holding/$collection/$RECDATE ) then cd $SOURCE/holding/$collection if( -e $RECDATE.tmp ) /bin/rm -r $RECDATE.tmp /bin/mv $RECDATE $RECDATE.tmp /bin/mv `/bin/ls -1 $RECDATE.tmp/${expid}*${collection}* | grep -v monthly | grep -v diurnal | grep -v daily` . /bin/rm -r $RECDATE.tmp endif end endif # Move Current Files within Holding Directory to proper YYYYMM Sub-Directories # ---------------------------------------------------------------------------- set dates = '' set numdates = '' @ nstream = 0 foreach collection ( $collections ) @ nstream = $nstream + 1 @ date_node = $ndots[$nstream] + 3 cd $SOURCE/holding/$collection set locals = `/bin/ls -1 | grep ${expid}.${collection} | grep -v monthly | grep -v diurnal` set numlocs = $#locals set numdate = 0 if( $numlocs != 0 ) then # Extract Extension (last node) from Typical Local File # ----------------------------------------------------- @ loc = 1 while( $loc != 0 ) set dum = `echo $locals[1] | cut -d "." -f$loc` if( .$dum != . ) then set ext = $dum @ loc = $loc + 1 else @ loc = 0 endif end set date0 = xxxx foreach local ( $locals ) set date = `echo $local | cut -d "." -f${date_node} | cut -c1-6` if( $date != $date0 ) then @ numdate = $numdate + 1 set dates = `echo $dates $date` set date0 = $date endif if(! -e $SOURCE/holding/$collection/$date ) mkdir -p $SOURCE/holding/$collection/$date /bin/mv $local $SOURCE/holding/$collection/$date end else @ numdate = $numdate + 1 set date = 0 set dates = `echo $dates $date` endif set numdates = `echo $numdates $numdate` end echo $numdates echo $dates # Process Monthly Means # --------------------- @ m = 1 @ begloc = 1 @ count = 0 foreach collection ( $collections ) @ endloc = $begloc + $numdates[$m] - 1 set streamdates = `echo $dates[${begloc}-${endloc}]` if( $streamdates[1] != 0 ) then foreach date ( $streamdates ) echo $collection $streamdates Current Date: $date if( -e $SOURCE/holding/$collection/$date ) then cd $SOURCE/holding/$collection/$date set locals = `/bin/ls -1 | grep ${expid}.${collection} | grep -v monthly | grep -v diurnal` set num = `/bin/ls -1 | grep ${expid}.${collection} | grep -v monthly | grep -v diurnal | wc -l` echo "Is it time to perform Time-Average on Local Files?:" echo "--------------------------------------------------" echo " Collection: $collection" echo " Date: $date" echo "Number of Files: $num" echo "" echo $locals echo "" if( $num > 0 ) then # Find Dates within first local file # ---------------------------------- set file = $locals[1] set filedate = `$GEOSUTIL/post/getdates $file` set begdate = $filedate[1] set begtime = $filedate[2] set enddate = $filedate[3] set endtime = $filedate[4] set ndt = $filedate[5] # Decrement First Date by one Time Increment # ------------------------------------------ set prevdate = `$GEOSUTIL/post/tick $begdate $begtime -$ndt` set prvdate = $prevdate[1] set prvtime = $prevdate[2] # Check to see if Decremented Date passed Month Boundary # ------------------------------------------------------ set prvmon = `echo $prvdate | cut -c5-6` set begmon = `echo $begdate | cut -c5-6` # Find Dates within last local file # --------------------------------- set file = $locals[$num] set filedate = `$GEOSUTIL/post/getdates $file` set begdate = $filedate[1] set begtime = $filedate[2] set enddate = $filedate[3] set endtime = $filedate[4] set ndt = $filedate[5] # Increment Last Date by one Time Increment # ----------------------------------------- set nextdate = `$GEOSUTIL/post/tick $enddate $endtime $ndt` set nxtdate = $nextdate[1] set nxttime = $nextdate[2] # Check to see if Incremented Date passed Month Boundary # ------------------------------------------------------ set endmon = `echo $enddate | cut -c5-6` set nxtmon = `echo $nxtdate | cut -c5-6` echo "Beginning Month within Local Files: ${begmon} (-$ndt Month: ${prvmon})" echo " Ending Month within Local Files: ${begmon} (+$ndt Month: ${nxtmon})" if( $prvmon != $begmon && $endmon != $nxtmon ) then echo " Performing time average ..." if(! -e time_ave.rc ) ln -s $GEOSUTIL/post/time_ave.rc . if( $NCPUS == "NULL" | $NCPUS == 1 | !($?RUN_CMD) ) then $GEOSUTIL/post/time_ave_nompi.x -hdf $locals -rc time_ave.rc \ -tag $expid.$collection.monthly \ -d $expid.$collection.diurnal else $RUN_CMD $NCPUS $GEOSUTIL/post/time_ave.x -hdf $locals -rc time_ave.rc \ -tag $expid.$collection.monthly \ -d $expid.$collection.diurnal endif @ count = $count + 1 if( $count == 9 ) then @ count = 1 wait endif else echo " End of Month not yet reached." endif endif endif # End IFTEST for -e $SOURCE/holding/$collection/$date due to possible deletion from other archive job end endif @ begloc = $endloc + 1 @ m = $m + 1 end # End Collection Loop wait # Move and Archive Monthly Means and Dailies # ------------------------------------------ set archfile = $SOURCE/archive/archive_commands.`date +%Y%m%d_%H%M%S` /bin/rm -f $archfile touch $archfile @ m = 1 @ begloc = 1 @ nstream = 0 foreach collection ( $collections ) @ nstream = $nstream + 1 @ date_node = $ndots[$nstream] + 3 @ endloc = $begloc + $numdates[$m] - 1 set streamdates = `echo $dates[${begloc}-${endloc}]` if( $streamdates[1] != 0 ) then foreach date ( $streamdates ) if( -e $SOURCE/holding/$collection/$date ) then set locdir = $SOURCE/holding/$collection/$date cd $SOURCE/holding/$collection/$date set num = `/bin/ls -1 $expid.$collection.monthly.* | wc -l` if( $num != 0 ) then set check_plot = TRUE echo "set success = TRUE" >> $archfile echo "@ npasses = 3" >> $archfile echo "if( -e $SOURCE/holding/$collection/$date ) then " >> $archfile echo "cd $SOURCE/holding/$collection/$date" >> $archfile # Tar and Archive Dailies # ----------------------- set locals = `/bin/ls -1 | grep ${expid}.${collection} | grep -v monthly | grep -v diurnal` $mytar cf $expid.${collection}.daily.$date.$ext.tar $locals set locals = $expid.${collection}.daily.$date.$ext.tar @ daily_date_node = $date_node + 1 # Since daily is simply appended to collection name foreach local ($locals) set fdate = `echo $local | cut -d "." -f${daily_date_node}` # Assumed date format: YYYYMMDD_HHMMSS set year = `echo $fdate | cut -c1-4` set month = `echo $fdate | cut -c5-6` set day = `echo $fdate | cut -c7-8` set hour = `echo $fdate | cut -c10-11` set archive = `echo $archives[$m] | sed -e "s/%c/$collection/ g" | \ sed -e "s/%y4/$year/ g" | \ sed -e "s/%m2/$month/ g" | \ sed -e "s/%d2/$day/ g" | \ sed -e "s/%h2/$hour/ g"` if( $HOST == 'pleiades' ) then echo "ssh bridge2 ssh ${MASTOR} mkdir -p ${MASDIR}/$archive " >> $archfile echo "ssh bridge2 $scpvar $locdir/$local ${MASTOR}:${MASDIR}/$archive " >> $archfile endif if( $HOST == 'columbia' ) then echo "ssh ${MASTOR} mkdir -p ${MASDIR}/$archive " >> $archfile echo "scp $local ${MASTOR}:${MASDIR}/$archive " >> $archfile endif if( $HOST == 'discover' ) then echo " ssh $MASTOR mkdir -p ${MASDIR}/$archive " >> $archfile echo 'echo " "' >> $archfile echo "echo 'Archiving: '$local" >> $archfile echo '@ n = 1' >> $archfile echo 'while( $n <= $npasses )' >> $archfile echo "$scpvar $local ${MASTOR}:${MASDIR}/$archive | set archive_status = "'`sed -e "s/ / /g"`' >> $archfile echo 'if ( .$archive_status[4] == .OK ) then' >> $archfile echo 'echo " Attempt "''$n ... PASS ' >> $archfile echo '@ n = 999' >> $archfile echo "else" >> $archfile echo 'echo " Attempt "''$n ... FAIL!' >> $archfile echo 'if( $n == $npasses ) set success = FALSE' >> $archfile echo '@ n = $n + 1' >> $archfile echo "endif" >> $archfile echo "end" >> $archfile echo 'unset archive_status' >> $archfile endif end echo "wait" >> $archfile # Archive Monthlies (non diurnal files) # ------------------------------------- @ monthly_date_node = $date_node + 1 # Since monthly is simply appended to collection name set locals = `/bin/ls -1 | grep ${expid}.${collection} | grep monthly | grep -v diurnal` foreach local ($locals) set fdate = `echo $local | cut -d "." -f${monthly_date_node}` # Assumed date format: YYYYMMDD_HHMMSS set year = `echo $fdate | cut -c1-4` set month = `echo $fdate | cut -c5-6` set day = `echo $fdate | cut -c7-8` set hour = `echo $fdate | cut -c10-11` set archive = `echo $archives[$m] | sed -e "s/%c/$collection/ g" | \ sed -e "s/%y4/$year/ g" | \ sed -e "s/%m2/$month/ g" | \ sed -e "s/%d2/$day/ g" | \ sed -e "s/%h2/$hour/ g"` /bin/cp $local $SOURCE/$collection if( $HOST == 'pleiades' ) then echo "ssh bridge2 ssh ${MASTOR} mkdir -p ${MASDIR}/$archive" >> $archfile echo "ssh bridge2 scp $locdir/$local ${MASTOR}:${MASDIR}/$archive" >> $archfile endif if( $HOST == 'columbia' ) then echo "ssh ${MASTOR} mkdir -p ${MASDIR}/$archive" >> $archfile echo "scp $local ${MASTOR}:${MASDIR}/$archive" >> $archfile endif if( $HOST == 'discover' ) then echo " ssh $MASTOR mkdir -p ${MASDIR}/$archive " >> $archfile echo 'echo " "' >> $archfile echo "echo 'Archiving: '$local" >> $archfile echo '@ n = 1' >> $archfile echo 'while( $n <= $npasses )' >> $archfile echo "$scpvar $local ${MASTOR}:${MASDIR}/$archive | set archive_status = "'`sed -e "s/ / /g"`' >> $archfile echo 'if ( .$archive_status[4] == .OK ) then' >> $archfile echo 'echo " Attempt "''$n ... PASS ' >> $archfile echo '@ n = 999' >> $archfile echo "else" >> $archfile echo 'echo " Attempt "''$n ... FAIL!' >> $archfile echo 'if( $n == $npasses ) set success = FALSE' >> $archfile echo '@ n = $n + 1' >> $archfile echo "endif" >> $archfile echo "end" >> $archfile echo 'unset archive_status' >> $archfile endif end # Archive Monthlies (diurnal files) # --------------------------------- @ monthly_date_node = $date_node + 1 # Since diurnal is simply appended to collection name set locals = `/bin/ls -1 | grep ${expid}.${collection} | grep diurnal | grep -v monthly` set num = `/bin/ls -1 | grep ${expid}.${collection} | grep diurnal | grep -v monthly | wc -l` if( $num != 0 ) then foreach local ($locals) set fdate = `echo $local | cut -d "." -f${monthly_date_node}` # Assumed date format: YYYYMMDD_HHMMSS set year = `echo $fdate | cut -c1-4` set month = `echo $fdate | cut -c5-6` set day = `echo $fdate | cut -c7-8` set hour = `echo $fdate | cut -c10-11` set archive = `echo $archives[$m] | sed -e "s/%c/$collection/ g" | \ sed -e "s/%y4/$year/ g" | \ sed -e "s/%m2/$month/ g" | \ sed -e "s/%d2/$day/ g" | \ sed -e "s/%h2/$hour/ g"` mkdir -p $SOURCE/$collection/diurnal /bin/cp $local $SOURCE/$collection/diurnal if( $HOST == 'pleiades' ) then echo "ssh bridge2 ssh ${MASTOR} mkdir -p ${MASDIR}/$archive" >> $archfile echo "ssh bridge2 scp $locdir/$local ${MASTOR}:${MASDIR}/$archive" >> $archfile endif if( $HOST == 'columbia' ) then echo "ssh ${MASTOR} mkdir -p ${MASDIR}/$archive" >> $archfile echo "scp $local ${MASTOR}:${MASDIR}/$archive" >> $archfile endif if( $HOST == 'discover' ) then echo " ssh $MASTOR mkdir -p ${MASDIR}/$archive " >> $archfile echo 'echo " "' >> $archfile echo "echo 'Archiving: '$local" >> $archfile echo '@ n = 1' >> $archfile echo 'while( $n <= $npasses )' >> $archfile echo "$scpvar $local ${MASTOR}:${MASDIR}/$archive | set archive_status = "'`sed -e "s/ / /g"`' >> $archfile echo 'if ( .$archive_status[4] == .OK ) then' >> $archfile echo 'echo " Attempt "''$n ... PASS ' >> $archfile echo '@ n = 999' >> $archfile echo "else" >> $archfile echo 'echo " Attempt "''$n ... FAIL!' >> $archfile echo 'if( $n == $npasses ) set success = FALSE' >> $archfile echo '@ n = $n + 1' >> $archfile echo "endif" >> $archfile echo "end" >> $archfile echo 'unset archive_status' >> $archfile endif end endif # Archive Restarts (First Stream Only) # ------------------------------------ if( $nstream == 1 ) then echo " " >> $archfile if( $HOST == 'pleiades' ) then echo "ssh bridge2 ssh ${MASTOR} mkdir -p ${MASDIR}/restarts/Y${year}" >> $archfile echo "ssh bridge2 $scpvar $SOURCE/restarts/*${year}${month}* ${MASTOR}:${MASDIR}/restarts/Y${year}" >> $archfile echo "ssh bridge2 $scpvar $SOURCE/GEOSgcm.x ${MASTOR}:${MASDIR}" >> $archfile echo "ssh bridge2 $scpvar $HOMDIR/HISTORY.rc ${MASTOR}:${MASDIR}" >> $archfile echo "ssh bridge2 $scpvar $HOMDIR/AGCM.rc ${MASTOR}:${MASDIR}" >> $archfile echo "ssh bridge2 $scpvar $HOMDIR/CAP.rc ${MASTOR}:${MASDIR}" >> $archfile endif if( $HOST == 'columbia' ) then echo "ssh ${MASTOR} mkdir -p ${MASDIR}/restarts/Y${year}" >> $archfile echo "scp $SOURCE/restarts/*${year}${month}* ${MASTOR}:${MASDIR}/restarts/Y${year}" >> $archfile echo "scp $SOURCE/GEOSgcm.x ${MASTOR}:${MASDIR}" >> $archfile echo "scp $HOMDIR/HISTORY.rc ${MASTOR}:${MASDIR}" >> $archfile echo "scp $HOMDIR/AGCM.rc ${MASTOR}:${MASDIR}" >> $archfile echo "scp $HOMDIR/CAP.rc ${MASTOR}:${MASDIR}" >> $archfile endif if( $HOST == 'discover' ) then echo " ssh $MASTOR mkdir -p ${MASDIR}/restarts/Y${year}" >> $archfile echo "$scpvar $SOURCE/restarts/*${year}${month}* ${MASTOR}:${MASDIR}/restarts/Y${year}" >> $archfile echo "$scpvar $SOURCE/GEOSgcm.x ${MASTOR}:${MASDIR}" >> $archfile echo "$scpvar $HOMDIR/HISTORY.rc ${MASTOR}:${MASDIR}" >> $archfile echo "$scpvar $HOMDIR/AGCM.rc ${MASTOR}:${MASDIR}" >> $archfile echo "$scpvar $HOMDIR/CAP.rc ${MASTOR}:${MASDIR}" >> $archfile endif echo "/bin/rm $SOURCE/restarts/*${year}${month}*" >> $archfile endif echo "cd ../" >> $archfile echo 'if( $success == TRUE ) then' >> $archfile echo ' /bin/rm -r '$date >> $archfile echo 'echo " Successfully Archived: "'$SOURCE/holding/$collection/$date >> $archfile echo 'else' >> $archfile echo 'echo " FAILED to Archive: "'$SOURCE/holding/$collection/$date >> $archfile echo 'endif' >> $archfile echo 'endif' >> $archfile endif endif # End IFTEST for -e $SOURCE/holding/$collection/$date due to possible deletion from other archive job end endif @ begloc = $endloc + 1 @ m = $m + 1 end wait # Submit Archive Job # ------------------ set test = `cat $archfile` if( $#test != 0 ) then cat $SOURCE/archive/gcm_archive.j $archfile > $SOURCE/archive/gcm_archive.$streamdates[1].j cd $SOURCE/archive /bin/rm -f sedfile /bin/mv -f gcm_archive.$streamdates[1].j tmpfile cat > sedfile << EOF s/OUTPUT/gcm_archive.$streamdates[1].o/g EOF sed -f sedfile tmpfile > gcm_archive.$streamdates[1].j chmod +x gcm_archive.$streamdates[1].j if( $HOST == 'pleiades' ) then ./gcm_archive.$streamdates[1].j else qsub gcm_archive.$streamdates[1].j endif /bin/rm -f $archfile /bin/rm -f sedfile /bin/rm -f tmpfile else /bin/rm -f $archfile endif ####################################################################### # Create Grads Data Description File (DDF) for Monthly Means ####################################################################### @ nstream = 0 foreach collection ( $collections ) @ nstream = $nstream + 1 @ date_node = $ndots[$nstream] + 4 cd $SOURCE/${collection} set monthlies = `/bin/ls -1 $expid.${collection}.monthly* | grep -v clim` set num = `/bin/ls -1 $monthlies | wc -l` if( $num != 0 ) then # Create DDF File # --------------- /bin/rm -f xdf.tabl # Extract Extension (last node) from Monthly Mean File # ---------------------------------------------------- @ m = 1 while( $m != 0 ) set dum = `echo $monthlies[1] | cut -d "." -f$m` if( .$dum != . ) then set ext = $dum @ m = $m + 1 else @ m = 0 endif end set date = `echo $monthlies[1] | cut -d "." -f${date_node}` set year = `echo $date | cut -c1-4` set month = `echo $date | cut -c5-6` set day = `echo $date | cut -c7-8` set hour = `echo $date | cut -c10-11` set expdsc = `grep EXPDSC: $HOMDIR/HISTORY.rc | cut -d" " -f2` set timinc = `grep PERPETUAL_YEAR: $HOMDIR/CAP.rc | grep -v \#` if( $#timinc == 0 ) then set timinc = "mo" else set timinc = "yr" endif if( $month == "01" ) set MON = JAN if( $month == "02" ) set MON = FEB if( $month == "03" ) set MON = MAR if( $month == "04" ) set MON = APR if( $month == "05" ) set MON = MAY if( $month == "06" ) set MON = JUN if( $month == "07" ) set MON = JUL if( $month == "08" ) set MON = AUG if( $month == "09" ) set MON = SEP if( $month == "10" ) set MON = OCT if( $month == "11" ) set MON = NOV if( $month == "12" ) set MON = DEC echo DSET $SOURCE/${collection}/$expid.${collection}.monthly.%y4%m2.$ext > xdf.tabl echo TITLE $expdsc >> xdf.tabl echo OPTIONS template >> xdf.tabl echo TDEF time $num LINEAR 00:00Z01$MON$year 1$timinc >> xdf.tabl endif # Endif for monthlies NUM = 0 check # Update Climatology Files # ------------------------ if( $num > 12 && ( $RECDATE == "NULL" || $CLIMO == "TRUE" ) ) then set date = `echo $monthlies[$num] | cut -d "." -f${date_node}` set month = `echo $date | cut -c5-6` $GEOSUTIL/post/gcmclim.script -source $SOURCE -collection $collection -month $month if( -e $SOURCE/${collection}/diurnal ) then $GEOSUTIL/post/gcmclim.script -source $SOURCE -collection $collection -month $month -diurnal endif if( $num >= 24 && $DDF == "NULL" ) set DDF = clim endif end # End ForEach Output Stream Loop ####################################################################### # Submit Quickplot Job # -------------------- # Note: $num, $monthlies, and ${date_node} # are from last output stream examined ####################################################################### if( $check_plot == "TRUE" && $RECDATE == "NULL" ) then cd $SOURCE/plot if(! -e plot.rc ) ln -s $GEOSUTIL/post/plot.rc . set STATUS = `grep PLOT_STATUS: plot.rc | cut -d'#' -f1 | cut -d':' -f2 | tr "[:lower:]" "[:upper:]"` set SEASONS = `grep PLOT_SEASONS: plot.rc | cut -d'#' -f1 | cut -d':' -f2 | tr "[:lower:]" "[:upper:]"` set FREQUENCY = `grep PLOT_FREQUENCY: plot.rc | cut -d'#' -f1 | cut -d':' -f2 | tr "[:lower:]" "[:upper:]"` set CMPEXP = `grep PLOT_CMPEXP: plot.rc | cut -d'#' -f1 | cut -d':' -f2 ` set MISCTMP = `grep PLOT_MISC: plot.rc | cut -d'#' -f1 | tr "[:lower:]" "[:upper:]"` set MISC = '' set miscnum = $#MISCTMP if( $#miscnum != 0 ) then @ m = 2 while( $m <= $miscnum ) set MISC = `echo $MISC $MISCTMP[$m]` @ m = $m + 1 end endif set CMPEXP = `echo $CMPEXP` if( $STATUS == "ON" && $num > 0 ) then # At least 1 monthly mean exists set date = `echo $monthlies[$num] | cut -d "." -f${date_node}` set month = `echo $date | cut -c5-6` set year = `echo $date | cut -c1-4` set decade = `echo $year | cut -c3-4` if( $month == "01" ) set MON = JAN if( $month == "02" ) set MON = FEB if( $month == "03" ) set MON = MAR if( $month == "04" ) set MON = APR if( $month == "05" ) set MON = MAY if( $month == "06" ) set MON = JUN if( $month == "07" ) set MON = JUL if( $month == "08" ) set MON = AUG if( $month == "09" ) set MON = SEP if( $month == "10" ) set MON = OCT if( $month == "11" ) set MON = NOV if( $month == "12" ) set MON = DEC set season = '' foreach case ($SEASONS) if( $MON == $case ) set season = `echo $season $case ` if( $MON == "FEB" && $case == "DJF" && $num > 2 ) set season = `echo $season $case ` if( $MON == "MAY" && $case == "MAM" && $num > 2 ) set season = `echo $season $case ` if( $MON == "AUG" && $case == "JJA" && $num > 2 ) set season = `echo $season $case ` if( $MON == "OCT" && $case == "SON" && $num > 2 ) set season = `echo $season $case ` if( $MON == "DEC" && $case == "ANN" && $num > 11 ) set season = `echo $season $case ` endif end if( $season[1] != '' ) then if( $#CMPEXP != 0 ) set CMPEXP = `echo -cmpexp $CMPEXP` if( $FREQUENCY == "CLIM" ) then set plotsdir = $SOURCE/plots_CLIM set date = `echo $monthlies[1] | cut -d "." -f${date_node}` set year = `echo $date | cut -c1-4` set month = `echo $date | cut -c5-6` set begdate = ${year}${month} set date = `echo $monthlies[$num] | cut -d "." -f${date_node}` set year = `echo $date | cut -c1-4` set month = `echo $date | cut -c5-6` set enddate = ${year}${month} else set plotsdir = $SOURCE/plots_Y${year} if( $#season == 1 ) then if( $season == $MON ) then set begdate = ${year}${month} set enddate = ${year}${month} else if( $season == "ANN" ) then @ ndt = 11 * 30 * 86400 else @ ndt = 2 * 30 * 86400 endif set nymd = ${year}${month}15 set date = `$GEOSUTIL/post/tick $nymd 000000 -$ndt` set begdate = `echo $date[1] | cut -c1-6` set enddate = ${year}${month} endif else if( $season[1] == "ANN" || $season[2] == "ANN" ) then @ ndt = 11 * 30 * 86400 else @ ndt = 2 * 30 * 86400 endif set nymd = ${year}${month}15 set date = `$GEOSUTIL/post/tick $nymd 000000 -$ndt` set begdate = `echo $date[1] | cut -c1-6` set enddate = ${year}${month} endif endif # Create Plot Job Scripts # ----------------------- set ntypes = "1 2 3" foreach type ($ntypes) if( $type == "1" ) then set nplots = "ALL gwd turb.1 turb.2 moist.1 moist.2 moist.3 moist.4 tend.1 tend.2 tend.3 tend.4 tend.5 residual $MISC" else if ( $type == "2" ) then set nplots = "ALL" else if ( $type == "3" ) then set nplots = "ALL" endif foreach plot ($nplots) if( $type == "1" ) then set types = " -type $type " set plots = " -plots $plot " set noplot = "" if( $plot == "ALL" ) then set plots = "" set noplot = "-noplot tseries " foreach subplot ($nplots) if( $subplot != "ALL" ) set noplot = "$noplot $subplot" end endif if( $DDF == "clim" ) then set begplt = NULL set endplt = NULL else set begplt = $begdate set endplt = $enddate endif else if ( $type == "2" ) then set types = " -type $type " set plots = "" set noplot = " -noplot tseries " if( $DDF == "clim" ) then set begplt = NULL set endplt = NULL else set begplt = $begdate set endplt = $enddate endif else if ( $type == "3" ) then set types = "" set plots = " -plots tseries " set noplot = "" set begplt = $begdate set endplt = $enddate endif set fname = `echo ${MON}${decade}_${type}_${plot}` set bname = `echo ${fname} | cut -b1-15` set FILE = $fname.j /bin/rm -f FILE /bin/rm -f $FILE /bin/rm -f sedfile set PLOT_COMMANDS = "-source $SOURCE -season $season $types $plots $noplot -clim false $CMPEXP -plotsdir $plotsdir -begdate $begplt -enddate $endplt" cat gcm_plot.j > FILE cat > sedfile << EOF s|${expid}_PLT|$bname|g s|OUTPUT|$bname.o|g s|@PLOT_COMMANDS|$PLOT_COMMANDS|g EOF sed -f sedfile FILE > $FILE qsub $FILE /bin/rm -f FILE /bin/rm -f sedfile end # End plot Loop end # End type Loop # ----------------------- endif # End season test endif # End num test endif # End check_plot test