source: trunk/MESOSCALE/LMD_MM_MARS/SIMU/meso_install.sh

Last change on this file was 2876, checked in by aslmd, 22 months ago

mesoscale installer: adding an option to compile from a tar.gz archive (e.g. releases or external users)

File size: 7.9 KB
RevLine 
[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]12name="MESORUN"
[2445]13## git version or tag
14version="tags/mesoscale-jezero"
15version="tags/gcm-mesoini-ok"
[2472]16version="841f9fc0b74168c34dbbcd47fef2544654a3d763" #2315
17version="tags/mesoscale-compile-run"
[2853]18version="tags/mesoscale-compile-run_MESOIPSL"
[2472]19## once folder created, code may be updated using git reset --hard $commit_SHA
[1471]20################################
21
[1568]22meso="on"
[1613]23gcm=""
[1852]24gcmcompile="on"
[1865]25fortcom="ifort"
[2876]26while 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
44done
45
46################################
47## machine on which you will compile
48machine="CICLAD"
[2852]49machine="MESOIPSL"
[1471]50## server for sources
[2474]51where_is_svn="https://svn.lmd.jussieu.fr/Planeto/trunk/"
[2445]52## server for sources
53where_is_git="git@gitlab.in2p3.fr:la-communaut-des-mod-les-atmosph-riques-plan-taires/git-trunk.git"
54## depth of git checkout
55depth=500 # should be enough and avoid too big a directory
[1471]56## grid definition for GCM
57dimgcm="64x48x29"
58## location of static data
[2853]59webrepo="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## -----------------------------
67echo "*** get structure"
68rm -rf $name > /dev/null 2> /dev/null
[1613]69svn -q co $where_is_svn"/MESOSCALE/LMD_MM_MARS/SIMU/MESORUN"$gcm $name
[1471]70refrepo=$PWD/$name
71## fill here user input to obtain independent script
[1613]72case ${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]81esac
82
83## ----------------
84## create code repo
85## ----------------
[2876]86if [[ "${archive}" != "" ]]
87then
88#### archive mode (backup plan)
89echo "*** installing from archive"
90\rm $refrepo/code
91tar xzvf ${archive}".tar.gz" > /dev/null
92mv ${archive} $refrepo/code
93cd $refrepo/code
94pwd
95else
96#### normal mode (gitlab)
[2445]97echo "*** get gitlab repository"
[1556]98\rm $refrepo/code
[2852]99git clone --no-single-branch --depth $depth $where_is_git $refrepo/code
[2445]100echo "*** set a branch with same name as repo for version "$version
101cd $refrepo/code
102git checkout $version -b $name
[2876]103####
104fi
[1471]105
[1613]106###################################
107################################### GCM
108###################################
109if [[ "${gcm}" == "old" ]]
110then
[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]121fi
[1471]122
[1852]123## START compiling GCM PART
124if [[ "${gcmcompile}" == "on" ]]
125then
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
175fi
176
177###################################
178################################### MESO
179###################################
180
[1568]181## START MESOSCALE PART
182if [[ "${meso}" == "on" ]]
183then
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]197echo "*** compile mesoscale"
[1873]198cd $refrepo/code/MESOSCALE/LMD_MM_MARS
[1471]199ls $refrepo/mesoin
200if [[ "$?" == 0 ]] ; then
[1613]201  ./makemeso $option < $refrepo/mesoin
[1471]202else
[1613]203  ./makemeso $option
[1471]204fi
205rm -rf $refrepo/mesoin
206
207## -------------------------------
208## make ini&bdy tools in mesoscale
209## -------------------------------
210echo "*** compile initialization tools"
211cd $refrepo/code_compiled
212ln -sf $refrepo/code/MESOSCALE/LMD_MM_MARS/SRC/SCRIPTS/prepare_ini .
213./prepare_ini > /dev/null
214##
215cd $refrepo/code_compiled/PREP_MARS
216./compile"_"$fortcom
217##
218cd $refrepo/code_compiled/WPS
219ls $refrepo/wpsin
220if [[ "$?" == 0 ]] ; then
221  ./configure < $refrepo/wpsin > /dev/null 2> /dev/null
222else
223  ./configure
224fi
225rm -rf $refrepo/wpsin
226rm -rf logcompile
[2852]227#### to avoid weird comments bug
228sed 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## ------------------
235echo "*** get static data"
[1556]236rm -rf $refrepo/data_static
[1471]237svn co -q $where_is_svn/MESOSCALE/LMD_MM_MARS/WPS_GEOG $refrepo/data_static
238cd $refrepo/data_static
239rm -rf logdown
240wget $webrepo"/albedo_TES.tar.gz" -a logdown
241wget $webrepo"/mola_topo64.tar.gz" -a logdown
242wget $webrepo"/thermal_TES.tar.gz" -a logdown
243for fff in *.tar.gz; do
244  tar xzvf $fff > /dev/null
245  rm -rf $fff
246done
247
[1551]248## ------------------------
[1559]249## get and compile postproc
250## ------------------------
251echo "*** get and compile post-processing tool"
[1561]252cd $refrepo
[1559]253svn co -q https://github.com/aymeric-spiga/api/trunk postproc
254cd $refrepo/postproc
255./compile
256
[1568]257fi
258## END MESOSCALE PART
259
[1471]260## -----
261## check
262## -----
263echo "*** CHECKLIST:"
264ls -lL $refrepo/gcm/gcm.e
265ls -lL $refrepo/geogrid/geogrid.exe
266ls -lL $refrepo/metgrid/metgrid.exe
267ls -lL $refrepo/prep/readmeteo.exe
268ls -lL $refrepo/data_static/albedo_TES
269ls -lL $refrepo/real.exe
270ls -lL $refrepo/wrf.exe
[1559]271ls -lL $refrepo/postproc/api
[1471]272
Note: See TracBrowser for help on using the repository browser.