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://data.spiga.fr/mesoscale_model/STATIC_DATA/" |
---|
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 | ./install_ioipsl_$fortcom".bash" > $log 2> $log |
---|
126 | |
---|
127 | ## ----------- |
---|
128 | ## compile GCM |
---|
129 | ## ----------- |
---|
130 | log=$refrepo/code/logcompile_gcm |
---|
131 | echo "*** compile GCM: check progress in "$log |
---|
132 | rm -rf $log ; touch $log |
---|
133 | # make a re-usable command |
---|
134 | echo "#! /bin/bash" > $refrepo/compile_gcm.sh |
---|
135 | echo "cd $refrepo/code/LMDZ.COMMON" >> $refrepo/compile_gcm.sh |
---|
136 | echo "./makelmdz_fcm -cpp MESOINI -j 8 -s 2 -d $dimgcm -arch $machine$fortcom -parallel mpi -p mars gcm" >> $refrepo/compile_gcm.sh |
---|
137 | echo "./makelmdz_fcm -j 8 -s 2 -d $dimgcm -arch $machine$fortcom -p mars newstart" >> $refrepo/compile_gcm.sh |
---|
138 | 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 |
---|
139 | 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 |
---|
140 | chmod 755 $refrepo/compile_gcm.sh |
---|
141 | # now execute command |
---|
142 | $refrepo/compile_gcm.sh > $log 2> $log |
---|
143 | |
---|
144 | ## ------------------------ |
---|
145 | ## make a minimal startbase |
---|
146 | ## ------------------------ |
---|
147 | echo "*** make a minimal startbase" |
---|
148 | cd $refrepo/gcm/newstart |
---|
149 | ./mini_startbase.sh |
---|
150 | |
---|
151 | fi |
---|
152 | |
---|
153 | fi |
---|
154 | |
---|
155 | ################################### |
---|
156 | ################################### MESO |
---|
157 | ################################### |
---|
158 | |
---|
159 | ## START MESOSCALE PART |
---|
160 | if [[ "${meso}" == "on" ]] |
---|
161 | then |
---|
162 | |
---|
163 | ### |
---|
164 | if [[ "${gcm}" == "old" ]] |
---|
165 | then |
---|
166 | option="" |
---|
167 | else |
---|
168 | option="-p mars_lmd_new" |
---|
169 | fi |
---|
170 | ### |
---|
171 | |
---|
172 | ## ---------------------- |
---|
173 | ## get and make mesoscale |
---|
174 | ## ---------------------- |
---|
175 | echo "*** get and compile mesoscale version "$version |
---|
176 | cd $refrepo/code |
---|
177 | svn update -r $version MESOSCALE > /dev/null |
---|
178 | # |
---|
179 | if [[ "${les}" == "on" ]] |
---|
180 | then |
---|
181 | echo "*** LES LES LES LES" |
---|
182 | cd $refrepo/code/MESOSCALE/LMD_MM_MARS/SRC/LES/ |
---|
183 | ./LMD_LES_MARS_install > /dev/null |
---|
184 | option=$option" -c les" |
---|
185 | fi |
---|
186 | # |
---|
187 | cd $refrepo/code/MESOSCALE/LMD_MM_MARS |
---|
188 | ls $refrepo/mesoin |
---|
189 | if [[ "$?" == 0 ]] ; then |
---|
190 | ./makemeso $option < $refrepo/mesoin |
---|
191 | else |
---|
192 | ./makemeso $option |
---|
193 | fi |
---|
194 | rm -rf $refrepo/mesoin |
---|
195 | |
---|
196 | if [[ "${les}" == "off" ]] |
---|
197 | then |
---|
198 | ## ------------------------------- |
---|
199 | ## make ini&bdy tools in mesoscale |
---|
200 | ## ------------------------------- |
---|
201 | echo "*** compile initialization tools" |
---|
202 | cd $refrepo/code_compiled |
---|
203 | ln -sf $refrepo/code/MESOSCALE/LMD_MM_MARS/SRC/SCRIPTS/prepare_ini . |
---|
204 | ./prepare_ini > /dev/null |
---|
205 | ## |
---|
206 | cd $refrepo/code_compiled/PREP_MARS |
---|
207 | ./compile"_"$fortcom |
---|
208 | ## |
---|
209 | cd $refrepo/code_compiled/WPS |
---|
210 | ls $refrepo/wpsin |
---|
211 | if [[ "$?" == 0 ]] ; then |
---|
212 | ./configure < $refrepo/wpsin > /dev/null 2> /dev/null |
---|
213 | else |
---|
214 | ./configure |
---|
215 | fi |
---|
216 | rm -rf $refrepo/wpsin |
---|
217 | rm -rf logcompile |
---|
218 | ./compile > logcompile 2>&1 |
---|
219 | |
---|
220 | ## ------------------ |
---|
221 | ## import static data |
---|
222 | ## ------------------ |
---|
223 | echo "*** get static data" |
---|
224 | rm -rf $refrepo/data_static |
---|
225 | svn co -q $where_is_svn/MESOSCALE/LMD_MM_MARS/WPS_GEOG $refrepo/data_static |
---|
226 | cd $refrepo/data_static |
---|
227 | rm -rf logdown |
---|
228 | wget $webrepo"/albedo_TES.tar.gz" -a logdown |
---|
229 | wget $webrepo"/mola_topo64.tar.gz" -a logdown |
---|
230 | wget $webrepo"/thermal_TES.tar.gz" -a logdown |
---|
231 | for fff in *.tar.gz; do |
---|
232 | tar xzvf $fff > /dev/null |
---|
233 | rm -rf $fff |
---|
234 | done |
---|
235 | fi |
---|
236 | |
---|
237 | ## ------------------------ |
---|
238 | ## get and compile postproc |
---|
239 | ## ------------------------ |
---|
240 | echo "*** get and compile post-processing tool" |
---|
241 | cd $refrepo |
---|
242 | svn co -q https://github.com/aymeric-spiga/api/trunk postproc |
---|
243 | cd $refrepo/postproc |
---|
244 | ./compile |
---|
245 | |
---|
246 | fi |
---|
247 | ## END MESOSCALE PART |
---|
248 | |
---|
249 | ## ----- |
---|
250 | ## check |
---|
251 | ## ----- |
---|
252 | echo "*** CHECKLIST:" |
---|
253 | ls -lL $refrepo/gcm/gcm.e |
---|
254 | ls -lL $refrepo/geogrid/geogrid.exe |
---|
255 | ls -lL $refrepo/metgrid/metgrid.exe |
---|
256 | ls -lL $refrepo/prep/readmeteo.exe |
---|
257 | ls -lL $refrepo/data_static/albedo_TES |
---|
258 | ls -lL $refrepo/real.exe |
---|
259 | ls -lL $refrepo/wrf.exe |
---|
260 | ls -lL $refrepo/postproc/api |
---|
261 | |
---|