#!/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 # # +-======-+ # Create true comma-separated HISTORY variable # -------------------------------------------- if( -e HISTORY.T ) /bin/rm HISTORY.T cat HISTORY.rc | sed -e 's/,/ , /g' > HISTORY.T set HISTORY = `cat HISTORY.T` set numwords = $#HISTORY # 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 # Find Templates # -------------- set templates = '' foreach collection ($collections) @ n = 1 while( $n <= $numwords ) if( $HISTORY[$n] == ${collection}.template: ) then @ m = $n + 1 set template = `echo $HISTORY[$m] | sed -e "s/'//g"` set templates = `echo $templates $template` @ n = $numwords + 1000 endif @ n = $n + 1 end if( $n == $numwords + 1 ) set templates = `echo $templates NULL` end # Echo Collections and Templates # ------------------------------ echo " " @ n = 0 foreach collection ($collections) @ n = $n + 1 echo "List(${n}): $collection Template(${n}): $templates[$n]" end # Create SEDFILE # -------------- if( -e sedfile ) /bin/rm sedfile touch sedfile @ L = 0 foreach collection ($collections) @ L = $L + 1 set list = "list("${L}")%" if( "$templates[$L]" == "NULL" ) then set filename = $collection else set filename = "%s.${collection}.$templates[$L]" endif echo /${collection}.fields/ i\\${list}filename: \'${filename}\' , >> sedfile echo /${collection}.template/d >> sedfile echo s/${collection}./$list/g >> sedfile echo /COLLECTIONS:/,/::/d >> sedfile end if( -e HISTORY.rcold ) /bin/rm HISTORY.rcold sed -f sedfile HISTORY.T > HISTORY.rcold exit