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

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

As done in compilat_ipslcm6.sh [4622]:

  • Add date on the output text file to avoid deleating preivously file if recompilation
  • Check and remove dimensions.h and .lock in LMDZ to avoid makelmdz_fcm interupt the compilation with the question:

"WARNING: you are probably already compiling the model somewhere else.
Wait until the first compilation is finished before launching this one.
If you are sure that you are not compiling elsewhere, just answer
yes (or 'oui') to the question below to proceed.
Do you wish to continue?"

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