Skip to content

Commit

Permalink
Move answers to reading from answers.tsv (29)
Browse files Browse the repository at this point in the history
  • Loading branch information
LivInTheLookingGlass committed Sep 25, 2024
1 parent 3e374cd commit 1c58095
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 23 deletions.
8 changes: 4 additions & 4 deletions fortran/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ OBJ_FILES=$(patsubst $(SRC_DIR)/%.f90, $(BUILD_DIR)/%.o, $(SRC_FILES))


ifeq ($(FC),ifort)
opt_args= -Wall -march=native -qwholeprogram -J$(BUILD_DIR)
opt_args= -Wall -Werror -march=native -qwholeprogram -J$(BUILD_DIR)
else ifeq ($(FC),lfortran)
opt_args= -J$(BUILD_DIR)
else ifeq ($(FC),nvfortran)
opt_args= -Wall -march=native -module $(BUILD_DIR)
opt_args= -Wall -Werror -march=native -module $(BUILD_DIR)
else ifneq (,$(findstring flang,$(FC)))
opt_args= -march=native -flto -J$(BUILD_DIR)
opt_args= -Werror -march=native -flto -J$(BUILD_DIR)
else
opt_args= -Wall -march=native -flto -J$(BUILD_DIR)
opt_args= -Wall -Werror -march=native -flto -J$(BUILD_DIR)
endif

ifneq ($(COV),false)
Expand Down
7 changes: 4 additions & 3 deletions fortran/src/include/utils.f90
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,19 @@ 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
print *, "Error opening file: ../_data/" // filename
contents = ''
return
end if

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 @@ -37,8 +40,6 @@ function get_data_file(filename) result(contents)
end if
contents = contents // trim(line) // char(10)
end do
else
contents = ''
end if
close(unit_number)
end function get_data_file
Expand Down
17 changes: 1 addition & 16 deletions fortran/test.f90
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ subroutine process_problems(problem_ids, long_runtime)
integer(kind=4), dimension(:), intent(in) :: problem_ids
logical(kind=1), dimension(:), intent(in) :: long_runtime
type(AnswerT) :: expected, answer
integer(kind=4) :: i, j
integer(kind=4) :: i
integer :: first_count, second_count, count_rate, count_max, tmp
real :: time_elapsed

Expand Down Expand Up @@ -91,21 +91,6 @@ subroutine process_problems(problem_ids, long_runtime)
print *, " Error: problem ", problem_ids(i), " failed!"
print *, " Expected Answer : ", expected%string_value
print *, " Solution returned: ", answer%string_value
do j = 1, len(expected%string_value)
write(*, '(A, I3)', advance='no') "Character ", j, ": ", ichar(expected%string_value(j:j))
if (j < len(expected%string_value)) then
write(*, '(A, I3)', advance='no') ", "
end if
end do
print *
do j = 1, len(answer%string_value)
write(*, '(A, I3)', advance='no') "Character ", j, ": ", ichar(answer%string_value(j:j))
if (j < len(answer%string_value)) then
write(*, '(A, I3)', advance='no') ", "
end if
end do
print *
deallocate(answer%string_value, expected%string_value)
stop 1
end if
deallocate(answer%string_value, expected%string_value)
Expand Down

0 comments on commit 1c58095

Please sign in to comment.