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 | ## git version or tag |
---|
14 | version="tags/mesoscale-jezero" |
---|
15 | version="tags/gcm-mesoini-ok" |
---|
16 | version="841f9fc0b74168c34dbbcd47fef2544654a3d763" #2315 |
---|
17 | version="tags/mesoscale-compile-run" |
---|
18 | ## once folder created, code may be updated using git reset --hard $commit_SHA |
---|
19 | ################################ |
---|
20 | |
---|
21 | meso="on" |
---|
22 | gcm="" |
---|
23 | gcmcompile="on" |
---|
24 | les="off" |
---|
25 | fortcom="ifort" |
---|
26 | while getopts "gn:hv:f:ol" options; do |
---|
27 | case $options in |
---|
28 | n ) name="${OPTARG}";; |
---|
29 | g ) meso="off";; |
---|
30 | v ) version="${OPTARG}";; |
---|
31 | o ) gcm="old" ;; |
---|
32 | l ) gcmcompile="off";les="on" ;; |
---|
33 | f ) fortcom="${OPTARG}" ;; |
---|
34 | h ) echo " |
---|
35 | # OPTIONS |
---|
36 | # -n [name] --> name of the folder to be created |
---|
37 | # -g --> only compile GCM (for tests) |
---|
38 | # -v [version/tag] --> git commit or tag |
---|
39 | # -o --> old GCM+meso version |
---|
40 | # -l --> LES version (only new physics) |
---|
41 | # -f --> fortran compiler (experimental) |
---|
42 | " ; exit ;; |
---|
43 | esac |
---|
44 | done |
---|
45 | |
---|
46 | ################################ |
---|
47 | ## machine on which you will compile |
---|
48 | machine="CICLAD" |
---|
49 | ## server for sources |
---|
50 | where_is_svn="https://svn.lmd.jussieu.fr/Planeto/trunk/" |
---|
51 | ## server for sources |
---|
52 | where_is_git="git@gitlab.in2p3.fr:la-communaut-des-mod-les-atmosph-riques-plan-taires/git-trunk.git" |
---|
53 | ## depth of git checkout |
---|
54 | depth=500 # should be enough and avoid too big a directory |
---|
55 | ## grid definition for GCM |
---|
56 | dimgcm="64x48x29" |
---|
57 | ## location of static data |
---|
58 | webrepo="http://www.lmd.jussieu.fr/~aslmd/mesoscale_model/data_static/" |
---|
59 | ## TBD: datadir: http://www.lmd.jussieu.fr/~lmdz/planets/mars/datadir/ |
---|
60 | ## wget -r -np --cut-dirs=3 -nH https://www.lmd.jussieu.fr/~lmdz/planets/mars/datadir/ |
---|
61 | ################################ |
---|
62 | |
---|
63 | ## ----------------------------- |
---|
64 | ## import settings and structure |
---|
65 | ## ----------------------------- |
---|
66 | echo "*** get structure" |
---|
67 | rm -rf $name > /dev/null 2> /dev/null |
---|
68 | svn -q co $where_is_svn"/MESOSCALE/LMD_MM_MARS/SIMU/MESORUN"$gcm $name |
---|
69 | refrepo=$PWD/$name |
---|
70 | ## fill here user input to obtain independent script |
---|
71 | case ${fortcom}$gcm in |
---|
72 | "ifort") echo 1 > $refrepo/wpsin ; echo 5 > $refrepo/mesoin ; echo 1 >> $refrepo/mesoin ;; |
---|
73 | "ifortold") echo 1 > $refrepo/wpsin ; echo 5 > $refrepo/mesoin ; echo 4 >> $refrepo/mesoin ; |
---|
74 | echo 61 >> $refrepo/mesoin ; echo 61 >> $refrepo/mesoin ; echo 61 >> $refrepo/mesoin ; |
---|
75 | echo 1 >> $refrepo/mesoin ; echo 1 >> $refrepo/mesoin ;; |
---|
76 | "gnuold") echo 10 > $refrepo/wpsin ; echo 8 > $refrepo/mesoin ; |
---|
77 | echo 61 >> $refrepo/mesoin ; echo 61 >> $refrepo/mesoin ; echo 61 >> $refrepo/mesoin ; |
---|
78 | echo 1 >> $refrepo/mesoin ; echo 1 >> $refrepo/mesoin ;; |
---|
79 | *) echo "compiler not supported" ; exit ;; |
---|
80 | esac |
---|
81 | |
---|
82 | ## ---------------- |
---|
83 | ## create code repo |
---|
84 | ## ---------------- |
---|
85 | echo "*** get gitlab repository" |
---|
86 | \rm $refrepo/code |
---|
87 | git clone --depth $depth $where_is_git $refrepo/code |
---|
88 | echo "*** set a branch with same name as repo for version "$version |
---|
89 | cd $refrepo/code |
---|
90 | git checkout $version -b $name |
---|
91 | |
---|
92 | ################################### |
---|
93 | ################################### GCM |
---|
94 | ################################### |
---|
95 | if [[ "${gcm}" == "old" ]] |
---|
96 | then |
---|
97 | |
---|
98 | if [[ "${gcmcompile}" == "on" ]] |
---|
99 | then |
---|
100 | log=$refrepo/code/MESOSCALE/LMDZ.MARS/logcompile_gcm |
---|
101 | echo "*** compile GCM" |
---|
102 | cd $refrepo/code/MESOSCALE/LMDZ.MARS |
---|
103 | ln -sf makegcm_$fortcom makegcm |
---|
104 | ./compile > $log 2> $log |
---|
105 | fi |
---|
106 | |
---|
107 | fi |
---|
108 | |
---|
109 | ## START compiling GCM PART |
---|
110 | if [[ "${gcmcompile}" == "on" ]] |
---|
111 | then |
---|
112 | |
---|
113 | cd $refrepo/code/LMDZ.COMMON |
---|
114 | svn -q co http://forge.ipsl.jussieu.fr/fcm/svn/PATCHED/FCM_V1.2 |
---|
115 | ln -sf FCM_V1.2/bin/fcm . |
---|
116 | |
---|
117 | ## -------------- |
---|
118 | ## compile IOIPSL |
---|
119 | ## -------------- |
---|
120 | log=$refrepo/code/logcompile_ioipsl |
---|
121 | echo "*** compile IOIPSL: check progress in "$log |
---|
122 | rm -rf $log ; touch $log |
---|
123 | cd $refrepo/code/LMDZ.COMMON/ioipsl |
---|
124 | if [[ "${machine}" == "CICLAD" ]] |
---|
125 | then |
---|
126 | ./install_ioipsl_ciclad-ifort.bash > $log 2> $log |
---|
127 | else |
---|
128 | ./install_ioipsl_$fortcom".bash" > $log 2> $log |
---|
129 | fi |
---|
130 | |
---|
131 | ## ----------- |
---|
132 | ## compile GCM |
---|
133 | ## ----------- |
---|
134 | log=$refrepo/code/logcompile_gcm |
---|
135 | echo "*** compile GCM: check progress in "$log |
---|
136 | rm -rf $log ; touch $log |
---|
137 | # make a re-usable command |
---|
138 | echo "#! /bin/bash" > $refrepo/compile_gcm.sh |
---|
139 | echo "cd $refrepo/code/LMDZ.COMMON" >> $refrepo/compile_gcm.sh |
---|
140 | echo "./makelmdz_fcm -cpp MESOINI -j 8 -d $dimgcm -arch $machine$fortcom -parallel mpi -p mars gcm" >> $refrepo/compile_gcm.sh |
---|
141 | echo "./makelmdz_fcm -j 8 -d $dimgcm -arch $machine$fortcom -p mars newstart" >> $refrepo/compile_gcm.sh |
---|
142 | 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 |
---|
143 | 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 |
---|
144 | chmod 755 $refrepo/compile_gcm.sh |
---|
145 | # now execute command |
---|
146 | $refrepo/compile_gcm.sh > $log 2> $log |
---|
147 | |
---|
148 | ## ------------------------ |
---|
149 | ## make a minimal startbase |
---|
150 | ## ------------------------ |
---|
151 | echo "*** make a minimal startbase" |
---|
152 | cd $refrepo/gcm/newstart |
---|
153 | ./mini_startbase.sh |
---|
154 | |
---|
155 | fi |
---|
156 | |
---|
157 | ################################### |
---|
158 | ################################### MESO |
---|
159 | ################################### |
---|
160 | |
---|
161 | ## START MESOSCALE PART |
---|
162 | if [[ "${meso}" == "on" ]] |
---|
163 | then |
---|
164 | |
---|
165 | ### |
---|
166 | if [[ "${gcm}" == "old" ]] |
---|
167 | then |
---|
168 | option="" |
---|
169 | else |
---|
170 | option="-p mars_lmd_new" |
---|
171 | fi |
---|
172 | ### |
---|
173 | |
---|
174 | ## ---------------------- |
---|
175 | ## get and make mesoscale |
---|
176 | ## ---------------------- |
---|
177 | echo "*** compile mesoscale" |
---|
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 | |
---|