#! /usr/bin/csh -f ## This script builds cam and creates a run script setenv LIB_NETCDF /usr/local/lib64/r4i4 setenv INC_NETCDF /usr/local/include ## ROOT OF CAM DISTRIBUTION - probably needs to be customized. set camroot = /fs/cgd/data0/$LOGNAME/cam2_0_2_dev50/cam1 ## ROOT OF CAM DATA DISTRIBUTION - needs to be customized unless running at NCAR. setenv CSMDATA /fs/cgd/csm/inputdata ## Set compile options # $dycore is the dynamical core: sld, eul, or fv. # $resolution: for sld or eul: 128x256, 64x128, 32x64, or 8x16; for fv: 2x2.5, 4x5, or 10x15 # $usr_src specifies location of user-modified files: 'none', or valid directory. # $caseid if for notes to myself - keep it short!!! #set dycore = sld #set dycore = fv set dycore = eul #set usr_src = /fs/cgd/data0/$LOGNAME/rio33nom set usr_src = /fs/cgd/home0/$LOGNAME/empty set caseid = d50 ## Default namelist settings: ## $case is the case identifier for this run. It will be placed in the namelist. ## $nelapse is the number of timesteps to integrate, or number of days if negative. if ( $dycore == 'fv' ) then set resolution = 2x2.5 set resolution = 1x1.25 # set resolution = 4x5 # set nelapse = -490 # set nelapse = -578 set nelapse = -245 else set resolution = 64x128 set resolution = 128x256 set nelapse = -490 # set nelapse = -771 set nelapse = -300 endif set nlev = 26 set case = ${dycore}${resolution}_$caseid ## $wrkdir is a working directory where the model will be built and run. ## $blddir is the directory where model will be compiled. ## $rundir is the directory where the model will be run. ## $cfgdir is the directory containing the CAM configuration scripts. set wrkdir = /ptmp/$LOGNAME set blddir = $wrkdir/$case/bld set rundir = $wrkdir/$case/rundir set cfgdir = $camroot/models/atm/cam/bld ## Ensure that run and build directories exist mkdir -p $rundir || echo "cannot create $rundir" && exit 1 mkdir -p $blddir || echo "cannot create $blddir" && exit 1 cp $0 $rundir/buildscript.csh ## If an executable doesn't exist, build one. if ( ! -x $blddir/cam ) then cd $blddir || echo "cd $blddir failed" && exit 1 ## Control case $cfgdir/configure \ -dyn $dycore \ -res $resolution \ -usr_src $usr_src \ -sst -nlev $nlev \ || echo "configure failed" && exit 1 echo "building CAM in $blddir ..." rm -f Depends gmake -j32 >&! MAKE.out || echo "CAM build failed: see $blddir/MAKE.out" && exit 1 else echo Found $blddir/cam - not building a new one. endif ## Create the namelist cd $blddir || echo "cd $blddir failed" && exit 1 echo "Building the namelist." $cfgdir/build-namelist -s \ -case $case \ -runtype initial \ -o $rundir/namelist \ -namelist "&camexp nelapse=$nelapse,mss_irt=0,sstcyc=.false. /" \ || echo "build-namelist failed" && exit 1 ## Create the run script in $rundir echo "Building the run script." cat >! $rundir/run-cam.csh << EOF #!/usr/local/bin/tcsh -f ## Load leveler options ## If using csl_rg32, set node = 2 and tasks_per_node = 8 ## If using csl_rg8, set node = 8 and tasks_per_node = 2 ## These yield 64 total processors. #@ class = csl_rg32 #@ account_no = 93300080 #@ node = 4 #@ tasks_per_node = 8 #@ job_name = $case #@ shell = /usr/bin/csh #@ output = \$(job_name).\$(stepid).out #@ error = \$(job_name).\$(stepid).err #@ job_type = parallel #@ network.MPI = csss,not_shared,us #@ node_usage = not_shared #@ wall_clock_limit = 21600 #@ queue ## POE Environment. Set these for interactive jobs. They're ignored by LoadLeveler. setenv MP_ADAPTER_USE shared setenv MP_CPU_USE unique setenv MP_EUIDEVICE csss setenv MP_EUILIB us setenv MP_MSG_API MPI setenv MP_EUILIB us setenv MP_RMPOOL 1 setenv MP_SHARED_MEMORY yes setenv MP_PROCS 8 setenv MP_NODES 2 setenv MP_TASKS_PER_NODE 4 ## More environment variables. These are necessary for both batch and interactive jobs. setenv MP_SHARED_MEMORY yes setenv OMP_NUM_THREADS 4 setenv XLSMPOPTS "stack=86000000" limit stacksize unlimited ## Run CAM cd $rundir touch output.txt echo "Beg:: "\`date\` \`perl -e 'print time();'\` >> output.txt poe time $blddir/cam < namelist >>& output.txt set year = \`grep restart\ file output.txt | tail -1 | sed s/^.\*.r.// | sed s/-.\*\\\$//\` cat namelist | sed s/nsrest.\*=.\*0/nsrest\ =\ 1/ > temp.namelist \mv temp.namelist namelist if ( \$year < 002 ) then echo Year is \${year}, resubmitting. llsubmit run-cam.csh else touch $case.done setenv CASE $case /fs/cgd/home0/jmccaa/scripts/mkclimo.csh endif echo "End:: "\`date\` \`perl -e 'print time();'\` >> output.txt EOF chmod +x $rundir/run-cam.csh exit 0