source: BOL/script_install/install_lmdz_new.sh @ 4212

Last change on this file since 4212 was 4212, checked in by lguez, 2 years ago

Install more recent NetCDF libraries

Install NetCDF C library 4.3.3.1 and NetCDF Fortran library
4.4.2. Mainly we want a NetCDF configuration able to handle the
NetCDF4 format, with groups. The downside is that the compilation time
is longer. We could just configure NetCDF 4.0.1 with option
-enable-netcdf4 but compilation would also be longer, so while we are
at it, we use more recent versions of NetCDF.

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