summaryrefslogtreecommitdiffstats
path: root/fortran/src/H5match_types.c
diff options
context:
space:
mode:
authorScot Breitenfeld <brtnfld@hdfgroup.org>2015-04-24 18:54:25 (GMT)
committerScot Breitenfeld <brtnfld@hdfgroup.org>2015-04-24 18:54:25 (GMT)
commitb8b7d33f4100e4bf5e01bf169411d33114949556 (patch)
treec61b02da141b60bad3abbf24691df2a785710a17 /fortran/src/H5match_types.c
parent0f453502b98db079d966c29a7b9435984b1715c8 (diff)
downloadhdf5-b8b7d33f4100e4bf5e01bf169411d33114949556.zip
hdf5-b8b7d33f4100e4bf5e01bf169411d33114949556.tar.gz
hdf5-b8b7d33f4100e4bf5e01bf169411d33114949556.tar.bz2
[svn-r26919] fixed real promoted to 8 bytes
Diffstat (limited to 'fortran/src/H5match_types.c')
-rw-r--r--fortran/src/H5match_types.c46
1 files changed, 39 insertions, 7 deletions
diff --git a/fortran/src/H5match_types.c b/fortran/src/H5match_types.c
index 14b76a4..d162634 100644
--- a/fortran/src/H5match_types.c
+++ b/fortran/src/H5match_types.c
@@ -51,6 +51,7 @@ FILE * fort_header;
void writeTypedef(const char* c_typedef, const char* c_type, unsigned int size);
void writeTypedefDefault(const char* c_typedef, unsigned int size);
void writeToFiles(const char* c_typedef, const char* fortran_type, const char* c_type, int size, unsigned int kind);
+void writeToFilesChr(const char* c_typedef, const char* fortran_type, const char* c_type, int size, char* kind);
static void
initCfile(void)
@@ -100,6 +101,7 @@ initFfile(void)
!\n!\n\
! This file is automatically generated and contains HDF5 Fortran90 type definitions.\n!\n\
MODULE H5FORTRAN_TYPES\n\
+ USE ISO_C_BINDING\n\
!\n\
! HDF5 integers\n\
!\n");
@@ -137,6 +139,11 @@ void writeToFiles(const char* c_typedef, const char* fortran_type, const char* c
fprintf(fort_header, " INTEGER, PARAMETER :: %s = %u\n", fortran_type, kind);
fprintf(c_header, "typedef c_%s_%d %s;\n", c_typedef, size, c_type);
}
+void writeToFilesChr(const char* c_typedef, const char* fortran_type, const char* c_type, int size, char* kind)
+{
+ fprintf(fort_header, " INTEGER, PARAMETER :: %s = %s\n", fortran_type, kind);
+ fprintf(c_header, "typedef c_%s_%d %s;\n", c_typedef, size, c_type);
+}
int main(void)
{
@@ -532,12 +539,12 @@ int main(void)
/* real_f */
#if defined H5_FORTRAN_HAS_REAL_NATIVE_16_KIND
if(H5_C_HAS_REAL_NATIVE_16 != 0) {
- writeToFiles("float","Fortran_REAL", "real_f", 16, H5_FORTRAN_HAS_REAL_NATIVE_16_KIND);
+ writeToFilesChr("float","Fortran_REAL", "real_f", 16, "C_LONG_DOUBLE");
}
#elif defined H5_FORTRAN_HAS_REAL_NATIVE_8_KIND
- writeToFiles("float", "Fortran_REAL", "real_f", 8, H5_FORTRAN_HAS_REAL_NATIVE_8_KIND);
+ writeToFilesChr("float", "Fortran_REAL", "real_f", 8, "C_DOUBLE");
#elif defined H5_FORTRAN_HAS_REAL_NATIVE_4_KIND
- writeToFiles("float", "Fortran_REAL", "real_f", 4, H5_FORTRAN_HAS_REAL_NATIVE_4_KIND);
+ writeToFilesChr("float", "Fortran_REAL", "real_f", 4, "C_FLOAT");
#else
/* Error: couldn't find a size for real_f */
return -1;
@@ -546,13 +553,13 @@ int main(void)
/* double_f */
#if defined H5_FORTRAN_HAS_DOUBLE_NATIVE_16_KIND
if(H5_C_HAS_REAL_NATIVE_16 != 0) { /* Check if C has 16 byte floats */
- writeToFiles("float", "Fortran_DOUBLE", "double_f", 16, H5_FORTRAN_HAS_DOUBLE_NATIVE_16_KIND);
+ writeToFilesChr("float", "Fortran_DOUBLE", "double_f", 16, "C_LONG_DOUBLE");
} else {
#if defined H5_FORTRAN_HAS_REAL_NATIVE_8_KIND /* Fall back to 8 byte floats */
- writeToFiles("float", "Fortran_DOUBLE", "double_f", 8, H5_FORTRAN_HAS_REAL_NATIVE_8_KIND);
+ writeToFilesChr("float", "Fortran_DOUBLE", "double_f", 8, "C_DOUBLE");
}
#elif defined H5_FORTRAN_HAS_REAL_NATIVE_4_KIND /* Fall back to 4 byte floats */
- writeToFiles("float", "Fortran_DOUBLE", "double_f", 4, H5_FORTRAN_HAS_REAL_NATIVE_4_KIND);
+ writeToFilesChr("float", "Fortran_DOUBLE", "double_f", 4, "C_FLOAT");
}
#else
/* Error: couldn't find a size for double_f when fortran has 16 byte reals */
@@ -561,12 +568,37 @@ int main(void)
#endif
#elif defined H5_FORTRAN_HAS_DOUBLE_NATIVE_8_KIND
- writeToFiles("float", "Fortran_DOUBLE", "double_f", 8, H5_FORTRAN_HAS_DOUBLE_NATIVE_8_KIND);
+ writeToFilesChr("float", "Fortran_DOUBLE", "double_f", 8, "C_DOUBLE");
#else
/* Error: couldn't find a size for real_f */
return -1;
#endif
+/* /\* real_f *\/ */
+/* if(sizeof(float) == C_LONG_DOUBLE_SIZEOF) { */
+/* writeToFilesChr("float","Fortran_REAL", "real_f", (int)sizeof(float), "C_LONG_DOUBLE"); */
+/* } else if(sizeof(float) == C_DOUBLE_SIZEOF) { */
+/* writeToFilesChr("float","Fortran_REAL", "real_f", (int)sizeof(float), "C_DOUBLE"); */
+/* } else if(sizeof(float) == C_FLOAT_SIZEOF) { */
+/* writeToFilesChr("float","Fortran_REAL", "real_f", (int)sizeof(float), "C_FLOAT"); */
+/* } else { */
+/* /\* Error: couldn't find a size for real_f *\/ */
+/* return -1; */
+/* } */
+
+/* /\* double_f *\/ */
+/* if(sizeof(double) == C_LONG_DOUBLE_SIZEOF) { */
+/* writeToFilesChr("float","Fortran_DOUBLE", "double_f", (int)sizeof(double), "C_LONG_DOUBLE"); */
+/* } else if(sizeof(double) == C_DOUBLE_SIZEOF) { */
+/* writeToFilesChr("float","Fortran_DOUBLE", "double_f", (int)sizeof(double), "C_DOUBLE"); */
+/* } else if(sizeof(double) == C_FLOAT_SIZEOF) { */
+/* writeToFilesChr("float","Fortran_DOUBLE", "double_f", (int)sizeof(double), "C_FLOAT"); */
+/* } else { */
+/* /\* Error: couldn't find a size for double_f *\/ */
+/* return -1; */
+/* } */
+
+
/* Need the buffer size for the fortran derive type 'hdset_reg_ref_t_f03'
* in order to be interoperable with C's structure, the C buffer size
* H5R_DSET_REG_REF_BUF_SIZE is (sizeof(haddr_t)+4)