1 | # Copyright (C) 2011 The ScaFaCoS project
|
---|
2 | #
|
---|
3 | # This file is part of ScaFaCoS.
|
---|
4 | #
|
---|
5 | # ScaFaCoS is free software: you can redistribute it and/or modify it
|
---|
6 | # under the terms of the GNU Lesser Public License as published by
|
---|
7 | # the Free Software Foundation, either version 3 of the License, or
|
---|
8 | # (at your option) any later version.
|
---|
9 | #
|
---|
10 | # ScaFaCoS is distributed in the hope that it will be useful,
|
---|
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
13 | # GNU Lesser Public License for more details.
|
---|
14 | #
|
---|
15 | # You should have received a copy of the GNU Lesser Public License
|
---|
16 | # along with this program. If not, see <http://www.gnu.org/licenses/>.
|
---|
17 | #
|
---|
18 | AC_DEFUN([AX_FCS_TYPE_INT_SET],[
|
---|
19 | AC_DEFINE([fcs_int], [$1], [Define to the integer type to use for FCS.])
|
---|
20 | AC_DEFINE([FCS_MPI_INT], [$2], [Define to the MPI datatype that corresponds to the integer type to use for FCS.])
|
---|
21 | AC_DEFINE([FCS_LMOD_INT], [$3], [Define to the printf length modifier that corresponds to the integer type to use for FCS.])
|
---|
22 | AC_DEFINE([FCS_CONV_INT], [$4], [Define to the scanf conversion that corresponds to the integer type to use for FCS.])
|
---|
23 | ])
|
---|
24 |
|
---|
25 |
|
---|
26 | AC_DEFUN([AX_FCS_TYPE_INT],[
|
---|
27 | if test "$1" = "short" ; then
|
---|
28 | AX_FCS_TYPE_INT_SET([short],[MPI_SHORT],["h"],["h"])
|
---|
29 | AC_DEFINE([FCS_INT_IS_SHORT], [1], [Define whether fcs_int is short.])
|
---|
30 | elif test "$1" = "int" ; then
|
---|
31 | AX_FCS_TYPE_INT_SET([int],[MPI_INT],[""])
|
---|
32 | AC_DEFINE([FCS_INT_IS_INT], [1], [Define whether fcs_int is int.])
|
---|
33 | elif test "$1" = "long" ; then
|
---|
34 | AX_FCS_TYPE_INT_SET([long],[MPI_LONG],["l"],["l"])
|
---|
35 | AC_DEFINE([FCS_INT_IS_LONG], [1], [Define whether fcs_int is long.])
|
---|
36 | elif test "$1" = "long long" ; then
|
---|
37 | AX_FCS_TYPE_INT_SET([long long],[MPI_LONG_LONG],["ll"],["ll"])
|
---|
38 | AC_DEFINE([FCS_INT_IS_LONG_LONG], [1], [Define whether fcs_int is long long.])
|
---|
39 | else
|
---|
40 | AC_MSG_ERROR([Datatype $1 is not a supported C integer type to use for FCS.])
|
---|
41 | fi
|
---|
42 | ])
|
---|
43 |
|
---|
44 |
|
---|
45 | AC_DEFUN([AX_FCS_TYPE_FLOAT_SET],[
|
---|
46 | AC_DEFINE([fcs_float], [$1], [Define to the floating type to use for FCS.])
|
---|
47 | AC_DEFINE([FCS_MPI_FLOAT], [$2], [Define to the MPI datatype that corresponds to the floating type to use for FCS.])
|
---|
48 | AC_DEFINE([FCS_LMOD_FLOAT], [$3], [Define to the printf length modifier that corresponds to the floating type to use for FCS.])
|
---|
49 | AC_DEFINE([FCS_CONV_FLOAT], [$4], [Define to the scanf conversion that corresponds to the floating type to use for FCS.])
|
---|
50 | ])
|
---|
51 |
|
---|
52 |
|
---|
53 | AC_DEFUN([AX_FCS_TYPE_FLOAT],[
|
---|
54 | if test "$1" = "float" ; then
|
---|
55 | AX_FCS_TYPE_FLOAT_SET([float],[MPI_FLOAT],[""],[""])
|
---|
56 | AC_DEFINE([FCS_FLOAT_IS_FLOAT], [1], [Define whether fcs_float is float.])
|
---|
57 | elif test "$1" = "double" ; then
|
---|
58 | AX_FCS_TYPE_FLOAT_SET([double],[MPI_DOUBLE],[""],["l"])
|
---|
59 | AC_DEFINE([FCS_FLOAT_IS_DOUBLE], [1], [Define whether fcs_float is double.])
|
---|
60 | elif test "$1" = "long double" ; then
|
---|
61 | AX_FCS_TYPE_FLOAT_SET([long double],[MPI_LONG_DOUBLE],["L"],["L"])
|
---|
62 | AC_DEFINE([FCS_FLOAT_IS_LONG_DOUBLE], [1], [Define whether fcs_float is long double.])
|
---|
63 | else
|
---|
64 | AC_MSG_ERROR([Datatype $1 is not a supported C floating type to use for FCS.])
|
---|
65 | fi
|
---|
66 | ])
|
---|
67 |
|
---|
68 |
|
---|
69 | AC_DEFUN([AX_FCS_TYPE_INTEGER_SET],[
|
---|
70 | AC_DEFINE([fcs_integer], [$1], [Define to the Fortran integer type to use for FCS, corresponding to fcs_int.])
|
---|
71 | AC_DEFINE([FCS_MPI_INTEGER], [$2], [Define to the MPI datatype that corresponds to the Fortran integer type to use for FCS.])
|
---|
72 | AC_DEFINE_UNQUOTED([fcs_integer_kind], [$3], [Define to the kind of fcs_integer.])
|
---|
73 | AC_DEFINE_UNQUOTED([fcs_integer_kind_isoc], [$4], [Define to the ISO C kind of fcs_integer.])
|
---|
74 | ])
|
---|
75 |
|
---|
76 |
|
---|
77 | AC_DEFUN([AX_FCS_TYPE_INTEGER],[
|
---|
78 | AX_FORTRAN_C2F_KIND_ISOC([ax_kind_isoc],[$2])
|
---|
79 | if test "$1" = "integer" ; then
|
---|
80 | AX_CHECK_KINDOF([integer])
|
---|
81 | AX_FCS_TYPE_INTEGER_SET([integer],[MPI_INTEGER],[${ax_check_kindof}],[${ax_kind_isoc}])
|
---|
82 | elif test "$1" = "integer*2" ; then
|
---|
83 | AX_CHECK_KINDOF([integer*2])
|
---|
84 | AX_FCS_TYPE_INTEGER_SET([integer*2],[MPI_INTEGER2],[${ax_check_kindof}],[${ax_kind_isoc}])
|
---|
85 | elif test "$1" = "integer*4" ; then
|
---|
86 | AX_CHECK_KINDOF([integer*4])
|
---|
87 | AX_FCS_TYPE_INTEGER_SET([integer*4],[MPI_INTEGER4],[${ax_check_kindof}],[${ax_kind_isoc}])
|
---|
88 | elif test "$1" = "integer*8" ; then
|
---|
89 | AX_CHECK_KINDOF([integer*8])
|
---|
90 | AX_FCS_TYPE_INTEGER_SET([integer*8],[MPI_INTEGER8],[${ax_check_kindof}],[${ax_kind_isoc}])
|
---|
91 | else
|
---|
92 | AC_MSG_ERROR([Datatype $1 is not a supported Fortran integer type to use for FCS.])
|
---|
93 | fi
|
---|
94 | ])
|
---|
95 |
|
---|
96 |
|
---|
97 | AC_DEFUN([AX_FCS_TYPE_REAL_SET],[
|
---|
98 | AC_DEFINE([fcs_real], [$1], [Define to the Fortran floating type to use for FCS, corresponding to fcs_float.])
|
---|
99 | AC_DEFINE([FCS_MPI_REAL], [$2], [Define to the MPI datatype that corresponds to the Fortran floating type to use for FCS.])
|
---|
100 | AC_DEFINE_UNQUOTED([fcs_real_kind], [$3], [Define to the kind of fcs_real.])
|
---|
101 | AC_DEFINE_UNQUOTED([fcs_real_kind_isoc], [$4], [Define to the ISO C kind of fcs_real.])
|
---|
102 | ])
|
---|
103 |
|
---|
104 |
|
---|
105 | AC_DEFUN([AX_FCS_TYPE_REAL],[
|
---|
106 | AX_FORTRAN_C2F_KIND_ISOC([ax_kind_isoc],[$2])
|
---|
107 | if test "$1" = "real" ; then
|
---|
108 | AX_CHECK_KINDOF([real])
|
---|
109 | AX_FCS_TYPE_REAL_SET([real],[MPI_REAL],[${ax_check_kindof}],[${ax_kind_isoc}])
|
---|
110 | elif test "$1" = "double precision" ; then
|
---|
111 | AX_CHECK_KINDOF([double precision])
|
---|
112 | AX_FCS_TYPE_REAL_SET([double precision],[MPI_DOUBLE_PRECISION],[${ax_check_kindof}],[${ax_kind_isoc}])
|
---|
113 | elif test "$1" = "real*4" ; then
|
---|
114 | AX_CHECK_KINDOF([real*4])
|
---|
115 | AX_FCS_TYPE_REAL_SET([real*4],[MPI_REAL4],[${ax_check_kindof}],[${ax_kind_isoc}])
|
---|
116 | elif test "$1" = "real*8" ; then
|
---|
117 | AX_CHECK_KINDOF([real*8])
|
---|
118 | AX_FCS_TYPE_REAL_SET([real*8],[MPI_REAL8],[${ax_check_kindof}],[${ax_kind_isoc}])
|
---|
119 | elif test "$1" = "real*16" ; then
|
---|
120 | AX_CHECK_KINDOF([real*16])
|
---|
121 | AX_FCS_TYPE_REAL_SET([real*16],[MPI_REAL16],[${ax_check_kindof}],[${ax_kind_isoc}])
|
---|
122 | else
|
---|
123 | AC_MSG_ERROR([Datatype $1 is not an appropriate Fortran real type to use for FCS.])
|
---|
124 | fi
|
---|
125 | ])
|
---|
126 |
|
---|
127 |
|
---|
128 | # Add configure options to select C and Fortran types.
|
---|
129 | AC_DEFUN_ONCE([AX_FCS_TYPES_ARGS],[
|
---|
130 | AC_ARG_ENABLE([fcs-int],
|
---|
131 | [AS_HELP_STRING([--enable-fcs-int=TYPE],
|
---|
132 | [set FCS C integer type @<:@int@:>@])])
|
---|
133 | AC_ARG_ENABLE([fcs-float],
|
---|
134 | [AS_HELP_STRING([--enable-fcs-float=TYPE],
|
---|
135 | [set FCS C floating type @<:@double@:>@])])
|
---|
136 | AC_ARG_ENABLE([fcs-integer],
|
---|
137 | [AS_HELP_STRING([--enable-fcs-integer=TYPE],
|
---|
138 | [set FCS Fortran integer type])])
|
---|
139 | AC_ARG_ENABLE([fcs-real],
|
---|
140 | [AS_HELP_STRING([--enable-fcs-real=TYPE],
|
---|
141 | [set FCS Fortran floating type])])
|
---|
142 | ])
|
---|
143 |
|
---|
144 |
|
---|
145 | # Set up FCS integer and floating point types for C and Fortran.
|
---|
146 | AC_DEFUN([AX_FCS_TYPES],[
|
---|
147 |
|
---|
148 | AC_REQUIRE([AX_FCS_TYPES_ARGS])
|
---|
149 |
|
---|
150 | fcs_int=
|
---|
151 | fcs_integer=
|
---|
152 | case "x${enable_fcs_int}:x${enable_fcs_integer}" in
|
---|
153 | x:x)
|
---|
154 | fcs_int="int"
|
---|
155 | ;;
|
---|
156 | x*:x)
|
---|
157 | fcs_int="${enable_fcs_int}"
|
---|
158 | ;;
|
---|
159 | x:x*)
|
---|
160 | fcs_integer="${enable_fcs_integer}"
|
---|
161 | ;;
|
---|
162 | *)
|
---|
163 | fcs_int="${enable_fcs_int}"
|
---|
164 | fcs_integer="${enable_fcs_integer}"
|
---|
165 | ;;
|
---|
166 | esac
|
---|
167 |
|
---|
168 | fcs_float=
|
---|
169 | fcs_real=
|
---|
170 | case "x${enable_fcs_float}:x${enable_fcs_real}" in
|
---|
171 | x:x)
|
---|
172 | fcs_float="double"
|
---|
173 | ;;
|
---|
174 | x*:x)
|
---|
175 | fcs_float="${enable_fcs_float}"
|
---|
176 | ;;
|
---|
177 | x:x*)
|
---|
178 | fcs_real="${enable_fcs_real}"
|
---|
179 | ;;
|
---|
180 | *)
|
---|
181 | fcs_float="${enable_fcs_float}"
|
---|
182 | fcs_real="${enable_fcs_real}"
|
---|
183 | ;;
|
---|
184 | esac
|
---|
185 |
|
---|
186 | # Check if C and/or Fortran compilers are required to determine missing types.
|
---|
187 |
|
---|
188 | # The following conditionals ensure that the AX_PROG_..._MPI macros determine only MPI C and/or Fortran compilers if they are required.
|
---|
189 | # If they are not required then the corresponding non-MPI C and Fortran compilers are set up by AX_PROG_..._MPI.
|
---|
190 |
|
---|
191 | m4_define([have_f_not],[( test "x${enable_fcs_integer}" = x || test "x${enable_fcs_real}" = x )])
|
---|
192 | m4_define([have_c_not_or_have_f_not],[( test "x${enable_fcs_int}" = x || test "x${enable_fcs_float}" = x || test "x${enable_fcs_integer}" = x || test "x${enable_fcs_real}" = x )])
|
---|
193 | m4_define([have_c_not_and_have_f],[( ( test "x${enable_fcs_int}" = x && test "x${enable_fcs_integer}" != x ) || ( test "x${enable_fcs_float}" = x && test "x${enable_fcs_real}" != x ) )])
|
---|
194 |
|
---|
195 | ax_fcs_types_sets_cc=
|
---|
196 | ax_fcs_types_sets_fc=
|
---|
197 |
|
---|
198 | AC_PROVIDE_IFELSE([AC_PROG_FC],
|
---|
199 | [AC_PROVIDE_IFELSE([AC_PROG_CC],
|
---|
200 | [#echo "A: nothing"
|
---|
201 | ],
|
---|
202 | [AC_PROVIDE_IFELSE([AC_PROG_CXX],
|
---|
203 | [#echo "B: require CC if have_c_not_or_have_f_not"
|
---|
204 | ax_fcs_types_sets_cc=yes
|
---|
205 | AC_REQUIRE([AX_PROG_CC_MPI],[AX_PROG_CC_MPI([have_c_not_or_have_f_not],,[have_c_not_or_have_f_not && AC_MSG_FAILURE([The FCS library requires an MPI C compiler.])])])
|
---|
206 | ],
|
---|
207 | [#echo "C: require CC if have_f_not"
|
---|
208 | ax_fcs_types_sets_cc=yes
|
---|
209 | AC_REQUIRE([AX_PROG_CC_MPI],[AX_PROG_CC_MPI([have_f_not],,[have_f_not && AC_MSG_FAILURE([The FCS library requires an MPI C compiler.])])])
|
---|
210 | ]
|
---|
211 | )
|
---|
212 | ]
|
---|
213 | )
|
---|
214 | ],
|
---|
215 | [AC_PROVIDE_IFELSE([AC_PROG_CC],
|
---|
216 | [#echo "D: require FC if have_c_not_and_have_f"
|
---|
217 | ax_fcs_types_sets_fc=yes
|
---|
218 | AC_REQUIRE([AX_PROG_FC_MPI],[AX_PROG_FC_MPI([have_c_not_and_have_f],,[have_c_not_and_have_f && AC_MSG_FAILURE([The FCS library requires an MPI Fortran compiler.])])])
|
---|
219 | ],
|
---|
220 | [AC_PROVIDE_IFELSE([AC_PROG_CXX],
|
---|
221 | [#echo "E: require CC and FC if have_c_not_and_have_f"
|
---|
222 | ax_fcs_types_sets_cc=yes
|
---|
223 | AC_REQUIRE([AX_PROG_CC_MPI],[AX_PROG_CC_MPI([have_c_not_and_have_f],,[have_c_not_and_have_f && AC_MSG_FAILURE([The FCS library requires an MPI C compiler.])])])
|
---|
224 | ax_fcs_types_sets_fc=yes
|
---|
225 | AC_REQUIRE([AX_PROG_FC_MPI],[AX_PROG_FC_MPI([have_c_not_and_have_f],,[have_c_not_and_have_f && AC_MSG_FAILURE([The FCS library requires an MPI Fortran compiler.])])])
|
---|
226 | ],
|
---|
227 | [#echo "F: nothing"
|
---|
228 | ]
|
---|
229 | )
|
---|
230 | ]
|
---|
231 | )
|
---|
232 | ]
|
---|
233 | )
|
---|
234 |
|
---|
235 | # Determine missing C and Fortran types.
|
---|
236 |
|
---|
237 | # Don't do this if the C compiler was only set by us.
|
---|
238 | if test "x${ax_fcs_types_sets_cc}" != xyes ; then
|
---|
239 | if test "x${fcs_int}" = x ; then :
|
---|
240 | AX_FORTRAN_F2C_TYPE([fcs_int],[${fcs_integer}],[short,int,long,long long])
|
---|
241 | fi
|
---|
242 | if test "x${fcs_float}" = x ; then :
|
---|
243 | AX_FORTRAN_F2C_TYPE([fcs_float],[${fcs_real}],[float,double,long double])
|
---|
244 | fi
|
---|
245 | fi
|
---|
246 |
|
---|
247 | # Don't do this if the Fortran compiler was only set by us.
|
---|
248 | if test "x${ax_fcs_types_sets_fc}" != xyes ; then
|
---|
249 | if test "x${fcs_integer}" = x ; then :
|
---|
250 | AX_FORTRAN_C2F_TYPE([fcs_integer],[${fcs_int}],[integer,integer*2,integer*4,integer*8])
|
---|
251 | fi
|
---|
252 | if test "x${fcs_real}" = x ; then :
|
---|
253 | AX_FORTRAN_C2F_TYPE([fcs_real],[${fcs_float}],[real,real*4,real*8,real*16])
|
---|
254 | fi
|
---|
255 | fi
|
---|
256 |
|
---|
257 | # Set the FCS types.
|
---|
258 |
|
---|
259 | # At this point AC_PROG_CC and AC_PROG_FC might only be provided, because we have used the corresponding _MPI macros.
|
---|
260 | # However, ax_fcs_types_sets_cc and ax_fcs_types_sets_fc tells us whether we have used the _MPI macros or not.
|
---|
261 | # Thus, we set FCS C types only if we have not used AC_PROG_CC_MPI and we set FCS Fortran types only if we have not used AC_PROG_FC_MPI.
|
---|
262 |
|
---|
263 | ax_fcs_c_set=
|
---|
264 | if test "x${ax_fcs_types_sets_cc}" = x ; then
|
---|
265 | AC_PROVIDE_IFELSE([AC_PROG_CC],
|
---|
266 | [ax_fcs_c_set=yes
|
---|
267 | AX_FCS_TYPE_INT([${fcs_int}])
|
---|
268 | AX_FCS_TYPE_FLOAT([${fcs_float}])
|
---|
269 | AC_MSG_NOTICE([FCS C types: ${fcs_int}, ${fcs_float}])
|
---|
270 | ])
|
---|
271 | fi
|
---|
272 | if test "x${ax_fcs_c_set}" != xyes ; then :
|
---|
273 | AC_PROVIDE_IFELSE([AC_PROG_CXX],
|
---|
274 | [AX_FCS_TYPE_INT([${fcs_int}])
|
---|
275 | AX_FCS_TYPE_FLOAT([${fcs_float}])
|
---|
276 | AC_MSG_NOTICE([FCS C types: ${fcs_int}, ${fcs_float}])
|
---|
277 | ])
|
---|
278 | fi
|
---|
279 | if test "x${ax_fcs_types_sets_fc}" = x ; then
|
---|
280 | AC_PROVIDE_IFELSE([AC_PROG_FC],
|
---|
281 | [AX_FCS_TYPE_INTEGER([${fcs_integer}],[${fcs_int}])
|
---|
282 | AX_FCS_TYPE_REAL([${fcs_real}],[${fcs_float}])
|
---|
283 | AC_MSG_NOTICE([FCS Fortran types: ${fcs_integer}, ${fcs_real}])
|
---|
284 | ])
|
---|
285 | fi
|
---|
286 |
|
---|
287 |
|
---|
288 | # Modify configure arguments so that sub-configures do not need to determine missing types again.
|
---|
289 | if test "x${fcs_int}" != x ; then
|
---|
290 | case ${ac_configure_args} in
|
---|
291 | *--enable-fcs-int=*) ;;
|
---|
292 | *) ac_configure_args="${ac_configure_args} '--enable-fcs-int=${fcs_int}'"
|
---|
293 | esac
|
---|
294 | fi
|
---|
295 |
|
---|
296 | if test "x${fcs_float}" != x ; then
|
---|
297 | case ${ac_configure_args} in
|
---|
298 | *--enable-fcs-float=*) ;;
|
---|
299 | *) ac_configure_args="${ac_configure_args} '--enable-fcs-float=${fcs_float}'"
|
---|
300 | esac
|
---|
301 | fi
|
---|
302 |
|
---|
303 | if test "x${fcs_integer}" != x ; then
|
---|
304 | case ${ac_configure_args} in
|
---|
305 | *--enable-fcs-integer=*) ;;
|
---|
306 | *) ac_configure_args="${ac_configure_args} '--enable-fcs-integer=${fcs_integer}'"
|
---|
307 | esac
|
---|
308 | fi
|
---|
309 |
|
---|
310 | if test "x${fcs_real}" != x ; then
|
---|
311 | case ${ac_configure_args} in
|
---|
312 | *--enable-fcs-real=*) ;;
|
---|
313 | *) ac_configure_args="${ac_configure_args} '--enable-fcs-real=${fcs_real}'"
|
---|
314 | esac
|
---|
315 | fi
|
---|
316 | ])
|
---|