[1471] | 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 |
---|
[1568] | 12 | name="MESORUN" |
---|
[2445] | 13 | ## git version or tag |
---|
| 14 | version="tags/mesoscale-jezero" |
---|
| 15 | version="tags/gcm-mesoini-ok" |
---|
[2472] | 16 | version="841f9fc0b74168c34dbbcd47fef2544654a3d763" #2315 |
---|
| 17 | version="tags/mesoscale-compile-run" |
---|
[2853] | 18 | version="tags/mesoscale-compile-run_MESOIPSL" |
---|
[2472] | 19 | ## once folder created, code may be updated using git reset --hard $commit_SHA |
---|
[1471] | 20 | ################################ |
---|
| 21 | |
---|
[1568] | 22 | meso="on" |
---|
[1613] | 23 | gcm="" |
---|
[1852] | 24 | gcmcompile="on" |
---|
[1865] | 25 | fortcom="ifort" |
---|
[2876] | 26 | while getopts "gn:hv:f:ola:" options; do |
---|
[1471] | 27 | case $options in |
---|
| 28 | n ) name="${OPTARG}";; |
---|
[1568] | 29 | g ) meso="off";; |
---|
[1613] | 30 | v ) version="${OPTARG}";; |
---|
| 31 | o ) gcm="old" ;; |
---|
[1865] | 32 | f ) fortcom="${OPTARG}" ;; |
---|
[2876] | 33 | a ) archive="${OPTARG}" ;; |
---|
[1471] | 34 | h ) echo " |
---|
| 35 | # OPTIONS |
---|
[1613] | 36 | # -n [name] --> name of the folder to be created |
---|
| 37 | # -g --> only compile GCM (for tests) |
---|
[2445] | 38 | # -v [version/tag] --> git commit or tag |
---|
[1613] | 39 | # -o --> old GCM+meso version |
---|
[1865] | 40 | # -f --> fortran compiler (experimental) |
---|
[2876] | 41 | # -a [name] --> compile from a tar.gz archive (only provide basename) |
---|
[1471] | 42 | " ; exit ;; |
---|
| 43 | esac |
---|
| 44 | done |
---|
| 45 | |
---|
| 46 | ################################ |
---|
| 47 | ## machine on which you will compile |
---|
| 48 | machine="CICLAD" |
---|
[2852] | 49 | machine="MESOIPSL" |
---|
[1471] | 50 | ## server for sources |
---|
[2474] | 51 | where_is_svn="https://svn.lmd.jussieu.fr/Planeto/trunk/" |
---|
[2445] | 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 |
---|
[1471] | 56 | ## grid definition for GCM |
---|
| 57 | dimgcm="64x48x29" |
---|
| 58 | ## location of static data |
---|
[2853] | 59 | webrepo="http://web.lmd.jussieu.fr/~aslmd/mesoscale_model/data_static/" |
---|
[1865] | 60 | ## TBD: datadir: http://www.lmd.jussieu.fr/~lmdz/planets/mars/datadir/ |
---|
[2472] | 61 | ## wget -r -np --cut-dirs=3 -nH https://www.lmd.jussieu.fr/~lmdz/planets/mars/datadir/ |
---|
[1471] | 62 | ################################ |
---|
| 63 | |
---|
| 64 | ## ----------------------------- |
---|
| 65 | ## import settings and structure |
---|
| 66 | ## ----------------------------- |
---|
| 67 | echo "*** get structure" |
---|
| 68 | rm -rf $name > /dev/null 2> /dev/null |
---|
[1613] | 69 | svn -q co $where_is_svn"/MESOSCALE/LMD_MM_MARS/SIMU/MESORUN"$gcm $name |
---|
[1471] | 70 | refrepo=$PWD/$name |
---|
| 71 | ## fill here user input to obtain independent script |
---|
[1613] | 72 | case ${fortcom}$gcm in |
---|
| 73 | "ifort") echo 1 > $refrepo/wpsin ; echo 5 > $refrepo/mesoin ; echo 1 >> $refrepo/mesoin ;; |
---|
[1852] | 74 | "ifortold") echo 1 > $refrepo/wpsin ; echo 5 > $refrepo/mesoin ; echo 4 >> $refrepo/mesoin ; |
---|
[1873] | 75 | echo 61 >> $refrepo/mesoin ; echo 61 >> $refrepo/mesoin ; echo 61 >> $refrepo/mesoin ; |
---|
| 76 | echo 1 >> $refrepo/mesoin ; echo 1 >> $refrepo/mesoin ;; |
---|
[1865] | 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 ;; |
---|
[1471] | 81 | esac |
---|
| 82 | |
---|
| 83 | ## ---------------- |
---|
| 84 | ## create code repo |
---|
| 85 | ## ---------------- |
---|
[2876] | 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) |
---|
[2445] | 97 | echo "*** get gitlab repository" |
---|
[1556] | 98 | \rm $refrepo/code |
---|
[2852] | 99 | git clone --no-single-branch --depth $depth $where_is_git $refrepo/code |
---|
[2445] | 100 | echo "*** set a branch with same name as repo for version "$version |
---|
| 101 | cd $refrepo/code |
---|
| 102 | git checkout $version -b $name |
---|
[2876] | 103 | #### |
---|
| 104 | fi |
---|
[1471] | 105 | |
---|
[1613] | 106 | ################################### |
---|
| 107 | ################################### GCM |
---|
| 108 | ################################### |
---|
| 109 | if [[ "${gcm}" == "old" ]] |
---|
| 110 | then |
---|
[1471] | 111 | |
---|
[1873] | 112 | if [[ "${gcmcompile}" == "on" ]] |
---|
| 113 | then |
---|
| 114 | log=$refrepo/code/MESOSCALE/LMDZ.MARS/logcompile_gcm |
---|
[2445] | 115 | echo "*** compile GCM" |
---|
[1873] | 116 | cd $refrepo/code/MESOSCALE/LMDZ.MARS |
---|
| 117 | ln -sf makegcm_$fortcom makegcm |
---|
| 118 | ./compile > $log 2> $log |
---|
| 119 | fi |
---|
[1613] | 120 | |
---|
[2445] | 121 | fi |
---|
[1471] | 122 | |
---|
[1852] | 123 | ## START compiling GCM PART |
---|
| 124 | if [[ "${gcmcompile}" == "on" ]] |
---|
| 125 | then |
---|
| 126 | |
---|
[1613] | 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 . |
---|
[1471] | 130 | |
---|
[1613] | 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 |
---|
[2205] | 138 | if [[ "${machine}" == "CICLAD" ]] |
---|
| 139 | then |
---|
[2444] | 140 | ./install_ioipsl_ciclad-ifort.bash > $log 2> $log |
---|
[2205] | 141 | else |
---|
[2852] | 142 | ./install_ioipsl_${fortcom}_${machine}".bash" > $log 2> $log |
---|
[2205] | 143 | fi |
---|
[1613] | 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 |
---|
[1630] | 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 |
---|
[2852] | 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 |
---|
[1630] | 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 |
---|
[1613] | 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 | |
---|
[1568] | 181 | ## START MESOSCALE PART |
---|
| 182 | if [[ "${meso}" == "on" ]] |
---|
| 183 | then |
---|
| 184 | |
---|
[1873] | 185 | ### |
---|
| 186 | if [[ "${gcm}" == "old" ]] |
---|
| 187 | then |
---|
| 188 | option="" |
---|
| 189 | else |
---|
| 190 | option="-p mars_lmd_new" |
---|
| 191 | fi |
---|
| 192 | ### |
---|
| 193 | |
---|
[1471] | 194 | ## ---------------------- |
---|
| 195 | ## get and make mesoscale |
---|
| 196 | ## ---------------------- |
---|
[2445] | 197 | echo "*** compile mesoscale" |
---|
[1873] | 198 | cd $refrepo/code/MESOSCALE/LMD_MM_MARS |
---|
[1471] | 199 | ls $refrepo/mesoin |
---|
| 200 | if [[ "$?" == 0 ]] ; then |
---|
[1613] | 201 | ./makemeso $option < $refrepo/mesoin |
---|
[1471] | 202 | else |
---|
[1613] | 203 | ./makemeso $option |
---|
[1471] | 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 |
---|
[2852] | 227 | #### to avoid weird comments bug |
---|
| 228 | sed s+"-C -P"+"-P"+g configure.wps > yeah ; mv -f yeah configure.wps |
---|
| 229 | #### |
---|
[1471] | 230 | ./compile > logcompile 2>&1 |
---|
| 231 | |
---|
| 232 | ## ------------------ |
---|
| 233 | ## import static data |
---|
| 234 | ## ------------------ |
---|
| 235 | echo "*** get static data" |
---|
[1556] | 236 | rm -rf $refrepo/data_static |
---|
[1471] | 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 | |
---|
[1551] | 248 | ## ------------------------ |
---|
[1559] | 249 | ## get and compile postproc |
---|
| 250 | ## ------------------------ |
---|
| 251 | echo "*** get and compile post-processing tool" |
---|
[1561] | 252 | cd $refrepo |
---|
[1559] | 253 | svn co -q https://github.com/aymeric-spiga/api/trunk postproc |
---|
| 254 | cd $refrepo/postproc |
---|
| 255 | ./compile |
---|
| 256 | |
---|
[1568] | 257 | fi |
---|
| 258 | ## END MESOSCALE PART |
---|
| 259 | |
---|
[1471] | 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 |
---|
[1559] | 271 | ls -lL $refrepo/postproc/api |
---|
[1471] | 272 | |
---|