1 | #!/bin/bash |
---|
2 | |
---|
3 | install_dir=$PWD |
---|
4 | compil_full="false" |
---|
5 | use_oasis="false" |
---|
6 | oasis="oasis3_mct" |
---|
7 | use_memtrack="false" |
---|
8 | job="1" |
---|
9 | netcdf_lib="netcdf4_par" |
---|
10 | compil_mode="prod" |
---|
11 | |
---|
12 | # Traitement de la ligne de commande |
---|
13 | while (($# > 0)) |
---|
14 | do |
---|
15 | case $1 in |
---|
16 | "-h"|"--help"|"-help") |
---|
17 | echo "make_xios - installs XIOS on your architecture" |
---|
18 | echo "make_xios [options]" |
---|
19 | echo "options :" |
---|
20 | echo " [--prod] : compilation in production mode (default)" |
---|
21 | echo " [--dev] : compilation in development mode" |
---|
22 | echo " [--debug] : compilation in debug mode" |
---|
23 | echo " --arch arch : to choose target architecture" |
---|
24 | echo " [--avail] : to know available target architectures " |
---|
25 | echo " [--full] : to generate dependencies and recompile from scratch" |
---|
26 | echo " [--use_oasis 'oasis3' 'oasis3_mct' : default oasis3_mct] : to use Oasis coupler" |
---|
27 | echo " [--doc] : to generate Doxygen documentation (not available yet)" |
---|
28 | echo " [--job ntasks] : to use parallel compilation with ntasks" |
---|
29 | echo " [--netcdf_lib 'netcdf4_par'/'netcdf4_seq'/'netcdf4_internal' : default netcdf4_par] : choice of netcdf library" |
---|
30 | echo " [--memtrack] : tracking memory leak - developper only" |
---|
31 | echo "Example : ./make_xios --prod --arch PW6_VARGAS" |
---|
32 | echo "Example : ./make_xios --avail" |
---|
33 | exit;; |
---|
34 | "--prod") compil_mode="prod" ; shift ;; |
---|
35 | "--dev") compil_mode="dev" ; shift ;; |
---|
36 | "--debug") compil_mode="debug" ; shift ;; |
---|
37 | "--arch") arch=$2 ; shift ; shift ;; |
---|
38 | "--avail") ls arch/*.fcm | cut -d"-" -f2 | cut -d"." -f1 ; exit ;; |
---|
39 | "--full") compil_full="true" ; shift ;; |
---|
40 | "--use_oasis") use_oasis="true" oasis=$2 ; shift ; shift ;; |
---|
41 | "--doc") doc="true" ; shift ;; |
---|
42 | "--job") job=$2 ; shift ; shift ;; |
---|
43 | "--netcdf_lib") netcdf_lib=$2 ; shift ; shift ;; |
---|
44 | "--memtrack") use_memtrack="true" ; shift ;; |
---|
45 | *) code="$1" ; shift ;; |
---|
46 | esac |
---|
47 | done |
---|
48 | |
---|
49 | # Installation des sources |
---|
50 | nb_files_gz=`ls $install_dir/tools/archive | grep tar.gz | wc -l` |
---|
51 | if [ ${nb_files_gz} -ne 0 ] |
---|
52 | then |
---|
53 | echo -e "- uncompress archives ..." |
---|
54 | for tarname in `ls $install_dir/tools/archive/*.tar.gz` ; do |
---|
55 | gunzip -f "$tarname" |
---|
56 | tar -xf ${tarname%.gz} |
---|
57 | done |
---|
58 | fi |
---|
59 | |
---|
60 | # Vérification de la présence d'un identifiant d'architecture. |
---|
61 | |
---|
62 | ############################################################### |
---|
63 | # lecture des chemins propres a l'architecture de la machine # |
---|
64 | # et configuration de l'environnement # |
---|
65 | ############################################################### |
---|
66 | |
---|
67 | rm -f .void_file |
---|
68 | echo > .void_file |
---|
69 | rm -rf .void_dir |
---|
70 | mkdir .void_dir |
---|
71 | |
---|
72 | if [[ !(-z $arch) ]] |
---|
73 | then |
---|
74 | rm -f $install_dir/arch.path |
---|
75 | rm -f $install_dir/arch.fcm |
---|
76 | rm -f $install_dir/arch.env |
---|
77 | ln -s $install_dir/arch/arch-${arch}.path $install_dir/arch.path |
---|
78 | ln -s $install_dir/arch/arch-${arch}.fcm $install_dir/arch.fcm |
---|
79 | |
---|
80 | if test -f $install_dir/arch/arch-${arch}.env |
---|
81 | then |
---|
82 | ln -s $install_dir/arch/arch-${arch}.env arch.env |
---|
83 | else |
---|
84 | ln -s $install_dir/.void_file arch.env |
---|
85 | fi |
---|
86 | |
---|
87 | source $install_dir/arch.env |
---|
88 | source $install_dir/arch.path |
---|
89 | else |
---|
90 | echo "Please choose a target achitecture --> list all available architecture using make_xios --avail!" |
---|
91 | exit 1 |
---|
92 | fi |
---|
93 | |
---|
94 | # Vérification de la présence d'un mode de compilation. |
---|
95 | |
---|
96 | if [[ "$compil_mode" == "prod" ]] |
---|
97 | then |
---|
98 | COMPIL_CFLAGS="%PROD_CFLAGS" |
---|
99 | COMPIL_FFLAGS="%PROD_FFLAGS" |
---|
100 | elif [[ "$compil_mode" == "dev" ]] |
---|
101 | then |
---|
102 | COMPIL_CFLAGS="%DEV_CFLAGS" |
---|
103 | COMPIL_FFLAGS="%DEV_FFLAGS" |
---|
104 | elif [[ "$compil_mode" == "debug" ]] |
---|
105 | then |
---|
106 | COMPIL_CFLAGS="%DEBUG_CFLAGS" |
---|
107 | COMPIL_FFLAGS="%DEBUG_FFLAGS" |
---|
108 | fi |
---|
109 | |
---|
110 | rm -r $PWD/extern/netcdf4 |
---|
111 | |
---|
112 | if [[ "$netcdf_lib" == "netcdf4_par" ]] |
---|
113 | then |
---|
114 | ln -s $PWD/.void_dir $PWD/extern/netcdf4 |
---|
115 | XMLIO_CPPKEY="$XMLIO_CPPKEY USING_NETCDF_PAR" |
---|
116 | elif [[ "$netcdf_lib" == "netcdf4_seq" ]] |
---|
117 | then |
---|
118 | ln -s $PWD/.void_dir $PWD/extern/netcdf4 |
---|
119 | elif [[ "$netcdf_lib" == "netcdf4_internal" ]] |
---|
120 | then |
---|
121 | ln -s $PWD/extern/src_netcdf4 $PWD/extern/netcdf4 |
---|
122 | XMLIO_CPPKEY="$XMLIO_CPPKEY USING_NETCDF_PAR USING_NETCDF_INTERNAL" |
---|
123 | export NETCDF_INCDIR="-I${PWD}/extern/netcdf4" |
---|
124 | export NETCDF_LIBDIR="" |
---|
125 | export NETCDF_LIB="" |
---|
126 | else |
---|
127 | echo "Bad choice for --netcdf_lib argument : choose between 'netcdf4_par','netcdf4_seq' or 'netcdf4_internal'" |
---|
128 | exit |
---|
129 | fi |
---|
130 | |
---|
131 | if [[ "$use_oasis" == "true" ]] |
---|
132 | then |
---|
133 | if [[ "$oasis" == "oasis3_mct" ]] |
---|
134 | then |
---|
135 | XMLIO_CPPKEY="$XMLIO_CPPKEY USE_OMCT" |
---|
136 | elif [[ "$oasis" == "oasis3" ]] |
---|
137 | then |
---|
138 | XMLIO_CPPKEY="$XMLIO_CPPKEY USE_OASIS" |
---|
139 | OASIS_INCDIR="-I$PWD/../../prism/X64/build/lib/psmile.MPI1" |
---|
140 | OASIS_LIBDIR="-L$PWD/../../prism/X64/lib" |
---|
141 | OASIS_LIB="-lpsmile.MPI1 -lmpp_io" |
---|
142 | else |
---|
143 | echo "Bad choice for --use_oasis argument : choose between 'oasis3','oasis3_mct'" |
---|
144 | exit |
---|
145 | fi |
---|
146 | NETCDF_LIB="-lnetcdff -lnetcdf" |
---|
147 | XMLIO_FINCDIR="$OASIS_INCDIR $XMLIO_FINCDIR" |
---|
148 | XMLIO_LIB="$OASIS_LIBDIR $OASIS_LIB $XMLIO_LIB" |
---|
149 | fi |
---|
150 | |
---|
151 | if [[ "$use_memtrack" == "true" ]] |
---|
152 | then |
---|
153 | XMLIO_LIB="$ADDR2LINE_LIBDIR $ADDR2LINE_LIB $XMLIO_LIB" |
---|
154 | XMLIO_CPPKEY="$XMLIO_CPPKEY XIOS_MEMTRACK" |
---|
155 | fi |
---|
156 | |
---|
157 | XMLIO_CINCDIR="$NETCDF_INCDIR $HDF5_INCDIR $MPI_INCDIR" |
---|
158 | XMLIO_FINCDIR="$XMLIO_FINCDIR $MPI_INCDIR" |
---|
159 | |
---|
160 | XMLIO_LIB="$XMLIO_LIB $NETCDF_LIBDIR $HDF5_LIBDIR $MPI_LIBDIR $NETCDF_LIB $HDF5_LIB $MPI_LIB" |
---|
161 | |
---|
162 | rm -f config.fcm |
---|
163 | echo "%COMPIL_CFLAGS $COMPIL_CFLAGS" >> config.fcm |
---|
164 | echo "%COMPIL_FFLAGS $COMPIL_FFLAGS" >> config.fcm |
---|
165 | echo "%CPP_KEY $XMLIO_CPPKEY" >> config.fcm |
---|
166 | |
---|
167 | echo "%CBASE_INC $XMLIO_CINCDIR" >> config.fcm |
---|
168 | echo "%FBASE_INC $XMLIO_FINCDIR" >> config.fcm |
---|
169 | echo "%ARCH_LD $XMLIO_LIB" >> config.fcm |
---|
170 | |
---|
171 | echo "=> Using "$compil_mode" mode for compiling under architecture \""$arch"\" !" |
---|
172 | |
---|
173 | # Création de la documentation doxygen. |
---|
174 | if [[ !(-z $doc) ]] |
---|
175 | then |
---|
176 | echo -e "- Create Doxygen documentation (disabled)..." |
---|
177 | #doxygen -s |
---|
178 | fi |
---|
179 | |
---|
180 | make_dir=$PWD |
---|
181 | |
---|
182 | export PATH=$PWD/tools/FCM/bin:$PATH |
---|
183 | |
---|
184 | #$make_dir/tools/preprocess_cpp $make_dir/src/xmlio/iface/interface.cpp $make_dir/src/xmlio/iface/interface.cpp.in |
---|
185 | #$make_dir/tools/preprocess_f03 $make_dir/src/xmlio/fortran/ixmlioserver.f90 $make_dir/src/xmlio/fortran/ixmlioserver.f03.in |
---|
186 | |
---|
187 | if [[ "$compil_full" == "true" ]] |
---|
188 | then |
---|
189 | fcm build --clean --ignore-lock |
---|
190 | fcm build -f --ignore-lock -j $job |
---|
191 | else |
---|
192 | fcm build --ignore-lock -j $job |
---|
193 | fi |
---|
194 | |
---|
195 | build_exit_status=$? |
---|
196 | |
---|
197 | if [[ $build_exit_status == 0 ]] |
---|
198 | then |
---|
199 | set nothing |
---|
200 | # cd $WORKDIR/XMLIO_NEMO_COUPLE/modeles/NEMO/WORK |
---|
201 | # cd $WORKDIR/XMLIO_NEMO/modeles/NEMO/WORK |
---|
202 | # make |
---|
203 | fi |
---|
204 | |
---|
205 | exit $build_exit_status |
---|