Skip to content

Commit

Permalink
Bring some back
Browse files Browse the repository at this point in the history
  • Loading branch information
LivInTheLookingGlass committed Oct 7, 2024
1 parent 801621d commit b531ea5
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions fortran/src/include/utils.f90
Original file line number Diff line number Diff line change
Expand Up @@ -52,23 +52,27 @@ 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."
answer%type = errort
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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit b531ea5

Please sign in to comment.