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

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

Start version of compilation script.

  • Property svn:executable set to *
File size: 9.3 KB
RevLine 
[4268]1#!/bin/bash
2#set -vx
3# Default options
4#
5#
6#
[4409]7date
[4268]8#### 1  Set up the compiling options
9#### Define some directories
10submitdir=$( pwd )
11modipsl=$submitdir/../..
[4275]12arch_path=$submitdir/ARCH
[4268]13
[4278]14#### Set default options
[4471]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
[4268]24# Optimization mode
25# optmode=prod/dev/debug
26optmode=prod
27# fcm_arch
28fcm_arch=default
29# Default values to be overritten
[4339]30parallel=mpi_omp
[4268]31export fcm_arch parallel xios
32full_flag=""
[4391]33# Default netcdf_lib is used for XIOS but can be change by argument
34netcdf_lib=""
[4268]35
[4408]36# Output text file for compilation of each component
[4471]37outfile=$submitdir/out_compile_ipslcm6
[4408]38rm -f $outfile; echo > $outfile
[4471]39echo; echo "Text output from compilation will be stored in file out_compile_ipslcm6"; echo 
[4408]40
[4278]41#### Read arguments
[4268]42# Loop over all arguments to modify default set up
43while (($# > 0)) ; do
[4278]44    case $1 in
45        "-h") cat <<fin
[4268]46
47########################################################################
[4471]48# Usage of the script compile_ipslcm6.sh
[4268]49#
50########################################################################
51
[4471]52./compile_ipslcm6.sh [Options]
[4268]53
54
[4471]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.
[4268]59
[4407]60
[4471]61Example 1: Default compilation of IPSLCM6 for resoltion LR
62          (Resolution atmos: 144x142x79, ocean: ORCA1)
63./compile_ipslcm6.sh
[4268]64
[4471]65Example 2: Compilation of IPSLCM6 for resolution MR025
66           (atmos: 256x256x79, ocean: ORCA025, NOPISCES)
67./compile_ipslcm6.sh MR025
[4268]68
[4471]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
[4278]81fin
82            exit;;
[4268]83
[4471]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
[4278]96        "-parallel")
97            parallel=$2 ; shift ; shift ;;
98       
99        "-arch")
100            fcm_arch="$2" ; shift ; shift ;;
101       
[4407]102        "-debug")
103            optmode=debug ; shift ;;
104
105        "-dev")
106            optmode=dev ; shift ;;
107
108        "-prod")
109            optmode=prod ; shift ;;
110
[4278]111        "-full")
112            full_flag="-full"; shift ;;
113       
[4391]114        "-netcdf_lib_seq")
115            netcdf_lib="--netcdf_lib netcdf4_seq"; shift ;;
116
[4278]117        *)
118            echo "unknown option "$2" , exiting..."
119            exit
120    esac
121done
[4268]122
[4471]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 
[4408]127echo >> $outfile
[4268]128
[4278]129### Read host dependent default values
130### These variables will not be changed if they were set as argument
[4268]131###./host.sh $host
132# Later : Following lines should be set in host.sh file
133# begin host.sh
134if [ $fcm_arch == default ] ; then
[4278]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*)
[4391]140            fcm_arch=X64_IRENE;;
[4278]141        asterix*|obelix*)
142            fcm_arch=ifort_LSCE;;
[4391]143        ciclad*|climserv*)
144            fcm_arch=ifort_CICLAD;;
[4278]145        *)
[4391]146            echo Current host is not known. You must use option -arch to specify which architecuture files to use.
[4278]147            echo Exit now.
148            exit
149    esac
[4268]150fi
151
[4452]152# Set a link to arch.env if arch-${fcm_arch}.env file exist for current fcm_arch.
[4391]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
[4408]155    echo >> $outfile
[4470]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
[4391]163    rm -f ARCH/arch.env
164    ln -s arch-${fcm_arch}.env ARCH/arch.env
[4470]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
[4391]171fi
172
[4268]173#### 2 Do the compilation
174## 2.1 Compile ioipsl
175cd $modipsl/modeles/IOIPSL
[4278]176echo; echo "NOW COMPILE IOIPSL"
[4408]177echo >> $outfile ; echo " NOW COMPILE IOIPSL"   >> $outfile 
178
[4411]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
[4408]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
[4268]188# Test if compiling succeded
189if [[ $? != 0 ]] ; then
[4278]190    echo "THERE IS A PROBLEM IN IOIPSL COMPILATION - STOP"
191    exit
[4268]192fi
193
194## 2.2 Compile xios
195cd $modipsl/modeles/XIOS
[4278]196echo; echo "NOW COMPILE XIOS"
[4408]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
[4268]200# Test if compiling succeded
201if [[ $? != 0 ]] ; then
[4278]202    echo "THERE IS A PROBLEM IN XIOS COMPILATION - STOP"
203    exit
[4268]204fi
[4391]205# Move executables to modipsl/bin
[4457]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
[4391]208else
209    echo "THERE IS A PROBLEM IN XIOS COMPILATION EXECUTABLE MISSING - STOP"
210    exit
211fi
[4268]212
[4391]213
[4268]214## 2.3 Compile orchidee
215cd $modipsl/modeles/ORCHIDEE
[4278]216echo; echo "NOW COMPILE ORCHIDEE"
[4408]217echo >> $outfile ; echo " NOW COMPILE ORCHIDEE"   >> $outfile 
218
[4452]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
[4268]221# Test if compiling finished
222if [[ $? != 0 ]] ; then
223    echo "THERE IS A PROBLEM IN ORCHIDEE COMPILATION - STOP"
224    exit
225fi
226
[4408]227
[4411]228## 2.4 Compile LMDZ for regular latlon configuration
[4469]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 
[4268]233
[4469]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
[4408]241
[4469]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
[4278]253
[4469]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
[4408]261
[4469]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
[4278]266
[4268]267fi
268
[4278]269
[4408]270echo >>$outfile ; echo "ALL COMPILING FINISHED" >> $outfile
271echo; echo "ALL COMPILING FINISHED"
[4278]272
[4409]273date
[4268]274exit
275
276
Note: See TracBrowser for help on using the repository browser.