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

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

Enhancement in compilation and link to running environnement:
The compiling script determines which fcm_arch is to be used, makes a link ARCH/arch-${fcm_arch}.env to arch.env. arch.env is the sourced during compilation and is also set in config.card to be sourced during run time.

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