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

Last change on this file since 6484 was 6484, checked in by acosce, 13 months ago

Update to compile on redhat8
(en attendant de pouvoir utiliser la nouvelle testing de LMDZ sur toutes les machines)

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