From 9fa16bc831dc4b5648d3e7276f85dd6688710362 Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Mon, 26 Nov 2018 10:10:43 -0600 Subject: [PATCH] Make sure openmc_load_nuclide still works as intended --- src/nuclide.cpp | 4 ++-- src/nuclide_header.F90 | 11 ++++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/nuclide.cpp b/src/nuclide.cpp index 77b3177cd8..f6b344d249 100644 --- a/src/nuclide.cpp +++ b/src/nuclide.cpp @@ -67,8 +67,8 @@ Nuclide::Nuclide(hid_t group, const double* temperature, int n) // temperature range was given, in which case all temperatures in the range // are loaded irrespective of what temperatures actually appear in the model std::vector temps_to_read; - double T_min = settings::temperature_range[0]; - double T_max = settings::temperature_range[1]; + double T_min = n > 0 ? settings::temperature_range[0] : 0.0; + double T_max = n > 0 ? settings::temperature_range[1] : INFTY; if (T_max > 0.0) { for (auto T : temps_available) { if (T_min <= T && T <= T_max) { diff --git a/src/nuclide_header.F90 b/src/nuclide_header.F90 index e6f886a2c6..8730b124dc 100644 --- a/src/nuclide_header.F90 +++ b/src/nuclide_header.F90 @@ -243,7 +243,7 @@ contains minmax, master, i_nuclide) class(Nuclide), intent(inout) :: this integer(HID_T), intent(in) :: group_id - type(VectorReal), intent(in) :: temperature ! list of desired temperatures + type(VectorReal), intent(in), target :: temperature ! list of desired temperatures integer, intent(inout) :: method real(8), intent(in) :: tolerance real(8), intent(in) :: minmax(2) ! range of temperatures @@ -276,14 +276,19 @@ contains function nuclide_from_hdf5_c(group, temperature, n) result(ptr) bind(C) import HID_T, C_DOUBLE, C_INT, C_PTR integer(HID_T), value :: group - real(C_DOUBLE), intent(in) :: temperature(*) + type(C_PTR), value :: temperature integer(C_INT), value :: n type(C_PTR) :: ptr end function end interface ! Read data on C++ side - this % ptr = nuclide_from_hdf5_c(group_id, temperature % data(1), temperature % size()) + if (temperature % size() > 0) then + this % ptr = nuclide_from_hdf5_c(group_id, C_LOC(temperature % data(1)), & + temperature % size()) + else + this % ptr = nuclide_from_hdf5_c(group_id, C_NULL_PTR, 0) + end if ! Get name of nuclide from group this % name = get_name(group_id)