#!/bin/tcsh #PBS -l walltime=0:25:00 #PBS -l vmem=900MB #PBS -l ncpus=8 #PBS -wd setenv OMP_NUM_THREADS 8 # # Purpose # ------- # Runs the CSIRO Mk3L climate system model for 10 years, in stand-alone # atmosphere mode, coupled to CABLE. And can resubmit for next 10 years. # Each requesting 20 hours of walltime. # # Usage # ----- # (should have done setup_vu_cable beforehand) # qsub runCNP # # History # ------- # 2009 Sep 23 Bernard Pak Original version for VU. # 2009 Dec 16 Bernard Pak Modified for committing to SVN repository # # Note # ---- # *** Remember to check cable_mk3l.nml for output frequency *** # Duration of the run, in years (*** user must specify here ***) set LASTYR = 00001 # Address to which to send emails set ADDRESS = matear # Set the stack sizes limit stacksize unlimited setenv KMP_STACKSIZE 16M # Set names of directories set TMP_DIR = $cwd # Change to the run directory cd $TMP_DIR # Set model year number - $year may have leading zeroes, whereas $yr will not set year = `cat year` set yr = `expr $year + 0` set last = `expr $LASTYR + 0` set loop = 1 # Loop through the required number of years # while (($yr <= $LASTYR) && ($loop <= 2)) # ** cannot do more than 15 years for $loop as the output file becomes too large # while (($yr <= $last) && ($loop <= 20)) # use wall-time 6:58, 8 cpus, 900 vmem # ** # while (($yr <= $last) && ($loop <= 10)) # use wall-time 3:30, 8 cpus, 900 vmem while (($yr <= $last) && ($loop <= 10)) # use wall-time 5:30:00 # while (($yr <= $last) && ($loop <= 5)) # use wall-time 3:30:00 # Run the model ./model < input | tee output echo "Finished running $yr year." # Check that the run was OK set MESSAGE = `tail output | grep termination` if ("$MESSAGE" != '') then echo "Year $yr terminated normally." else echo "Abnormal termination of run." echo "Mk3L run stopped - abnormal termination." | mail $ADDRESS exit endif # Archive results cp restart_out.nc restart_out_${year}.nc cp rest.end rest.end_${year} cp rest.end rest.start mv out_cable.nc out_cable_${year}.nc mv output output_${year} mv log_cable.txt log_cable_${year}.txt if ($yr < $last) rm fort.3? # Start another year set yr1 = `expr $year + 1` set nextYr = $yr1 if ($yr1 <= 9999) set nextYr = 0$yr1 if ($yr1 <= 999) set nextYr = 00$yr1 if ($yr1 <= 99) set nextYr = 000$yr1 if ($yr1 <= 9) set nextYr = 0000$yr1 /bin/rm year echo $nextYr > year set year = `cat year` set yr = `expr $year + 0` set loop2 = `expr $loop + 1` set loop = $loop2 end # Submit another run if necessary if ($yr <= $last) then rm fort.3? qsub runCNP set errstat = $? @ n = 1 while (($errstat != 0) && ($n <= 15)) echo "qsub error - trying again in 60 seconds..." sleep 60 qsub runCNP set errstat = $? @ n ++ end endif