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

Last change on this file since 4407 was 4407, checked in by jgipsl, 5 years ago

Added argument -debug/-dev/-prod to easier change compile mode.

  • Property svn:executable set to *
File size: 8.8 KB
Line 
1#!/bin/bash
2#set -vx
3# Default options
4#
5#
6#
7#### 1  Set up the compiling options
8#### Define some directories
9submitdir=$( pwd )
10modipsl=$submitdir/../..
11echo modipsl=$modipsl 
12echo submitdir=$submitdir
13arch_path=$submitdir/ARCH
14export ROOT=$modipsl/modeles/DYNAMICO
15
16#### Set default options
17# Optimization mode
18# optmode=prod/dev/debug
19optmode=prod
20# Resolution if compiling LMDZ in regular mode without DYNAMICO
21# Use for example following "./compile_icolmdzor.sh -regular_lonlat 144x142x79"
22regular_latlon=no
23# fcm_arch
24fcm_arch=default
25# Default values to be overritten
26parallel=mpi_omp
27export fcm_arch parallel xios
28full_flag=""
29# Default netcdf_lib is used for XIOS but can be change by argument
30netcdf_lib=""
31
32#### Read arguments
33# Loop over all arguments to modify default set up
34while (($# > 0)) ; do
35    case $1 in
36        "-h") cat <<fin
37
38########################################################################
39# Usage of the script compile_icolmdzor.sh
40#
41########################################################################
42
43./compile_config [Options]
44
45Options: -full, -regular_latlon, -debug, -dev, -prod(default)
46
47Example 1: Default compilation of DYNAMICO-LMDZ-ORCHIDEE with XIOS and IOIPSL
48./compile_icolmdzor.sh
49
50Example 2: Compile in debug mode
51./compile_icolmdzor.sh -debug
52
53Example 3: Default compilation with full recompilation of all components
54./compile_icolmdzor.sh -full
55
56Example 4: Compilation of LMDZ in regular lat-lon for dimension 144x142x79.
57The dimension can be changed to any other 3d dimension. DYNAMICO is also compiled as default.
58./compile_icolmdzor.sh -regular_latlon 144x142x79
59
60fin
61            exit;;
62
63        "-parallel")
64            parallel=$2 ; shift ; shift ;;
65       
66        "-arch")
67            fcm_arch="$2" ; shift ; shift ;;
68       
69        "-xios")
70            xios="$2" ; shift ; shift ;;
71       
72        "-optmode")
73            optmode=$2 ; shift ; shift ;;
74
75        "-debug")
76            optmode=debug ; shift ;;
77
78        "-dev")
79            optmode=dev ; shift ;;
80
81        "-prod")
82            optmode=prod ; shift ;;
83
84        "-regular_latlon")
85            regular_latlon=yes ;
86            resol_atm_3d=$2 ; shift ; shift ;;
87       
88        "-full")
89            full_flag="-full"; shift ;;
90       
91        "-netcdf_lib_seq")
92            netcdf_lib="--netcdf_lib netcdf4_seq"; shift ;;
93
94        *)
95            echo "unknown option "$2" , exiting..."
96            exit
97    esac
98done
99
100
101### Read host dependent default values
102### These variables will not be changed if they were set as argument
103###./host.sh $host
104# Later : Following lines should be set in host.sh file
105# begin host.sh
106if [ $fcm_arch == default ] ; then
107    # Find out current host and source specific paths and commands for the host
108    case $( hostname -s ) in
109        ada*)
110            fcm_arch=X64_ADA;;
111        irene*)
112            fcm_arch=X64_IRENE;;
113        asterix*|obelix*)
114            fcm_arch=ifort_LSCE;;
115        ciclad*|climserv*)
116            fcm_arch=ifort_CICLAD;;
117        *)
118            echo Current host is not known. You must use option -arch to specify which architecuture files to use.
119            echo Exit now.
120            exit
121    esac
122fi
123
124# Set a link to arch.env and source the file if arch-${fcm_arch}.env file exist for current fcm_arch.
125# The link arch.env is also set in config.card and will be used by libIGCM to ensure the same running environnement.
126if [ -f ARCH/arch-${fcm_arch}.env ] ; then
127    rm -f ARCH/arch.env
128    ln -s arch-${fcm_arch}.env ARCH/arch.env
129    source ARCH/arch.env
130fi
131
132##### End host.sh
133echo
134echo "Following arguments are set in current compiling:"
135echo "   optmode = $optmode, parallel = $parallel, fcm_arch = $fcm_arch, full_flag=$full_flag regular_latlon=$regular_latlon"
136
137#### 2 Do the compilation
138## 2.1 Compile ioipsl
139cd $modipsl/modeles/IOIPSL
140echo; echo "NOW COMPILE IOIPSL"
141echo ./makeioipsl_fcm -$optmode -parallel -arch ${fcm_arch} -arch_path $arch_path -j 8 $full_flag
142./makeioipsl_fcm -$optmode -parallel -arch ${fcm_arch} -arch_path $arch_path -j 8 $full_flag
143# Test if compiling succeded
144if [[ $? != 0 ]] ; then
145    echo "THERE IS A PROBLEM IN IOIPSL COMPILATION - STOP"
146    exit
147fi
148
149## 2.2 Compile xios
150cd $modipsl/modeles/XIOS
151echo; echo "NOW COMPILE XIOS"
152echo ./make_xios --$optmode --arch $fcm_arch --arch_path $arch_path --job 4 $full_flag
153./make_xios --$optmode --arch $fcm_arch --arch_path $arch_path ${netcdf_lib} --job 4 $full_flag
154# Test if compiling succeded
155if [[ $? != 0 ]] ; then
156    echo "THERE IS A PROBLEM IN XIOS COMPILATION - STOP"
157    exit
158fi
159# Move executables to modipsl/bin
160if [ $modipsl/modeles/XIOS/bin/xios_server.exe ] ; then
161    mv $modipsl/modeles/XIOS/bin/xios_server.exe $modipsl/bin/.
162else
163    echo "THERE IS A PROBLEM IN XIOS COMPILATION EXECUTABLE MISSING - STOP"
164    exit
165fi
166
167
168## 2.3 Compile orchidee
169cd $modipsl/modeles/ORCHIDEE
170echo; echo "NOW COMPILE ORCHIDEE"
171echo    ./makeorchidee_fcm -j 8 -xios -parallel $parallel -$optmode -arch ${fcm_arch} $full_flag
172./makeorchidee_fcm -j 8 -xios -parallel $parallel -$optmode -arch ${fcm_arch} $full_flag
173# Test if compiling finished
174if [[ $? != 0 ]] ; then
175    echo "THERE IS A PROBLEM IN ORCHIDEE COMPILATION - STOP"
176    exit
177fi
178
179## 2.4 Compile lmdz
180cd $modipsl/modeles/LMDZ
181# Compile LMDZ as library to couple to DYNAMICO
182echo; echo "NOW COMPILE LMDZ FOR COUPLING TO DYNAMICO"
183echo ./makelmdz_fcm -p lmd -rrtm true -cosp true -$optmode -mem -parallel $parallel -libphy -v orchidee2.1 -io xios -arch $fcm_arch -j 8 $full_flag
184./makelmdz_fcm -p lmd -rrtm true -cosp true -$optmode -mem -parallel $parallel -libphy -v orchidee2.1 -io xios -arch $fcm_arch -j 8 $full_flag
185# Test if compiling finished
186if [[ $? != 0 ]] ; then
187    echo "THERE IS A PROBLEM IN LMDZ PHYSICS COMPILATION - STOP"
188    exit
189fi
190
191
192## 2.5 Compile DYNAMICO
193echo; echo "NOW COMPILE DYNAMICO "
194cd $modipsl/modeles/DYNAMICO
195echo ./make_icosa -$optmode -parallel $parallel -external_ioipsl -with_xios -arch $fcm_arch -arch_path $arch_path -job 8 $full_flag
196./make_icosa -$optmode -parallel $parallel -external_ioipsl -with_xios -arch $fcm_arch -arch_path $arch_path -job 8 $full_flag
197# Test if compiling finished
198if [[ $? != 0 ]] ; then
199    echo "THERE IS A PROBLEM IN DYNAMICO COMPILATION - STOP"
200    exit
201fi
202
203## 2.6 Compile interface ICOSA_LMDZ
204echo; echo "NOW COMPILE ICOSA_LMDZ "
205cd $modipsl/modeles/ICOSA_LMDZ
206echo ./make_icosa_lmdz -nodeps -p lmd -$optmode -parallel $parallel -with_orchidee -arch ${fcm_arch} -arch_path ${arch_path} -job 8 $full_flag
207
208./make_icosa_lmdz -nodeps -p lmd -$optmode -parallel $parallel -with_orchidee -arch ${fcm_arch} -arch_path ${arch_path} -job 8 $full_flag
209# Test if compiling finished
210if [[ $? != 0 ]] ; then
211    echo "THERE IS A PROBLEM IN ICOSA_LMDZ COMPILATION - STOP"
212    exit
213fi
214# Move executables to modipsl/bin
215if [ $modipsl/modeles/ICOSA_LMDZ/bin/icosa_lmdz.exe ] ; then
216    mv $modipsl/modeles/ICOSA_LMDZ/bin/icosa_lmdz.exe $modipsl/bin/.
217else
218    echo "THERE IS A PROBLEM IN ICOSA_LMDZ COMPILATION EXECUTABLE MISSING - STOP"
219    exit
220fi
221
222
223
224## 2.7 Compile LMDZ for regular latlon configuration
225if [ $regular_latlon = yes ] ; then
226
227    cd $modipsl/modeles/LMDZ
228    # Compile LMDZ regular lat-lon exectuable
229    echo; echo "NOW COMPILE LMDZ REGULAR LAT-LON MODE. Resolution = ${resol_atm_3d}"
230    echo ./makelmdz_fcm -d ${resol_atm_3d} -p lmd -rrtm true -$optmode -mem -parallel $parallel -io xios -v orchidee2.1 -arch $fcm_arch -j 8 $full_flag gcm
231    ./makelmdz_fcm -d ${resol_atm_3d} -p lmd -rrtm true -$optmode -mem -parallel $parallel -io xios -v orchidee2.1 -arch $fcm_arch -j 8 $full_flag gcm
232    # Test if compiling finished
233    if [[ $? != 0 ]] ; then
234        echo "THERE IS A PROBLEM IN LMDZ REGULAR LATLON COMPILATION - STOP"
235        exit
236    fi
237
238    # Compile ce0l initialization program for LMDZ regular lat-lon exectuable
239    echo; echo "NOW COMPILE CE0L OF LMDZ. Resolution = ${resol_atm_3d}"
240    echo ./makelmdz_fcm -d ${resol_atm_3d} -p lmd -rrtm true -$optmode -mem -parallel $parallel -io xios -v orchidee2.1 -arch $fcm_arch -j 8 $full_flag ce0l
241    ./makelmdz_fcm -d ${resol_atm_3d} -p lmd -rrtm true -$optmode -mem -parallel $parallel -io xios -v orchidee2.1 -arch $fcm_arch -j 8 $full_flag ce0l
242    # Test if compiling finished
243    if [[ $? != 0 ]] ; then
244        echo "THERE IS A PROBLEM IN CE0L (LMDZ) REGULAR LATLON COMPILATION - STOP"
245        exit
246    fi
247
248    # Find executable suffix
249    if [ $parallel == seq ] || [ $parallel == none ] ; then
250        suffix=_${resol_atm_3d}_phylmd_seq_orch
251    else
252        suffix=_${resol_atm_3d}_phylmd_para_mem_orch
253    fi
254    echo suffix = $suffix
255   
256    # Move executables to modipsl/bin folder
257    echo "Move gcm.e and ce0l executable to modipsl/bin"
258    if [ $modipsl/modeles/LMDZ/bin/gcm${suffix}.e ] ;  then mv $modipsl/modeles/LMDZ/bin/gcm${suffix}.e $modipsl/bin/gcm_${resol_atm_3d}.e ; fi
259    if [ $modipsl/modeles/LMDZ/bin/ce0l${suffix}.e ] ;  then mv $modipsl/modeles/LMDZ/bin/ce0l${suffix}.e $modipsl/bin/ce0l_${resol_atm_3d}.e ; fi
260
261    # Write .resol file
262    cd $submitdir   
263    resol2D=$( echo ${resol_atm_3d} | awk '-Fx' '{print $1}' )$( echo ${resol_atm_3d} | awk '-Fx' '{print $2}' )
264    echo "noORCAxLMD$resol2D" >.resol
265    echo "RESOL_ATM_3D=${resol_atm_3d}" >>.resol
266fi
267
268
269echo
270echo "ALL COMPILING FINISHED"
271echo
272
273exit
274
275
Note: See TracBrowser for help on using the repository browser.