diff --git a/examples/main.c b/examples/main.c index 6a7641dadc5c7cc07d890d788c550a4a5c735085..56f463940d51cc1c30904c2472334768fa3d58d1 100644 --- a/examples/main.c +++ b/examples/main.c @@ -325,7 +325,8 @@ int main(int argc, char *argv[]) { /* Let's pin the main thread, now we know if affinity will be used. */ #if defined(HAVE_SETAFFINITY) && defined(HAVE_LIBNUMA) && defined(_GNU_SOURCE) - if (with_aff && ((ENGINE_POLICY)&engine_policy_setaffinity) == engine_policy_setaffinity) + if (with_aff && + ((ENGINE_POLICY)&engine_policy_setaffinity) == engine_policy_setaffinity) engine_pin(); #endif diff --git a/src/common_io.c b/src/common_io.c index 168fcf2c695014cf532e622c928414b875fc54d5..11ec6ef1cdffce28285d5c5db2c8e7e139267b25 100644 --- a/src/common_io.c +++ b/src/common_io.c @@ -300,9 +300,10 @@ void io_write_attribute_s(hid_t grp, const char* name, const char* str) { */ void io_read_unit_system(hid_t h_file, struct unit_system* us) { - hid_t h_grp = H5Gopen(h_file, "/Units", H5P_DEFAULT); + /* First check if it exists as this is *not* required. */ + const htri_t exists = H5Lexists(h_file, "/Units", H5P_DEFAULT); - if (h_grp < 0) { + if (exists == 0) { message("'Units' group not found in ICs. Assuming CGS unit system."); /* Default to CGS */ @@ -313,8 +314,14 @@ void io_read_unit_system(hid_t h_file, struct unit_system* us) { us->UnitTemperature_in_cgs = 1.; return; + } else if (exists < 0) { + error("Serious problem with 'Units' group in ICs. H5Lexists gives %d", + exists); } + message("Reading IC units from ICs."); + hid_t h_grp = H5Gopen(h_file, "/Units", H5P_DEFAULT); + /* Ok, Read the damn thing */ io_read_attribute(h_grp, "Unit length in cgs (U_L)", DOUBLE, &us->UnitLength_in_cgs);