Skip to content

Commit

Permalink
create gauge filenames that allow more than 5 digits in gauge number
Browse files Browse the repository at this point in the history
same approach as in clawpack/geoclaw#615
  • Loading branch information
rjleveque committed May 30, 2024
1 parent 784e4c4 commit 573f80d
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/2d/gauges_module.f90
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ module gauges_module
! Gauge number
integer :: gauge_num

character(len=14) :: file_name
character(len=24) :: file_name

! Location in time and space
real(kind=8) :: x, y, t_start, t_end
Expand Down Expand Up @@ -106,6 +106,7 @@ subroutine set_gauges(restart, num_eqn, num_aux, fname)
integer, parameter :: UNIT = 7
character(len=128) :: header_1
character(len=40) :: q_column, aux_column
character(len=15) :: numstr

if (.not. module_setup) then

Expand Down Expand Up @@ -194,13 +195,12 @@ subroutine set_gauges(restart, num_eqn, num_aux, fname)

! Create gauge output files
do i = 1, num_gauges
gauges(i)%file_name = 'gaugexxxxx.txt'
num = gauges(i)%gauge_num
do pos = 10, 6, -1
digit = mod(num,10)
gauges(i)%file_name(pos:pos) = char(ichar('0') + digit)
num = num / 10
end do

! convert num to string numstr with zero padding if <5 digits
! since we want format gauge00012.txt or gauge1234567.txt:
write (numstr,'(I0.5)') num
gauges(i)%file_name = 'gauge'//trim(numstr)//'.txt'

! Handle restart
if (restart) then
Expand All @@ -212,7 +212,7 @@ subroutine set_gauges(restart, num_eqn, num_aux, fname)
rewind OUTGAUGEUNIT

! Write header
header_1 = "('# gauge_id= ',i5,' " // &
header_1 = "('# gauge_id= ',i0,' " // &
"location=( ',1e17.10,' ',1e17.10,' ) " // &
"num_var= ',i2)"
write(OUTGAUGEUNIT, header_1) gauges(i)%gauge_num, &
Expand Down

0 comments on commit 573f80d

Please sign in to comment.