Skip to content

Commit

Permalink
Merge pull request #4 from BerkeleyLab/elim-compiler-warning
Browse files Browse the repository at this point in the history
chore(read_lines): safer variable scoping
  • Loading branch information
rouson authored Jul 21, 2024
2 parents ab24858 + f658a8b commit d78c3c4
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/julienne/julienne_file_s.f90
Original file line number Diff line number Diff line change
Expand Up @@ -77,21 +77,21 @@ function line_count(file_unit) result(num_lines)
function line_lengths(file_unit) result(lengths)
integer, intent(in) :: file_unit
integer, allocatable :: lengths(:)
integer io_status
integer io_status, l
character(len=1) c

associate(num_lines => line_count(file_unit))

allocate(lengths(num_lines), source = 0)
rewind(file_unit)

do line_num = 1, num_lines
do l = 1, num_lines
do
read(file_unit, '(a)', advance='no', iostat=io_status, iomsg=error_message) c
associate(eliminate_nagfor_warning => c) ! eliminates "variable c set but never referenced" warning
associate(eliminate_unused_variable_warning => c) ! eliminate NAG compiler "variable c set but never referenced" warning
end associate
if (io_status==iostat_eor .or. io_status==iostat_end) exit
lengths(line_num) = lengths(line_num) + 1
lengths(l) = lengths(l) + 1
end do
end do

Expand Down

0 comments on commit d78c3c4

Please sign in to comment.