1 | #! /bin/bash |
---|
2 | |
---|
3 | ################################ |
---|
4 | # A. Spiga 09/06/2015 |
---|
5 | # Install the LMD mesoscale model |
---|
6 | ################################ |
---|
7 | # prerequisite: NETCDF |
---|
8 | # -- NETCDF env variable |
---|
9 | ################################ |
---|
10 | ## DEFAULT |
---|
11 | ## name of the folder |
---|
12 | name="MESORUN" |
---|
13 | ## SVN version |
---|
14 | version="HEAD" |
---|
15 | version="1520" |
---|
16 | ################################ |
---|
17 | |
---|
18 | meso="on" |
---|
19 | gcm="" |
---|
20 | gcmcompile="on" |
---|
21 | les="off" |
---|
22 | fortcom="ifort" |
---|
23 | while getopts "gn:hv:f:ol" options; do |
---|
24 | case $options in |
---|
25 | n ) name="${OPTARG}";; |
---|
26 | g ) meso="off";; |
---|
27 | v ) version="${OPTARG}";; |
---|
28 | o ) gcm="old" ;; |
---|
29 | l ) gcmcompile="off";les="on" ;; |
---|
30 | f ) fortcom="${OPTARG}" ;; |
---|
31 | h ) echo " |
---|
32 | # OPTIONS |
---|
33 | # -n [name] --> name of the folder to be created |
---|
34 | # -g --> only compile GCM (for tests) |
---|
35 | # -v [# (or) HEAD] --> svn version |
---|
36 | # -o --> old GCM+meso version |
---|
37 | # -l --> LES version (only new physics) |
---|
38 | # -f --> fortran compiler (experimental) |
---|
39 | " ; exit ;; |
---|
40 | esac |
---|
41 | done |
---|
42 | |
---|
43 | ################################ |
---|
44 | ## machine on which you will compile |
---|
45 | machine="CICLAD" |
---|
46 | ## server for sources |
---|
47 | where_is_svn="http://svn.lmd.jussieu.fr/Planeto/trunk/" |
---|
48 | ## grid definition for GCM |
---|
49 | dimgcm="64x48x29" |
---|
50 | ## location of static data |
---|
51 | webrepo="http://www.lmd.jussieu.fr/~aslmd/mesoscale_model/data_static/" |
---|
52 | ## TBD: datadir: http://www.lmd.jussieu.fr/~lmdz/planets/mars/datadir/ |
---|
53 | ################################ |
---|
54 | |
---|
55 | ## ----------------------------- |
---|
56 | ## import settings and structure |
---|
57 | ## ----------------------------- |
---|
58 | echo "*** get structure" |
---|
59 | rm -rf $name > /dev/null 2> /dev/null |
---|
60 | svn -q co $where_is_svn"/MESOSCALE/LMD_MM_MARS/SIMU/MESORUN"$gcm $name |
---|
61 | refrepo=$PWD/$name |
---|
62 | ## fill here user input to obtain independent script |
---|
63 | case ${fortcom}$gcm in |
---|
64 | "ifort") echo 1 > $refrepo/wpsin ; echo 5 > $refrepo/mesoin ; echo 1 >> $refrepo/mesoin ;; |
---|
65 | "ifortold") echo 1 > $refrepo/wpsin ; echo 5 > $refrepo/mesoin ; echo 4 >> $refrepo/mesoin ; |
---|
66 | echo 61 >> $refrepo/mesoin ; echo 61 >> $refrepo/mesoin ; echo 61 >> $refrepo/mesoin ; |
---|
67 | echo 1 >> $refrepo/mesoin ; echo 1 >> $refrepo/mesoin ;; |
---|
68 | "gnuold") echo 10 > $refrepo/wpsin ; echo 8 > $refrepo/mesoin ; |
---|
69 | echo 61 >> $refrepo/mesoin ; echo 61 >> $refrepo/mesoin ; echo 61 >> $refrepo/mesoin ; |
---|
70 | echo 1 >> $refrepo/mesoin ; echo 1 >> $refrepo/mesoin ;; |
---|
71 | *) echo "compiler not supported" ; exit ;; |
---|
72 | esac |
---|
73 | |
---|
74 | ## ---------------- |
---|
75 | ## create code repo |
---|
76 | ## ---------------- |
---|
77 | echo "*** get SVN repository" |
---|
78 | \rm $refrepo/code |
---|
79 | svn -q co -N $where_is_svn $refrepo/code |
---|
80 | |
---|
81 | |
---|
82 | ################################### |
---|
83 | ################################### GCM |
---|
84 | ################################### |
---|
85 | if [[ "${gcm}" == "old" ]] |
---|
86 | then |
---|
87 | |
---|
88 | if [[ "${gcmcompile}" == "on" ]] |
---|
89 | then |
---|
90 | log=$refrepo/code/MESOSCALE/LMDZ.MARS/logcompile_gcm |
---|
91 | echo "*** get and compile GCM code version "$version |
---|
92 | cd $refrepo/code |
---|
93 | svn update -r $version MESOSCALE > /dev/null |
---|
94 | cd $refrepo/code/MESOSCALE/LMDZ.MARS |
---|
95 | ln -sf makegcm_$fortcom makegcm |
---|
96 | ./compile > $log 2> $log |
---|
97 | fi |
---|
98 | |
---|
99 | else |
---|
100 | |
---|
101 | ## ------------ |
---|
102 | ## get GCM code |
---|
103 | ## ------------ |
---|
104 | echo "*** get GCM code version "$version |
---|
105 | cd $refrepo/code |
---|
106 | # at least get Mars physics (always needed) |
---|
107 | svn -q update -r $version LMDZ.MARS |
---|
108 | |
---|
109 | ## START compiling GCM PART |
---|
110 | if [[ "${gcmcompile}" == "on" ]] |
---|
111 | then |
---|
112 | |
---|
113 | svn -q update -r $version LMDZ.COMMON |
---|
114 | cd $refrepo/code/LMDZ.COMMON |
---|
115 | svn -q co http://forge.ipsl.jussieu.fr/fcm/svn/PATCHED/FCM_V1.2 |
---|
116 | ln -sf FCM_V1.2/bin/fcm . |
---|
117 | |
---|
118 | ## -------------- |
---|
119 | ## compile IOIPSL |
---|
120 | ## -------------- |
---|
121 | log=$refrepo/code/logcompile_ioipsl |
---|
122 | echo "*** compile IOIPSL: check progress in "$log |
---|
123 | rm -rf $log ; touch $log |
---|
124 | cd $refrepo/code/LMDZ.COMMON/ioipsl |
---|
125 | if [[ "${machine}" == "CICLAD" ]] |
---|
126 | then |
---|
127 | ./install_ioipsl_ciclad.bash > $log 2> $log |
---|
128 | else |
---|
129 | ./install_ioipsl_$fortcom".bash" > $log 2> $log |
---|
130 | fi |
---|
131 | |
---|
132 | ## ----------- |
---|
133 | ## compile GCM |
---|
134 | ## ----------- |
---|
135 | log=$refrepo/code/logcompile_gcm |
---|
136 | echo "*** compile GCM: check progress in "$log |
---|
137 | rm -rf $log ; touch $log |
---|
138 | # make a re-usable command |
---|
139 | echo "#! /bin/bash" > $refrepo/compile_gcm.sh |
---|
140 | echo "cd $refrepo/code/LMDZ.COMMON" >> $refrepo/compile_gcm.sh |
---|
141 | echo "./makelmdz_fcm -cpp MESOINI -j 8 -s 2 -d $dimgcm -arch $machine$fortcom -parallel mpi -p mars gcm" >> $refrepo/compile_gcm.sh |
---|
142 | echo "./makelmdz_fcm -j 8 -s 2 -d $dimgcm -arch $machine$fortcom -p mars newstart" >> $refrepo/compile_gcm.sh |
---|
143 | echo "cd $refrepo/gcm ; \rm gcm.e ; ln -sf $refrepo/code/LMDZ.COMMON/bin/gcm_${dimgcm}_phymars_para.e gcm.e" >> $refrepo/compile_gcm.sh |
---|
144 | echo "cd $refrepo/gcm/newstart ; \rm newstart.e ; ln -sf $refrepo/code/LMDZ.COMMON/bin/newstart_${dimgcm}_phymars_seq.e newstart.e" >> $refrepo/compile_gcm.sh |
---|
145 | chmod 755 $refrepo/compile_gcm.sh |
---|
146 | # now execute command |
---|
147 | $refrepo/compile_gcm.sh > $log 2> $log |
---|
148 | |
---|
149 | ## ------------------------ |
---|
150 | ## make a minimal startbase |
---|
151 | ## ------------------------ |
---|
152 | echo "*** make a minimal startbase" |
---|
153 | cd $refrepo/gcm/newstart |
---|
154 | ./mini_startbase.sh |
---|
155 | |
---|
156 | fi |
---|
157 | |
---|
158 | fi |
---|
159 | |
---|
160 | ################################### |
---|
161 | ################################### MESO |
---|
162 | ################################### |
---|
163 | |
---|
164 | ## START MESOSCALE PART |
---|
165 | if [[ "${meso}" == "on" ]] |
---|
166 | then |
---|
167 | |
---|
168 | ### |
---|
169 | if [[ "${gcm}" == "old" ]] |
---|
170 | then |
---|
171 | option="" |
---|
172 | else |
---|
173 | option="-p mars_lmd_new" |
---|
174 | fi |
---|
175 | ### |
---|
176 | |
---|
177 | ## ---------------------- |
---|
178 | ## get and make mesoscale |
---|
179 | ## ---------------------- |
---|
180 | echo "*** get and compile mesoscale version "$version |
---|
181 | cd $refrepo/code |
---|
182 | svn update -r $version MESOSCALE > /dev/null |
---|
183 | # |
---|
184 | if [[ "${les}" == "on" ]] |
---|
185 | then |
---|
186 | echo "*** LES LES LES LES" |
---|
187 | cd $refrepo/code/MESOSCALE/LMD_MM_MARS/SRC/LES/ |
---|
188 | ./LMD_LES_MARS_install > /dev/null |
---|
189 | option=$option" -c les" |
---|
190 | fi |
---|
191 | # |
---|
192 | cd $refrepo/code/MESOSCALE/LMD_MM_MARS |
---|
193 | ls $refrepo/mesoin |
---|
194 | if [[ "$?" == 0 ]] ; then |
---|
195 | ./makemeso $option < $refrepo/mesoin |
---|
196 | else |
---|
197 | ./makemeso $option |
---|
198 | fi |
---|
199 | rm -rf $refrepo/mesoin |
---|
200 | |
---|
201 | if [[ "${les}" == "off" ]] |
---|
202 | then |
---|
203 | ## ------------------------------- |
---|
204 | ## make ini&bdy tools in mesoscale |
---|
205 | ## ------------------------------- |
---|
206 | echo "*** compile initialization tools" |
---|
207 | cd $refrepo/code_compiled |
---|
208 | ln -sf $refrepo/code/MESOSCALE/LMD_MM_MARS/SRC/SCRIPTS/prepare_ini . |
---|
209 | ./prepare_ini > /dev/null |
---|
210 | ## |
---|
211 | cd $refrepo/code_compiled/PREP_MARS |
---|
212 | ./compile"_"$fortcom |
---|
213 | ## |
---|
214 | cd $refrepo/code_compiled/WPS |
---|
215 | ls $refrepo/wpsin |
---|
216 | if [[ "$?" == 0 ]] ; then |
---|
217 | ./configure < $refrepo/wpsin > /dev/null 2> /dev/null |
---|
218 | else |
---|
219 | ./configure |
---|
220 | fi |
---|
221 | rm -rf $refrepo/wpsin |
---|
222 | rm -rf logcompile |
---|
223 | ./compile > logcompile 2>&1 |
---|
224 | |
---|
225 | ## ------------------ |
---|
226 | ## import static data |
---|
227 | ## ------------------ |
---|
228 | echo "*** get static data" |
---|
229 | rm -rf $refrepo/data_static |
---|
230 | svn co -q $where_is_svn/MESOSCALE/LMD_MM_MARS/WPS_GEOG $refrepo/data_static |
---|
231 | cd $refrepo/data_static |
---|
232 | rm -rf logdown |
---|
233 | wget $webrepo"/albedo_TES.tar.gz" -a logdown |
---|
234 | wget $webrepo"/mola_topo64.tar.gz" -a logdown |
---|
235 | wget $webrepo"/thermal_TES.tar.gz" -a logdown |
---|
236 | for fff in *.tar.gz; do |
---|
237 | tar xzvf $fff > /dev/null |
---|
238 | rm -rf $fff |
---|
239 | done |
---|
240 | fi |
---|
241 | |
---|
242 | ## ------------------------ |
---|
243 | ## get and compile postproc |
---|
244 | ## ------------------------ |
---|
245 | echo "*** get and compile post-processing tool" |
---|
246 | cd $refrepo |
---|
247 | svn co -q https://github.com/aymeric-spiga/api/trunk postproc |
---|
248 | cd $refrepo/postproc |
---|
249 | ./compile |
---|
250 | |
---|
251 | fi |
---|
252 | ## END MESOSCALE PART |
---|
253 | |
---|
254 | ## ----- |
---|
255 | ## check |
---|
256 | ## ----- |
---|
257 | echo "*** CHECKLIST:" |
---|
258 | ls -lL $refrepo/gcm/gcm.e |
---|
259 | ls -lL $refrepo/geogrid/geogrid.exe |
---|
260 | ls -lL $refrepo/metgrid/metgrid.exe |
---|
261 | ls -lL $refrepo/prep/readmeteo.exe |
---|
262 | ls -lL $refrepo/data_static/albedo_TES |
---|
263 | ls -lL $refrepo/real.exe |
---|
264 | ls -lL $refrepo/wrf.exe |
---|
265 | ls -lL $refrepo/postproc/api |
---|
266 | |
---|