#!/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 # # +-======-+ ####################################################################### # Batch Parameters for Run Job ####################################################################### #PBS -l walltime=@RUN_T #@RUN_P #PBS -N @RUN_N #@RUN_Q #@BATCH_GROUP ####################################################################### # System Environment Variables ####################################################################### umask 022 limit stacksize unlimited @SETENVS ####################################################################### # Architecture Specific Environment Variables ####################################################################### setenv ARCH `uname` setenv SITE @SITE setenv GEOSDIR @GEOSDIR setenv GEOSBIN @GEOSBIN setenv RUN_CMD "@RUN_CMD" setenv GCMVER @GCMVER source $GEOSBIN/g5_modules setenv LD_LIBRARY_PATH ${LD_LIBRARY_PATH}:${BASEDIR}/${ARCH}/lib ####################################################################### # Experiment Specific Environment Variables ####################################################################### setenv EXPID @EXPID setenv EXPDIR @EXPDIR setenv HOMDIR @HOMDIR setenv SCRDIR $EXPDIR/scratch ####################################################################### # Create Experiment Sub-Directories ####################################################################### if (! -e $EXPDIR/restarts ) mkdir -p $EXPDIR/restarts if (! -e $EXPDIR/holding ) mkdir -p $EXPDIR/holding if (! -e $EXPDIR/archive ) mkdir -p $EXPDIR/archive if (! -e $EXPDIR/post ) mkdir -p $EXPDIR/post if (! -e $EXPDIR/plot ) mkdir -p $EXPDIR/plot if (! -e $SCRDIR ) mkdir -p $SCRDIR ####################################################################### # Set Experiment Run Parameters ####################################################################### set NX = `grep NX: $HOMDIR/AGCM.rc | cut -d':' -f2` set NY = `grep NY: $HOMDIR/AGCM.rc | cut -d':' -f2` set AGCM_IM = `grep AGCM_IM: $HOMDIR/AGCM.rc | cut -d':' -f2` set AGCM_JM = `grep AGCM_JM: $HOMDIR/AGCM.rc | cut -d':' -f2` set AGCM_LM = `grep AGCM_LM: $HOMDIR/AGCM.rc | cut -d':' -f2` set OGCM_IM = `grep OGCM_IM: $HOMDIR/AGCM.rc | cut -d':' -f2` set OGCM_JM = `grep OGCM_JM: $HOMDIR/AGCM.rc | cut -d':' -f2` set END_DATE = `grep END_DATE: $HOMDIR/CAP.rc | cut -d':' -f2` set NUM_SGMT = `grep NUM_SGMT: $HOMDIR/CAP.rc | cut -d':' -f2` >>>COUPLED<<>>COUPLED<< $NCPUS ) then echo "CPU Resources are Over-Specified" echo "--------------------------------" echo "Allotted NCPUs: $NCPUS" echo "Specified NX : $NX" echo "Specified NY : $NY" exit endif endif endif # Set ATMOS and OCEAN Horizontal Resolution Tags # ---------------------------------------------- set AGCM_IM_Tag = `echo $AGCM_IM | awk '{printf "%4.4i", $1}'` set AGCM_JM_Tag = `echo $AGCM_JM | awk '{printf "%4.4i", $1}'` set OGCM_IM_Tag = `echo $OGCM_IM | awk '{printf "%4.4i", $1}'` set OGCM_JM_Tag = `echo $OGCM_JM | awk '{printf "%4.4i", $1}'` >>>FVLATLON<<>>FVCUBED<<>>DATAOCEAN<<>>COUPLED<< $FILE #!/bin/ksh /bin/mv \$1 \$1.tmp touch \$1 while read line do echo \$line >> \$1 done < \$1.tmp exit EOF chmod +x $FILE ####################################################################### # Create HISTORY Collection Directories ####################################################################### set collections = '' foreach line ("`cat HISTORY.rc`") set firstword = `echo $line | awk '{print $1}'` set firstchar = `echo $firstword | cut -c1` set secondword = `echo $line | awk '{print $2}'` if ( $firstword == "::" ) goto done if ( $firstchar != "#" ) then set collection = `echo $firstword | sed -e "s/'//g"` set collections = `echo $collections $collection` if ( $secondword == :: ) goto done endif if ( $firstword == COLLECTIONS: ) then set collections = `echo $secondword | sed -e "s/'//g"` endif end done: foreach collection ( $collections ) if (! -e $EXPDIR/$collection ) mkdir $EXPDIR/$collection if (! -e $EXPDIR/holding/$collection ) mkdir $EXPDIR/holding/$collection end ####################################################################### # Link Boundary Datasets ####################################################################### setenv BCSDIR @BCSDIR setenv SSTDIR @SSTDIR setenv CHMDIR @CHMDIR setenv BCRSLV ${ATMOStag}_${OCEANtag} setenv DATELINE DC setenv EMISSIONS @EMISSIONS >>>COUPLED<<>>COUPLED<<>>DATAOCEAN<< $FILE #!/bin/csh -f >>>COUPLED<<>>COUPLED<<>>COUPLED<<>>COUPLED<<>>COUPLED<<>>COUPLED<<>>DATAOCEAN<<>>DATAOCEAN<<>>DATAOCEAN<<>>DATAOCEAN<<>>FVCUBED<<>>FVCUBED<<>>FVCUBED<<>>FVCUBED<<>>COUPLED<<>>COUPLED<<>>COUPLED<<>>COUPLED<<>>COUPLED<<>>DATAOCEAN<<> $FILE >>>DATAOCEAN<<> $FILE >>>DATAOCEAN<<> $FILE chmod +x linkbcs /bin/cp linkbcs $EXPDIR ####################################################################### # Get C2L History weights/index file for Cubed-Sphere ####################################################################### set C_NPX = `echo $AGCM_IM | awk '{printf "%5.5i", $1}'` set C_NPY = `echo $AGCM_JM | awk '{printf "%5.5i", $1}'` set H_NPX = `echo @HIST_IM | awk '{printf "%5.5i", $1}'` set H_NPY = `echo @HIST_JM | awk '{printf "%5.5i", $1}'` set c2l_file = "${C_NPX}x${C_NPY}_c2l_${H_NPX}x${H_NPY}.bin" if (-e $BCSDIR/$BCRSLV/${c2l_file}) /bin/ln -s $BCSDIR/$BCRSLV/${c2l_file} . ####################################################################### # Get Executable and RESTARTS ####################################################################### /bin/cp $EXPDIR/GEOSgcm.x . set rst_types = `cat AGCM.rc | grep "RESTART_FILE" | cut -d ":" -f1 | cut -d "_" -f1-2` set chk_types = `cat AGCM.rc | grep "CHECKPOINT_FILE" | cut -d ":" -f1 | cut -d "_" -f1-2` set rst_files = `cat AGCM.rc | grep "RESTART_FILE" | cut -d ":" -f2` set chk_files = `cat AGCM.rc | grep "CHECKPOINT_FILE" | cut -d ":" -f2` # Remove possible bootstrap parameters (+/-) # ------------------------------------------ set dummy = `echo $rst_files` set rst_files = '' foreach rst ( $dummy ) set length = `echo $rst | awk '{print length($0)}'` set bit = `echo $rst | cut -c1` if( "$bit" == "+" | \ "$bit" == "-" ) set rst = `echo $rst | cut -c2-$length` set rst_files = `echo $rst_files $rst` end # Copy Restarts to Scratch Directory # ---------------------------------- foreach rst ( $rst_files ) if(-e $EXPDIR/$rst ) /bin/cp $EXPDIR/$rst . & end wait >>>COUPLED<<>>COUPLED<<< /bin/cp -r $EXPDIR/RESTART ${EXPDIR}/restarts/RESTART.${edate} cd $EXPDIR/restarts tar cf restarts.${edate}.tar $EXPID.*.${edate}.${GCMVER}.${BCTAG}_${BCRSLV} /bin/rm -rf `/bin/ls -d -1 $EXPID.*.${edate}.${GCMVER}.${BCTAG}_${BCRSLV}` cd $SCRDIR endif ################################################################## ###### ###### Perform multiple iterations of Model Run ###### ################################################################## @ counter = 1 while ( $counter <= ${NUM_SGMT} ) /bin/rm -f EGRESS /bin/cp -f $HOMDIR/CAP.rc . ./strip CAP.rc # Set Time Variables for Current_(c), Ending_(e), and Segment_(s) dates # --------------------------------------------------------------------- set nymdc = `cat cap_restart | cut -c1-8` set nhmsc = `cat cap_restart | cut -c10-15` set nymde = `cat CAP.rc | grep END_DATE: | cut -d: -f2 | cut -c2-9` set nhmse = `cat CAP.rc | grep END_DATE: | cut -d: -f2 | cut -c11-16` set nymds = `cat CAP.rc | grep JOB_SGMT: | cut -d: -f2 | cut -c2-9` set nhmss = `cat CAP.rc | grep JOB_SGMT: | cut -d: -f2 | cut -c11-16` # Compute Time Variables at the Finish_(f) of current segment # ----------------------------------------------------------- set nyear = `echo $nymds | cut -c1-4` set nmonth = `echo $nymds | cut -c5-6` set nday = `echo $nymds | cut -c7-8` set nhour = `echo $nhmss | cut -c1-2` set nminute = `echo $nhmss | cut -c3-4` set nsec = `echo $nhmss | cut -c5-6` @ dt = $nsec + 60 * $nminute + 3600 * $nhour + 86400 * $nday set nymdf = $nymdc set nhmsf = $nhmsc set date = `$GEOSBIN/tick $nymdf $nhmsf $dt` set nymdf = $date[1] set nhmsf = $date[2] set year = `echo $nymdf | cut -c1-4` set month = `echo $nymdf | cut -c5-6` set day = `echo $nymdf | cut -c7-8` @ month = $month + $nmonth while( $month > 12 ) @ month = $month - 12 @ year = $year + 1 end @ year = $year + $nyear @ nymdf = $year * 10000 + $month * 100 + $day if( $nymdf > $nymde ) set nymdf = $nymde if( $nymdf == $nymde ) then if( $nhmsf > $nhmse ) set nhmsf = $nhmse endif set yearc = `echo $nymdc | cut -c1-4` set yearf = `echo $nymdf | cut -c1-4` # For MERRA-2 and OSTIA, Modify local CAP.rc Ending date if Finish time exceeds Current year boundary # --------------------------------------------------------------------------------------------------- if( ${OCEANtag} == DE1440xPE0720 | \ ${OCEANtag} == DE2880xPE1440 ) then if( $yearf > $yearc ) then @ yearf = $yearc + 1 @ nymdf = $yearf * 10000 + 0101 set oldstring = `cat CAP.rc | grep END_DATE:` set newstring = "END_DATE: $nymdf $nhmsf" /bin/mv CAP.rc CAP.tmp cat CAP.tmp | sed -e "s?$oldstring?$newstring?g" > CAP.rc endif endif # Select proper MERRA-2 GOCART Emission RC Files # ---------------------------------------------- if( ${EMISSIONS} == MERRA2 ) then set MERRA2_Transition_Date = 20000401 if( $nymdc < ${MERRA2_Transition_Date} ) then set MERRA2_EMISSIONS_DIRECTORY = $GEOSDIR/$ARCH/etc/MERRA2/19600101-20000331 if( $nymdf > ${MERRA2_Transition_Date} ) then set nymdf = ${MERRA2_Transition_Date} set oldstring = `cat CAP.rc | grep END_DATE:` set newstring = "END_DATE: $nymdf $nhmsf" /bin/mv CAP.rc CAP.tmp cat CAP.tmp | sed -e "s?$oldstring?$newstring?g" > CAP.rc endif else set MERRA2_EMISSIONS_DIRECTORY = $GEOSDIR/$ARCH/etc/MERRA2/20000401-present endif if( $AGCM_LM == 72 ) then /bin/cp --remove-destination ${MERRA2_EMISSIONS_DIRECTORY}/*.rc . else set files = `/bin/ls -1 ${MERRA2_EMISSIONS_DIRECTORY}/*.rc` foreach file ($files) /bin/rm -f `basename $file` /bin/rm -f dummy /bin/cp $file dummy cat dummy | sed -e "s|/L72/|/L${AGCM_LM}/|g" | sed -e "s|z72|z${AGCM_LM}|g" > `basename $file` end endif endif # Link Boundary Conditions for Appropriate Date # --------------------------------------------- setenv YEAR $yearc ./linkbcs if (! -e tile.bin) then $GEOSBIN/binarytile.x tile.data tile.bin endif # Run GEOSgcm.x # ------------- @ NPES = $NX * $NY $RUN_CMD $NPES ./GEOSgcm.x if( -e EGRESS ) then set rc = 0 else set rc = -1 endif echo GEOSgcm Run Status: $rc ####################################################################### # Rename Checkpoints => Restarts for Next Segment and Archive # Note: cap_restart contains the current NYMD and NHMS ####################################################################### set edate = e`cat cap_restart | cut -c1-8`_`cat cap_restart | cut -c10-11`z set numrst = `echo $rst_types | wc -w` set numchk = `echo $chk_types | wc -w` @ n = 1 @ z = $numrst + 1 while ( $n <= $numchk ) if ( -e $chk_files[$n] ) then @ m = 1 while ( $m <= $numrst ) if( $chk_types[$n] == $rst_types[$m] || \ \#$chk_types[$n] == $rst_types[$m] ) then set chk_ext = `cat AGCM.rc | grep ${chk_types[$n]}_CHECKPOINT_TYPE | cut -d: -f2` if( $chk_ext =~ *nc4 ) set ext = nc4 if( $chk_ext =~ *binary ) set ext = bin /bin/mv $chk_files[$n] $rst_files[$m] /bin/cp $rst_files[$m] ${EXPDIR}/restarts/$EXPID.${rst_files[$m]}.${edate}.${GCMVER}.${BCTAG}_${BCRSLV}.$ext & @ m = $numrst + 999 else @ m = $m + 1 endif end wait if( $m == $z ) then echo "Warning!! Could not find CHECKPOINT/RESTART match for: " $chk_types[$n] exit endif endif @ n = $n + 1 end >>>COUPLED<<>>COUPLED<<>>COUPLED<<<# MOM-Specific Output Files >>>COUPLED<<<# ------------------------- >>>COUPLED<<< set dsets="ocean_month" >>>COUPLED<<< foreach dset ( $dsets ) >>>COUPLED<<< set num = `/bin/ls -1 $dset.nc | wc -l` >>>COUPLED<<< if($num != 0) then >>>COUPLED<<< if(! -e $EXPDIR/MOM_Output) mkdir -p $EXPDIR/MOM_Output >>>COUPLED<<< /bin/mv $SCRDIR/$dset.nc $EXPDIR/MOM_Output/$dset.${edate}.nc >>>COUPLED<<< endif >>>COUPLED<<< end >>>COUPLED<<< ####################################################################### # Submit Post-Processing (if necessary) ####################################################################### if( $num_waiting_files == 0 ) then cd $EXPDIR/post /bin/rm -f sedfile cat > sedfile << EOF s/@POST_O/gcm_post.${edate}/g EOF sed -f sedfile gcm_post.j > gcm_post.jtmp chmod 755 gcm_post.jtmp qsub gcm_post.jtmp /bin/rm -f gcm_post.jtmp /bin/rm -f sedfile cd $SCRDIR endif ####################################################################### # Update Iteration Counter ####################################################################### set enddate = `echo $END_DATE | cut -c1-8` set capdate = `cat cap_restart | cut -c1-8` if ( $capdate < $enddate ) then @ counter = $counter + 1 else @ counter = ${NUM_SGMT} + 1 endif end ####################################################################### # Re-Submit Job ####################################################################### foreach rst ( $rst_files ) /bin/rm -f $EXPDIR/$rst end /bin/rm -f $EXPDIR/cap_restart foreach rst ( $rst_files ) /bin/cp $rst $EXPDIR/$rst & end wait /bin/cp cap_restart $EXPDIR/cap_restart >>>COUPLED<<