1 | #!/bin/bash |
---|
2 | # script pour lancer un cycle antarctique |
---|
3 | |
---|
4 | echo "----------------------------------------------" |
---|
5 | echo "Launching GRISLI Ant-40 last deglaciation" |
---|
6 | echo "Schoof or Tsai parameterisation ?" |
---|
7 | echo "For Tsai : 1" |
---|
8 | echo "For Schoof : 2" |
---|
9 | read gr_select |
---|
10 | echo |
---|
11 | |
---|
12 | tmodelend="10000." |
---|
13 | tmodelbegin="-126000." #"-150000." |
---|
14 | tmodellength="136000." |
---|
15 | |
---|
16 | parallel="no" # "yes or no?" |
---|
17 | proc_number="4" # number of processor used |
---|
18 | ppn_number=$proc_number # number of cpus (ppn) |
---|
19 | exename="Ant-40" |
---|
20 | |
---|
21 | queue="long" # specify queue used : short, medium, long, xlong... |
---|
22 | |
---|
23 | # Files used |
---|
24 | grisli_run_file="Master-files/grisli.run.lsce" # grisli.run |
---|
25 | param_tsai_file="../Param/anteis1_param_list_Cyc-Tsai.dat" # param file Tsai |
---|
26 | param_schoof_file="../Param/anteis1_param_list_Cyc-Scho.dat" # param file Schoof |
---|
27 | TEMPS_NETCDF_file="Master-files/Param/anteis1_TEMPS-NETCDF-cycle.dat" # TEMPS-NETCDF.dat |
---|
28 | module_choix_file="Master-files/module_choix-antar40-0.4-cycles.f90" # module choix |
---|
29 | |
---|
30 | |
---|
31 | #Revision number : |
---|
32 | rev=`svn info | grep "vision" | awk '{print $2}'` |
---|
33 | echo "Code revision svn "$rev |
---|
34 | |
---|
35 | # name of the run: |
---|
36 | if [ $gr_select = "1" ] ; then |
---|
37 | echo "grounding line parameterisation type : Tsai" |
---|
38 | namerun="Cyc-Tsai" |
---|
39 | elif [ $gr_select = "2" ] ; then |
---|
40 | echo "grounding line parameterisation type : Schoof" |
---|
41 | namerun="Cyc-Scho" |
---|
42 | else |
---|
43 | echo "Bad choice for gr_select (1 or 2 only) !!!" |
---|
44 | exit 0 |
---|
45 | fi |
---|
46 | |
---|
47 | echo |
---|
48 | echo "----------------------------------------------" |
---|
49 | echo " Now launching run: " $namerun |
---|
50 | echo "----------------------------------------------" |
---|
51 | echo |
---|
52 | |
---|
53 | #-------------------------------------------------- |
---|
54 | # Check if times are ok: |
---|
55 | #-------------------------------------------------- |
---|
56 | |
---|
57 | tcheck=`echo "$tmodelbegin + $tmodellength" | bc -l` |
---|
58 | tcheckbis=`echo "$tmodelend + 0" | bc -l` |
---|
59 | if [ $tcheck != $tcheckbis ]; then |
---|
60 | echo "The times provided are wrong!" |
---|
61 | echo $tcheck $tcheckbis |
---|
62 | echo "Tbegin:" $tmodelbegin ", Tend:" $tmodelend ", length:" $tmodellength |
---|
63 | exit 0 |
---|
64 | else |
---|
65 | echo "The times provided are correct." |
---|
66 | fi |
---|
67 | |
---|
68 | #-------------------------------------------------- |
---|
69 | # The different directories: |
---|
70 | #-------------------------------------------------- |
---|
71 | LAUNCHING_DIR=`pwd` |
---|
72 | GRISLI_DIR=${LAUNCHING_DIR%%/launching_area} |
---|
73 | RUNDIR=${GRISLI_DIR}"/RUNS/"${namerun}-r${rev} |
---|
74 | MODELMASTER=${GRISLI_DIR}"/SOURCES" |
---|
75 | MODEL=${RUNDIR}"/SOURCES" |
---|
76 | |
---|
77 | if [ -d $RUNDIR ]; then |
---|
78 | echo "This run exists, do you really want to overwrite?" |
---|
79 | echo "You have 3 sec. to do a ctr+c..." |
---|
80 | sleep 3 |
---|
81 | echo "Ok, your choice." |
---|
82 | else |
---|
83 | mkdir $RUNDIR |
---|
84 | echo " Run will be in:" |
---|
85 | echo " " $RUNDIR |
---|
86 | fi |
---|
87 | |
---|
88 | if [ -d $MODEL ]; then |
---|
89 | echo "model dir already created, cleaning up before copying files" |
---|
90 | rm -rf $MODEL"/"* |
---|
91 | else |
---|
92 | mkdir $MODEL |
---|
93 | fi |
---|
94 | |
---|
95 | cp -R $MODELMASTER"/"* $MODEL"/." |
---|
96 | svn status $MODELMASTER > $MODEL"/svn.status.txt" |
---|
97 | svn diff $MODELMASTER > $MODEL"/svn.diff.txt" |
---|
98 | |
---|
99 | if [ -d $RUNDIR"/bin" ]; then |
---|
100 | echo "exe in bin/" |
---|
101 | else |
---|
102 | mkdir $RUNDIR"/bin" |
---|
103 | fi |
---|
104 | |
---|
105 | if [ -d $RUNDIR"/RESULTATS" ]; then |
---|
106 | echo "exe in RESULTATS/" |
---|
107 | else |
---|
108 | mkdir $RUNDIR"/RESULTATS" |
---|
109 | fi |
---|
110 | |
---|
111 | if [ -d $RUNDIR"/INPUT" ]; then |
---|
112 | echo "inputs are linked to model master" |
---|
113 | else |
---|
114 | echo "inputs will be linked to model master" |
---|
115 | mkdir $RUNDIR"/INPUT" |
---|
116 | fi |
---|
117 | |
---|
118 | |
---|
119 | |
---|
120 | echo "Now copying master files to the working directory:" |
---|
121 | echo $RUNDIR |
---|
122 | echo "And to the model directory:" |
---|
123 | echo $MODEL |
---|
124 | |
---|
125 | |
---|
126 | cp $TEMPS_NETCDF_file $MODEL"/Fichiers-parametres/TEMPS-NETCDF.dat" |
---|
127 | cp $module_choix_file $MODEL"/Ant40_files/module_choix-antar40-0.4.f90" |
---|
128 | if [ $gr_select = "1" ] ; then |
---|
129 | cp $param_tsai_file $RUNDIR"/bin/anteis1_param_list.dat" |
---|
130 | elif [ $gr_select = "2" ] ; then |
---|
131 | cp $param_schoof_file $RUNDIR"/bin/anteis1_param_list.dat" |
---|
132 | fi |
---|
133 | |
---|
134 | cp $grisli_run_file $RUNDIR"/bin/grisli.run" |
---|
135 | |
---|
136 | cd $RUNDIR"/INPUT" |
---|
137 | ln -sf ${GRISLI_DIR}"/INPUT/ANTEIS1" . |
---|
138 | ln -sf ${GRISLI_DIR}"/INPUT/Forcage" . |
---|
139 | ln -sf ${GRISLI_DIR}"/INPUT/tracer.dat" . |
---|
140 | |
---|
141 | #-------------------------------------------------- |
---|
142 | # Replacing key words: |
---|
143 | #-------------------------------------------------- |
---|
144 | |
---|
145 | # run spec.: |
---|
146 | sed -i "s/RUNNAME/$namerun/" $RUNDIR"/bin/anteis1_param_list.dat" |
---|
147 | sed -i "s/RUNTBEGIN/$tmodelbegin/" $RUNDIR"/bin/anteis1_param_list.dat" |
---|
148 | sed -i "s/RUNTEND/$tmodelend/" $RUNDIR"/bin/anteis1_param_list.dat" |
---|
149 | |
---|
150 | # submission script: |
---|
151 | sed -i "s|SOURCESREP|$MODEL|" $RUNDIR"/bin/grisli.run" |
---|
152 | sed -i "s|EXEREP|$RUNDIR\/bin|" $RUNDIR"/bin/grisli.run" |
---|
153 | sed -i "s/RUNNAME/$namerun/" $RUNDIR"/bin/grisli.run" |
---|
154 | sed -i "s/EXE_NAME/$exename/g" $RUNDIR"/bin/grisli.run" |
---|
155 | |
---|
156 | if [ $parallel = "yes" ]; then |
---|
157 | sed -i "s/QUEUE/${queue}p/" $RUNDIR"/bin/grisli.run" |
---|
158 | sed -i "s/PROC_NUMBER/$proc_number/" $RUNDIR"/bin/grisli.run" |
---|
159 | sed -i "s/PPN_NUMBER/$ppn_number/" $RUNDIR"/bin/grisli.run" |
---|
160 | else |
---|
161 | sed -i "s/QUEUE/$queue/" $RUNDIR"/bin/grisli.run" |
---|
162 | sed -i "s/PROC_NUMBER/1/" $RUNDIR"/bin/grisli.run" |
---|
163 | sed -i "s/PPN_NUMBER/1/" $RUNDIR"/bin/grisli.run" |
---|
164 | sed -i "/export\ MKL_NUM_THREADS/d" $RUNDIR"/bin/grisli.run" |
---|
165 | sed -i "/export\ OMP_NUM_THREADS/d" $RUNDIR"/bin/grisli.run" |
---|
166 | sed -i "/export\ KMP_STACKSIZE/d" $RUNDIR"/bin/grisli.run" |
---|
167 | fi |
---|
168 | |
---|
169 | # Makefile: |
---|
170 | if [ $parallel = "yes" ]; then |
---|
171 | sed -i "s/Makefile.tof-lsce3130.inc/Makefile.tof-asterix-parallel.inc/" $RUNDIR"/SOURCES/Makefile" |
---|
172 | else |
---|
173 | sed -i "s/Makefile.tof-lsce3130.inc/Makefile.tof-asterix-sequential.inc/" $RUNDIR"/SOURCES/Makefile" |
---|
174 | fi |
---|
175 | |
---|
176 | |
---|
177 | #-------------------------------------------------- |
---|
178 | # Submitting the job: |
---|
179 | #-------------------------------------------------- |
---|
180 | cd $RUNDIR"/bin" |
---|
181 | echo "submitting the job" |
---|
182 | qsub $RUNDIR"/bin/grisli.run" |
---|
183 | echo "-------------------------------------" |
---|
184 | |
---|
185 | |
---|
186 | |
---|