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