diff --git a/fortran/Makefile b/fortran/Makefile index c57e70a3..77c96b68 100644 --- a/fortran/Makefile +++ b/fortran/Makefile @@ -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) diff --git a/fortran/src/include/utils.f90 b/fortran/src/include/utils.f90 index 2decc766..3cf807a9 100644 --- a/fortran/src/include/utils.f90 +++ b/fortran/src/include/utils.f90 @@ -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 @@ -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 diff --git a/fortran/test.f90 b/fortran/test.f90 index e719bfa0..33c641ec 100644 --- a/fortran/test.f90 +++ b/fortran/test.f90 @@ -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 @@ -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)