Changeset 4215


Ignore:
Timestamp:
Jul 20, 2022, 5:54:14 PM (23 months ago)
Author:
lguez
Message:

Indent the whole file

File:
1 edited

Legend:

Unmodified
Added
Removed
  • BOL/script_install/install_lmdz_new.sh

    r4214 r4215  
    4747################################################################
    4848function myget { #1st and only argument should be file name
    49   # Path on local computer where to look for the datafile
    50   if [ -f /u/lmdz/WWW/LMDZ/pub/$1 ] ; then
    51     \cp -f -p /u/lmdz/WWW/LMDZ/pub/$1 .
    52   elif [ -f ~/LMDZ/pub/$1 ] ; then
    53     \cp -f -p ~/LMDZ/pub/$1 .
    54   else
    55     wget --no-check-certificate -nv http://lmdz.lmd.jussieu.fr/pub/$1
    56     save_pub_locally=0
    57     if [ $save_pub_locally = 1 ] ; then # saving wget files on ~/LMDZ/pub
    58        dir=~/LMDZ/pub/`dirname $1` ; mkdir -p $dir ; cp -r `basename $1` $dir
    59     fi
    60   fi
     49    # Path on local computer where to look for the datafile
     50    if [ -f /u/lmdz/WWW/LMDZ/pub/$1 ] ; then
     51        \cp -f -p /u/lmdz/WWW/LMDZ/pub/$1 .
     52    elif [ -f ~/LMDZ/pub/$1 ] ; then
     53        \cp -f -p ~/LMDZ/pub/$1 .
     54    else
     55        wget --no-check-certificate -nv http://lmdz.lmd.jussieu.fr/pub/$1
     56        save_pub_locally=0
     57        if [ $save_pub_locally = 1 ] ; then # saving wget files on ~/LMDZ/pub
     58            dir=~/LMDZ/pub/`dirname $1` ; mkdir -p $dir ; cp -r `basename $1` $dir
     59        fi
     60    fi
    6161}
    6262
     
    7575getlmdzor=1
    7676netcdf=0   #  1: for automatic installation;
    77            #  or 0: do not install NetCDF and look for it in standard locations;
    78            #  or absolute path: look for NetCDF there
     77#  or 0: do not install NetCDF and look for it in standard locations;
     78#  or absolute path: look for NetCDF there
    7979check_linux=1
    8080ioipsl=1
     
    137137#########################################################################
    138138while (($# > 0))
    139    do
    140    case $1 in
    141      "-h") cat <<........fin
     139do
     140    case $1 in
     141        "-h") cat <<........fin
    142142    $0 [ -v version ] [ -r svn_release ]
    143143           [ -parallel PARA ] [ -d GRID_RESOLUTION ] [ -bench 0/1 ]
     
    192192
    193193........fin
    194      exit ;;
    195      "-v") version=$2 ; shift ; shift ;;
    196      "-r") svn=$2 ; shift ; shift ;;
    197      "-compiler") compiler=$2
    198                   case $compiler in
    199                     "gfortran"|"ifort"|"pgf90") compiler=$2 ; shift ; shift ;;
    200                     *) echo "Only gfortran , ifort or pgf90 for the compiler option" ; exit
    201                   esac ;;
    202      "-d") grid_resolution=$2 ; shift ; shift ;;
    203      "-gprof") OPT_GPROF="-pg" ; shift ;;
    204      "-cosp") cosp=$2
    205               case $cosp in
    206                   "none"|"v1"|"v2") cosp=$2 ; shift ; shift ;;
    207                   *) echo Only none v1 v2 for cosp option ; exit
    208               esac ;;
    209      "-nofcm") compile_with_fcm=0 ; shift ;;
    210      "-SCM") SCM=1 ; shift ;;
    211      "-opt_makelmdz") OPT_MAKELMDZ="$2" ; shift ; shift ;;
    212      "-rrtm") rrtm="$2" ; if [ "$2" = "false" ] ; then rad="oldrad" ; else rad="rrtm" ; fi ; shift ; shift ;;
    213      "-rad") rad=$2
    214              case $rad in
    215                 "oldrad"|"rrtm"|"ecrad") rad=$2 ; shift ; shift ;;
    216                 *) echo Only oldrad rrtm ecrad for rad option ; exit
    217              esac ;;
    218      "-parallel") parallel=$2
    219                   case $parallel in
    220                     "none"|"mpi"|"omp"|"mpi_omp") parallel=$2 ; shift ; shift ;;
    221                     *) echo Only none mpi omp mpi_omp for the parallel option ; exit
    222                   esac ;;
    223      "-bench") bench=$2 ; shift ; shift ;;
    224      "-debug") optim=-debug ; shift ;;
    225      "-name") MODEL=$2 ; shift ; shift ;;
    226      "-netcdf") netcdf=$2 ; shift ; shift ;;
    227      "-physiq") physiq=$2 ; shift ; shift ;;
    228      "-xios") with_xios="y" ; shift ;;
    229      "-env_file") env_file=$2 ; shift ; shift ;;
    230      "-veget") veget=$2 ; shift ; shift ;;
    231      *) ./install_lmdz.sh -h ; exit
    232    esac
     194              exit ;;
     195        "-v") version=$2 ; shift ; shift ;;
     196        "-r") svn=$2 ; shift ; shift ;;
     197        "-compiler") compiler=$2
     198                     case $compiler in
     199                        "gfortran"|"ifort"|"pgf90") compiler=$2 ; shift ; shift ;;
     200                        *) echo "Only gfortran , ifort or pgf90 for the compiler option" ; exit
     201                     esac ;;
     202        "-d") grid_resolution=$2 ; shift ; shift ;;
     203        "-gprof") OPT_GPROF="-pg" ; shift ;;
     204        "-cosp") cosp=$2
     205                case $cosp in
     206                     "none"|"v1"|"v2") cosp=$2 ; shift ; shift ;;
     207                     *) echo Only none v1 v2 for cosp option ; exit
     208                esac ;;
     209        "-nofcm") compile_with_fcm=0 ; shift ;;
     210        "-SCM") SCM=1 ; shift ;;
     211        "-opt_makelmdz") OPT_MAKELMDZ="$2" ; shift ; shift ;;
     212        "-rrtm") rrtm="$2" ; if [ "$2" = "false" ] ; then rad="oldrad" ; else rad="rrtm" ; fi ; shift ; shift ;;
     213        "-rad") rad=$2
     214                case $rad in
     215                    "oldrad"|"rrtm"|"ecrad") rad=$2 ; shift ; shift ;;
     216                    *) echo Only oldrad rrtm ecrad for rad option ; exit
     217                esac ;;
     218        "-parallel") parallel=$2
     219                     case $parallel in
     220                        "none"|"mpi"|"omp"|"mpi_omp") parallel=$2 ; shift ; shift ;;
     221                        *) echo Only none mpi omp mpi_omp for the parallel option ; exit
     222                     esac ;;
     223        "-bench") bench=$2 ; shift ; shift ;;
     224        "-debug") optim=-debug ; shift ;;
     225        "-name") MODEL=$2 ; shift ; shift ;;
     226        "-netcdf") netcdf=$2 ; shift ; shift ;;
     227        "-physiq") physiq=$2 ; shift ; shift ;;
     228        "-xios") with_xios="y" ; shift ;;
     229        "-env_file") env_file=$2 ; shift ; shift ;;
     230        "-veget") veget=$2 ; shift ; shift ;;
     231        *) ./install_lmdz.sh -h ; exit
     232    esac
    233233done
    234234
     
    244244opt_cosp=""
    245245case cosp in
    246    v1) opt_cosp="-cosp true" ;;
    247    v2) opt_cosp="-cospv2 true" ;;
     246    v1) opt_cosp="-cosp true" ;;
     247    v2) opt_cosp="-cospv2 true" ;;
    248248esac
    249249
     
    288288case ${hostname:0:5} in
    289289
    290    jean-)   compiler="mpiifort" ;
    291             par_comp="mpiifort" ;
    292             o_ins_make="-t jeanzay" ;
    293             make=gmake ;
    294             module purge
    295             module load intel-compilers/19.0.4 ;
    296             #module load intel-mpi/19.0.4 ;
    297             #module load intel-mkl/19.0.4 ;
    298             module load hdf5/1.10.5-mpi ;
    299             module load netcdf/4.7.2-mpi ;
    300             module load netcdf-fortran/4.5.2-mpi ;
    301             module load subversion/1.9.7 ;
    302             export NETCDF_LIBDIR=./
    303             export NETCDFFORTRAN_INCDIR=./
    304             export NETCDFFORTRAN_LIBDIR=./
    305             arch=X64_JEANZAY ;;
    306 
    307    cicla|camel)   compiler="gfortran" ;
    308             module load netcdf4/4.3.3.1-gfortran;
    309             netcdf=/opt/netcdf43/gfortran
    310 
    311             if [ $parallel != none ] ; then
    312               module load openmpi/1.6.5-gfortran ;
    313               root_mpi=$MPI_HOME ;
    314               path_mpi=$root_mpi/bin ;
    315               par_comp=${path_mpi}/mpif90 ;
    316               mpirun=${path_mpi}/mpirun ;
    317             fi ;
    318             arch=local  ;
    319             make=make ;
    320             o_ins_make="-t g95" ;;
    321 
    322    *)       if [ $parallel = none -o -f /usr/bin/mpif90 ] ; then
    323                 path_mpi=`which mpif90 | sed -e s:/mpif90::` ;
    324                 if [ -d /usr/lib64/openmpi ] ; then
    325                   root_mpi="/usr/lib64/openmpi"
    326                 else
    327                   root_mpi="/usr"
    328                 fi
    329             else
    330               echo "Cannot find mpif90" ;
    331               if [ $parallel = none ] ; then exit ; fi ;
    332             fi ;
    333             if [ $parallel != none ] ; then
    334               root_mpi=$(which mpif90 | sed -e s:/bin/mpif90::)
    335               path_mpi=$(which mpif90 | sed -e s:/mpif90::)
    336               export LD_LIBRARY_PATH=${root_mpi}/lib:$LD_LIBRARY_PATH
    337             fi
    338             par_comp=${path_mpi}/mpif90 ;
    339             mpirun=${path_mpi}/mpirun ;
    340             arch=local  ;
    341             make=make ;
    342             o_ins_make="-t g95"
     290    jean-)   compiler="mpiifort" ;
     291             par_comp="mpiifort" ;
     292             o_ins_make="-t jeanzay" ;
     293             make=gmake ;
     294             module purge
     295             module load intel-compilers/19.0.4 ;
     296             #module load intel-mpi/19.0.4 ;
     297             #module load intel-mkl/19.0.4 ;
     298             module load hdf5/1.10.5-mpi ;
     299             module load netcdf/4.7.2-mpi ;
     300             module load netcdf-fortran/4.5.2-mpi ;
     301             module load subversion/1.9.7 ;
     302             export NETCDF_LIBDIR=./
     303             export NETCDFFORTRAN_INCDIR=./
     304             export NETCDFFORTRAN_LIBDIR=./
     305             arch=X64_JEANZAY ;;
     306
     307    cicla|camel)   compiler="gfortran" ;
     308                   module load netcdf4/4.3.3.1-gfortran;
     309                   netcdf=/opt/netcdf43/gfortran
     310
     311                   if [ $parallel != none ] ; then
     312                       module load openmpi/1.6.5-gfortran ;
     313                       root_mpi=$MPI_HOME ;
     314                       path_mpi=$root_mpi/bin ;
     315                       par_comp=${path_mpi}/mpif90 ;
     316                       mpirun=${path_mpi}/mpirun ;
     317                   fi ;
     318                   arch=local  ;
     319                   make=make ;
     320                   o_ins_make="-t g95" ;;
     321
     322    *)       if [ $parallel = none -o -f /usr/bin/mpif90 ] ; then
     323                 path_mpi=`which mpif90 | sed -e s:/mpif90::` ;
     324                 if [ -d /usr/lib64/openmpi ] ; then
     325                     root_mpi="/usr/lib64/openmpi"
     326                 else
     327                     root_mpi="/usr"
     328                 fi
     329             else
     330                echo "Cannot find mpif90" ;
     331                if [ $parallel = none ] ; then exit ; fi ;
     332             fi ;
     333             if [ $parallel != none ] ; then
     334                root_mpi=$(which mpif90 | sed -e s:/bin/mpif90::)
     335                path_mpi=$(which mpif90 | sed -e s:/mpif90::)
     336                export LD_LIBRARY_PATH=${root_mpi}/lib:$LD_LIBRARY_PATH
     337             fi
     338             par_comp=${path_mpi}/mpif90 ;
     339             mpirun=${path_mpi}/mpirun ;
     340             arch=local  ;
     341             make=make ;
     342             o_ins_make="-t g95"
    343343esac
    344344
    345345# Flags for parallelism:
    346346if [ $parallel != none ] ; then
    347   # MPI_LD are the flags needed for linking with MPI
    348   MPI_LD="-L${root_mpi}/lib -lmpi"
    349   if [ "$compiler" = "gfortran" ] ; then
    350     # MPI_FLAGS are the flags needed for compilation with MPI
    351     MPI_FLAGS="-fcray-pointer"
    352     # OMP_FLAGS are the flags needed for compilation with OpenMP
    353     OMP_FLAGS="-fopenmp -fcray-pointer"
    354     # OMP_LD are the flags needed for linking with OpenMP
    355     OMP_LD="-fopenmp"
    356   elif [ "$compiler" = "ifort" ] ; then
    357     MPI_FLAGS=""
    358     OMP_FLAGS="-openmp"
    359     OMP_LD="-openmp"
    360   else # pgf90
    361     MPI_FLAGS=""
    362     OMP_FLAGS="-mp"
    363     OMP_LD="-mp"
    364   fi
     347    # MPI_LD are the flags needed for linking with MPI
     348    MPI_LD="-L${root_mpi}/lib -lmpi"
     349    if [ "$compiler" = "gfortran" ] ; then
     350        # MPI_FLAGS are the flags needed for compilation with MPI
     351        MPI_FLAGS="-fcray-pointer"
     352        # OMP_FLAGS are the flags needed for compilation with OpenMP
     353        OMP_FLAGS="-fopenmp -fcray-pointer"
     354        # OMP_LD are the flags needed for linking with OpenMP
     355        OMP_LD="-fopenmp"
     356    elif [ "$compiler" = "ifort" ] ; then
     357        MPI_FLAGS=""
     358        OMP_FLAGS="-openmp"
     359        OMP_LD="-openmp"
     360    else # pgf90
     361        MPI_FLAGS=""
     362        OMP_FLAGS="-mp"
     363        OMP_LD="-mp"
     364    fi
    365365fi
    366366
     
    374374
    375375if [ "$compiler" = "gfortran" ] ; then
    376    gfortran=gfortran
    377    gfortranv=`gfortran --version | \
     376    gfortran=gfortran
     377    gfortranv=`gfortran --version | \
    378378   head -1 | awk ' { print $NF } ' | awk -F. ' { print $1 * 10 + $2 } '`
    379    if [ $gfortranv -le 43 ] ; then
    380        echo ERROR : Your gfortran compiler is too old
    381        echo 'Please choose a new one (ifort) and change the line'
    382        echo compiler=xxx
    383        echo in the install_lmdz.sh script and rerun it
    384        if [ `which gfortran44 | wc -w` -ne 0 ] ; then
    385           gfortran=gfortran44
    386        else
    387           echo gfotran trop vieux ; exit
    388        fi
    389    fi
    390    compiler=$gfortran
     379    if [ $gfortranv -le 43 ] ; then
     380        echo ERROR : Your gfortran compiler is too old
     381        echo 'Please choose a new one (ifort) and change the line'
     382        echo compiler=xxx
     383        echo in the install_lmdz.sh script and rerun it
     384        if [ `which gfortran44 | wc -w` -ne 0 ] ; then
     385            gfortran=gfortran44
     386        else
     387            echo gfotran trop vieux ; exit
     388        fi
     389    fi
     390    compiler=$gfortran
    391391fi
    392392#####################################################################
     
    394394## if also compiling XIOS, parallel must be mpi_omp
    395395if [ "$with_xios" = "y" -a "$parallel" != "mpi_omp" ] ; then
    396   echo "Error, you must set -parallel mpi_omp if you want XIOS"
    397   exit
     396    echo "Error, you must set -parallel mpi_omp if you want XIOS"
     397    exit
    398398fi
    399399
    400400if [ "$with_xios" = "y" ] ; then
    401   opt_makelmdz_xios="-io xios"
     401    opt_makelmdz_xios="-io xios"
    402402fi
    403403
    404404if [ "$cosp" = "v2" -a "$with_xios" = "n" ] ; then
    405   echo "Error, Cospv2 cannot run without Xios"
    406   exit
     405    echo "Error, Cospv2 cannot run without Xios"
     406    exit
    407407fi
    408408
     
    423423
    424424if [ "$compiler" = "$gfortran" ] ; then
    425    OPTIM='-O3'
    426    OPTDEB="-g3 -Wall -fbounds-check -ffpe-trap=invalid,zero,overflow -O0 -fstack-protector-all -fbacktrace -finit-real=snan"
    427    OPTDEV="-Wall -fbounds-check"
    428    fmod='I '
    429    OPTPREC="$OPTPREC -cpp -ffree-line-length-0"
    430    if [ $real = r8 ] ; then OPTPREC="$OPTPREC -fdefault-real-8 -DNC_DOUBLE" ; fi
    431    export F90FLAGS=" -ffree-form $OPTIMNC"
    432    export FFLAGS=" $OPTIMNC"
    433    export CC=gcc
    434    export CXX=g++
    435    export fpp_flags="-P -C -traditional -ffreestanding"
     425    OPTIM='-O3'
     426    OPTDEB="-g3 -Wall -fbounds-check -ffpe-trap=invalid,zero,overflow -O0 -fstack-protector-all -fbacktrace -finit-real=snan"
     427    OPTDEV="-Wall -fbounds-check"
     428    fmod='I '
     429    OPTPREC="$OPTPREC -cpp -ffree-line-length-0"
     430    if [ $real = r8 ] ; then OPTPREC="$OPTPREC -fdefault-real-8 -DNC_DOUBLE" ; fi
     431    export F90FLAGS=" -ffree-form $OPTIMNC"
     432    export FFLAGS=" $OPTIMNC"
     433    export CC=gcc
     434    export CXX=g++
     435    export fpp_flags="-P -C -traditional -ffreestanding"
    436436
    437437elif [ $compiler = mpif90 ] ; then
    438    OPTIM='-O3'
    439    OPTDEB="-g3 -Wall -fbounds-check -ffpe-trap=invalid,zero,overflow -O0 -fstack-protector-all"
    440    OPTDEV="-Wall -fbounds-check"
    441    BASE_LD="$BASE_LD -lblas"
    442    fmod='I '
    443    if [ $real = r8 ] ; then OPTPREC="$OPTPREC -fdefault-real-8 -DNC_DOUBLE -fcray-pointer" ; fi
    444    export F90FLAGS=" -ffree-form $OPTIMNC"
    445    export FFLAGS=" $OPTIMNC"
    446    export CC=gcc
    447    export CXX=g++
     438    OPTIM='-O3'
     439    OPTDEB="-g3 -Wall -fbounds-check -ffpe-trap=invalid,zero,overflow -O0 -fstack-protector-all"
     440    OPTDEV="-Wall -fbounds-check"
     441    BASE_LD="$BASE_LD -lblas"
     442    fmod='I '
     443    if [ $real = r8 ] ; then OPTPREC="$OPTPREC -fdefault-real-8 -DNC_DOUBLE -fcray-pointer" ; fi
     444    export F90FLAGS=" -ffree-form $OPTIMNC"
     445    export FFLAGS=" $OPTIMNC"
     446    export CC=gcc
     447    export CXX=g++
    448448
    449449elif [ $compiler = pgf90 ] ; then
    450    OPTIM='-O2 -Mipa -Munroll -Mnoframe -Mautoinline -Mcache_align'
    451    OPTDEB='-g -Mdclchk -Mbounds -Mchkfpstk -Mchkptr -Minform=inform -Mstandard -Ktrap=fp -traceback'
    452    OPTDEV='-g -Mbounds -Ktrap=fp -traceback'
    453    fmod='module '
    454    if [ $real = r8 ] ; then OPTPREC="$OPTPREC -r8 -DNC_DOUBLE" ; fi
    455    export CPPFLAGS="-DpgiFortran"
    456    export CC=pgcc
    457    export CFLAGS="-O2 -Msignextend"
    458    export CXX=pgCC
    459    export CXXFLAGS="-O2 -Msignextend"
    460    export FFLAGS="-O2 $OPTIMNC"
    461    export F90FLAGS="-O2 $OPTIMNC"
    462    compile_with_fcm=1
     450    OPTIM='-O2 -Mipa -Munroll -Mnoframe -Mautoinline -Mcache_align'
     451    OPTDEB='-g -Mdclchk -Mbounds -Mchkfpstk -Mchkptr -Minform=inform -Mstandard -Ktrap=fp -traceback'
     452    OPTDEV='-g -Mbounds -Ktrap=fp -traceback'
     453    fmod='module '
     454    if [ $real = r8 ] ; then OPTPREC="$OPTPREC -r8 -DNC_DOUBLE" ; fi
     455    export CPPFLAGS="-DpgiFortran"
     456    export CC=pgcc
     457    export CFLAGS="-O2 -Msignextend"
     458    export CXX=pgCC
     459    export CXXFLAGS="-O2 -Msignextend"
     460    export FFLAGS="-O2 $OPTIMNC"
     461    export F90FLAGS="-O2 $OPTIMNC"
     462    compile_with_fcm=1
    463463
    464464elif [ $compiler = ifort ] ; then
    465    OPTIM="-O2 -fp-model strict -ip -align all "
    466    OPTDEV="-p -g -O2 -traceback -fp-stack-check -ftrapuv -check"
    467    OPTDEB="-g -no-ftz -traceback -ftrapuv -fp-stack-check -check"
    468    fmod='module '
    469    if [ $real = r8 ] ; then OPTPREC="$OPTPREC -real-size 64 -DNC_DOUBLE" ; fi
    470    export CPP="icc -E"
    471    export FFLAGS="-O2 -ip -fpic -mcmodel=large"
    472    export FCFLAGS="-O2 -ip -fpic -mcmodel=large"
    473    export CC=icc
    474    export CFLAGS="-O2 -ip -fpic -mcmodel=large"
    475    export CXX=icpc
    476    export CXXFLAGS="-O2 -ip -fpic -mcmodel=large"
    477    export fpp_flags="-P -traditional"
    478    # Pourquoi forcer la compilation fcm. Marche mieux sans
    479    #compile_with_fcm=1
     465    OPTIM="-O2 -fp-model strict -ip -align all "
     466    OPTDEV="-p -g -O2 -traceback -fp-stack-check -ftrapuv -check"
     467    OPTDEB="-g -no-ftz -traceback -ftrapuv -fp-stack-check -check"
     468    fmod='module '
     469    if [ $real = r8 ] ; then OPTPREC="$OPTPREC -real-size 64 -DNC_DOUBLE" ; fi
     470    export CPP="icc -E"
     471    export FFLAGS="-O2 -ip -fpic -mcmodel=large"
     472    export FCFLAGS="-O2 -ip -fpic -mcmodel=large"
     473    export CC=icc
     474    export CFLAGS="-O2 -ip -fpic -mcmodel=large"
     475    export CXX=icpc
     476    export CXXFLAGS="-O2 -ip -fpic -mcmodel=large"
     477    export fpp_flags="-P -traditional"
     478    # Pourquoi forcer la compilation fcm. Marche mieux sans
     479    #compile_with_fcm=1
    480480
    481481elif [ $compiler = mpiifort ] ; then
    482    echo on ne fait rien la
    483    # Pourquoi forcer la compilation fcm. Marche mieux sans
    484    #compile_with_fcm=1
     482    echo on ne fait rien la
     483    # Pourquoi forcer la compilation fcm. Marche mieux sans
     484    #compile_with_fcm=1
    485485
    486486else
    487    echo unexpected compiler $compiler ; exit
     487    echo unexpected compiler $compiler ; exit
    488488fi
    489489
     
    496496# don't check for available software and don't install netcdf
    497497if [ ${hostname:0:5} = jean- ] ; then
    498   netcdf=0 # no need to recompile netcdf, alreday available
    499   check_linux=0
    500   pclinux=0
    501   ioipsl=0 # no need to recompile ioipsl, already available
    502   #netcdf="/smplocal/pub/NetCDF/4.1.3"
    503   compiler="mpiifort"
    504   fmod='module '
    505   if [ $real = r8 ] ; then OPTPREC="$OPTPREC -i4 -r8 -DNC_DOUBLE" ; fi
    506   OPTIM="-auto -align all -O2 -fp-model strict -xHost "
    507   OPTIMGCM="$OPTIM $OPTPREC"
     498    netcdf=0 # no need to recompile netcdf, alreday available
     499    check_linux=0
     500    pclinux=0
     501    ioipsl=0 # no need to recompile ioipsl, already available
     502    #netcdf="/smplocal/pub/NetCDF/4.1.3"
     503    compiler="mpiifort"
     504    fmod='module '
     505    if [ $real = r8 ] ; then OPTPREC="$OPTPREC -i4 -r8 -DNC_DOUBLE" ; fi
     506    OPTIM="-auto -align all -O2 -fp-model strict -xHost "
     507    OPTIMGCM="$OPTIM $OPTPREC"
    508508fi
    509509##########################################################################
     
    517517echo '################################################################'
    518518if [ "$check_linux" = 1 ] ; then
    519 echo   Check if required software is available
    520 echo '################################################################'
    521 
    522 #### Ehouarn: test if the required shell is available
    523 #### Maj FH-LF-AS 2021-04 : default=bash ; if bash missing, use ksh
    524 use_shell="bash" # default
    525 if [ "`which bash`" = "" ] ; then
    526   echo "no bash ; we will use ksh"
    527   use_shell="ksh"
    528   if [ "`which ksh`" = "" ] ; then
    529     echo "bash (or ksh) needed!! Install it!"
    530     exit
    531   fi
    532 fi
    533 
    534 for logiciel in wget tar gzip make $compiler gcc cmake ; do
    535 if [ "`which $logiciel`" = "" ] ; then
    536 echo You must first install $logiciel on your system
    537 exit
    538 fi
    539 done
    540 
    541 if [ $pclinux = 1 ] ; then
    542 cd $MODEL
    543 cat <<eod > tt.f90
     519    echo   Check if required software is available
     520    echo '################################################################'
     521
     522    #### Ehouarn: test if the required shell is available
     523    #### Maj FH-LF-AS 2021-04 : default=bash ; if bash missing, use ksh
     524    use_shell="bash" # default
     525    if [ "`which bash`" = "" ] ; then
     526        echo "no bash ; we will use ksh"
     527        use_shell="ksh"
     528        if [ "`which ksh`" = "" ] ; then
     529            echo "bash (or ksh) needed!! Install it!"
     530            exit
     531        fi
     532    fi
     533
     534    for logiciel in wget tar gzip make $compiler gcc cmake ; do
     535        if [ "`which $logiciel`" = "" ] ; then
     536            echo You must first install $logiciel on your system
     537            exit
     538        fi
     539    done
     540
     541    if [ $pclinux = 1 ] ; then
     542        cd $MODEL
     543        cat <<eod > tt.f90
    544544print*,'coucou'
    545545end
    546546eod
    547 $compiler tt.f90 -o a.out
    548 ./a.out >| tt
    549 if [ "`cat tt | sed -e 's/ //g' `" != "coucou" ] ; then
    550 echo problem installing with compiler $compiler ; exit ; fi
    551 \rm tt a.out tt.f90
    552 fi
     547        $compiler tt.f90 -o a.out
     548        ./a.out >| tt
     549        if [ "`cat tt | sed -e 's/ //g' `" != "coucou" ] ; then
     550            echo problem installing with compiler $compiler ; exit ; fi
     551        \rm tt a.out tt.f90
     552    fi
    553553fi
    554554
    555555###########################################################################
    556556if [ $getlmdzor = 1 -a ! -d $MODEL/modipsl ] ; then
    557 ###########################################################################
    558    echo '##########################################################'
    559    echo  Download a slightly modified version of  LMDZ
    560    echo '##########################################################'
    561    cd $MODEL
    562    myget src/modipsl.$version.tar.gz
    563    echo install_lmdz.sh wget_OK `date`
    564    gunzip modipsl.$version.tar.gz
    565    tar xf modipsl.$version.tar
    566    \rm modipsl.$version.tar
     557    ###########################################################################
     558    echo '##########################################################'
     559    echo  Download a slightly modified version of  LMDZ
     560    echo '##########################################################'
     561    cd $MODEL
     562    myget src/modipsl.$version.tar.gz
     563    echo install_lmdz.sh wget_OK `date`
     564    gunzip modipsl.$version.tar.gz
     565    tar xf modipsl.$version.tar
     566    \rm modipsl.$version.tar
    567567fi
    568568
    569569###########################################################################
    570570if [ $netcdf = 1 -a ! -d $MODEL/netcdf ] ; then
    571 ###########################################################################
    572    cd $MODEL
    573    netcdflog=`pwd`/netcdf.log
    574    echo '##########################################################'
    575    echo Compiling the Netcdf library
    576    echo '##########################################################'
    577    echo log file : $netcdflog
    578    if [ "$with_xios" = "n" ] ; then
    579        myget import/install_netcdf4_hdf5_seq.bash
    580        chmod +x install_netcdf4_hdf5_seq.bash
    581 
    582        if [ "$compiler" = "gfortran" ]
    583        then
    584            ./install_netcdf4_hdf5_seq.bash -prefix $MODEL/netcdf4_hdf5_seq \
    585                                            -compiler gnu  > $netcdflog 2>&1
    586        elif [ "$compiler" = "ifort" ]
    587        then
    588            ./install_netcdf4_hdf5_seq.bash -prefix $MODEL/netcdf4_hdf5_seq \
    589                                            -compiler intel  > $netcdflog 2>&1
    590        else
    591            echo "unexpected compiler $compiler" ; exit
    592        fi
    593 
    594        # LF rajout d'une verrue, pour une raison non encore expliquee,
    595        # la librairie est parfois rangée dans lib64 et non dans lib
    596        # par certains compilateurs
    597        if [ ! -e lib -a -d lib64 ] ; then ln -s lib64 lib; fi
    598    else
    599       # download and compile hdf5 and netcdf, etc. using the install_netcdf4_hdf5.bash script
    600       #wget http://www.lmd.jussieu.fr/~lmdz/Distrib/install_netcdf4_hdf5.bash
    601       myget import/install_netcdf4_hdf5.bash
    602       chmod u=rwx install_netcdf4_hdf5.bash
    603       if [ "$compiler" = "gfortran" ] ; then
    604       ./install_netcdf4_hdf5.bash -prefix $MODEL/netcdf4_hdf5 -CC gcc -FC gfortran -CXX g++ -MPI $root_mpi  > $netcdflog 2>&1
    605       elif [ "$compiler" = "ifort" ] ; then
    606       ./install_netcdf4_hdf5.bash -prefix $MODEL/netcdf4_hdf5 -CC icc -FC ifort -CXX icpc -MPI $root_mpi  > $netcdflog 2>&1
    607       elif [ "$compiler" = "pgf90" ] ; then
    608       ./install_netcdf4_hdf5.bash -prefix $MODEL/netcdf4_hdf5 -CC pgcc -FC pgf90 -CXX pgCC -MPI $root_mpi  > $netcdflog 2>&1
    609       else
    610         echo "unexpected compiler $compiler" ; exit
    611       fi
    612    fi  # of if [ "$with_xios" = "n" ]
    613    echo install_lmdz.sh netcdf_OK `date`
     571    ###########################################################################
     572    cd $MODEL
     573    netcdflog=`pwd`/netcdf.log
     574    echo '##########################################################'
     575    echo Compiling the Netcdf library
     576    echo '##########################################################'
     577    echo log file : $netcdflog
     578    if [ "$with_xios" = "n" ] ; then
     579        myget import/install_netcdf4_hdf5_seq.bash
     580        chmod +x install_netcdf4_hdf5_seq.bash
     581
     582        if [ "$compiler" = "gfortran" ]
     583        then
     584            ./install_netcdf4_hdf5_seq.bash -prefix $MODEL/netcdf4_hdf5_seq \
     585                                            -compiler gnu  > $netcdflog 2>&1
     586        elif [ "$compiler" = "ifort" ]
     587        then
     588            ./install_netcdf4_hdf5_seq.bash -prefix $MODEL/netcdf4_hdf5_seq \
     589                                            -compiler intel  > $netcdflog 2>&1
     590        else
     591            echo "unexpected compiler $compiler" ; exit
     592        fi
     593
     594        # LF rajout d'une verrue, pour une raison non encore expliquee,
     595        # la librairie est parfois rangée dans lib64 et non dans lib
     596        # par certains compilateurs
     597        if [ ! -e lib -a -d lib64 ] ; then ln -s lib64 lib; fi
     598    else
     599        # download and compile hdf5 and netcdf, etc. using the install_netcdf4_hdf5.bash script
     600        #wget http://www.lmd.jussieu.fr/~lmdz/Distrib/install_netcdf4_hdf5.bash
     601        myget import/install_netcdf4_hdf5.bash
     602        chmod u=rwx install_netcdf4_hdf5.bash
     603        if [ "$compiler" = "gfortran" ] ; then
     604            ./install_netcdf4_hdf5.bash -prefix $MODEL/netcdf4_hdf5 -CC gcc -FC gfortran -CXX g++ -MPI $root_mpi  > $netcdflog 2>&1
     605        elif [ "$compiler" = "ifort" ] ; then
     606            ./install_netcdf4_hdf5.bash -prefix $MODEL/netcdf4_hdf5 -CC icc -FC ifort -CXX icpc -MPI $root_mpi  > $netcdflog 2>&1
     607        elif [ "$compiler" = "pgf90" ] ; then
     608            ./install_netcdf4_hdf5.bash -prefix $MODEL/netcdf4_hdf5 -CC pgcc -FC pgf90 -CXX pgCC -MPI $root_mpi  > $netcdflog 2>&1
     609        else
     610            echo "unexpected compiler $compiler" ; exit
     611        fi
     612    fi  # of if [ "$with_xios" = "n" ]
     613    echo install_lmdz.sh netcdf_OK `date`
    614614fi # of if [ $netcdf = 1 ]
    615615
    616616# ncdfdir contains the directory where netcdf is installed
    617617if [ $netcdf = 1 ] ; then
    618    if [ "$with_xios" = "y" ] ; then
    619       ncdfdir=$MODEL/netcdf4_hdf5
    620    else
    621       ncdfdir=$MODEL/netcdf4_hdf5_seq
    622    fi
     618    if [ "$with_xios" = "y" ] ; then
     619        ncdfdir=$MODEL/netcdf4_hdf5
     620    else
     621        ncdfdir=$MODEL/netcdf4_hdf5_seq
     622    fi
    623623elif [ $netcdf = 0 ]
    624624then
    625      ncdfdir=/usr
     625    ncdfdir=/usr
    626626else
    627    ncdfdir=$netcdf
     627    ncdfdir=$netcdf
    628628fi
    629629
     
    631631if [[ ! -f $MODEL/modipsl/lib/libioipsl.a ]]
    632632then
    633 if [ $ioipsl = 1 ] ; then
    634 #=========================================================================
    635    echo OK ioipsl=$ioipsl
    636    echo '##########################################################'
    637    echo 'Installing MODIPSL, the installation package manager for the '
    638    echo 'IPSL models and tools'
    639    echo '##########################################################'
    640    echo `date`
    641 
    642    cd $MODEL/modipsl
    643    \rm -rf lib/*
    644    cd util
    645    cp AA_make.gdef AA_make.orig
    646    F_C="$compiler -c " ; if [ "$compiler" = "$gfortran" -o "$compiler" = "mpif90" ] ; then F_C="$compiler -c -cpp " ; fi
    647    if [ "$compiler" = "pgf90" ] ; then F_C="$compiler -c -Mpreprocess" ; fi
    648    sed -e 's/^\#.*.g95.*.\#.*.$/\#/' AA_make.gdef > tmp
    649    sed -e "s:F_L = g95:F_L = $compiler:" -e "s:F_C = g95 -c -cpp:F_C = $F_C": \
    650    -e 's/g95.*.w_w.*.(F_D)/g95      w_w = '"$OPTIMGCM"'/' \
    651    -e 's:g95.*.NCDF_INC.*.$:g95      NCDF_INC= '"$ncdfdir"'/include:' \
    652    -e 's:g95.*.NCDF_LIB.*.$:g95      NCDF_LIB= -L'"$ncdfdir"'/lib -lnetcdff -lnetcdf:' \
    653    -e 's:g95      L_O =:g95      L_O = -Wl,-rpath='"$ncdfdir"'/lib:' \
    654    -e "s:-fmod=:-$fmod:" -e 's/-fno-second-underscore//' \
    655    -e 's:#-Q- g95      M_K = gmake:#-Q- g95      M_K = make:' \
    656    tmp >| AA_make.gdef
    657 
    658    if [ $pcmac == 1 ]
    659    then
    660        cp AA_make.gdef tmp
    661        sed -e 's/rpath=/rpath,/g' tmp > AA_make.gdef
    662    fi
    663 
    664 
    665  # We use lines for g95 even for the other compilers to run ins_make
    666    if [ "$use_shell" = "ksh" ] ; then
    667      ./ins_make $o_ins_make
    668    else # bash
    669      sed -e s:/bin/ksh:/bin/bash:g ins_make > ins_make.bash
    670      if [ "`grep jeanzay AA_make.gdef`" = "" ] ; then # Bidouille pour compiler sur ada des vieux modipsl.tar
    671          echo 'Warning jean-zay not in AA_make.gdef'
    672          echo 'Think about updating'
    673          exit 1
    674      fi
    675 
    676      chmod u=rwx ins_make.bash
    677      ./ins_make.bash $o_ins_make
    678    fi # of if [ "$use_shell" = "ksh" ]
    679 
    680    echo install_lmdz.sh MODIPSL_OK `date`
    681 
    682    cd $MODEL/modipsl/modeles/IOIPSL/src
    683    ioipsllog=`pwd`/ioipsl.log
    684    echo '##########################################################'
    685    echo 'Compiling IOIPSL, the interface library with Netcdf'
    686    echo '##########################################################'
    687    echo `date`
    688    echo log file : $ioipsllog
    689 
    690    if [ "$use_shell" = "bash" ] ; then
    691      cp Makefile Makefile.ksh
    692      sed -e s:/bin/ksh:/bin/bash:g Makefile.ksh > Makefile
    693    fi
    694  # if [ "$pclinux" = 1 ] ; then
    695      # Build IOIPSL modules and library
    696      $make clean
    697      $make > $ioipsllog 2>&1
    698      if [ "$compiler" = "$gfortran" -o "$compiler" = "mpif90" ] ; then # copy module files to lib
    699        cp -f *.mod ../../../lib
    700      fi
    701      # Build IOIPSL tools (ie: "rebuild", if present)
    702      if [ -f $MODEL/modipsl/modeles/IOIPSL/tools/rebuild ] ; then
    703        cd $MODEL/modipsl/modeles/IOIPSL/tools
    704        # adapt Makefile & rebuild script if in bash
    705        if [ "$use_shell" = "bash" ] ; then
    706          cp Makefile Makefile.ksh
    707          sed -e s:/bin/ksh:/bin/bash:g Makefile.ksh > Makefile
    708          cp rebuild rebuild.ksh
    709          sed -e 's:/bin/ksh:/bin/bash:g' \
    710              -e 's:print -u2:echo:g' \
    711              -e 's:print:echo:g' rebuild.ksh > rebuild
    712        fi
    713        $make clean
    714        $make > $ioipsllog 2>&1
    715      fi
    716 # fi # of if [ "$pclinux" = 1 ]
    717 
    718 else # of if [ $ioipsl = 1 ]
    719    if [ ${hostname:0:5} = jean- ] ; then
    720       cd $MODEL/modipsl
    721       cd util
    722         if [ "`grep jeanzay AA_make.gdef`" = "" ] ; then
    723          echo 'Warning jean-zay not in AA_make.gdef'
    724          echo 'Think about updating'
    725          exit 1
    726         fi
    727         ./ins_make $o_ins_make
    728 # Compile IOIPSL on jean-zay
    729         cd $MODEL/modipsl/modeles/IOIPSL/src
    730         gmake > ioipsl.log
    731         cd $MODEL/modipsl/modeles/IOIPSL/tools
    732         gmake > ioipsl.log
    733 
    734    fi
    735    echo install_lmdz.sh ioipsl_OK `date`
    736 fi # of if [ $ioipsl = 1 ]
     633    if [ $ioipsl = 1 ] ; then
     634        #=========================================================================
     635        echo OK ioipsl=$ioipsl
     636        echo '##########################################################'
     637        echo 'Installing MODIPSL, the installation package manager for the '
     638        echo 'IPSL models and tools'
     639        echo '##########################################################'
     640        echo `date`
     641
     642        cd $MODEL/modipsl
     643        \rm -rf lib/*
     644        cd util
     645        cp AA_make.gdef AA_make.orig
     646        F_C="$compiler -c " ; if [ "$compiler" = "$gfortran" -o "$compiler" = "mpif90" ] ; then F_C="$compiler -c -cpp " ; fi
     647        if [ "$compiler" = "pgf90" ] ; then F_C="$compiler -c -Mpreprocess" ; fi
     648        sed -e 's/^\#.*.g95.*.\#.*.$/\#/' AA_make.gdef > tmp
     649        sed -e "s:F_L = g95:F_L = $compiler:" -e "s:F_C = g95 -c -cpp:F_C = $F_C": \
     650            -e 's/g95.*.w_w.*.(F_D)/g95      w_w = '"$OPTIMGCM"'/' \
     651            -e 's:g95.*.NCDF_INC.*.$:g95      NCDF_INC= '"$ncdfdir"'/include:' \
     652            -e 's:g95.*.NCDF_LIB.*.$:g95      NCDF_LIB= -L'"$ncdfdir"'/lib -lnetcdff -lnetcdf:' \
     653            -e 's:g95      L_O =:g95      L_O = -Wl,-rpath='"$ncdfdir"'/lib:' \
     654            -e "s:-fmod=:-$fmod:" -e 's/-fno-second-underscore//' \
     655            -e 's:#-Q- g95      M_K = gmake:#-Q- g95      M_K = make:' \
     656            tmp >| AA_make.gdef
     657
     658        if [ $pcmac == 1 ]
     659        then
     660            cp AA_make.gdef tmp
     661            sed -e 's/rpath=/rpath,/g' tmp > AA_make.gdef
     662        fi
     663
     664
     665        # We use lines for g95 even for the other compilers to run ins_make
     666        if [ "$use_shell" = "ksh" ] ; then
     667            ./ins_make $o_ins_make
     668        else # bash
     669            sed -e s:/bin/ksh:/bin/bash:g ins_make > ins_make.bash
     670            if [ "`grep jeanzay AA_make.gdef`" = "" ] ; then # Bidouille pour compiler sur ada des vieux modipsl.tar
     671                echo 'Warning jean-zay not in AA_make.gdef'
     672                echo 'Think about updating'
     673                exit 1
     674            fi
     675
     676            chmod u=rwx ins_make.bash
     677            ./ins_make.bash $o_ins_make
     678        fi # of if [ "$use_shell" = "ksh" ]
     679
     680        echo install_lmdz.sh MODIPSL_OK `date`
     681
     682        cd $MODEL/modipsl/modeles/IOIPSL/src
     683        ioipsllog=`pwd`/ioipsl.log
     684        echo '##########################################################'
     685        echo 'Compiling IOIPSL, the interface library with Netcdf'
     686        echo '##########################################################'
     687        echo `date`
     688        echo log file : $ioipsllog
     689
     690        if [ "$use_shell" = "bash" ] ; then
     691            cp Makefile Makefile.ksh
     692            sed -e s:/bin/ksh:/bin/bash:g Makefile.ksh > Makefile
     693        fi
     694        # if [ "$pclinux" = 1 ] ; then
     695        # Build IOIPSL modules and library
     696        $make clean
     697        $make > $ioipsllog 2>&1
     698        if [ "$compiler" = "$gfortran" -o "$compiler" = "mpif90" ] ; then # copy module files to lib
     699            cp -f *.mod ../../../lib
     700        fi
     701        # Build IOIPSL tools (ie: "rebuild", if present)
     702        if [ -f $MODEL/modipsl/modeles/IOIPSL/tools/rebuild ] ; then
     703            cd $MODEL/modipsl/modeles/IOIPSL/tools
     704            # adapt Makefile & rebuild script if in bash
     705            if [ "$use_shell" = "bash" ] ; then
     706                cp Makefile Makefile.ksh
     707                sed -e s:/bin/ksh:/bin/bash:g Makefile.ksh > Makefile
     708                cp rebuild rebuild.ksh
     709                sed -e 's:/bin/ksh:/bin/bash:g' \
     710                    -e 's:print -u2:echo:g' \
     711                    -e 's:print:echo:g' rebuild.ksh > rebuild
     712            fi
     713            $make clean
     714            $make > $ioipsllog 2>&1
     715        fi
     716        # fi # of if [ "$pclinux" = 1 ]
     717
     718    else # of if [ $ioipsl = 1 ]
     719        if [ ${hostname:0:5} = jean- ] ; then
     720            cd $MODEL/modipsl
     721            cd util
     722            if [ "`grep jeanzay AA_make.gdef`" = "" ] ; then
     723                echo 'Warning jean-zay not in AA_make.gdef'
     724                echo 'Think about updating'
     725                exit 1
     726            fi
     727            ./ins_make $o_ins_make
     728            # Compile IOIPSL on jean-zay
     729            cd $MODEL/modipsl/modeles/IOIPSL/src
     730            gmake > ioipsl.log
     731            cd $MODEL/modipsl/modeles/IOIPSL/tools
     732            gmake > ioipsl.log
     733
     734        fi
     735        echo install_lmdz.sh ioipsl_OK `date`
     736    fi # of if [ $ioipsl = 1 ]
    737737fi
    738738# Saving ioipsl lib for possible parallel compile
    739   cd $MODEL/modipsl
    740   tar cf ioipsl.tar lib/ bin/
     739cd $MODEL/modipsl
     740tar cf ioipsl.tar lib/ bin/
    741741
    742742#=========================================================================
    743743if [ "$with_xios" = "y" ] ; then
    744   echo '##########################################################'
    745   echo 'Compiling XIOS'
    746   echo '##########################################################'
    747   cd $MODEL/modipsl/modeles
    748   xioslog=`pwd`/xios.log
    749   #wget http://www.lmd.jussieu.fr/~lmdz/Distrib/install_xios.bash
    750   myget import/install_xios.bash
    751   chmod u=rwx install_xios.bash
    752   if [ ${hostname:0:5} = jean- ] ; then
    753      svn co http://forge.ipsl.jussieu.fr/ioserver/svn/XIOS/branchs/xios-2.5 XIOS
    754      cd XIOS/arch
    755      svn update
    756      cd ..
    757      echo "Compiling XIOS, start" `date` "(it takes about 20 min on Jean-Zay)"
    758      echo "log file: $xioslog"
    759      ./make_xios --prod --arch $arch --job 4 > xios.log 2>&1
    760   else
    761      ./install_xios.bash -prefix $MODEL/modipsl/modeles \
    762                       -netcdf ${ncdfdir} -hdf5 ${ncdfdir} \
    763                       -MPI $root_mpi -arch $arch > xios.log 2>&1
    764   fi # of case Jean-Zay
    765   if [ -f XIOS/lib/libxios.a ] ; then
    766      echo "XIOS library successfully generated"
    767      echo install_lmdz.sh XIOS_OK `date`
    768   fi
     744    echo '##########################################################'
     745    echo 'Compiling XIOS'
     746    echo '##########################################################'
     747    cd $MODEL/modipsl/modeles
     748    xioslog=`pwd`/xios.log
     749    #wget http://www.lmd.jussieu.fr/~lmdz/Distrib/install_xios.bash
     750    myget import/install_xios.bash
     751    chmod u=rwx install_xios.bash
     752    if [ ${hostname:0:5} = jean- ] ; then
     753        svn co http://forge.ipsl.jussieu.fr/ioserver/svn/XIOS/branchs/xios-2.5 XIOS
     754        cd XIOS/arch
     755        svn update
     756        cd ..
     757        echo "Compiling XIOS, start" `date` "(it takes about 20 min on Jean-Zay)"
     758        echo "log file: $xioslog"
     759        ./make_xios --prod --arch $arch --job 4 > xios.log 2>&1
     760    else
     761        ./install_xios.bash -prefix $MODEL/modipsl/modeles \
     762                            -netcdf ${ncdfdir} -hdf5 ${ncdfdir} \
     763                            -MPI $root_mpi -arch $arch > xios.log 2>&1
     764    fi # of case Jean-Zay
     765    if [ -f XIOS/lib/libxios.a ] ; then
     766        echo "XIOS library successfully generated"
     767        echo install_lmdz.sh XIOS_OK `date`
     768    fi
    769769fi
    770770
     
    772772veget_version=false
    773773if [ "$veget" != 'NONE' ] ; then
    774   cd $MODEL/modipsl/modeles/ORCHIDEE
    775   set +e ; svn upgrade ; set -e
    776   if [ "$veget" = "CMIP6" ] ; then
    777     veget_version=orchidee2.0
    778     orchidee_rev=6592
    779   else # specific orchidee revision newer than CMIP6, on 2_1 or 2_2 branches
    780     veget_version=orchidee2.1
    781     orchidee_rev=$veget
    782      if [ $veget -lt 4465 ] ; then
    783              echo 'Stopping, ORCHIDEE version too old, script needs work on the CPP flags to pass to makelmdz'
    784              exit 1
    785      fi
    786      set +e
    787      # which branch is my version on?
    788      orcbranch=`svn log -v -q svn://forge.ipsl.jussieu.fr/orchidee/ -r $veget |grep ORCHIDEE |head -1| sed -e 's:ORCHIDEE/.*$:ORCHIDEE:' | awk '{print $2}'`
    789      # switch to that branch
    790      echo IF YOU INSTALL ORCHIDEE THE VERY FIRST TIME, ASK for PASSWORD at orchidee-help@listes.ipsl.fr
    791      svn switch -r $veget --accept theirs-full svn://forge.ipsl.jussieu.fr/orchidee/$orcbranch
    792      svn log -r $veget | grep  $veget
    793      if [  $? -gt 0 ] ; then
    794           echo 'Cannot update ORCHIDEE as not on the right branch for ORCHIDEE'
    795           exit
    796       fi
    797       set -e
    798       set +e ; svn update -r $veget ; set -e
    799   fi
    800   # Correctif suite debug Jean-Zay
    801   sed -i -e 's/9010  FORMAT(A52,F17.14)/9010  FORMAT(A52,F20.14)/' src_stomate/stomate.f90
    802   opt_orc="-prod" ; if [ "$optim" = "-debug" ] ; then opt_orc="-debug" ; fi
    803 
    804   orchideelog=`pwd`/orchidee.log
    805   echo '########################################################'
    806   echo 'Compiling ORCHIDEE, the continental surface model '
    807   echo '########################################################'
    808   echo Start of the first compilation of orchidee, in sequential mode: `date`
    809   echo log file : $orchideelog
    810 
    811   export ORCHPATH=`pwd`
    812   xios_orchid="-noxios"
    813   if [ "$with_xios" = "y" ] ; then
    814     xios_orchid="-xios"
    815   fi
    816   if [ -d tools ] ; then
    817 ###################################################################
    818 # Pour les experts qui voudraient changer de version d'orchidee.
    819 # Attention : necessite d'avoir le password pour orchidee
    820 
    821       # Correctif suite debug Jean-Zay
    822       if [ -f src_global/time.f90 ] ; then sed -i -e 's/CALL tlen2itau/\!CALL tlen2itau/' src_global/time.f90 ; fi
    823 ###################################################################
    824      if [ "$veget_version" == "false" ] ; then veget_version=orchidee2.0 ; fi
    825       cd arch
    826       sed -e s:"%COMPILER        .*.$":"%COMPILER            $compiler":1 \
    827      -e s:"%LINK            .*.$":"%LINK                $compiler":1 \
    828      -e s:"%FPP_FLAGS       .*.$":"%FPP_FLAGS           $fpp_flags":1 \
    829      -e s:"%PROD_FFLAGS     .*.$":"%PROD_FFLAGS         $OPTIM":1 \
    830      -e s:"%DEV_FFLAGS      .*.$":"%DEV_FFLAGS          $OPTDEV":1 \
    831      -e s:"%DEBUG_FFLAGS    .*.$":"%DEBUG_FFLAGS        $OPTDEB":1 \
    832      -e s:"%BASE_FFLAGS     .*.$":"%BASE_FFLAGS         $OPTPREC":1 \
    833      -e s:"%BASE_LD         .*.$":"%BASE_LD             $BASE_LD":1 \
    834      -e s:"%ARFLAGS         .*.$":"%ARFLAGS             $ARFLAGS":1 \
    835      arch-gfortran.fcm > arch-local.fcm
    836      echo "NETCDF_LIBDIR=\"-L${ncdfdir}/lib -lnetcdff -lnetcdf\"" > arch-local.path
    837      echo "NETCDF_INCDIR=${ncdfdir}/include" >> arch-local.path
    838      echo "IOIPSL_INCDIR=$ORCHPATH/../../lib" >> arch-local.path
    839      echo "IOIPSL_LIBDIR=$ORCHPATH/../../lib" >> arch-local.path
    840      echo 'XIOS_INCDIR=${ORCHDIR}/../XIOS/inc' >> arch-local.path
    841      echo 'XIOS_LIBDIR="${ORCHDIR}/../XIOS/lib -lxios"' >> arch-local.path
    842      cd ../
    843 
    844      echo ./makeorchidee_fcm -j $xios_orchid $opt_orc -parallel none -arch $arch
    845      ./makeorchidee_fcm -j 8 $xios_orchid $opt_orc -parallel none -arch $arch > $orchideelog 2>&1
    846      pwd
    847   else # of "if [ -d tools ]"
    848      if [ -d src_parallel ] ; then
    849        liste_src="parallel parameters global stomate sechiba driver"
    850        if [ "$veget_version" == "false" ] ; then veget_version=orchidee2.0 ; fi
    851      fi
    852      for d in $liste_src ; do src_d=src_$d
    853         echo src_d $src_d
    854         echo ls ; ls
    855         if [ ! -d $src_d ] ; then echo Problem orchidee : no $src_d ; exit ; fi
    856         cd $src_d ; \rm -f *.mod make ; $make clean
    857         $make > $orchideelog 2>&1 ; if [ "$compiler" = "$gfortran" -o "$compiler" = "mpif90" ] ; then cp -f *.mod ../../../lib ; fi
    858         cd ..
    859      done
    860   fi # of "if [ -d tools ]"
    861   echo install_lmdz.sh orchidee_compil_seq_OK `date`
     774    cd $MODEL/modipsl/modeles/ORCHIDEE
     775    set +e ; svn upgrade ; set -e
     776    if [ "$veget" = "CMIP6" ] ; then
     777        veget_version=orchidee2.0
     778        orchidee_rev=6592
     779    else # specific orchidee revision newer than CMIP6, on 2_1 or 2_2 branches
     780        veget_version=orchidee2.1
     781        orchidee_rev=$veget
     782        if [ $veget -lt 4465 ] ; then
     783            echo 'Stopping, ORCHIDEE version too old, script needs work on the CPP flags to pass to makelmdz'
     784            exit 1
     785        fi
     786        set +e
     787        # which branch is my version on?
     788        orcbranch=`svn log -v -q svn://forge.ipsl.jussieu.fr/orchidee/ -r $veget |grep ORCHIDEE |head -1| sed -e 's:ORCHIDEE/.*$:ORCHIDEE:' | awk '{print $2}'`
     789        # switch to that branch
     790        echo IF YOU INSTALL ORCHIDEE THE VERY FIRST TIME, ASK for PASSWORD at orchidee-help@listes.ipsl.fr
     791        svn switch -r $veget --accept theirs-full svn://forge.ipsl.jussieu.fr/orchidee/$orcbranch
     792        svn log -r $veget | grep  $veget
     793        if [  $? -gt 0 ] ; then
     794            echo 'Cannot update ORCHIDEE as not on the right branch for ORCHIDEE'
     795            exit
     796        fi
     797        set -e
     798        set +e ; svn update -r $veget ; set -e
     799    fi
     800    # Correctif suite debug Jean-Zay
     801    sed -i -e 's/9010  FORMAT(A52,F17.14)/9010  FORMAT(A52,F20.14)/' src_stomate/stomate.f90
     802    opt_orc="-prod" ; if [ "$optim" = "-debug" ] ; then opt_orc="-debug" ; fi
     803
     804    orchideelog=`pwd`/orchidee.log
     805    echo '########################################################'
     806    echo 'Compiling ORCHIDEE, the continental surface model '
     807    echo '########################################################'
     808    echo Start of the first compilation of orchidee, in sequential mode: `date`
     809    echo log file : $orchideelog
     810
     811    export ORCHPATH=`pwd`
     812    xios_orchid="-noxios"
     813    if [ "$with_xios" = "y" ] ; then
     814        xios_orchid="-xios"
     815    fi
     816    if [ -d tools ] ; then
     817        ###################################################################
     818        # Pour les experts qui voudraient changer de version d'orchidee.
     819        # Attention : necessite d'avoir le password pour orchidee
     820
     821        # Correctif suite debug Jean-Zay
     822        if [ -f src_global/time.f90 ] ; then sed -i -e 's/CALL tlen2itau/\!CALL tlen2itau/' src_global/time.f90 ; fi
     823        ###################################################################
     824        if [ "$veget_version" == "false" ] ; then veget_version=orchidee2.0 ; fi
     825        cd arch
     826        sed -e s:"%COMPILER        .*.$":"%COMPILER            $compiler":1 \
     827            -e s:"%LINK            .*.$":"%LINK                $compiler":1 \
     828            -e s:"%FPP_FLAGS       .*.$":"%FPP_FLAGS           $fpp_flags":1 \
     829            -e s:"%PROD_FFLAGS     .*.$":"%PROD_FFLAGS         $OPTIM":1 \
     830            -e s:"%DEV_FFLAGS      .*.$":"%DEV_FFLAGS          $OPTDEV":1 \
     831            -e s:"%DEBUG_FFLAGS    .*.$":"%DEBUG_FFLAGS        $OPTDEB":1 \
     832            -e s:"%BASE_FFLAGS     .*.$":"%BASE_FFLAGS         $OPTPREC":1 \
     833            -e s:"%BASE_LD         .*.$":"%BASE_LD             $BASE_LD":1 \
     834            -e s:"%ARFLAGS         .*.$":"%ARFLAGS             $ARFLAGS":1 \
     835            arch-gfortran.fcm > arch-local.fcm
     836        echo "NETCDF_LIBDIR=\"-L${ncdfdir}/lib -lnetcdff -lnetcdf\"" > arch-local.path
     837        echo "NETCDF_INCDIR=${ncdfdir}/include" >> arch-local.path
     838        echo "IOIPSL_INCDIR=$ORCHPATH/../../lib" >> arch-local.path
     839        echo "IOIPSL_LIBDIR=$ORCHPATH/../../lib" >> arch-local.path
     840        echo 'XIOS_INCDIR=${ORCHDIR}/../XIOS/inc' >> arch-local.path
     841        echo 'XIOS_LIBDIR="${ORCHDIR}/../XIOS/lib -lxios"' >> arch-local.path
     842        cd ../
     843
     844        echo ./makeorchidee_fcm -j $xios_orchid $opt_orc -parallel none -arch $arch
     845        ./makeorchidee_fcm -j 8 $xios_orchid $opt_orc -parallel none -arch $arch > $orchideelog 2>&1
     846        pwd
     847    else # of "if [ -d tools ]"
     848        if [ -d src_parallel ] ; then
     849            liste_src="parallel parameters global stomate sechiba driver"
     850            if [ "$veget_version" == "false" ] ; then veget_version=orchidee2.0 ; fi
     851        fi
     852        for d in $liste_src ; do src_d=src_$d
     853                                echo src_d $src_d
     854                                echo ls ; ls
     855                                if [ ! -d $src_d ] ; then echo Problem orchidee : no $src_d ; exit ; fi
     856                                cd $src_d ; \rm -f *.mod make ; $make clean
     857                                $make > $orchideelog 2>&1 ; if [ "$compiler" = "$gfortran" -o "$compiler" = "mpif90" ] ; then cp -f *.mod ../../../lib ; fi
     858                                cd ..
     859        done
     860    fi # of "if [ -d tools ]"
     861    echo install_lmdz.sh orchidee_compil_seq_OK `date`
    862862fi # of if [ "$veget" != 'NONE' ]
    863863
     
    866866# Ehouarn: the directory name LMDZ* depends on version/tar file...
    867867if [ -d $MODEL/modipsl/modeles/LMD* ] ; then
    868   echo '###############################################################'
    869   echo 'Preparing LMDZ compilation : arch file, svn switch if needed...'
    870   echo '###############################################################'
    871   cd $MODEL/modipsl/modeles/LMD*
    872   LMDZPATH=`pwd`
     868    echo '###############################################################'
     869    echo 'Preparing LMDZ compilation : arch file, svn switch if needed...'
     870    echo '###############################################################'
     871    cd $MODEL/modipsl/modeles/LMD*
     872    LMDZPATH=`pwd`
    873873else
    874   echo "ERROR: No LMD* directory !!!"
    875   exit
     874    echo "ERROR: No LMD* directory !!!"
     875    exit
    876876fi
    877877
     
    883883if [[ "$pclinux" = "1" && ! -f arch/arch-local.path ]] ; then
    884884
    885 # create local 'arch' files (if on Linux PC):
    886 cd arch
    887 # arch-local.path file
    888 echo "NETCDF_LIBDIR=\"-L${ncdfdir}/lib -lnetcdff -lnetcdf\"" > arch-local.path
    889 echo "NETCDF_INCDIR=-I${ncdfdir}/include" >> arch-local.path
    890 echo 'NETCDF95_INCDIR=$LMDGCM/../../include' >> arch-local.path
    891 echo 'NETCDF95_LIBDIR=$LMDGCM/../../lib' >> arch-local.path
    892 echo 'IOIPSL_INCDIR=$LMDGCM/../../lib' >> arch-local.path
    893 echo 'IOIPSL_LIBDIR=$LMDGCM/../../lib' >> arch-local.path
    894 echo 'XIOS_INCDIR=$LMDGCM/../XIOS/inc' >> arch-local.path
    895 echo 'XIOS_LIBDIR=$LMDGCM/../XIOS/lib' >> arch-local.path
    896 echo 'ORCH_INCDIR=$LMDGCM/../../lib' >> arch-local.path
    897 echo 'ORCH_LIBDIR=$LMDGCM/../../lib' >> arch-local.path
    898 
    899 if [ $pcmac == 1 ] ; then
    900     BASE_LD="$BASE_LD -Wl,-rpath,${ncdfdir}/lib"
    901 else
    902     BASE_LD="$BASE_LD -Wl,-rpath=${ncdfdir}/lib"
    903 fi
    904 # Arch-local.fcm file (adapted from arch-linux-32bit.fcm)
    905 
    906 if [ $real = r8 ] ; then FPP_DEF=NC_DOUBLE ; else FPP_DEF="" ; fi
    907 sed -e s:"%COMPILER        .*.$":"%COMPILER            $compiler":1 \
    908     -e s:"%LINK            .*.$":"%LINK                $compiler":1 \
    909     -e s:"%PROD_FFLAGS     .*.$":"%PROD_FFLAGS         $OPTIM":1 \
    910     -e s:"%DEV_FFLAGS      .*.$":"%DEV_FFLAGS          $OPTDEV":1 \
    911     -e s:"%DEBUG_FFLAGS    .*.$":"%DEBUG_FFLAGS        $OPTDEB":1 \
    912     -e s:"%BASE_FFLAGS     .*.$":"%BASE_FFLAGS         $OPTPREC":1 \
    913     -e s:"%FPP_DEF         .*.$":"%FPP_DEF             $FPP_DEF":1 \
    914     -e s:"%BASE_LD         .*.$":"%BASE_LD             $BASE_LD":1 \
    915     -e s:"%ARFLAGS         .*.$":"%ARFLAGS             $ARFLAGS":1 \
    916     arch-linux-32bit.fcm > arch-local.fcm
    917 
    918 cd ..
    919 ### Adapt "bld.cfg" (add the shell):
    920 #whereisthatshell=$(which ${use_shell})
    921 #echo "bld::tool::SHELL   $whereisthatshell" >> bld.cfg
     885    # create local 'arch' files (if on Linux PC):
     886    cd arch
     887    # arch-local.path file
     888    echo "NETCDF_LIBDIR=\"-L${ncdfdir}/lib -lnetcdff -lnetcdf\"" > arch-local.path
     889    echo "NETCDF_INCDIR=-I${ncdfdir}/include" >> arch-local.path
     890    echo 'NETCDF95_INCDIR=$LMDGCM/../../include' >> arch-local.path
     891    echo 'NETCDF95_LIBDIR=$LMDGCM/../../lib' >> arch-local.path
     892    echo 'IOIPSL_INCDIR=$LMDGCM/../../lib' >> arch-local.path
     893    echo 'IOIPSL_LIBDIR=$LMDGCM/../../lib' >> arch-local.path
     894    echo 'XIOS_INCDIR=$LMDGCM/../XIOS/inc' >> arch-local.path
     895    echo 'XIOS_LIBDIR=$LMDGCM/../XIOS/lib' >> arch-local.path
     896    echo 'ORCH_INCDIR=$LMDGCM/../../lib' >> arch-local.path
     897    echo 'ORCH_LIBDIR=$LMDGCM/../../lib' >> arch-local.path
     898
     899    if [ $pcmac == 1 ] ; then
     900        BASE_LD="$BASE_LD -Wl,-rpath,${ncdfdir}/lib"
     901    else
     902        BASE_LD="$BASE_LD -Wl,-rpath=${ncdfdir}/lib"
     903    fi
     904    # Arch-local.fcm file (adapted from arch-linux-32bit.fcm)
     905
     906    if [ $real = r8 ] ; then FPP_DEF=NC_DOUBLE ; else FPP_DEF="" ; fi
     907    sed -e s:"%COMPILER        .*.$":"%COMPILER            $compiler":1 \
     908        -e s:"%LINK            .*.$":"%LINK                $compiler":1 \
     909        -e s:"%PROD_FFLAGS     .*.$":"%PROD_FFLAGS         $OPTIM":1 \
     910        -e s:"%DEV_FFLAGS      .*.$":"%DEV_FFLAGS          $OPTDEV":1 \
     911        -e s:"%DEBUG_FFLAGS    .*.$":"%DEBUG_FFLAGS        $OPTDEB":1 \
     912        -e s:"%BASE_FFLAGS     .*.$":"%BASE_FFLAGS         $OPTPREC":1 \
     913        -e s:"%FPP_DEF         .*.$":"%FPP_DEF             $FPP_DEF":1 \
     914        -e s:"%BASE_LD         .*.$":"%BASE_LD             $BASE_LD":1 \
     915        -e s:"%ARFLAGS         .*.$":"%ARFLAGS             $ARFLAGS":1 \
     916        arch-linux-32bit.fcm > arch-local.fcm
     917
     918    cd ..
     919    ### Adapt "bld.cfg" (add the shell):
     920    #whereisthatshell=$(which ${use_shell})
     921    #echo "bld::tool::SHELL   $whereisthatshell" >> bld.cfg
    922922
    923923fi # of if [ "$pclinux" = 1 ]
     
    989989# sequential compilation
    990990if [ "$sequential" = 1 ] ; then
    991   echo Sequential compilation command, saved in compile.sh:
    992   echo "./$makelmdz $optim $OPT_MAKELMDZ $optim $opt_rad $opt_cosp -d ${grid_resolution} -v $veget_version gcm "
    993   echo "./$makelmdz $optim $OPT_MAKELMDZ $optim $opt_rad $opt_cosp -d ${grid_resolution} -v $veget_version gcm " > compile.sh
    994   chmod +x ./compile.sh
    995   if [ $bench = 1 ] ; then
    996     echo install_lmdz.sh start_lmdz_seq_compilation `date`
    997     echo log file: $lmdzlog
    998     ./compile.sh > $lmdzlog 2>&1
    999     echo install_lmdz.sh end_lmdz_seq_compilation `date`
    1000   fi
     991    echo Sequential compilation command, saved in compile.sh:
     992    echo "./$makelmdz $optim $OPT_MAKELMDZ $optim $opt_rad $opt_cosp -d ${grid_resolution} -v $veget_version gcm "
     993    echo "./$makelmdz $optim $OPT_MAKELMDZ $optim $opt_rad $opt_cosp -d ${grid_resolution} -v $veget_version gcm " > compile.sh
     994    chmod +x ./compile.sh
     995    if [ $bench = 1 ] ; then
     996        echo install_lmdz.sh start_lmdz_seq_compilation `date`
     997        echo log file: $lmdzlog
     998        ./compile.sh > $lmdzlog 2>&1
     999        echo install_lmdz.sh end_lmdz_seq_compilation `date`
     1000    fi
    10011001fi # fin sequential
    10021002
    10031003# compiling in parallel mode
    10041004if [ $parallel != "none" ] ; then
    1005   echo '##########################################################'
    1006   echo ' Parallel compile '
    1007   echo '##########################################################'
    1008   echo "(after saving the sequential libs and binaries)"
    1009   cd $MODEL/modipsl
    1010   tar cf sequential.tar bin/ lib/
    1011   \rm -rf bin/ lib/
    1012   tar xf ioipsl.tar
    1013   #
    1014   # Orchidee
    1015   #
    1016   cd $ORCHPATH
    1017   if [ -d src_parallel -a $veget != 'NONE' ] ; then
    1018      cd arch
    1019      sed  \
    1020      -e s:"%COMPILER.*.$":"%COMPILER            $par_comp":1 \
    1021      -e s:"%LINK.*.$":"%LINK                $par_comp":1 \
    1022      -e s:"%MPI_FFLAG.*.$":"%MPI_FFLAGS          $MPI_FLAGS":1 \
    1023      -e s:"%OMP_FFLAG.*.$":"%OMP_FFLAGS          $OMP_FLAGS":1 \
    1024      -e s:"%MPI_LD.*.$":"%MPI_LD              $MPI_LD":1 \
    1025      -e s:"%OMP_LD.*.$":"%OMP_LD              $OMP_LD":1 \
    1026      arch-local.fcm > tmp.fcm
    1027 
    1028      mv tmp.fcm arch-local.fcm
    1029      cd ../
    1030      echo Compiling ORCHIDEE in parallel mode `date`
    1031      echo logfile $orchideelog
    1032      echo "NOTE : to recompile it when necessary, use ./compile_orc.sh in modipsl/modeles/ORCHIDEE"
    1033      echo ./makeorchidee_fcm -j 8 -clean $xios_orchid $opt_orc -parallel $parallel -arch $arch > compile_orc.sh
    1034      echo ./makeorchidee_fcm -j 8 $xios_orchid $opt_orc -parallel $parallel -arch $arch >> compile_orc.sh
    1035      echo echo Now you must also recompile LMDZ, by running ./compile.sh in modeles/LMDZ >> compile_orc.sh
    1036      chmod u+x compile_orc.sh
    1037      ./makeorchidee_fcm -j 8 -clean $xios_orchid $opt_orc -parallel $parallel -arch $arch > $orchideelog 2>&1
    1038      ./makeorchidee_fcm -j 8 $xios_orchid $opt_orc -parallel $parallel -arch $arch >> $orchideelog 2>&1
    1039      echo End of ORCHIDEE compilation in parallel mode `date`
    1040   elif [ $veget != 'NONE' ] ; then
    10411005    echo '##########################################################'
    1042     echo ' Orchidee version too old                                 '
    1043     echo ' Please update to new version                             '
     1006    echo ' Parallel compile '
    10441007    echo '##########################################################'
    1045     exit
    1046   fi # of [ -d src_parallel -a $veget != 'NONE' ]
    1047 
    1048   # LMDZ
    1049   cd $LMDZPATH
    1050   if [ $arch = local ] ; then
    1051     cd arch
    1052     sed -e s:"%COMPILER.*.$":"%COMPILER            $par_comp":1 \
    1053     -e s:"%LINK.*.$":"%LINK                $par_comp":1 \
    1054     -e s:"%MPI_FFLAG.*.$":"%MPI_FFLAGS          $MPI_FLAGS":1 \
    1055     -e s:"%OMP_FFLAG.*.$":"%OMP_FFLAGS          $OMP_FLAGS":1 \
    1056     -e s:"%ARFLAGS.*.$":"%ARFLAGS          $ARFLAGS":1 \
    1057     -e s@"%BASE_LD.*.$"@"%BASE_LD             -Wl,-rpath=${root_mpi}/lib:${ncdfdir}/lib"@1 \
    1058     -e s:"%MPI_LD.*.$":"%MPI_LD              $MPI_LD":1 \
    1059     -e s:"%OMP_LD.*.$":"%OMP_LD              $OMP_LD":1 \
    1060     arch-local.fcm > tmp.fcm
    1061     mv tmp.fcm arch-local.fcm
    1062     cd ../
    1063   fi
    1064   rm -f compile.sh
    1065   echo resol=${grid_resolution} >> compile.sh
    1066   if [ ${hostname:0:5} = jean- -a "$cosp" = "v2" ] ; then
    1067 
    1068   echo LMDZ compilation command in parallel mode, saved in compile.sh, is :
    1069   echo "(ATTENTION le probleme de cospv2 sur jean-zay en mode prod n est pas corrige ! )"
    1070 # ATTENTION le probleme de cospv2 sur jean-zay en mode prod n est pas corrige
    1071      echo ./$makelmdz -dev $optim $OPT_MAKELMDZ $opt_rad $opt_cosp $opt_makelmdz_xios -d \$resol -v $veget_version -mem -parallel $parallel gcm >> compile.sh
    1072      echo ./$makelmdz -dev $optim $OPT_MAKELMDZ $opt_rad $opt_cosp $opt_makelmdz_xios -d \$resol -v $veget_version -mem -parallel $parallel gcm
    1073   else
    1074     echo ./$makelmdz $optim $OPT_MAKELMDZ $opt_rad $opt_cosp $opt_makelmdz_xios -d \$resol -v $veget_version -mem -parallel $parallel gcm >> compile.sh
    1075     echo ./$makelmdz $optim $OPT_MAKELMDZ $opt_rad $opt_cosp $opt_makelmdz_xios -d \$resol -v $veget_version -mem -parallel $parallel gcm
    1076   fi
    1077   chmod +x ./compile.sh
    1078 
    1079   if [ $bench = 1 ] ; then
    1080      echo Compiling LMDZ in parallel mode `date`,  LMDZ log file: $lmdzlog ; ./compile.sh > $lmdzlog 2>&1
    1081   fi
     1008    echo "(after saving the sequential libs and binaries)"
     1009    cd $MODEL/modipsl
     1010    tar cf sequential.tar bin/ lib/
     1011    \rm -rf bin/ lib/
     1012    tar xf ioipsl.tar
     1013    #
     1014    # Orchidee
     1015    #
     1016    cd $ORCHPATH
     1017    if [ -d src_parallel -a $veget != 'NONE' ] ; then
     1018        cd arch
     1019        sed  \
     1020            -e s:"%COMPILER.*.$":"%COMPILER            $par_comp":1 \
     1021            -e s:"%LINK.*.$":"%LINK                $par_comp":1 \
     1022            -e s:"%MPI_FFLAG.*.$":"%MPI_FFLAGS          $MPI_FLAGS":1 \
     1023            -e s:"%OMP_FFLAG.*.$":"%OMP_FFLAGS          $OMP_FLAGS":1 \
     1024            -e s:"%MPI_LD.*.$":"%MPI_LD              $MPI_LD":1 \
     1025            -e s:"%OMP_LD.*.$":"%OMP_LD              $OMP_LD":1 \
     1026            arch-local.fcm > tmp.fcm
     1027
     1028        mv tmp.fcm arch-local.fcm
     1029        cd ../
     1030        echo Compiling ORCHIDEE in parallel mode `date`
     1031        echo logfile $orchideelog
     1032        echo "NOTE : to recompile it when necessary, use ./compile_orc.sh in modipsl/modeles/ORCHIDEE"
     1033        echo ./makeorchidee_fcm -j 8 -clean $xios_orchid $opt_orc -parallel $parallel -arch $arch > compile_orc.sh
     1034        echo ./makeorchidee_fcm -j 8 $xios_orchid $opt_orc -parallel $parallel -arch $arch >> compile_orc.sh
     1035        echo echo Now you must also recompile LMDZ, by running ./compile.sh in modeles/LMDZ >> compile_orc.sh
     1036        chmod u+x compile_orc.sh
     1037        ./makeorchidee_fcm -j 8 -clean $xios_orchid $opt_orc -parallel $parallel -arch $arch > $orchideelog 2>&1
     1038        ./makeorchidee_fcm -j 8 $xios_orchid $opt_orc -parallel $parallel -arch $arch >> $orchideelog 2>&1
     1039        echo End of ORCHIDEE compilation in parallel mode `date`
     1040    elif [ $veget != 'NONE' ] ; then
     1041        echo '##########################################################'
     1042        echo ' Orchidee version too old                                 '
     1043        echo ' Please update to new version                             '
     1044        echo '##########################################################'
     1045        exit
     1046    fi # of [ -d src_parallel -a $veget != 'NONE' ]
     1047
     1048    # LMDZ
     1049    cd $LMDZPATH
     1050    if [ $arch = local ] ; then
     1051        cd arch
     1052        sed -e s:"%COMPILER.*.$":"%COMPILER            $par_comp":1 \
     1053            -e s:"%LINK.*.$":"%LINK                $par_comp":1 \
     1054            -e s:"%MPI_FFLAG.*.$":"%MPI_FFLAGS          $MPI_FLAGS":1 \
     1055            -e s:"%OMP_FFLAG.*.$":"%OMP_FFLAGS          $OMP_FLAGS":1 \
     1056            -e s:"%ARFLAGS.*.$":"%ARFLAGS          $ARFLAGS":1 \
     1057            -e s@"%BASE_LD.*.$"@"%BASE_LD             -Wl,-rpath=${root_mpi}/lib:${ncdfdir}/lib"@1 \
     1058            -e s:"%MPI_LD.*.$":"%MPI_LD              $MPI_LD":1 \
     1059            -e s:"%OMP_LD.*.$":"%OMP_LD              $OMP_LD":1 \
     1060            arch-local.fcm > tmp.fcm
     1061        mv tmp.fcm arch-local.fcm
     1062        cd ../
     1063    fi
     1064    rm -f compile.sh
     1065    echo resol=${grid_resolution} >> compile.sh
     1066    if [ ${hostname:0:5} = jean- -a "$cosp" = "v2" ] ; then
     1067
     1068        echo LMDZ compilation command in parallel mode, saved in compile.sh, is :
     1069        echo "(ATTENTION le probleme de cospv2 sur jean-zay en mode prod n est pas corrige ! )"
     1070        # ATTENTION le probleme de cospv2 sur jean-zay en mode prod n est pas corrige
     1071        echo ./$makelmdz -dev $optim $OPT_MAKELMDZ $opt_rad $opt_cosp $opt_makelmdz_xios -d \$resol -v $veget_version -mem -parallel $parallel gcm >> compile.sh
     1072        echo ./$makelmdz -dev $optim $OPT_MAKELMDZ $opt_rad $opt_cosp $opt_makelmdz_xios -d \$resol -v $veget_version -mem -parallel $parallel gcm
     1073    else
     1074        echo ./$makelmdz $optim $OPT_MAKELMDZ $opt_rad $opt_cosp $opt_makelmdz_xios -d \$resol -v $veget_version -mem -parallel $parallel gcm >> compile.sh
     1075        echo ./$makelmdz $optim $OPT_MAKELMDZ $opt_rad $opt_cosp $opt_makelmdz_xios -d \$resol -v $veget_version -mem -parallel $parallel gcm
     1076    fi
     1077    chmod +x ./compile.sh
     1078
     1079    if [ $bench = 1 ] ; then
     1080        echo Compiling LMDZ in parallel mode `date`,  LMDZ log file: $lmdzlog ; ./compile.sh > $lmdzlog 2>&1
     1081    fi
    10821082
    10831083fi # of if [ $parallel != "none" ]
     
    10971097
    10981098if [ "$gcm" = "" ] ; then
    1099   if [ $bench = 1 ] ; then
    1100     echo 'Compilation failed !! Cannot run the benchmark;'
    1101     exit
    1102   else
    1103     echo 'Compilation not done (only done when bench=1)'
    1104   fi
     1099    if [ $bench = 1 ] ; then
     1100        echo 'Compilation failed !! Cannot run the benchmark;'
     1101        exit
     1102    else
     1103        echo 'Compilation not done (only done when bench=1)'
     1104    fi
    11051105else
    1106    echo '##########################################################'
    1107    echo 'Compilation successfull !! ' `date`
    1108    echo '##########################################################'
    1109    echo The executable is $gcm
     1106    echo '##########################################################'
     1107    echo 'Compilation successfull !! ' `date`
     1108    echo '##########################################################'
     1109    echo The executable is $gcm
    11101110fi
    11111111
     
    11151115
    11161116if [ $bench = tuto ] ; then
    1117    myget Training/tutorial.tar ; tar xvf tutorial.tar ; cd TUTORIAL ; ./init.sh
     1117    myget Training/tutorial.tar ; tar xvf tutorial.tar ; cd TUTORIAL ; ./init.sh
    11181118
    11191119elif [[ $bench = 1 && ! -d BENCH${grid_resolution} ]] ; then
    1120    # TOUTE CETTE SECTION DEVRAIT DISPARAITRE POUR UNE COMMANDE
    1121    # OU DES BENCHS PAR MOTS CLES COMME tuto
    1122 
    1123    echo '##########################################################'
    1124    echo ' Running a test run '
    1125    echo '##########################################################'
    1126 
    1127    \rm -rf BENCH${grid_resolution}
    1128    bench=bench_lmdz_${grid_resolution}
    1129    echo install_lmdz.sh before bench download  `date`
    1130    #wget http://www.lmd.jussieu.fr/~lmdz/Distrib/$bench.tar.gz
    1131    myget 3DBenchs/$bench.tar.gz
    1132    echo install_lmdz.sh after bench download  `date`
    1133    tar xvf $bench.tar.gz
    1134 
    1135    if [ "$cosp" = "v1" -o "$cosp" = "v2" ] ; then
    1136      cd BENCH${grid_resolution}
    1137    # copier les fichiers namelist input et output our COSP
    1138      cp ../DefLists/cosp*_input_nl.txt .
    1139      cp ../DefLists/cosp*_output_nl.txt .
    1140    # Activer la cles ok_cosp pour tourner avec COSP
    1141      sed -e 's@ok_cosp=n@ok_cosp=y@' config.def > tmp
    1142       \mv -f tmp config.def
    1143      cd ..
    1144    fi
    1145 
    1146    if [ -n "$physiq" ]; then
    1147      cd BENCH${grid_resolution}
    1148      if [ -f physiq.def_${physiq} ]; then
    1149        cp physiq.def_${physiq} physiq.def
    1150        echo using physiq.def_${physiq}
    1151      else
    1152        echo using standard physiq.def
    1153      fi
    1154      cd ..
    1155    else
    1156      echo using standard physiq.def
    1157    fi
    1158 
    1159    if [ "$with_xios" = "y" ] ; then
    1160      cd BENCH${grid_resolution}
    1161      cp ../DefLists/iodef.xml .
    1162      cp ../DefLists/context_lmdz.xml .
    1163      cp ../DefLists/field_def_lmdz.xml .
    1164    # A raffiner par la suite
    1165      echo A FAIRE : Copier les *xml en fonction de l option cosp
    1166      cp ../DefLists/field_def_cosp*.xml .
    1167      cp ../DefLists/file_def_hist*xml .
    1168      # adapt iodef.xml to use attached mode
    1169      sed -e 's@"using_server" type="bool">true@"using_server" type="bool">false@' iodef.xml > tmp
    1170      \mv -f tmp iodef.xml
    1171 
    1172      # and convert all the enabled="_AUTO_" (for libIGCM) to enabled=.FALSE.
    1173      # except for histday
    1174      for histfile in file_def_hist*xml
    1175      do
    1176        if [ "$histfile" = "file_def_histday_lmdz.xml" ] ; then
    1177        sed -e 's@enabled="_AUTO_"@type="one_file" enabled=".TRUE."@' $histfile > tmp ; \mv -f tmp $histfile
    1178        sed -e 's@output_level="_AUTO_"@output_level="5"@' $histfile > tmp ; \mv -f tmp $histfile
    1179        sed -e 's@compression_level="2"@compression_level="0"@' $histfile > tmp ; \mv -f tmp $histfile
    1180        else
    1181        sed -e 's@enabled="_AUTO_"@type="one_file" enabled=".FALSE."@' $histfile > tmp ; \mv -f tmp $histfile
    1182        fi
    1183      done
    1184      # and add option "ok_all_xml=y" in config.def
    1185      echo "### XIOS outputs" >> config.def
    1186      echo 'ok_all_xml=.true.' >> config.def
    1187 
    1188      #activer les sorties pour Cosp
    1189      if [ "$cosp" = "v1" ] ; then
    1190       histfile=file_def_histdayCOSP_lmdz.xml
    1191       sed -e 's@enabled=".FALSE."@enabled=".TRUE."@' $histfile > tmp ; \mv -f tmp $histfile
    1192       sed -e 's@output_level="_AUTO_"@output_level="5"@' $histfile > tmp ; \mv -f tmp $histfile
    1193       sed -e 's@compression_level="2"@compression_level="0"@' $histfile > tmp ; \mv -f tmp $histfile
    1194      fi
    1195      if [ "$cosp" = "v2" ] ; then
    1196       histfile=file_def_histdayCOSPv2_lmdz.xml
    1197       sed -e 's@compression_level="2"@compression_level="0"@' $histfile > tmp ; \mv -f tmp $histfile
    1198       contextfile=context_lmdz.xml
    1199       sed -e 's@src="./file_def_histdayCOSP_lmdz.xml"@src="./file_def_histdayCOSPv2_lmdz.xml"@' $contextfile > tmp ; \mv -f tmp $contextfile
    1200       sed -e 's@src="./file_def_histmthCOSP_lmdz.xml"@src="./file_def_histmthCOSPv2_lmdz.xml"@' $contextfile > tmp ; \mv -f tmp $contextfile
    1201       sed -e 's@src="./file_def_histhfCOSP_lmdz.xml"@src="./file_def_histhfCOSPv2_lmdz.xml"@' $contextfile > tmp ; \mv -f tmp $contextfile
    1202       fieldfile=field_def_lmdz.xml
    1203       sed -e 's@field_def_cosp1.xml@field_def_cospv2.xml@' $fieldfile > tmp ; \mv -f tmp $fieldfile
    1204      fi
    1205 
    1206      cd ..
    1207    fi
    1208 
    1209    # Cas Bensh avec ecrad
    1210    if [ "$rad" = "ecrad" ] ; then
    1211      cd BENCH${grid_resolution}
    1212      cp  ../DefLists/namelist_ecrad .
    1213      cp -r ../libf/phylmd/ecrad/data .
    1214      cd ..
    1215    fi
    1216 
    1217    # Adjusting bench physiq.def to radiative code chosen
    1218    cd BENCH${grid_resolution}
    1219    sed -e 's/iflag_rrtm=.*.$/iflag_rrtm='$iflag_rrtm'/' -e 's/NSW=.*.$/NSW='$NSW'/' physiq.def > tmpdef
    1220    \mv tmpdef physiq.def
    1221    cd ..
    1222 
    1223    cp $gcm BENCH${grid_resolution}/gcm.e
    1224 
    1225    cd BENCH${grid_resolution}
    1226    # On cree le fichier bench.sh au besoin
    1227    # Dans le cas 48x36x39 le bench.sh existe deja en parallele
    1228 
    1229    if [ "$grid_resolution" = "48x36x39" ] ; then
    1230       echo On ne touche pas au bench.sh
    1231       # But we have to adapt "run_local.sh" for $mpirun
    1232       sed -e "s@mpirun@$mpirun@g" run_local.sh > tmp
    1233       mv -f tmp run_local.sh
    1234       chmod u=rwx run_local.sh
    1235    elif [ "${parallel:0:3}" = "mpi" ] ; then
    1236       # Lancement avec deux procs mpi et 2 openMP
    1237       echo "export OMP_STACKSIZE=800M" > bench.sh
    1238       if [ "${parallel:4:3}" = "omp" ] ; then
    1239         echo "export OMP_NUM_THREADS=2" >> bench.sh
    1240       fi
    1241       if [ "$cosp" = "v1" -o "$cosp" = "v2" ] ; then
    1242          if [ ${hostname:0:5} = jean- ] ; then
    1243         chmod +x ../arch.env
    1244            ../arch.env 
    1245            echo "ulimit -s 2000000" >> bench.sh
    1246          else
    1247            echo "ulimit -s 200000" >> bench.sh
    1248          fi     
    1249       else
    1250          echo "ulimit -s unlimited" >> bench.sh
    1251       fi
    1252       if [ ${hostname:0:5} = jean- ] ; then
    1253         . ../arch/arch-${arch}.env
    1254         echo "srun -n 2 -A $idris_acct@cpu gcm.e > listing  2>&1" >> bench.sh
    1255       else
    1256         echo "$mpirun -np 2 gcm.e > listing  2>&1" >> bench.sh
    1257       fi
    1258       # Add rebuild, using reb.sh if it is there
    1259       echo 'if [ -f reb.sh ] ; then' >> bench.sh
    1260       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
    1261       echo 'fi' >> bench.sh
    1262    else
    1263       echo "./gcm.e > listing  2>&1" > bench.sh
    1264    fi
    1265    # Getting orchidee stuff
    1266    if [ $veget == 'CMIP6' ] ; then
    1267        #echo 'myget 3DBenchs/BENCHorch11.tar.gz'
    1268        #myget 3DBenchs/BENCHorch11.tar.gz
    1269        #tar xvzf BENCHorch11.tar.gz
    1270        echo 'myget 3DBenchs/BENCHCMIP6.tar.gz'
    1271        myget 3DBenchs/BENCHCMIP6.tar.gz
    1272        tar xvzf BENCHCMIP6.tar.gz
    1273        sed -e "s:VEGET=n:VEGET=y:" config.def > tmp
    1274        mv -f tmp config.def
    1275        if [ "$with_xios" = "y" ] ; then
    1276          cp ../../ORCHIDEE/src_xml/context_orchidee.xml .
    1277          echo '<context id="orchidee" src="./context_orchidee.xml"/>' > add.tmp
    1278          cp ../../ORCHIDEE/src_xml/field_def_orchidee.xml .
    1279          cp ../../ORCHIDEE/src_xml/file_def_orchidee.xml .
    1280          cp ../../ORCHIDEE/src_xml/file_def_input_orchidee.xml .
    1281          if [ -f ../../ORCHIDEE/src_xml/context_input_orchidee.xml ] ; then
    1282         cp ../../ORCHIDEE/src_xml/context_input_orchidee.xml .
    1283         echo '<context id="orchidee" src="./context_input_orchidee.xml"/>' >> add.tmp
    1284          fi
    1285          sed -e '/id="LMDZ"/r add.tmp' iodef.xml > tmp
    1286          mv tmp iodef.xml
    1287          sed -e'{/sechiba1/ s/enabled="_AUTO_"/type="one_file" enabled=".TRUE."/}' file_def_orchidee.xml > tmp ; \mv -f tmp file_def_orchidee.xml
    1288          sed -e 's@enabled="_AUTO_"@type="one_file" enabled=".FALSE."@' file_def_orchidee.xml > tmp ; \mv -f tmp file_def_orchidee.xml
    1289          sed -e 's@output_level="_AUTO_"@output_level="1"@' file_def_orchidee.xml > tmp ; \mv -f tmp file_def_orchidee.xml
    1290          sed -e 's@output_freq="_AUTO_"@output_freq="1d"@' file_def_orchidee.xml > tmp ; \mv -f tmp file_def_orchidee.xml
    1291          sed -e 's@compression_level="4"@compression_level="0"@' file_def_orchidee.xml > tmp ; \mv -f tmp file_def_orchidee.xml
    1292          sed -e 's@XIOS_ORCHIDEE_OK = n@XIOS_ORCHIDEE_OK = y@' orchidee.def > tmp ; \mv -f tmp orchidee.def
    1293        fi
    1294    fi
    1295    echo EXECUTION DU BENCH
    1296    set +e
    1297    date ; ./bench.sh > out.bench 2>&1 ; date
    1298    set -e
    1299    tail listing
    1300 
    1301 
    1302    echo '##########################################################'
    1303    echo 'Simulation finished in' `pwd`
    1304       echo 'You have compiled with:'
    1305       cat ../compile.sh
    1306    if [ $parallel = "none" ] ; then
    1307      echo 'You may re-run it with : cd ' `pwd` ' ; gcm.e'
    1308      echo 'or ./bench.sh'
    1309    else
    1310      echo 'You may re-run it with : '
    1311      echo 'cd ' `pwd` '; ./bench.sh'
    1312    #  echo 'ulimit -s unlimited'
    1313    #  echo 'export OMP_NUM_THREADS=2'
    1314    #  echo 'export OMP_STACKSIZE=800M'
    1315    #  echo "$mpirun -np 2 gcm.e "
    1316    fi
    1317    echo '##########################################################'
     1120    # TOUTE CETTE SECTION DEVRAIT DISPARAITRE POUR UNE COMMANDE
     1121    # OU DES BENCHS PAR MOTS CLES COMME tuto
     1122
     1123    echo '##########################################################'
     1124    echo ' Running a test run '
     1125    echo '##########################################################'
     1126
     1127    \rm -rf BENCH${grid_resolution}
     1128    bench=bench_lmdz_${grid_resolution}
     1129    echo install_lmdz.sh before bench download  `date`
     1130    #wget http://www.lmd.jussieu.fr/~lmdz/Distrib/$bench.tar.gz
     1131    myget 3DBenchs/$bench.tar.gz
     1132    echo install_lmdz.sh after bench download  `date`
     1133    tar xvf $bench.tar.gz
     1134
     1135    if [ "$cosp" = "v1" -o "$cosp" = "v2" ] ; then
     1136        cd BENCH${grid_resolution}
     1137        # copier les fichiers namelist input et output our COSP
     1138        cp ../DefLists/cosp*_input_nl.txt .
     1139        cp ../DefLists/cosp*_output_nl.txt .
     1140        # Activer la cles ok_cosp pour tourner avec COSP
     1141        sed -e 's@ok_cosp=n@ok_cosp=y@' config.def > tmp
     1142        \mv -f tmp config.def
     1143        cd ..
     1144    fi
     1145
     1146    if [ -n "$physiq" ]; then
     1147        cd BENCH${grid_resolution}
     1148        if [ -f physiq.def_${physiq} ]; then
     1149            cp physiq.def_${physiq} physiq.def
     1150            echo using physiq.def_${physiq}
     1151        else
     1152            echo using standard physiq.def
     1153        fi
     1154        cd ..
     1155    else
     1156        echo using standard physiq.def
     1157    fi
     1158
     1159    if [ "$with_xios" = "y" ] ; then
     1160        cd BENCH${grid_resolution}
     1161        cp ../DefLists/iodef.xml .
     1162        cp ../DefLists/context_lmdz.xml .
     1163        cp ../DefLists/field_def_lmdz.xml .
     1164        # A raffiner par la suite
     1165        echo A FAIRE : Copier les *xml en fonction de l option cosp
     1166        cp ../DefLists/field_def_cosp*.xml .
     1167        cp ../DefLists/file_def_hist*xml .
     1168        # adapt iodef.xml to use attached mode
     1169        sed -e 's@"using_server" type="bool">true@"using_server" type="bool">false@' iodef.xml > tmp
     1170        \mv -f tmp iodef.xml
     1171
     1172        # and convert all the enabled="_AUTO_" (for libIGCM) to enabled=.FALSE.
     1173        # except for histday
     1174        for histfile in file_def_hist*xml
     1175        do
     1176            if [ "$histfile" = "file_def_histday_lmdz.xml" ] ; then
     1177                sed -e 's@enabled="_AUTO_"@type="one_file" enabled=".TRUE."@' $histfile > tmp ; \mv -f tmp $histfile
     1178                sed -e 's@output_level="_AUTO_"@output_level="5"@' $histfile > tmp ; \mv -f tmp $histfile
     1179                sed -e 's@compression_level="2"@compression_level="0"@' $histfile > tmp ; \mv -f tmp $histfile
     1180            else
     1181                sed -e 's@enabled="_AUTO_"@type="one_file" enabled=".FALSE."@' $histfile > tmp ; \mv -f tmp $histfile
     1182            fi
     1183        done
     1184        # and add option "ok_all_xml=y" in config.def
     1185        echo "### XIOS outputs" >> config.def
     1186        echo 'ok_all_xml=.true.' >> config.def
     1187
     1188        #activer les sorties pour Cosp
     1189        if [ "$cosp" = "v1" ] ; then
     1190            histfile=file_def_histdayCOSP_lmdz.xml
     1191            sed -e 's@enabled=".FALSE."@enabled=".TRUE."@' $histfile > tmp ; \mv -f tmp $histfile
     1192            sed -e 's@output_level="_AUTO_"@output_level="5"@' $histfile > tmp ; \mv -f tmp $histfile
     1193            sed -e 's@compression_level="2"@compression_level="0"@' $histfile > tmp ; \mv -f tmp $histfile
     1194        fi
     1195        if [ "$cosp" = "v2" ] ; then
     1196            histfile=file_def_histdayCOSPv2_lmdz.xml
     1197            sed -e 's@compression_level="2"@compression_level="0"@' $histfile > tmp ; \mv -f tmp $histfile
     1198            contextfile=context_lmdz.xml
     1199            sed -e 's@src="./file_def_histdayCOSP_lmdz.xml"@src="./file_def_histdayCOSPv2_lmdz.xml"@' $contextfile > tmp ; \mv -f tmp $contextfile
     1200            sed -e 's@src="./file_def_histmthCOSP_lmdz.xml"@src="./file_def_histmthCOSPv2_lmdz.xml"@' $contextfile > tmp ; \mv -f tmp $contextfile
     1201            sed -e 's@src="./file_def_histhfCOSP_lmdz.xml"@src="./file_def_histhfCOSPv2_lmdz.xml"@' $contextfile > tmp ; \mv -f tmp $contextfile
     1202            fieldfile=field_def_lmdz.xml
     1203            sed -e 's@field_def_cosp1.xml@field_def_cospv2.xml@' $fieldfile > tmp ; \mv -f tmp $fieldfile
     1204        fi
     1205
     1206        cd ..
     1207    fi
     1208
     1209    # Cas Bensh avec ecrad
     1210    if [ "$rad" = "ecrad" ] ; then
     1211        cd BENCH${grid_resolution}
     1212        cp  ../DefLists/namelist_ecrad .
     1213        cp -r ../libf/phylmd/ecrad/data .
     1214        cd ..
     1215    fi
     1216
     1217    # Adjusting bench physiq.def to radiative code chosen
     1218    cd BENCH${grid_resolution}
     1219    sed -e 's/iflag_rrtm=.*.$/iflag_rrtm='$iflag_rrtm'/' -e 's/NSW=.*.$/NSW='$NSW'/' physiq.def > tmpdef
     1220    \mv tmpdef physiq.def
     1221    cd ..
     1222
     1223    cp $gcm BENCH${grid_resolution}/gcm.e
     1224
     1225    cd BENCH${grid_resolution}
     1226    # On cree le fichier bench.sh au besoin
     1227    # Dans le cas 48x36x39 le bench.sh existe deja en parallele
     1228
     1229    if [ "$grid_resolution" = "48x36x39" ] ; then
     1230        echo On ne touche pas au bench.sh
     1231        # But we have to adapt "run_local.sh" for $mpirun
     1232        sed -e "s@mpirun@$mpirun@g" run_local.sh > tmp
     1233        mv -f tmp run_local.sh
     1234        chmod u=rwx run_local.sh
     1235    elif [ "${parallel:0:3}" = "mpi" ] ; then
     1236        # Lancement avec deux procs mpi et 2 openMP
     1237        echo "export OMP_STACKSIZE=800M" > bench.sh
     1238        if [ "${parallel:4:3}" = "omp" ] ; then
     1239            echo "export OMP_NUM_THREADS=2" >> bench.sh
     1240        fi
     1241        if [ "$cosp" = "v1" -o "$cosp" = "v2" ] ; then
     1242            if [ ${hostname:0:5} = jean- ] ; then
     1243                chmod +x ../arch.env
     1244                ../arch.env     
     1245                echo "ulimit -s 2000000" >> bench.sh
     1246            else
     1247                echo "ulimit -s 200000" >> bench.sh
     1248            fi 
     1249        else
     1250            echo "ulimit -s unlimited" >> bench.sh
     1251        fi
     1252        if [ ${hostname:0:5} = jean- ] ; then
     1253            . ../arch/arch-${arch}.env
     1254            echo "srun -n 2 -A $idris_acct@cpu gcm.e > listing  2>&1" >> bench.sh
     1255        else
     1256            echo "$mpirun -np 2 gcm.e > listing  2>&1" >> bench.sh
     1257        fi
     1258        # Add rebuild, using reb.sh if it is there
     1259        echo 'if [ -f reb.sh ] ; then' >> bench.sh
     1260        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
     1261        echo 'fi' >> bench.sh
     1262    else
     1263        echo "./gcm.e > listing  2>&1" > bench.sh
     1264    fi
     1265    # Getting orchidee stuff
     1266    if [ $veget == 'CMIP6' ] ; then
     1267        #echo 'myget 3DBenchs/BENCHorch11.tar.gz'
     1268        #myget 3DBenchs/BENCHorch11.tar.gz
     1269        #tar xvzf BENCHorch11.tar.gz
     1270        echo 'myget 3DBenchs/BENCHCMIP6.tar.gz'
     1271        myget 3DBenchs/BENCHCMIP6.tar.gz
     1272        tar xvzf BENCHCMIP6.tar.gz
     1273        sed -e "s:VEGET=n:VEGET=y:" config.def > tmp
     1274        mv -f tmp config.def
     1275        if [ "$with_xios" = "y" ] ; then
     1276            cp ../../ORCHIDEE/src_xml/context_orchidee.xml .
     1277            echo '<context id="orchidee" src="./context_orchidee.xml"/>' > add.tmp
     1278            cp ../../ORCHIDEE/src_xml/field_def_orchidee.xml .
     1279            cp ../../ORCHIDEE/src_xml/file_def_orchidee.xml .
     1280            cp ../../ORCHIDEE/src_xml/file_def_input_orchidee.xml .
     1281            if [ -f ../../ORCHIDEE/src_xml/context_input_orchidee.xml ] ; then
     1282                cp ../../ORCHIDEE/src_xml/context_input_orchidee.xml .
     1283                echo '<context id="orchidee" src="./context_input_orchidee.xml"/>' >> add.tmp
     1284            fi
     1285            sed -e '/id="LMDZ"/r add.tmp' iodef.xml > tmp
     1286            mv tmp iodef.xml
     1287            sed -e'{/sechiba1/ s/enabled="_AUTO_"/type="one_file" enabled=".TRUE."/}' file_def_orchidee.xml > tmp ; \mv -f tmp file_def_orchidee.xml
     1288            sed -e 's@enabled="_AUTO_"@type="one_file" enabled=".FALSE."@' file_def_orchidee.xml > tmp ; \mv -f tmp file_def_orchidee.xml
     1289            sed -e 's@output_level="_AUTO_"@output_level="1"@' file_def_orchidee.xml > tmp ; \mv -f tmp file_def_orchidee.xml
     1290            sed -e 's@output_freq="_AUTO_"@output_freq="1d"@' file_def_orchidee.xml > tmp ; \mv -f tmp file_def_orchidee.xml
     1291            sed -e 's@compression_level="4"@compression_level="0"@' file_def_orchidee.xml > tmp ; \mv -f tmp file_def_orchidee.xml
     1292            sed -e 's@XIOS_ORCHIDEE_OK = n@XIOS_ORCHIDEE_OK = y@' orchidee.def > tmp ; \mv -f tmp orchidee.def
     1293        fi
     1294    fi
     1295    echo EXECUTION DU BENCH
     1296    set +e
     1297    date ; ./bench.sh > out.bench 2>&1 ; date
     1298    set -e
     1299    tail listing
     1300
     1301
     1302    echo '##########################################################'
     1303    echo 'Simulation finished in' `pwd`
     1304    echo 'You have compiled with:'
     1305    cat ../compile.sh
     1306    if [ $parallel = "none" ] ; then
     1307        echo 'You may re-run it with : cd ' `pwd` ' ; gcm.e'
     1308        echo 'or ./bench.sh'
     1309    else
     1310        echo 'You may re-run it with : '
     1311        echo 'cd ' `pwd` '; ./bench.sh'
     1312        #  echo 'ulimit -s unlimited'
     1313        #  echo 'export OMP_NUM_THREADS=2'
     1314        #  echo 'export OMP_STACKSIZE=800M'
     1315        #  echo "$mpirun -np 2 gcm.e "
     1316    fi
     1317    echo '##########################################################'
    13181318
    13191319fi # bench
     
    13251325
    13261326if [ $SCM = 1 ] ; then
    1327 cd $MODEL
    1328 #wget http://www.lmd.jussieu.fr/~lmdz/Distrib/1D.tar.gz
    1329 myget 1D/1D.tar.gz
    1330 tar xvf 1D.tar.gz
    1331 cd 1D
    1332 ./run.sh -rad $rad
     1327    cd $MODEL
     1328    #wget http://www.lmd.jussieu.fr/~lmdz/Distrib/1D.tar.gz
     1329    myget 1D/1D.tar.gz
     1330    tar xvf 1D.tar.gz
     1331    cd 1D
     1332    ./run.sh -rad $rad
    13331333fi
    13341334#set -vx
Note: See TracChangeset for help on using the changeset viewer.