From d47518e511264e14e0a2136a597e9bab95f4fa52 Mon Sep 17 00:00:00 2001 From: Olivia Appleton Date: Sun, 22 Sep 2024 13:35:06 -0500 Subject: [PATCH] Move answers to reading from answers.tsv (5) --- fortran/src/include/utils.f90 | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/fortran/src/include/utils.f90 b/fortran/src/include/utils.f90 index 6148ff57..c9b8b45a 100644 --- a/fortran/src/include/utils.f90 +++ b/fortran/src/include/utils.f90 @@ -73,17 +73,12 @@ function get_answer(id) result(answer) answer%int_value = i end if case ("str") - read(length, *, iostat=ios) i - if (ios /= 0) then - print *, "Invalid integer literal for string length. Returning error type" + 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 - allocate(character(len=i), 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 = val - end if + answer%type = stringt + answer%string_value = val end if case default print *, "Invalid value type. Returning error type"