From b531ea5c43e821a6516376c9017365b8ddc6f2eb Mon Sep 17 00:00:00 2001 From: Olivia Appleton Date: Sat, 5 Oct 2024 23:32:04 -0500 Subject: [PATCH] Bring some back --- fortran/src/include/utils.f90 | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/fortran/src/include/utils.f90 b/fortran/src/include/utils.f90 index 8eb231ca..9ecc5bb7 100644 --- a/fortran/src/include/utils.f90 +++ b/fortran/src/include/utils.f90 @@ -52,11 +52,6 @@ end function get_data_file function get_answer(id) result(answer) type(AnswerT) :: answer integer(i4t), intent(in) :: id - integer(i18t) :: i, j - integer :: ios, row_start, row_end, line_length - character(len=:), allocatable :: text - character(len=32) :: val - character(len=4) :: id_, type_, length if (id < 1 .or. id > size(cached_answers)) then print *, "Error: ID is out of bounds." @@ -64,11 +59,20 @@ function get_answer(id) result(answer) return end if - if (cache_inited) then - answer = cached_answers(id) - return + if (.not. cache_inited) then + call init_answer_cache() end if + answer = cached_answers(id) + end function + + subroutine init_answer_cache() + integer(i18t) :: i, j + integer :: ios, row_start, row_end, line_length + character(len=:), allocatable :: text + character(len=32) :: val + character(len=4) :: id_, type_, length + do i=1, size(cached_answers) cached_answers(i)%type = errort end do @@ -116,8 +120,7 @@ function get_answer(id) result(answer) deallocate(text) cache_inited = .true. - answer = cached_answers(id) - end function + end subroutine pure subroutine parse_line(line, id_out, type_out, length_out, value_out) character(len=*), intent(in) :: line