source: BOL/script_install/install_lmdz.sh @ 4930

Last change on this file since 4930 was 4919, checked in by Laurent Fairhead, 5 months ago

Switching from forge.ipsl.jussieu.fr to forge.ipsl.fr

  • Property svn:executable set to *
File size: 57.2 KB
RevLine 
[4210]1#!/bin/bash
2
3#set -vx
4
5###########################################################################
6# Author : Laurent Fairhead et Frédéric Hourdin
7# Usage  : install_lmdz.sh -help
8#
9# bash installation script of the LMDZ model on different computer types :
10# Linux PC, "mesocentre" (IPSL-UPMC, IPSL-X), super-computer (IDRIS)
11#
12# The model is downloaded in the following directory tree
13# $MODEL/modipsl/modeles/...
14# using the "modipsl" infrastructure created by the "IPSL"
15# for coupled (atmosphere/ocean/vegetation/chemistry) climate modeling
16# activities.
17# Here we only download atmospheric (LMDZ) and vegetation (ORCHIDEE)
18# components.
19#
20# The sources of the models can be found in the "modeles" directory.
[4218]21# In the present case, LMDZ, ORCHIDEE, and IOIPSL or XIOS (handling of
22# input-outputs using the NetCDF library).
[4210]23#
24# The script downloads various source files (including a version of NetCDF)
25# and utilities, compiles the model, and runs a test simulation in a
26# minimal configuration.
27#
28# Prerequisites : pgf90/gfortran, bash or ksh, wget , gunzip, tar, ...
29#
30# Modif 18/11/2011
31#    changes for option real 8.
32#      We compile with -r8 (or equivalent) and -DNC_DOUBLE for the GCM
33#      but with -r4 for netcdf. Variable real must be set to
34#      r4 or r8 at the beginning of the script below.
35#
36###########################################################################
37
38echo install_lmdz.sh DEBUT `date`
39set -e
40
41################################################################
42# Choice of installation options
43################################################################
44
45################################################################
46# A function to fetch files either locally or on the internet
47################################################################
48function myget { #1st and only argument should be file name
[4215]49    # Path on local computer where to look for the datafile
50    if [ -f /u/lmdz/WWW/LMDZ/pub/$1 ] ; then
[4405]51        \cp -f -p /u/lmdz/WWW/LMDZ/pub/$1 .
[4215]52    elif [ -f ~/LMDZ/pub/$1 ] ; then
[4405]53        \cp -f -p ~/LMDZ/pub/$1 .
[4215]54    else
[4405]55        wget --no-check-certificate -nv http://lmdz.lmd.jussieu.fr/pub/$1
56        save_pub_locally=0
57        if [ $save_pub_locally = 1 ] ; then # saving wget files on ~/LMDZ/pub
58            dir=~/LMDZ/pub/`dirname $1` ; mkdir -p $dir
59            cp -r `basename $1` $dir
60        fi
[4210]61    fi
62}
63
64# 04_2021 : tester si r4 marche encore !
65#real=r4
66real=r8
67
68
69#########################################################################
70# Valeur par défaut des parametres
71#########################################################################
72svn=""
73#version=trunk
[4731]74version=20231022.trunk
[4210]75
76getlmdzor=1
[4237]77netcdf=1   #  1: for automatic installation;
[4267]78#          or 0: do not install NetCDF and look for it in standard locations;
79#          or absolute path: look for NetCDF there
[4210]80check_linux=1
81ioipsl=1
82bench=1
83pclinux=1
84pcmac=0 # default: not on a Mac
85compiler=gfortran
[4779]86if [ `gfortran -dumpversion | cut -d. -f1` -ge 10 ] ; then allow_arg_mismatch="-fallow-argument-mismatch" ; fi
[4210]87SCM=0
88# surface/vegetation scheme treatment
89# controlled by the single variable veget which can have the following values
90# - NONE: bucket scheme (default)
91# - CMIP6: orchidee version used in CMIP exercise, rev 5661
92# - number: orchidee version number
93veget=NONE
94# choose the resolution for the bench runs
95# grid_resolution= 32x24x11 or 48x36x19 for tests (test without ORCHIDEE)
96#                  96x71x19  standard configuration
97grid_resolution=144x142x79
98grid_resolution=96x95x39
99grid_resolution=48x36x19
100grid_resolution=32x32x39
101# choose the physiq version you want to test
102#physiq=NPv6.0.14splith
103physiq=
104
105## parallel can take the values none/mpi/omp/mpi_omp
106parallel=mpi_omp
107parallel=none
108idris_acct=lmd
[4417]109trusting=testing
[4210]110OPT_GPROF=""
111OPT_MAKELMDZ=""
112MODEL=""
113
114## also compile XIOS? (and more recent NetCDF/HDF5 libraries) Default=no
115with_xios="n"
116opt_makelmdz_xios=""
117
118## compile with oldrad/rrtm/ecrad radiatif code (Default=rrtm)
119rad=rrtm
120
121## compile_with_fcm=1 : use makelmdz_fcm (1) or makelmdz (0)
122compile_with_fcm=1
123
124#Compilation with Cosp (cosp=NONE/v1/v2 ; default=NONE)
125cosp=NONE
126opt_cosp=""
127
128# Check if on a Mac
129if [ `uname` = "Darwin" ]
130then
131    pcmac=1
132    export MAKE=make
133fi
134#echo "pcmac="$pcmac
135
136env_file=""
137
138#########################################################################
139#  Options interactives
140#########################################################################
141while (($# > 0))
[4215]142do
143    case $1 in
[4405]144        "-h") cat <<........fin
[4210]145    $0 [ -v version ] [ -r svn_release ]
146           [ -parallel PARA ] [ -d GRID_RESOLUTION ] [ -bench 0/1 ]
147           [-name LOCAL_MODEL_NAME] [-gprof] [-opt_makelmdz] [-rad RADIATIF]
148
149    -v       "version" like 20150828.trunk
150             see http://www.lmd.jussieu.fr/~lmdz/Distrib/LISMOI.trunk
151
152    -r       "svn_release" : either the svn release number or "last"
153
154    -compiler gfortran|ifort|pgf90 (default: gfortran)
155
156    -parallel PARA : can be mpi_omp (mpi with openMP) or none (for sequential)
157
158    -d        GRID_RESOLUTION should be among the available benchs if -bench 1
159              among which : 48x36x19, 48x36x39
160              if wanting to run a bench simulation in addition to compilation
161              default : 48x36x19
162
163    -bench     activating the bench or not (0/1). Default 1
164
[4421]165    -testing/unstable
[4417]166
[4210]167    -name      LOCAL_MODEL_NAME : default = LMDZversion.release
168
[4211]169    -netcdf    0, 1 or PATH
[4405]170                   0: do not download NetCDF, look for it in standard locations
171               1: download and compile NetCDF
172                   PATH: full path to an existing installed NetCDF library
[4210]173
174    -xios      also download and compile the XIOS library
175               (requires the NetCDF4-HDF5 library, also installed by default)
176               (requires to also have -parallel mpi_omp)
177
178    -gprof     to compile with -pg to enable profiling with gprof
179
180    -cosp      to run without our with cospv1 or cospv2 [none/v1/v2]
181
182    -rad RADIATIF can be oldrad, rrtm or ecrad radiatif code
183
184    -nofcm     to compile without fcm
185
186    -SCM        install 1D version automatically
187
188    -debug      compile everything in debug mode
189
190    -opt_makelmdz     to call makelmdz or makelmdz_fcm with additional options
191
192    -physiq    to choose which physics package to use
193
194    -env_file  specify an arch.env file to overwrite the existing one
195
196    -veget surface model to run [NONE/CMIP6/xxxx]
197
198........fin
[4405]199              exit ;;
200        "-v") version=$2 ; shift ; shift ;;
201        "-r") svn=$2 ; shift ; shift ;;
202        "-compiler") compiler=$2
[4215]203                     case $compiler in
[4405]204                         "gfortran"|"ifort"|"pgf90") compiler=$2 ; shift
205                                                     shift ;;
206                         *) echo "Only gfortran , ifort or pgf90 for the " \
207                                 "compiler option"
208                            exit
[4215]209                     esac ;;
[4405]210        "-d") grid_resolution=$2 ; shift ; shift ;;
211        "-gprof") OPT_GPROF="-pg" ; shift ;;
[4417]212        "-unstable"|"-testing") trusting=`echo $1 | cut -c2-`  ; shift ;;
[4405]213        "-cosp") cosp=$2
214                 case $cosp in
[4215]215                     "none"|"v1"|"v2") cosp=$2 ; shift ; shift ;;
216                     *) echo Only none v1 v2 for cosp option ; exit
[4405]217                 esac ;;
218        "-nofcm") compile_with_fcm=0 ; echo This option will be reactivated soon '(promesse du 8dec2022)' ; exit 1 ;  shift ;;
219        "-SCM") SCM=1 ; shift ;;
220        "-opt_makelmdz") OPT_MAKELMDZ="$2" ; shift ; shift ;;
221        "-rrtm") rrtm="$2"
222                 if [ "$2" = "false" ] ; then
223                     rad="oldrad"
224                 else
225                     rad="rrtm"
226                 fi
227                 shift ; shift ;;
228        "-rad") rad=$2
229                case $rad in
[4215]230                    "oldrad"|"rrtm"|"ecrad") rad=$2 ; shift ; shift ;;
231                    *) echo Only oldrad rrtm ecrad for rad option ; exit
[4405]232                esac ;;
233        "-parallel") parallel=$2
[4215]234                     case $parallel in
[4405]235                         "none"|"mpi"|"omp"|"mpi_omp") parallel=$2 ; shift
236                                                       shift ;;
237                         *) echo Only none mpi omp mpi_omp for the parallel \
238                                 option
239                            exit
[4215]240                     esac ;;
[4405]241        "-bench") bench=$2 ; shift ; shift ;;
242        "-debug") optim=-debug ; shift ;;
243        "-name") MODEL=$2 ; shift ; shift ;;
[4546]244        "-netcdf") netcdf=$2 ; shift ; shift ;;
[4405]245        "-physiq") physiq=$2 ; shift ; shift ;;
246        "-xios") with_xios="y" ; shift ;;
247        "-env_file") env_file=$2 ; shift ; shift ;;
248        "-veget") veget=$2 ; shift ; shift ;;
[4546]249        *)  bash install_lmdz.sh -h ; exit
[4215]250    esac
[4210]251done
252
[4218]253# Option de compilation du rayonnement : depend de $mysvn ><= r4185,
254# sera donc definie plus bas
255
[4210]256#opt_rad=""
257#case $rad in
258#   rrtm) opt_rad="-rad rrtm" ;;
259#   ecrad) opt_rad="-rad ecrad" ;;
260#esac
261
[4807]262
[4210]263# Option de compilation pour Cosp
264opt_cosp=""
[4784]265case $cosp in
[4215]266    v1) opt_cosp="-cosp true" ;;
267    v2) opt_cosp="-cospv2 true" ;;
[4210]268esac
269
270# Check on veget version
271#if [ "$veget" != 'NONE'  -a "$veget" != "CMIP6" -a "$veget" != +([0-9]) ] ; then
272if [ $veget != 'NONE'   -a $veget != "CMIP6" ] ; then
273    re='^[0-9]+$'
274    if ! [[ $veget =~ $re ]] ; then
[4405]275        echo 'Valeur de l option veget non valable'
276        exit
[4210]277    fi
278fi
279
280#Define veget-related suffix for gcm name
281if [ "$veget" = 'NONE' ] ; then
282    suff_orc=''
[4218]283    #For use with tutorial, orchidee_rev is also defined (will be
284    #written in surface_env at the end of the script)
[4210]285    orchidee_rev=''
286else
287    suff_orc='_orch'
288fi
289
290
[4218]291if [ $parallel = none ] ; then
292    sequential=1; suff_exe='_seq'
293else
294    sequential=0; suff_exe='_para_mem'
295fi
[4210]296
297#Chemin pour placer le modele
298if [ "$MODEL" = "" ] ; then MODEL=./LMDZ$version$svn$optim ; fi
299
300
301arch=local
302
303
304if [ $compiler = g95 ] ; then echo g95 is not supported anymore ; exit ; fi
305
306################################################################
307# Specificite des machines
308################################################################
309
310hostname=`hostname`
311if [ "$pclinux" = 1 ] ; then o_ins_make="-t g95" ; else o_ins_make="" ; fi
312
313case ${hostname:0:5} in
314
[4215]315    jean-)   compiler="mpiifort" ;
316             par_comp="mpiifort" ;
317             o_ins_make="-t jeanzay" ;
318             make=gmake ;
319             module purge
320             module load intel-compilers/19.0.4 ;
321             #module load intel-mpi/19.0.4 ;
322             #module load intel-mkl/19.0.4 ;
323             module load hdf5/1.10.5-mpi ;
324             module load netcdf/4.7.2-mpi ;
325             module load netcdf-fortran/4.5.2-mpi ;
326             module load subversion/1.9.7 ;
[4503]327             module load cmake
[4508]328             export NETCDF_LIBDIR=./
[4215]329             export NETCDFFORTRAN_INCDIR=./
330             export NETCDFFORTRAN_LIBDIR=./
331             arch=X64_JEANZAY ;;
[4210]332
[4215]333    cicla|camel)   compiler="gfortran" ;
[4405]334                   module purge
335                   module load gnu/10.2.0
336                   module load openmpi/4.0.5
337                   module load hdf5/1.10.7-mpi
338                   module load netcdf-c/4.7.4-mpi
339                   module load netcdf-fortran/4.5.3-mpi
340                   netcdf=/net/nfs/tools/PrgEnv/linux-scientific6-x86_64/gcc-10.2.0/netcdf-fortran-4.5.3-k3drgfqok3lip62hnm3tsyof4cjen5sk
341                   module load svn/1.14.0
[4211]342
[4405]343                   if [ $parallel != none ] ; then
344                       root_mpi=/net/nfs/tools/meso-sl6/openmpi/4.0.5-gcc-10.2.0
345                       path_mpi=$root_mpi/bin ;
346                       par_comp=${path_mpi}/mpif90 ;
347                       mpirun=${path_mpi}/mpirun ;
348                   fi ;
349                   arch=local  ;
350                   make=make ;
351                   o_ins_make="-t g95" ;;
[4210]352
[4215]353    *)       if [ $parallel = none -o -f /usr/bin/mpif90 ] ; then
354                 path_mpi=`which mpif90 | sed -e s:/mpif90::` ;
355                 if [ -d /usr/lib64/openmpi ] ; then
356                     root_mpi="/usr/lib64/openmpi"
357                 else
358                     root_mpi="/usr"
359                 fi
360             else
[4405]361                 echo "Cannot find mpif90" ;
362                 if [ $parallel = none ] ; then exit ; fi ;
[4215]363             fi ;
364             if [ $parallel != none ] ; then
[4405]365                 root_mpi=$(which mpif90 | sed -e s:/bin/mpif90::)
366                 path_mpi=$(which mpif90 | sed -e s:/mpif90::)
367                 export LD_LIBRARY_PATH=${root_mpi}/lib:$LD_LIBRARY_PATH
[4215]368             fi
369             par_comp=${path_mpi}/mpif90 ;
370             mpirun=${path_mpi}/mpirun ;
371             arch=local  ;
372             make=make ;
373             o_ins_make="-t g95"
[4210]374esac
375
376# Flags for parallelism:
377if [ $parallel != none ] ; then
[4215]378    # MPI_LD are the flags needed for linking with MPI
379    MPI_LD="-L${root_mpi}/lib -lmpi"
380    if [ "$compiler" = "gfortran" ] ; then
[4405]381        # MPI_FLAGS are the flags needed for compilation with MPI
382        MPI_FLAGS="-fcray-pointer"
383        # OMP_FLAGS are the flags needed for compilation with OpenMP
384        OMP_FLAGS="-fopenmp -fcray-pointer"
385        # OMP_LD are the flags needed for linking with OpenMP
386        OMP_LD="-fopenmp"
[4215]387    elif [ "$compiler" = "ifort" ] ; then
[4405]388        MPI_FLAGS=""
389        OMP_FLAGS="-openmp"
390        OMP_LD="-openmp"
[4215]391    else # pgf90
[4405]392        MPI_FLAGS=""
393        OMP_FLAGS="-mp"
394        OMP_LD="-mp"
[4215]395    fi
[4210]396fi
397
398#####################################################################
399# Test for old gfortran compilers
400# If the compiler is too old (older than 4.3.x) we test if the
401# temporary gfortran44 patch is available on the computer in which
402# case the compiler is changed from gfortran to gfortran44
403# Must be aware than parallelism can not be activated in this case
404#####################################################################
405
406if [ "$compiler" = "gfortran" ] ; then
[4215]407    gfortran=gfortran
408    gfortranv=`gfortran --version | \
[4210]409   head -1 | awk ' { print $NF } ' | awk -F. ' { print $1 * 10 + $2 } '`
[4215]410    if [ $gfortranv -le 43 ] ; then
[4405]411        echo ERROR : Your gfortran compiler is too old
412        echo 'Please choose a new one (ifort) and change the line'
413        echo compiler=xxx
414        echo in the install_lmdz.sh script and rerun it
415        if [ `which gfortran44 | wc -w` -ne 0 ] ; then
[4215]416            gfortran=gfortran44
[4405]417        else
[4215]418            echo gfotran trop vieux ; exit
[4405]419        fi
[4215]420    fi
421    compiler=$gfortran
[4210]422fi
423#####################################################################
424
425## if also compiling XIOS, parallel must be mpi_omp
426if [ "$with_xios" = "y" -a "$parallel" != "mpi_omp" ] ; then
[4215]427    echo "Error, you must set -parallel mpi_omp if you want XIOS"
428    exit
[4210]429fi
430
431if [ "$with_xios" = "y" ] ; then
[4215]432    opt_makelmdz_xios="-io xios"
[4210]433fi
434
435if [ "$cosp" = "v2" -a "$with_xios" = "n" ] ; then
[4215]436    echo "Error, Cospv2 cannot run without Xios"
437    exit
[4210]438fi
439
440echo '################################################################'
441echo  Choix des options de compilation
442echo '################################################################'
443
444export FC=$compiler
445export F90=$compiler
446export F77=$compiler
447export CPPFLAGS=
448OPTIMNC=$OPTIM
449BASE_LD="$OPT_GPROF"
450OPTPREC="$OPT_GPROF"
[4218]451ARFLAGS="rs"
[4418]452if [ "`lsb_release -i -s`" = "Ubuntu" ] ; then
[4398]453    if [ "`lsb_release -r -s | cut -d. -f1`" -ge 16 ] ; then
454            ARFLAGS="rU"
[4218]455    fi
456fi
[4210]457
458if [ "$compiler" = "$gfortran" ] ; then
[4267]459   OPTIM="-O3 $allow_arg_mismatch"
460   OPTDEB="-g3 -Wall -fbounds-check -ffpe-trap=invalid,zero,overflow -O0 -fstack-protector-all -fbacktrace -finit-real=snan  $allow_arg_mismatch"
461   OPTDEV="-Wall -fbounds-check  $allow_arg_mismatch"
462   fmod='I '
463   OPTPREC="$OPTPREC -cpp -ffree-line-length-0"
464   if [ $real = r8 ] ; then OPTPREC="$OPTPREC -fdefault-real-8 -DNC_DOUBLE" ; fi
465   export F90FLAGS=" -ffree-form $OPTIMNC"
466   export FFLAGS=" $OPTIMNC"
467   export CC=gcc
468   export CXX=g++
469   export fpp_flags="-P -C -traditional -ffreestanding"
[4210]470
471elif [ $compiler = mpif90 ] ; then
[4215]472    OPTIM='-O3'
473    OPTDEB="-g3 -Wall -fbounds-check -ffpe-trap=invalid,zero,overflow -O0 -fstack-protector-all"
474    OPTDEV="-Wall -fbounds-check"
475    BASE_LD="$BASE_LD -lblas"
476    fmod='I '
[4218]477    if [ $real = r8 ] ; then
[4405]478        OPTPREC="$OPTPREC -fdefault-real-8 -DNC_DOUBLE -fcray-pointer"
[4218]479    fi
[4215]480    export F90FLAGS=" -ffree-form $OPTIMNC"
481    export FFLAGS=" $OPTIMNC"
482    export CC=gcc
483    export CXX=g++
[4210]484
485elif [ $compiler = pgf90 ] ; then
[4215]486    OPTIM='-O2 -Mipa -Munroll -Mnoframe -Mautoinline -Mcache_align'
487    OPTDEB='-g -Mdclchk -Mbounds -Mchkfpstk -Mchkptr -Minform=inform -Mstandard -Ktrap=fp -traceback'
488    OPTDEV='-g -Mbounds -Ktrap=fp -traceback'
489    fmod='module '
490    if [ $real = r8 ] ; then OPTPREC="$OPTPREC -r8 -DNC_DOUBLE" ; fi
491    export CPPFLAGS="-DpgiFortran"
492    export CC=pgcc
493    export CFLAGS="-O2 -Msignextend"
494    export CXX=pgCC
495    export CXXFLAGS="-O2 -Msignextend"
496    export FFLAGS="-O2 $OPTIMNC"
497    export F90FLAGS="-O2 $OPTIMNC"
498    compile_with_fcm=1
[4210]499
[4221]500elif [[ $compiler = ifort || $compiler = mpiifort ]] ; then
[4215]501    OPTIM="-O2 -fp-model strict -ip -align all "
502    OPTDEV="-p -g -O2 -traceback -fp-stack-check -ftrapuv -check"
503    OPTDEB="-g -no-ftz -traceback -ftrapuv -fp-stack-check -check"
504    fmod='module '
505    if [ $real = r8 ] ; then OPTPREC="$OPTPREC -real-size 64 -DNC_DOUBLE" ; fi
506    export CPP="icc -E"
507    export FFLAGS="-O2 -ip -fpic -mcmodel=large"
508    export FCFLAGS="-O2 -ip -fpic -mcmodel=large"
509    export CC=icc
510    export CFLAGS="-O2 -ip -fpic -mcmodel=large"
511    export CXX=icpc
512    export CXXFLAGS="-O2 -ip -fpic -mcmodel=large"
513    export fpp_flags="-P -traditional"
514    # Pourquoi forcer la compilation fcm. Marche mieux sans
515    #compile_with_fcm=1
[4210]516else
[4215]517    echo unexpected compiler $compiler ; exit
[4210]518fi
519
520OPTIMGCM="$OPTIM $OPTPREC"
521
522hostname=`hostname`
523
524##########################################################################
525# If installing on known machines such as Jean-Zay at IDRIS,
526# don't check for available software and don't install netcdf
527if [ ${hostname:0:5} = jean- ] ; then
[4215]528    netcdf=0 # no need to recompile netcdf, alreday available
529    check_linux=0
530    pclinux=0
531    ioipsl=0 # no need to recompile ioipsl, already available
532    #netcdf="/smplocal/pub/NetCDF/4.1.3"
533    compiler="mpiifort"
534    fmod='module '
535    if [ $real = r8 ] ; then OPTPREC="$OPTPREC -i4 -r8 -DNC_DOUBLE" ; fi
536    OPTIM="-auto -align all -O2 -fp-model strict -xHost "
537    OPTIMGCM="$OPTIM $OPTPREC"
[4210]538fi
539##########################################################################
540
541
542mkdir -p $MODEL
543echo $MODEL
544MODEL=`( cd $MODEL ; pwd )` # to get absolute path, if necessary
545
546
547if [ "$check_linux" = 1 ] ; then
[4372]548    echo '################################################################'
[4215]549    echo   Check if required software is available
550    echo '################################################################'
[4210]551
[4215]552    #### Ehouarn: test if the required shell is available
553    #### Maj FH-LF-AS 2021-04 : default=bash ; if bash missing, use ksh
554    use_shell="bash" # default
555    if [ "`which bash`" = "" ] ; then
[4405]556        echo "no bash ; we will use ksh"
557        use_shell="ksh"
558        if [ "`which ksh`" = "" ] ; then
559            echo "bash (or ksh) needed!! Install it!"
560            exit
561        fi
[4215]562    fi
[4210]563
[4372]564    for logiciel in wget tar gzip make $compiler gcc cmake m4 c++ ; do
[4405]565        if [ "`which $logiciel`" = "" ] ; then
566            echo You must first install $logiciel on your system
567            exit
568        fi
[4215]569    done
[4210]570
[4215]571    if [ $pclinux = 1 ] ; then
[4405]572        cd $MODEL
573        cat <<eod > tt.f90
[4210]574print*,'coucou'
575end
576eod
[4405]577        $compiler tt.f90 -o a.out
578        ./a.out >| tt
579        if [ "`cat tt | sed -e 's/ //g' `" != "coucou" ] ; then
580            echo problem installing with compiler $compiler ; exit ; fi
581        \rm tt a.out tt.f90
[4215]582    fi
[4210]583fi
584
585###########################################################################
586if [ $getlmdzor = 1 -a ! -d $MODEL/modipsl ] ; then
[4267]587###########################################################################
588   echo '##########################################################'
589   echo  Download a slightly modified version of  LMDZ
590   echo '##########################################################'
591   cd $MODEL
592   getlog=`pwd`/get.log
593   echo logfile : $getlog
[4417]594   myget src_archives/$trusting/modipsl.$version.tar.gz >> get.log 2>&1
[4267]595   echo install_lmdz.sh wget_OK `date`
596   gunzip modipsl.$version.tar.gz >> get.log 2>&1
[4286]597   tar xf modipsl.$version.tar >> get.log 2>&1
[4267]598   \rm modipsl.$version.tar
[4210]599fi
600
601###########################################################################
[4546]602echo Installing Netcdf
[4405]603###########################################################################
[4546]604
605if [ $netcdf = 0 ] ; then
606    ncdfdir=/usr
607
608else
[4215]609    cd $MODEL
[4212]610
[4405]611    case $compiler in
612      gfortran) opt1="-compiler gnu" ; opt2="-CC gcc -FC gfortran -CXX g++" ;;
613      ifort)  opt1="-compiler intel" ; opt2="-CC icc -FC ifort -CXX icpc" ;;
614      pgf90)  opt1="-compiler pgf90" ; opt2="-CC pgcc -FC pgf90 -CXX pgCC" ;;
615      *)      echo "unexpected compiler $compiler" for netcdf ; exit 1
616    esac
[4212]617
[4405]618    case $with_xios in
619        n) script_install_netcdf=install_netcdf4_hdf5_seq.bash
[4546]620           ncdfdir=netcdf4_hdf5_seq
[4405]621           opt_=$opt1 ;;
622        y) script_install_netcdf=install_netcdf4_hdf5.bash
[4546]623           ncdfdir=netcdf4_hdf5
[4405]624           opt_="$opt2 -MPI $root_mpi" ;;
625        *) echo with_xios=$with_xios, should be n or y ; exit 1
626    esac
[4546]627    if [ $netcdf = 1 ] ; then
628       ncdfdir=$MODEL/$ncdfdir
629    else
630       mkdir -p $netcdf ; ncdfdir=$netcdf/$ncdfdir
631    fi
[4405]632         
[4546]633    echo Repertoire netcdf $ncdfdir
634    if [ ! -d $ncdfdir ] ; then
635        netcdflog=`pwd`/netcdf.log
636        echo '----------------------------------------------------------'
637        echo Compiling the Netcdf library
638        echo '----------------------------------------------------------'
639        echo log file : $netcdflog
[4411]640        myget script_install/$script_install_netcdf >> $netcdflog 2>&1
[4405]641        chmod u=rwx $script_install_netcdf
642        ./$script_install_netcdf -prefix $ncdfdir $opt_ >> $netcdflog 2>&1
643    fi
644
645    #----------------------------------------------------------------------------
646    # LF rajout d'une verrue, pour une raison non encore expliquee,
647    # la librairie est parfois rangée dans lib64 et non dans lib
648    # par certains compilateurs
649    if [ ! -e lib -a -d lib64 ] ; then ln -s lib64 lib; fi
650    #----------------------------------------------------------------------------
651
[4215]652    echo install_lmdz.sh netcdf_OK `date`
[4210]653
654fi
655
[4238]656cat >test_netcdf90.f90 <<EOF
[4239]657use netcdf
[4238]658print *, "NetCDF library version: ", nf90_inq_libvers()
659end
660EOF
661
[4405]662$compiler -I$ncdfdir/include test_netcdf90.f90 -L$ncdfdir/lib -lnetcdff \
663          -lnetcdf -Wl,-rpath=$ncdfdir/lib && ./a.out
[4238]664   
665if (($? == 0))
666then
667    rm test_netcdf90.f90 a.out
668else
669    echo "Failed test program using NetCDF-Fortran."
670    echo "You can:"
671    echo "- check that you have NetCDF-Fortran installed in your system"
672    echo "- or specify an installation directory with option -netcdf of" \
[4405]673         "install_lmdz.sh"
[4238]674    echo "- or download and compile NetCDF-Fortran with option -netcdf 1 of" \
[4405]675         "install_lmdz.sh"
[4238]676    exit 1
677fi
678
[4210]679#=========================================================================
680if [[ ! -f $MODEL/modipsl/lib/libioipsl.a ]]
681then
[4215]682    if [ $ioipsl = 1 ] ; then
[4405]683        #=====================================================================
684        echo OK ioipsl=$ioipsl
685        echo '##########################################################'
686        echo 'Installing MODIPSL, the installation package manager for the '
687        echo 'IPSL models and tools'
688        echo '##########################################################'
689        echo `date`
[4210]690
[4405]691        cd $MODEL/modipsl
692        \rm -rf lib/*
693        cd util
694        cp AA_make.gdef AA_make.orig
695        F_C="$compiler -c "
696        if [ "$compiler" = "$gfortran" -o "$compiler" = "mpif90" ]
697        then
698            F_C="$compiler -c -cpp "
699        fi
700        if [ "$compiler" = "pgf90" ] ; then F_C="$compiler -c -Mpreprocess" ; fi
701        sed -e 's/^\#.*.g95.*.\#.*.$/\#/' AA_make.gdef > tmp
702        sed -e "s:F_L = g95:F_L = $compiler:" \
703            -e "s:F_C = g95 -c -cpp:F_C = $F_C": \
704            -e 's/g95.*.w_w.*.(F_D)/g95      w_w = '"$OPTIMGCM"'/' \
705            -e 's:g95.*.NCDF_INC.*.$:g95      NCDF_INC= '"$ncdfdir"'/include:' \
706            -e 's:g95.*.NCDF_LIB.*.$:g95      NCDF_LIB= -L'"$ncdfdir"'/lib -lnetcdff -lnetcdf:' \
707            -e 's:g95      L_O =:g95      L_O = -Wl,-rpath='"$ncdfdir"'/lib:' \
708            -e "s:-fmod=:-$fmod:" -e 's/-fno-second-underscore//' \
709            -e 's:#-Q- g95      M_K = gmake:#-Q- g95      M_K = make:' \
710            tmp >| AA_make.gdef
[4210]711
[4405]712        if [ $pcmac == 1 ]
713        then
714            cp AA_make.gdef tmp
715            sed -e 's/rpath=/rpath,/g' tmp > AA_make.gdef
716        fi
[4210]717
718
[4405]719        # We use lines for g95 even for the other compilers to run ins_make
720        if [ "$use_shell" = "ksh" ] ; then
721            ./ins_make $o_ins_make
722        else # bash
723            sed -e s:/bin/ksh:/bin/bash:g ins_make > ins_make.bash
724            if [ "`grep jeanzay AA_make.gdef`" = "" ] ; then
725                # Bidouille pour compiler sur ada des vieux modipsl.tar
726                echo 'Warning jean-zay not in AA_make.gdef'
727                echo 'Think about updating'
728                exit 1
729            fi
[4210]730
[4405]731            chmod u=rwx ins_make.bash
732            ./ins_make.bash $o_ins_make
733        fi # of if [ "$use_shell" = "ksh" ]
[4210]734
[4405]735        echo install_lmdz.sh MODIPSL_OK `date`
[4210]736
[4405]737        cd $MODEL/modipsl/modeles/IOIPSL/src
738        ioipsllog=`pwd`/ioipsl.log
739        echo '##########################################################'
740        echo 'Compiling IOIPSL, the interface library with Netcdf'
741        echo '##########################################################'
742        echo `date`
743        echo log file : $ioipsllog
[4210]744
[4405]745        if [ "$use_shell" = "bash" ] ; then
746            cp Makefile Makefile.ksh
747            sed -e s:/bin/ksh:/bin/bash:g Makefile.ksh > Makefile
748        fi
[4508]749        ### if [ "$pclinux" = 1 ] ; then
[4405]750        # Build IOIPSL modules and library
751        $make clean
752        $make > $ioipsllog 2>&1
753        if [ "$compiler" = "$gfortran" -o "$compiler" = "mpif90" ] ; then
754            # copy module files to lib
755            cp -f *.mod ../../../lib
756        fi
757        # Build IOIPSL tools (ie: "rebuild", if present)
[4542]758          # For IOIPSLv_2_2_2, "rebuild" files are in IOIPSL/tools
759        rebuild_dir=""
[4508]760        if [ -f $MODEL/modipsl/modeles/IOIPSL/tools/rebuild ] ; then 
[4542]761            rebuild_dir=$MODEL/modipsl/modeles/IOIPSL/tools
762        elif [ -d $MODEL/modipsl/modeles/IOIPSL/rebuild ] ; then
763              rebuild_dir=$MODEL/modipsl/modeles/IOIPSL/rebuild
764        fi
765        if [ $rebuild_dir != "" ] ; then
766            cd $rebuild_dir     
[4405]767            # adapt Makefile & rebuild script if in bash
768            if [ "$use_shell" = "bash" ] ; then
769                cp Makefile Makefile.ksh
770                sed -e s:/bin/ksh:/bin/bash:g Makefile.ksh > Makefile
771                cp rebuild rebuild.ksh
772                sed -e 's:/bin/ksh:/bin/bash:g' \
773                    -e 's:print -u2:echo:g' \
774                    -e 's:print:echo:g' rebuild.ksh > rebuild
775            fi
776            $make clean
777            $make > $ioipsllog 2>&1
778        fi
[4508]779        ### fi # of if [ "$pclinux" = 1 ] which is commented out
[4210]780
[4508]781    else # of if [ $ioipsl = 1 ]
[4405]782        if [ ${hostname:0:5} = jean- ] ; then
783            cd $MODEL/modipsl
784            cd util
[4215]785            if [ "`grep jeanzay AA_make.gdef`" = "" ] ; then
[4405]786                echo 'Warning jean-zay not in AA_make.gdef'
787                echo 'Think about updating'
788                exit 1
[4215]789            fi
790            ./ins_make $o_ins_make
[4405]791            # Compile IOIPSL on jean-zay
[4215]792            cd $MODEL/modipsl/modeles/IOIPSL/src
793            gmake > ioipsl.log
[4508]794            # For IOIPSLv_2_2_2, "rebuild" files are in IOIPSL/tools, so "gmake" in IOIPSL/tools is enough
795            # For IOIPSLv_2_2_5, "rebuild" files are in a separate IOIPSL/rebuild folder , while "tools" only contains "FCM"
796            if [ -f $MODEL/modipsl/modeles/IOIPSL/tools/Makefile ] ; then
[4502]797              cd $MODEL/modipsl/modeles/IOIPSL/tools
798              gmake > ioipsl.log
799            fi
[4508]800            if [ -d $MODEL/modipsl/modeles/IOIPSL/rebuild ] ; then
801              cd $MODEL/modipsl/modeles/IOIPSL/rebuild
802              gmake > ioipsl.log
803            fi
804
[4405]805        fi
806        echo install_lmdz.sh ioipsl_OK `date`
[4215]807    fi # of if [ $ioipsl = 1 ]
[4508]808fi # of if [[ ! -f $MODEL/modipsl/lib/libioipsl.a ]]
[4210]809
810#=========================================================================
811if [ "$with_xios" = "y" ] ; then
[4215]812    echo '##########################################################'
813    echo 'Compiling XIOS'
814    echo '##########################################################'
815    cd $MODEL/modipsl/modeles
816    xioslog=`pwd`/xios.log
817    #wget http://www.lmd.jussieu.fr/~lmdz/Distrib/install_xios.bash
[4411]818    myget script_install/install_xios.bash
[4215]819    chmod u=rwx install_xios.bash
[4709]820# following will be recalculated later on once LMDZ is updated
821#    mysvn=`svnversion LMDZ | egrep -o "[0-9]+" 2>/dev/null`
822    mysvn=`grep 'Revision: [0-9]' $MODEL/Read*.md | awk ' { print $2 } ' 2>/dev/null`
823    if [ "$svn" != "" ] ; then mysvn=$svn ; fi 
824    echo mysvn $mysvn
825
[4215]826    if [ ${hostname:0:5} = jean- ] ; then
[4708]827        if [ $mysvn -ge 4619 ] ; then 
[4919]828          svn co http://forge.ipsl.fr/ioserver/svn/XIOS2/branches/xios-2.6 \
[4405]829            XIOS
[4708]830        else
[4919]831          svn co http://forge.ipsl.fr/ioserver/svn/XIOS2/branches/xios-2.5 \
[4708]832            XIOS
833        fi
[4405]834        cd XIOS/arch
835        svn update
836        cd ..
837        echo "Compiling XIOS, start" `date` \
838             "(it takes about 20 min on Jean-Zay)"
839        echo "log file: $xioslog"
840        ./make_xios --prod --arch $arch --job 4 > xios.log 2>&1
[4215]841    else
[4405]842        ./install_xios.bash -prefix $MODEL/modipsl/modeles \
843                            -netcdf ${ncdfdir} -hdf5 ${ncdfdir} \
844                            -MPI $root_mpi -arch $arch > xios.log 2>&1
[4215]845    fi # of case Jean-Zay
846    if [ -f XIOS/lib/libxios.a ] ; then
[4405]847        echo "XIOS library successfully generated"
848        echo install_lmdz.sh XIOS_OK `date`
[4215]849    fi
[4210]850fi
851
852#============================================================================
853veget_version=false
854if [ "$veget" != 'NONE' ] ; then
[4215]855    cd $MODEL/modipsl/modeles/ORCHIDEE
856    set +e ; svn upgrade ; set -e
857    if [ "$veget" = "CMIP6" ] ; then
[4405]858        veget_version=orchidee2.0
859        orchidee_rev=6592
[4215]860    else # specific orchidee revision newer than CMIP6, on 2_1 or 2_2 branches
[4405]861        veget_version=orchidee2.1
862        orchidee_rev=$veget
863        if [ $veget -lt 4465 ] ; then
864            echo 'Stopping, ORCHIDEE version too old, script needs work on ' \
865                 'the CPP flags to pass to makelmdz'
866            exit 1
867        fi
868        set +e
869        # which branch is my version on?
[4919]870        orcbranch=`svn log -v -q svn://forge.ipsl.fr/orchidee/ -r $veget |grep ORCHIDEE |head -1| sed -e 's:ORCHIDEE/.*$:ORCHIDEE:' | awk '{print $2}'`
[4405]871        # switch to that branch
872        echo IF YOU INSTALL ORCHIDEE THE VERY FIRST TIME, ASK for PASSWORD at \
873             orchidee-help@listes.ipsl.fr
874        svn switch -r $veget --accept theirs-full \
[4919]875            svn://forge.ipsl.fr/orchidee/$orcbranch
[4405]876        svn log -r $veget | grep  $veget
877        if [  $? -gt 0 ] ; then
[4218]878            echo 'Cannot update ORCHIDEE as not on the right branch for ' \
[4405]879                 'ORCHIDEE'
[4215]880            exit
[4405]881        fi
882        set -e
883        set +e ; svn update -r $veget ; set -e
[4215]884    fi
885    # Correctif suite debug Jean-Zay
[4218]886    sed -i -e 's/9010  FORMAT(A52,F17.14)/9010  FORMAT(A52,F20.14)/' \
[4405]887        src_stomate/stomate.f90
[4215]888    opt_orc="-prod" ; if [ "$optim" = "-debug" ] ; then opt_orc="-debug" ; fi
[4210]889
[4215]890    orchideelog=`pwd`/orchidee.log
891    echo '########################################################'
892    echo 'Compiling ORCHIDEE, the continental surface model '
893    echo '########################################################'
894    echo Start of the first compilation of orchidee, in sequential mode: `date`
895    echo log file : $orchideelog
[4210]896
[4215]897    export ORCHPATH=`pwd`
898    xios_orchid="-noxios"
899    if [ "$with_xios" = "y" ] ; then
[4405]900        xios_orchid="-xios"
[4215]901    fi
902    if [ -d tools ] ; then
[4405]903        ###################################################################
904        # Pour les experts qui voudraient changer de version d'orchidee.
905        # Attention : necessite d'avoir le password pour orchidee
[4210]906
[4405]907        # Correctif suite debug Jean-Zay
908        if [ -f src_global/time.f90 ] ; then
909            sed -i -e 's/CALL tlen2itau/\!CALL tlen2itau/' src_global/time.f90
910        fi
911        ###################################################################
912        if [ "$veget_version" == "false" ] ; then
913            veget_version=orchidee2.0
914        fi
915        cd arch
916        sed -e s:"%COMPILER        .*.$":"%COMPILER            $compiler":1 \
917            -e s:"%LINK            .*.$":"%LINK                $compiler":1 \
918            -e s:"%FPP_FLAGS       .*.$":"%FPP_FLAGS           $fpp_flags":1 \
919            -e s:"%PROD_FFLAGS     .*.$":"%PROD_FFLAGS         $OPTIM":1 \
920            -e s:"%DEV_FFLAGS      .*.$":"%DEV_FFLAGS          $OPTDEV":1 \
921            -e s:"%DEBUG_FFLAGS    .*.$":"%DEBUG_FFLAGS        $OPTDEB":1 \
922            -e s:"%BASE_FFLAGS     .*.$":"%BASE_FFLAGS         $OPTPREC":1 \
923            -e s:"%BASE_LD         .*.$":"%BASE_LD             $BASE_LD":1 \
924            -e s:"%ARFLAGS         .*.$":"%ARFLAGS             $ARFLAGS":1 \
925            arch-gfortran.fcm > arch-local.fcm
926        echo "NETCDF_LIBDIR=\"-L${ncdfdir}/lib -lnetcdff -lnetcdf\"" \
927             > arch-local.path
928        echo "NETCDF_INCDIR=${ncdfdir}/include" >> arch-local.path
929        echo "IOIPSL_INCDIR=$ORCHPATH/../../lib" >> arch-local.path
930        echo "IOIPSL_LIBDIR=$ORCHPATH/../../lib" >> arch-local.path
931        echo 'XIOS_INCDIR=${ORCHDIR}/../XIOS/inc' >> arch-local.path
932        echo 'XIOS_LIBDIR="${ORCHDIR}/../XIOS/lib -lxios"' >> arch-local.path
933        cd ../
[4210]934
[4405]935        echo ./makeorchidee_fcm -j $xios_orchid $opt_orc -parallel none \
936             -arch $arch
937        ./makeorchidee_fcm -j 8 $xios_orchid $opt_orc -parallel none \
938                           -arch $arch > $orchideelog 2>&1
939        pwd
[4215]940    else # of "if [ -d tools ]"
[4405]941        if [ -d src_parallel ] ; then
942            liste_src="parallel parameters global stomate sechiba driver"
943            if [ "$veget_version" == "false" ] ; then
944                veget_version=orchidee2.0
945            fi
946        fi
947        for d in $liste_src ; do
948            src_d=src_$d
949            echo src_d $src_d
950            echo ls ; ls
951            if [ ! -d $src_d ] ; then
952                echo Problem orchidee : no $src_d ; exit
953            fi
954            cd $src_d ; \rm -f *.mod make ; $make clean
955            $make > $orchideelog 2>&1
956            if [ "$compiler" = "$gfortran" -o "$compiler" = "mpif90" ] ; then
957                cp -f *.mod ../../../lib
958            fi
959            cd ..
960        done
[4215]961    fi # of "if [ -d tools ]"
962    echo install_lmdz.sh orchidee_compil_seq_OK `date`
[4210]963fi # of if [ "$veget" != 'NONE' ]
964
965
966#============================================================================
967# Ehouarn: the directory name LMDZ* depends on version/tar file...
968if [ -d $MODEL/modipsl/modeles/LMD* ] ; then
[4215]969    echo '###############################################################'
970    echo 'Preparing LMDZ compilation : arch file, svn switch if needed...'
971    echo '###############################################################'
972    cd $MODEL/modipsl/modeles/LMD*
973    LMDZPATH=`pwd`
[4210]974else
[4215]975    echo "ERROR: No LMD* directory !!!"
976    exit
[4210]977fi
978
979###########################################################
980# For those who want to use fcm to compile via :
981#  makelmdz_fcm -arch local .....
982############################################################
983
984
985
986cd $MODEL/modipsl/modeles/LMDZ*
987lmdzlog=`pwd`/lmdz.log
988
989##################################################################
990# Possibly update LMDZ if a specific svn release is requested
991##################################################################
992
993set +e ; svn upgrade ; set -e
994
995if [ "$svn" = "last" ] ; then svnopt="" ; else svnopt="-r $svn" ; fi
996if [ "$svn" != "" ] ; then
[4634]997    set +e ; svn info | grep -q 'https:'
[4210]998    if [ $? = 0 ] ; then
[4634]999        svn switch --relocate https://svn.lmd.jussieu.fr/LMDZ \
1000            http://svn.lmd.jussieu.fr/LMDZ
[4210]1001    fi
1002    svn update $svnopt
[4372]1003    set -e
[4210]1004fi
1005
[4372]1006#---------------------------------------------------------------------
[4218]1007# Retrieve the final svn release number, and adjust compilation
1008# options accordingly
[4372]1009# If svn not available, will use the svn writen in $MODEL/Readm*md
1010# For old version it assumes that it is before 4185 (the version
1011# for which the test was introduced
1012#---------------------------------------------------------------------
[4210]1013
[4372]1014set +e ; mysvn=`svnversion . | egrep -o "[0-9]+" 2>/dev/null` ; set -e
1015if [ "$mysvn" = "" ] ; then mysvn=`grep 'Revision: [0-9]' $MODEL/Read*.md | awk ' { print $2 } ' 2>/dev/null` ; fi
1016if [ "$mysvn" = "" ] ; then mysvn=4190 ; fi
1017
[4427]1018if [[ "$pclinux" = "1" && ! -f arch/arch-local.path ]] ; then
1019
1020    # create local 'arch' files (if on Linux PC):
1021    cd arch
1022    # arch-local.path file
1023    # test for version as arch.pth file changed format with rev 4426
1024    if [ "$mysvn" -gt 4425 ] ; then
1025      echo "NETCDF_LIBDIR=\"-L${ncdfdir}/lib \"" > arch-local.path
1026      echo "NETCDF_LIB=\"-lnetcdff -lnetcdf\"" >> arch-local.path
1027      echo "NETCDF_INCDIR=-I${ncdfdir}/include" >> arch-local.path
1028      echo 'NETCDF95_INCDIR=-I$LMDGCM/../../include' >> arch-local.path
1029      echo 'NETCDF95_LIBDIR=-L$LMDGCM/../../lib' >> arch-local.path
1030      echo 'NETCDF95_LIB=-lnetcdf95' >> arch-local.path
1031      echo 'IOIPSL_INCDIR=-I$LMDGCM/../../lib' >> arch-local.path
1032      echo 'IOIPSL_LIBDIR=-L$LMDGCM/../../lib' >> arch-local.path
1033      echo 'IOIPSL_LIB=-lioipsl' >> arch-local.path
1034      echo 'XIOS_INCDIR=-I$LMDGCM/../XIOS/inc' >> arch-local.path
1035      echo 'XIOS_LIBDIR=-L$LMDGCM/../XIOS/lib' >> arch-local.path
1036      echo "XIOS_LIB=\"-lxios -lstdc++\"" >> arch-local.path
1037      echo 'ORCH_INCDIR=-I$LMDGCM/../../lib' >> arch-local.path
1038      echo 'ORCH_LIBDIR=-L$LMDGCM/../../lib' >> arch-local.path
1039    else
1040      echo "NETCDF_LIBDIR=\"-L${ncdfdir}/lib -lnetcdff -lnetcdf\"" \
1041         > arch-local.path
1042      echo "NETCDF_INCDIR=-I${ncdfdir}/include" >> arch-local.path
1043      echo 'NETCDF95_INCDIR=$LMDGCM/../../include' >> arch-local.path
1044      echo 'NETCDF95_LIBDIR=$LMDGCM/../../lib' >> arch-local.path
1045      echo 'IOIPSL_INCDIR=$LMDGCM/../../lib' >> arch-local.path
1046      echo 'IOIPSL_LIBDIR=$LMDGCM/../../lib' >> arch-local.path
1047      echo 'XIOS_INCDIR=$LMDGCM/../XIOS/inc' >> arch-local.path
1048      echo 'XIOS_LIBDIR=$LMDGCM/../XIOS/lib' >> arch-local.path
1049      echo 'ORCH_INCDIR=$LMDGCM/../../lib' >> arch-local.path
1050      echo 'ORCH_LIBDIR=$LMDGCM/../../lib' >> arch-local.path
1051    fi 
1052
1053    if [ $pcmac == 1 ] ; then
1054        BASE_LD="$BASE_LD -Wl,-rpath,${ncdfdir}/lib"
1055    else
1056        BASE_LD="$BASE_LD -Wl,-rpath=${ncdfdir}/lib"
1057    fi
1058    # Arch-local.fcm file (adapted from arch-linux-32bit.fcm)
1059
1060    if [ $real = r8 ] ; then FPP_DEF=NC_DOUBLE ; else FPP_DEF="" ; fi
1061    sed -e s:"%COMPILER        .*.$":"%COMPILER            $compiler":1 \
1062        -e s:"%LINK            .*.$":"%LINK                $compiler":1 \
1063        -e s:"%PROD_FFLAGS     .*.$":"%PROD_FFLAGS         $OPTIM":1 \
1064        -e s:"%DEV_FFLAGS      .*.$":"%DEV_FFLAGS          $OPTDEV":1 \
1065        -e s:"%DEBUG_FFLAGS    .*.$":"%DEBUG_FFLAGS        $OPTDEB":1 \
1066        -e s:"%BASE_FFLAGS     .*.$":"%BASE_FFLAGS         $OPTPREC":1 \
1067        -e s:"%FPP_DEF         .*.$":"%FPP_DEF             $FPP_DEF":1 \
1068        -e s:"%BASE_LD         .*.$":"%BASE_LD             $BASE_LD":1 \
1069        -e s:"%ARFLAGS         .*.$":"%ARFLAGS             $ARFLAGS":1 \
1070        arch-linux-32bit.fcm > arch-local.fcm
1071
1072    cd ..
1073    ### Adapt "bld.cfg" (add the shell):
1074    #whereisthatshell=$(which ${use_shell})
1075    #echo "bld::tool::SHELL   $whereisthatshell" >> bld.cfg
1076
1077fi # of if [ "$pclinux" = 1 ]
[4372]1078#---------------------------------------------------------------------
[4210]1079# Option de compilation du rayonnement : depend de $mysvn ><= r4185
[4372]1080#---------------------------------------------------------------------
[4210]1081opt_rad=""
1082
1083case $rad in
1084    oldrad) iflag_rrtm=0 ; NSW=2 ; opt_rad="" ;;
[4218]1085    rrtm)   iflag_rrtm=1 ; NSW=6
[4405]1086            if [ $mysvn -le 4185 ] ; then
1087                opt_rad="-rrtm true"
1088            else
1089                opt_rad="-rad rrtm"
1090            fi ;;
[4210]1091    ecrad)  iflag_rrtm=2 ; NSW=6 ; opt_rad="-rad ecrad" ;;
1092    *) echo Only oldrad rrtm ecrad for rad option ; exit
1093esac
1094
[4218]1095if [ $mysvn -le 4185 -a $rad = "ecrad" ] ; then
1096    echo "ecrad only available for LMDZ rev starting with 4186 " ; exit
1097fi
[4210]1098
1099##################################################################
1100
[4213]1101
[4577]1102if [[ ! -f libf/misc/netcdf95.F90 &&  ! -d $MODEL/NetCDF95-0.3 ]]
[4213]1103then
1104    cd $MODEL
[4577]1105    myget src_archives/netcdf/NetCDF95-0.3.tar.gz
1106    tar -xf NetCDF95-0.3.tar.gz
1107    rm NetCDF95-0.3.tar.gz
1108    cd NetCDF95-0.3
[4213]1109    mkdir build
1110    cd build
1111    cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=$ncdfdir \
[4405]1112          -DCMAKE_INSTALL_PREFIX=$MODEL/modipsl
[4213]1113    make install
1114    cd $MODEL/modipsl/modeles/LMDZ*
1115fi
1116
[4210]1117echo '##################################################################'
1118echo "Preparing script compile.sh for LMDZ compilation"
1119echo "It will only be run automatically if bench=1/tuto"
1120echo Here bench=$bench
1121echo '##################################################################'
1122
[4218]1123if [ "$env_file" != "" ] ; then
1124    mv arch/arch-${arch}.env arch/arch-${arch}.orig
1125    \cp -f $env_file arch/arch-${arch}.env
1126fi
[4210]1127
[4218]1128if [ $compile_with_fcm = 1 ] ; then
1129    makelmdz="makelmdz_fcm $optim -arch $arch -j 8 "
1130else
1131    makelmdz="makelmdz $optim -arch $arch"
1132fi
[4210]1133
1134# sequential compilation
1135if [ "$sequential" = 1 ] ; then
[4215]1136    echo Sequential compilation command, saved in compile.sh:
[4218]1137    echo "./$makelmdz $optim $OPT_MAKELMDZ $optim $opt_rad $opt_cosp " \
[4405]1138         "-d ${grid_resolution} -v $veget_version gcm "
[4218]1139    echo "./$makelmdz $optim $OPT_MAKELMDZ $optim $opt_rad $opt_cosp " \
[4405]1140         "-d ${grid_resolution} -v $veget_version gcm " > compile.sh
[4215]1141    chmod +x ./compile.sh
1142    if [ $bench = 1 ] ; then
[4405]1143        echo install_lmdz.sh start_lmdz_seq_compilation `date`
1144        echo log file: $lmdzlog
1145        ./compile.sh > $lmdzlog 2>&1
1146        echo install_lmdz.sh end_lmdz_seq_compilation `date`
[4215]1147    fi
[4210]1148fi # fin sequential
1149
1150# compiling in parallel mode
1151if [ $parallel != "none" ] ; then
1152    echo '##########################################################'
[4215]1153    echo ' Parallel compile '
[4210]1154    echo '##########################################################'
[4215]1155    echo "(after saving the sequential libs and binaries)"
1156    cd $MODEL/modipsl
1157    tar cf sequential.tar bin/ lib/
1158    #
1159    # Orchidee
1160    #
1161    cd $ORCHPATH
1162    if [ -d src_parallel -a $veget != 'NONE' ] ; then
[4405]1163        cd arch
1164        sed  \
1165            -e s:"%COMPILER.*.$":"%COMPILER            $par_comp":1 \
1166            -e s:"%LINK.*.$":"%LINK                $par_comp":1 \
1167            -e s:"%MPI_FFLAG.*.$":"%MPI_FFLAGS          $MPI_FLAGS":1 \
1168            -e s:"%OMP_FFLAG.*.$":"%OMP_FFLAGS          $OMP_FLAGS":1 \
1169            -e s:"%MPI_LD.*.$":"%MPI_LD              $MPI_LD":1 \
1170            -e s:"%OMP_LD.*.$":"%OMP_LD              $OMP_LD":1 \
1171            arch-local.fcm > tmp.fcm
[4210]1172
[4405]1173        mv tmp.fcm arch-local.fcm
1174        cd ../
1175        echo Compiling ORCHIDEE in parallel mode `date`
1176        echo logfile $orchideelog
1177        echo "NOTE : to recompile it when necessary, use ./compile_orc.sh " \
1178             "in modipsl/modeles/ORCHIDEE"
1179        echo ./makeorchidee_fcm -j 8 -clean $xios_orchid $opt_orc \
1180             -parallel $parallel -arch $arch > compile_orc.sh
1181        echo ./makeorchidee_fcm -j 8 $xios_orchid $opt_orc \
1182             -parallel $parallel -arch $arch >> compile_orc.sh
1183        echo echo Now you must also recompile LMDZ, by running ./compile.sh \
1184             in modeles/LMDZ >> compile_orc.sh
1185        chmod u+x compile_orc.sh
1186        ./makeorchidee_fcm -j 8 -clean $xios_orchid $opt_orc \
1187                           -parallel $parallel -arch $arch > $orchideelog 2>&1
1188        ./makeorchidee_fcm -j 8 $xios_orchid $opt_orc -parallel $parallel \
1189                           -arch $arch >> $orchideelog 2>&1
1190        echo End of ORCHIDEE compilation in parallel mode `date`
[4215]1191    elif [ $veget != 'NONE' ] ; then
[4405]1192        echo '##########################################################'
1193        echo ' Orchidee version too old                                 '
1194        echo ' Please update to new version                             '
1195        echo '##########################################################'
1196        exit
[4215]1197    fi # of [ -d src_parallel -a $veget != 'NONE' ]
[4210]1198
[4215]1199    # LMDZ
1200    cd $LMDZPATH
1201    if [ $arch = local ] ; then
[4405]1202        cd arch
1203        sed -e s:"%COMPILER.*.$":"%COMPILER            $par_comp":1 \
1204            -e s:"%LINK.*.$":"%LINK                $par_comp":1 \
1205            -e s:"%MPI_FFLAG.*.$":"%MPI_FFLAGS          $MPI_FLAGS":1 \
1206            -e s:"%OMP_FFLAG.*.$":"%OMP_FFLAGS          $OMP_FLAGS":1 \
1207            -e s:"%ARFLAGS.*.$":"%ARFLAGS          $ARFLAGS":1 \
1208            -e s@"%BASE_LD.*.$"@"%BASE_LD             -Wl,-rpath=${root_mpi}/lib:${ncdfdir}/lib"@1 \
1209            -e s:"%MPI_LD.*.$":"%MPI_LD              $MPI_LD":1 \
1210            -e s:"%OMP_LD.*.$":"%OMP_LD              $OMP_LD":1 \
1211            arch-local.fcm > tmp.fcm
1212        mv tmp.fcm arch-local.fcm
1213        cd ../
[4215]1214    fi
1215    rm -f compile.sh
1216    echo resol=${grid_resolution} >> compile.sh
1217    if [ ${hostname:0:5} = jean- -a "$cosp" = "v2" ] ; then
[4210]1218
[4405]1219        echo LMDZ compilation command in parallel mode, saved in compile.sh, \
1220             is :
1221        echo "(ATTENTION le probleme de cospv2 sur jean-zay en mode prod " \
1222             "n est pas corrige ! )"
1223        # ATTENTION le probleme de cospv2 sur jean-zay en mode prod n
1224        # est pas corrige
1225        echo ./$makelmdz -dev $optim $OPT_MAKELMDZ $opt_rad $opt_cosp \
1226             $opt_makelmdz_xios -d \$resol -v $veget_version -mem \
1227             -parallel $parallel gcm >> compile.sh
1228        echo ./$makelmdz -dev $optim $OPT_MAKELMDZ $opt_rad $opt_cosp \
1229             $opt_makelmdz_xios -d \$resol -v $veget_version -mem \
1230             -parallel $parallel gcm
[4215]1231    else
[4405]1232        echo ./$makelmdz $optim $OPT_MAKELMDZ $opt_rad $opt_cosp \
1233             $opt_makelmdz_xios -d \$resol -v $veget_version -mem \
1234             -parallel $parallel gcm >> compile.sh
1235        echo ./$makelmdz $optim $OPT_MAKELMDZ $opt_rad $opt_cosp \
1236             $opt_makelmdz_xios -d \$resol -v $veget_version -mem \
1237             -parallel $parallel gcm
[4215]1238    fi
1239    chmod +x ./compile.sh
[4210]1240
[4215]1241    if [ $bench = 1 ] ; then
[4405]1242        echo Compiling LMDZ in parallel mode `date`,  LMDZ log file: $lmdzlog
1243        ./compile.sh > $lmdzlog 2>&1
[4215]1244    fi
1245
[4210]1246fi # of if [ $parallel != "none" ]
1247
1248
1249##################################################################
1250# Verification du succes de la compilation
1251##################################################################
1252
1253# Recherche de l'executable dont le nom a change au fil du temps ...
1254# suffix contains radiative option starting with revision 4186
1255if [ $mysvn -ge 4186 ] ; then suff_exe=_${rad}${suff_exe} ; fi
1256gcm=""
[4219]1257
[4218]1258for exe in gcm.e bin/gcm_${grid_resolution}_phylmd${suff_exe}${suff_orc}.e
1259do
1260    if [ -f $exe ] ; then gcm=$exe ; fi
[4210]1261done
1262
1263if [ "$gcm" = "" ] ; then
[4215]1264    if [ $bench = 1 ] ; then
[4405]1265        echo 'Compilation failed !! Cannot run the benchmark;'
1266        exit
[4215]1267    else
[4405]1268        echo 'Compilation not done (only done when bench=1)'
[4215]1269    fi
[4210]1270else
[4215]1271    echo '##########################################################'
1272    echo 'Compilation successfull !! ' `date`
1273    echo '##########################################################'
1274    echo The executable is $gcm
[4210]1275fi
1276
1277##################################################################
1278# Below, we run a benchmark if bench=1 or tuto
1279##################################################################
1280
1281if [ $bench = tuto ] ; then
[4286]1282    myget Training/tutorial.tar ; tar xf tutorial.tar ; cd TUTORIAL
[4218]1283    ./init.sh
[4210]1284
1285elif [[ $bench = 1 && ! -d BENCH${grid_resolution} ]] ; then
[4215]1286    # TOUTE CETTE SECTION DEVRAIT DISPARAITRE POUR UNE COMMANDE
1287    # OU DES BENCHS PAR MOTS CLES COMME tuto
[4210]1288
[4215]1289    echo '##########################################################'
1290    echo ' Running a test run '
1291    echo '##########################################################'
[4210]1292
[4215]1293    \rm -rf BENCH${grid_resolution}
1294    bench=bench_lmdz_${grid_resolution}
1295    echo install_lmdz.sh before bench download  `date`
1296    #wget http://www.lmd.jussieu.fr/~lmdz/Distrib/$bench.tar.gz
1297    myget 3DBenchs/$bench.tar.gz
1298    echo install_lmdz.sh after bench download  `date`
[4286]1299    tar xf $bench.tar.gz
[4210]1300
[4215]1301    if [ "$cosp" = "v1" -o "$cosp" = "v2" ] ; then
[4405]1302        cd BENCH${grid_resolution}
1303        # copier les fichiers namelist input et output our COSP
1304        cp ../DefLists/cosp*_input_nl.txt .
1305        cp ../DefLists/cosp*_output_nl.txt .
1306        # Activer la cles ok_cosp pour tourner avec COSP
1307        sed -e 's@ok_cosp=n@ok_cosp=y@' config.def > tmp
1308        \mv -f tmp config.def
1309        cd ..
[4215]1310    fi
[4210]1311
[4215]1312    if [ -n "$physiq" ]; then
[4405]1313        cd BENCH${grid_resolution}
1314        if [ -f physiq.def_${physiq} ]; then
1315            cp physiq.def_${physiq} physiq.def
1316            echo using physiq.def_${physiq}
1317        else
1318            echo using standard physiq.def
1319        fi
1320        cd ..
[4215]1321    else
[4405]1322        echo using standard physiq.def
[4215]1323    fi
[4210]1324
[4215]1325    if [ "$with_xios" = "y" ] ; then
[4405]1326        cd BENCH${grid_resolution}
1327        cp ../DefLists/iodef.xml .
1328        cp ../DefLists/context_lmdz.xml .
1329        cp ../DefLists/field_def_lmdz.xml .
1330        # A raffiner par la suite
1331        echo A FAIRE : Copier les *xml en fonction de l option cosp
1332        cp ../DefLists/field_def_cosp*.xml .
1333        cp ../DefLists/file_def_hist*xml .
1334        # adapt iodef.xml to use attached mode
1335        sed -e 's@"using_server" type="bool">true@"using_server" type="bool">false@' \
1336            iodef.xml > tmp
1337        \mv -f tmp iodef.xml
[4210]1338
[4405]1339        # and convert all the enabled="_AUTO_" (for libIGCM) to enabled=.FALSE.
1340        # except for histday
1341        for histfile in file_def_hist*xml
1342        do
1343            if [ "$histfile" = "file_def_histday_lmdz.xml" ] ; then
1344                sed -e 's@enabled="_AUTO_"@type="one_file" enabled=".TRUE."@' \
1345                    $histfile > tmp
1346                \mv -f tmp $histfile
1347                sed -e 's@output_level="_AUTO_"@output_level="5"@' $histfile \
1348                    > tmp
1349                \mv -f tmp $histfile
1350                sed -e 's@compression_level="2"@compression_level="0"@' \
1351                    $histfile > tmp
1352                \mv -f tmp $histfile
1353            else
1354                sed -e 's@enabled="_AUTO_"@type="one_file" enabled=".FALSE."@' \
1355                    $histfile > tmp
1356                \mv -f tmp $histfile
1357            fi
1358        done
1359        # and add option "ok_all_xml=y" in config.def
1360        echo "### XIOS outputs" >> config.def
1361        echo 'ok_all_xml=.true.' >> config.def
[4210]1362
[4405]1363        #activer les sorties pour Cosp
1364        if [ "$cosp" = "v1" ] ; then
[4807]1365            sed -i'' -e 's@enabled=".FALSE."@enabled=".TRUE."@' \
1366                     -e 's@output_level="_AUTO_"@output_level="5"@' \
1367                     -e 's@compression_level="2"@compression_level="0"@' \
1368                     file_def_histdayCOSP_lmdz.xml
[4405]1369        fi
1370        if [ "$cosp" = "v2" ] ; then
[4807]1371            sed -e 's@compression_level="2"@compression_level="0"@' file_def_histdayCOSPv2_lmdz.xml
1372            for type_ in hf day mth ; do
1373                file=file_def_hist${type_}COSP
1374                sed -i'' -e 's@src="./'${file}'_lmdz.xml"@src="./'${file}'v2_lmdz.xml"@' context_lmdz.xml
1375            done
1376            sed -i '' -e 's@field_def_cosp1.xml@field_def_cospv2.xml@' field_def_lmdz.xml
[4405]1377        fi
[4210]1378
[4405]1379        cd ..
[4215]1380    fi
[4210]1381
[4215]1382    # Cas Bensh avec ecrad
1383    if [ "$rad" = "ecrad" ] ; then
[4405]1384        cd BENCH${grid_resolution}
1385        cp  ../DefLists/namelist_ecrad .
1386        cp -r ../libf/phylmd/ecrad/data .
1387        cd ..
[4215]1388    fi
[4210]1389
[4215]1390    # Adjusting bench physiq.def to radiative code chosen
1391    cd BENCH${grid_resolution}
[4218]1392    sed -e 's/iflag_rrtm=.*.$/iflag_rrtm='$iflag_rrtm'/' \
[4405]1393        -e 's/NSW=.*.$/NSW='$NSW'/' physiq.def > tmpdef
[4215]1394    \mv tmpdef physiq.def
1395    cd ..
[4210]1396
[4215]1397    cp $gcm BENCH${grid_resolution}/gcm.e
[4210]1398
[4215]1399    cd BENCH${grid_resolution}
1400    # On cree le fichier bench.sh au besoin
1401    # Dans le cas 48x36x39 le bench.sh existe deja en parallele
[4210]1402
[4215]1403    if [ "$grid_resolution" = "48x36x39" ] ; then
[4405]1404        echo On ne touche pas au bench.sh
1405        # But we have to adapt "run_local.sh" for $mpirun
1406        sed -e "s@mpirun@$mpirun@g" run_local.sh > tmp
1407        mv -f tmp run_local.sh
1408        chmod u=rwx run_local.sh
[4215]1409    elif [ "${parallel:0:3}" = "mpi" ] ; then
[4405]1410        # Lancement avec deux procs mpi et 2 openMP
1411        echo "export OMP_STACKSIZE=800M" > bench.sh
1412        if [ "${parallel:4:3}" = "omp" ] ; then
[4215]1413            echo "export OMP_NUM_THREADS=2" >> bench.sh
[4405]1414        fi
1415        if [ "$cosp" = "v1" -o "$cosp" = "v2" ] ; then
[4215]1416            if [ ${hostname:0:5} = jean- ] ; then
[4405]1417                   chmod +x ../arch.env
1418                ../arch.env       
1419                echo "ulimit -s 2000000" >> bench.sh
[4215]1420            else
[4405]1421                echo "ulimit -s 200000" >> bench.sh
1422            fi       
1423        else
[4215]1424            echo "ulimit -s unlimited" >> bench.sh
[4405]1425        fi
1426        if [ ${hostname:0:5} = jean- ] ; then
[4215]1427            . ../arch/arch-${arch}.env
[4218]1428            echo "srun -n 2 -A $idris_acct@cpu gcm.e > listing  2>&1" \
[4405]1429                 >> bench.sh
1430        else
[4215]1431            echo "$mpirun -np 2 gcm.e > listing  2>&1" >> bench.sh
[4405]1432        fi
1433        # Add rebuild, using reb.sh if it is there
1434        echo 'if [ -f reb.sh ] ; then' >> bench.sh
1435        echo '  ./reb.sh histday ; ./reb.sh histmth ; ./reb.sh histhf ; ' \
1436             './reb.sh histins ; ./reb.sh stomate_history ; ' \
1437             './reb.sh sechiba_history ; ./reb.sh sechiba_out_2 ' >> bench.sh
1438        echo 'fi' >> bench.sh
[4215]1439    else
[4405]1440        echo "./gcm.e > listing  2>&1" > bench.sh
[4215]1441    fi
1442    # Getting orchidee stuff
1443    if [ $veget == 'CMIP6' ] ; then
[4405]1444        #echo 'myget 3DBenchs/BENCHorch11.tar.gz'
1445        #myget 3DBenchs/BENCHorch11.tar.gz
1446        #tar xvzf BENCHorch11.tar.gz
1447        echo 'myget 3DBenchs/BENCHCMIP6.tar.gz'
1448        myget 3DBenchs/BENCHCMIP6.tar.gz
1449        tar xvzf BENCHCMIP6.tar.gz
1450        sed -e "s:VEGET=n:VEGET=y:" config.def > tmp
1451        mv -f tmp config.def
1452        if [ "$with_xios" = "y" ] ; then
[4215]1453            cp ../../ORCHIDEE/src_xml/context_orchidee.xml .
[4218]1454            echo '<context id="orchidee" src="./context_orchidee.xml"/>' \
[4405]1455                 > add.tmp
[4215]1456            cp ../../ORCHIDEE/src_xml/field_def_orchidee.xml .
1457            cp ../../ORCHIDEE/src_xml/file_def_orchidee.xml .
1458            cp ../../ORCHIDEE/src_xml/file_def_input_orchidee.xml .
1459            if [ -f ../../ORCHIDEE/src_xml/context_input_orchidee.xml ] ; then
[4405]1460                   cp ../../ORCHIDEE/src_xml/context_input_orchidee.xml .
1461                   echo '<context id="orchidee" ' \
1462                     'src="./context_input_orchidee.xml"/>' >> add.tmp
[4215]1463            fi
1464            sed -e '/id="LMDZ"/r add.tmp' iodef.xml > tmp
1465            mv tmp iodef.xml
[4218]1466            sed -e'{/sechiba1/ s/enabled="_AUTO_"/type="one_file" enabled=".TRUE."/}' \
[4405]1467                file_def_orchidee.xml > tmp
1468            \mv -f tmp file_def_orchidee.xml
[4218]1469            sed -e 's@enabled="_AUTO_"@type="one_file" enabled=".FALSE."@' \
[4405]1470                file_def_orchidee.xml > tmp
1471            \mv -f tmp file_def_orchidee.xml
[4218]1472            sed -e 's@output_level="_AUTO_"@output_level="1"@' \
[4405]1473                file_def_orchidee.xml > tmp
1474            \mv -f tmp file_def_orchidee.xml
[4218]1475            sed -e 's@output_freq="_AUTO_"@output_freq="1d"@' \
[4405]1476                file_def_orchidee.xml > tmp
1477            \mv -f tmp file_def_orchidee.xml
[4218]1478            sed -e 's@compression_level="4"@compression_level="0"@' \
[4405]1479                file_def_orchidee.xml > tmp
1480            \mv -f tmp file_def_orchidee.xml
[4218]1481            sed -e 's@XIOS_ORCHIDEE_OK = n@XIOS_ORCHIDEE_OK = y@' \
[4405]1482                orchidee.def > tmp
1483            \mv -f tmp orchidee.def
1484        fi
[4215]1485    fi
[4220]1486
1487    if [[ -f ../arch.env ]]
1488    then
[4405]1489        source ../arch.env
[4220]1490    fi
1491
[4215]1492    echo EXECUTION DU BENCH
1493    set +e
1494    date ; ./bench.sh > out.bench 2>&1 ; date
1495    set -e
1496    tail listing
[4210]1497
1498
[4215]1499    echo '##########################################################'
1500    echo 'Simulation finished in' `pwd`
1501    echo 'You have compiled with:'
1502    cat ../compile.sh
1503    if [ $parallel = "none" ] ; then
[4405]1504        echo 'You may re-run it with : cd ' `pwd` ' ; gcm.e'
1505        echo 'or ./bench.sh'
[4215]1506    else
[4405]1507        echo 'You may re-run it with : '
1508        echo 'cd ' `pwd` '; ./bench.sh'
1509        #  echo 'ulimit -s unlimited'
1510        #  echo 'export OMP_NUM_THREADS=2'
1511        #  echo 'export OMP_STACKSIZE=800M'
1512        #  echo "$mpirun -np 2 gcm.e "
[4215]1513    fi
1514    echo '##########################################################'
[4210]1515
1516fi # bench
1517
1518
1519#################################################################
1520# Installation eventuelle du 1D
1521#################################################################
1522
1523if [ $SCM = 1 ] ; then
[4215]1524    cd $MODEL
1525    myget 1D/1D.tar.gz
[4286]1526    tar xf 1D.tar.gz
[4215]1527    cd 1D
[4422]1528    if [ $rad = oldrad ] ; then
1529        sed -i'' -e 's/^rad=.*$/rad=oldrad/' run.sh
1530        sed -i'' -e 's/^rad=.*$/rad=oldrad/' bin/compile
1531    fi
[4877]1532    if [ $rad = ecrad ] ; then
1533        sed -i'' -e 's/^rad=.*$/rad=ecrad/' run.sh
1534        sed -i'' -e 's/^rad=.*$/rad=ecrad/' bin/compile
1535    fi
[4409]1536    echo Running 1D/run.sh, log in `pwd`/run1d.log
[4457]1537    ./run.sh > `pwd`/run1d.log 2>&1
[4210]1538fi
1539
[4409]1540
[4210]1541#################################################################
1542# sauvegarde des options veget pour utilisation eventuelle tutorial_prod
1543#################################################################
1544cd $MODEL/modipsl/modeles
1545#echo surface_env file created in $MODEL
1546echo 'veget='$veget > surface_env
1547#opt_veget="-v $veget_version"
1548#echo 'opt_veget="'$opt_veget\" >> surface_env
1549echo 'opt_veget="'-v $veget_version\" >> surface_env
1550echo 'orchidee_rev='$orchidee_rev >> surface_env
1551echo 'suforch='$suff_orc >> surface_env
Note: See TracBrowser for help on using the repository browser.