diff --git a/fortran/src/include/utils.f90 b/fortran/src/include/utils.f90 index 3cf807a9..37db0cc6 100644 --- a/fortran/src/include/utils.f90 +++ b/fortran/src/include/utils.f90 @@ -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 @@ -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 @@ -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)