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 | version="tags/mesoscale-compile-run_MESOIPSL" |
---|
19 | ## once folder created, code may be updated using git reset --hard $commit_SHA |
---|
20 | ################################ |
---|
21 | |
---|
22 | meso="on" |
---|
23 | gcm="" |
---|
24 | gcmcompile="on" |
---|
25 | fortcom="ifort" |
---|
26 | while getopts "gn:hv:f:ola:" options; do |
---|
27 | case $options in |
---|
28 | n ) name="${OPTARG}";; |
---|
29 | g ) meso="off";; |
---|
30 | v ) version="${OPTARG}";; |
---|
31 | o ) gcm="old" ;; |
---|
32 | f ) fortcom="${OPTARG}" ;; |
---|
33 | a ) archive="${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 | # -f --> fortran compiler (experimental) |
---|
41 | # -a [name] --> compile from a tar.gz archive (only provide basename) |
---|
42 | " ; exit ;; |
---|
43 | esac |
---|
44 | done |
---|
45 | |
---|
46 | ################################ |
---|
47 | ## machine on which you will compile |
---|
48 | machine="CICLAD" |
---|
49 | machine="MESOIPSL" |
---|
50 | ## server for sources |
---|
51 | where_is_svn="https://svn.lmd.jussieu.fr/Planeto/trunk/" |
---|
52 | ## server for sources |
---|
53 | where_is_git="git@gitlab.in2p3.fr:la-communaut-des-mod-les-atmosph-riques-plan-taires/git-trunk.git" |
---|
54 | ## depth of git checkout |
---|
55 | depth=500 # should be enough and avoid too big a directory |
---|
56 | ## grid definition for GCM |
---|
57 | dimgcm="64x48x29" |
---|
58 | ## location of static data |
---|
59 | webrepo="http://web.lmd.jussieu.fr/~aslmd/mesoscale_model/data_static/" |
---|
60 | ## TBD: datadir: http://www.lmd.jussieu.fr/~lmdz/planets/mars/datadir/ |
---|
61 | ## wget -r -np --cut-dirs=3 -nH https://www.lmd.jussieu.fr/~lmdz/planets/mars/datadir/ |
---|
62 | ################################ |
---|
63 | |
---|
64 | ## ----------------------------- |
---|
65 | ## import settings and structure |
---|
66 | ## ----------------------------- |
---|
67 | echo "*** get structure" |
---|
68 | rm -rf $name > /dev/null 2> /dev/null |
---|
69 | svn -q co $where_is_svn"/MESOSCALE/LMD_MM_MARS/SIMU/MESORUN"$gcm $name |
---|
70 | refrepo=$PWD/$name |
---|
71 | ## fill here user input to obtain independent script |
---|
72 | case ${fortcom}$gcm in |
---|
73 | "ifort") echo 1 > $refrepo/wpsin ; echo 5 > $refrepo/mesoin ; echo 1 >> $refrepo/mesoin ;; |
---|
74 | "ifortold") echo 1 > $refrepo/wpsin ; echo 5 > $refrepo/mesoin ; echo 4 >> $refrepo/mesoin ; |
---|
75 | echo 61 >> $refrepo/mesoin ; echo 61 >> $refrepo/mesoin ; echo 61 >> $refrepo/mesoin ; |
---|
76 | echo 1 >> $refrepo/mesoin ; echo 1 >> $refrepo/mesoin ;; |
---|
77 | "gnuold") echo 10 > $refrepo/wpsin ; echo 8 > $refrepo/mesoin ; |
---|
78 | echo 61 >> $refrepo/mesoin ; echo 61 >> $refrepo/mesoin ; echo 61 >> $refrepo/mesoin ; |
---|
79 | echo 1 >> $refrepo/mesoin ; echo 1 >> $refrepo/mesoin ;; |
---|
80 | *) echo "compiler not supported" ; exit ;; |
---|
81 | esac |
---|
82 | |
---|
83 | ## ---------------- |
---|
84 | ## create code repo |
---|
85 | ## ---------------- |
---|
86 | if [[ "${archive}" != "" ]] |
---|
87 | then |
---|
88 | #### archive mode (backup plan) |
---|
89 | echo "*** installing from archive" |
---|
90 | \rm $refrepo/code |
---|
91 | tar xzvf ${archive}".tar.gz" > /dev/null |
---|
92 | mv ${archive} $refrepo/code |
---|
93 | cd $refrepo/code |
---|
94 | pwd |
---|
95 | else |
---|
96 | #### normal mode (gitlab) |
---|
97 | echo "*** get gitlab repository" |
---|
98 | \rm $refrepo/code |
---|
99 | git clone --no-single-branch --depth $depth $where_is_git $refrepo/code |
---|
100 | echo "*** set a branch with same name as repo for version "$version |
---|
101 | cd $refrepo/code |
---|
102 | git checkout $version -b $name |
---|
103 | #### |
---|
104 | fi |
---|
105 | |
---|
106 | ################################### |
---|
107 | ################################### GCM |
---|
108 | ################################### |
---|
109 | if [[ "${gcm}" == "old" ]] |
---|
110 | then |
---|
111 | |
---|
112 | if [[ "${gcmcompile}" == "on" ]] |
---|
113 | then |
---|
114 | log=$refrepo/code/MESOSCALE/LMDZ.MARS/logcompile_gcm |
---|
115 | echo "*** compile GCM" |
---|
116 | cd $refrepo/code/MESOSCALE/LMDZ.MARS |
---|
117 | ln -sf makegcm_$fortcom makegcm |
---|
118 | ./compile > $log 2> $log |
---|
119 | fi |
---|
120 | |
---|
121 | fi |
---|
122 | |
---|
123 | ## START compiling GCM PART |
---|
124 | if [[ "${gcmcompile}" == "on" ]] |
---|
125 | then |
---|
126 | |
---|
127 | cd $refrepo/code/LMDZ.COMMON |
---|
128 | svn -q co http://forge.ipsl.jussieu.fr/fcm/svn/PATCHED/FCM_V1.2 |
---|
129 | ln -sf FCM_V1.2/bin/fcm . |
---|
130 | |
---|
131 | ## -------------- |
---|
132 | ## compile IOIPSL |
---|
133 | ## -------------- |
---|
134 | log=$refrepo/code/logcompile_ioipsl |
---|
135 | echo "*** compile IOIPSL: check progress in "$log |
---|
136 | rm -rf $log ; touch $log |
---|
137 | cd $refrepo/code/LMDZ.COMMON/ioipsl |
---|
138 | if [[ "${machine}" == "CICLAD" ]] |
---|
139 | then |
---|
140 | ./install_ioipsl_ciclad-ifort.bash > $log 2> $log |
---|
141 | else |
---|
142 | ./install_ioipsl_${fortcom}_${machine}".bash" > $log 2> $log |
---|
143 | fi |
---|
144 | |
---|
145 | ## ----------- |
---|
146 | ## compile GCM |
---|
147 | ## ----------- |
---|
148 | log=$refrepo/code/logcompile_gcm |
---|
149 | echo "*** compile GCM: check progress in "$log |
---|
150 | rm -rf $log ; touch $log |
---|
151 | # make a re-usable command |
---|
152 | echo "#! /bin/bash" > $refrepo/compile_gcm.sh |
---|
153 | echo "cd $refrepo/code/LMDZ.COMMON" >> $refrepo/compile_gcm.sh |
---|
154 | if [[ "${machine}" == "CICLAD" ]] |
---|
155 | then |
---|
156 | echo "./makelmdz_fcm -cpp MESOINI -j 8 -d $dimgcm -arch $machine$fortcom -parallel mpi -p mars gcm" >> $refrepo/compile_gcm.sh |
---|
157 | echo "./makelmdz_fcm -j 8 -d $dimgcm -arch $machine$fortcom -p mars newstart" >> $refrepo/compile_gcm.sh |
---|
158 | else |
---|
159 | echo "./makelmdz_fcm -cpp MESOINI -j 8 -d $dimgcm -arch ${fortcom}_${machine} -parallel mpi -p mars gcm" >> $refrepo/compile_gcm.sh |
---|
160 | echo "./makelmdz_fcm -j 8 -d $dimgcm -arch ${fortcom}_${machine} -p mars newstart" >> $refrepo/compile_gcm.sh |
---|
161 | fi |
---|
162 | 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 |
---|
163 | 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 |
---|
164 | chmod 755 $refrepo/compile_gcm.sh |
---|
165 | # now execute command |
---|
166 | $refrepo/compile_gcm.sh > $log 2> $log |
---|
167 | |
---|
168 | ## ------------------------ |
---|
169 | ## make a minimal startbase |
---|
170 | ## ------------------------ |
---|
171 | echo "*** make a minimal startbase" |
---|
172 | cd $refrepo/gcm/newstart |
---|
173 | ./mini_startbase.sh |
---|
174 | |
---|
175 | fi |
---|
176 | |
---|
177 | ################################### |
---|
178 | ################################### MESO |
---|
179 | ################################### |
---|
180 | |
---|
181 | ## START MESOSCALE PART |
---|
182 | if [[ "${meso}" == "on" ]] |
---|
183 | then |
---|
184 | |
---|
185 | ### |
---|
186 | if [[ "${gcm}" == "old" ]] |
---|
187 | then |
---|
188 | option="" |
---|
189 | else |
---|
190 | option="-p mars_lmd_new" |
---|
191 | fi |
---|
192 | ### |
---|
193 | |
---|
194 | ## ---------------------- |
---|
195 | ## get and make mesoscale |
---|
196 | ## ---------------------- |
---|
197 | echo "*** compile mesoscale" |
---|
198 | cd $refrepo/code/MESOSCALE/LMD_MM_MARS |
---|
199 | ls $refrepo/mesoin |
---|
200 | if [[ "$?" == 0 ]] ; then |
---|
201 | ./makemeso $option < $refrepo/mesoin |
---|
202 | else |
---|
203 | ./makemeso $option |
---|
204 | fi |
---|
205 | rm -rf $refrepo/mesoin |
---|
206 | |
---|
207 | ## ------------------------------- |
---|
208 | ## make ini&bdy tools in mesoscale |
---|
209 | ## ------------------------------- |
---|
210 | echo "*** compile initialization tools" |
---|
211 | cd $refrepo/code_compiled |
---|
212 | ln -sf $refrepo/code/MESOSCALE/LMD_MM_MARS/SRC/SCRIPTS/prepare_ini . |
---|
213 | ./prepare_ini > /dev/null |
---|
214 | ## |
---|
215 | cd $refrepo/code_compiled/PREP_MARS |
---|
216 | ./compile"_"$fortcom |
---|
217 | ## |
---|
218 | cd $refrepo/code_compiled/WPS |
---|
219 | ls $refrepo/wpsin |
---|
220 | if [[ "$?" == 0 ]] ; then |
---|
221 | ./configure < $refrepo/wpsin > /dev/null 2> /dev/null |
---|
222 | else |
---|
223 | ./configure |
---|
224 | fi |
---|
225 | rm -rf $refrepo/wpsin |
---|
226 | rm -rf logcompile |
---|
227 | #### to avoid weird comments bug |
---|
228 | sed s+"-C -P"+"-P"+g configure.wps > yeah ; mv -f yeah configure.wps |
---|
229 | #### |
---|
230 | ./compile > logcompile 2>&1 |
---|
231 | |
---|
232 | ## ------------------ |
---|
233 | ## import static data |
---|
234 | ## ------------------ |
---|
235 | echo "*** get static data" |
---|
236 | rm -rf $refrepo/data_static |
---|
237 | svn co -q $where_is_svn/MESOSCALE/LMD_MM_MARS/WPS_GEOG $refrepo/data_static |
---|
238 | cd $refrepo/data_static |
---|
239 | rm -rf logdown |
---|
240 | wget $webrepo"/albedo_TES.tar.gz" -a logdown |
---|
241 | wget $webrepo"/mola_topo64.tar.gz" -a logdown |
---|
242 | wget $webrepo"/thermal_TES.tar.gz" -a logdown |
---|
243 | for fff in *.tar.gz; do |
---|
244 | tar xzvf $fff > /dev/null |
---|
245 | rm -rf $fff |
---|
246 | done |
---|
247 | |
---|
248 | ## ------------------------ |
---|
249 | ## get and compile postproc |
---|
250 | ## ------------------------ |
---|
251 | echo "*** get and compile post-processing tool" |
---|
252 | cd $refrepo |
---|
253 | svn co -q https://github.com/aymeric-spiga/api/trunk postproc |
---|
254 | cd $refrepo/postproc |
---|
255 | ./compile |
---|
256 | |
---|
257 | fi |
---|
258 | ## END MESOSCALE PART |
---|
259 | |
---|
260 | ## ----- |
---|
261 | ## check |
---|
262 | ## ----- |
---|
263 | echo "*** CHECKLIST:" |
---|
264 | ls -lL $refrepo/gcm/gcm.e |
---|
265 | ls -lL $refrepo/geogrid/geogrid.exe |
---|
266 | ls -lL $refrepo/metgrid/metgrid.exe |
---|
267 | ls -lL $refrepo/prep/readmeteo.exe |
---|
268 | ls -lL $refrepo/data_static/albedo_TES |
---|
269 | ls -lL $refrepo/real.exe |
---|
270 | ls -lL $refrepo/wrf.exe |
---|
271 | ls -lL $refrepo/postproc/api |
---|
272 | |
---|