#!/bin/tcsh -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 # # +-======-+ if ( ! $?GEOSUTIL ) then echo " " echo Environment variable GEOSUTIL must be defined before use! echo Set GEOSUTIL to the directory path of the GEOS_util module echo " " exit 1 endif @ nmax = $#argv # ------------------- if( $nmax == 0 ) then Usage: echo " " echo "Usage:" echo "-----" echo "quickstat -rc STATS_RC" echo " [-exps EXPS]" echo " [-fields FIELDS]" echo " [-plots PLOTS]" echo " [-output OUTPUT]" echo " [-gradsx GRADSX]" echo " " echo "where: STATS_RC: is the full path (including filename) of the stats resource file to use " echo " EXPS: Experiment IDs to plot (e.g., 0 1 3 4 ) (Default: ALL experiments in STATS_RC) " echo " FIELDS: Fields to plot (e.g., p u v ) (Default: p u v t q h) " echo " PLOTS: Plot Types (corcmp, sys, syscmp) (Default: ALL) " echo " OUTPUT: Output directory to contain plots (Default: STATS_RC directory) " echo " GRADSX: GrADS executable to use for processing (Default: grads) " echo " " echo "Note: Plots will be located in experiment sub-directories under OUTPUT " echo " " exit 1 endif # Set Variables # ------------- set statsrc = NULL set output = NULL set gradsx = grads set exps = ALL set plots = "corcmp pltsys syscmp" set fields = "p u v t q h chi psi" # Parse command line # ------------------ @ n = 1 while( $n <= $nmax ) if( "$argv[$n]" == "-rc" ) then @ n = $n + 1 set statsrc = $argv[$n] endif if( "$argv[$n]" == "-gradsx" ) then @ n = $n + 1 set gradsx = $argv[$n] endif if( "$argv[$n]" == "-output" ) then @ n = $n + 1 set output = $argv[$n] endif if( "$argv[$n]" == "-exps" ) then @ n = $n + 1 set exps = "" set next = $argv[$n] set bit = `echo $next | cut -c1-1` while( "$bit" != "-" ) set exps = `echo $exps $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 if( "$argv[$n]" == "-plots" ) then @ n = $n + 1 set plots = "" set next = $argv[$n] if( "$next" == "sys" ) set next = pltsys set bit = `echo $next | cut -c1-1` while( "$bit" != "-" ) set plots = `echo $plots $next` @ n = $n + 1 if( $n <= $nmax ) then set next = $argv[$n] if( "$next" == "sys" ) set next = pltsys set bit = `echo $next | cut -c1-1` else set bit = "-" endif end @ n = $n - 1 endif if( "$argv[$n]" == "-fields" ) then @ n = $n + 1 set fields = "" set next = $argv[$n] set bit = `echo $next | cut -c1-1` while( "$bit" != "-" ) set fields = `echo $fields $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 if( $statsrc == NULL | -d $statsrc ) then echo ' ' echo '\!\! You must enter the full path (including filename) of the stats.rc to use \!\!' goto Usage exit endif set rcfile = `basename $statsrc` setenv GRADSX $gradsx # Determine ROOT directory containing stats.rc # -------------------------------------------- @ n = 1 set root = `echo $statsrc | cut -d / -f$n` while( .$root == . ) @ n = $n + 1 set root = `echo $statsrc | cut -d / -f$n` end set ROOTDIR = '' while( $root != $rcfile ) set ROOTDIR = `echo ${ROOTDIR}/${root}` @ n = $n + 1 set root = `echo $statsrc | cut -d / -f$n` end # Set SOURCE directory containing Plots # ------------------------------------- if( $output == NULL ) then setenv SOURCE $ROOTDIR else if(! -e $output ) mkdir -p $output setenv SOURCE $output if(-e $output/$rcfile ) /bin/rm -f $output/$rcfile /bin/ln -sf $statsrc $output endif # Configure QUICKSTAT to Computing Platform # ----------------------------------------- cd $SOURCE $GEOSUTIL/plots/configure source $SOURCE/.quickplotrc # Determine Experiments to plot # ----------------------------- if( $exps[1] == ALL ) then set allexps = `grep "EXP.*:" $rcfile | grep -v \#` @ numexps = $#allexps / 2 set exps = '' @ n = 1 while ($n <= $numexps ) @ loc = $n * 2 - 1 set len1 = `echo $allexps[$loc] | awk '{print length($0)}'` @ len2 = $len1 - 1 set exp = `echo $allexps[$loc] | cut -c4-$len2` set exps = `echo $exps $exp` @ n = $n + 1 end endif echo " " echo " ARCH = " `uname` echo " HOST = " `hostname` echo " GRADS = " $GRADS echo " GEOSUTIL = " $GEOSUTIL echo " OUTPUT = " $SOURCE echo " STATS_RC = " $statsrc echo " EXPS = " $exps echo " FIELDS = " $fields echo " PLOTS = " $plots echo " " # Run Grads-Based Quickstat Utility for Anomaly Correlation Comparison # -------------------------------------------------------------------- if( "$plots" =~ *corcmp* ) then $GRADS -l -b -c "run $GEOSUTIL/plots/fcst/pltcorcmp -source $SOURCE -rc $rcfile -fields $fields" & wait endif # Run Grads-Based Quickstat Utility for Systematic Error # ------------------------------------------------------ if( "$plots" =~ *pltsys* ) then set tmpdirs = "" foreach exp ($exps) foreach field ($fields) set pltdir = $SOURCE/pltsys_scratch/EXP${exp}_$field.`date +%Y%m%d_%H%M%S` mkdir -p $pltdir cd $pltdir ; set tmpdirs = `echo $tmpdirs $pltdir` $GRADS -l -b -c "run pltsys.gs -exp $exp -field $field -rc $rcfile" & sleep 5 end end wait endif # Run Grads-Based Quickstat Utility for Systematic Error Comparison # ----------------------------------------------------------------- if( "$plots" =~ *syscmp* ) then set tmpdirs = "" foreach exp ($exps) if( $exp != 0 ) then foreach field ($fields) set pltdir = $SOURCE/syscmp_scratch/EXP${exp}_$field.`date +%Y%m%d_%H%M%S` mkdir -p $pltdir cd $pltdir ; set tmpdirs = `echo $tmpdirs $pltdir` $GRADS -l -b -c "run $GEOSUTIL/plots/fcst/setup_statd -exps 0 $exp -fields $field -rc $rcfile" & sleep 5 end endif end wait endif # Sleep for 1 minutes to ensure all plots are finished # ---------------------------------------------------- sleep 1m # Reset Environment # ----------------- cd $SOURCE /bin/rm -rf $tmpdirs exit