source: CONFIG_DEVT/ORCHIDEE_OL_TP/compile_orchidee_ol.sh @ 5863

Last change on this file since 5863 was 5570, checked in by aclsce, 3 years ago

Created ORCHIDEE_OL_TP configuration : temporary configuration to be used during prectical session.

  • Property svn:executable set to *
File size: 11.1 KB
Line 
1#!/bin/bash
2#set -vx
3# ================================================================================================================================
4#  compile_orchidee_ol.sh
5#
6#  CONTACT      : orchidee-help _at_ listes.ipsl.fr
7#
8#  LICENCE      : IPSL (2006)
9#  This software is governed by the CeCILL licence see ORCHIDEE/ORCHIDEE_CeCILL.LIC
10#
11#  DESCRIPTION  : This script is used to compile all components needed for the ORCHIDEE offline drivers. The following components
12#                 will be compiled: IOIPSL, XIOS and ORCHIDEE.
13#                 Default compilation is set up for the machines irene/TGCC, jean-zay/IDRIS, obelix/LSCE and ciclad and
14#                 climserv/IPSL. For other machines compiling option needs to be specified for each of the components.
15#                 The script first sources a arch.env file, from folder ARCH, containing modules needed for the current machine.
16#                 This means that the modules do not need to be sourced before starting the compilation. Output from compilation
17#                 are stored in a separate file out_compile_orchidee.date.
18#                 For help about the script, use: ./compile_orchidee_ol.sh -h
19#
20# $HeadURL: svn://forge.ipsl.jussieu.fr/orchidee/trunk/ORCHIDEE_OL/compile_orchidee_ol.sh $
21# $Date: 2020-04-03 12:33:11 +0200 (Fri, 03 Apr 2020) $
22# $Revision: 6707 $
23# ================================================================================================================================
24
25date
26
27#### 1  Set up the compiling options
28#### Define some directories
29submitdir=$( pwd )
30modipsl=$submitdir/../..
31arch_path=$submitdir/ARCH
32
33#### Set default options
34# Optimization mode
35# optmode=prod/dev/debug
36optmode=prod
37
38# fcm_arch
39fcm_arch=default
40
41# parallel: mpi or seq
42parallel=mpi
43
44export fcm_arch parallel xios
45full_flag=""
46full_xios=""
47full_orch=""
48
49# Compile with linking to XIOS: xios=xios (default)
50# Use argument -without_xios for compilation without linking to XIOS: xios=noxios
51xios=xios
52
53# Compile other executables: if otherexec="-otherexec", then
54otherexec=""
55
56# Default netcdf_lib is used for XIOS but can be change by argument
57netcdf_lib=""
58
59
60#### Read arguments
61# Loop over all arguments to modify default set up
62while (($# > 0)) ; do
63    case $1 in
64        "-h") cat <<end_help
65########################################################################
66# Usage of the script compile_orchidee_ol.sh
67#
68########################################################################
69
70./compile_orchidee_ol.sh [Options]
71
72Options:
73  [-full]: full recompilation of all components
74  [-full_orch], [-full_xios]: recompile only orchidee or xios component
75  [-arch XXX]: Force to use arch-XXX.fcm and arch-XXX.path files with specific compilation options for current platform. The files must be
76   available in modles/ORCHIDEE/arch, modeles/XIOS/arch and modeles/IOIPSL/arch folders. If the file config/ORCHIDEE_OL/ARCH/arch-XXX.env
77   exist, it'll be sourced in the beginning of this compilation script.
78  [-debug], [-dev], [-prod](default): use compilation options for debug, dev or production mode, only one option can be used
79  [-all_exec]: also compile other exectables than the drivers (testrouting and forcesoil)
80  [-without_xios]: no compilation or linking to XIOS. Default compilation is done with XIOS
81  [-parallel seq] / [-parallel mpi](default): compile without MPI for use in sequential mode / with MPI (default).
82   When using [-parallel seq], [-without_xios] must as well be set.
83  [-netcdf_lib_seq]: option to tell XIOS that linking with netcdf4 sequential library will be used instead of default netcdf4 parallel library
84
85
86Example 1: Default compilation of ORCHIDEE with XIOS and IOIPSL
87./compile_orchidee_ol.sh
88
89Example 2: Compile in debug mode
90./compile_orchidee_ol.sh -debug
91
92Example 3: Default compilation with full recompilation of all components
93./compile_orchidee_ol.sh -full
94
95Example 4: No compilation or linking to XIOS
96./compile_orchidee_ol.sh -without_xios
97
98Example 5: Compilation without MPI for sequential use only. Note that XIOS must be deactivated as well.
99./compile_orchidee_ol.sh -parallel seq -without_xios
100
101
102end_help
103exit;;
104        "-parallel")        parallel="$2" ; shift ; shift ;;
105        "-arch")            fcm_arch="$2" ; shift ; shift ;;
106        "-without_xios")    xios=noxios ; shift ;;
107        "-debug")           optmode=debug ; shift ;;
108        "-dev")             optmode=dev ; shift ;;
109        "-prod")            optmode=prod ; shift ;;
110        "-full")            full_flag="-full"; full_xios="--full" ; full_orch="-full" ; shift ;;
111        "-full_xios")       full_xios="--full" ; shift ;;  # Note only full_xios is using double dash: --full
112        "-full_orch")       full_orch="-full"  ; shift ;;
113        "-all_exec")        otherexec="-otherexec" ; shift ;;
114        "-netcdf_lib_seq")  netcdf_lib="--netcdf_lib netcdf4_seq"; shift ;;
115        *)                  echo "unknown option "$1" , exiting..." ; exit
116    esac
117done
118
119
120# Create text output file
121datestr=`LC_ALL=C date +"%Y%m%dT%H%M"`
122outfile=$submitdir/out_compile_orchidee.$datestr
123echo > $outfile
124echo; echo "Text output from compilation will be stored in file out_compile_orchidee.$datestr"; echo
125
126
127echo "Following options are set in current compiling:" >> $outfile 
128echo "   optmode = $optmode, parallel = $parallel, fcm_arch = $fcm_arch " >> $outfile 
129echo "   full_flag=$full_flag, full_xios=$full_xios, full_orch=$full_orch" >> $outfile 
130echo >> $outfile
131
132if [ $parallel = seq ] && [ $xios = y ] ; then
133    echo "It is not possible to compile ORCHIDEE in sequential mode using XIOS."
134    echo "Option -without_xios must be set if option [-parallel seq] is set"
135    echo "Option -without_xios must be set if option [-parallel seq] is set" >> $outfile 
136    exit
137fi
138
139### Read host dependent default values
140### These variables will not be changed if they were set as argument
141###./host.sh $host
142# Later : Following lines should be set in host.sh file
143# begin host.sh
144if [ $fcm_arch == default ] ; then
145    # Find out current host and source specific paths and commands for the host
146    case $( hostname -s ) in
147        jean-zay*)
148            fcm_arch=X64_JEANZAY;;
149        irene170|irene171|irene190|irene191|irene192|irene193)
150            fcm_arch=X64_IRENE;;
151        irene172|irene173|irene194|irene195)
152            fcm_arch=X64_IRENE-AMD;;
153        asterix*|obelix*)
154            fcm_arch=ifort_LSCE;;
155        ciclad*|climserv*|loholt*|camelot*)
156            fcm_arch=ifort_CICLAD;;
157        *)
158            echo Current host is not known. You must use option -arch to specify which architecuture files to use.
159            echo Exit now.
160            exit
161    esac
162fi
163
164echo "The fcm_arch has been changed to: $fcm_arch" >> $outfile 
165
166# Set a link to arch.env if arch-${fcm_arch}.env file exist for current fcm_arch.
167# The link arch.env is also set in config.card and will be used by libIGCM to ensure the same running environnement.
168if [ -f ARCH/arch-${fcm_arch}.env ] ; then
169    echo >> $outfile
170    echo "The file ARCH/arch-${fcm_arch}.env will now be sourced with modules needed for compilation for all components."
171    echo "Note that this new environement might be kept after compilation." 
172    echo "If this is the case, source again your personal environment after compilation. "
173
174    # Make a link to this file, to be used also in config.card
175    rm -f ARCH/arch.env
176    ln -s arch-${fcm_arch}.env ARCH/arch.env
177
178    # Source the file
179    source ARCH/arch.env   >> $outfile 2>&1
180    echo >> $outfile 
181    echo "New module list after sourcing of ARCH/arch.env file:"    >> $outfile 
182    module list   >> $outfile 2>&1
183else
184    echo "No specific ARCH/arch-${fcm_arch}.env have been found. No change in environnement will be done."
185    echo "Previous loaded module modules will be used."    >> $outfile 
186    module list   >> $outfile 2>&1
187fi
188
189
190#### 2 Do the compilation component by component
191## 2.1 Compile ioipsl
192cd $modipsl/modeles/IOIPSL
193echo; echo "NOW COMPILE IOIPSL"
194echo >> $outfile ; echo " NOW COMPILE IOIPSL"   >> $outfile 
195
196# Check if compilation with fcm is included in IOIPSL
197if [ ! -f makeioipsl_fcm ] ; then
198  echo "The file makeiopsl_fcm do not exist. Probably this is not the right version of IOIPSL."
199  echo "Version of IOIPSL with fcm compilation is needed to compile with this script. Stop now."
200  exit
201fi
202
203echo ./makeioipsl_fcm -$optmode -arch ${fcm_arch} -arch_path $arch_path -j 8 $full_flag   >> $outfile 
204     ./makeioipsl_fcm -$optmode -arch ${fcm_arch} -arch_path $arch_path -j 8 $full_flag   >> $outfile 2>&1
205# Test if compiling succeded
206if [[ $? != 0 ]] ; then
207    echo "THERE IS A PROBLEM IN IOIPSL COMPILATION - STOP"
208    exit
209fi
210
211## 2.2 Compile xios
212if [ $xios == xios ] ; then
213    cd $modipsl/modeles/XIOS
214    echo; echo "NOW COMPILE XIOS"
215    echo >> $outfile ; echo " NOW COMPILE XIOS"   >> $outfile 
216    echo ./make_xios --$optmode --arch $fcm_arch --arch_path $arch_path ${netcdf_lib} --job 4 $full_xios   >> $outfile 
217    ./make_xios --$optmode --arch $fcm_arch --arch_path $arch_path ${netcdf_lib} --job 4 $full_xios   >> $outfile 2>&1
218    # Test if compiling succeded
219    if [[ $? != 0 ]] ; then
220        echo "THERE IS A PROBLEM IN XIOS COMPILATION - STOP"
221        exit
222    fi
223    # Move executables to modipsl/bin
224    if [ -f $modipsl/modeles/XIOS/bin/xios_server.exe ] ; then
225        mv $modipsl/modeles/XIOS/bin/xios_server.exe $modipsl/bin/xios_server_${optmode}.exe
226    else
227        echo "THERE IS A PROBLEM IN XIOS COMPILATION EXECUTABLE MISSING - STOP"
228        exit
229    fi
230fi
231
232
233## 2.3 Compile orchidee
234cd $modipsl/modeles/ORCHIDEE
235echo; echo "NOW COMPILE ORCHIDEE"
236echo >> $outfile ; echo " NOW COMPILE ORCHIDEE"   >> $outfile 
237
238# Check if the compilation of ORCHIDEE was previsouly interupted prematured.
239# In that case, the files fcm.bld.lock exist. If the file exist, it is here removed to avoid makeorchidee_fcm
240# to ask question and wait for interactivly answer from the user.
241if [ -f build/fcm.bld.lock ] ; then
242    echo >> $outfile
243    echo " WARNING!! The file ORCHIDEE/build/fcm.bld.lock exist. "   >> $outfile
244    echo "           This means that the compilation is either currently on going in another terminal was previous interupted before the end."   >> $outfile
245    echo "           The file will now be removed. "   >> $outfile
246    echo >> $outfile
247    rm -f build/fcm.bld.lock
248fi
249
250echo    ./makeorchidee_fcm -j 8 -$xios -parallel $parallel -$optmode -arch ${fcm_arch} -arch_path $arch_path $full_orch -driver $otherexec   >> $outfile 
251        ./makeorchidee_fcm -j 8 -$xios -parallel $parallel -$optmode -arch ${fcm_arch} -arch_path $arch_path $full_orch -driver $otherexec   >> $outfile 2>&1
252# Test if compiling finished
253if [[ $? != 0 ]] ; then
254    echo "THERE IS A PROBLEM IN ORCHIDEE COMPILATION - STOP"
255    exit
256fi
257
258# Rename executables to contain $optmode
259if [ -f $modipsl/bin/orchidee_ol ] ; then mv $modipsl/bin/orchidee_ol  $modipsl/bin/orchidee_ol_${optmode} ; fi
260if [ -f $modipsl/bin/orchideedriver ] ; then mv $modipsl/bin/orchideedriver  $modipsl/bin/orchideedriver_${optmode} ; fi
261if [ -f $modipsl/bin/testrouting ] ; then mv $modipsl/bin/testrouting  $modipsl/bin/testrouting_${optmode} ; fi
262if [ -f $modipsl/bin/forcesoil ] ; then mv $modipsl/bin/forcesoil  $modipsl/bin/forcesoil_${optmode} ; fi
263
264
265
266echo >>$outfile ; echo "ALL COMPILING FINISHED" >> $outfile
267echo ls -lrt modipsl/bin >> $outfile
268ls -lrt $modipsl/bin >> $outfile
269
270echo; echo "ALL COMPILING FINISHED" ; echo
271echo "Executables are found in modipsl/bin"
272echo ls -lrt modipsl/bin
273ls -lrt $modipsl/bin
274
275date
276
277exit
278
Note: See TracBrowser for help on using the repository browser.