source: BOL/script_install_amaury/install_xios.bash @ 5400

Last change on this file since 5400 was 4871, checked in by abarral, 9 months ago

(WIP)
fix IOIPSL fcm arch
refactor install_xios

  • Property svn:executable set to *
File size: 3.3 KB
Line 
1#!/bin/bash
2set -e -u  # exit on most (not all!) error codes, and error on unset variables
3
4# Installs xios
5# Rewritten 02/2024 A. Barral
6
7function read_args {
8  ## Defaults
9  install_dir=$(pwd)
10
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)")")")
18
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}
38
39function download_xios {
40  # Install directory (get full path)
41  mkdir -p "$install_dir"
42  install_dir=$(cd "$install_dir" || exit 1; pwd -P)
43
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
51
52  cd "$install_dir" || exit 1
53  svn co --revision "$xios_rev" "$xios_http" XIOS
54}
55
56function create_local_arch {
57  cd "$install_dir/XIOS/arch" || exit 1
58
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 TracBrowser for help on using the repository browser.