From 562133437c9f724f0d16c7a9e4040cd4e43ee59c Mon Sep 17 00:00:00 2001
From: Luis Kornblueh <luis.kornblueh@zmaw.de>
Date: Wed, 22 May 2013 15:51:02 +0200
Subject: [PATCH] Added the missing preprocessor option for Fortran.

---
 Makefile.in      |  1 +
 configure        | 75 ++++++++++++++++++++++++++++++++++++++++++++++++
 configure.ac     |  1 +
 doc/Makefile.in  |  1 +
 src/Makefile.am  |  1 +
 src/Makefile.in  |  2 ++
 src/libmtime.f90 | 38 ++++++++++++------------
 test/Makefile.in |  1 +
 8 files changed, 102 insertions(+), 18 deletions(-)

diff --git a/Makefile.in b/Makefile.in
index 024b15d8..69dd1565 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -222,6 +222,7 @@ EGREP = @EGREP@
 EXEEXT = @EXEEXT@
 FC = @FC@
 FCFLAGS = @FCFLAGS@
+FCFLAGS_f90 = @FCFLAGS_f90@
 FC_MODEXT = @FC_MODEXT@
 FC_MODINC = @FC_MODINC@
 FGREP = @FGREP@
diff --git a/configure b/configure
index f704b451..33f72510 100755
--- a/configure
+++ b/configure
@@ -690,6 +690,7 @@ TAR
 FC_MODEXT
 ac_empty
 FC_MODINC
+FCFLAGS_f90
 ac_ct_FC
 FCFLAGS
 FC
@@ -14920,6 +14921,80 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
 
 
+ac_ext=${ac_fc_srcext-f}
+ac_compile='$FC -c $FCFLAGS $ac_fcflags_srcext conftest.$ac_ext >&5'
+ac_link='$FC -o conftest$ac_exeext $FCFLAGS $LDFLAGS $ac_fcflags_srcext conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_fc_compiler_gnu
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for Fortran flag to compile preprocessed .f90 files" >&5
+$as_echo_n "checking for Fortran flag to compile preprocessed .f90 files... " >&6; }
+if ${ac_cv_fc_pp_srcext_f90+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_ext=f90
+ac_fcflags_pp_srcext_save=$ac_fcflags_srcext
+ac_fcflags_srcext=
+ac_cv_fc_pp_srcext_f90=unknown
+case $ac_ext in #(
+  [fF]77) ac_try=f77-cpp-input;; #(
+  *) ac_try=f95-cpp-input;;
+esac
+for ac_flag in none -ftpp -fpp -Tf "-fpp -Tf" -xpp=fpp -Mpreprocess "-e Z" \
+               -cpp -xpp=cpp -qsuffix=cpp=f90 "-x $ac_try" +cpp -Cpp; do
+  test "x$ac_flag" != xnone && ac_fcflags_srcext="$ac_flag"
+  cat > conftest.$ac_ext <<_ACEOF
+      program main
+
+#if 0
+#include <ac_nonexistent.h>
+      choke me
+#endif
+      end
+_ACEOF
+if ac_fn_fc_try_compile "$LINENO"; then :
+  cat > conftest.$ac_ext <<_ACEOF
+      program main
+
+#if 1
+#include <ac_nonexistent.h>
+      choke me
+#endif
+      end
+_ACEOF
+if ac_fn_fc_try_compile "$LINENO"; then :
+
+else
+  ac_cv_fc_pp_srcext_f90=$ac_flag; break
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+done
+rm -f conftest.$ac_objext conftest.f90
+ac_fcflags_srcext=$ac_fcflags_pp_srcext_save
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_fc_pp_srcext_f90" >&5
+$as_echo "$ac_cv_fc_pp_srcext_f90" >&6; }
+if test "x$ac_cv_fc_pp_srcext_f90" = xunknown; then
+  as_fn_error $? "Fortran could not compile preprocessed .f90 files" "$LINENO" 5
+else
+  ac_fc_srcext=f90
+  if test "x$ac_cv_fc_pp_srcext_f90" = xnone; then
+    ac_fcflags_srcext=""
+    FCFLAGS_f90=""
+  else
+    ac_fcflags_srcext=$ac_cv_fc_pp_srcext_f90
+    FCFLAGS_f90=$ac_cv_fc_pp_srcext_f90
+  fi
+
+
+fi
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
 
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking Fortran 90 module inclusion flag" >&5
 $as_echo_n "checking Fortran 90 module inclusion flag... " >&6; }
