source: BOL/script_install/install_lmdz.sh @ 3944

Last change on this file since 3944 was 3944, checked in by idelkadi, 3 years ago

Changing the svn version used by default in install_lmdz.sh (default use of a newer svn version)

File size: 44.3 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
785     set +e
786     svn log -r $veget | grep  $veget
787     if [  $? -gt 0 ] ; then
788          echo 'Cannot update ORCHIDEE as not on the right branch for ORCHIDEE'
789          exit
790      fi
791      set -e
792      set +e ; svn update -r $veget ; set -e 
793  fi
794  # Correctif suite debug Jean-Zay
795  sed -i -e 's/9010  FORMAT(A52,F17.14)/9010  FORMAT(A52,F20.14)/' src_stomate/stomate.f90
796  opt_orc="-prod" ; if [ "$optim" = "-debug" ] ; then opt_orc="-debug" ; fi
797
798  orchideelog=`pwd`/orchidee.log
799  echo '########################################################'
800  echo 'Compiling ORCHIDEE, the continental surfaces model '
801  echo '########################################################'
802  echo log file : $orchideelog
803  export ORCHPATH=`pwd`
804  if [ -d tools ] ; then
805###################################################################
806# Pour les experts qui voudraient changer de version d'orchidee.
807# Attention : necessite d'avoir le password pour orchidee
808
809      # Correctif suite debug Jean-Zay
810      if [ -f src_global/time.f90 ] ; then sed -i -e 's/CALL tlen2itau/\!CALL tlen2itau/' src_global/time.f90 ; fi
811###################################################################
812     if [ "$veget_version" == "false" ] ; then veget_version=orchidee2.0 ; fi
813      cd arch
814      sed -e s:"%COMPILER        .*.$":"%COMPILER            $compiler":1 \
815     -e s:"%LINK            .*.$":"%LINK                $compiler":1 \
816     -e s:"%FPP_FLAGS       .*.$":"%FPP_FLAGS           $fpp_flags":1 \
817     -e s:"%PROD_FFLAGS     .*.$":"%PROD_FFLAGS         $OPTIM":1 \
818     -e s:"%DEV_FFLAGS      .*.$":"%DEV_FFLAGS          $OPTDEV":1 \
819     -e s:"%DEBUG_FFLAGS    .*.$":"%DEBUG_FFLAGS        $OPTDEB":1 \
820     -e s:"%BASE_FFLAGS     .*.$":"%BASE_FFLAGS         $OPTPREC":1 \
821     -e s:"%BASE_LD         .*.$":"%BASE_LD             $BASE_LD":1 \
822     -e s:"%ARFLAGS         .*.$":"%ARFLAGS             $ARFLAGS":1 \
823     arch-gfortran.fcm > arch-local.fcm
824     echo "NETCDF_LIBDIR=\"-L${ncdfdir}/lib -lnetcdff -lnetcdf\"" > arch-local.path
825     echo "NETCDF_INCDIR=${ncdfdir}/include" >> arch-local.path
826     echo "IOIPSL_INCDIR=$ORCHPATH/../../lib" >> arch-local.path
827     echo "IOIPSL_LIBDIR=$ORCHPATH/../../lib" >> arch-local.path
828     echo 'XIOS_INCDIR=${ORCHDIR}/../XIOS/inc' >> arch-local.path
829     echo 'XIOS_LIBDIR="${ORCHDIR}/../XIOS/lib -lxios"' >> arch-local.path
830     cd ../
831# compiling ORCHIDEE sequential mode
832     ./makeorchidee_fcm -j 8 -noxios $opt_orc -parallel none -arch $arch > $orchideelog 2>&1
833     echo ./makeorchidee_fcm -j 8 -noxios $opt_orc -parallel none -arch $arch
834     echo End of the first compilation of orchidee ; pwd
835  else
836     if [ -d src_parallel ] ; then
837       liste_src="parallel parameters global stomate sechiba driver"
838       if [ "$veget_version" == "false" ] ; then veget_version=orchidee2.0 ; fi
839     fi
840     for d in $liste_src ; do src_d=src_$d
841        echo src_d $src_d
842        echo ls ; ls
843        if [ ! -d $src_d ] ; then echo Problem orchidee : no $src_d ; exit ; fi
844        cd $src_d ; \rm -f *.mod make ; $make clean
845        $make > $orchideelog 2>&1 ; if [ "$compiler" = "$gfortran" -o "$compiler" = "mpif90" ] ; then cp -f *.mod ../../../lib ; fi
846        cd ..
847     done
848  fi
849  echo install.sh orchidee_OK `date`
850fi # of if [ "$veget" = 1 ]
851
852
853#============================================================================
854# Ehouarn: the directory name LMDZ* depends on version/tar file...
855if [ -d $MODEL/modipsl/modeles/LMD* ] ; then
856  echo '##########################################################'
857  echo 'Compiling LMDZ'
858  echo '##########################################################'
859  cd $MODEL/modipsl/modeles/LMD*
860  LMDZPATH=`pwd`
861else
862  echo "ERROR: No LMD* directory !!!"
863  exit
864fi
865
866###########################################################
867# For those who want to use fcm to compile via :
868#  makelmdz_fcm -arch local .....
869############################################################
870
871if [ "$pclinux" = "1" ] ; then
872
873# create local 'arch' files (if on Linux PC):
874cd arch
875# arch-local.path file
876echo "NETCDF_LIBDIR=\"-L${ncdfdir}/lib -lnetcdff -lnetcdf\"" > arch-local.path
877echo "NETCDF_INCDIR=-I${ncdfdir}/include" >> arch-local.path
878echo 'IOIPSL_INCDIR=$LMDGCM/../../lib' >> arch-local.path
879echo 'IOIPSL_LIBDIR=$LMDGCM/../../lib' >> arch-local.path
880echo 'XIOS_INCDIR=$LMDGCM/../XIOS/inc' >> arch-local.path
881echo 'XIOS_LIBDIR=$LMDGCM/../XIOS/lib' >> arch-local.path
882echo 'ORCH_INCDIR=$LMDGCM/../../lib' >> arch-local.path
883echo 'ORCH_LIBDIR=$LMDGCM/../../lib' >> arch-local.path
884
885if [ $pcmac == 1 ] ; then
886    BASE_LD="$BASE_LD -Wl,-rpath,${ncdfdir}/lib"
887else
888    BASE_LD="$BASE_LD -Wl,-rpath=${ncdfdir}/lib"
889fi
890# Arch-local.fcm file (adapted from arch-linux-32bit.fcm)
891
892if [ $real = r8 ] ; then FPP_DEF=NC_DOUBLE ; else FPP_DEF="" ; fi
893sed -e s:"%COMPILER        .*.$":"%COMPILER            $compiler":1 \
894    -e s:"%LINK            .*.$":"%LINK                $compiler":1 \
895    -e s:"%PROD_FFLAGS     .*.$":"%PROD_FFLAGS         $OPTIM":1 \
896    -e s:"%DEV_FFLAGS      .*.$":"%DEV_FFLAGS          $OPTDEV":1 \
897    -e s:"%DEBUG_FFLAGS    .*.$":"%DEBUG_FFLAGS        $OPTDEB":1 \
898    -e s:"%BASE_FFLAGS     .*.$":"%BASE_FFLAGS         $OPTPREC":1 \
899    -e s:"%FPP_DEF         .*.$":"%FPP_DEF             $FPP_DEF":1 \
900    -e s:"%BASE_LD         .*.$":"%BASE_LD             $BASE_LD":1 \
901    -e s:"%ARFLAGS         .*.$":"%ARFLAGS             $ARFLAGS":1 \
902    arch-linux-32bit.fcm > arch-local.fcm
903
904cd ..
905### Adapt "bld.cfg" (add the shell):
906whereisthatshell=$(which ${use_shell})
907echo "bld::tool::SHELL   $whereisthatshell" >> bld.cfg
908
909fi # of if [ "$pclinux" = 1 ]
910
911
912cd $MODEL/modipsl/modeles/LMDZ*
913lmdzlog=`pwd`/lmdz.log
914
915##################################################################
916# Possibly update LMDZ if a specific svn release is requested
917##################################################################
918
919
920set +e ; svn upgrade ; set -e
921if [ "$svn" = "last" ] ; then svnopt="" ; else svnopt="-r $svn" ; fi
922if [ "$svn" != "" ] ; then
923    svn info | grep -q 'http:'
924    if [ $? = 0 ] ; then
925        svn switch --relocate http://svn.lmd.jussieu.fr/LMDZ https://svn.lmd.jussieu.fr/LMDZ
926    fi
927    svn update $svnopt
928fi
929set -e
930
931echo '##################################################################'
932echo Compile LMDZ
933echo '##################################################################'
934echo log file : $lmdzlog
935
936if [ "$env_file" != "" ] ; then mv arch/arch-${arch}.env arch/arch-${arch}.orig ; \cp -f $env_file arch/arch-${arch}.env ; fi
937
938echo install.sh avant_compilation `date`
939if [ $compile_with_fcm = 1 ] ; then makelmdz="makelmdz_fcm $optim -arch $arch -j 8 " ; else makelmdz="makelmdz $optim -arch $arch" ; fi
940
941# sequential compilation and bench
942if [ "$sequential" = 1 ] ; then
943echo "./$makelmdz $optim $OPT_MAKELMDZ $optim $opt_rad $opt_cosp -d ${grid_resolution} -v $veget_version gcm " >> compile.sh
944chmod +x ./compile.sh
945if [ $bench != 0 ] ; then ./compile.sh > $lmdzlog 2>&1 ; fi
946echo install.sh apres_compilation `date`
947
948
949fi # fin sequential
950
951
952
953# compiling in parallel mode
954if [ $parallel != "none" ] ; then
955  echo '##########################################################'
956  echo ' Parallel compile '
957  echo '##########################################################'
958  # saving the sequential libs and binaries
959  cd $MODEL/modipsl
960  tar cf sequential.tar bin/ lib/
961  \rm -rf bin/ lib/
962  tar xf ioipsl.tar
963  #
964  # Orchidee
965  #
966  cd $ORCHPATH
967  if [ -d src_parallel -a $veget != 'NONE' ] ; then
968     cd arch
969     sed  \
970     -e s:"%COMPILER.*.$":"%COMPILER            $par_comp":1 \
971     -e s:"%LINK.*.$":"%LINK                $par_comp":1 \
972     -e s:"%MPI_FFLAG.*.$":"%MPI_FFLAGS          $MPI_FLAGS":1 \
973     -e s:"%OMP_FFLAG.*.$":"%OMP_FFLAGS          $OMP_FLAGS":1 \
974     -e s:"%MPI_LD.*.$":"%MPI_LD              $MPI_LD":1 \
975     -e s:"%OMP_LD.*.$":"%OMP_LD              $OMP_LD":1 \
976     arch-local.fcm > tmp.fcm
977
978     mv tmp.fcm arch-local.fcm
979     cd ../
980     echo compiling ORCHIDEE parallel mode
981     echo logfile $orchideelog
982     ./makeorchidee_fcm -j 8 -clean -noxios $opt_orc -parallel $parallel -arch $arch > $orchideelog 2>&1
983     ./makeorchidee_fcm -j 8 -noxios $opt_orc -parallel $parallel -arch $arch >> $orchideelog 2>&1
984     echo ./makeorchidee_fcm -j 8 -clean -noxios $opt_orc -parallel $parallel -arch $arch
985     echo ./makeorchidee_fcm -j 8 -noxios $opt_orc -parallel $parallel -arch $arch
986  elif [ $veget != 'NONE' ] ; then
987    echo '##########################################################'
988    echo ' Orchidee version too old                                 '
989    echo ' Please update to new version                             '
990    echo '##########################################################'
991    exit
992  fi # of if [ -d src_parallel ]
993  # LMDZ
994  cd $LMDZPATH
995  if [ $arch = local ] ; then
996    cd arch
997    sed -e s:"%COMPILER.*.$":"%COMPILER            $par_comp":1 \
998    -e s:"%LINK.*.$":"%LINK                $par_comp":1 \
999    -e s:"%MPI_FFLAG.*.$":"%MPI_FFLAGS          $MPI_FLAGS":1 \
1000    -e s:"%OMP_FFLAG.*.$":"%OMP_FFLAGS          $OMP_FLAGS":1 \
1001    -e s:"%ARFLAGS.*.$":"%ARFLAGS          $ARFLAGS":1 \
1002    -e s@"%BASE_LD.*.$"@"%BASE_LD             -Wl,-rpath=${root_mpi}/lib:${ncdfdir}/lib"@1 \
1003    -e s:"%MPI_LD.*.$":"%MPI_LD              $MPI_LD":1 \
1004    -e s:"%OMP_LD.*.$":"%OMP_LD              $OMP_LD":1 \
1005    arch-local.fcm > tmp.fcm
1006    mv tmp.fcm arch-local.fcm
1007    cd ../
1008  fi
1009  rm -f compile.sh
1010  echo resol=${grid_resolution} >> compile.sh
1011  if [ ${hostname:0:5} = jean- -a "$cospv2" = 1 ] ; then
1012     echo ./$makelmdz -dev $optim $OPT_MAKELMDZ $opt_rad $opt_cosp $opt_makelmdz_xios -d \$resol -v $veget_version -mem -parallel $parallel gcm >> compile.sh
1013     echo ./$makelmdz -dev $optim $OPT_MAKELMDZ $opt_rad $opt_cosp $opt_makelmdz_xios -d \$resol -v $veget_version -mem -parallel $parallel gcm
1014  else   
1015    echo ./$makelmdz $optim $OPT_MAKELMDZ $opt_rad $opt_cosp $opt_makelmdz_xios -d \$resol -v $veget_version -mem -parallel $parallel gcm >> compile.sh
1016    echo ./$makelmdz $optim $OPT_MAKELMDZ $opt_rad $opt_cosp $opt_makelmdz_xios -d \$resol -v $veget_version -mem -parallel $parallel gcm
1017  fi 
1018  chmod +x ./compile.sh
1019  if [ $bench != 0 ] ; then ./compile.sh > $lmdzlog 2>&1 ; fi
1020
1021  echo "Compilation finished"
1022 
1023fi # of if [ $parallel != "none" ]
1024
1025
1026##################################################################
1027# Verification du succes de la compilation
1028##################################################################
1029
1030# Recherche de l'executable dont le nom a change au fil du temps ...
1031gcm=""
1032#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
1033for exe in gcm.e bin/gcm_${grid_resolution}_phylmd${suff_exe}${suff_orc}.e ; do   if [ -f $exe ] ; then gcm=$exe ; fi
1034done
1035
1036if [ "$gcm" = "" ] ; then
1037  if [ $bench != 0 ] ; then
1038    echo 'Compilation failed !! Cannot run the benchmark;'
1039    exit
1040  else
1041    echo 'Compilation not done (only done when bench=1)'
1042  fi
1043else
1044   echo '##########################################################'
1045   echo 'Compilation successfull !! '
1046   echo '##########################################################'
1047   echo The executable is $gcm
1048fi
1049
1050##################################################################
1051# Below, we run a benchmark test (if bench=0)
1052##################################################################
1053
1054if [ $bench != 0 ] ; then
1055
1056echo '##########################################################'
1057echo ' Running a test run '
1058echo '##########################################################'
1059
1060\rm -rf BENCH${grid_resolution}
1061bench=bench_lmdz_${grid_resolution}
1062echo install.sh before bench download  `date`
1063#wget http://www.lmd.jussieu.fr/~lmdz/Distrib/$bench.tar.gz
1064myget 3DBenchs/$bench.tar.gz
1065echo install.sh after bench download  `date`
1066tar xvf $bench.tar.gz
1067
1068if [ "$cosp" = 1 -o "$cosp2" = 1 -o "$cospv2" = 1 ] ; then
1069  cd BENCH${grid_resolution}
1070# copier les fichiers namelist input et output our COSP
1071  cp ../DefLists/cosp*_input_nl.txt .
1072  cp ../DefLists/cosp*_output_nl.txt .
1073# Activer la cles ok_cosp pour tourner avec COSP
1074  sed -e 's@ok_cosp=n@ok_cosp=y@' config.def > tmp
1075   \mv -f tmp config.def
1076  cd ..
1077fi 
1078
1079if [ -n "$physiq" ]; then
1080  cd BENCH${grid_resolution}
1081  if [ -f physiq.def_${physiq} ]; then
1082    cp physiq.def_${physiq} physiq.def
1083    echo using physiq.def_${physiq}
1084  else
1085    echo using standard physiq.def
1086  fi
1087  cd ..
1088else
1089  echo using standard physiq.def
1090fi
1091
1092if [ "$with_xios" = "y" ] ; then
1093  cd BENCH${grid_resolution}
1094  cp ../DefLists/iodef.xml .
1095  cp ../DefLists/context_lmdz.xml .
1096  cp ../DefLists/field_def_lmdz.xml .
1097  cp ../DefLists/field_def_cosp*.xml .
1098  cp ../DefLists/file_def_hist*xml .
1099  # adapt iodef.xml to use attached mode
1100  sed -e 's@"using_server" type="bool">true@"using_server" type="bool">false@' iodef.xml > tmp
1101  \mv -f tmp iodef.xml
1102
1103  # and convert all the enabled="_AUTO_" (for libIGCM) to enabled=.FALSE.
1104  # except for histday
1105  for histfile in file_def_hist*xml
1106  do
1107    if [ "$histfile" = "file_def_histday_lmdz.xml" ] ; then
1108    sed -e 's@enabled="_AUTO_"@type="one_file" enabled=".TRUE."@' $histfile > tmp ; \mv -f tmp $histfile
1109    sed -e 's@output_level="_AUTO_"@output_level="5"@' $histfile > tmp ; \mv -f tmp $histfile
1110    sed -e 's@compression_level="2"@compression_level="0"@' $histfile > tmp ; \mv -f tmp $histfile
1111    else
1112    sed -e 's@enabled="_AUTO_"@type="one_file" enabled=".FALSE."@' $histfile > tmp ; \mv -f tmp $histfile
1113    fi
1114  done
1115  # and add option "ok_all_xml=y" in config.def
1116  echo "### XIOS outputs" >> config.def
1117  echo 'ok_all_xml=.true.' >> config.def
1118
1119  #activer les sorties pour Cosp
1120  if [ "$cosp" = 1 -o "$cosp2" = 1 ] ; then 
1121   histfile=file_def_histdayCOSP_lmdz.xml
1122   sed -e 's@enabled=".FALSE."@enabled=".TRUE."@' $histfile > tmp ; \mv -f tmp $histfile
1123   sed -e 's@output_level="_AUTO_"@output_level="5"@' $histfile > tmp ; \mv -f tmp $histfile
1124   sed -e 's@compression_level="2"@compression_level="0"@' $histfile > tmp ; \mv -f tmp $histfile
1125  fi
1126  if [ "$cospv2" = 1 ] ; then
1127   histfile=file_def_histdayCOSPv2_lmdz.xml
1128   sed -e 's@compression_level="2"@compression_level="0"@' $histfile > tmp ; \mv -f tmp $histfile
1129   contextfile=context_lmdz.xml
1130   sed -e 's@src="./file_def_histdayCOSP_lmdz.xml"@src="./file_def_histdayCOSPv2_lmdz.xml"@' $contextfile > tmp ; \mv -f tmp $contextfile
1131   fieldfile=field_def_lmdz.xml
1132   sed -e 's@field_def_cosp1.xml@field_def_cospv2.xml@' $fieldfile > tmp ; \mv -f tmp $fieldfile
1133  fi
1134
1135  cd ..
1136fi
1137
1138# Cas Bensh avec ecrad
1139if [ "$rad" = "ecrad" ] ; then
1140  cd BENCH${grid_resolution}
1141  cp  ../DefLists/namelist_ecrad .
1142  cp -r ../libf/phylmd/ecrad/data .
1143# Attention au cas ou ne 1
1144  sed -e 's@iflag_rrtm=1@iflag_rrtm=2@' physiq.def > tmp
1145   \mv -f tmp physiq.def
1146  cd ..
1147fi
1148
1149cp $gcm BENCH${grid_resolution}/gcm.e
1150
1151cd BENCH${grid_resolution}
1152# On cree le fichier bench.sh au besoin
1153# Dans le cas 48x36x39 le bench.sh existe deja en parallele
1154
1155if [ "$grid_resolution" = "48x36x39" ] ; then
1156   echo On ne touche pas au bench.sh
1157   # But we have to adapt "run_local.sh" for $mpirun
1158   sed -e "s@mpirun@$mpirun@g" run_local.sh > tmp
1159   mv -f tmp run_local.sh
1160   chmod u=rwx run_local.sh
1161elif [ "${parallel:0:3}" = "mpi" ] ; then
1162   # Lancement avec deux procs mpi et 2 openMP
1163   echo "export OMP_STACKSIZE=800M" > bench.sh
1164   if [ "${parallel:4:3}" = "omp" ] ; then
1165     echo "export OMP_NUM_THREADS=2" >> bench.sh
1166   fi
1167   if [ "$cospv2" = 1 -o "$cosp" = 1 -o "$cosp2" = 1 ] ; then 
1168      if [ ${hostname:0:5} = jean- ] ; then   
1169        chmod +x ../arch.env
1170        ../arch.env     
1171        echo "ulimit -s 2000000" >> bench.sh
1172      else
1173        echo "ulimit -s 200000" >> bench.sh           
1174      fi       
1175   else
1176      echo "ulimit -s unlimited" >> bench.sh
1177   fi
1178   if [ ${hostname:0:5} = jean- ] ; then
1179     . ../arch/arch-${arch}.env 
1180     echo "srun -n 2 -A $idris_acct@cpu gcm.e > listing  2>&1" >> bench.sh
1181   else
1182     echo "$mpirun -np 2 gcm.e > listing  2>&1" >> bench.sh
1183   fi
1184   # Add rebuild, using reb.sh if it is there
1185   echo 'if [ -f reb.sh ] ; then' >> bench.sh
1186   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
1187   echo 'fi' >> bench.sh
1188else
1189   echo "./gcm.e > listing  2>&1" > bench.sh
1190fi
1191# Getting orchidee stuff
1192if [ $veget == 'CMIP6' ] ; then
1193    #echo 'myget 3DBenchs/BENCHorch11.tar.gz'
1194    #myget 3DBenchs/BENCHorch11.tar.gz
1195    #tar xvzf BENCHorch11.tar.gz
1196    echo 'myget 3DBenchs/BENCHCMIP6.tar.gz'
1197    myget 3DBenchs/BENCHCMIP6.tar.gz
1198    tar xvzf BENCHCMIP6.tar.gz
1199    sed -e "s:VEGET=n:VEGET=y:" config.def > tmp
1200    mv -f tmp config.def
1201fi
1202echo EXECUTION DU BENCH
1203set +e
1204date ; ./bench.sh > out.bench 2>&1 ; date
1205set -e
1206tail listing
1207
1208
1209echo '##########################################################'
1210echo 'Simulation finished in' `pwd`
1211   echo 'You have compiled with:'
1212   cat ../compile.sh
1213if [ $parallel = "none" ] ; then
1214  echo 'You may re-run it with : cd ' `pwd` ' ; gcm.e'
1215  echo 'or ./bench.sh'
1216else
1217  echo 'You may re-run it with : '
1218  echo 'cd ' `pwd` '; ./bench.sh'
1219#  echo 'ulimit -s unlimited'
1220#  echo 'export OMP_NUM_THREADS=2'
1221#  echo 'export OMP_STACKSIZE=800M'
1222#  echo "$mpirun -np 2 gcm.e "
1223fi
1224echo '##########################################################'
1225
1226fi # bench
1227
1228
1229#################################################################
1230# Installation eventuelle du 1D
1231#################################################################
1232
1233if [ $SCM = 1 ] ; then
1234cd $MODEL
1235#wget http://www.lmd.jussieu.fr/~lmdz/Distrib/1D.tar.gz
1236myget 1D/1D.tar.gz
1237tar xvf 1D.tar.gz
1238cd 1D
1239./run.sh -rad $rad
1240fi
1241set -vx
1242
1243#################################################################
1244# sauvegarde des options veget pour utilisation eventuelle tutorial_prod
1245#################################################################
1246cd $MODEL/modipsl/modeles
1247echo surface_env file created in $MODEL
1248echo 'veget='$veget > surface_env
1249#opt_veget="-v $veget_version"
1250#echo 'opt_veget="'$opt_veget\" >> surface_env
1251echo 'opt_veget="'-v $veget_version\" >> surface_env
1252echo 'orchidee_rev='$orchidee_rev >> surface_env
1253echo 'suforch='$suff_orc >> surface_env
1254   
1255
1256
1257
Note: See TracBrowser for help on using the repository browser.