#!/bin/bash set -e -u # exit on most (not all!) error codes, and error on unset variables # Installs xios # Rewritten 02/2024 A. Barral function read_args { ## Defaults install_dir=$(pwd) xios_branch="2.6" xios_rev="2568" arch="local" make_j="8" # Not inputs hdf5_home=$(dirname "$(dirname "$(readlink -f "$(which h5pcc)")")") mpi_home=$(dirname "$(dirname "$(readlink -f "$(which mpif90)")")") while (($# > 0)); do case $1 in "-h") cat < arch-local.env export MPI_LIB="-L${mpi_home}/lib -lmpi" export NETCDFC_INC="\$(nc-config --includedir)" export NETCDFC_LIB="\$(nc-config --libdir)" export NETCDFF_INC="\$(nf-config --includedir)" export NETCDFF_LIB="\$(nf-config --prefix)/lib" export NETCDFCXX_INC="\$(ncxx4-config --includedir)" export NETCDFCXX_LIB="\$(ncxx4-config --libdir)" eof cat < arch-local.fcm %CCOMPILER "$(which mpicc)" %FCOMPILER "$(which mpif90)" %LINKER "$(which mpif90)" %BASE_CFLAGS -w -std=c++11 -D__XIOS_EXCEPTION %PROD_CFLAGS -O3 -D BOOST_DISABLE_ASSERTS %DEV_CFLAGS -g -O2 %DEBUG_CFLAGS -g -DBZ_DEBUG %BASE_FFLAGS -D__NONE__ -ffree-line-length-none %PROD_FFLAGS -O3 %DEV_FFLAGS -g -O2 %DEBUG_FFLAGS -g %BASE_INC -D__NONE__ %BASE_LD -lstdc++ -Wl,-rpath=${mpi_home}/lib %CPP $(which mpicc) -EP %FPP cpp -P %MAKE make eof cat < arch-local.path NETCDF_INCDIR="-I\${NETCDFC_INC} -I\${NETCDFF_INC} -I\${NETCDFCXX_INC}" NETCDF_LIBDIR="-L\${NETCDFC_LIB} -L\${NETCDFF_LIB} -L\${NETCDFCXX_LIB}" NETCDF_LIB="-lnetcdf -lnetcdff -lnetcdf_c++4" HDF5_INCDIR="-I${hdf5_home}/include" HDF5_LIBDIR="-L${hdf5_home}/lib" HDF5_LIB="-lhdf5_hl -lhdf5 -lz -lcurl" eof } function make_xios { cd "$install_dir/XIOS" echo "Compiling xios, see $(pwd)/make_xios.out" ./make_xios --arch "$arch" --job "$make_j" >make_xios.out 2>&1 } read_args "$@" download_xios if [[ $arch = "local" ]]; then create_local_arch; fi make_xios