diff --git a/configure.ac b/configure.ac
index 9807c753..6eb933fa 100644
--- a/configure.ac
+++ b/configure.ac
@@ -17,6 +17,7 @@ AM_INIT_AUTOMAKE
 AC_PROG_CC_C99
 AC_PROG_FC
 
+AC_FC_PP_SRCEXT([f90])
 AC_FC_MODULE_FLAG
 AC_FC_MODULE_EXTENSION
 
diff --git a/doc/Makefile.in b/doc/Makefile.in
index b092934b..032bfbce 100644
--- a/doc/Makefile.in
+++ b/doc/Makefile.in
@@ -135,6 +135,7 @@ EGREP = @EGREP@
 EXEEXT = @EXEEXT@
 FC = @FC@
 FCFLAGS = @FCFLAGS@
+FCFLAGS_f90 = @FCFLAGS_f90@
 FC_MODEXT = @FC_MODEXT@
 FC_MODINC = @FC_MODINC@
 FGREP = @FGREP@
diff --git a/src/Makefile.am b/src/Makefile.am
index 111e123d..51d2b537 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,4 +1,5 @@
 AM_CPPFLAGS = -I$(top_srcdir)/include
+AM_FCFLAGS = $(FCFLAGS_f90)
 
 lib_LTLIBRARIES     = libmtime.la
 
diff --git a/src/Makefile.in b/src/Makefile.in
index ca799709..96c94ccf 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -230,6 +230,7 @@ EGREP = @EGREP@
 EXEEXT = @EXEEXT@
 FC = @FC@
 FCFLAGS = @FCFLAGS@
+FCFLAGS_f90 = @FCFLAGS_f90@
 FC_MODEXT = @FC_MODEXT@
 FC_MODINC = @FC_MODINC@
 FGREP = @FGREP@
@@ -328,6 +329,7 @@ top_build_prefix = @top_build_prefix@
 top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
 AM_CPPFLAGS = -I$(top_srcdir)/include
+AM_FCFLAGS = $(FCFLAGS_f90)
 lib_LTLIBRARIES = libmtime.la
 libmtime_la_SOURCES = calendar.c \
 		      calendar_360day.c \
diff --git a/src/libmtime.f90 b/src/libmtime.f90
index 083921ef..75131492 100644
--- a/src/libmtime.f90
+++ b/src/libmtime.f90
@@ -24,9 +24,6 @@
 !! done. The implementation is based on a singleton concept meaning that only one calendar
 !! can be active at a time. The release a calendar a call to resetCalendar has to be done.
 !!
-!! @author  Luis Kornblueh, Max Planck Institute for Meteorology
-!! @author  Rahul Sinha, Max Planck Institute for Meteorology
-!!
 !___________________________________________________________________________________________________________
 module mtime_calendar
   !
@@ -138,10 +135,6 @@ end module mtime_calendar
 !! @brief Julian Day Calendar and some operations supported on julian dates.
 !!
 !! @details
-!!
-!! @author  Luis Kornblueh, Max Planck Institute for Meteorology
-!! @author  Rahul Sinha, Max Planck Institute for Meteorology
-!!
 !___________________________________________________________________________________________________________
 module mtime_julianday
   !
@@ -161,8 +154,8 @@ module mtime_julianday
   integer, parameter :: max_julianday_str_len = 32   
   !
   type, bind(c) :: julianday
-    integer(c_int64_t) :: day
-    integer(c_int64_t) :: ms
+    integer(c_int64_t) :: day  !> the actual Julian day
+    integer(c_int64_t) :: ms   !> the milisecond on that particular day
   end type julianday
   !
   interface
@@ -207,7 +200,7 @@ contains
   !>
   !! @brief destructor for a Julian date 
   !!
-  !! @param[in] my_julianday   a pointer of type(julianday)
+  !! @param     my_julianday   a pointer of type(julianday)
   subroutine deallocateJulianday(my_julianday)
     type(julianday), pointer :: my_julianday
     call my_deallocatejulianday(c_loc(my_julianday))
