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

Last change on this file since 6282 was 6282, checked in by acosce, 19 months ago

remove lines used to copy files for hotfix

  • Property svn:executable set to *
File size: 15.6 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: -ico_only, -reg_only, -ce0_only, -full, -regular_latlon, -debug, -dev, -prod(default)
61
62Example 1: Default compilation of [DYNAMICO-LMDZ-ORCHIDEE with XIOS and IOIPSL] and [LMDZ(144x142x79)-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_icolmdzor.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
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
271    echo ./make_icosa -$optmode -parallel $parallel -external_ioipsl -with_xios -arch $fcm_arch -arch_path $arch_path -job 8 $full_dyna    >> $outfile 
272    ./make_icosa -$optmode -parallel $parallel -external_ioipsl -with_xios -arch $fcm_arch -arch_path $arch_path -job 8 $full_dyna    >> $outfile 2>&1
273    # Test if compiling finished
274    if [[ $? != 0 ]] ; then
275        echo "THERE IS A PROBLEM IN DYNAMICO COMPILATION - STOP"
276        exit
277    fi
278
279    ## 2.6 Compile interface ICOSA_LMDZ
280    cd $modipsl/modeles/ICOSA_LMDZ
281    echo; echo "NOW COMPILE ICOSA_LMDZ "
282    echo >> $outfile ; echo " NOW COMPILE ICOSA_LMDZ"   >> $outfile 
283   
284    echo ./make_icosa_lmdz -nodeps -p lmd -$optmode -parallel $parallel -with_orchidee -arch ${fcm_arch} -arch_path ${arch_path} -job 8 $full_dyna    >> $outfile 
285    ./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
286    # Test if compiling finished
287    if [[ $? != 0 ]] ; then
288        echo "THERE IS A PROBLEM IN ICOSA_LMDZ COMPILATION - STOP"
289        exit
290    fi
291    # Move executables to modipsl/bin
292    if [ $modipsl/modeles/ICOSA_LMDZ/bin/icosa_lmdz.exe ] ; then
293        mv $modipsl/modeles/ICOSA_LMDZ/bin/icosa_lmdz.exe $modipsl/bin/icosa_lmdz_${optmode}.exe
294    else
295        echo "THERE IS A PROBLEM IN ICOSA_LMDZ COMPILATION EXECUTABLE MISSING - STOP"
296        exit
297    fi
298   
299fi 
300
301## 2.7 Compile LMDZ for regular latlon configuration
302
303# Find executable suffix
304if [ $parallel == seq ] || [ $parallel == none ] ; then
305    suffix=_${resol_atm}_phylmd_seq_orch.e
306else
307    suffix=_${resol_atm}_phylmd_para_mem_orch.e
308fi
309echo gcm suffix = $suffix
310
311
312if [ $ico_only = no ] && [ $ce0l_only = no ]; then
313
314    cd $modipsl/modeles/LMDZ
315    # Compile LMDZ regular lat-lon exectuable
316    echo; echo "NOW COMPILE LMDZ REGULAR LAT-LON MODE. Resolution = ${resol_atm}"
317    echo >> $outfile ; echo " NOW COMPILE LMDZ REGULAR LAT-LON MODE. Resolution = ${resol_atm}"   >> $outfile 
318
319    # Check if the compilation of LMDZ was previsouly interupted prematured.
320    # In that case, the files dimension.h and .lock exist. If the files exist, they are here removed to avoid makelmdz_fcm
321    # to ask question and wait for interactivly answer from the user.
322    if [ -f libf/grid/dimensions.h ] || [ -f .lock ] ; then
323        echo >> $outfile
324        echo " WARNING!! The file LMDZ/libf/grid/dimension.h and/or the LMDZ/.lock exist. "   >> $outfile
325        echo "           This means that the compilation is either currently on going in another terminal was previous interupted before the end."   >> $outfile
326        echo "           The files dimension.h and .lock will now be removed. "   >> $outfile
327        echo >> $outfile
328        rm -f libf/grid/dimensions.h
329        rm -f .lock
330    fi
331    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 
332         ./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
333    # Test if compiling finished
334    if [[ $? != 0 ]] ; then
335        echo "THERE IS A PROBLEM IN LMDZ REGULAR LATLON COMPILATION - STOP"
336        exit
337    fi
338
339
340    # Move executables to modipsl/bin folder
341    echo "Move gcm.e  executable to modipsl/bin"
342    if [ -f $modipsl/modeles/LMDZ/bin/gcm${suffix} ] ;  then
343        mv $modipsl/modeles/LMDZ/bin/gcm${suffix} $modipsl/bin/gcm_${resol_atm}_${optmode}.e
344    else
345        echo "ERROR gcm${suffix} executable does not exist." 
346        echo "THERE IS A PROBLEM IN LMDZ REGULAR LATLON COMPILATION - STOP"
347        exit
348    fi
349
350fi
351
352
353if [ $ce0l_only = yes ] || [ $ico_only = no ] && [ $reg_only = no ] ; then
354
355    cd $modipsl/modeles/LMDZ
356
357    # Compile ce0l initialization program for LMDZ regular lat-lon exectuable
358    echo; echo "NOW COMPILE CE0L OF LMDZ. Resolution = ${resol_atm}"
359    echo >> $outfile ; echo " NOW COMPILE CE0L OF LMDZ. Resolution = ${resol_atm}"   >> $outfile 
360
361    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 
362         ./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
363    # Test if compiling finished
364    if [[ $? != 0 ]] ; then
365        echo "THERE IS A PROBLEM IN CE0L (LMDZ) REGULAR LATLON COMPILATION - STOP"
366        exit
367    fi
368
369    # Move executables to modipsl/bin folder
370    echo "Move ce0l.e  executable to modipsl/bin"
371    if [ -f $modipsl/modeles/LMDZ/bin/ce0l${suffix} ] ;  then
372        mv $modipsl/modeles/LMDZ/bin/ce0l${suffix} $modipsl/bin/ce0l_${resol_atm}_${optmode}.e
373    else
374        echo "ERROR ce0l${suffix} executable does not exist." 
375        echo "THERE IS A PROBLEM IN LMDZ REGULAR LATLON COMPILATION - STOP"
376        exit
377    fi
378
379fi
380
381
382
383echo >>$outfile ; echo "ALL COMPILING FINISHED" >> $outfile
384echo ls -lrt modipsl/bin >> $outfile
385ls -lrt $modipsl/bin >> $outfile
386
387echo; echo "ALL COMPILING FINISHED" ; echo
388echo "Executables are found in modipsl/bin"
389echo "Check that executable names correspond with the name set in config.card before launching the job"
390echo ls -lrt modipsl/bin
391ls -lrt $modipsl/bin
392
393date
394exit
395
396
Note: See TracBrowser for help on using the repository browser.