#!/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 #PBS -l @RUN_P #PBS -N @RUN_N #PBS -q @RUN_Q #PBS -W group_list=@GROUP ####################################################################### # System Environment Variables ####################################################################### umask 022 limit stacksize unlimited @SETENVS ####################################################################### # Architecture Specific Environment Variables ####################################################################### setenv ARCH `uname` setenv SITE @SITE setenv GEOSBIN @GEOSBIN setenv RUN_CMD "@RUN_CMD" 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` # Check for Over-Specification of CPU Resources # --------------------------------------------- if ($?PBS_NODEFILE) then set NCPUS = `qstat -f $PBS_JOBID | grep -i Resource_List.ncpus | cut -d'=' -f2` @ NPES = $NX * $NY if( $NPES > $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 ####################################################################### # Move to Scratch Directory and Copy RC Files from Home Directory ####################################################################### cd $SCRDIR /bin/rm -rf * /bin/ln -sf $EXPDIR/RC/* . /bin/cp $EXPDIR/cap_restart . /bin/cp -f $HOMDIR/*.rc . ####################################################################### # 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 DATELINE DC >>>COUPLED<< $FILE #!/bin/csh -f >>>COUPLED<<>>COUPLED<<>>COUPLED<<>>COUPLED<<>>COUPLED<<>>COUPLED<<>>DATAOCEAN<<>>DATAOCEAN<<>>DATAOCEAN<<>>DATAOCEAN<<>>FVLATLON<<>>FVCUBED<<>>FVCUBED<<>>COUPLED<<>>COUPLED<<>>COUPLED<<>>COUPLED<<>>COUPLED<<>>COUPLED<<>>COUPLED<<< /bin/cp $EXPDIR/RESTART ${EXPDIR}/restarts/RESTART.${edate} cd $EXPDIR/restarts tar cf restarts.${edate}.tar *.${edate} /bin/rm -rf `ls -1 *.${edate}` cd $SCRDIR endif ################################################################## ###### ###### Perform multiple iterations of Model Run ###### ################################################################## @ counter = 1 while ( $counter <= ${NUM_SGMT} ) @ NPES = $NX * $NY $RUN_CMD $NPES ./GEOSgcm.x set rc = $status echo 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 /bin/mv $chk_files[$n] $rst_files[$m] /bin/cp $rst_files[$m] ${EXPDIR}/restarts/${rst_files[$m]}.${edate} @ m = $numrst + 999 else @ m = $m + 1 endif end 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<<< ####################################################################### # Perform Post Processing ####################################################################### 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 if( ( $SITE == "NAS" ) & \ ( $AGCM_IM == "45" | \ $AGCM_IM == "90" | \ $AGCM_IM == "144" | \ $AGCM_IM == "288" ) ) then nohup ssh -t bridge1 "$EXPDIR/post/gcm_post.jtmp > $EXPDIR/post/gcm_post.${edate} ; \ /bin/rm -f $EXPDIR/post/gcm_post.jtmp &" else qsub gcm_post.jtmp /bin/rm -f gcm_post.jtmp endif /bin/rm -f sedfile cd $SCRDIR ####################################################################### # 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 /bin/cp cap_restart $EXPDIR/cap_restart >>>COUPLED<<