source: CONFIG/UNIFORM/v6/LMDZOR_v6.4/compile_lmdzor.sh @ 6684

Last change on this file since 6684 was 6684, checked in by nillod, 6 months ago

Update LMDZOR compile script to add -strataer option + remove former LMDZORSTRATAER config (not used and deprecated)

  • Property svn:executable set to *
File size: 13.7 KB
Line 
1#!/bin/bash
2#set -vx
3# Default options
4#
5#
6#
7date
8#### 1  Set up the compiling options
9#### Define some directories
10submitdir=$( pwd )
11modipsl=$submitdir/../..
12arch_path=$submitdir/ARCH
13
14#### Set default options
15# Optimization mode
16# optmode=prod/dev/debug
17optmode=prod
18# Resolution of LMDZ in regular mode
19resol_atm=144x142x79
20# Also compile ce0l subprogram to LMDZ (y/n)
21ce0l=y
22
23# fcm_arch
24fcm_arch=default
25# Default values to be overritten
26parallel=mpi_omp
27# Compilation with rrtm or ecrad radiative code (default rad=rrtm)
28rad=rrtm
29opt_rad=""
30# Compilation with Cosp (cosp=NONE/v1/v2 ; default=NONE)
31cosp=NONE
32
33# Compilation with flag StratAer (option -strataer)
34opt_strataer=""
35
36export fcm_arch parallel xios
37full_flag=""
38full_xios=""
39full_lmdz=""
40full_orch=""
41
42# Default netcdf_lib is used for XIOS but can be change by argument
43netcdf_lib=""
44
45# Output text file for compilation of each component
46datestr=`LC_ALL=C date +"%Y%m%dT%H%M"`
47outfile=$submitdir/out_compile_lmdzor.$datestr
48echo > $outfile
49echo; echo "Text output from compilation will be stored in file out_compile_lmdzor.$datestr"; echo 
50
51#### Read arguments
52# Loop over all arguments to modify default set up
53while (($# > 0)) ; do
54    case $1 in
55        "-h") cat <<end_help
56########################################################################
57# Usage of the script compile_lmdzor.sh
58#
59########################################################################
60
61./compile_config [Options]
62
63Options: -full, -resol_atm, -debug, -dev, -prod(default)
64
65Example 1: Default compilation of LMDZ-ORCHIDEE with XIOS and IOIPSL
66./compile_lmdzor.sh
67
68Example 2: Compile in debug mode
69./compile_lmdzor.sh -debug
70
71Example 3: Default compilation with full recompilation of all components
72./compile_lmdzor.sh -full
73
74Example 4: Compilation of LMDZ in regular lat-lon for other dimensions (default: 144x142x79)
75The dimension can be changed to any other 3d dimension.
76./compile_lmdzor.sh -resol_atm 96x95x79
77
78end_help
79exit;;
80        "-parallel")        parallel=$2 ; shift ; shift ;;
81        "-rad")             rad=$2 ; shift ; shift ;;
82        "-cosp")            cosp=$2 ; shift ; shift ;;
83        "-strataer")        opt_strataer="-strataer true" ; shift ; shift ;;
84        "-arch")            fcm_arch="$2" ; shift ; shift ;;
85        "-xios")            xios="$2" ; shift ; shift ;;
86        "-debug")           optmode=debug ; shift ;;
87        "-dev")             optmode=dev ; shift ;;
88        "-prod")            optmode=prod ; shift ;;
89        "-resol_atm")       resol_atm=$2 ; shift ; shift ;;
90        "CE0L")             ce0l=y ; shift ;;
91        "-full")            full_flag="-full"; full_xios="--full" ; full_lmdz="-full" ; full_orch="-full" ; shift ;;
92        "-full_xios")       full_xios="--full" ; shift ;;  # Note only full_xios is using double dash: --full
93        "-full_lmdz")       full_lmdz="-full"  ; shift ;;
94        "-full_orch")       full_orch="-full"  ; shift ;;
95        "-netcdf_lib_seq")  netcdf_lib="--netcdf_lib netcdf4_seq"; shift ;;
96        *)                  echo "unknown option "$1" , exiting..." ; exit
97    esac
98done
99
100echo "Following options are set in current compiling:" >> $outfile 
101echo "   resol_atm=${resol_atm}" >> $outfile 
102echo "   ce0l=${ce0l}" >> $outfile 
103echo "   optmode = $optmode, parallel = $parallel, fcm_arch = $fcm_arch " >> $outfile 
104echo "   full_flag=$full_flag, full_xios=$full_xios, full_lmdz=$full_lmdz, full_orch=$full_orch" >> $outfile 
105echo >> $outfile
106
107if [ $cosp = v1 ] ; then
108    opt_cosp="-cosp true"
109elif [ $cosp = v2 ] ; then
110    opt_cosp="-cospv2 true"
111else
112    opt_cosp=""
113fi
114### Read host dependent default values
115### These variables will not be changed if they were set as argument
116###./host.sh $host
117# Later : Following lines should be set in host.sh file
118# begin host.sh
119if [ $fcm_arch == default ] ; then
120    # Find out current host and source specific paths and commands for the host
121    case $( hostname -s ) in
122        jean-zay*)
123            if [[ $( hostname -s ) != *"pp"* ]] ; then
124                echo "Warning! You MUST compile on jean-zay-pp."
125                echo "EXIT"
126                exit
127            else
128                fcm_arch=X64_JEANZAY
129            fi ;;
130        irene170|irene171|irene190|irene191|irene192|irene193)
131            fcm_arch=X64_IRENE;;
132        irene172|irene173|irene194|irene195)
133            fcm_arch=X64_IRENE-AMD;;
134        asterix*|obelix*)
135            fcm_arch=ifort_LSCE
136            if [ "${parallel}" == "mpi_omp" ] ; then
137                echo "Warning!! Currently at Obelix hybrid mode is not possible."
138                echo "          Option -parallel mpi_omp is now changed to -parallel mpi"
139                echo ""
140                parallel=mpi
141            else
142                echo "You used -parallel" $parallel
143            fi ;;
144        spirit*)
145            fcm_arch=ifort_MESOIPSL;;
146        ciclad*|climserv*|loholt*|camelot*)
147            fcm_arch=ifort_CICLAD;;
148        *)
149            echo Current host is not known. You must use option -arch to specify which architecuture files to use.
150            echo Exit now.
151            exit
152    esac
153fi
154
155# Set a link to arch.env if arch-${fcm_arch}.env file exist for current fcm_arch.
156# The link arch.env is also set in config.card and will be used by libIGCM to ensure the same running environnement.
157if [ -f ARCH/arch-${fcm_arch}.env ] ; then
158    echo >> $outfile
159    echo "The file ARCH/arch-${fcm_arch}.env will now be sourced with modules needed for compilation for all components."
160    echo "Note that this new environement might be kept after compilation." 
161    echo "If this is the case, source again your personal environment after compilation. "
162    echo " Personal module list before sourcing of ARCH/arch.env file:"    >> $outfile 
163    module list   >> $outfile 2>&1
164    # Get initial svn version
165    svn_version=$(module list -t | grep subversion)
166   
167    # Make a link to this file, to be used also in config.card
168    rm -f ARCH/arch.env
169    ln -s arch-${fcm_arch}.env ARCH/arch.env
170
171    # Source the file
172    source ARCH/arch.env   >> $outfile 2>&1
173    if [ X$svn_version != X ] ; then
174        # Put back initial version of svn
175        module load ${svn_version}
176    fi
177
178    echo >> $outfile 
179    echo " New module list after sourcing of ARCH/arch.env file:"    >> $outfile 
180    module list   >> $outfile 2>&1
181fi
182
183#### 2 Do the compilation
184## 2.1 Compile ioipsl
185cd $modipsl/modeles/IOIPSL
186echo; echo "NOW COMPILE IOIPSL"
187echo >> $outfile ; echo " NOW COMPILE IOIPSL"   >> $outfile 
188
189# Check if compilation with fcm is included in IOIPSL
190if [ ! -f makeioipsl_fcm ] ; then
191  echo "The file makeiopsl_fcm do not exist. Probably this is not the right version of IOIPSL."
192  echo "Version of IOIPSL with fcm compilation is needed to compile with this script. Stop now."
193  exit
194fi
195
196echo ./makeioipsl_fcm -$optmode -arch ${fcm_arch} -arch_path $arch_path -j 8 $full_flag   >> $outfile 
197     ./makeioipsl_fcm -$optmode -arch ${fcm_arch} -arch_path $arch_path -j 8 $full_flag   >> $outfile 2>&1
198# Test if compiling succeded
199if [[ $? != 0 ]] ; then
200    echo "THERE IS A PROBLEM IN IOIPSL COMPILATION - STOP"
201    exit
202fi
203
204## 2.2 Compile xios
205cd $modipsl/modeles/XIOS
206echo; echo "NOW COMPILE XIOS"
207echo >> $outfile ; echo " NOW COMPILE XIOS"   >> $outfile 
208echo ./make_xios --$optmode --arch $fcm_arch --arch_path $arch_path ${netcdf_lib} --job 4 $full_xios   >> $outfile 
209     ./make_xios --$optmode --arch $fcm_arch --arch_path $arch_path ${netcdf_lib} --job 4 $full_xios   >> $outfile 2>&1
210# Test if compiling succeded
211if [[ $? != 0 ]] ; then
212    echo "THERE IS A PROBLEM IN XIOS COMPILATION - STOP"
213    exit
214fi
215# Move executables to modipsl/bin
216if [ -f $modipsl/modeles/XIOS/bin/xios_server.exe ] ; then
217    mv $modipsl/modeles/XIOS/bin/xios_server.exe $modipsl/bin/xios_server_${optmode}.exe
218else
219    echo "THERE IS A PROBLEM IN XIOS COMPILATION EXECUTABLE MISSING - STOP"
220    exit
221fi
222
223
224## 2.3 Compile orchidee
225cd $modipsl/modeles/ORCHIDEE
226echo; echo "NOW COMPILE ORCHIDEE"
227echo >> $outfile ; echo " NOW COMPILE ORCHIDEE"   >> $outfile 
228
229
230# Check if the compilation of ORCHIDEE was previsouly interupted prematured.
231# In that case, the files fcm.bld.lock exist. If the file exist, it is here removed to avoid makeorchidee_fcm
232# to ask question and wait for interactivly answer from the user.
233if [ -f build/fcm.bld.lock ] ; then
234    echo >> $outfile
235    echo " WARNING!! The file ORCHIDEE/build/fcm.bld.lock exist. "   >> $outfile
236    echo "           This means that the compilation is either currently on going in another terminal was previous interupted before the end."   >> $outfile
237    echo "           The file will now be removed. "   >> $outfile
238    echo >> $outfile
239    rm -f build/fcm.bld.lock
240fi
241
242echo    ./makeorchidee_fcm -j 8 -xios -parallel $parallel -$optmode -arch ${fcm_arch} -arch_path $arch_path $full_orch -driver   >> $outfile 
243        ./makeorchidee_fcm -j 8 -xios -parallel $parallel -$optmode -arch ${fcm_arch} -arch_path $arch_path $full_orch -driver    >> $outfile 2>&1
244# Test if compiling finished
245if [[ $? != 0 ]] ; then
246    echo "THERE IS A PROBLEM IN ORCHIDEE COMPILATION - STOP"
247    exit
248fi
249
250# Rename executables to contain $optmode
251if [ -f $modipsl/bin/orchidee_ol ] ; then mv $modipsl/bin/orchidee_ol  $modipsl/bin/orchidee_ol_${optmode} ; fi
252if [ -f $modipsl/bin/orchideedriver ] ; then mv $modipsl/bin/orchideedriver  $modipsl/bin/orchideedriver_${optmode} ; fi
253
254
255## 2.4 Compile LMDZ for regular latlon configuration
256cd $modipsl/modeles/LMDZ
257# Compile LMDZ regular lat-lon executable
258echo; echo "NOW COMPILE LMDZ REGULAR LAT-LON MODE. Resolution = ${resol_atm}"
259echo >> $outfile ; echo " NOW COMPILE LMDZ REGULAR LAT-LON MODE. Resolution = ${resol_atm}"   >> $outfile 
260# Retrieve the final svn release number, needed for radiative code suffix of executable
261lmdzsvn=`svnversion . | egrep -o "[0-9]+"  | awk 'NR==1'`
262echo >> $outfile ; echo "lmdzsvn= $lmdzsvn "   >> $outfile
263
264# Check if the compilation of LMDZ was previsouly interupted prematured.
265# In that case, the files dimension.h and .lock exist. If the files exist, they are here removed to avoid makelmdz_fcm
266# to ask question and wait for interactivly answer from the user.
267if [ -f libf/grid/dimensions.h ] || [ -f .lock ] ; then
268  echo >> $outfile
269  echo " WARNING!! The file LMDZ/libf/grid/dimension.h and/or the LMDZ/.lock exist. "   >> $outfile
270  echo "           This means that the compilation is either currently on going in another terminal was previous interupted before the end."   >> $outfile
271  echo "           The files dimension.h and .lock will now be removed. "   >> $outfile
272  echo >> $outfile
273  rm -f libf/grid/dimensions.h
274  rm -f .lock
275fi
276
277# Need to define the proper option for radiative code compilation. By default, we use rrtm
278case $rad in
279    oldrad) opt_rad="" ;;
280    rrtm)   if [ $lmdzsvn -le 4185 ] ; then opt_rad="-rrtm true" ; else opt_rad="-rad rrtm" ; fi ;;
281    ecrad)  opt_rad="-rad ecrad" ;;
282    *) echo Only oldrad rrtm ecrad for rad option ; exit
283esac
284
285if [ $lmdzsvn -le 4185 -a $rad = "ecrad" ] ; then echo "ecrad only available for LMDZ rev starting with 4186 " ; exit ; fi
286
287
288echo ./makelmdz_fcm -d ${resol_atm} -p lmd  $opt_rad $opt_cosp $opt_strataer -$optmode -parallel $parallel -io xios -v orchidee2.1 -arch $fcm_arch -arch_path $arch_path -j 8 $full_lmdz gcm    >> $outfile 
289./makelmdz_fcm -d ${resol_atm} -p lmd  $opt_rad $opt_strataer -$optmode -parallel $parallel -io xios -v orchidee2.1 -arch $fcm_arch -arch_path $arch_path -j 8 $full_lmdz gcm    >> $outfile 2>&1
290# Test if compiling finished
291if [[ $? != 0 ]] ; then
292    echo "THERE IS A PROBLEM IN LMDZ REGULAR LATLON COMPILATION - STOP"
293    exit
294fi
295
296# Move executables to modipsl/bin folder
297echo >> $outfile
298echo "Move gcm.e executable to modipsl/bin" >> $outfile
299echo ls -lrt $modipsl/modeles/LMDZ/bin   >> $outfile
300ls -lrt $modipsl/modeles/LMDZ/bin  >> $outfile
301echo >> $outfile
302
303suffix=${resol_atm}_phylmd
304if [ $lmdzsvn -ge 4186 ] ; then suffix=${suffix}_${rad} ; fi
305if [ $parallel == seq ] || [ $parallel == none ] ; then
306    suffix=_${suffix}_seq_orch.e
307else
308    suffix=_${suffix}_para_mem_orch.e
309fi
310echo gcm suffix = $suffix
311
312if [ -f $modipsl/modeles/LMDZ/bin/gcm${suffix} ] ;  then
313    mv $modipsl/modeles/LMDZ/bin/gcm${suffix} $modipsl/bin/gcm_${resol_atm}_${optmode}.e
314else
315    echo "ERROR gcm${suffix} executable does not exist." 
316    echo "THERE IS A PROBLEM IN LMDZ REGULAR LATLON COMPILATION - STOP"
317    exit
318fi 
319
320
321# Compile ce0l initialization program for LMDZ regular lat-lon exectuable
322if [ $ce0l == y ] ; then
323    echo; echo "NOW COMPILE CE0L OF LMDZ. Resolution = ${resol_atm}"
324    echo >> $outfile ; echo " NOW COMPILE CE0L OF LMDZ. Resolution = ${resol_atm}"   >> $outfile 
325   
326    echo ./makelmdz_fcm -d ${resol_atm} -p lmd  $opt_rad -$optmode -arch $fcm_arch -arch_path $arch_path -j 8 $full_lmdz ce0l    >> $outfile 
327    ./makelmdz_fcm -d ${resol_atm} -p lmd  $opt_rad -$optmode -arch $fcm_arch -arch_path $arch_path -j 8 $full_lmdz ce0l    >> $outfile 2>&1
328    # Test if compiling finished
329    if [[ $? != 0 ]] ; then
330        echo "THERE IS A PROBLEM IN CE0L (LMDZ) REGULAR LATLON COMPILATION - STOP"
331        exit
332    fi
333
334   
335    # Move executables to modipsl/bin folder
336    echo >> $outfile
337    echo "Move ce0l.e executable to modipsl/bin" >> $outfile
338    echo ls -lrt $modipsl/modeles/LMDZ/bin   >> $outfile
339    ls -lrt $modipsl/modeles/LMDZ/bin  >> $outfile
340    echo >> $outfile
341    suffix=_${resol_atm}_phylmd_seq.e
342    if [ $lmdzsvn -ge 4186 ] ; then suffix=_${resol_atm}_phylmd_${rad}_seq.e ; fi
343    echo ce0l suffix = $suffix
344
345    if [ -f $modipsl/modeles/LMDZ/bin/ce0l${suffix} ] ;  then
346        mv $modipsl/modeles/LMDZ/bin/ce0l${suffix} $modipsl/bin/ce0l_${resol_atm}_${optmode}.e
347    else
348        echo "ERROR ce0l${suffix} executable does not exist." 
349        echo "THERE IS A PROBLEM IN CE0L (LMDZ) REGULAR LATLON COMPILATION - STOP"
350        exit
351    fi 
352fi
353
354
355echo >>$outfile ; echo "ALL COMPILING FINISHED" >> $outfile
356echo ls -lrt modipsl/bin >> $outfile
357ls -lrt $modipsl/bin >> $outfile
358
359echo; echo "ALL COMPILING FINISHED" ; echo
360echo "Executables are found in modipsl/bin"
361echo "Check that executable names correspond with the name set in config.card before launching the job"
362echo ls -lrt modipsl/bin
363ls -lrt $modipsl/bin
364
365date
366
367exit
Note: See TracBrowser for help on using the repository browser.