source: CONFIG/UNIFORM/v6/IPSLCM6.2/compile_ipslcm6.sh @ 4604

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

Correct error since previous commit today [4469]

  • Property svn:executable set to *
File size: 9.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
13
14#### Set default options
15# Atmospheric resolution, for LMDZ/ORCHIDEE in regular mode
16resol_atm=144x142x79
17# Oceanic resolution, for NEMO (ORCA2/ORCA1/ORCA025)
18resol_oce=ORCA1
19# Version of ice model lim2/lim3
20version_lim=lim3
21# Version ESM CO2: CO2 interactif ocean/atmosphere (y/n)
22esmco2=n
23
24# Optimization mode
25# optmode=prod/dev/debug
26optmode=prod
27# fcm_arch
28fcm_arch=default
29# Default values to be overritten
30parallel=mpi_omp
31export fcm_arch parallel xios
32full_flag=""
33# Default netcdf_lib is used for XIOS but can be change by argument
34netcdf_lib=""
35
36# Output text file for compilation of each component
37outfile=$submitdir/out_compile_ipslcm6
38rm -f $outfile; echo > $outfile
39echo; echo "Text output from compilation will be stored in file out_compile_ipslcm6"; echo 
40
41#### Read arguments
42# Loop over all arguments to modify default set up
43while (($# > 0)) ; do
44    case $1 in
45        "-h") cat <<fin
46
47########################################################################
48# Usage of the script compile_ipslcm6.sh
49#
50########################################################################
51
52./compile_ipslcm6.sh [Options]
53
54
55Options: [LR / VLR / MR025] Model resolution, choose only one. Default: LR.
56         [ESMCO2] Compile IPSLCM6 for CO2 interactif ocean/atmosphere.
57         [-full] Full recompilation of all components. This option can be added to all other options.
58         [-debug / -dev / -prod] Level of optimization. One of these can be added to all other compile options. Default: -prod.
59
60
61Example 1: Default compilation of IPSLCM6 for resoltion LR
62          (Resolution atmos: 144x142x79, ocean: ORCA1)
63./compile_ipslcm6.sh
64
65Example 2: Compilation of IPSLCM6 for resolution MR025
66           (atmos: 256x256x79, ocean: ORCA025, NOPISCES)
67./compile_ipslcm6.sh MR025
68
69Example 3: Compilation of IPSLCM6 for ESM CO2
70./compile_ipslcm6.sh ESMCO2
71
72Example 4: Default resoltuion (LR) compiled in debug mode
73./compile_ipslcm6.sh -debug
74
75Example 5: Default compilation with full recompilation of all components. No clean is needed.
76./compile_ipslcm6.sh -full
77
78Example 6: Full recompilation of resolution MR05 in debug mode
79./compile_ipslcm6.sh MR025 -debug -full
80
81fin
82            exit;;
83
84        "VLR")
85            resol_atm=96x95x39; resol_oce=ORCA1 ; version_lim=lim2;  shift ;;
86
87        "LR")
88            resol_atm=144x142x79; resol_oce=ORCA1 ; version_lim=lim3; shift ;;
89
90        "MR025")
91            resol_atm=256x256x79; resol_oce=ORCA025 ; version_lim=lim3;  shift ;;
92
93        "ESMCO2")
94            esmco2=y;  shift ;;
95
96        "-parallel")
97            parallel=$2 ; shift ; shift ;;
98       
99        "-arch")
100            fcm_arch="$2" ; shift ; shift ;;
101       
102        "-debug")
103            optmode=debug ; shift ;;
104
105        "-dev")
106            optmode=dev ; shift ;;
107
108        "-prod")
109            optmode=prod ; shift ;;
110
111        "-full")
112            full_flag="-full"; shift ;;
113       
114        "-netcdf_lib_seq")
115            netcdf_lib="--netcdf_lib netcdf4_seq"; shift ;;
116
117        *)
118            echo "unknown option "$2" , exiting..."
119            exit
120    esac
121done
122
123echo "Following options are set in current compiling:" >> $outfile 
124echo "   resol_atm=${resol_atm}, resol_oce=${resol_oce}, $version_lim=${version_lim}" >> $outfile 
125echo "   esmco2=${esmco2}" >> $outfile 
126echo "   optmode = $optmode, parallel = $parallel, fcm_arch = $fcm_arch, full_flag=$full_flag" >> $outfile 
127echo >> $outfile
128
129### Read host dependent default values
130### These variables will not be changed if they were set as argument
131###./host.sh $host
132# Later : Following lines should be set in host.sh file
133# begin host.sh
134if [ $fcm_arch == default ] ; then
135    # Find out current host and source specific paths and commands for the host
136    case $( hostname -s ) in
137        ada*)
138            fcm_arch=X64_ADA;;
139        irene*)
140            fcm_arch=X64_IRENE;;
141        asterix*|obelix*)
142            fcm_arch=ifort_LSCE;;
143        ciclad*|climserv*)
144            fcm_arch=ifort_CICLAD;;
145        *)
146            echo Current host is not known. You must use option -arch to specify which architecuture files to use.
147            echo Exit now.
148            exit
149    esac
150fi
151
152# Set a link to arch.env if arch-${fcm_arch}.env file exist for current fcm_arch.
153# The link arch.env is also set in config.card and will be used by libIGCM to ensure the same running environnement.
154if [ -f ARCH/arch-${fcm_arch}.env ] ; then
155    echo >> $outfile
156    echo "The file ARCH/arch-${fcm_arch}.env will now be sourced with modules needed for compilation for all components"
157    echo "Note that this new environement might be kept after compilation." 
158    echo "If this is the case, source again your personal environment after compilation. "
159    echo " Personal module list before sourcing of ARCH/arch.env file:"    >> $outfile 
160    module list   >> $outfile 2>&1
161
162    # Make a link to this file, to be used also in config.card
163    rm -f ARCH/arch.env
164    ln -s arch-${fcm_arch}.env ARCH/arch.env
165
166    # Source the file
167    source ARCH/arch.env   >> $outfile 2>&1
168    echo >> $outfile 
169    echo " New module list after sourcing of ARCH/arch.env file:"    >> $outfile 
170    module list   >> $outfile 2>&1
171fi
172
173#### 2 Do the compilation
174## 2.1 Compile ioipsl
175cd $modipsl/modeles/IOIPSL
176echo; echo "NOW COMPILE IOIPSL"
177echo >> $outfile ; echo " NOW COMPILE IOIPSL"   >> $outfile 
178
179# Check if compilation with fcm is included in IOIPSL
180if [ ! -f makeioipsl_fcm ] ; then
181  echo "The file makeiopsl_fcm do not exist. Probably this is not the right version of IOIPSL."
182  echo "Version of IOIPSL with fcm compilation is needed to compile with this script. Stop now."
183  exit
184fi
185
186echo ./makeioipsl_fcm -$optmode -parallel -arch ${fcm_arch} -arch_path $arch_path -j 8 $full_flag   >> $outfile 
187     ./makeioipsl_fcm -$optmode -parallel -arch ${fcm_arch} -arch_path $arch_path -j 8 $full_flag   >> $outfile 2>&1
188# Test if compiling succeded
189if [[ $? != 0 ]] ; then
190    echo "THERE IS A PROBLEM IN IOIPSL COMPILATION - STOP"
191    exit
192fi
193
194## 2.2 Compile xios
195cd $modipsl/modeles/XIOS
196echo; echo "NOW COMPILE XIOS"
197echo >> $outfile ; echo " NOW COMPILE XIOS"   >> $outfile 
198echo ./make_xios --$optmode --arch $fcm_arch --arch_path $arch_path ${netcdf_lib} --job 4 $full_flag   >> $outfile 
199     ./make_xios --$optmode --arch $fcm_arch --arch_path $arch_path ${netcdf_lib} --job 4 $full_flag   >> $outfile 2>&1
200# Test if compiling succeded
201if [[ $? != 0 ]] ; then
202    echo "THERE IS A PROBLEM IN XIOS COMPILATION - STOP"
203    exit
204fi
205# Move executables to modipsl/bin
206if [ -f $modipsl/modeles/XIOS/bin/xios_server.exe ] ; then
207    mv $modipsl/modeles/XIOS/bin/xios_server.exe $modipsl/bin/xios_server_${optmode}.exe
208else
209    echo "THERE IS A PROBLEM IN XIOS COMPILATION EXECUTABLE MISSING - STOP"
210    exit
211fi
212
213
214## 2.3 Compile orchidee
215cd $modipsl/modeles/ORCHIDEE
216echo; echo "NOW COMPILE ORCHIDEE"
217echo >> $outfile ; echo " NOW COMPILE ORCHIDEE"   >> $outfile 
218
219echo    ./makeorchidee_fcm -j 8 -xios -parallel $parallel -$optmode -arch ${fcm_arch} -arch_path $arch_path $full_flag -driver   >> $outfile 
220        ./makeorchidee_fcm -j 8 -xios -parallel $parallel -$optmode -arch ${fcm_arch} -arch_path $arch_path $full_flag -driver    >> $outfile 2>&1
221# Test if compiling finished
222if [[ $? != 0 ]] ; then
223    echo "THERE IS A PROBLEM IN ORCHIDEE COMPILATION - STOP"
224    exit
225fi
226
227
228## 2.4 Compile LMDZ for regular latlon configuration
229cd $modipsl/modeles/LMDZ
230# Compile LMDZ regular lat-lon exectuable
231echo; echo "NOW COMPILE LMDZ REGULAR LAT-LON MODE. Resolution = ${resol_atm}"
232echo >> $outfile ; echo " NOW COMPILE LMDZ REGULAR LAT-LON MODE. Resolution = ${resol_atm}"   >> $outfile 
233
234echo ./makelmdz_fcm -d ${resol_atm} -p lmd -rrtm true -$optmode -mem -parallel $parallel -io xios -v orchidee2.1 -arch $fcm_arch -arch_path $arch_path -j 8 $full_flag gcm    >> $outfile 
235./makelmdz_fcm -d ${resol_atm} -p lmd -rrtm true -$optmode -mem -parallel $parallel -io xios -v orchidee2.1 -arch $fcm_arch -arch_path $arch_path -j 8 $full_flag gcm    >> $outfile 2>&1
236# Test if compiling finished
237if [[ $? != 0 ]] ; then
238    echo "THERE IS A PROBLEM IN LMDZ REGULAR LATLON COMPILATION - STOP"
239    exit
240fi
241
242# Compile ce0l initialization program for LMDZ regular lat-lon exectuable
243echo; echo "NOW COMPILE CE0L OF LMDZ. Resolution = ${resol_atm}"
244echo >> $outfile ; echo " NOW COMPILE CE0L OF LMDZ. Resolution = ${resol_atm}"   >> $outfile 
245   
246echo ./makelmdz_fcm -d ${resol_atm} -p lmd -rrtm true -$optmode -mem -parallel $parallel -io xios -v orchidee2.1 -arch $fcm_arch -arch_path $arch_path -j 8 $full_flag ce0l    >> $outfile 
247./makelmdz_fcm -d ${resol_atm} -p lmd -rrtm true -$optmode -mem -parallel $parallel -io xios -v orchidee2.1 -arch $fcm_arch -arch_path $arch_path -j 8 $full_flag ce0l    >> $outfile 2>&1
248# Test if compiling finished
249if [[ $? != 0 ]] ; then
250    echo "THERE IS A PROBLEM IN CE0L (LMDZ) REGULAR LATLON COMPILATION - STOP"
251    exit
252fi
253
254# Find executable suffix
255if [ $parallel == seq ] || [ $parallel == none ] ; then
256    suffix=_${resol_atm}_phylmd_seq_orch
257else
258    suffix=_${resol_atm}_phylmd_para_mem_orch
259fi
260echo suffix = $suffix
261
262# Move executables to modipsl/bin folder
263echo "Move gcm.e and ce0l executable to modipsl/bin"
264if [ -f $modipsl/modeles/LMDZ/bin/gcm${suffix}.e ] ;  then mv $modipsl/modeles/LMDZ/bin/gcm${suffix}.e $modipsl/bin/gcm_${resol_atm}_${optmode}.e ; fi
265if [ -f $modipsl/modeles/LMDZ/bin/ce0l${suffix}.e ] ;  then mv $modipsl/modeles/LMDZ/bin/ce0l${suffix}.e $modipsl/bin/ce0l_${resol_atm}_${optmode}.e ; fi
266
267
268echo >>$outfile ; echo "ALL COMPILING FINISHED" >> $outfile
269echo; echo "ALL COMPILING FINISHED"
270
271date
272exit
273
274
Note: See TracBrowser for help on using the repository browser.