#! /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 = /cgd/cms/$LOGNAME/cam2_0_2_dev86/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: 64x128, 32x64, or 8x16; for fv: 2x2.5, 4x5, or 10x15 # $caseid if for notes to myself - keep it short!!! #set dycore = sld set dycore = fv #set dycore = eul set caseid = d86amip ## 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 nelapse = -200 set sstdata = "'/fs/cgd/csm/inputdata/atm/cam2/sst/sst_HadOIBl_bc_2x2.5_1949_2001_c020531.nc'" else set resolution = 64x128 set nelapse = -771 set sstdata = "'/fs/cgd/csm/inputdata/atm/cam2/sst/sst_HadOIBl_bc_64x128_1949_2001_c020411.nc'" # set resolution = 128x256 # set nelapse = -300 # set sstdata = "'/fs/cgd/csm/inputdata/atm/cam2/sst/sst_HadOIBl_bc_128x256_1949_2001_c020812.nc'" 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 \ || 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,bndtvs=$sstdata,start_ymd=19770901,fincl3 = 'FLUT','OMEGA500','PRECT','U200','U850',mfilt(3) = 40,nhtfrq(3) = -6,sstcyc=.FALSE.,doisccp= .TRUE.,isccpdata = '/fs/cgd/csm/inputdata/atm/cam2/rad/isccp.tautab_invtau.nc',fincl2 = 'U200','V200','PRECT' /" \ || 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 #@ class = csl_spec #@ account_no = 93300080 #@ node = 16 #@ tasks_per_node = 1 #@ 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/-.\*\\\$//\` if ( \$year < 2001 ) then echo Year is \${year}, resubmitting. cat namelist | sed s/nsrest.\*=.\*0/nsrest\ =\ 1/ > temp.namelist \mv temp.namelist namelist 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