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

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

Now inca create a file tracer.def - the compilation copy this file on bin to be used by the simulation
add the copy from the compilation
add the copy in lmdz.card
and modify xml files for new version of dynamico

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