#!/bin/csh # +-======-+ # 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 # # +-======-+ set EXPORT = $1 set GC = $2 if( .$3 == . ) then set source = $SOURCE else set source = $3 endif set base = `basename $source` set arch = `uname` # Set Defaults # ------------ set expdsc = NULL set alias = NULL set output = NULL set format = NULL set scale = 1.0 @ ncoll = 0 # Create true comma-separated HISTORY variable # -------------------------------------------- if(! -e HISTORY.T ) then cat $HISTORYRC | sed -e 's/,/ , /g' > HISTORY.T endif set HISTORY = `cat HISTORY.T` set numwords = $#HISTORY # Find Experiment Description # --------------------------- @ n = 0 @ numword = 1 while( $numword <= $numwords ) set word = $HISTORY[$numword] @ numword = $numword + 1 @ n = $n + 1 @ m = $n + 1 if( $word == EXPDSC: ) then set expdsc = $HISTORY[$m] endif end # Find Collections # ---------------- @ n = 1 while( $n <= $numwords ) if( $HISTORY[$n] == COLLECTIONS: ) then set collections = '' @ m = $n + 1 while( $HISTORY[$m] != "::" ) set collection = `echo $HISTORY[$m] | sed -e "s/'//g"` set collections = `echo $collections $collection` @ m = $m + 1 end @ n = $numwords + 1 endif @ n = $n + 1 end set num_collections = $#collections # Find EXPORT and GC within Collection # ------------------------------------ if( $arch == 'IRIX64' ) set catargs = "-ve" if( $arch == 'Linux' ) set catargs = "-E" if( $arch == 'OSF1' ) set catargs = "-E" set temp = `cat $catargs HISTORY.T` set ntemp = $#temp set found = FALSE @ n = 1 while( $n <= $ntemp ) @ m = 0 foreach collection ($collections) @ m = $m + 1 if( $temp[$n] == ${collection}.fields: ) then set dum = '' @ k = $n while( "$dum" != "::" ) @ k = $k + 1 set QEXPORT = `echo $temp[$k] | sed -e "s/'//g"` ; @ k = $k + 2 set QGC = `echo $temp[$k] | sed -e "s/'//g"` ; @ k = $k + 2 if( "$temp[$k]" == '$' ) then set QALIAS = $QEXPORT else set QALIAS = `echo $temp[$k] | sed -e "s/'//g"` ; @ k = $k + 2 endif @ k = $k + 1 set dum = `echo $temp[$k] | cut -b1-2` @ k = $k - 1 if( $EXPORT == $QEXPORT && $GC == $QGC ) then set found = TRUE set alias = $QALIAS @ ncoll = $m endif end endif end if( $found == TRUE ) @ n = $ntemp @ n = $n + 1 end # Find Collection Attributes # -------------------------- if( $ncoll != 0 ) then set output = '' set format = '' foreach collection ($collections) set dummy = `grep ${collection}.grads_ddf HISTORY.T | cut -d: -f2 | cut -d, -f1 | sed -e "s/'//g"` if( "$dummy" == "" ) set dummy = `grep ${collection}.grads_ctl HISTORY.T | cut -d: -f2 | cut -d, -f1 | sed -e "s/'//g"` if( "$dummy" == "" ) set dummy = `echo ${source}/${collection}/xdf.tabl` set output = `echo $output $dummy` set dummy = `grep ${collection}.format HISTORY.T | cut -d: -f2 | cut -d, -f1 | sed -e "s/'//g"` if( "$dummy" == "" ) set dummy = flat set format = `echo $format $dummy` end else @ ncoll = 1 endif # Export Results # -------------- setenv EXPDSC $expdsc setenv ALIAS $alias setenv OUTPUT $output[$ncoll] setenv FORMAT $format[$ncoll] setenv BASE $base echo ' ' echo "Number of History Output Streams: $num_collections" if( $EXPORT == $ALIAS ) then echo " Found: $EXPORT from GC: $GC" echo " CTL or DDF: ${OUTPUT}" echo " Format: ${FORMAT}" echo " Scaling: $scale" else echo " Found: $EXPORT (aka: ${ALIAS}) from GC: $GC" echo " CTL or DDF: ${OUTPUT}" echo " Format: ${FORMAT}" echo " Scaling: $scale" endif echo ' ' if( -e hist.txt ) /bin/rm hist.txt touch hist.txt echo $EXPDSC >> hist.txt echo $ALIAS >> hist.txt echo $OUTPUT >> hist.txt echo $scale >> hist.txt echo $FORMAT >> hist.txt echo $BASE >> hist.txt