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

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

Add printing of start and end time of compilation

  • Property svn:executable set to *
File size: 10.6 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]13export ROOT=$modipsl/modeles/DYNAMICO
14
[4278]15#### Set default options
[4268]16# Optimization mode
17# optmode=prod/dev/debug
18optmode=prod
19# Resolution if compiling LMDZ in regular mode without DYNAMICO
[4278]20# Use for example following "./compile_icolmdzor.sh -regular_lonlat 144x142x79"
[4268]21regular_latlon=no
22# fcm_arch
23fcm_arch=default
24# Default values to be overritten
[4339]25parallel=mpi_omp
[4268]26export fcm_arch parallel xios
27full_flag=""
[4391]28# Default netcdf_lib is used for XIOS but can be change by argument
29netcdf_lib=""
[4268]30
[4408]31# Output text file for compilation of each component
32outfile=$submitdir/out_compile_icolmdzor
33rm -f $outfile; echo > $outfile
34echo; echo "Text output from compilation will be stored in file out_compile_icolmdzor"; echo 
35
[4278]36#### Read arguments
[4268]37# Loop over all arguments to modify default set up
38while (($# > 0)) ; do
[4278]39    case $1 in
40        "-h") cat <<fin
[4268]41
42########################################################################
[4278]43# Usage of the script compile_icolmdzor.sh
[4268]44#
45########################################################################
46
47./compile_config [Options]
48
[4407]49Options: -full, -regular_latlon, -debug, -dev, -prod(default)
[4268]50
[4278]51Example 1: Default compilation of DYNAMICO-LMDZ-ORCHIDEE with XIOS and IOIPSL
52./compile_icolmdzor.sh
[4268]53
[4407]54Example 2: Compile in debug mode
55./compile_icolmdzor.sh -debug
56
57Example 3: Default compilation with full recompilation of all components
[4278]58./compile_icolmdzor.sh -full
[4268]59
[4407]60Example 4: Compilation of LMDZ in regular lat-lon for dimension 144x142x79.
[4278]61The dimension can be changed to any other 3d dimension. DYNAMICO is also compiled as default.
62./compile_icolmdzor.sh -regular_latlon 144x142x79
[4268]63
[4278]64fin
65            exit;;
[4268]66
[4278]67        "-parallel")
68            parallel=$2 ; shift ; shift ;;
69       
70        "-arch")
71            fcm_arch="$2" ; shift ; shift ;;
72       
73        "-xios")
74            xios="$2" ; shift ; shift ;;
75       
76        "-optmode")
77            optmode=$2 ; shift ; shift ;;
[4407]78
79        "-debug")
80            optmode=debug ; shift ;;
81
82        "-dev")
83            optmode=dev ; shift ;;
84
85        "-prod")
86            optmode=prod ; shift ;;
87
[4278]88        "-regular_latlon")
89            regular_latlon=yes ;
90            resol_atm_3d=$2 ; shift ; shift ;;
91       
92        "-full")
93            full_flag="-full"; shift ;;
94       
[4391]95        "-netcdf_lib_seq")
96            netcdf_lib="--netcdf_lib netcdf4_seq"; shift ;;
97
[4278]98        *)
99            echo "unknown option "$2" , exiting..."
100            exit
101    esac
102done
[4268]103
[4408]104echo "Following arguments are set in current compiling:" >> $outfile 
105echo "   optmode = $optmode, parallel = $parallel, fcm_arch = $fcm_arch, full_flag=$full_flag regular_latlon=$regular_latlon" >> $outfile 
106echo >> $outfile
[4268]107
[4278]108### Read host dependent default values
109### These variables will not be changed if they were set as argument
[4268]110###./host.sh $host
111# Later : Following lines should be set in host.sh file
112# begin host.sh
113if [ $fcm_arch == default ] ; then
[4278]114    # Find out current host and source specific paths and commands for the host
115    case $( hostname -s ) in
116        ada*)
117            fcm_arch=X64_ADA;;
118        irene*)
[4391]119            fcm_arch=X64_IRENE;;
[4278]120        asterix*|obelix*)
121            fcm_arch=ifort_LSCE;;
[4391]122        ciclad*|climserv*)
123            fcm_arch=ifort_CICLAD;;
[4278]124        *)
[4391]125            echo Current host is not known. You must use option -arch to specify which architecuture files to use.
[4278]126            echo Exit now.
127            exit
128    esac
[4268]129fi
130
[4391]131# Set a link to arch.env and source the file if arch-${fcm_arch}.env file exist for current fcm_arch.
132# The link arch.env is also set in config.card and will be used by libIGCM to ensure the same running environnement.
133if [ -f ARCH/arch-${fcm_arch}.env ] ; then
[4408]134    echo >> $outfile
135    echo "The file ARCH/arch-${fcm_arch}.env will now be sourced with modules needed for compilation."
136    echo "Note that this new environement will be kept after compilation."
137    echo "You might want to source again your personal environment after compilation. This must be done manually or by reconnection."
138    echo " Personal module list before sourcing of ARCH/arch.env file:"    >> $outfile 
139    module list   >> $outfile 2>&1
140
[4391]141    rm -f ARCH/arch.env
142    ln -s arch-${fcm_arch}.env ARCH/arch.env
[4408]143    source ARCH/arch.env   >> $outfile 2>&1
144
145    echo >> $outfile
146    echo " New module list after sourcing of ARCH/arch.env file:"    >> $outfile 
147    module list   >> $outfile 2>&1
[4391]148fi
149
[4268]150#### 2 Do the compilation
151## 2.1 Compile ioipsl
152cd $modipsl/modeles/IOIPSL
[4278]153echo; echo "NOW COMPILE IOIPSL"
[4408]154echo >> $outfile ; echo " NOW COMPILE IOIPSL"   >> $outfile 
155
156echo ./makeioipsl_fcm -$optmode -parallel -arch ${fcm_arch} -arch_path $arch_path -j 8 $full_flag   >> $outfile 
157     ./makeioipsl_fcm -$optmode -parallel -arch ${fcm_arch} -arch_path $arch_path -j 8 $full_flag   >> $outfile 2>&1
[4268]158# Test if compiling succeded
159if [[ $? != 0 ]] ; then
[4278]160    echo "THERE IS A PROBLEM IN IOIPSL COMPILATION - STOP"
161    exit
[4268]162fi
163
164## 2.2 Compile xios
165cd $modipsl/modeles/XIOS
[4278]166echo; echo "NOW COMPILE XIOS"
[4408]167echo >> $outfile ; echo " NOW COMPILE XIOS"   >> $outfile 
168echo ./make_xios --$optmode --arch $fcm_arch --arch_path $arch_path ${netcdf_lib} --job 4 $full_flag   >> $outfile 
169     ./make_xios --$optmode --arch $fcm_arch --arch_path $arch_path ${netcdf_lib} --job 4 $full_flag   >> $outfile 2>&1
[4268]170# Test if compiling succeded
171if [[ $? != 0 ]] ; then
[4278]172    echo "THERE IS A PROBLEM IN XIOS COMPILATION - STOP"
173    exit
[4268]174fi
[4391]175# Move executables to modipsl/bin
176if [ $modipsl/modeles/XIOS/bin/xios_server.exe ] ; then
177    mv $modipsl/modeles/XIOS/bin/xios_server.exe $modipsl/bin/.
178else
179    echo "THERE IS A PROBLEM IN XIOS COMPILATION EXECUTABLE MISSING - STOP"
180    exit
181fi
[4268]182
[4391]183
[4268]184## 2.3 Compile orchidee
185cd $modipsl/modeles/ORCHIDEE
[4278]186echo; echo "NOW COMPILE ORCHIDEE"
[4408]187echo >> $outfile ; echo " NOW COMPILE ORCHIDEE"   >> $outfile 
188
189echo    ./makeorchidee_fcm -j 8 -xios -parallel $parallel -$optmode -arch ${fcm_arch} $full_flag    >> $outfile 
190        ./makeorchidee_fcm -j 8 -xios -parallel $parallel -$optmode -arch ${fcm_arch} $full_flag    >> $outfile 2>&1
[4268]191# Test if compiling finished
192if [[ $? != 0 ]] ; then
193    echo "THERE IS A PROBLEM IN ORCHIDEE COMPILATION - STOP"
194    exit
195fi
196
[4278]197## 2.4 Compile lmdz
[4268]198cd $modipsl/modeles/LMDZ
[4278]199# Compile LMDZ as library to couple to DYNAMICO
200echo; echo "NOW COMPILE LMDZ FOR COUPLING TO DYNAMICO"
[4408]201echo >> $outfile ; echo " NOW COMPILE LMDZ FOR COUPLING TO DYNAMICO"   >> $outfile 
202
203echo ./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    >> $outfile 
204     ./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    >> $outfile 2>&1
[4268]205# Test if compiling finished
206if [[ $? != 0 ]] ; then
[4278]207    echo "THERE IS A PROBLEM IN LMDZ PHYSICS COMPILATION - STOP"
[4268]208    exit
209fi
210
[4278]211
212## 2.5 Compile DYNAMICO
[4408]213cd $modipsl/modeles/DYNAMICO
[4278]214echo; echo "NOW COMPILE DYNAMICO "
[4408]215echo >> $outfile ; echo " NOW COMPILE DYNAMICO"   >> $outfile 
216
217echo ./make_icosa -$optmode -parallel $parallel -external_ioipsl -with_xios -arch $fcm_arch -arch_path $arch_path -job 8 $full_flag    >> $outfile 
218     ./make_icosa -$optmode -parallel $parallel -external_ioipsl -with_xios -arch $fcm_arch -arch_path $arch_path -job 8 $full_flag    >> $outfile 2>&1
[4268]219# Test if compiling finished
220if [[ $? != 0 ]] ; then
[4278]221    echo "THERE IS A PROBLEM IN DYNAMICO COMPILATION - STOP"
222    exit
[4268]223fi
224
[4278]225## 2.6 Compile interface ICOSA_LMDZ
[4408]226cd $modipsl/modeles/ICOSA_LMDZ
[4278]227echo; echo "NOW COMPILE ICOSA_LMDZ "
[4408]228echo >> $outfile ; echo " NOW COMPILE ICOSA_LMDZ"   >> $outfile 
[4268]229
[4408]230echo ./make_icosa_lmdz -nodeps -p lmd -$optmode -parallel $parallel -with_orchidee -arch ${fcm_arch} -arch_path ${arch_path} -job 8 $full_flag    >> $outfile 
231     ./make_icosa_lmdz -nodeps -p lmd -$optmode -parallel $parallel -with_orchidee -arch ${fcm_arch} -arch_path ${arch_path} -job 8 $full_flag    >> $outfile 2>&1
[4268]232# Test if compiling finished
233if [[ $? != 0 ]] ; then
[4278]234    echo "THERE IS A PROBLEM IN ICOSA_LMDZ COMPILATION - STOP"
235    exit
[4268]236fi
[4391]237# Move executables to modipsl/bin
238if [ $modipsl/modeles/ICOSA_LMDZ/bin/icosa_lmdz.exe ] ; then
239    mv $modipsl/modeles/ICOSA_LMDZ/bin/icosa_lmdz.exe $modipsl/bin/.
240else
241    echo "THERE IS A PROBLEM IN ICOSA_LMDZ COMPILATION EXECUTABLE MISSING - STOP"
242    exit
243fi
[4268]244
245
[4359]246
[4278]247## 2.7 Compile LMDZ for regular latlon configuration
248if [ $regular_latlon = yes ] ; then
[4268]249
[4278]250    cd $modipsl/modeles/LMDZ
251    # Compile LMDZ regular lat-lon exectuable
252    echo; echo "NOW COMPILE LMDZ REGULAR LAT-LON MODE. Resolution = ${resol_atm_3d}"
[4408]253    echo >> $outfile ; echo " NOW COMPILE LMDZ REGULAR LAT-LON MODE. Resolution = ${resol_atm_3d}"   >> $outfile 
254
255    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    >> $outfile 
256         ./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    >> $outfile 2>&1
[4278]257    # Test if compiling finished
258    if [[ $? != 0 ]] ; then
259        echo "THERE IS A PROBLEM IN LMDZ REGULAR LATLON COMPILATION - STOP"
260        exit
261    fi
262
263    # Compile ce0l initialization program for LMDZ regular lat-lon exectuable
264    echo; echo "NOW COMPILE CE0L OF LMDZ. Resolution = ${resol_atm_3d}"
[4408]265    echo >> $outfile ; echo " NOW COMPILE CE0L OF LMDZ. Resolution = ${resol_atm_3d}"   >> $outfile 
266
267    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    >> $outfile 
268         ./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    >> $outfile 2>&1
[4278]269    # Test if compiling finished
270    if [[ $? != 0 ]] ; then
271        echo "THERE IS A PROBLEM IN CE0L (LMDZ) REGULAR LATLON COMPILATION - STOP"
272        exit
273    fi
274
275    # Find executable suffix
276    if [ $parallel == seq ] || [ $parallel == none ] ; then
277        suffix=_${resol_atm_3d}_phylmd_seq_orch
278    else
279        suffix=_${resol_atm_3d}_phylmd_para_mem_orch
280    fi
281    echo suffix = $suffix
[4268]282   
[4278]283    # Move executables to modipsl/bin folder
284    echo "Move gcm.e and ce0l executable to modipsl/bin"
285    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
286    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
[4268]287
288    # Write .resol file
289    cd $submitdir   
[4278]290    resol2D=$( echo ${resol_atm_3d} | awk '-Fx' '{print $1}' )$( echo ${resol_atm_3d} | awk '-Fx' '{print $2}' )
[4268]291    echo "noORCAxLMD$resol2D" >.resol
[4278]292    echo "RESOL_ATM_3D=${resol_atm_3d}" >>.resol
[4268]293fi
294
[4278]295
[4408]296echo >>$outfile ; echo "ALL COMPILING FINISHED" >> $outfile
297echo; echo "ALL COMPILING FINISHED"
[4278]298
[4409]299date
[4268]300exit
301
302
Note: See TracBrowser for help on using the repository browser.