source: CONFIG/UNIFORM/v6/LMDZOR_v6.2/compile_lmdzor.sh @ 4469

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

Simplifications : change resol_atm_2d into resol_atm. Remove indentation and option regular_latlon.

  • Property svn:executable set to *
File size: 7.7 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# Optimization mode
16# optmode=prod/dev/debug
17optmode=prod
18# Resolution of LMDZ in regular mode
19resol_atm=144x142x79
20
21# fcm_arch
22fcm_arch=default
23# Default values to be overritten
24parallel=mpi_omp
25export fcm_arch parallel xios
26full_flag=""
27# Default netcdf_lib is used for XIOS but can be change by argument
28netcdf_lib=""
29
30# Output text file for compilation of each component
31outfile=$submitdir/out_compile_lmdzor
32rm -f $outfile; echo > $outfile
33echo; echo "Text output from compilation will be stored in file out_compile_lmdzor"; echo 
34
35#### Read arguments
36# Loop over all arguments to modify default set up
37while (($# > 0)) ; do
38    case $1 in
39        "-h") cat <<fin
40
41########################################################################
42# Usage of the script compile_lmdzor.sh
43#
44########################################################################
45
46./compile_config [Options]
47
48Options: -full, -resol_atm, -debug, -dev, -prod(default)
49
50Example 1: Default compilation of LMDZ-ORCHIDEE with XIOS and IOIPSL
51./compile_lmdzor.sh
52
53Example 2: Compile in debug mode
54./compile_lmdzor.sh -debug
55
56Example 3: Default compilation with full recompilation of all components
57./compile_lmdzor.sh -full
58
59Example 4: Compilation of LMDZ in regular lat-lon for other dimensions (default: 144x142x79)
60The dimension can be changed to any other 3d dimension.
61./compile_lmdzor.sh -resol_atm 96x95x79
62
63fin
64            exit;;
65
66        "-parallel")
67            parallel=$2 ; shift ; shift ;;
68       
69        "-arch")
70            fcm_arch="$2" ; shift ; shift ;;
71       
72        "-xios")
73            xios="$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        "-resol_atm")
85            resol_atm=$2 ; shift ; shift ;;
86       
87        "-full")
88            full_flag="-full"; shift ;;
89       
90        "-netcdf_lib_seq")
91            netcdf_lib="--netcdf_lib netcdf4_seq"; shift ;;
92
93        *)
94            echo "unknown option "$2" , exiting..."
95            exit
96    esac
97done
98
99echo "Following arguments are set in current compiling:" >> $outfile 
100echo "   optmode = $optmode, parallel = $parallel, fcm_arch = $fcm_arch, full_flag=$full_flag resol_atm=${resol_atm}" >> $outfile 
101echo >> $outfile
102
103### Read host dependent default values
104### These variables will not be changed if they were set as argument
105###./host.sh $host
106# Later : Following lines should be set in host.sh file
107# begin host.sh
108if [ $fcm_arch == default ] ; then
109    # Find out current host and source specific paths and commands for the host
110    case $( hostname -s ) in
111        ada*)
112            fcm_arch=X64_ADA;;
113        irene*)
114            fcm_arch=X64_IRENE;;
115        asterix*|obelix*)
116            fcm_arch=ifort_LSCE;;
117        ciclad*|climserv*)
118            fcm_arch=ifort_CICLAD;;
119        *)
120            echo Current host is not known. You must use option -arch to specify which architecuture files to use.
121            echo Exit now.
122            exit
123    esac
124fi
125
126# Set a link to arch.env if arch-${fcm_arch}.env file exist for current fcm_arch.
127# The link arch.env is also set in config.card and will be used by libIGCM to ensure the same running environnement.
128if [ -f ARCH/arch-${fcm_arch}.env ] ; then
129    echo >> $outfile
130    echo "The file ARCH/arch-${fcm_arch}.env will be used for the compilation of each component"
131    rm -f ARCH/arch.env
132    ln -s arch-${fcm_arch}.env ARCH/arch.env
133fi
134
135#### 2 Do the compilation
136## 2.1 Compile ioipsl
137cd $modipsl/modeles/IOIPSL
138echo; echo "NOW COMPILE IOIPSL"
139echo >> $outfile ; echo " NOW COMPILE IOIPSL"   >> $outfile 
140
141# Check if compilation with fcm is included in IOIPSL
142if [ ! -f makeioipsl_fcm ] ; then
143  echo "The file makeiopsl_fcm do not exist. Probably this is not the right version of IOIPSL."
144  echo "Version of IOIPSL with fcm compilation is needed to compile with this script. Stop now."
145  exit
146fi
147
148echo ./makeioipsl_fcm -$optmode -parallel -arch ${fcm_arch} -arch_path $arch_path -j 8 $full_flag   >> $outfile 
149     ./makeioipsl_fcm -$optmode -parallel -arch ${fcm_arch} -arch_path $arch_path -j 8 $full_flag   >> $outfile 2>&1
150# Test if compiling succeded
151if [[ $? != 0 ]] ; then
152    echo "THERE IS A PROBLEM IN IOIPSL COMPILATION - STOP"
153    exit
154fi
155
156## 2.2 Compile xios
157cd $modipsl/modeles/XIOS
158echo; echo "NOW COMPILE XIOS"
159echo >> $outfile ; echo " NOW COMPILE XIOS"   >> $outfile 
160echo ./make_xios --$optmode --arch $fcm_arch --arch_path $arch_path ${netcdf_lib} --job 4 $full_flag   >> $outfile 
161     ./make_xios --$optmode --arch $fcm_arch --arch_path $arch_path ${netcdf_lib} --job 4 $full_flag   >> $outfile 2>&1
162# Test if compiling succeded
163if [[ $? != 0 ]] ; then
164    echo "THERE IS A PROBLEM IN XIOS COMPILATION - STOP"
165    exit
166fi
167# Move executables to modipsl/bin
168if [ -f $modipsl/modeles/XIOS/bin/xios_server.exe ] ; then
169    mv $modipsl/modeles/XIOS/bin/xios_server.exe $modipsl/bin/xios_server_${optmode}.exe
170else
171    echo "THERE IS A PROBLEM IN XIOS COMPILATION EXECUTABLE MISSING - STOP"
172    exit
173fi
174
175
176## 2.3 Compile orchidee
177cd $modipsl/modeles/ORCHIDEE
178echo; echo "NOW COMPILE ORCHIDEE"
179echo >> $outfile ; echo " NOW COMPILE ORCHIDEE"   >> $outfile 
180
181echo    ./makeorchidee_fcm -j 8 -xios -parallel $parallel -$optmode -arch ${fcm_arch} -arch_path $arch_path $full_flag -driver   >> $outfile 
182        ./makeorchidee_fcm -j 8 -xios -parallel $parallel -$optmode -arch ${fcm_arch} -arch_path $arch_path $full_flag -driver    >> $outfile 2>&1
183# Test if compiling finished
184if [[ $? != 0 ]] ; then
185    echo "THERE IS A PROBLEM IN ORCHIDEE COMPILATION - STOP"
186    exit
187fi
188
189
190## 2.4 Compile LMDZ for regular latlon configuration
191cd $modipsl/modeles/LMDZ
192# Compile LMDZ regular lat-lon exectuable
193echo; echo "NOW COMPILE LMDZ REGULAR LAT-LON MODE. Resolution = ${resol_atm}"
194echo >> $outfile ; echo " NOW COMPILE LMDZ REGULAR LAT-LON MODE. Resolution = ${resol_atm}"   >> $outfile 
195
196echo ./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 
197./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
198# Test if compiling finished
199if [[ $? != 0 ]] ; then
200    echo "THERE IS A PROBLEM IN LMDZ REGULAR LATLON COMPILATION - STOP"
201    exit
202fi
203
204# Compile ce0l initialization program for LMDZ regular lat-lon exectuable
205echo; echo "NOW COMPILE CE0L OF LMDZ. Resolution = ${resol_atm}"
206echo >> $outfile ; echo " NOW COMPILE CE0L OF LMDZ. Resolution = ${resol_atm}"   >> $outfile 
207   
208echo ./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 
209./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
210# Test if compiling finished
211if [[ $? != 0 ]] ; then
212    echo "THERE IS A PROBLEM IN CE0L (LMDZ) REGULAR LATLON COMPILATION - STOP"
213    exit
214fi
215
216# Find executable suffix
217if [ $parallel == seq ] || [ $parallel == none ] ; then
218    suffix=_${resol_atm}_phylmd_seq_orch
219else
220    suffix=_${resol_atm}_phylmd_para_mem_orch
221fi
222echo suffix = $suffix
223
224# Move executables to modipsl/bin folder
225echo "Move gcm.e and ce0l executable to modipsl/bin"
226if [ -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
227if [ -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
228
229fi
230
231
232echo >>$outfile ; echo "ALL COMPILING FINISHED" >> $outfile
233echo; echo "ALL COMPILING FINISHED"
234
235date
236exit
237
238
Note: See TracBrowser for help on using the repository browser.