Skip to content

Commit

Permalink
cleaner way to zero pad only if fewer than 5 digits using I0.5 format
Browse files Browse the repository at this point in the history
  • Loading branch information
rjleveque committed May 30, 2024
1 parent 51c0d27 commit 794e751
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions src/2d/shallow/gauges_module.f90
Original file line number Diff line number Diff line change
Expand Up @@ -207,18 +207,12 @@ subroutine set_gauges(restart, num_eqn, num_aux, fname)
end do

! Create gauge output files
! with format gauge00012.txt or gauge1234567.txt
do i = 1, num_gauges
num = gauges(i)%gauge_num
! convert num to string numstr:
if (num > 100000) then
! > 5 digits, no padding
write (numstr,'(I0)') num
else
! <= 5 digits, add zero padding
write (numstr,'(I5.5)') num
endif

! 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
Expand Down

0 comments on commit 794e751

Please sign in to comment.