source: CONFIG/UNIFORM/v6/LMDZREPR_v6/compile_lmdzrepr.sh @ 6363

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