Skip to content

Commit

Permalink
Move answers to reading from answers.tsv (30)
Browse files Browse the repository at this point in the history
  • Loading branch information
LivInTheLookingGlass committed Sep 25, 2024
1 parent 1c58095 commit 7831e22
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions fortran/src/include/utils.f90
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ function get_data_file(filename) result(contents)
character(len=:), allocatable :: contents
character(len=64) :: line
integer :: unit_number, iostat, file_size
contents = ''

open(newunit=unit_number, file=("../_data/" // filename), status='old', action='read', iostat=iostat)
if (iostat /= 0) then
Expand All @@ -27,9 +26,6 @@ function get_data_file(filename) result(contents)

inquire(unit=unit_number, size=file_size)
if (file_size > 0) then
if (allocated(contents)) then
deallocate(contents)
end if
allocate(character(len=file_size) :: contents)
contents = ''
do
Expand All @@ -42,6 +38,9 @@ function get_data_file(filename) result(contents)
end do
end if
close(unit_number)
if (.not. allocated(contents)) then
contents = ''
end if
end function get_data_file

function get_answer(id) result(answer)
Expand Down

0 comments on commit 7831e22

Please sign in to comment.