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

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

Remove .resol file which is not needed anymore

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