source: CONFIG/UNIFORM/v6/LMDZORINCA_v6.2/compile_lmdzorinca.sh @ 4683

Last change on this file since 4683 was 4625, checked in by acosce, 5 years ago

new configuration with LMDZ trunk

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