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 crash ######## |
---|
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 stats.nc ) then |
---|
79 | \mv -f stats.nc stats${numnew}.nc |
---|
80 | endif |
---|
81 | if ( -f profiles.dat ) then |
---|
82 | \mv -f profiles.dat profiles${numnew}.dat |
---|
83 | \mv -f profiles.hdr profiles${numnew}.hdr |
---|
84 | endif |
---|
85 | if ( -f stats.nc ) then |
---|
86 | \mv -f stats.nc stats${numnew}.nc |
---|
87 | endif |
---|
88 | |
---|
89 | |
---|
90 | # Prepare things for upcoming runs by writing |
---|
91 | # value of computed season in file num_run |
---|
92 | echo ${numnew} >! num_run |
---|
93 | |
---|
94 | # If we are over nummax : stop |
---|
95 | if ( `expr $numnew + 1 \> $nummax ` == 1) then |
---|
96 | exit |
---|
97 | else |
---|
98 | \cp -f run0 exe_mars |
---|
99 | exe_mars |
---|
100 | endif |
---|
101 | |
---|
102 | |
---|