Changeset 4862 for BOL


Ignore:
Timestamp:
Mar 21, 2024, 3:19:06 PM (8 months ago)
Author:
abarral
Message:

(WIP)
turn blocks into functions
auto-detect netcdf dir if -netcdf 0
compile IOIPSL via fcm

File:
1 edited

Legend:

Unmodified
Added
Removed
  • BOL/script_install_amaury/install_lmdz.sh

    r4861 r4862  
    3636###########################################################################
    3737
    38 echo install_lmdz.sh DEBUT "$(date)"
    39 
    40 ################################################################
    41 # Choice of installation options
    42 ################################################################
    43 
    44 ################################################################
    45 # A function to fetch files either locally or on the internet
    46 ################################################################
    47 function myget { #1st and only argument should be file name
     38### Functions
     39
     40function myget {
     41    # A function to fetch files either locally or on the internet
     42
     43    local file_name=$1
    4844    # Path on local computer where to look for the datafile
    49     if [[ -f /u/lmdz/WWW/LMDZ/pub/$1 ]]; then
    50         \cp -f -p "/u/lmdz/WWW/LMDZ/pub/$1" .
    51     elif [[ -f ~/LMDZ/pub/$1 ]]; then
    52         \cp -f -p ~"/LMDZ/pub/$1" .
     45    if [[ -f "/u/lmdz/WWW/LMDZ/pub/$file_name" ]]; then
     46        \cp -f -p "/u/lmdz/WWW/LMDZ/pub/$file_name" .
     47    elif [[ -f ~"/LMDZ/pub/$file_name" ]]; then
     48        \cp -f -p ~"/LMDZ/pub/$file_name" .
    5349    else
    54         wget --no-check-certificate -nv "http://lmdz.lmd.jussieu.fr/pub/$1"
    55         save_pub_locally=0
    56         if [[ $save_pub_locally = 1 ]]; then # saving wget files on ~/LMDZ/pub
    57             dir=~"/LMDZ/pub/$(dirname "$1")"; mkdir -p "$dir"
    58             cp -r "$(basename "$1")" "$dir"
    59         fi
     50        wget --no-check-certificate -nv "http://lmdz.lmd.jussieu.fr/pub/$file_name"
    6051    fi
    6152}
    6253
    63 # 04_2021 : tester si r4 marche encore !
    64 real="r8"  # ou "r4"
    65 
    66 
    67 #########################################################################
    68 # Valeur par défaut des parametres
    69 #########################################################################
    70 svn=""
    71 version="20231022.trunk"
    72 
    73 getlmdzor=1
    74 netcdf=1   #  1: for automatic installation;
    75 #          or 0: do not install NetCDF and look for it in standard locations;
    76 #          or absolute path: look for NetCDF there
    77 check_software_linux=1
    78 ioipsl=1
    79 bench=1
    80 pclinux=1
    81 pcmac=0 # default: not on a Mac
    82 compiler="gfortran"
    83 if [[ $(gfortran -dumpversion | cut -d. -f1) -ge 10 ]]; then allow_arg_mismatch="-fallow-argument-mismatch"; fi
    84 SCM=0
    85 # surface/vegetation scheme treatment
    86 # controlled by the single variable veget which can have the following values
    87 # - NONE: bucket scheme (default)
    88 # - CMIP6: orchidee version used in CMIP exercise, rev 5661
    89 # - number: orchidee version number
    90 veget="NONE"
    91 # choose the resolution for the bench runs
    92 # grid_resolution= 32x24x11 or 48x36x19 for tests (test without ORCHIDEE)
    93 #                  96x71x19  standard configuration
    94 grid_resolution="144x142x79"
    95 grid_resolution="96x95x39"
    96 grid_resolution="48x36x19"
    97 grid_resolution="32x32x39"
    98 # choose the physiq version you want to test
    99 #physiq=NPv6.0.14splith
    100 physiq=""
    101 
    102 ## parallel can take the values none/mpi/omp/mpi_omp
    103 parallel="mpi_omp"
    104 parallel="none"
    105 idris_acct="lmd"
    106 trusting="testing"
    107 OPT_GPROF=""
    108 OPT_MAKELMDZ=""
    109 MODEL=""
    110 
    111 ## also compile XIOS? (and more recent NetCDF/HDF5 libraries) Default=no
    112 with_xios="n"
    113 opt_makelmdz_xios=""
    114 
    115 ## compile with oldrad/rrtm/ecrad radiatif code (Default=rrtm)
    116 rad="rrtm"
    117 
    118 ## compile_with_fcm=1 : use makelmdz_fcm (1) or makelmdz (0)
    119 compile_with_fcm=1
    120 
    121 #Compilation with Cosp (cosp=NONE/v1/v2; default=NONE)
    122 cosp="NONE"
    123 opt_cosp=""
    124 
    125 # Check if on a Mac
    126 if [[ $(uname) = "Darwin" ]]; then
    127     pcmac=1
    128     export MAKE=make
    129 fi
    130 
    131 env_file=""
    132 optim=""
    133 
    134 #########################################################################
    135 #  Options interactives
    136 #########################################################################
    137 while (($# > 0))
    138 do
    139     case $1 in
    140         "-h") cat <<........fin
    141     $0 [ -v version ] [ -r svn_release ]
    142            [ -parallel PARA ] [ -d GRID_RESOLUTION ] [ -bench 0/1 ]
    143            [-name LOCAL_MODEL_NAME] [-gprof] [-opt_makelmdz] [-rad RADIATIF]
    144 
    145     -v       "version" like 20150828.trunk
    146              see http://www.lmd.jussieu.fr/~lmdz/Distrib/LISMOI.trunk
    147 
    148     -r       "svn_release" : either the svn release number or "last"
    149 
    150     -compiler gfortran|ifort|pgf90 (default: gfortran)
    151 
    152     -parallel PARA : can be mpi_omp (mpi with openMP) or none (for sequential)
    153 
    154     -d        GRID_RESOLUTION should be among the available benchs if -bench 1
    155               among which : 48x36x19, 48x36x39
    156               if wanting to run a bench simulation in addition to compilation
    157               default : 48x36x19
    158 
    159     -bench     activating the bench or not (0/1). Default 1
    160 
    161     -testing/unstable
    162 
    163     -name      LOCAL_MODEL_NAME : default = LMDZversion.release
    164 
    165     -netcdf    0, 1 or PATH
    166                    0: do not download NetCDF, look for it in standard locations
    167                1: download and compile NetCDF
    168                    PATH: full path to an existing installed NetCDF library
    169 
    170     -xios      also download and compile the XIOS library
    171                (requires the NetCDF4-HDF5 library, also installed by default)
    172                (requires to also have -parallel mpi_omp)
    173 
    174     -gprof     to compile with -pg to enable profiling with gprof
    175 
    176     -cosp      to run without our with cospv1 or cospv2 [none/v1/v2]
    177 
    178     -rad RADIATIF can be oldrad, rrtm or ecrad radiatif code
    179 
    180     -nofcm     to compile without fcm
    181 
    182     -SCM        install 1D version automatically
    183 
    184     -debug      compile everything in debug mode
    185 
    186     -opt_makelmdz     to call makelmdz or makelmdz_fcm with additional options
    187 
    188     -physiq    to choose which physics package to use
    189 
    190     -env_file  specify an arch.env file to overwrite the existing one
    191 
    192     -veget surface model to run [NONE/CMIP6/xxxx]
     54function set_default_params {
     55    # Valeur par défaut des parametres
     56
     57    # 04_2021 : tester si r4 marche encore !
     58    real="r8"  # ou "r4"
     59
     60    svn=""
     61    version="20231022.trunk"
     62
     63    getlmdzor=1
     64    netcdf=1   #  1: for automatic installation;
     65    #          or 0: do not install NetCDF and look for it in standard locations;
     66    #          or absolute path: look for NetCDF there
     67    check_software_linux=1
     68    ioipsl=1
     69    bench=1
     70    pclinux=1
     71    pcmac=0 # default: not on a Mac
     72    compiler="gfortran"
     73    if [[ $(gfortran -dumpversion | cut -d. -f1) -ge 10 ]]; then allow_arg_mismatch="-fallow-argument-mismatch"; fi
     74    SCM=0
     75    # surface/vegetation scheme treatment
     76    # controlled by the single variable veget which can have the following values
     77    # - NONE: bucket scheme (default)
     78    # - CMIP6: orchidee version used in CMIP exercise, rev 5661
     79    # - number: orchidee version number
     80    veget="NONE"
     81    # choose the resolution for the bench runs
     82    # grid_resolution= 32x24x11 or 48x36x19 for tests (test without ORCHIDEE)
     83    #                  96x71x19  standard configuration
     84    grid_resolution="32x32x39"  # "48x36x19", "96x95x39", "144x142x79"
     85    # choose the physiq version you want to test
     86    #physiq=NPv6.0.14splith
     87    physiq=""
     88
     89    ## parallel can take the values none/mpi/omp/mpi_omp
     90    parallel="none"  # "mpi_omp"
     91    idris_acct="lmd"
     92    trusting="testing"
     93    OPT_GPROF=""
     94    OPT_MAKELMDZ=""
     95    MODEL=""
     96
     97    ## also compile XIOS? (and more recent NetCDF/HDF5 libraries) Default=no
     98    with_xios="n"
     99    opt_makelmdz_xios=""
     100
     101    ## compile with oldrad/rrtm/ecrad radiatif code (Default=rrtm)
     102    rad="rrtm"
     103
     104    ## compile_with_fcm=1 : use makelmdz_fcm (1) or makelmdz (0)
     105    compile_with_fcm=1
     106
     107    #Compilation with Cosp (cosp=NONE/v1/v2; default=NONE)
     108    cosp="NONE"
     109    opt_cosp=""
     110
     111    # Check if on a Mac
     112    if [[ $(uname) = "Darwin" ]]; then
     113        pcmac=1
     114        export MAKE="make"
     115    fi
     116
     117    env_file=""
     118    optim=""
     119    arch="local"
     120
     121    local mpi_file
     122    mpi_file=$(readlink -f "$(which mpif90)")
     123    path_mpi=$(dirname "$mpi_file")
     124    root_mpi=$(dirname "$path_mpi")
     125}
     126
     127function read_cmdline_args {
     128    while (($# > 0)); do
     129        case $1 in
     130            "-h") cat <<........fin
     131        $0 [ -v version ] [ -r svn_release ]
     132               [ -parallel PARA ] [ -d GRID_RESOLUTION ] [ -bench 0/1 ]
     133               [-name LOCAL_MODEL_NAME] [-gprof] [-opt_makelmdz] [-rad RADIATIF]
     134
     135        -v       "version" like 20150828.trunk
     136                 see http://www.lmd.jussieu.fr/~lmdz/Distrib/LISMOI.trunk
     137
     138        -r       "svn_release" : either the svn release number or "last"
     139
     140        -compiler gfortran|ifort|pgf90 (default: gfortran)
     141
     142        -parallel PARA : can be mpi_omp (mpi with openMP) or none (for sequential)
     143
     144        -d        GRID_RESOLUTION should be among the available benchs if -bench 1
     145                  among which : 48x36x19, 48x36x39
     146                  if wanting to run a bench simulation in addition to compilation
     147                  default : 48x36x19
     148
     149        -bench     activating the bench or not (0/1). Default 1
     150
     151        -testing/unstable
     152
     153        -name      LOCAL_MODEL_NAME : default = LMDZversion.release
     154
     155        -netcdf    0, 1 or PATH
     156                       0: do not download NetCDF, look for it in standard locations
     157                   1: download and compile NetCDF
     158                       PATH: full path to an existing installed NetCDF library
     159
     160        -xios      also download and compile the XIOS library
     161                   (requires the NetCDF4-HDF5 library, also installed by default)
     162                   (requires to also have -parallel mpi_omp)
     163
     164        -gprof     to compile with -pg to enable profiling with gprof
     165
     166        -cosp      to run without our with cospv1 or cospv2 [none/v1/v2]
     167
     168        -rad RADIATIF can be oldrad, rrtm or ecrad radiatif code
     169
     170        -nofcm     to compile without fcm
     171
     172        -SCM        install 1D version automatically
     173
     174        -debug      compile everything in debug mode
     175
     176        -opt_makelmdz     to call makelmdz or makelmdz_fcm with additional options
     177
     178        -physiq    to choose which physics package to use
     179
     180        -env_file  specify an arch.env file to overwrite the existing one
     181
     182        -veget surface model to run [NONE/CMIP6/xxxx]
    193183
    194184........fin
    195               exit 1;;
    196         "-v") version=$2; shift; shift;;
    197         "-r") svn=$2; shift; shift;;
    198         "-compiler") compiler=$2
    199                      case $compiler in
    200                          "gfortran"|"ifort"|"pgf90") compiler=$2; shift
    201                                                      shift;;
    202                          *) echo "Only gfortran , ifort or pgf90 for the " \
    203                                  "compiler option"
    204                             exit 1
     185                  exit 1;;
     186            "-v") version=$2; shift; shift;;
     187            "-r") svn=$2; shift; shift;;
     188            "-compiler") compiler=$2
     189                         case $compiler in
     190                             "gfortran"|"ifort"|"pgf90") compiler=$2; shift
     191                                                         shift;;
     192                             *) echo "Only gfortran , ifort or pgf90 for the " \
     193                                     "compiler option"
     194                                exit 1
     195                         esac;;
     196            "-d") grid_resolution=$2; shift; shift;;
     197            "-gprof") OPT_GPROF="-pg"; shift;;
     198            "-unstable"|"-testing") trusting=$(echo "$1" | cut -c2-) ; shift;;
     199            "-cosp") cosp=$2
     200                     case $cosp in
     201                         "none"|"v1"|"v2") cosp=$2; shift; shift;;
     202                         *) echo "Only none v1 v2 for cosp option"; exit 1
    205203                     esac;;
    206         "-d") grid_resolution=$2; shift; shift;;
    207         "-gprof") OPT_GPROF="-pg"; shift;;
    208         "-unstable"|"-testing") trusting=$(echo "$1" | cut -c2-) ; shift;;
    209         "-cosp") cosp=$2
    210                  case $cosp in
    211                      "none"|"v1"|"v2") cosp=$2; shift; shift;;
    212                      *) echo Only none v1 v2 for cosp option; exit 1
    213                  esac;;
    214         "-nofcm") compile_with_fcm=0; echo This option will be reactivated soon '(promesse du 8dec2022)'; exit 1;  shift;;
    215         "-SCM") SCM=1; shift;;
    216         "-opt_makelmdz") OPT_MAKELMDZ="$2"; shift; shift;;
    217         "-rrtm") if [[ $2 = "false" ]]; then
    218                      rad="oldrad"
    219                  else
    220                      rad="rrtm"
    221                  fi
    222                  shift; shift;;
    223         "-rad") rad=$2
    224                 case $rad in
    225                     "oldrad"|"rrtm"|"ecrad") rad=$2; shift; shift;;
    226                     *) echo "Only oldrad rrtm ecrad for rad option"; exit 1
    227                 esac;;
    228         "-parallel") parallel=$2
    229                      case $parallel in
    230                          "none"|"mpi"|"omp"|"mpi_omp") parallel=$2; shift
    231                                                        shift;;
    232                          *) echo "Only none mpi omp mpi_omp for the parallel option"
    233                             exit 1
    234                      esac;;
    235         "-bench") bench=$2; shift; shift;;
    236         "-debug") optim=-debug; shift;;
    237         "-name") MODEL=$2; shift; shift;;
    238         "-netcdf") netcdf=$2; shift; shift;;
    239         "-physiq") physiq=$2; shift; shift;;
    240         "-xios") with_xios="y"; shift;;
    241         "-env_file") env_file=$2; shift; shift;;
    242         "-veget") veget=$2; shift; shift;;
    243         *)  bash install_lmdz.sh -h; exit 1
     204            "-nofcm") compile_with_fcm=0; echo "This option will be reactivated soon (promesse du 8dec2022)"; exit 1;  shift;;
     205            "-SCM") SCM=1; shift;;
     206            "-opt_makelmdz") OPT_MAKELMDZ="$2"; shift; shift;;
     207            "-rrtm") if [[ $2 = "false" ]]; then
     208                         rad="oldrad"
     209                     else
     210                         rad="rrtm"
     211                     fi
     212                     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 1
     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 1
     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            *)  bash install_lmdz.sh -h; exit 1
     232        esac
     233    done
     234
     235    # Option de compilation pour Cosp
     236    case $cosp in
     237        v1) opt_cosp="-cosp true";;
     238        v2) opt_cosp="-cospv2 true";;
     239        *) opt_cosp=""
    244240    esac
    245 done
    246 
    247 # Option de compilation du rayonnement : depend de $mysvn ><= r4185,
    248 # sera donc definie plus bas
    249 
    250 #opt_rad=""
    251 #case $rad in
    252 #   rrtm) opt_rad="-rad rrtm";;
    253 #   ecrad) opt_rad="-rad ecrad";;
    254 #esac
    255 
    256 
    257 # Option de compilation pour Cosp
    258 opt_cosp=""
    259 case $cosp in
    260     v1) opt_cosp="-cosp true";;
    261     v2) opt_cosp="-cospv2 true";;
    262 esac
    263 
    264 # Check on veget version
    265 if [[ $veget != 'NONE' && $veget != "CMIP6" ]]; then
    266     re='^[0-9]+$'
    267     if ! [[ $veget =~ $re ]]; then
    268         echo 'Valeur de l option veget non valable'
     241
     242    # Check on veget version
     243    if [[ $veget != 'NONE' && $veget != "CMIP6" ]]; then
     244        re='^[0-9]+$'
     245        if ! [[ $veget =~ $re ]]; then
     246            echo 'Valeur de l option veget non valable'; exit 1
     247        fi
     248    fi
     249
     250    #Define veget-related suffix for gcm name
     251    if [[ $veget = 'NONE' ]]; then
     252        suff_orc=''
     253        #For use with tutorial, orchidee_rev is also defined (will be
     254        #written in surface_env at the end of the script)
     255        orchidee_rev=''
     256    else
     257        suff_orc='_orch'
     258    fi
     259
     260
     261    if [[ $parallel = "none" ]]; then
     262        sequential=1; suff_exe='_seq'
     263    else
     264        sequential=0; suff_exe='_para_mem'
     265    fi
     266
     267    #Chemin pour placer le modele
     268    if [[ $MODEL = "" ]]; then MODEL="./LMDZ$version$svn$optim"; fi
     269
     270    ## if also compiling XIOS, parallel must be mpi_omp
     271    if [[ $with_xios = "y" && $parallel != "mpi_omp" ]]; then
     272        echo "Error, you must set -parallel mpi_omp if you want XIOS"; exit 1
     273    fi
     274
     275    if [[ $with_xios = "y" ]]; then
     276        opt_makelmdz_xios="-io xios"
     277    fi
     278
     279    if [[ $cosp = "v2" && $with_xios = "n" ]]; then
     280        echo "Error, Cospv2 cannot run without Xios"; exit 1
     281    fi
     282}
     283
     284function check_available_software {
     285    if [[ $check_software_linux = 1 ]]; then
     286        echo "################################################################"
     287        echo "Check if required software is available"
     288        echo "################################################################"
     289
     290        for logiciel in wget tar gzip make $compiler gcc cmake m4 c++; do
     291            if [[ $(which "$logiciel") = "" ]]; then
     292                echo "You must first install $logiciel on your system"; exit 1
     293            fi
     294        done
     295
     296        cat <<eod > tt.f90
     297    print*,'coucou'
     298    end
     299eod
     300        $compiler tt.f90 || a.out
     301        ./a.out >| tt
     302        if [[ $(< tt sed -e 's/ //g' ) != "coucou" ]]; then
     303            echo "problem installing with compiler $compiler"; exit 1; fi
     304        \rm tt a.out tt.f90
     305    fi
     306}
     307
     308function download_model {
     309    mkdir -p "$MODEL"
     310    MODEL=$(readlink -f "$MODEL"); echo "$MODEL"  # absolute path
     311
     312    if [[ $getlmdzor = 1 && ! -d $MODEL/modipsl ]]; then
     313        echo "##########################################################"
     314        echo "Download a slightly modified version of  LMDZ"
     315        echo "##########################################################"
     316        cd "$MODEL"
     317        getlog="$(pwd)/get.log"
     318        echo "logfile : $getlog"
     319        myget "src_archives/$trusting/modipsl.$version.tar.gz" >> get.log 2>&1
     320        echo "install_lmdz.sh wget_OK $(date)"
     321        gunzip "modipsl.$version.tar.gz" >> get.log 2>&1
     322        tar xf "modipsl.$version.tar" >> get.log 2>&1
     323        \rm "modipsl.$version.tar"
     324    fi
     325}
     326
     327function install_netcdf {
     328    echo "Installing Netcdf"
     329
     330    if [[ $netcdf = 0 ]]; then
     331        ncdfdir=$(nc-config --prefix)
     332    else
     333        cd "$MODEL"
     334
     335        case $compiler in
     336          gfortran) opt1="-compiler gnu"; opt2="-CC gcc -FC gfortran -CXX g++";;
     337          ifort)  opt1="-compiler intel"; opt2="-CC icc -FC ifort -CXX icpc";;
     338          pgf90)  opt1="-compiler pgf90"; opt2="-CC pgcc -FC pgf90 -CXX pgCC";;
     339          *)      echo "unexpected compiler $compiler" for netcdf; exit 1
     340        esac
     341
     342        case $with_xios in
     343            n) script_install_netcdf="install_netcdf4_hdf5_seq.bash"
     344               ncdfdir="netcdf4_hdf5_seq"
     345               opt_="$opt1";;
     346            y) script_install_netcdf="install_netcdf4_hdf5.bash"
     347               ncdfdir="netcdf4_hdf5"
     348               opt_="$opt2 -MPI $root_mpi";;
     349            *) echo "with_xios=$with_xios, should be n or y"; exit 1
     350        esac
     351        if [[ $netcdf = 1 ]]; then
     352           ncdfdir="$MODEL/$ncdfdir"
     353        else
     354           mkdir -p "$netcdf"; ncdfdir="$netcdf/$ncdfdir"
     355        fi
     356
     357        echo "Repertoire netcdf $ncdfdir"
     358        if [[ ! -d $ncdfdir ]]; then
     359            netcdflog=$(pwd)/netcdf.log
     360            echo "----------------------------------------------------------"
     361            echo "Compiling the Netcdf library"
     362            echo "----------------------------------------------------------"
     363            echo "log file : $netcdflog"
     364            myget script_install/$script_install_netcdf >> "$netcdflog" 2>&1
     365            chmod u=rwx $script_install_netcdf
     366            # shellcheck disable=SC2086
     367            ./$script_install_netcdf -prefix "$ncdfdir" $opt_ >> "$netcdflog" 2>&1
     368        fi
     369
     370        #----------------------------------------------------------------------------
     371        # LF rajout d'une verrue, pour une raison non encore expliquee,
     372        # la librairie est parfois rangée dans lib64 et non dans lib
     373        # par certains compilateurs
     374        if [[ ! -e lib && -d lib64 ]]; then ln -s lib64 lib; fi
     375        #----------------------------------------------------------------------------
     376
     377        echo "install_lmdz.sh netcdf_OK $(date)"
     378    fi
     379
     380    cat >test_netcdf90.f90 <<EOF
     381    use netcdf
     382    print *, "NetCDF library version: ", nf90_inq_libvers()
     383    end
     384EOF
     385
     386    if $compiler -I"$ncdfdir"/include test_netcdf90.f90 -L"$ncdfdir"/lib -lnetcdff \
     387              -lnetcdf -Wl,-rpath="$ncdfdir"/lib && ./a.out
     388    then
     389        \rm test_netcdf90.f90 a.out
     390    else
     391        cat <<EOF
     392Failed test program using NetCDF-Fortran. You can:
     393- check that you have NetCDF-Fortran installed in your system
     394- or specify an installation directory with option -netcdf of install_lmdz.sh
     395- or download and compile NetCDF-Fortran with option -netcdf 1 of nstall_lmdz.sh
     396EOF
    269397        exit 1
    270398    fi
    271 fi
    272 
    273 #Define veget-related suffix for gcm name
    274 if [[ $veget = 'NONE' ]]; then
    275     suff_orc=''
    276     #For use with tutorial, orchidee_rev is also defined (will be
    277     #written in surface_env at the end of the script)
    278     orchidee_rev=''
    279 else
    280     suff_orc='_orch'
    281 fi
    282 
    283 
    284 if [[ $parallel = none ]]; then
    285     sequential=1; suff_exe='_seq'
    286 else
    287     sequential=0; suff_exe='_para_mem'
    288 fi
    289 
    290 #Chemin pour placer le modele
    291 if [[ $MODEL = "" ]]; then MODEL=./LMDZ$version$svn$optim; fi
    292 
    293 
    294 arch=local
     399}
     400
     401function install_IOIPSL {  # via fcm
     402  if [[ ! -f $MODEL/modipsl/lib/libioipsl.a ]]; then
     403    cd "$MODEL/modipsl/modeles/IOIPSL"
     404    ioipsllog="$(pwd)/ioipsl.log"
     405    echo "Compiling IOIPSL, the interface library with Netcdf $(date) (log: $ioipsllog)"
     406
     407    if ! ./makeioipsl_fcm -job 8 > "$ioipsllog" 2>&1; then
     408      echo "IOIPSL compile failed, exiting"; exit 1
     409    fi
     410    cp lib/* ../../lib
     411    echo "IOIPSL compiled $(date)"
     412  fi
     413}
     414
     415echo "install_lmdz.sh DEBUT $(date)"
     416
     417set_default_params
     418read_cmdline_args "$@"
     419check_available_software
     420download_model
     421install_netcdf
     422install_IOIPSL
     423
     424
     425
    295426
    296427################################################################
     
    299430
    300431hostname=$(hostname)
    301 if [[ $pclinux = 1 ]]; then o_ins_make="-t g95"; else o_ins_make=""; fi
    302 
    303 case ${hostname:0:5} in
    304 
    305     jean-)   compiler="mpiifort";
    306              par_comp="mpiifort";
    307              o_ins_make="-t jeanzay";
    308              make=gmake;
    309              module purge
    310              module load intel-compilers/19.0.4;
    311              module load hdf5/1.10.5-mpi;
    312              module load netcdf/4.7.2-mpi;
    313              module load netcdf-fortran/4.5.2-mpi;
    314              module load subversion/1.9.7;
    315                    module load cmake
    316              export NETCDF_LIBDIR=./
    317              export NETCDFFORTRAN_INCDIR=./
    318              export NETCDFFORTRAN_LIBDIR=./
    319              arch=X64_JEANZAY;;
    320 
    321     cicla|camel)   compiler="gfortran";
    322                    module purge
    323                    module load gnu/10.2.0
    324                    module load openmpi/4.0.5
    325                    module load hdf5/1.10.7-mpi
    326                    module load netcdf-c/4.7.4-mpi
    327                    module load netcdf-fortran/4.5.3-mpi
    328                    netcdf=/net/nfs/tools/PrgEnv/linux-scientific6-x86_64/gcc-10.2.0/netcdf-fortran-4.5.3-k3drgfqok3lip62hnm3tsyof4cjen5sk
    329                    module load svn/1.14.0
    330 
    331                    if [[ $parallel != none ]]; then
    332                        root_mpi=/net/nfs/tools/meso-sl6/openmpi/4.0.5-gcc-10.2.0
    333                        path_mpi=$root_mpi/bin;
    334                        par_comp=${path_mpi}/mpif90;
    335                        mpirun=${path_mpi}/mpirun;
    336                    fi;
    337                    arch="local" ;
    338                    make="make";
    339                    o_ins_make="-t g95";;
    340 
    341     *)       if [[ $parallel = none || -f /usr/bin/mpif90 ]]; then
    342                  path_mpi=$(which mpif90 | sed -e s:/mpif90::);
    343                  if [[ -d /usr/lib64/openmpi ]]; then
    344                      root_mpi="/usr/lib64/openmpi"
    345                  else
    346                      root_mpi="/usr"
    347                  fi
    348              else
    349                  echo "Cannot find mpif90";
    350                  if [[ $parallel = none ]]; then exit 1; fi;
    351              fi;
    352              if [[ $parallel != none ]]; then
    353                  root_mpi=$(which mpif90 | sed -e s:/bin/mpif90::)
    354                  path_mpi=$(which mpif90 | sed -e s:/mpif90::)
    355                  export LD_LIBRARY_PATH=${root_mpi}/lib:$LD_LIBRARY_PATH
    356              fi
    357              par_comp=${path_mpi}/mpif90;
    358              mpirun=${path_mpi}/mpirun;
    359              arch="local" ;
    360              make="make";
    361              o_ins_make="-t g95"
    362 esac
    363 
    364 # Flags for parallelism:
    365 if [[ $parallel != none ]]; then
    366     # MPI_LD are the flags needed for linking with MPI
    367     MPI_LD="-L${root_mpi}/lib -lmpi"
    368     if [[ "$compiler" = "gfortran" ]]; then
    369         # MPI_FLAGS are the flags needed for compilation with MPI
    370         MPI_FLAGS="-fcray-pointer"
    371         # OMP_FLAGS are the flags needed for compilation with OpenMP
    372         OMP_FLAGS="-fopenmp -fcray-pointer"
    373         # OMP_LD are the flags needed for linking with OpenMP
    374         OMP_LD="-fopenmp"
    375     elif [[ "$compiler" = "ifort" ]]; then
    376         MPI_FLAGS=""
    377         OMP_FLAGS="-openmp"
    378         OMP_LD="-openmp"
    379     else # pgf90
    380         MPI_FLAGS=""
    381         OMP_FLAGS="-mp"
    382         OMP_LD="-mp"
    383     fi
    384 fi
    385 
    386 ## if also compiling XIOS, parallel must be mpi_omp
    387 if [[ $with_xios = "y" && $parallel != "mpi_omp" ]]; then
    388     echo "Error, you must set -parallel mpi_omp if you want XIOS"
    389     exit 1
    390 fi
    391 
    392 if [[ $with_xios = "y" ]]; then
    393     opt_makelmdz_xios="-io xios"
    394 fi
    395 
    396 if [[ $cosp = "v2" && $with_xios = "n" ]]; then
    397     echo "Error, Cospv2 cannot run without Xios"
    398     exit 1
    399 fi
    400 
    401 echo "################################################################"
    402 echo  "Choix des options de compilation"
    403 echo "################################################################"
    404 
    405 export FC=$compiler
    406 export F90=$compiler
    407 export F77=$compiler
    408 export CPPFLAGS=
    409 OPTIMNC=""
    410 BASE_LD="$OPT_GPROF"
    411 OPTPREC="$OPT_GPROF"
    412 ARFLAGS="rs"
    413 if [[ $(lsb_release -i -s) = "Ubuntu" ]]; then
    414     if [[ $(lsb_release -r -s | cut -d. -f1) -ge 16 ]]; then
    415         ARFLAGS="rU"
    416     fi
    417 fi
    418 
    419 if [[ $compiler = "gfortran" ]]; then
    420    OPTIM="-O3 $allow_arg_mismatch"
    421    OPTDEB="-g3 -Wall -fbounds-check -ffpe-trap=invalid,zero,overflow -O0 -fstack-protector-all -fbacktrace -finit-real=snan  $allow_arg_mismatch"
    422    OPTDEV="-Wall -fbounds-check  $allow_arg_mismatch"
    423    fmod="I "
    424    OPTPREC="$OPTPREC -cpp -ffree-line-length-0"
    425    if [[ $real = r8 ]]; then OPTPREC="$OPTPREC -fdefault-real-8 -DNC_DOUBLE"; fi
    426    export F90FLAGS=" -ffree-form $OPTIMNC"
    427    export FFLAGS=" $OPTIMNC"
    428    export CC=gcc
    429    export CXX=g++
    430    export fpp_flags="-P -C -traditional -ffreestanding"
    431 
    432 elif [[ $compiler = mpif90 ]]; then
    433     OPTIM="-O3"
    434     OPTDEB="-g3 -Wall -fbounds-check -ffpe-trap=invalid,zero,overflow -O0 -fstack-protector-all"
    435     OPTDEV="-Wall -fbounds-check"
    436     BASE_LD="$BASE_LD -lblas"
    437     fmod="I "
    438     if [[ $real = r8 ]]; then
    439         OPTPREC="$OPTPREC -fdefault-real-8 -DNC_DOUBLE -fcray-pointer"
    440     fi
    441     export F90FLAGS=" -ffree-form $OPTIMNC"
    442     export FFLAGS=" $OPTIMNC"
    443     export CC=gcc
    444     export CXX=g++
    445 
    446 elif [[ $compiler = pgf90 ]]; then
    447     OPTIM="-O2 -Mipa -Munroll -Mnoframe -Mautoinline -Mcache_align"
    448     OPTDEB="-g -Mdclchk -Mbounds -Mchkfpstk -Mchkptr -Minform=inform -Mstandard -Ktrap=fp -traceback"
    449     OPTDEV="-g -Mbounds -Ktrap=fp -traceback"
    450     fmod="module "
    451     if [[ $real = r8 ]]; then OPTPREC="$OPTPREC -r8 -DNC_DOUBLE"; fi
    452     export CPPFLAGS="-DpgiFortran"
    453     export CC=pgcc
    454     export CFLAGS="-O2 -Msignextend"
    455     export CXX=pgCC
    456     export CXXFLAGS="-O2 -Msignextend"
    457     export FFLAGS="-O2 $OPTIMNC"
    458     export F90FLAGS="-O2 $OPTIMNC"
    459     compile_with_fcm=1
    460 
    461 elif [[ $compiler = ifort || $compiler = mpiifort ]]; then
    462     OPTIM="-O2 -fp-model strict -ip -align all "
    463     OPTDEV="-p -g -O2 -traceback -fp-stack-check -ftrapuv -check"
    464     OPTDEB="-g -no-ftz -traceback -ftrapuv -fp-stack-check -check"
    465     fmod='module '
    466     if [[ $real = r8 ]]; then OPTPREC="$OPTPREC -real-size 64 -DNC_DOUBLE"; fi
    467     export CPP="icc -E"
    468     export FFLAGS="-O2 -ip -fpic -mcmodel=large"
    469     export FCFLAGS="-O2 -ip -fpic -mcmodel=large"
    470     export CC=icc
    471     export CFLAGS="-O2 -ip -fpic -mcmodel=large"
    472     export CXX=icpc
    473     export CXXFLAGS="-O2 -ip -fpic -mcmodel=large"
    474     export fpp_flags="-P -traditional"
    475     # Pourquoi forcer la compilation fcm. Marche mieux sans
    476     #compile_with_fcm=1
    477 else
    478     echo "unexpected compiler $compiler"; exit 1
    479 fi
    480 
    481 OPTIMGCM="$OPTIM $OPTPREC"
    482 
    483 hostname=$(hostname)
    484 
    485 ##########################################################################
    486 # If installing on known machines such as Jean-Zay at IDRIS,
    487 # don't check for available software and don't install netcdf
    488 if [[ ${hostname:0:5} = "jean-" ]]; then
    489     netcdf=0 # no need to recompile netcdf, alreday available
    490     check_software_linux=0
    491     pclinux=0
    492     ioipsl=0 # no need to recompile ioipsl, already available
    493     #netcdf="/smplocal/pub/NetCDF/4.1.3"
    494     compiler="mpiifort"
    495     fmod='module '
    496     if [[ $real = r8 ]]; then OPTPREC="$OPTPREC -i4 -r8 -DNC_DOUBLE"; fi
    497     OPTIM="-auto -align all -O2 -fp-model strict -xHost "
    498     OPTIMGCM="$OPTIM $OPTPREC"
    499 fi
    500 ##########################################################################
    501 
    502 
    503 mkdir -p "$MODEL"
    504 echo "$MODEL"
    505 MODEL=$( cd "$MODEL"; pwd ) # to get absolute path, if necessary
    506 
    507 
    508 if [[ $check_software_linux = 1 ]]; then
    509     echo "################################################################"
    510     echo "Check if required software is available"
    511     echo "################################################################"
    512 
    513     for logiciel in wget tar gzip make $compiler gcc cmake m4 c++; do
    514         if [[ $(which $logiciel) = "" ]]; then
    515             echo "You must first install $logiciel on your system"
    516             exit 1
    517         fi
    518     done
    519 
    520     cd "$MODEL"
    521     cat <<eod > tt.f90
    522 print*,'coucou'
    523 end
    524 eod
    525     $compiler tt.f90 || a.out
    526     ./a.out >| tt
    527     if [[ $(< tt sed -e 's/ //g' ) != "coucou" ]]; then
    528         echo "problem installing with compiler $compiler"; exit 1; fi
    529     \rm tt a.out tt.f90
    530 fi
    531 
    532 ###########################################################################
    533 if [[ $getlmdzor = 1 && ! -d $MODEL/modipsl ]]; then
    534 ###########################################################################
    535    echo "##########################################################"
    536    echo "Download a slightly modified version of  LMDZ"
    537    echo "##########################################################"
    538    cd "$MODEL"
    539    getlog=$(pwd)/get.log
    540    echo logfile : "$getlog"
    541    myget "src_archives/$trusting/modipsl.$version.tar.gz" >> get.log 2>&1
    542    echo install_lmdz.sh wget_OK "$(date)"
    543    gunzip "modipsl.$version.tar.gz" >> get.log 2>&1
    544    tar xf "modipsl.$version.tar" >> get.log 2>&1
    545    \rm "modipsl.$version.tar"
    546 fi
    547 
    548 ###########################################################################
    549 echo "Installing Netcdf"
    550 ###########################################################################
    551 
    552 if [[ $netcdf = 0 ]]; then
    553     ncdfdir=/usr
    554 
    555 else
    556     cd "$MODEL"
    557 
    558     case $compiler in
    559       gfortran) opt1="-compiler gnu"; opt2="-CC gcc -FC gfortran -CXX g++";;
    560       ifort)  opt1="-compiler intel"; opt2="-CC icc -FC ifort -CXX icpc";;
    561       pgf90)  opt1="-compiler pgf90"; opt2="-CC pgcc -FC pgf90 -CXX pgCC";;
    562       *)      echo "unexpected compiler $compiler" for netcdf; exit 1
    563     esac
    564 
    565     case $with_xios in
    566         n) script_install_netcdf=install_netcdf4_hdf5_seq.bash
    567            ncdfdir=netcdf4_hdf5_seq
    568            opt_=$opt1;;
    569         y) script_install_netcdf=install_netcdf4_hdf5.bash
    570            ncdfdir=netcdf4_hdf5
    571            opt_="$opt2 -MPI $root_mpi";;
    572         *) echo with_xios=$with_xios, should be n or y; exit 1
    573     esac
    574     if [[ $netcdf = 1 ]]; then
    575        ncdfdir=$MODEL/$ncdfdir
    576     else
    577        mkdir -p $netcdf; ncdfdir=$netcdf/$ncdfdir
    578     fi
    579          
    580     echo "Repertoire netcdf $ncdfdir"
    581     if [[ ! -d $ncdfdir ]]; then
    582         netcdflog=$(pwd)/netcdf.log
    583         echo "----------------------------------------------------------"
    584         echo "Compiling the Netcdf library"
    585         echo "----------------------------------------------------------"
    586         echo "log file : $netcdflog"
    587         myget script_install/$script_install_netcdf >> "$netcdflog" 2>&1
    588         chmod u=rwx $script_install_netcdf
    589         # shellcheck disable=SC2086
    590         ./$script_install_netcdf -prefix "$ncdfdir" $opt_ >> "$netcdflog" 2>&1
    591     fi
    592 
    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 && -d lib64 ]]; then ln -s lib64 lib; fi
    598     #----------------------------------------------------------------------------
    599 
    600     echo install_lmdz.sh netcdf_OK "$(date)"
    601 
    602 fi
    603 
    604 cat >test_netcdf90.f90 <<EOF
    605 use netcdf
    606 print *, "NetCDF library version: ", nf90_inq_libvers()
    607 end
    608 EOF
    609 
    610 if $compiler -I"$ncdfdir"/include test_netcdf90.f90 -L"$ncdfdir"/lib -lnetcdff \
    611           -lnetcdf -Wl,-rpath="$ncdfdir"/lib && ./a.out
    612 then
    613     rm test_netcdf90.f90 a.out
    614 else
    615     echo "Failed test program using NetCDF-Fortran."
    616     echo "You can:"
    617     echo "- check that you have NetCDF-Fortran installed in your system"
    618     echo "- or specify an installation directory with option -netcdf of" \
    619          "install_lmdz.sh"
    620     echo "- or download and compile NetCDF-Fortran with option -netcdf 1 of" \
    621          "install_lmdz.sh"
    622     exit 1
    623 fi
    624 
    625 if [[ ! -f $MODEL/modipsl/lib/libioipsl.a ]]
    626 then
    627     if [[ $ioipsl = 1 ]]; then
    628         cat <<EOF
    629 OK ioipsl=$ioipsl
    630 ##########################################################
    631 Installing MODIPSL, the installation package manager for the
    632 IPSL models and tools
    633 ##########################################################
    634 $(date)
    635 EOF
    636         cd "$MODEL/modipsl"
    637         \rm -rf lib/*
    638         cd util
    639         cp AA_make.gdef AA_make.orig
    640         F_C="$compiler -c "
    641         if [[ $compiler = "gfortran" || $compiler = "mpif90" ]]
    642         then
    643             F_C="$compiler -c -cpp "
    644         fi
    645         if [[ $compiler = "pgf90" ]]; then F_C="$compiler -c -Mpreprocess"; fi
    646         sed -e 's/^\#.*.g95.*.\#.*.$/\#/' AA_make.gdef > tmp
    647         sed -e "s:F_L = g95:F_L = $compiler:" \
    648             -e "s:F_C = g95 -c -cpp:F_C = $F_C": \
    649             -e 's/g95.*.w_w.*.(F_D)/g95      w_w = '"$OPTIMGCM"'/' \
    650             -e 's:g95.*.NCDF_INC.*.$:g95      NCDF_INC= '"$ncdfdir"'/include:' \
    651             -e 's:g95.*.NCDF_LIB.*.$:g95      NCDF_LIB= -L'"$ncdfdir"'/lib -lnetcdff -lnetcdf:' \
    652             -e 's:g95      L_O =:g95      L_O = -Wl,-rpath='"$ncdfdir"'/lib:' \
    653             -e "s:-fmod=:-$fmod:" -e 's/-fno-second-underscore//' \
    654             -e 's:#-Q- g95      M_K = gmake:#-Q- g95      M_K = make:' \
    655             tmp >| AA_make.gdef
    656 
    657         if [[ $pcmac == 1 ]]
    658         then
    659             cp AA_make.gdef tmp
    660             sed -e 's/rpath=/rpath,/g' tmp > AA_make.gdef
    661         fi
    662 
    663         # We use lines for g95 even for the other compilers to run ins_make
    664         sed -e s:/bin/ksh:/bin/bash:g ins_make > ins_make.bash  # Note Amaury: the case where the default shell isn't bash should be handled directly in ins_make (via ./ and #! directives)
    665 
    666         chmod u=rwx ins_make.bash
    667         # shellcheck disable=SC2086
    668         ./ins_make.bash $o_ins_make
    669 
    670         echo "install_lmdz.sh MODIPSL_OK $(date)"
    671 
    672         cd "$MODEL/modipsl/modeles/IOIPSL/src"
    673         ioipsllog=$(pwd)/ioipsl.log
    674         echo '##########################################################'
    675         echo 'Compiling IOIPSL, the interface library with Netcdf'
    676         echo '##########################################################'
    677         echo "log file : $ioipsllog   $(date)"
    678 
    679         cp Makefile Makefile.ksh
    680         sed -e s:/bin/ksh:/bin/bash:g Makefile.ksh > Makefile
    681 
    682         # Build IOIPSL modules and library
    683         $make clean
    684         $make > "$ioipsllog" 2>&1
    685         if [[ $compiler = "gfortran" || $compiler = "mpif90" ]]; then
    686             # copy module files to lib
    687             cp -f -- *.mod ../../../lib
    688         fi
    689         # Build IOIPSL tools (ie: "rebuild", if present)
    690         # For IOIPSLv_2_2_2, "rebuild" files are in IOIPSL/tools
    691         rebuild_dir=""
    692         if [[ -f $MODEL/modipsl/modeles/IOIPSL/tools/rebuild ]]; then
    693             rebuild_dir=$MODEL/modipsl/modeles/IOIPSL/tools
    694               elif [[ -d $MODEL/modipsl/modeles/IOIPSL/rebuild ]]; then
    695             rebuild_dir=$MODEL/modipsl/modeles/IOIPSL/rebuild
    696         fi
    697         if [[ $rebuild_dir != "" ]]; then
    698                   cd "$rebuild_dir"
    699             # adapt Makefile & rebuild script if in bash
    700             cp Makefile Makefile.ksh
    701             sed -e s:/bin/ksh:/bin/bash:g Makefile.ksh > Makefile
    702             cp rebuild rebuild.ksh
    703             sed -e 's:/bin/ksh:/bin/bash:g' \
    704                 -e 's:print -u2:echo:g' \
    705                 -e 's:print:echo:g' rebuild.ksh > rebuild
    706             $make clean
    707             $make > "$ioipsllog" 2>&1
    708         fi
    709 
    710     else # of if [[ $ioipsl = 1 ]]
    711         if [[ ${hostname:0:5} = jean- ]]; then
    712             cd "$MODEL/modipsl"
    713             cd util
    714             if [[ $(grep jeanzay AA_make.gdef) = "" ]]; then
    715                 echo 'Warning jean-zay not in AA_make.gdef'
    716                 echo 'Think about updating'
    717                 exit 1
    718             fi
    719             ./ins_make "$o_ins_make"
    720             # Compile IOIPSL on jean-zay
    721             cd "$MODEL/modipsl/modeles/IOIPSL/src"
    722             gmake > ioipsl.log
    723             # For IOIPSLv_2_2_2, "rebuild" files are in IOIPSL/tools, so "gmake" in IOIPSL/tools is enough
    724             # For IOIPSLv_2_2_5, "rebuild" files are in a separate IOIPSL/rebuild folder , while "tools" only contains "FCM"
    725             if [[ -f $MODEL/modipsl/modeles/IOIPSL/tools/Makefile ]]; then
    726               cd "$MODEL/modipsl/modeles/IOIPSL/tools"
    727               gmake > ioipsl.log
    728             fi
    729             if [[ -d $MODEL/modipsl/modeles/IOIPSL/rebuild ]]; then
    730               cd "$MODEL/modipsl/modeles/IOIPSL/rebuild"
    731               gmake > ioipsl.log
    732             fi
    733 
    734         fi
    735         echo "install_lmdz.sh ioipsl_OK $(date)"
    736     fi # of if [[ $ioipsl = 1 ]]
    737 fi # of if [[ ! -f $MODEL/modipsl/lib/libioipsl.a ]]
    738 
    739 #=========================================================================
     432#case ${hostname:0:5} in
     433#    *)       if [[ $parallel = none || -f /usr/bin/mpif90 ]]; then
     434#                 path_mpi=$(which mpif90 | sed -e s:/mpif90::);
     435#                 if [[ -d /usr/lib64/openmpi ]]; then
     436#                     root_mpi="/usr/lib64/openmpi"
     437#                 else
     438#                     root_mpi="/usr"
     439#                 fi
     440#             else
     441#                 echo "Cannot find mpif90";
     442#                 if [[ $parallel = none ]]; then exit 1; fi;
     443#             fi;
     444#             if [[ $parallel != none ]]; then
     445#                 root_mpi=$(which mpif90 | sed -e s:/bin/mpif90::)
     446#                 path_mpi=$(which mpif90 | sed -e s:/mpif90::)
     447#                 export LD_LIBRARY_PATH=${root_mpi}/lib:$LD_LIBRARY_PATH
     448#             fi
     449#             par_comp=${path_mpi}/mpif90;
     450#             mpirun=${path_mpi}/mpirun;
     451#             arch="local" ;
     452#             make="make";
     453#             o_ins_make="-t g95"
     454#esac
     455
     456## Flags for parallelism:
     457#if [[ $parallel != none ]]; then
     458#    # MPI_LD are the flags needed for linking with MPI
     459#    MPI_LD="-L${root_mpi}/lib -lmpi"
     460#    if [[ $compiler = "gfortran" ]]; then
     461#        # MPI_FLAGS are the flags needed for compilation with MPI
     462#        MPI_FLAGS="-fcray-pointer"
     463#        # OMP_FLAGS are the flags needed for compilation with OpenMP
     464#        OMP_FLAGS="-fopenmp -fcray-pointer"
     465#        # OMP_LD are the flags needed for linking with OpenMP
     466#        OMP_LD="-fopenmp"
     467#    elif [[ $compiler = "ifort" ]]; then
     468#        MPI_FLAGS=""
     469#        OMP_FLAGS="-openmp"
     470#        OMP_LD="-openmp"
     471#    else # pgf90
     472#        MPI_FLAGS=""
     473#        OMP_FLAGS="-mp"
     474#        OMP_LD="-mp"
     475#    fi
     476#fi
     477#
     478#
     479#echo "################################################################"
     480#echo  "Choix des options de compilation"
     481#echo "################################################################"
     482#
     483#export FC=$compiler
     484#export F90=$compiler
     485#export F77=$compiler
     486#export CPPFLAGS=
     487#OPTIMNC=""
     488#BASE_LD="$OPT_GPROF"
     489#OPTPREC="$OPT_GPROF"
     490#ARFLAGS="rs"
     491#if [[ $(lsb_release -i -s) = "Ubuntu" ]]; then
     492#    if [[ $(lsb_release -r -s | cut -d. -f1) -ge 16 ]]; then
     493#        ARFLAGS="rU"
     494#    fi
     495#fi
     496#
     497#if [[ $compiler = "gfortran" ]]; then
     498#   OPTIM="-O3 $allow_arg_mismatch"
     499#   OPTDEB="-g3 -Wall -fbounds-check -ffpe-trap=invalid,zero,overflow -O0 -fstack-protector-all -fbacktrace -finit-real=snan  $allow_arg_mismatch"
     500#   OPTDEV="-Wall -fbounds-check  $allow_arg_mismatch"
     501#   fmod="I "
     502#   OPTPREC="$OPTPREC -cpp -ffree-line-length-0"
     503#   if [[ $real = r8 ]]; then OPTPREC="$OPTPREC -fdefault-real-8 -DNC_DOUBLE"; fi
     504#   export F90FLAGS=" -ffree-form $OPTIMNC"
     505#   export FFLAGS=" $OPTIMNC"
     506#   export CC=gcc
     507#   export CXX=g++
     508#   export fpp_flags="-P -C -traditional -ffreestanding"
     509#
     510#elif [[ $compiler = mpif90 ]]; then
     511#    OPTIM="-O3"
     512#    OPTDEB="-g3 -Wall -fbounds-check -ffpe-trap=invalid,zero,overflow -O0 -fstack-protector-all"
     513#    OPTDEV="-Wall -fbounds-check"
     514#    BASE_LD="$BASE_LD -lblas"
     515#    fmod="I "
     516#    if [[ $real = r8 ]]; then
     517#        OPTPREC="$OPTPREC -fdefault-real-8 -DNC_DOUBLE -fcray-pointer"
     518#    fi
     519#    export F90FLAGS=" -ffree-form $OPTIMNC"
     520#    export FFLAGS=" $OPTIMNC"
     521#    export CC=gcc
     522#    export CXX=g++
     523#
     524#elif [[ $compiler = pgf90 ]]; then
     525#    OPTIM="-O2 -Mipa -Munroll -Mnoframe -Mautoinline -Mcache_align"
     526#    OPTDEB="-g -Mdclchk -Mbounds -Mchkfpstk -Mchkptr -Minform=inform -Mstandard -Ktrap=fp -traceback"
     527#    OPTDEV="-g -Mbounds -Ktrap=fp -traceback"
     528#    fmod="module "
     529#    if [[ $real = r8 ]]; then OPTPREC="$OPTPREC -r8 -DNC_DOUBLE"; fi
     530#    export CPPFLAGS="-DpgiFortran"
     531#    export CC=pgcc
     532#    export CFLAGS="-O2 -Msignextend"
     533#    export CXX=pgCC
     534#    export CXXFLAGS="-O2 -Msignextend"
     535#    export FFLAGS="-O2 $OPTIMNC"
     536#    export F90FLAGS="-O2 $OPTIMNC"
     537#    compile_with_fcm=1
     538#
     539#elif [[ $compiler = ifort || $compiler = mpiifort ]]; then
     540#    OPTIM="-O2 -fp-model strict -ip -align all "
     541#    OPTDEV="-p -g -O2 -traceback -fp-stack-check -ftrapuv -check"
     542#    OPTDEB="-g -no-ftz -traceback -ftrapuv -fp-stack-check -check"
     543#    fmod='module '
     544#    if [[ $real = r8 ]]; then OPTPREC="$OPTPREC -real-size 64 -DNC_DOUBLE"; fi
     545#    export CPP="icc -E"
     546#    export FFLAGS="-O2 -ip -fpic -mcmodel=large"
     547#    export FCFLAGS="-O2 -ip -fpic -mcmodel=large"
     548#    export CC=icc
     549#    export CFLAGS="-O2 -ip -fpic -mcmodel=large"
     550#    export CXX=icpc
     551#    export CXXFLAGS="-O2 -ip -fpic -mcmodel=large"
     552#    export fpp_flags="-P -traditional"
     553#    # Pourquoi forcer la compilation fcm. Marche mieux sans
     554#    #compile_with_fcm=1
     555#else
     556#    echo "unexpected compiler $compiler"; exit 1
     557#fi
     558#
     559#OPTIMGCM="$OPTIM $OPTPREC"
     560
     561
     562
     563
    740564if [[ "$with_xios" = "y" ]]; then
    741565    echo '##########################################################'
Note: See TracChangeset for help on using the changeset viewer.