[135] | 1 | #!/bin/csh |
---|
| 2 | ########################################################################### |
---|
| 3 | # Script to perform several chained LMD UCM simulations |
---|
| 4 | # SET HERE the maximum total number of simulations |
---|
| 5 | |
---|
[253] | 6 | set nummax=5 |
---|
[135] | 7 | |
---|
| 8 | ########################################################################### |
---|
| 9 | |
---|
| 10 | |
---|
| 11 | |
---|
| 12 | echo "---------------------------------------------------------" |
---|
| 13 | echo "starting run0" |
---|
| 14 | |
---|
| 15 | set dir=`pwd` |
---|
| 16 | set machine=`hostname` |
---|
| 17 | set address=`whoami` |
---|
| 18 | |
---|
| 19 | # Look for file "num_run" which should contain |
---|
| 20 | # the value of the previously computed season |
---|
| 21 | # (defaults to 0 if file "num_run" does not exist) |
---|
| 22 | if ( -f num_run ) then |
---|
| 23 | echo "found file num_run" |
---|
| 24 | set numold=`cat num_run` |
---|
| 25 | else |
---|
| 26 | set numold=0 |
---|
| 27 | endif |
---|
| 28 | echo "numold is set to" ${numold} |
---|
| 29 | |
---|
| 30 | |
---|
| 31 | # Set value of current season |
---|
| 32 | set numnew=${numold} |
---|
| 33 | @ numnew = ${numnew} + 1 |
---|
| 34 | echo "numnew is set to" ${numnew} |
---|
| 35 | |
---|
| 36 | # Look for initialization data files (exit if none found) |
---|
| 37 | if ( ( -f start${numold}.nc ) && ( -f startfi${numold}.nc ) ) then |
---|
| 38 | \cp -f start${numold}.nc start.nc |
---|
| 39 | \cp -f startfi${numold}.nc startfi.nc |
---|
| 40 | else if ( ${numold} == 99999 ) then |
---|
| 41 | echo "No run because previous run crashed ! (99999 in num_run)" |
---|
| 42 | exit |
---|
| 43 | else |
---|
| 44 | echo "Where is file start"${numold}".nc??" |
---|
| 45 | exit |
---|
| 46 | endif |
---|
| 47 | |
---|
| 48 | # |
---|
| 49 | |
---|
| 50 | # Run GCM |
---|
[253] | 51 | gcm.e >! lrun${numnew} |
---|
[135] | 52 | |
---|
| 53 | |
---|
| 54 | # Check if run ended normaly and copy datafiles |
---|
| 55 | if ( ( -f restartfi.nc ) && ( -f restart.nc ) ) then |
---|
| 56 | echo "Run seems to have ended normally" |
---|
| 57 | \mv -f restartfi.nc startfi${numnew}.nc |
---|
| 58 | \mv -f restart.nc start${numnew}.nc |
---|
| 59 | else |
---|
| 60 | if ( -f num_run ) then |
---|
| 61 | \mv -f num_run num_run.crash |
---|
| 62 | else |
---|
| 63 | echo "No file num_run to build num_run.crash from !!" |
---|
| 64 | # Impose a default value of 0 for num_run |
---|
| 65 | echo 0 >! num_run.crash |
---|
| 66 | endif |
---|
| 67 | echo 99999 >! num_run |
---|
[253] | 68 | ############## To receive an email message if the run crashes ######## |
---|
| 69 | #mail -s "crash run GCM" $address <<ENDMAIL |
---|
| 70 | #The run on $machine in $dir has just crashed. |
---|
| 71 | #ENDMAIL |
---|
[135] | 72 | ############################################"" |
---|
| 73 | exit |
---|
| 74 | endif |
---|
| 75 | |
---|
| 76 | # Copy other datafiles that may have been generated |
---|
| 77 | if ( -f diagfi.nc ) then |
---|
| 78 | \mv -f diagfi.nc diagfi${numnew}.nc |
---|
| 79 | endif |
---|
[253] | 80 | if ( -f diagspec.nc ) then |
---|
| 81 | \mv -f diagspec.nc diagspec${numnew}.nc |
---|
| 82 | endif |
---|
[135] | 83 | if ( -f diagsoil.nc ) then |
---|
| 84 | \mv -f diagsoil.nc diagsoil${numnew}.nc |
---|
| 85 | endif |
---|
| 86 | if ( -f stats.nc ) then |
---|
| 87 | \mv -f stats.nc stats${numnew}.nc |
---|
| 88 | endif |
---|
| 89 | if ( -f profiles.dat ) then |
---|
| 90 | \mv -f profiles.dat profiles${numnew}.dat |
---|
| 91 | \mv -f profiles.hdr profiles${numnew}.hdr |
---|
| 92 | endif |
---|
| 93 | |
---|
| 94 | |
---|
| 95 | # Prepare things for upcoming runs by writing |
---|
| 96 | # value of computed season in file num_run |
---|
| 97 | echo ${numnew} >! num_run |
---|
| 98 | |
---|
| 99 | if ( -f rad_bal.out ) then |
---|
[253] | 100 | mv rad_bal.out rad_bal${numnew}.out |
---|
[135] | 101 | endif |
---|
| 102 | |
---|
[253] | 103 | if ( -f h2o_bal.out ) then |
---|
| 104 | mv h2o_bal.out h2o_bal${numnew}.out |
---|
| 105 | endif |
---|
[135] | 106 | |
---|
| 107 | # If we are over nummax : stop |
---|
| 108 | if ( `expr $numnew + 1 \> $nummax ` == 1) then |
---|
| 109 | exit |
---|
| 110 | else |
---|
| 111 | \cp -f run0 exe_planet |
---|
| 112 | exe_planet |
---|
| 113 | endif |
---|