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

Last change on this file since 6333 was 6299, checked in by jgipsl, 17 months ago

Add a quickfix related to the subversion module. If there was a module for subversion loaded in the begining of the compilation, the same module will be loaded after the arch.env file has been sourced. We here suppose that the arch.env file contains a module purge which is currently the case for the arch.env in ARCH folder. This quickfix was done previously in ICOLMDZ configurations by A. Caubel.

Note that for compile_lmdzorinca.sh only an echo was added.

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