From 4830ea19c947ab34e2e80c6b99b36f4485a71470 Mon Sep 17 00:00:00 2001 From: Philip Eisenlohr Date: Fri, 9 Dec 2022 10:00:00 -0500 Subject: [PATCH] bug fix;more elaborate self test --- src/tables.f90 | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/src/tables.f90 b/src/tables.f90 index 867433ab2..c62082705 100644 --- a/src/tables.f90 +++ b/src/tables.f90 @@ -1,5 +1,6 @@ !-------------------------------------------------------------------------------------------------- !> @author Martin Diehl, KU Leuven +!> @author Philip Eisenlohr, Michigan State University !> @brief Tabular representation of variable data. !-------------------------------------------------------------------------------------------------- module tables @@ -50,11 +51,12 @@ function table_from_values(x,y) result(t) type(tTable) :: t - if (min(size(x),size(y))< 1) call IO_error(603,ext_msg='no data specified') - if (size(x) /= size(y)) call IO_error(603,ext_msg='non-matching shape of tabulated data') - if (size(x) /=1) then - if (any(x(1:size(x)-1) -x(2:size(x)) > 0.0_pReal)) & - call IO_error(603,ext_msg='ordinate data does not increase monotonically') + if (size(x) < 1) call IO_error(603,ext_msg='missing tabulated x data') + if (size(y) < 1) call IO_error(603,ext_msg='missing tabulated y data') + if (size(x) /= size(y)) call IO_error(603,ext_msg='shape mismatch in tabulated data') + if (size(x) /= 1) then + if (any(x(2:size(x))-x(1:size(x)-1) <= 0.0_pReal)) & + call IO_error(603,ext_msg='ordinate data does not increase monotonically') end if t%x = x @@ -79,7 +81,7 @@ end function table_from_dict !-------------------------------------------------------------------------------------------------- -!> @brief Evaluate a table. +!> @brief Linearly interpolate/extrapolate tabular data. !-------------------------------------------------------------------------------------------------- pure function eval(self,x) result(y) @@ -91,11 +93,11 @@ pure function eval(self,x) result(y) if (size(self%x) == 1) then - y = self%x(1) + y = self%y(1) else i = max(1,min(findloc(self%x YAML_parse_str_asList('[1, 2, 3, 4]'//IO_EOL) - l_y => YAML_parse_str_asList('[1, 2, 2, 1]'//IO_EOL) + l_y => YAML_parse_str_asList('[1, 3, 2,-2]'//IO_EOL) allocate(dict) call dict%set('t',l_x) call dict%set('T',l_y)