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

Last change on this file since 6080 was 6080, checked in by acosce, 2 years ago

update compilation script for ICOLMDZOR_v7 configuration. Add new options

-ico_only : compile only DYN-LMDZ-OR (grid ico)
-reg_only : compile only LMDZ-OR (grid reg)
-ce0l_only : compile only create_etat0_limit for regular grid

Note: for ico grid the executable done both : ce0l and gcm
If we don't put any option we will compile ico / reg and ce0l

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