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

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

update compile script for ICOLMDZORINCA config
now regular and ico grid will be systematically compile
defaut resolution is 144x142x79 for regular grid. Use regular_latlon option to modify it

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