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

Last change on this file was 6449, checked in by jgipsl, 12 months ago

Removed SOURCES which were needed for older version of DYNAMICO. This is needed to use DYNAMICO rev 3558d704

  • Property svn:executable set to *
File size: 16.7 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    echo ./make_icosa -$optmode -with_fcm1 -parallel $parallel -external_ioipsl -with_xios -arch $fcm_arch -arch_path $arch_path -job 8 $full_dyna    >> $outfile 
294    ./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
295    # Test if compiling finished
296    if [[ $? != 0 ]] ; then
297        echo "THERE IS A PROBLEM IN DYNAMICO COMPILATION - STOP"
298        exit
299    fi
300
301    ## 2.6 Compile interface ICOSA_LMDZ
302    cd $modipsl/modeles/ICOSA_LMDZ
303    echo; echo "NOW COMPILE ICOSA_LMDZ "
304    echo >> $outfile ; echo " NOW COMPILE ICOSA_LMDZ"   >> $outfile 
305   
306    echo ./make_icosa_lmdz -nodeps -p lmd -$optmode -parallel $parallel -with_orchidee -arch ${fcm_arch} -arch_path ${arch_path} -job 8 $full_dyna    >> $outfile 
307    ./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
308    # Test if compiling finished
309    if [[ $? != 0 ]] ; then
310        echo "THERE IS A PROBLEM IN ICOSA_LMDZ COMPILATION - STOP"
311        exit
312    fi
313    # Move executables to modipsl/bin
314    if [ $modipsl/modeles/ICOSA_LMDZ/bin/icosa_lmdz.exe ] ; then
315        mv $modipsl/modeles/ICOSA_LMDZ/bin/icosa_lmdz.exe $modipsl/bin/icosa_lmdz_${optmode}.exe
316    else
317        echo "THERE IS A PROBLEM IN ICOSA_LMDZ COMPILATION EXECUTABLE MISSING - STOP"
318        exit
319    fi
320   
321fi 
322
323## 2.7 Compile LMDZ for regular latlon configuration
324
325# Find executable suffix
326suffix=_${resol_atm}_phylmd
327if [ $lmdzsvn -ge 4186 ] ; then suffix=${suffix}_${rad} ; fi
328if [ $parallel == seq ] || [ $parallel == none ] ; then
329    suffix=${suffix}_seq_orch.e
330else
331    suffix=${suffix}_para_mem_orch.e
332fi
333echo gcm suffix = $suffix
334
335
336if [ $ico_only = no ] && [ $ce0l_only = no ]; then
337
338    cd $modipsl/modeles/LMDZ
339    # Compile LMDZ regular lat-lon exectuable
340    echo; echo "NOW COMPILE LMDZ REGULAR LAT-LON MODE. Resolution = ${resol_atm}"
341    echo >> $outfile ; echo " NOW COMPILE LMDZ REGULAR LAT-LON MODE. Resolution = ${resol_atm}"   >> $outfile 
342
343    # Check if the compilation of LMDZ was previsouly interupted prematured.
344    # In that case, the files dimension.h and .lock exist. If the files exist, they are here removed to avoid makelmdz_fcm
345    # to ask question and wait for interactivly answer from the user.
346    if [ -f libf/grid/dimensions.h ] || [ -f .lock ] ; then
347        echo >> $outfile
348        echo " WARNING!! The file LMDZ/libf/grid/dimension.h and/or the LMDZ/.lock exist. "   >> $outfile
349        echo "           This means that the compilation is either currently on going in another terminal was previous interupted before the end."   >> $outfile
350        echo "           The files dimension.h and .lock will now be removed. "   >> $outfile
351        echo >> $outfile
352        rm -f libf/grid/dimensions.h
353        rm -f .lock
354    fi
355    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 
356         ./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
357    # Test if compiling finished
358    if [[ $? != 0 ]] ; then
359        echo "THERE IS A PROBLEM IN LMDZ REGULAR LATLON COMPILATION - STOP"
360        exit
361    fi
362
363
364    # Move executables to modipsl/bin folder
365    echo "Move gcm.e  executable to modipsl/bin"
366    if [ -f $modipsl/modeles/LMDZ/bin/gcm${suffix} ] ;  then
367        mv $modipsl/modeles/LMDZ/bin/gcm${suffix} $modipsl/bin/gcm_${resol_atm}_${optmode}.e
368    else
369        echo "ERROR gcm${suffix} executable does not exist." 
370        echo "THERE IS A PROBLEM IN LMDZ REGULAR LATLON COMPILATION - STOP"
371        exit
372    fi
373
374fi
375
376
377if [ $ce0l_only = yes ] || [ $ico_only = no ] && [ $reg_only = no ] ; then
378
379    cd $modipsl/modeles/LMDZ
380
381    # Compile ce0l initialization program for LMDZ regular lat-lon exectuable
382    echo; echo "NOW COMPILE CE0L OF LMDZ. Resolution = ${resol_atm}"
383    echo >> $outfile ; echo " NOW COMPILE CE0L OF LMDZ. Resolution = ${resol_atm}"   >> $outfile 
384
385    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 
386         ./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
387    # Test if compiling finished
388    if [[ $? != 0 ]] ; then
389        echo "THERE IS A PROBLEM IN CE0L (LMDZ) REGULAR LATLON COMPILATION - STOP"
390        exit
391    fi
392
393    # Move executables to modipsl/bin folder
394    echo "Move ce0l.e  executable to modipsl/bin"
395    if [ -f $modipsl/modeles/LMDZ/bin/ce0l${suffix} ] ;  then
396        mv $modipsl/modeles/LMDZ/bin/ce0l${suffix} $modipsl/bin/ce0l_${resol_atm}_${optmode}.e
397    else
398        echo "ERROR ce0l${suffix} executable does not exist." 
399        echo "THERE IS A PROBLEM IN LMDZ REGULAR LATLON COMPILATION - STOP"
400        exit
401    fi
402
403fi
404
405
406
407echo >>$outfile ; echo "ALL COMPILING FINISHED" >> $outfile
408echo ls -lrt modipsl/bin >> $outfile
409ls -lrt $modipsl/bin >> $outfile
410
411echo; echo "ALL COMPILING FINISHED" ; echo
412echo "Executables are found in modipsl/bin"
413echo "Check that executable names correspond with the name set in config.card before launching the job"
414echo ls -lrt modipsl/bin
415ls -lrt $modipsl/bin
416
417date
418exit
419
420
Note: See TracBrowser for help on using the repository browser.