Skip to content

Commit

Permalink
Move answers to reading from answers.tsv (27)
Browse files Browse the repository at this point in the history
  • Loading branch information
LivInTheLookingGlass committed Sep 25, 2024
1 parent 10366f5 commit cce11e2
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions fortran/src/include/utils.f90
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,12 @@ function get_answer(id) result(answer)
answer%int_value = i
end if
case ("str")
allocate(character(len=len(trim(val))) :: answer%string_value)
allocate(character(len=len(val)) :: answer%string_value)
if (.not. allocated(answer%string_value)) then
print *, "Memory allocation failed for string_value. Returning error type"
else
answer%type = stringt
answer%string_value = trim(val)
answer%string_value = val
end if
case default
print *, "Invalid value type. Returning error type"
Expand Down Expand Up @@ -129,6 +129,12 @@ subroutine parse_line(line, id_out, type_out, length_out, value_out)
length_out = trim(line(last_pos + 1:))
case (4)
value_out = trim(line(last_pos + 1:))
if (value_out(len(value_out):len(value_out)) == char(10)) then
value_out = value_out(0:len(value_out) - 1) ! strip \n
end if
if (value_out(len(value_out):len(value_out)) == char(13)) then
value_out = value_out(0:len(value_out) - 1) ! strip \r
end if
end select
return
else
Expand Down

0 comments on commit cce11e2

Please sign in to comment.