source: ThirdParty/vmg/m4/ax_fcs_types.m4

Candidate_v1.6.1
Last change on this file was 7faa5c, checked in by Frederik Heber <heber@…>, 8 years ago

Merge commit 'de061d9d851257a04e924d4472df4523d33bb08b' as 'ThirdParty/vmg'

  • Property mode set to 100644
File size: 11.8 KB
Line 
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#
18AC_DEFUN([AX_FCS_TYPE_INT_SET],[
19AC_DEFINE([fcs_int], [$1], [Define to the integer type to use for FCS.])
20AC_DEFINE([FCS_MPI_INT], [$2], [Define to the MPI datatype that corresponds to the integer type to use for FCS.])
21AC_DEFINE([FCS_LMOD_INT], [$3], [Define to the printf length modifier that corresponds to the integer type to use for FCS.])
22AC_DEFINE([FCS_CONV_INT], [$4], [Define to the scanf conversion that corresponds to the integer type to use for FCS.])
23])
24
25
26AC_DEFUN([AX_FCS_TYPE_INT],[
27if 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.])
30elif 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.])
33elif 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.])
36elif 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.])
39else
40 AC_MSG_ERROR([Datatype $1 is not a supported C integer type to use for FCS.])
41fi
42])
43
44
45AC_DEFUN([AX_FCS_TYPE_FLOAT_SET],[
46AC_DEFINE([fcs_float], [$1], [Define to the floating type to use for FCS.])
47AC_DEFINE([FCS_MPI_FLOAT], [$2], [Define to the MPI datatype that corresponds to the floating type to use for FCS.])
48AC_DEFINE([FCS_LMOD_FLOAT], [$3], [Define to the printf length modifier that corresponds to the floating type to use for FCS.])
49AC_DEFINE([FCS_CONV_FLOAT], [$4], [Define to the scanf conversion that corresponds to the floating type to use for FCS.])
50])
51
52
53AC_DEFUN([AX_FCS_TYPE_FLOAT],[
54if 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.])
57elif 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.])
60elif 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.])
63else
64 AC_MSG_ERROR([Datatype $1 is not a supported C floating type to use for FCS.])
65fi
66])
67
68
69AC_DEFUN([AX_FCS_TYPE_INTEGER_SET],[
70AC_DEFINE([fcs_integer], [$1], [Define to the Fortran integer type to use for FCS, corresponding to fcs_int.])
71AC_DEFINE([FCS_MPI_INTEGER], [$2], [Define to the MPI datatype that corresponds to the Fortran integer type to use for FCS.])
72AC_DEFINE_UNQUOTED([fcs_integer_kind], [$3], [Define to the kind of fcs_integer.])
73AC_DEFINE_UNQUOTED([fcs_integer_kind_isoc], [$4], [Define to the ISO C kind of fcs_integer.])
74])
75
76
77AC_DEFUN([AX_FCS_TYPE_INTEGER],[
78AX_FORTRAN_C2F_KIND_ISOC([ax_kind_isoc],[$2])
79if test "$1" = "integer" ; then
80 AX_CHECK_KINDOF([integer])
81 AX_FCS_TYPE_INTEGER_SET([integer],[MPI_INTEGER],[${ax_check_kindof}],[${ax_kind_isoc}])
82elif 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}])
85elif 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}])
88elif 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}])
91else
92 AC_MSG_ERROR([Datatype $1 is not a supported Fortran integer type to use for FCS.])
93fi
94])
95
96
97AC_DEFUN([AX_FCS_TYPE_REAL_SET],[
98AC_DEFINE([fcs_real], [$1], [Define to the Fortran floating type to use for FCS, corresponding to fcs_float.])
99AC_DEFINE([FCS_MPI_REAL], [$2], [Define to the MPI datatype that corresponds to the Fortran floating type to use for FCS.])
100AC_DEFINE_UNQUOTED([fcs_real_kind], [$3], [Define to the kind of fcs_real.])
101AC_DEFINE_UNQUOTED([fcs_real_kind_isoc], [$4], [Define to the ISO C kind of fcs_real.])
102])
103
104
105AC_DEFUN([AX_FCS_TYPE_REAL],[
106AX_FORTRAN_C2F_KIND_ISOC([ax_kind_isoc],[$2])
107if test "$1" = "real" ; then
108 AX_CHECK_KINDOF([real])
109 AX_FCS_TYPE_REAL_SET([real],[MPI_REAL],[${ax_check_kindof}],[${ax_kind_isoc}])
110elif 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}])
113elif 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}])
116elif 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}])
119elif 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}])
122else
123 AC_MSG_ERROR([Datatype $1 is not an appropriate Fortran real type to use for FCS.])
124fi
125])
126
127
128# Add configure options to select C and Fortran types.
129AC_DEFUN_ONCE([AX_FCS_TYPES_ARGS],[
130AC_ARG_ENABLE([fcs-int],
131 [AS_HELP_STRING([--enable-fcs-int=TYPE],
132 [set FCS C integer type @<:@int@:>@])])
133AC_ARG_ENABLE([fcs-float],
134 [AS_HELP_STRING([--enable-fcs-float=TYPE],
135 [set FCS C floating type @<:@double@:>@])])
136AC_ARG_ENABLE([fcs-integer],
137 [AS_HELP_STRING([--enable-fcs-integer=TYPE],
138 [set FCS Fortran integer type])])
139AC_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.
146AC_DEFUN([AX_FCS_TYPES],[
147
148AC_REQUIRE([AX_FCS_TYPES_ARGS])
149
150fcs_int=
151fcs_integer=
152case "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 ;;
166esac
167
168fcs_float=
169fcs_real=
170case "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 ;;
184esac
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
191m4_define([have_f_not],[( test "x${enable_fcs_integer}" = x || test "x${enable_fcs_real}" = x )])
192m4_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 )])
193m4_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
195ax_fcs_types_sets_cc=
196ax_fcs_types_sets_fc=
197
198AC_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.
238if 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
245fi
246
247# Don't do this if the Fortran compiler was only set by us.
248if 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
255fi
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
263ax_fcs_c_set=
264if 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 ])
271fi
272if 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 ])
278fi
279if 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 ])
285fi
286
287
288# Modify configure arguments so that sub-configures do not need to determine missing types again.
289if 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
294fi
295
296if 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
301fi
302
303if 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
308fi
309
310if 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
315fi
316])
Note: See TracBrowser for help on using the repository browser.