source: CONFIG/UNIFORM/v7/ICOLMDZORINCA_v7/compile_icolmdzorinca.sh @ 5958

Last change on this file since 5958 was 5958, checked in by acosce, 3 years ago

add option in compilation script

  • ico_only : to compile only ico grid
  • reg_only : to compile only reg grid
  • ce0l : to activate compilation of create_etat0_limit (+ gcm.e)
  • Property svn:executable set to *
File size: 16.9 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
13export ROOT=$modipsl/modeles/DYNAMICO
14
15#### Set default options
16# Optimization mode
17# optmode=prod/dev/debug
18optmode=prod
19# Resolution if compiling LMDZ in regular mode without DYNAMICO
20# Use for example following "./compile_icolmdzorinca.sh -regular_latlon 144x142x79"
21regular_latlon=no
22# fcm_arch
23fcm_arch=default
24# Default values to be overritten
25parallel=mpi_omp
26export fcm_arch parallel xios
27full_flag=""
28full_xios=""
29full_lmdz=""
30full_orch=""
31full_dyna=""
32ico_only=no
33reg_only=no
34ce0l=no
35optchimie=GES
36resol_atm="144x142x79"
37
38# Default netcdf_lib is used for XIOS but can be change by argument
39netcdf_lib=""
40
41# Output text file for compilation of each component
42datestr=`LC_ALL=C date +"%Y%m%dT%H%M"`
43outfile=$submitdir/out_compile_icolmdzorinca.$datestr
44echo > $outfile
45echo; echo "Text output from compilation will be stored in file out_compile_icolmdzorinca.$datestr"; echo 
46
47#### Read arguments
48# Loop over all arguments to modify default set up
49while (($# > 0)) ; do
50    case $1 in
51        "-h") cat <<end_help
52
53########################################################################
54# Usage of the script compile_icolmdzorinca.sh
55#
56########################################################################
57
58./compile_config [Options]
59
60Options: -full, -regular_latlon, -debug, -dev, -prod(default)
61
62Example 1: Default compilation of DYNAMICO-LMDZ-ORCHIDEE with XIOS and IOIPSL
63./compile_icolmdzorinca.sh
64
65Example 2: Compile in debug mode
66./compile_icolmdzorinca.sh -debug
67
68Example 3: Default compilation with full recompilation of all components
69./compile_icolmdzorinca.sh -full
70
71Example 4: Compilation of LMDZ in regular lat-lon for dimension 144x142x79.
72The dimension can be changed to any other 3d dimension. DYNAMICO is also compiled as default.
73./compile_icolmdzorinca.sh -regular_latlon 144x142x79
74
75Example 5: Compilation with a chosen chemistry, for example DUSS  (default: NMHC_AER_S)
76./compile_icolmdzorinca.sh -chimie DUSS
77
78Example 6: Compile only ico grid
79./compile_icolmdzorinca.sh -ico_only
80
81Example 7: Compile only reg grid
82./compile_icolmdzorinca.sh -reg_only
83
84Example 8 : compile create_etat0_limit (and gcm.e)
85./compile_icolmdzorinca.sh -ce0l
86
87end_help
88            exit;;
89
90        "-parallel")        parallel=$2 ; shift ; shift ;;
91        "-arch")            fcm_arch="$2" ; shift ; shift ;;
92        "-xios")            xios="$2" ; shift ; shift ;;
93        "-debug")           optmode=debug ; shift ;;
94        "-dev")             optmode=dev ; shift ;;
95        "-prod")            optmode=prod ; shift ;;
96        "-regular_latlon")  regular_latlon=yes ; resol_atm=$2 ; shift ; shift ;;
97        "-full")            full_flag="-full"; full_xios="--full" ; full_lmdz="-full" ; full_orch="-full" ; full_dyna="-full" ; shift ;;
98        "-full_xios")       full_xios="--full" ; shift ;;  # Note only full_xios is using double dash: --full
99        "-full_lmdz")       full_lmdz="-full"  ; shift ;;
100        "-full_orch")       full_orch="-full"  ; shift ;;
101        "-full_dyna")       full_dyna="-full"  ; shift ;;
102        "-ico_only")        ico_only=yes  ; shift ;;
103        "-reg_only")        reg_only=yes  ; shift ;;
104        "-ce0l")            ce0l=yes  ; shift ;;
105        "-netcdf_lib_seq")  netcdf_lib="--netcdf_lib netcdf4_seq"; shift ;;
106        "-chimie")          optchimie=$2; shift ; shift;;
107
108        *)                  echo "unknown option "$1" , exiting..." ;  exit
109    esac
110done
111
112echo "Following options are set in current compiling:" >> $outfile 
113echo "   regular_latlon=$regular_latlon (if yes, then resol_atm=${resol_atm})" >> $outfile 
114echo "   optmode = $optmode, parallel = $parallel, fcm_arch = $fcm_arch " >> $outfile 
115echo "   full_flag=$full_flag, full_xios=$full_xios, full_lmdz=$full_lmdz, full_orch=$full_orch, full_dyna=$full_dyna" >> $outfile 
116echo >> $outfile
117
118### Read host dependent default values
119### These variables will not be changed if they were set as argument
120###./host.sh $host
121# Later : Following lines should be set in host.sh file
122# begin host.sh
123if [ $fcm_arch == default ] ; then
124    # Find out current host and source specific paths and commands for the host
125    case $( hostname -s ) in
126        jean-zay*)
127            fcm_arch=X64_JEANZAY;;
128        irene170|irene171|irene190|irene191|irene192|irene193)
129            fcm_arch=X64_IRENE;;
130        irene172|irene173|irene194|irene195)
131            fcm_arch=X64_IRENE-AMD;;
132        asterix*|obelix*)
133            fcm_arch=ifort_LSCE
134            if [ "${parallel}" == "mpi_omp" ] ; then
135                echo "Warning!! Currently at Obelix hybrid mode is not possible."
136                echo "          Option -parallel mpi_omp is now changed to -parallel mpi"
137                echo ""
138                parallel=mpi
139            else
140                echo "You used -parallel" $parallel
141            fi ;;
142        ciclad*|climserv*|loholt*|camelot*)
143            fcm_arch=ifort_CICLAD;;
144        *)
145            echo Current host is not known. You must use option -arch to specify which architecuture files to use.
146            echo Exit now.
147            exit
148    esac
149fi
150
151# Set a link to arch.env if arch-${fcm_arch}.env file exist for current fcm_arch.
152# The link arch.env is also set in config.card and will be used by libIGCM to ensure the same running environnement.
153if [ -f ARCH/arch-${fcm_arch}.env ] ; then
154    echo >> $outfile
155    echo "The file ARCH/arch-${fcm_arch}.env will now be sourced with modules needed for compilation for all components."
156    echo "Note that this new environement might be kept after compilation."
157    echo "If this is the case, source again your personal environment after compilation."
158    echo " Personal module list before sourcing of ARCH/arch.env file:"    >> $outfile 
159    module list   >> $outfile 2>&1
160
161    # Make a link to this file, to be used also in config.card
162    rm -f ARCH/arch.env
163    ln -s arch-${fcm_arch}.env ARCH/arch.env
164
165    # Source the file
166    source ARCH/arch.env   >> $outfile 2>&1
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
179echo ./makeioipsl_fcm -$optmode -parallel -arch ${fcm_arch} -arch_path $arch_path -j 8 $full_flag   >> $outfile 
180     ./makeioipsl_fcm -$optmode -parallel -arch ${fcm_arch} -arch_path $arch_path -j 8 $full_flag   >> $outfile 2>&1
181# Test if compiling succeded
182if [[ $? != 0 ]] ; then
183    echo "THERE IS A PROBLEM IN IOIPSL COMPILATION - STOP"
184    echo "ALL INFORMATION IN FILE $outfile"
185    exit
186fi
187
188## 2.2 Compile xios
189cd $modipsl/modeles/XIOS
190echo; echo "NOW COMPILE XIOS"
191echo >> $outfile ; echo " NOW COMPILE XIOS"   >> $outfile 
192echo ./make_xios --$optmode --arch $fcm_arch --arch_path $arch_path ${netcdf_lib} --job 4 $full_xios   >> $outfile 
193     ./make_xios --$optmode --arch $fcm_arch --arch_path $arch_path ${netcdf_lib} --job 4 $full_xios   >> $outfile 2>&1
194# Test if compiling succeded
195if [[ $? != 0 ]] ; then
196    echo "THERE IS A PROBLEM IN XIOS COMPILATION - STOP"
197    echo "ALL INFORMATION IN FILE $outfile"
198    exit
199fi
200# Move executables to modipsl/bin
201if [ -f $modipsl/modeles/XIOS/bin/xios_server.exe ] ; then
202    mv $modipsl/modeles/XIOS/bin/xios_server.exe $modipsl/bin/xios_server_${optmode}.exe
203else
204    echo "THERE IS A PROBLEM IN XIOS COMPILATION EXECUTABLE MISSING - STOP"
205    echo "ALL INFORMATION IN FILE $outfile"
206    exit
207fi
208
209
210## 2.3 Compile orchidee
211cd $modipsl/modeles/ORCHIDEE
212echo; echo "NOW COMPILE ORCHIDEE"
213echo >> $outfile ; echo " NOW COMPILE ORCHIDEE"   >> $outfile 
214
215# Check if the compilation of ORCHIDEE was previsouly interupted prematured.
216# In that case, the files fcm.bld.lock exist. If the file exist, it is here removed to avoid makeorchidee_fcm
217# to ask question and wait for interactivly answer from the user.
218if [ -f build/fcm.bld.lock ] ; then
219    echo >> $outfile
220    echo " WARNING!! The file ORCHIDEE/build/fcm.bld.lock exist. "   >> $outfile
221    echo "           This means that the compilation is either currently on going in another terminal was previous interupted before the end."   >> $outfile
222    echo "           The file will now be removed. "   >> $outfile
223    echo >> $outfile
224    rm -f build/fcm.bld.lock
225fi
226
227echo    ./makeorchidee_fcm -j 8 -xios -parallel $parallel -$optmode -arch ${fcm_arch} -arch_path $arch_path $full_orch    >> $outfile 
228        ./makeorchidee_fcm -j 8 -xios -parallel $parallel -$optmode -arch ${fcm_arch} -arch_path $arch_path $full_orch    >> $outfile 2>&1
229# Test if compiling finished
230if [[ $? != 0 ]] ; then
231    echo "THERE IS A PROBLEM IN ORCHIDEE COMPILATION - STOP"
232    echo "ALL INFORMATION IN FILE $outfile"
233    exit
234fi
235
236# If orchide driver executables have been compiled (option -driver), then rename executables to contain $optmode
237if [ -f $modipsl/bin/orchidee_ol ] ; then mv $modipsl/bin/orchidee_ol  $modipsl/bin/orchidee_ol_${optmode} ; fi
238if [ -f $modipsl/bin/orchideedriver ] ; then mv $modipsl/bin/orchideedriver  $modipsl/bin/orchideedriver_${optmode} ; fi
239
240
241## ajout compile inca Anne
242    cd $modipsl/modeles/INCA
243
244    echo; echo "NOW COMPILE INCA ${optchimie}"
245    echo ./makeinca_fcm -chimie ${optchimie} -$optmode -xios -parallel mpi_omp -j 8 -arch ${fcm_arch}  -arch_path $arch_path $full_flag  >> $outfile
246    ./makeinca_fcm -chimie ${optchimie} -$optmode -xios -parallel mpi_omp  -j 8 -arch ${fcm_arch} -arch_path $arch_path  $full_flag >> $outfile 2>&1
247
248    # Test if compiling finished
249    if [[ $? != 0 ]] ; then
250        echo "THERE IS A PROBLEM IN INCA COMPILATION - STOP"
251        echo "ALL INFORMATION IN FILE $outfile"
252        exit
253    fi
254
255
256
257    echo "Move inca.dat modipsl/bin"
258    if [[ -f $modipsl/modeles/INCA/SIMULATIONS/${optchimie}/inca.dat ]] ;  then 
259        mv $modipsl/modeles/INCA/SIMULATIONS/${optchimie}/inca.dat $modipsl/bin/inca_${optmode}_${optchimie}.dat ;
260    else
261        echo "THERE IS A PROBLEM IN INCA COMPILATION - STOP"
262        echo "ALL INFORMATION IN FILE $outfile"
263        exit   
264    fi
265
266    echo "Move tracer.def to  modipsl/bin"
267    if [[ -f $modipsl/modeles/INCA/tracer.def ]] ;  then
268        mv $modipsl/modeles/INCA/tracer.def $modipsl/bin/tracer_${optmode}_${optchimie}.def ;
269    fi
270
271
272## 2.4 Compile lmdz
273cd $modipsl/modeles/LMDZ
274
275if [ $reg_only = no ] ; then 
276
277    # Compile LMDZ as library to couple to DYNAMICO
278    echo; echo "NOW COMPILE LMDZ FOR COUPLING TO DYNAMICO"
279    echo >> $outfile ; echo " NOW COMPILE LMDZ FOR COUPLING TO DYNAMICO"   >> $outfile 
280
281    # Check if the compilation of LMDZ was previsouly interupted prematured.
282    # In that case, the files dimension.h and .lock exist. If the files exist, they are here removed to avoid makelmdz_fcm
283    # to ask question and wait for interactivly answer from the user.
284    if [ -f libf/grid/dimensions.h ] || [ -f .lock ] ; then
285        echo >> $outfile
286        echo " WARNING!! The file LMDZ/libf/grid/dimension.h and/or the LMDZ/.lock exist. "   >> $outfile
287        echo "           This means that the compilation is either currently on going in another terminal was previous interupted before the end."   >> $outfile
288        echo "           The files dimension.h and .lock will now be removed. "   >> $outfile
289        echo >> $outfile
290        rm -f libf/grid/dimensions.h
291        rm -f .lock
292    fi
293
294    echo ./makelmdz_fcm -p lmd -rrtm true -cosp true -$optmode -mem -parallel $parallel -libphy -v orchidee2.1 -chimie INCA -io xios -arch $fcm_arch -j 8 $full_lmdz    >> $outfile 
295    ./makelmdz_fcm -p lmd -rrtm true -cosp true -$optmode -mem -parallel $parallel -libphy -v orchidee2.1 -chimie INCA -io xios -arch $fcm_arch -j 8 $full_lmdz    >> $outfile 2>&1
296    # Test if compiling finished
297    if [[ $? != 0 ]] ; then
298        echo "THERE IS A PROBLEM IN LMDZ PHYSICS COMPILATION - STOP"
299        echo "ALL INFORMATION IN FILE $outfile"
300        exit
301    fi
302
303
304## 2.5 Compile DYNAMICO
305    cd $modipsl/modeles/DYNAMICO
306    echo; echo "NOW COMPILE DYNAMICO "
307    echo >> $outfile ; echo " NOW COMPILE DYNAMICO"   >> $outfile 
308
309    echo ./make_icosa -$optmode -parallel $parallel -external_ioipsl -with_xios -arch $fcm_arch -arch_path $arch_path -job 8 $full_dyna    >> $outfile 
310    ./make_icosa -$optmode -parallel $parallel -external_ioipsl -with_xios -arch $fcm_arch -arch_path $arch_path -job 8 $full_dyna    >> $outfile 2>&1
311    # Test if compiling finished
312    if [[ $? != 0 ]] ; then
313        echo "THERE IS A PROBLEM IN DYNAMICO COMPILATION - STOP"
314        echo "ALL INFORMATION IN FILE $outfile"
315        exit
316    fi
317
318    ## 2.6 Compile interface ICOSA_LMDZ
319    cd $modipsl/modeles/ICOSA_LMDZ
320    echo; echo "NOW COMPILE ICOSA_LMDZ "
321    echo >> $outfile ; echo " NOW COMPILE ICOSA_LMDZ"   >> $outfile 
322
323    echo ./make_icosa_lmdz -nodeps -p lmd -$optmode -parallel $parallel -with_orchidee -with_inca -arch ${fcm_arch} -arch_path ${arch_path} -job 8 $full_dyna    >> $outfile 
324    ./make_icosa_lmdz -nodeps -p lmd -$optmode -parallel $parallel -with_orchidee -with_inca -arch ${fcm_arch} -arch_path ${arch_path} -job 8 $full_dyna    >> $outfile 2>&1
325    # Test if compiling finished
326    if [[ $? != 0 ]] ; then
327        echo "THERE IS A PROBLEM IN ICOSA_LMDZ COMPILATION - STOP"
328        echo "ALL INFORMATION IN FILE $outfile"
329        exit
330    fi
331    # Move executables to modipsl/bin
332    if [ $modipsl/modeles/ICOSA_LMDZ/bin/icosa_lmdz.exe ] ; then
333        mv $modipsl/modeles/ICOSA_LMDZ/bin/icosa_lmdz.exe $modipsl/bin/icosa_lmdz_${optmode}_${optchimie}.exe
334    else
335        echo "THERE IS A PROBLEM IN ICOSA_LMDZ COMPILATION EXECUTABLE MISSING - STOP"
336        echo "ALL INFORMATION IN FILE $outfile"
337        exit
338    fi
339fi 
340
341
342## 2.7 Compile LMDZ for regular latlon configuration
343
344if [ $ico_only = no ] ; then
345    cd $modipsl/modeles/LMDZ
346    # Compile LMDZ regular lat-lon exectuable
347    echo; echo "NOW COMPILE LMDZ REGULAR LAT-LON MODE. Resolution = ${resol_atm}"
348    echo >> $outfile ; echo " NOW COMPILE LMDZ REGULAR LAT-LON MODE. Resolution = ${resol_atm}"   >> $outfile 
349   
350    # Check if the compilation of LMDZ was previsouly interupted prematured.
351    # In that case, the files dimension.h and .lock exist. If the files exist, they are here removed to avoid makelmdz_fcm
352    # to ask question and wait for interactivly answer from the user.
353    if [ -f libf/grid/dimensions.h ] || [ -f .lock ] ; then
354        echo >> $outfile
355        echo " WARNING!! The file LMDZ/libf/grid/dimension.h and/or the LMDZ/.lock exist. "   >> $outfile
356        echo "           This means that the compilation is either currently on going in another terminal was previous interupted before the end."   >> $outfile
357        echo "           The files dimension.h and .lock will now be removed. "   >> $outfile
358        echo >> $outfile
359        rm -f libf/grid/dimensions.h
360        rm -f .lock
361    fi
362    echo ./makelmdz_fcm -d ${resol_atm} -p lmd -rrtm true -$optmode -mem -parallel $parallel -io xios -v orchidee2.1 -chimie INCA -arch $fcm_arch -j 8 $full_lmdz gcm    >> $outfile 
363    ./makelmdz_fcm -d ${resol_atm} -p lmd -rrtm true -$optmode -mem -parallel $parallel -io xios -v orchidee2.1 -chimie INCA -arch $fcm_arch -j 8 $full_lmdz gcm    >> $outfile 2>&1
364    # Test if compiling finished
365    if [[ $? != 0 ]] ; then
366        echo "THERE IS A PROBLEM IN LMDZ REGULAR LATLON COMPILATION - STOP"
367        echo "ALL INFORMATION IN FILE $outfile"
368        exit
369    fi
370fi
371
372
373if [ $ce0l = yes ] ; then 
374    # Compile ce0l initialization program for LMDZ regular lat-lon exectuable
375    echo; echo "NOW COMPILE CE0L OF LMDZ. Resolution = ${resol_atm}"
376    echo >> $outfile ; echo " NOW COMPILE CE0L OF LMDZ. Resolution = ${resol_atm}"   >> $outfile 
377   
378    echo ./makelmdz_fcm -d ${resol_atm} -p lmd -rrtm true -$optmode -mem -parallel $parallel -io xios -v orchidee2.1 -chimie INCA -arch $fcm_arch -j 8 $full_lmdz ce0l    >> $outfile 
379    ./makelmdz_fcm -d ${resol_atm} -p lmd -rrtm true -$optmode -mem -parallel $parallel -io xios -v orchidee2.1 -chimie INCA -arch $fcm_arch -j 8 $full_lmdz ce0l    >> $outfile 2>&1
380    # Test if compiling finished
381    if [[ $? != 0 ]] ; then
382        echo "THERE IS A PROBLEM IN CE0L (LMDZ) REGULAR LATLON COMPILATION - STOP"
383        echo "ALL INFORMATION IN FILE $outfile"
384        exit
385    fi
386fi 
387
388# Find executable suffix
389if [ $parallel == seq ] || [ $parallel == none ] ; then
390    suffix=_${resol_atm}_phylmd_seq_orch_inca.e
391else
392    suffix=_${resol_atm}_phylmd_para_mem_orch_inca.e
393fi
394echo gcm suffix = $suffix
395
396# Move executables to modipsl/bin folder
397echo "Move gcm.e and ce0l executable to modipsl/bin"
398if [ -f $modipsl/modeles/LMDZ/bin/gcm${suffix} ] ;  then
399    mv $modipsl/modeles/LMDZ/bin/gcm${suffix} $modipsl/bin/gcm_${resol_atm}_${optmode}_${optchimie}.e
400else
401    echo "ERROR gcm${suffix} executable does not exist." 
402    echo "THERE IS A PROBLEM IN LMDZ REGULAR LATLON COMPILATION - STOP"
403    echo "ALL INFORMATION IN FILE $outfile"
404    exit
405fi
406
407if [ -f $modipsl/modeles/LMDZ/bin/ce0l${suffix} ] ;  then
408    mv $modipsl/modeles/LMDZ/bin/ce0l${suffix} $modipsl/bin/ce0l_${resol_atm}_${optmode}_${optchimie}.e
409else
410    echo "ERROR ce0l${suffix} executable does not exist." 
411    echo "THERE IS A PROBLEM IN LMDZ REGULAR LATLON COMPILATION - STOP"
412    echo "ALL INFORMATION IN FILE $outfile"
413    exit
414fi
415
416
417
418echo >>$outfile ; echo "ALL COMPILING FINISHED" >> $outfile
419echo ls -lrt modipsl/bin >> $outfile
420ls -lrt $modipsl/bin >> $outfile
421
422echo; echo "ALL COMPILING FINISHED" ; echo
423echo "Executables are found in modipsl/bin"
424echo "Check that executable names correspond with the name set in config.card before launching the job"
425echo ls -lrt modipsl/bin
426ls -lrt $modipsl/bin
427
428date
429exit
430
431
Note: See TracBrowser for help on using the repository browser.