Ignore:
Timestamp:
Nov 23, 2017, 6:18:30 AM (7 years ago)
Author:
fhourdin
Message:

Add a "-compiler" option to install_lmdz.sh script (default is gfortran).
EM

File:
1 edited

Legend:

Unmodified
Added
Removed
  • BOL/script_install/install_lmdz.sh

    r3076 r3088  
    7575bench=1
    7676pclinux=1
     77compiler=gfortran
    7778SCM=0
    7879# use the old orchidee interface without the calculation of z0h
     
    110111
    111112    -r       "svn_release" : either the svn release number or "last"
     113   
     114    -compiler gfortran|ifort|pgf90 (default: gfortran)
    112115
    113116    -parallel PARA : can be mpi_omp (mpi with openMP) or none (for sequential)
     
    138141     "-v") version=$2 ; shift ; shift ;;
    139142     "-r") svn=$2 ; shift ; shift ;;
     143     "-compiler") compiler=$2
     144                  case $compiler in
     145                    "gfortran"|"ifort"|"pgf90") compiler=$2 ; shift ; shift ;;
     146                    *) echo "Only gfortran , ifort or pgf90 for the compiler option" ; exit
     147                  esac ;;
    140148     "-d") grid_resolution=$2 ; shift ; shift ;;
    141149     "-gprof") OPT_GPROF="-pg" ; shift ;;
     
    157165if [ $parallel = none ] ; then sequential=1 ; else sequential=0 ; fi
    158166
    159 
    160 compilo=gfortran # compilo=pgf90 or gfortran or ifort sur PC linux
    161167#Chemin pour placer le modele
    162168if [ "$MODEL" = "" ] ; then MODEL=./LMDZ$version$svn ; fi
     
    168174
    169175
    170 if [ $compilo = g95 ] ; then echo g95 is not supported anymore ; exit ; fi
     176if [ $compiler = g95 ] ; then echo g95 is not supported anymore ; exit ; fi
    171177
    172178################################################################
     
    179185case ${hostname:0:5} in
    180186
    181    ada33)   compilo="ifort" ;
     187   ada33)   compiler="ifort" ;
    182188            par_comp="ifort" ;
    183189            o_ins_make="-t ada" ;
     
    186192            arch=X64_ADA ;;
    187193
    188    cicla)   compilo="gfortran" ;
     194   cicla)   compiler="gfortran" ;
    189195            if [ $parallel != none ] ; then
    190196              module load openmpi/1.4.5-gfortran ;
     
    198204            o_ins_make="-t g95" ;;
    199205           
    200    *)       compilo="gfortran" ;
    201             if [ $parallel = none -o -f /usr/bin/mpif90 ] ; then
     206   *)       if [ $parallel = none -o -f /usr/bin/mpif90 ] ; then
    202207                path_mpi=`which mpif90 | sed -e s:/mpif90::` ;
    203208                if [ -d /usr/lib64/openmpi ] ; then
     
    206211                  root_mpi="/usr"
    207212                fi
    208             # For Scientifique Linux at LMD :
    209             elif [ -f /usr/lib64/openmpi/1.4.5-gfortran/bin/mpif90 ] ; then
     213            # For Scientifique Linux with gfortran at LMD :
     214            elif [ -f /usr/lib64/openmpi/1.4.5-gfortran/bin/mpif90 -a compiler = "gfortran" ] ; then
    210215                path_mpi=/usr/lib64/openmpi/1.4.5-gfortran/bin ;
    211216                root_mpi=/usr/lib64/openmpi/1.4.5-gfortran ;
     217                export LD_LIBRARY_PATH=${root_mpi}/lib:$LD_LIBRARY_PATH
     218            # For Scientifique Linux with ifort at LMD :
     219            elif [ -f /usr/lib64/openmpi/1.4.5-ifort/bin/mpif90 -a compiler = "ifort" ] ; then
     220                path_mpi=/usr/lib64/openmpi/1.4.5-ifort/bin ;
     221                root_mpi=/usr/lib64/openmpi/1.4.5-ifort ;
     222                export LD_LIBRARY_PATH=${root_mpi}/lib:$LD_LIBRARY_PATH
     223            # For Scientifique Linux with pgf90 at LMD :
     224            elif [ -f /usr/lib64/openmpi/1.4.5-ifort/bin/mpif90 -a compiler = "pgf90" ] ; then
     225                path_mpi=/usr/lib64/openmpi/1.4.5-pgf/bin ;
     226                root_mpi=/usr/lib64/openmpi/1.4.5-pgf ;
    212227                export LD_LIBRARY_PATH=${root_mpi}/lib:$LD_LIBRARY_PATH
    213228            else
     
    222237esac
    223238
    224 
    225 # MPI_FLAGS are the flags needed for compilation with MPI
    226 #MPI_FLAGS="-I/usr/include/openmpi-x86_64 -fcray-pointer"
    227 MPI_FLAGS="-fcray-pointer"
    228 # MPI_LD are the flags needed for linking with MPI
    229 MPI_LD="-L/usr/lib64/openmpi/lib -lmpi"
    230 # OMP_FLAGS are the flags needed for compilation with OpenMP
    231 OMP_FLAGS="-fopenmp -fcray-pointer"
    232 # OMP_LD are the flags needed for linking with OpenMP
    233 #OMP_LD="-fopenmp -L/usr/lib64 -lnuma"
    234 OMP_LD="-fopenmp"
    235 
     239# Flags for parallelism:
     240if [ $parallel != none ] ; then
     241  # MPI_LD are the flags needed for linking with MPI
     242  MPI_LD="-L${root_mpi}/lib -lmpi"
     243  if [ "$compiler" = "gfortran" ] ; then
     244    # MPI_FLAGS are the flags needed for compilation with MPI
     245    MPI_FLAGS="-fcray-pointer"
     246    # OMP_FLAGS are the flags needed for compilation with OpenMP
     247    OMP_FLAGS="-fopenmp -fcray-pointer"
     248    # OMP_LD are the flags needed for linking with OpenMP
     249    OMP_LD="-fopenmp"
     250  elif [ "$compiler" = "ifort" ] ; then
     251    MPI_FLAGS=""
     252    OMP_FLAGS="-openmp"
     253    OMP_LD="-openmp"
     254  else # pgf90
     255    MPI_FLAGS=""
     256    OMP_FLAGS="-mp"
     257    OMP_LD="-mp"
     258  fi
     259fi
    236260
    237261#####################################################################
     
    243267#####################################################################
    244268
    245 if [ "$compilo" = "gfortran" ] ; then
     269if [ "$compiler" = "gfortran" ] ; then
    246270   gfortran=gfortran
    247271   gfortranv=`gfortran --version | \
     
    250274       echo ERROR : Your gfortran compiler is too old
    251275       echo 'Please choose a new one (ifort) and change the line'
    252        echo compilo=xxx
     276       echo compiler=xxx
    253277       echo in the install.sh script and rerun it
    254278       if [ `which gfortran44 | wc -w` -ne 0 ] ; then
     
    258282       fi
    259283   fi
    260    compilo=$gfortran
     284   compiler=$gfortran
    261285fi
    262286#####################################################################
     
    275299echo '################################################################'
    276300
    277 export FC=$compilo
    278 export F90=$compilo
    279 export F77=$compilo
     301export FC=$compiler
     302export F90=$compiler
     303export F77=$compiler
    280304export CPPFLAGS=
    281305OPTIMNC=$OPTIM
     
    286310
    287311
    288 if [ "$compilo" = "$gfortran" ] ; then
     312if [ "$compiler" = "$gfortran" ] ; then
    289313   OPTIM='-O3'
    290314   OPTDEB="-g3 -Wall -fbounds-check -ffpe-trap=invalid,zero,overflow -O0 -fstack-protector-all -fbacktrace -finit-real=nan"
     
    299323   export fpp_flags="-P -C -traditional -ffreestanding"
    300324
    301 elif [ $compilo = mpif90 ] ; then
     325elif [ $compiler = mpif90 ] ; then
    302326   OPTIM='-O3'
    303327   OPTDEB="-g3 -Wall -fbounds-check -ffpe-trap=invalid,zero,overflow -O0 -fstack-protector-all"
     
    311335   export CXX=g++
    312336
    313 elif [ $compilo = pgf90 ] ; then
     337elif [ $compiler = pgf90 ] ; then
    314338   OPTIM='-O2 -Mipa -Munroll -Mnoframe -Mautoinline -Mcache_align'
    315339   OPTDEB='-g -Mdclchk -Mbounds -Mchkfpstk -Mchkptr -Minform=inform -Mstandard -Ktrap=fp -traceback'
     
    326350   compile_with_fcm=1
    327351
    328 elif [ $compilo = ifort ] ; then
     352elif [ $compiler = ifort ] ; then
    329353   OPTIM="-O2 -fp-model strict -ip -align all "
    330354   OPTDEV="-p -g -O2 -traceback -fp-stack-check -ftrapuv -check"
     
    342366
    343367else
    344    echo unexpected compiler $compilo ; exit
     368   echo unexpected compiler $compiler ; exit
    345369fi
    346370
     
    358382  ioipsl=1 # no need to recompile ioipsl, already available
    359383  #netcdf="/smplocal/pub/NetCDF/4.1.3"
    360   compilo="ifort"
     384  compiler="ifort"
    361385  fmod='module '
    362386  if [ $real = r8 ] ; then OPTPREC="$OPTPREC -real-size 64 -DNC_DOUBLE" ; fi
     
    397421
    398422
    399 for logiciel in csh wget tar gzip make $compilo gcc ; do
     423for logiciel in csh wget tar gzip make $compiler gcc ; do
    400424if [ "`which $logiciel`" = "" ] ; then
    401425echo You must first install $logiciel on your system
     
    410434end
    411435eod
    412 $compilo tt.f90 -o a.out
     436$compiler tt.f90 -o a.out
    413437./a.out >| tt
    414438if [ "`cat tt | sed -e 's/ //g' `" != "coucou" ] ; then
    415 echo problem installing with compiler $compilo ; exit ; fi
     439echo problem installing with compiler $compiler ; exit ; fi
    416440\rm tt a.out tt.f90
    417441fi
     
    461485  myget import/install_netcdf4_hdf5.bash
    462486  chmod u=rwx install_netcdf4_hdf5.bash
    463   if [ "$compilo" = "gfortran" ] ; then
     487  if [ "$compiler" = "gfortran" ] ; then
    464488  ./install_netcdf4_hdf5.bash -prefix $MODEL/netcdf4_hdf5 -CC gcc -FC gfortran -CXX g++ -MPI $root_mpi
    465   elif [ "$compilo" = "ifort" ] ; then
     489  elif [ "$compiler" = "ifort" ] ; then
    466490  ./install_netcdf4_hdf5.bash -prefix $MODEL/netcdf4_hdf5 -CC icc -FC ifort -CXX icpc -MPI $root_mpi
    467   elif [ "$compilo" = "pgf90" ] ; then
     491  elif [ "$compiler" = "pgf90" ] ; then
    468492  ./install_netcdf4_hdf5.bash -prefix $MODEL/netcdf4_hdf5 -CC pgcc -FC pgf90 -CXX pgCC -MPI $root_mpi
    469493  else
    470     echo "unexpected compiler $compilo" ; exit
     494    echo "unexpected compiler $compiler" ; exit
    471495  fi
    472496fi  # of if [ "$with_xios" = "n" ]
     
    499523
    500524  cp AA_make.gdef AA_make.orig
    501   F_C="$compilo -c " ; if [ "$compilo" = "$gfortran" -o "$compilo" = "mpif90" ] ; then F_C="$compilo -c -cpp " ; fi
    502   if [ "$compilo" = "pgf90" ] ; then F_C="$compilo -c -Mpreprocess" ; fi
     525  F_C="$compiler -c " ; if [ "$compiler" = "$gfortran" -o "$compiler" = "mpif90" ] ; then F_C="$compiler -c -cpp " ; fi
     526  if [ "$compiler" = "pgf90" ] ; then F_C="$compiler -c -Mpreprocess" ; fi
    503527  sed -e 's/^\#.*.g95.*.\#.*.$/\#/' AA_make.gdef > tmp
    504   sed -e "s:F_L = g95:F_L = $compilo:" -e "s:F_C = g95 -c -cpp:F_C = $F_C": \
     528  sed -e "s:F_L = g95:F_L = $compiler:" -e "s:F_C = g95 -c -cpp:F_C = $F_C": \
    505529  -e 's/g95.*.w_w.*.(F_D)/g95      w_w = '"$OPTIMGCM"'/' \
    506530  -e 's:g95.*.NCDF_INC.*.$:g95      NCDF_INC= '"$ncdfdir"'/include:' \
     
    539563    $make clean
    540564    $make
    541     if [ "$compilo" = "$gfortran" -o "$compilo" = "mpif90" ] ; then # copy module files to lib
     565    if [ "$compiler" = "$gfortran" -o "$compiler" = "mpif90" ] ; then # copy module files to lib
    542566      cp -f *.mod ../../../lib
    543567    fi
     
    566590    cp AA_make.gdef AA_make.orig
    567591    sed -e 's/^\#.*.g95.*.\#.*.$/\#/' AA_make.gdef > tmp
    568     sed -e "s:F_L = g95:F_L = $compilo:" -e "s:F_C = g95 -c:F_C = $compilo -c": \
     592    sed -e "s:F_L = g95:F_L = $compiler:" -e "s:F_C = g95 -c:F_C = $compiler -c": \
    569593    -e 's/g95.*.w_w.*.(F_D)/g95      w_w = '"$OPTIMGCM"'/' \
    570594    -e 's:g95.*.NCDF_INC.*.$:g95      NCDF_INC= -I/smplocal/pub/HDF5/1.8.9/seq/include -I/smplocal/pub/NetCDF/4.1.3/include:' \
     
    618642     veget_version=orchidee2.0
    619643      cd arch
    620       sed -e s:"%COMPILER        .*.$":"%COMPILER            $compilo":1 \
    621      -e s:"%LINK            .*.$":"%LINK                $compilo":1 \
     644      sed -e s:"%COMPILER        .*.$":"%COMPILER            $compiler":1 \
     645     -e s:"%LINK            .*.$":"%LINK                $compiler":1 \
    622646     -e s:"%FPP_FLAGS       .*.$":"%FPP_FLAGS           $fpp_flags":1 \
    623647     -e s:"%PROD_FFLAGS     .*.$":"%PROD_FFLAGS         $OPTIM":1 \
     
    653677        if [ ! -d $src_d ] ; then echo Problem orchidee : no $src_d ; exit ; fi
    654678        cd $src_d ; \rm -f *.mod make ; $make clean
    655         $make ; if [ "$compilo" = "$gfortran" -o "$compilo" = "mpif90" ] ; then cp -f *.mod ../../../lib ; fi
     679        $make ; if [ "$compiler" = "$gfortran" -o "$compiler" = "mpif90" ] ; then cp -f *.mod ../../../lib ; fi
    656680        cd ..
    657681     done
     
    697721
    698722if [ $real = r8 ] ; then FPP_DEF=NC_DOUBLE ; else FPP_DEF="" ; fi
    699 sed -e s:"%COMPILER        .*.$":"%COMPILER            $compilo":1 \
    700     -e s:"%LINK            .*.$":"%LINK                $compilo":1 \
     723sed -e s:"%COMPILER        .*.$":"%COMPILER            $compiler":1 \
     724    -e s:"%LINK            .*.$":"%LINK                $compiler":1 \
    701725    -e s:"%PROD_FFLAGS     .*.$":"%PROD_FFLAGS         $OPTIM":1 \
    702726    -e s:"%DEV_FFLAGS      .*.$":"%DEV_FFLAGS          $OPTDEV":1 \
Note: See TracChangeset for help on using the changeset viewer.