source: CONFIG/UNIFORM/v7/ICOLMDZOR_v7/compile_icolmdzor.sh @ 6362

Last change on this file since 6362 was 6362, checked in by aclsce, 15 months ago

Modified sponge parameters ICOLMDZ to use same treatment as LMDZ (iflag_sponge=2, mode_sponge=3).
Remind :
iflag_sponge !0 --> for no sponge

!1 --> for sponge over 4 topmost layers
!2 --> for sponge from top to ~1% of top layer pressure

mode_sponge !1 --> u and v relax towards 0

!2 --> u and v relax towards their zonal mean
!3 --> u,v and pot. temp. relax towards their zonal mean

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