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" |
---|
19 | |
---|
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 |
---|
53 | |
---|
54 | # Install directory (get full path) |
---|
55 | mkdir -p $install_dir |
---|
56 | install_dir=$(cd $install_dir ; pwd -P ) |
---|
57 | |
---|
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 |
---|
69 | |
---|
70 | cd $install_dir |
---|
71 | svn co --revision $xios_rev $xios_http XIOS |
---|
72 | |
---|
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 |
---|
90 | |
---|
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 |
---|
116 | |
---|
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 |
---|
125 | |
---|
126 | # make XIOS |
---|
127 | cd $install_dir/XIOS |
---|
128 | ./make_xios --arch $arch --job 8 2>&1 | tee make_xios.out |
---|
129 | |
---|