1dnl  This file is part of MED.
2dnl
3dnl  COPYRIGHT (C) 1999 - 2019  EDF R&D, CEA/DEN
4dnl  MED is free software: you can redistribute it and/or modify
5dnl  it under the terms of the GNU Lesser General Public License as published by
6dnl  the Free Software Foundation, either version 3 of the License, or
7dnl  (at your option) any later version.
8dnl
9dnl  MED is distributed in the hope that it will be useful,
10dnl  but WITHOUT ANY WARRANTY; without even the implied warranty of
11dnl  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12dnl  GNU Lesser General Public License for more details.
13dnl
14dnl  You should have received a copy of the GNU Lesser General Public License
15dnl  along with MED.  If not, see <http://www.gnu.org/licenses/>.
16dnl
17
18AC_DEFUN([_MED_DEFINE_F90_ARGS],[
19## Guess where as f90prog is defined by the F90 environement variable
20## or by the --with-f90 option
21 AC_ARG_WITH([f90],
22             AC_HELP_STRING([--with-f90=<compiler>],
23 	                   [Use <compiler> for F90 compiler (default:no)]),
24 	    [
25            ], [with_f90=no
26 ])
27])
28
29AC_DEFUN([_MED_BEFORE_FC], [
30  AC_REQUIRE([_MED_DEFINE_F90_ARGS])
31#We must check if the user want the Fortran interface
32#before testing a mpi fortran frontend
33 AC_REQUIRE([_MED_DEFINE_F77_ENABLE])
34#Pour des raisons historiques prend en compte la variable utilisateur F90
35test x"$with_f90" = xyes && f90prog=${F90}
36#La variable f90prog m�morise le choix de compilateur F90 fait par l'utilisateur, mais les variables MPIFC et FC restent proritaires
37#Ces deux veriables sont utilis�es dans ax__prog__fc__mpi
38test ! x"$with_f90" = xyes && test ! x"$with_f90" = xno && f90prog=$with_f90
39#Faut-il lancer la d�tection du compilateur (par d�faut non)
40med_check_f90="no"
41#Si l'activation de f90 a �t� explicitement demand�e ou si l'une des variables FC, MPIFC est position�e la d�tection du compilateur doit �tre activ�e
42(test ! x"$with_f90" = xno||(test x"$with_f90" = xno &&(test ! x"$FC" = x||test ! x"$MPIFC" = x )))&&med_check_f90="yes"
43#Si l'utilisateur a explicitement demand� de ne pas contruire l'interface Fortran par l'option --enable-fortran=no, il ne faut pas lance la d�tection du compilateur
44test x"$enable_fortran" = xno && med_check_f90="no"
45])
46
47AC_DEFUN([_MED_CALLING_FC], [
48#la macro de d�tection du compilateur f90 cherchera le compilateur s�quentiel si mpi_wanted_test == no
49#Elle prend en compte les variables f90prog, FC et MPIFC et mpi_wanted_test pour d�finir et tester le compilateur dont le nom sera forc�ment FC en retour (parallel ou s�quentiel)
50  AX_PROG_FC_MPI(test "x$mpi_wanted_test" = "xyes",[],[
51  if test x"$mpi_wanted_test" = xyes && test x"$med_check_f90" = xyes ; then
52    AC_MSG_ERROR([MPI F90 compiler requested, but couldn't use MPI.])
53  fi
54  ])
55#Si aucun compilateur n'a �t� trouv� et que le F90 est requis, on g�n�re une erreur
56  test x"$FC" = x && test x"$med_check_f90" = xyes && AC_MSG_ERROR([Can't find a valid FC compiler, check your configure switches or the FC var...])
57])
58
59
60AC_DEFUN_ONCE([MED_CHECK_F90],dnl
61[
62#The macro for detecting Fortran compilers must not be called before
63# testing mpi fortran compiler frontend
64AC_BEFORE([$0],[AC_PROG_FC])
65AC_BEFORE([$0],[AC_PROG_F77])
66AC_REQUIRE([_MED_BEFORE_FC])
67
68_MED_CALLING_FC
69
70AS_IF([test  x"$FC" != x && test x"$med_check_f90" = xyes ],
71[
72#Le compilateur FC �tant d�fini, on positionne maintenant les LDFLAGS
73  AC_FC_LIBRARY_LDFLAGS
74  ##AC_FC_WRAPPERS Inutile car pas d'interface sp�cifique f90
75
76# Ce test semble obsol�te : A v�rifier.
77  if test -z "$FC" ; then
78    AC_MSG_ERROR([Can't find $f90prog command, please verify your env. var. PATH])
79  fi
80
81#Si HDF5 n'est pas parallel, la macro ax__prog__fc__mpi n'a pas test� de compilation en F90
82if test x"$mpi_wanted_test" = xno; then
83    AC_LANG_PUSH([Fortran])
84    AC_MSG_CHECKING([ a F90 compilation])
85    AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,[[
86      print *,"Testing a F90 compilation..."
87]])],
88        [ AC_MSG_RESULT(ok)],
89        [ AC_MSG_RESULT(ko)
90          AC_MSG_ERROR([Can't find a valid FC compiler, check your configure switches or the FC var...])
91        ]
92    )
93    AC_LANG_POP([Fortran])
94fi
95
96#Test la capacit� du compilateur F90 a g�rer le pr�-processing
97   AC_FC_PP_SRCEXT(F90, [ AC_FC_PP_DEFINE( [AM_CONDITIONAL([WITHFCPP],[true])],
98                                           [AM_CONDITIONAL([WITHFCPP],[false])] )
99			], [AM_CONDITIONAL([WITHFCPP],[false])]
100		  )
101
102# Pour l'affichage du Summary
103   BUILD_F90TESTS_CONDITIONAL_TRUE=
104   BUILD_F90TESTS_CONDITIONAL_FALSE='#'
105],[
106   FC=""
107# Pour l'affichage du Summary
108   BUILD_F90TESTS_CONDITIONAL_TRUE='#'
109   BUILD_F90TESTS_CONDITIONAL_FALSE=
110   AM_CONDITIONAL([WITHFCPP],[false])
111
112])
113
114AC_SUBST([BUILD_F90TESTS_CONDITIONAL_TRUE])
115AC_SUBST([BUILD_F90TESTS_CONDITIONAL_FALSE])
116
117])
118
119