summaryrefslogtreecommitdiffstats
path: root/fortran/src
diff options
context:
space:
mode:
authorScot Breitenfeld <brtnfld@hdfgroup.org>2015-06-05 22:17:13 (GMT)
committerScot Breitenfeld <brtnfld@hdfgroup.org>2015-06-05 22:17:13 (GMT)
commit8641814c4e5b4211e0980df783c3d2d25f484226 (patch)
tree14301cf1ffc17ffdc945aea72752ce41703c77a2 /fortran/src
parent043173a689015960758c0276486eca9e7a223366 (diff)
downloadhdf5-8641814c4e5b4211e0980df783c3d2d25f484226.zip
hdf5-8641814c4e5b4211e0980df783c3d2d25f484226.tar.gz
hdf5-8641814c4e5b4211e0980df783c3d2d25f484226.tar.bz2
[svn-r27154] fixed issue with mis-matching long double between Fortran and C
Diffstat (limited to 'fortran/src')
-rw-r--r--fortran/src/H5_f.c9
-rw-r--r--fortran/src/H5_ff.F904
-rw-r--r--fortran/src/H5config_f.inc.in3
-rw-r--r--fortran/src/H5fort_type_defines.h.in7
-rw-r--r--fortran/src/H5match_types.c28
-rw-r--r--fortran/src/Makefile.in1
6 files changed, 37 insertions, 15 deletions
diff --git a/fortran/src/H5_f.c b/fortran/src/H5_f.c
index c12b610..241af79 100644
--- a/fortran/src/H5_f.c
+++ b/fortran/src/H5_f.c
@@ -227,9 +227,14 @@ h5init_types_c( hid_t_f * types, hid_t_f * floatingtypes, hid_t_f * integertypes
else if (sizeof(real_C_LONG_DOUBLE_f) == sizeof(double)) {
if ((types[12] = (hid_t_f)H5Tcopy(H5T_NATIVE_DOUBLE)) < 0) return ret_value;
} /*end if */
-#if H5_SIZEOF_LONG_DOUBLE!=0
+#if FORTRAN_HAVE_C_LONG_DOUBLE!=0
+ else if (sizeof(real_C_LONG_DOUBLE_f) == sizeof(long double)) {
+ if ((types[12] = (hid_t_f)H5Tcopy(H5T_NATIVE_LDOUBLE)) < 0) return ret_value;
+ } /*end else */
+#else
else if (sizeof(real_C_LONG_DOUBLE_f) == sizeof(long double)) {
- if ((types[12] = (hid_t_f)H5Tcopy(H5T_NATIVE_LDOUBLE)) < 0) return ret_value;
+ if ((types[12] = H5Tcopy (H5T_NATIVE_FLOAT)) < 0) return ret_value;
+ if ( H5Tset_precision (types[12], 128) < 0) return ret_value;
} /*end else */
#endif
/*
diff --git a/fortran/src/H5_ff.F90 b/fortran/src/H5_ff.F90
index aba9d1b..74838cf 100644
--- a/fortran/src/H5_ff.F90
+++ b/fortran/src/H5_ff.F90
@@ -391,10 +391,12 @@ CONTAINS
h5_type = H5T_NATIVE_REAL_C_DOUBLE
ELSE IF(kind.EQ.Fortran_REAL_C_LONG_DOUBLE)THEN
h5_type = H5T_NATIVE_REAL_C_LONG_DOUBLE
-#if H5_PAC_FC_MAX_REAL_PRECISION > 28
+#if H5_PAC_FC_MAX_REAL_PRECISION > 28
+#ifdef H5_HAVE_FLOAT128
ELSE IF(kind.EQ.Fortran_REAL_C_FLOAT128)THEN
h5_type = H5T_NATIVE_FLOAT_128
#endif
+#endif
ENDIF
ENDIF
diff --git a/fortran/src/H5config_f.inc.in b/fortran/src/H5config_f.inc.in
index a28480c..c8fcf31 100644
--- a/fortran/src/H5config_f.inc.in
+++ b/fortran/src/H5config_f.inc.in
@@ -27,6 +27,9 @@
! Define the maximum decimal precision for reals
#undef PAC_FC_MAX_REAL_PRECISION
+! If C has quad precision
+#undef HAVE_FLOAT128
+
! Define if INTEGER*16 is available
#undef HAVE_Fortran_INTEGER_SIZEOF_16
diff --git a/fortran/src/H5fort_type_defines.h.in b/fortran/src/H5fort_type_defines.h.in
index dc2fc94..279deb9 100644
--- a/fortran/src/H5fort_type_defines.h.in
+++ b/fortran/src/H5fort_type_defines.h.in
@@ -13,9 +13,4 @@
#define H5_FORTRAN_REAL_KINDS_SIZEOF @PAC_FC_ALL_REAL_KINDS_SIZEOF@
#define H5_PAC_FC_MAX_REAL_PRECISION @PAC_FC_MAX_REAL_PRECISION@
#define H5_HAVE_Fortran_INTEGER_SIZEOF_16 @HAVE_Fortran_INTEGER_SIZEOF_16@
-#define C_LONG_DOUBLE_KIND 10
-#define C_LONG_DOUBLE_SIZEOF 12
-#define C_DOUBLE_KIND 8
-#define C_DOUBLE_SIZEOF 8
-#define C_FLOAT_KIND 4
-#define C_FLOAT_SIZEOF 4
+#define H5_HAVE_Fortran_INTRINSIC_C_LONG_DOUBLE @FORTRAN_HAVE_C_LONG_DOUBLE@
diff --git a/fortran/src/H5match_types.c b/fortran/src/H5match_types.c
index 5ac5c80..366e3da 100644
--- a/fortran/src/H5match_types.c
+++ b/fortran/src/H5match_types.c
@@ -215,6 +215,7 @@ int main(void)
} else if(sizeof(double) == RealKinds_SizeOf[i]) {
writeTypedef("float", "double", RealKinds[i]);
strcpy(Real_C_TYPES[i], "C_DOUBLE");
+/* may not have long double in fortran need check */
} else if(sizeof(long double) == RealKinds_SizeOf[i] && found_long_double == 0) {
writeTypedef("float", "long double", RealKinds[i]);
strcpy(Real_C_TYPES[i], "C_LONG_DOUBLE");
@@ -227,12 +228,27 @@ int main(void)
strcpy(Real_C_TYPES[i], "C_FLOAT128");
}
#endif
- else {
- printf(" **** HDF5 WARNING ****/n");
- printf("Fortran REAL is %d bytes, but no corresponding C floating type exists\n",RealKinds_SizeOf[i]);
- printf("Fortran Interfaces for Fortran REALs of %d bytes will not exist\n",RealKinds_SizeOf[i]);
- }
- }
+/* else { */
+ /* /\* Did not find the real type, use the next smallest *\/ */
+/* sprintf(chrA, "%d", RealKinds[i]); */
+/* if(sizeof(float) > RealKinds_SizeOf[H5_FORTRAN_NUM_REAL_KINDS-2]) { */
+/* writeTypedef("float", "float", RealKinds[i]); */
+/* strcpy(Real_C_TYPES[i], chrA); */
+/* } else if(sizeof(double) > RealKinds_SizeOf[H5_FORTRAN_NUM_REAL_KINDS-2]) { */
+/* writeTypedef("float", "double", RealKinds[i]); */
+/* strcpy(Real_C_TYPES[i], chrA); */
+/* } else if(sizeof(long double) > RealKinds_SizeOf[H5_FORTRAN_NUM_REAL_KINDS-2]) { */
+/* writeTypedef("float", "long double", RealKinds[i]); */
+/* strcpy(Real_C_TYPES[i], "C_LONG_DOUBLE"); } */
+ else {
+ printf(" **** HDF5 WARNING ****\n");
+ printf("Fortran REAL is %d bytes, but no corresponding C floating type exists\n",RealKinds_SizeOf[i]);
+ printf("Fortran Interface will create a custom datatype to store Fortran Real\n",RealKinds_SizeOf[i]);
+
+ writeTypedef("float", "long double", RealKinds[i]);
+ strcpy(Real_C_TYPES[i], "C_LONG_DOUBLE"); }
+ }
+/* } */
/* Now begin defining fortran types. */
fprintf(c_header, "\n");
diff --git a/fortran/src/Makefile.in b/fortran/src/Makefile.in
index eaf0244..54f2065 100644
--- a/fortran/src/Makefile.in
+++ b/fortran/src/Makefile.in
@@ -503,6 +503,7 @@ FCFLAGS_f90 = @FCFLAGS_f90@
FCLIBS = @FCLIBS@
FC_VERSION = @FC_VERSION@
FGREP = @FGREP@
+FORTRAN_HAVE_C_LONG_DOUBLE = @FORTRAN_HAVE_C_LONG_DOUBLE@
FSEARCH_DIRS = @FSEARCH_DIRS@
GREP = @GREP@
H5_CFLAGS = @H5_CFLAGS@