source: BOL/script_install/install_lmdz.sh @ 3972

Last change on this file since 3972 was 3972, checked in by Laurent Fairhead, 3 years ago

Choosing wich orchidee version to run with a revision number (careful checks on the interface might be required)

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