Skip to content

Commit

Permalink
Merge pull request clawpack#615 from rjleveque/gauge_filenames
Browse files Browse the repository at this point in the history
Gauge filenames
  • Loading branch information
mandli authored May 30, 2024
2 parents 80e0804 + 794e751 commit b975fef
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions src/2d/shallow/gauges_module.f90
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ module gauges_module
integer :: gauge_num
integer :: gdata_bytes

character(len=14) :: file_name ! for header (and data if 'ascii')
character(len=14) :: file_name_bin ! used if file_format='binary'
character(len=24) :: file_name ! for header (and data if 'ascii')
character(len=24) :: file_name_bin ! used if file_format='binary'

! Location in time and space
real(kind=8) :: x, y, t_start, t_end
Expand Down Expand Up @@ -116,6 +116,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 @@ -207,17 +208,15 @@ subroutine set_gauges(restart, num_eqn, num_aux, fname)

! Create gauge output files
do i = 1, num_gauges
gauges(i)%file_name = 'gaugexxxxx.txt' ! ascii
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'

if (gauges(i)%file_format >= 2) then
gauges(i)%file_name_bin = gauges(i)%file_name
gauges(i)%file_name_bin(12:14) = 'bin'
gauges(i)%file_name_bin = 'gauge'//trim(numstr)//'.bin'
endif


Expand All @@ -243,7 +242,7 @@ subroutine set_gauges(restart, num_eqn, num_aux, fname)

if (.not. restart) then
! Write header to .txt file:
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 b975fef

Please sign in to comment.