aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrhaas <rhaas@8e189c6b-2ab8-4400-aa02-70a9cfce18b9>2012-08-10 00:43:38 +0000
committerrhaas <rhaas@8e189c6b-2ab8-4400-aa02-70a9cfce18b9>2012-08-10 00:43:38 +0000
commitad34cd67ac87dec5c3f3a47644cb1dbe61c7dfbd (patch)
treeaf88208d99850698c61bb06475f30269a828674a
parent3c614e451b1a698e501c430b875a6eb2a24b6176 (diff)
EOS_Omni: use H5Fis_hdf5, protect assumed type sizes
From: Roland Haas <roland.haas@physics.gatech.edu> git-svn-id: http://svn.einsteintoolkit.org/cactus/EinsteinEOS/EOS_Omni/trunk@66 8e189c6b-2ab8-4400-aa02-70a9cfce18b9
-rw-r--r--src/nuc_eos/readtable.c19
1 files changed, 5 insertions, 14 deletions
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))))