#!/bin/csh -f # +-======-+ # Copyright (c) 2003-2018 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 is a launcher for the QUICKPLOT utility # ------------------------------------------------------------------------- @ nmax = $#argv # Usage # ----- if( $nmax == 0 ) then echo " " echo "Usage:" echo "-----" echo "gcmplot.script -source SOURCE_DIRECTORY" echo " -season SEASON" echo " " echo " where: SOURCE_DIRECTORY is the directory containing the HISTORY.rc for experiment" echo " SEASON is the SEASON to plot " echo " " echo " <-begdate BEGDATE Optional Argument to use BEGDATE (YYYYMM) for plots>" echo " <-enddate ENDDATE Optional Argument to use BEGDATE (YYYYMM) for plots>" echo " <-history HISTORY.rc Optional Argument to use HISTORY.rc for plots>" echo " <-ddf clim Optional Argument to Use clim.tabl for plots>" echo " <-ana Optional Argument to use 'ana' Countours for plots>" echo " " echo "NOTE:" echo "----" echo "Environment variable GEOSUTIL must be defined before use\!" echo "GEOSUTIL must point to the build directory containing: src/GMAO_Shared/GEOS_Util" echo " " exit 1 endif if ( ! $?GEOSUTIL ) then echo " " echo "Environment variable GEOSUTIL must be defined before use\!" echo "GEOSUTIL must point to the build directory containing: src/GMAO_Shared/GEOS_Util" echo " " exit 1 endif # Process Input String # -------------------- set EXPID = 'NULL' set DDF = 'NULL' set HISTORYRC = "NULL" set SEASON = "NULL" set BEGDATE = "NULL" set ENDDATE = "NULL" set ANA = "" @ n = 1 while( $n <= $nmax ) if( "$argv[$n]" == "-source" ) then @ n = $n + 1 setenv SOURCE $argv[$n] endif if( "$argv[$n]" == "-expid" ) then @ n = $n + 1 set EXPID = $argv[$n] endif if( "$argv[$n]" == "-ana" ) then set ANA = '-ana' endif if( "$argv[$n]" == "-ddf" ) then @ n = $n + 1 set DDF = $argv[$n] endif if( "$argv[$n]" == "-history" ) then @ n = $n + 1 set HISTORYRC = $argv[$n] endif if( "$argv[$n]" == "-begdate" ) then @ n = $n + 1 set BEGDATE = $argv[$n] endif if( "$argv[$n]" == "-enddate" ) then @ n = $n + 1 set ENDDATE = $argv[$n] endif if( "$argv[$n]" == "-season" ) then @ n = $n + 1 set SEASON = "" set next = $argv[$n] set bit = `echo $next | cut -c1-1` while( "$bit" != "-" ) set SEASON = `echo $SEASON $next` @ n = $n + 1 if( $n <= $nmax ) then set next = $argv[$n] set bit = `echo $next | cut -c1-1` else set bit = "-" endif end @ n = $n - 1 endif @ n = $n + 1 end # Set HOMDIR # ---------- if( -e $SOURCE/.HOMDIR ) then setenv HOMDIR `cat $SOURCE/.HOMDIR` else setenv HOMDIR $SOURCE endif # Set HISTORYRC # ------------- if( $HISTORYRC == "NULL" ) then if( -e $HOMDIR/HISTORY.rc ) set HISTORYRC = $HOMDIR/HISTORY.rc endif if(! -e $HISTORYRC | -d $HISTORYRC ) then echo " " echo "You must supply the full pathname for your HISTORY.rc\!" echo " " exit 7 else set dummy = `grep COLLECTIONS: $HISTORYRC` if( "$dummy" == "" ) then echo " " echo "You must supply the full pathname for your HISTORY.rc\!" echo " " exit 7 endif endif # Extract EXPID # ------------- if( $EXPID == "NULL" ) then if( $HISTORYRC != "NULL" ) then set expid = `grep EXPID: $HISTORYRC | cut -d':' -f2` else set expid = `basename $SOURCE` endif else set expid = $EXPID endif setenv GROUP `cat $HOME/.GROUProot` # Determine Collection Names from HISTORY RC File # ----------------------------------------------- set collections = `$GEOSUTIL/post/get_streams $HISTORYRC` # Count Number of "Dots" in EXPID # ------------------------------- set edots = '' @ n = 0 @ b = 1 set bit = `echo ${expid} | cut -b $b` while( "${bit}" != '' ) if( "${bit}" == '.' ) then @ n = $n + 1 endif @ b = $b + 1 set bit = `echo ${expid} | cut -b $b` end set edots = $n # Count Number of "Dots" in Collection Name to Find Location of Date Node # ----------------------------------------------------------------------- set ndots = '' foreach collection ( $collections ) @ n = $edots @ 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` end # Check for PLOTS Option # ---------------------- set grads_ddfs = `grep grads_ddf $HISTORYRC | cut -d: -f2 | cut -d, -f1 | sed -e "s/'//g"` if( $#grads_ddfs == 0 ) then # Default Model Development Case (No grads_ddf attribute) # ------------------------------------------------------- cd $SOURCE/$collections[1] set monthlies = `/bin/ls -1 $expid.$collections[1].monthly* | grep -v clim` set num = `/bin/ls -1 $monthlies | wc -l` @ date_node = $ndots[1] + 4 if( $num >= 24 ) set DDF = clim else # Non-Default Case (Need to Find location of monthlies) # ----------------------------------------------------- set DSET = "NULL" @ n = 1 while( $DSET == "NULL" & $n <= $#grads_ddfs ) set TEST = `cat ${grads_ddfs[$n]} | grep -i DSET | cut -d' ' -f2` set FILE = `basename $TEST` set COLLECTION = `echo $FILE | cut -d. -f2` if( ! ($FILE =~ *const_2d*) ) then set DSET = $TEST else @ n = $n + 1 endif end if( $DSET == "NULL" ) then echo " " echo "There are no NON 'const_2d' COLLECTION names!" echo " " exit 7 endif @ m = 1 set PATH = '' set node = `echo $DSET | cut -d / -f$m ` while( $node != $FILE ) set node = `echo $node | sed -e 's/%y4/\#/g' ` set node = `echo $node | sed -e "s/%m2/\#/g" ` set node = `echo $node | sed -e "s/%d2/\#/g" ` set node = `echo $node | sed -e "s/%h2/\#/g" ` set node = `echo $node | sed -e "s/%n2/\#/g" ` set PATH = `echo ${PATH}/${node}` @ m = $m + 1 set node = `echo $DSET | cut -d / -f$m ` end set PATH = `echo $PATH/\#$COLLECTION.monthly\#` set monthlies = `echo $PATH | sed -e 's/\#/\*/g'` set num = `/bin/ls -1 $monthlies | wc -l` @ date_node = $ndots[1] + 4 endif ####################################################################### # Submit Quickplot Job # -------------------- # Note: $num, $monthlies, and ${date_node} # are from last output stream examined ####################################################################### cd $SOURCE/plot if(! -e plot.rc ) ln -s $GEOSUTIL/post/plot.rc . set FREQUENCY = `grep PLOT_FREQUENCY: plot.rc | cut -d'#' -f1 | cut -d':' -f2 | tr "[:lower:]" "[:upper:]"` set OPTIONS = `grep PLOT_OPTIONS: plot.rc | cut -d'#' -f1 | cut -d':' -f2 ` 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( $#CMPEXP != 0 ) then set CMPEXP = `echo -cmpexp $CMPEXP` endif ####################################################################### ####################################################################### if( $num > 0 ) then # At least 1 monthly mean exists ####################################################################### ####################################################################### if( $BEGDATE != "NULL" & $ENDDATE != "NULL" ) then @ n = 1 set date = '' while( $date == '' & $n <= $num ) set date = `echo $monthlies[$n] | grep $ENDDATE | cut -d "." -f${date_node}` @ n = $n + 1 end else set date = `echo $monthlies[$num] | cut -d "." -f${date_node}` endif set season = `echo $SEASON` 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 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 (ntype:1 => landscape.script, ntype:2 => portrait.script) # --------------------------------------------------------------------------------- set datetime = `date +%Y%m%d_%H%M%S` /bin/rm -f LIST_$datetime touch LIST_$datetime set ntypes = "1 2" foreach type ($ntypes) if( $type == "1" ) then set nplots = `$GEOSUTIL/plots/landscape.script -plots` set nplots = "$nplots $MISC" else if ( $type == "2" ) then set nplots = `$GEOSUTIL/plots/portrait.script -plots` set nplots = "$nplots $MISC" endif set nplots = `echo $nplots` # To remove blanks foreach plot ($nplots) set types = " -type $type " set plots = " -plots $plot " if( $DDF != "clim" | $plot == "tseries" ) then set begplt = $begdate set endplt = $enddate else set begplt = NULL set endplt = NULL endif set PLOT_COMMANDS = "-source $SOURCE \ -season $season \ $types \ $plots \ $CMPEXP \ -plotsdir $plotsdir \ -rc $HISTORYRC \ -begdate $begplt \ -enddate $endplt \ -clim false \ $ANA \ $OPTIONS " set PLOT_COMMANDS = `echo $PLOT_COMMANDS` # To remove blanks echo $PLOT_COMMANDS >> LIST_$datetime end # End plot Loop end # End type Loop /bin/cp -f LIST_$datetime MASTERLIST # ----------------------- @ njobs = 10 @ n = 1 while( $n <= $njobs ) set FILE = gcm_plot${n}.j set OFILE = gcm_plot${n}.o set bname = `echo ${expid}_PLT${n} | cut -b1-15` /bin/rm -f FILE /bin/rm -f $FILE /bin/rm -f sedfile cat gcm_plot.tmpl > FILE cat > sedfile << EOF s|${expid}_PLT|$bname|g s|OUTPUT|$OFILE|g s|@LIST|LIST_$datetime|g s|@N|$n|g EOF sed -f sedfile FILE > $FILE echo qsub $FILE /bin/rm -f FILE /bin/rm -f sedfile @ n = $n + 1 end ####################################################################### ####################################################################### endif # End num test ####################################################################### #######################################################################