@@ -217,10 +210,11 @@ contains
   !>
   !! @brief get Julian day as a string.
   !!
-  !! @param[in] jd   a pointer to type(julianday). The Julian day to be converted to a string 
+  !! @param[in]  my_julianday   a pointer to type(julianday). The Julian day to be converted to a string 
+  !! @param[out] string         the Julian day verbose
   subroutine juliandayToString(my_julianday, string)
     type(julianday), pointer :: my_julianday
-    character(len=max_julianday_str_len) :: string
+    character(len=max_julianday_str_len), intent(out) :: string
     type(c_ptr) :: dummy_ptr
     integer :: i
     dummy_ptr = my_juliandaytostring(c_loc(my_julianday), string)
@@ -236,9 +230,6 @@ end module mtime_julianday
 !!
 !! @details
 !!
-!! @author  Luis Kornblueh, Max Planck Institute for Meteorology
-!! @author  Rahul Sinha, Max Planck Institute for Meteorology
-!!
 !___________________________________________________________________________________________________________
 module mtime_date
   !
@@ -254,6 +245,7 @@ module mtime_date
   public :: deallocateDate
   public :: dateToString
   !
+  !> provides a string length for toString 
   integer, parameter :: max_date_str_len = 32
   !
   type, bind(c) :: date
@@ -287,6 +279,11 @@ module mtime_date
   !
 contains
   !
+  !>
+  !! @brief construct a new date 
+  !!
+  !! @param[in] string         an ISO 8601 conforming date string
+  !! @return    ret_date       a pointer of type(date)
   function newDate(string) result(ret_date)
     type(date), pointer :: ret_date
     character(len=*), intent(in) :: string
@@ -295,6 +292,9 @@ contains
     call c_f_pointer(c_pointer, ret_date)
   end function newDate
   !
+  !! @brief destructor for a date 
+  !!
+  !! @param[in] my_date        a pointer of type(date)
   subroutine deallocateDate(my_date)
     type(date), pointer :: my_date
     call my_deallocatedate(c_loc(my_date))
@@ -337,6 +337,7 @@ module mtime_time
   public :: deallocateTime
   public :: timeToString
   !
+  !> provides a string length for toString 
   integer, parameter :: max_time_str_len = 32
   !
   type, bind(c) :: time
@@ -433,6 +434,7 @@ module mtime_datetime
   public :: operator(==)
   public :: operator(/=)
   !
+  !> provides a string length for toString 
   integer, parameter :: max_datetime_str_len = 32
   !
   type, bind(c) :: datetime
@@ -717,6 +719,7 @@ module mtime_timedelta
   public :: timedeltaToString
   public :: operator(+)
   !
+  !> provides a string length for toString 
   integer, parameter :: max_timedelta_str_len = 32
   !
   type, bind(c) :: timedelta
@@ -816,9 +819,6 @@ end module mtime_timedelta
 !!
 !! @details
 !!
-!! @author  Luis Kornblueh, Max Planck Institute for Meteorology
-!! @author  Rahul Sinha, Max Planck Institute for Meteorology
-!!
 !___________________________________________________________________________________________________________
 module mtime_events
   !
@@ -834,6 +834,7 @@ module mtime_events
   public :: deallocateEvent
   public :: eventToString
   !
+  !> provides a string length for toString 
   integer, parameter :: max_eventname_str_len = 132
   !
   type, bind(c) :: event
@@ -944,6 +945,7 @@ module mtime_eventgroups
   public :: addEventToEventGroup
   public :: removeEventFromEventGroup
   !
+  !> provides a string length for toString 
   integer, parameter :: max_groupname_str_len = 132
   !
   type, bind(c) :: eventgroup
diff --git a/test/Makefile.in b/test/Makefile.in
index 8126c5ba..d280444e 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -220,6 +220,7 @@ EGREP = @EGREP@
 EXEEXT = @EXEEXT@
 FC = @FC@
 FCFLAGS = @FCFLAGS@
+FCFLAGS_f90 = @FCFLAGS_f90@
 FC_MODEXT = @FC_MODEXT@
 FC_MODINC = @FC_MODINC@
 FGREP = @FGREP@
-- 
GitLab