From ad34cd67ac87dec5c3f3a47644cb1dbe61c7dfbd Mon Sep 17 00:00:00 2001 From: rhaas Date: Fri, 10 Aug 2012 00:43:38 +0000 Subject: EOS_Omni: use H5Fis_hdf5, protect assumed type sizes From: Roland Haas git-svn-id: http://svn.einsteintoolkit.org/cactus/EinsteinEOS/EOS_Omni/trunk@66 8e189c6b-2ab8-4400-aa02-70a9cfce18b9 --- src/nuc_eos/readtable.c | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/nuc_eos/readtable.c b/src/nuc_eos/readtable.c index 9dfb727..37c7472 100644 --- a/src/nuc_eos/readtable.c +++ b/src/nuc_eos/readtable.c @@ -31,19 +31,6 @@ void CCTK_FNAME(setup_eosmodule) #fn_call, _error_code); \ } -static int file_is_readable(const char* filename); -static int file_is_readable(const char* filename) -{ - FILE* fp = NULL; - fp = fopen(filename, "r"); - if(fp != NULL) - { - fclose(fp); - return 1; - } - return 0; -} - // Cactus calls this function. It reads in the table and calls a fortran // function to setup values for the fortran eos module void EOS_OMNI_ReadTable(CCTK_ARGUMENTS) @@ -66,7 +53,7 @@ void EOS_OMNI_ReadTable(CCTK_ARGUMENTS) const int doIO = !read_table_on_single_process || CCTK_MyProc(cctkGH) == my_reader_process; hid_t file = -1; - if (doIO && !file_is_readable(nuceos_table_name)) + if (doIO && ! H5Fis_hdf5(nuceos_table_name) > 0) CCTK_VWarn(CCTK_WARN_ABORT, __LINE__, __FILE__, CCTK_THORNSTRING, "Could not read nuceos_table_name'%s'", nuceos_table_name); @@ -100,6 +87,10 @@ void EOS_OMNI_ReadTable(CCTK_ARGUMENTS) // Allocate memory for tables CCTK_REAL *alltables, *logrho, *logtemp, *ye, energy_shift; + // protect our use of H5T_NATIVE_DOUBLE and H5T_NATIVE_INT + assert (sizeof(CCTK_REAL) == sizeof(double)); + assert (sizeof(CCTK_INT) == sizeof(int)); + if (!(alltables = (CCTK_REAL*)malloc(nrho * ntemp * nye * 19 * sizeof(CCTK_REAL)))) CCTK_WARN(CCTK_WARN_ABORT, "Cannot allocate memory for EOS table\n"); if (!(logrho = (CCTK_REAL*)malloc(nrho * sizeof(CCTK_REAL)))) -- cgit v1.2.3