Ignore:
Timestamp:
Mar 25, 2024, 10:27:44 AM (8 weeks ago)
Author:
abarral
Message:

(WIP)
fix IOIPSL fcm arch
refactor install_xios

File:
1 edited

Legend:

Unmodified
Added
Removed
  • BOL/script_install_amaury/install_xios.bash

    r4782 r4871  
    1 #!/bin/bash
    2 #########################################################################
    3 # Defaults
    4 #########################################################################
    5 hostname=`hostname`
    6 install_dir=$(pwd)
    7 netcdf_home="/usr/local/netcdf"
    8 hdf5_home="/usr/local/hdf5"
    9 if [ -d /usr/lib64/openmpi ] ; then
    10   mpi_home="/usr/lib64/openmpi"
    11 else
    12   mpi_home="/usr"
    13 fi
    14 arch="local"
    15 #xios_branch="trunk"
    16 xios_branch="2.6"
    17 #xios_rev="HEAD"
    18 xios_rev="2568"
     1#!/bin/bash
     2set -e -u  # exit on most (not all!) error codes, and error on unset variables
    193
    20 #########################################################################
    21 #  Options
    22 #########################################################################
    23 while (($# > 0))
    24    do
    25    case $1 in
    26      "-h") cat <<........fin
    27     $0 [ -prefix path ]       where (path) to install
    28                               (default: $install_dir)
    29        [ -netcdf path ]       top directory of the netcdf library
    30                               (default: $netcdf_home)
    31        [ -hdf5 path ]         top directory of the hdf5 library
    32                               (default: $hdf5_home)
    33        [ -MPI path ]          top directory of the MPI library
    34                               (default: $mpi_home)
    35        [ -branch branch]      XIOS branch trunk|2.5|2.6
    36                               (default: $xios_branch)
    37        [ -rev number ]        XIOS revision
    38                               (default: $xios_rev)
    39        [ -arch ARCH ]         Use ARCH file (provided by XIOS)
    40                               (default: make/use a local arch file)
    41 ........fin
    42      exit ;;
    43      "-prefix") install_dir=$2 ; shift ; shift ;;
    44      "-netcdf") netcdf_home=$2 ; shift ; shift ;;
    45      "-hdf5" ) hdf5_home=$2 ; shift ; shift ;;
    46      "-MPI") mpi_home=$2 ; shift ; shift ;;
    47      "-branch") xios_branch=$2 ; shift ; shift ;;
    48      "-rev") xios_rev=$2 ; shift ; shift ;;
    49      "-arch") arch=$2 ; shift ; shift ;;
    50      *) echo "Error, bad argument $1" ; $0 -h ; exit
    51    esac
    52 done
     4# Installs xios
     5# Rewritten 02/2024 A. Barral
    536
    54 # Install directory (get full path)
    55 mkdir -p $install_dir
    56 install_dir=$(cd $install_dir ; pwd -P )
     7function read_args {
     8  ## Defaults
     9  install_dir=$(pwd)
    5710
    58 # Download XIOS
    59 case $xios_branch in
    60   "trunk")
    61   xios_http="http://forge.ipsl.jussieu.fr/ioserver/svn/XIOS/trunk" ;;
    62   "2.5")
    63   xios_http="http://forge.ipsl.jussieu.fr/ioserver/svn/XIOS/branchs/xios-2.5" ;;
    64   "2.6")
    65   xios_http="http://forge.ipsl.jussieu.fr/ioserver/svn/XIOS2/branches/xios-2.6" ;;
    66 *)
    67 echo "Error, bad argument for -branch ! Did not expect $xios_branch" ; exit ;;
    68 esac
     11  xios_branch="2.6"
     12  xios_rev="2568"
     13  arch="local"
     14  make_j="8"
     15  # Not inputs
     16  hdf5_home=$(dirname "$(dirname "$(readlink -f "$(which h5pcc)")")")
     17  mpi_home=$(dirname "$(dirname "$(readlink -f "$(which mpif90)")")")
    6918
    70 cd $install_dir
    71 svn co --revision $xios_rev $xios_http XIOS
     19  while (($# > 0)); do
     20    case $1 in
     21      "-h") cat <<eof
     22      $0 [ -prefix path ]       where (path) to install (default: $install_dir)
     23      [ -branch branch]         XIOS branch trunk|2.5|2.6 (default: $xios_branch)
     24      [ -rev number ]           XIOS revision (default: $xios_rev)
     25      [ -arch ARCH ]            Use ARCH file (provided by XIOS) (default: make/use a local arch file)
     26      [ -make_j N ]             Number of procs for compilation
     27eof
     28      exit;;
     29      "-prefix") install_dir=$2; shift; shift;;
     30      "-branch") xios_branch=$2; shift; shift;;
     31      "-rev") xios_rev=$2; shift; shift;;
     32      "-arch") arch=$2; shift; shift;;
     33      "-make_j") make_j=$2; shift; shift;;
     34      *) echo "Error, bad argument $1"; $0 -h; exit
     35    esac
     36  done
     37}
    7238
    73 # Make arch files, if necesary:
    74 if [ "$arch" = "local" ] ; then
    75 cd $install_dir/XIOS/arch
    76 # arch-local.env
    77 echo 'export MPI_LIB="-L'${mpi_home}'/lib -lmpi"'     > arch-local.env
    78 echo ''                                              >> arch-local.env
    79 echo 'export NETCDFC='${netcdf_home}                 >> arch-local.env
    80 echo 'export NETCDFC_LIB=$NETCDFC/lib'               >> arch-local.env
    81 echo 'export NETCDFC_INC=$NETCDFC/include'           >> arch-local.env
    82 echo ''                                              >> arch-local.env
    83 echo 'export NETCDFF='${netcdf_home}                 >> arch-local.env
    84 echo 'export NETCDFF_LIB=$NETCDFF/lib'               >> arch-local.env
    85 echo 'export NETCDFF_INC=$NETCDFF/include'           >> arch-local.env
    86 echo ''                                              >> arch-local.env
    87 echo 'export NETCDFCXX='${netcdf_home}               >> arch-local.env
    88 echo 'export NETCDFCXX_LIB=$NETCDFCXX/lib'           >> arch-local.env
    89 echo 'export NETCDFCXX_INC=$NETCDFCXX/include'       >> arch-local.env
     39function download_xios {
     40  # Install directory (get full path)
     41  mkdir -p "$install_dir"
     42  install_dir=$(cd "$install_dir" || exit 1; pwd -P)
    9043
    91 # arch-local.fcm
    92 echo '%CCOMPILER      '${mpi_home}'/bin/mpicc'             > arch-local.fcm
    93 echo '%FCOMPILER      '${mpi_home}'/bin/mpif90'           >> arch-local.fcm
    94 echo '%LINKER         '${mpi_home}'/bin/mpif90'           >> arch-local.fcm
    95 echo ''                                                   >> arch-local.fcm
    96 if [ ${hostname:0:5} = cicla ] ; then
    97 echo '%BASE_CFLAGS    -w -ansi'                >> arch-local.fcm
    98 else
    99 echo '%BASE_CFLAGS    -w -std=c++11 -D__XIOS_EXCEPTION'   >> arch-local.fcm
    100 fi
    101 echo '%PROD_CFLAGS    -O3 -D BOOST_DISABLE_ASSERTS'       >> arch-local.fcm
    102 echo '%DEV_CFLAGS     -g -O2'                             >> arch-local.fcm
    103 echo '%DEBUG_CFLAGS   -g -DBZ_DEBUG'                      >> arch-local.fcm
    104 echo ''                                                   >> arch-local.fcm
    105 echo '%BASE_FFLAGS    -D__NONE__ -ffree-line-length-none' >> arch-local.fcm
    106 echo '%PROD_FFLAGS    -O3'                                >> arch-local.fcm
    107 echo '%DEV_FFLAGS     -g -O2'                             >> arch-local.fcm
    108 echo '%DEBUG_FFLAGS   -g'                                 >> arch-local.fcm
    109 echo ''                                                   >> arch-local.fcm
    110 echo '%BASE_INC       -D__NONE__'                         >> arch-local.fcm
    111 echo '%BASE_LD        -lstdc++ -Wl,-rpath='${mpi_home}'/lib' >> arch-local.fcm
    112 echo ''                                                   >> arch-local.fcm
    113 echo '%CPP            '${mpi_home}'/bin/mpicc -EP'        >> arch-local.fcm
    114 echo '%FPP            cpp -P'                             >> arch-local.fcm
    115 echo '%MAKE           make'                               >> arch-local.fcm
     44  local xios_http
     45  case $xios_branch in
     46    "trunk") xios_http="http://forge.ipsl.jussieu.fr/ioserver/svn/XIOS/trunk";;
     47    "2.5") xios_http="http://forge.ipsl.jussieu.fr/ioserver/svn/XIOS/branchs/xios-2.5";;
     48    "2.6") xios_http="http://forge.ipsl.jussieu.fr/ioserver/svn/XIOS2/branches/xios-2.6";;
     49    *) echo "Error, bad argument for -branch ! Did not expect $xios_branch"; exit 1;;
     50  esac
    11651
    117 # arch-local.path
    118 echo 'NETCDF_INCDIR="-I${NETCDFC_INC} -I${NETCDFF_INC} -I${NETCDFCXX_INC} "'  > arch-local.path
    119 echo 'NETCDF_LIBDIR="-L${NETCDFC_LIB} -L${NETCDFF_LIB} -L${NETCDFCXX_LIB} "' >> arch-local.path
    120 echo 'NETCDF_LIB="-lnetcdf -lnetcdff -lnetcdf_c++4"'                         >> arch-local.path
    121 echo 'HDF5_INCDIR="-I'${hdf5_home}'/include"'                                >> arch-local.path
    122 echo 'HDF5_LIBDIR="-L'${hdf5_home}'/lib"'                                    >> arch-local.path
    123 echo 'HDF5_LIB="-lhdf5_hl -lhdf5 -lhdf5 -lz -lcurl"'                         >> arch-local.path
    124 fi
     52  cd "$install_dir" || exit 1
     53  svn co --revision "$xios_rev" "$xios_http" XIOS
     54}
    12555
    126 # make XIOS
    127 cd $install_dir/XIOS
    128 ./make_xios --arch $arch --job 8 2>&1 | tee make_xios.out
     56function create_local_arch {
     57  cd "$install_dir/XIOS/arch" || exit 1
    12958
     59  cat <<eof > arch-local.env
     60export MPI_LIB="-L${mpi_home}/lib -lmpi"
     61
     62export NETCDFC_INC="\$(nc-config --includedir)"
     63export NETCDFC_LIB="\$(nc-config --libdir)"
     64
     65export NETCDFF_INC="\$(nf-config --includedir)"
     66export NETCDFF_LIB="\$(nf-config --prefix)/lib"
     67
     68export NETCDFCXX_INC="\$(ncxx4-config --includedir)"
     69export NETCDFCXX_LIB="\$(ncxx4-config --libdir)"
     70eof
     71
     72  cat <<eof > arch-local.fcm
     73%CCOMPILER      "$(which mpicc)"
     74%FCOMPILER      "$(which mpif90)"
     75%LINKER         "$(which mpif90)"
     76
     77%BASE_CFLAGS    -w -std=c++11 -D__XIOS_EXCEPTION
     78%PROD_CFLAGS    -O3 -D BOOST_DISABLE_ASSERTS
     79%DEV_CFLAGS     -g -O2
     80%DEBUG_CFLAGS   -g -DBZ_DEBUG
     81
     82%BASE_FFLAGS    -D__NONE__ -ffree-line-length-none
     83%PROD_FFLAGS    -O3
     84%DEV_FFLAGS     -g -O2
     85%DEBUG_FFLAGS   -g
     86
     87%BASE_INC       -D__NONE__
     88%BASE_LD        -lstdc++ -Wl,-rpath=${mpi_home}/lib
     89
     90%CPP            $(which mpicc) -EP
     91%FPP            cpp -P
     92%MAKE           make
     93eof
     94  cat <<eof > arch-local.path
     95NETCDF_INCDIR="-I\${NETCDFC_INC} -I\${NETCDFF_INC} -I\${NETCDFCXX_INC}"
     96NETCDF_LIBDIR="-L\${NETCDFC_LIB} -L\${NETCDFF_LIB} -L\${NETCDFCXX_LIB}"
     97NETCDF_LIB="-lnetcdf -lnetcdff -lnetcdf_c++4"
     98
     99HDF5_INCDIR="-I${hdf5_home}/include"
     100HDF5_LIBDIR="-L${hdf5_home}/lib"
     101HDF5_LIB="-lhdf5_hl -lhdf5 -lz -lcurl"
     102eof
     103}
     104
     105function make_xios {
     106  cd "$install_dir/XIOS"
     107  echo "Compiling xios, see $(pwd)/make_xios.out"
     108  ./make_xios --arch "$arch" --job "$make_j" >make_xios.out 2>&1
     109}
     110
     111read_args "$@"
     112download_xios
     113if [[ $arch = "local" ]]; then create_local_arch; fi
     114make_xios
     115
Note: See TracChangeset for help on using the changeset viewer.