source: CONFIG/UNIFORM/v7/ICOLMDZORINCA_v7.2/compile_icolmdzorinca.sh @ 6803

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

Update configuration to compile and run on redhat8

  • Property svn:executable set to *
File size: 17.1 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
15mysrc_path=$submitdir/SOURCES
16sources_RH8_path=$submitdir/SOURCES/REDHAT8
17
18#### Set default options
19# Optimization mode
20# optmode=prod/dev/debug
21optmode=prod
22# Resolution if compiling LMDZ in regular mode without DYNAMICO
23# Use for example following "./compile_icolmdzorinca.sh -regular_latlon 144x142x79"
24regular_latlon=no
25# fcm_arch
26fcm_arch=default
27# Default values to be overritten
28parallel=mpi_omp
29export fcm_arch parallel xios
30full_flag=""
31full_xios=""
32full_lmdz=""
33full_orch=""
34full_dyna=""
35ico_only=no
36reg_only=no
37ce0l=no
38optchimie=GES
39resol_atm="144x142x79"
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_icolmdzorinca.$datestr
47echo > $outfile
48echo; echo "Text output from compilation will be stored in file out_compile_icolmdzorinca.$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 <<end_help
55
56########################################################################
57# Usage of the script compile_icolmdzorinca.sh
58#
59########################################################################
60
61./compile_config [Options]
62
63Options: -full, -regular_latlon, -debug, -dev, -prod(default)
64
65Example 1: Default compilation of DYNAMICO-LMDZ-ORCHIDEE with XIOS and IOIPSL
66./compile_icolmdzorinca.sh
67
68Example 2: Compile in debug mode
69./compile_icolmdzorinca.sh -debug
70
71Example 3: Default compilation with full recompilation of all components
72./compile_icolmdzorinca.sh -full
73
74Example 4: Compilation of LMDZ in regular lat-lon for dimension 144x142x79.
75The dimension can be changed to any other 3d dimension. DYNAMICO is also compiled as default.
76./compile_icolmdzorinca.sh -regular_latlon 144x142x79
77
78Example 5: Compilation with a chosen chemistry, for example DUSS  (default: NMHC_AER_S)
79./compile_icolmdzorinca.sh -chimie DUSS
80
81Example 6: Compile only ico grid
82./compile_icolmdzorinca.sh -ico_only
83
84Example 7: Compile only reg grid
85./compile_icolmdzorinca.sh -reg_only
86
87Example 8 : compile create_etat0_limit (and gcm.e)
88./compile_icolmdzorinca.sh -ce0l
89
90end_help
91            exit;;
92
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        "-regular_latlon")  regular_latlon=yes ; resol_atm=$2 ; shift ; shift ;;
100        "-full")            full_flag="-full"; full_xios="--full" ; full_lmdz="-full" ; full_orch="-full" ; full_dyna="-full" ; shift ;;
101        "-full_xios")       full_xios="--full" ; shift ;;  # Note only full_xios is using double dash: --full
102        "-full_lmdz")       full_lmdz="-full"  ; shift ;;
103        "-full_orch")       full_orch="-full"  ; shift ;;
104        "-full_dyna")       full_dyna="-full"  ; shift ;;
105        "-ico_only")        ico_only=yes  ; shift ;;
106        "-reg_only")        reg_only=yes  ; shift ;;
107        "-ce0l")            ce0l=yes  ; shift ;;
108        "-netcdf_lib_seq")  netcdf_lib="--netcdf_lib netcdf4_seq"; shift ;;
109        "-chimie")          optchimie=$2; shift ; shift;;
110
111        *)                  echo "unknown option "$1" , exiting..." ;  exit
112    esac
113done
114
115echo "Following options are set in current compiling:" >> $outfile 
116echo "   regular_latlon=$regular_latlon (if yes, then resol_atm=${resol_atm})" >> $outfile 
117echo "   optmode = $optmode, parallel = $parallel, fcm_arch = $fcm_arch " >> $outfile 
118echo "   full_flag=$full_flag, full_xios=$full_xios, full_lmdz=$full_lmdz, full_orch=$full_orch, full_dyna=$full_dyna" >> $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
164    # Make a link to this file, to be used also in config.card
165    rm -f ARCH/arch.env
166    ln -s arch-${fcm_arch}.env ARCH/arch.env
167
168    # Source the file
169    source ARCH/arch.env   >> $outfile 2>&1
170
171    echo >> $outfile
172    echo " New module list after sourcing of ARCH/arch.env file:"    >> $outfile 
173    module list   >> $outfile 2>&1
174fi
175
176#### 2 Do the compilation
177## 2.1 Compile ioipsl
178cd $modipsl/modeles/IOIPSL
179echo; echo "NOW COMPILE IOIPSL"
180echo >> $outfile ; echo " NOW COMPILE IOIPSL"   >> $outfile 
181
182echo ./makeioipsl_fcm -$optmode -parallel -arch ${fcm_arch} -arch_path $arch_path -j 8 $full_flag   >> $outfile 
183     ./makeioipsl_fcm -$optmode -parallel -arch ${fcm_arch} -arch_path $arch_path -j 8 $full_flag   >> $outfile 2>&1
184# Test if compiling succeded
185if [[ $? != 0 ]] ; then
186    echo "THERE IS A PROBLEM IN IOIPSL COMPILATION - STOP"
187    echo "ALL INFORMATION IN FILE $outfile"
188    exit
189fi
190
191## 2.2 Compile xios
192cd $modipsl/modeles/XIOS
193echo; echo "NOW COMPILE XIOS"
194echo >> $outfile ; echo " NOW COMPILE XIOS"   >> $outfile 
195echo ./make_xios --$optmode --arch $fcm_arch --arch_path $arch_path ${netcdf_lib} --job 4 $full_xios   >> $outfile 
196     ./make_xios --$optmode --arch $fcm_arch --arch_path $arch_path ${netcdf_lib} --job 4 $full_xios   >> $outfile 2>&1
197# Test if compiling succeded
198if [[ $? != 0 ]] ; then
199    echo "THERE IS A PROBLEM IN XIOS COMPILATION - STOP"
200    echo "ALL INFORMATION IN FILE $outfile"
201    exit
202fi
203# Move executables to modipsl/bin
204if [ -f $modipsl/modeles/XIOS/bin/xios_server.exe ] ; then
205    mv $modipsl/modeles/XIOS/bin/xios_server.exe $modipsl/bin/xios_server_${optmode}.exe
206else
207    echo "THERE IS A PROBLEM IN XIOS COMPILATION EXECUTABLE MISSING - STOP"
208    echo "ALL INFORMATION IN FILE $outfile"
209    exit
210fi
211
212
213## 2.3 Compile orchidee
214cd $modipsl/modeles/ORCHIDEE
215
216cp ${sources_RH8_path}/ORCHIDEE/mod_orchidee_para.F90 src_parallel/.
217
218echo; echo "NOW COMPILE ORCHIDEE"
219echo >> $outfile ; echo " NOW COMPILE ORCHIDEE"   >> $outfile 
220
221# Check if the compilation of ORCHIDEE was previsouly interupted prematured.
222# In that case, the files fcm.bld.lock exist. If the file exist, it is here removed to avoid makeorchidee_fcm
223# to ask question and wait for interactivly answer from the user.
224if [ -f build/fcm.bld.lock ] ; then
225    echo >> $outfile
226    echo " WARNING!! The file ORCHIDEE/build/fcm.bld.lock exist. "   >> $outfile
227    echo "           This means that the compilation is either currently on going in another terminal was previous interupted before the end."   >> $outfile
228    echo "           The file will now be removed. "   >> $outfile
229    echo >> $outfile
230    rm -f build/fcm.bld.lock
231fi
232
233echo    ./makeorchidee_fcm -j 8 -xios -parallel $parallel -$optmode -arch ${fcm_arch} -arch_path $arch_path $full_orch    >> $outfile 
234        ./makeorchidee_fcm -j 8 -xios -parallel $parallel -$optmode -arch ${fcm_arch} -arch_path $arch_path $full_orch    >> $outfile 2>&1
235# Test if compiling finished
236if [[ $? != 0 ]] ; then
237    echo "THERE IS A PROBLEM IN ORCHIDEE COMPILATION - STOP"
238    echo "ALL INFORMATION IN FILE $outfile"
239    exit
240fi
241
242# If orchide driver executables have been compiled (option -driver), then rename executables to contain $optmode
243if [ -f $modipsl/bin/orchidee_ol ] ; then mv $modipsl/bin/orchidee_ol  $modipsl/bin/orchidee_ol_${optmode} ; fi
244if [ -f $modipsl/bin/orchideedriver ] ; then mv $modipsl/bin/orchideedriver  $modipsl/bin/orchideedriver_${optmode} ; fi
245
246
247## ajout compile inca Anne
248    cd $modipsl/modeles/INCA
249
250
251    echo; echo "NOW COMPILE INCA ${optchimie}"
252    echo ./makeinca_fcm -chimie ${optchimie} -$optmode -xios -parallel mpi_omp -j 8 -arch ${fcm_arch}  -arch_path $arch_path $full_flag  >> $outfile
253    ./makeinca_fcm -chimie ${optchimie} -$optmode -xios -parallel mpi_omp  -j 8 -arch ${fcm_arch} -arch_path $arch_path  $full_flag >> $outfile 2>&1
254
255    # Test if compiling finished
256    if [[ $? != 0 ]] ; then
257        echo "THERE IS A PROBLEM IN INCA COMPILATION - STOP"
258        echo "ALL INFORMATION IN FILE $outfile"
259        exit
260    fi
261
262
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_${optmode}_${optchimie}.dat ;
267    else
268        echo "THERE IS A PROBLEM IN INCA COMPILATION - STOP"
269        echo "ALL INFORMATION IN FILE $outfile"
270        exit   
271    fi
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_${optmode}_${optchimie}.def ;
276    fi
277
278
279## 2.4 Compile lmdz
280cd $modipsl/modeles/LMDZ
281
282
283if [ $reg_only = no ] ; then 
284
285    # Compile LMDZ as library to couple to DYNAMICO
286    echo; echo "NOW COMPILE LMDZ FOR COUPLING TO DYNAMICO"
287    echo >> $outfile ; echo " NOW COMPILE LMDZ FOR COUPLING TO DYNAMICO"   >> $outfile 
288
289    # Check if the compilation of LMDZ was previsouly interupted prematured.
290    # In that case, the files dimension.h and .lock exist. If the files exist, they are here removed to avoid makelmdz_fcm
291    # to ask question and wait for interactivly answer from the user.
292    if [ -f libf/grid/dimensions.h ] || [ -f .lock ] ; then
293        echo >> $outfile
294        echo " WARNING!! The file LMDZ/libf/grid/dimension.h and/or the LMDZ/.lock exist. "   >> $outfile
295        echo "           This means that the compilation is either currently on going in another terminal was previous interupted before the end."   >> $outfile
296        echo "           The files dimension.h and .lock will now be removed. "   >> $outfile
297        echo >> $outfile
298        rm -f libf/grid/dimensions.h
299        rm -f .lock
300    fi
301
302    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 
303    ./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
304    # Test if compiling finished
305    if [[ $? != 0 ]] ; then
306        echo "THERE IS A PROBLEM IN LMDZ PHYSICS COMPILATION - STOP"
307        echo "ALL INFORMATION IN FILE $outfile"
308        exit
309    fi
310
311
312## 2.5 Compile DYNAMICO
313    cd $modipsl/modeles/DYNAMICO
314    echo; echo "NOW COMPILE DYNAMICO "
315    echo >> $outfile ; echo " NOW COMPILE DYNAMICO"   >> $outfile 
316
317    echo ./make_icosa -$optmode -parallel $parallel -external_ioipsl -with_xios -arch $fcm_arch -arch_path $arch_path -job 8 $full_dyna    >> $outfile 
318    ./make_icosa -$optmode -parallel $parallel -external_ioipsl -with_xios -arch $fcm_arch -arch_path $arch_path -job 8 $full_dyna    >> $outfile 2>&1
319    # Test if compiling finished
320    if [[ $? != 0 ]] ; then
321        echo "THERE IS A PROBLEM IN DYNAMICO COMPILATION - STOP"
322        echo "ALL INFORMATION IN FILE $outfile"
323        exit
324    fi
325
326    ## 2.6 Compile interface ICOSA_LMDZ
327    cd $modipsl/modeles/ICOSA_LMDZ
328    echo; echo "NOW COMPILE ICOSA_LMDZ "
329    echo >> $outfile ; echo " NOW COMPILE ICOSA_LMDZ"   >> $outfile 
330
331    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 
332    ./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
333    # Test if compiling finished
334    if [[ $? != 0 ]] ; then
335        echo "THERE IS A PROBLEM IN ICOSA_LMDZ COMPILATION - STOP"
336        echo "ALL INFORMATION IN FILE $outfile"
337        exit
338    fi
339    # Move executables to modipsl/bin
340    if [ $modipsl/modeles/ICOSA_LMDZ/bin/icosa_lmdz.exe ] ; then
341        mv $modipsl/modeles/ICOSA_LMDZ/bin/icosa_lmdz.exe $modipsl/bin/icosa_lmdz_${optmode}_${optchimie}.exe
342    else
343        echo "THERE IS A PROBLEM IN ICOSA_LMDZ COMPILATION EXECUTABLE MISSING - STOP"
344        echo "ALL INFORMATION IN FILE $outfile"
345        exit
346    fi
347fi 
348
349
350## 2.7 Compile LMDZ for regular latlon configuration
351
352if [ $ico_only = no ] ; then
353    cd $modipsl/modeles/LMDZ
354    # Compile LMDZ regular lat-lon exectuable
355    echo; echo "NOW COMPILE LMDZ REGULAR LAT-LON MODE. Resolution = ${resol_atm}"
356    echo >> $outfile ; echo " NOW COMPILE LMDZ REGULAR LAT-LON MODE. Resolution = ${resol_atm}"   >> $outfile 
357   
358    # Check if the compilation of LMDZ was previsouly interupted prematured.
359    # In that case, the files dimension.h and .lock exist. If the files exist, they are here removed to avoid makelmdz_fcm
360    # to ask question and wait for interactivly answer from the user.
361    if [ -f libf/grid/dimensions.h ] || [ -f .lock ] ; then
362        echo >> $outfile
363        echo " WARNING!! The file LMDZ/libf/grid/dimension.h and/or the LMDZ/.lock exist. "   >> $outfile
364        echo "           This means that the compilation is either currently on going in another terminal was previous interupted before the end."   >> $outfile
365        echo "           The files dimension.h and .lock will now be removed. "   >> $outfile
366        echo >> $outfile
367        rm -f libf/grid/dimensions.h
368        rm -f .lock
369    fi
370    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 
371    ./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
372    # Test if compiling finished
373    if [[ $? != 0 ]] ; then
374        echo "THERE IS A PROBLEM IN LMDZ REGULAR LATLON COMPILATION - STOP"
375        echo "ALL INFORMATION IN FILE $outfile"
376        exit
377    fi
378fi
379
380
381if [ $ce0l = yes ] ; then 
382    # Compile ce0l initialization program for LMDZ regular lat-lon exectuable
383    echo; echo "NOW COMPILE CE0L OF LMDZ. Resolution = ${resol_atm}"
384    echo >> $outfile ; echo " NOW COMPILE CE0L OF LMDZ. Resolution = ${resol_atm}"   >> $outfile 
385   
386    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 
387    ./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
388    # Test if compiling finished
389    if [[ $? != 0 ]] ; then
390        echo "THERE IS A PROBLEM IN CE0L (LMDZ) REGULAR LATLON COMPILATION - STOP"
391        echo "ALL INFORMATION IN FILE $outfile"
392        exit
393    fi
394fi 
395
396# Find executable suffix
397if [ $parallel == seq ] || [ $parallel == none ] ; then
398    suffix=_${resol_atm}_phylmd_seq_orch_inca.e
399else
400    suffix=_${resol_atm}_phylmd_para_mem_orch_inca.e
401fi
402echo gcm suffix = $suffix
403
404if [ $ico_only = no ] ; then 
405    # Move executables to modipsl/bin folder
406    echo "Move gcm.e and ce0l executable to modipsl/bin"
407    if [ -f $modipsl/modeles/LMDZ/bin/gcm${suffix} ] ;  then
408        mv $modipsl/modeles/LMDZ/bin/gcm${suffix} $modipsl/bin/gcm_${resol_atm}_${optmode}_${optchimie}.e
409    else
410        echo "ERROR gcm${suffix} executable does not exist." 
411        echo "THERE IS A PROBLEM TO MOVE LMDZ REGULAR LATLON EXECUTABLE - STOP"
412        echo "ALL INFORMATION IN FILE $outfile"
413        exit
414    fi
415fi
416
417if [ $ce0l = yes ] ; then
418
419    if [ -f $modipsl/modeles/LMDZ/bin/ce0l${suffix} ] ;  then
420        mv $modipsl/modeles/LMDZ/bin/ce0l${suffix} $modipsl/bin/ce0l_${resol_atm}_${optmode}_${optchimie}.e
421    else
422        echo "ERROR ce0l${suffix} executable does not exist." 
423        echo "THERE IS A PROBLEM IN LMDZ REGULAR LATLON COMPILATION - STOP"
424        echo "ALL INFORMATION IN FILE $outfile"
425        exit
426    fi
427fi
428
429
430echo >>$outfile ; echo "ALL COMPILING FINISHED" >> $outfile
431echo ls -lrt modipsl/bin >> $outfile
432ls -lrt $modipsl/bin >> $outfile
433
434echo; echo "ALL COMPILING FINISHED" ; echo
435echo "Executables are found in modipsl/bin"
436echo "Check that executable names correspond with the name set in config.card before launching the job"
437echo ls -lrt modipsl/bin
438ls -lrt $modipsl/bin
439
440date
441exit
442
443
Note: See TracBrowser for help on using the repository browser.