source: CONFIG/UNIFORM/v6/LMDZORINCA_v6.2/compile_lmdzorinca.sh @ 6567

Last change on this file since 6567 was 6541, checked in by acosce, 11 months ago

we don't need any more external sources adapted for redhat8. LMDZ is now update to run on redhat8

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