Skip to content

Commit

Permalink
Check Get_Environment_Variable at configure time
Browse files Browse the repository at this point in the history
  • Loading branch information
wkliao committed Feb 9, 2024
1 parent ea19123 commit b796759
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
14 changes: 14 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -1025,6 +1025,20 @@ if test "x${has_fortran}" = xyes && test "x${ax_cv_fc_compiler_vendor}" = xnag ;
fi
AM_CONDITIONAL(NAGFORT, [test x$ax_cv_fc_compiler_vendor = xnag])

if test "x${has_fortran}" = xyes ; then
# check if subroutine Get_Environment_Variable is available
AC_MSG_CHECKING([whether subroutine Get_Environment_Variable is available])
AC_LANG_PUSH([Fortran])
dnl check if can use mpif.h
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [[
character(len=255) value
call Get_Environment_Variable("HOME", Value=value)]])],
[decl_get_environment_variable=yes],[decl_get_environment_variable=no])
AC_LANG_POP([Fortran])
AC_MSG_RESULT($decl_get_environment_variable)
fi
AM_CONDITIONAL(DECL_GET_ENVIRONMENT_VARIABLE, [test x$decl_get_environment_variable = xyes])

if test "x$enable_shared" = xyes ; then
dnl Call LT_OUTPUT to produce file ./libtool which is used later in
dnl. LT_AC_CHECK_SHLIB. Note LT_OUTPUT must be called after all compilers
Expand Down
4 changes: 4 additions & 0 deletions test/common/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ endif
AM_FFLAGS =
AM_FCFLAGS =

if DECL_GET_ENVIRONMENT_VARIABLE
AM_FCFLAGS += $(FC_DEFINE)HAS_GET_ENVIRONMENT_VARIABLE
endif

if DECL_MPI_OFFSET
# Do not add to AM_CPPFLAGS, as it will be used by both C and Fortran programs
# AM_CPPFLAGS += -DHAVE_DECL_MPI_OFFSET
Expand Down
2 changes: 1 addition & 1 deletion test/common/testutilsf.F90
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ end subroutine pass_fail

subroutine get_env(hint_str, value)
character(len=*) hint_str, value
#ifdef NAGFOR
#ifdef HAS_GET_ENVIRONMENT_VARIABLE
call Get_Environment_Variable(hint_str, Value=value)
#else
call getenv(hint_str, value)
Expand Down

0 comments on commit b796759

Please sign in to comment.