Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change around logic for creating time files #231

Merged
merged 1 commit into from
Aug 12, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions src/1d/amr1.f90
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,12 @@ program amr1
integer :: clock_start, clock_finish, clock_rate, ttotal
real(kind=8) :: cpu_start, cpu_finish,ttotalcpu
integer, parameter :: timing_unit = 48
character(len=256) :: timing_line, timing_substr
character(len=*), parameter :: timing_base_name = "timing."
character(len=*), parameter :: timing_header_format = &
"(' wall time (', i2,')," // &
" CPU time (', i2,'), " // &
"cells updated (', i2,'),')"

! Common block variables
real(kind=8) :: dxmin
Expand All @@ -125,7 +131,6 @@ program amr1
character(len=*), parameter :: dbugfile = 'fort.debug'
character(len=*), parameter :: matfile = 'fort.nplot'
character(len=*), parameter :: parmfile = 'fort.parameters'
character(len=*), parameter :: timing_file = 'timing.txt'

! Open parameter and debug files
open(dbugunit,file=dbugfile,status='unknown',form='formatted')
Expand Down Expand Up @@ -439,6 +444,19 @@ program amr1

else

! Write header out and continue
open(unit=timing_unit, file=timing_base_name//"csv", &
form='formatted', status='unknown', action='write')
! Construct header string
timing_line = 'output_time,total_wall_time,total_cpu_time,'
timing_substr = ""
do level=1, mxnest
write(timing_substr, timing_header_format) level, level, level
timing_line = trim(timing_line) // trim(timing_substr)
end do
write(timing_unit, "(a)") timing_line
close(timing_unit)

open(outunit, file=outfile, status='unknown', form='formatted')

tstart_thisrun = t0
Expand Down Expand Up @@ -559,7 +577,8 @@ program amr1


!output timing data
open(timing_unit, file=timing_file, status='unknown', form='formatted')
open(timing_unit, file=timing_base_name//"txt", status='unknown', &
form='formatted')
write(*,*)
write(timing_unit,*)
format_string="('============================== Timing Data ==============================')"
Expand Down
19 changes: 2 additions & 17 deletions src/1d/valout.f90
Original file line number Diff line number Diff line change
Expand Up @@ -259,23 +259,8 @@ subroutine valout(level_begin, level_end, time, num_eqn, num_aux)
! ==========================================================================
! Write out timing stats
! Assume that this has been started some where
inquire(file=timing_file_name, exist=timing_file_exists)
if (frame == 0 .or. (.not. timing_file_exists)) then
! Write header out and continue
open(unit=out_unit, file=timing_file_name, form='formatted', &
status='unknown', action='write')
! Construct header string
timing_line = 'output_time,total_wall_time,total_cpu_time,'
timing_substr = ""
do level=1, mxnest
write(timing_substr, timing_header_format) level, level, level
timing_line = trim(timing_line) // trim(timing_substr)
end do
write(out_unit, "(a)") timing_line
else
open(unit=out_unit, file=timing_file_name, form='formatted', &
status='old', action='write', position='append')
end if
open(unit=out_unit, file=timing_file_name, form='formatted', &
status='old', action='write', position='append')

timing_line = "(e16.6, ', ', e16.6, ', ', e16.6,"
do level=1, mxnest
Expand Down
17 changes: 7 additions & 10 deletions src/2d/amr2.f90
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,8 @@ program amr2
real(kind=8) ::ttotalcpu, cpu_start,cpu_finish
integer :: clock_start, clock_finish, clock_rate
integer, parameter :: timing_unit = 48
integer, parameter :: out_unit = 67
character(len=256) :: timing_line, timing_substr
character(len=*), parameter :: timing_file_name = "timing.csv"
character(len=*), parameter :: timing_base_name = "timing."
character(len=*), parameter :: timing_header_format = &
"(' wall time (', i2,')," // &
" CPU time (', i2,'), " // &
Expand All @@ -138,7 +137,6 @@ program amr2
character(len=*), parameter :: dbugfile = 'fort.debug'
character(len=*), parameter :: matfile = 'fort.nplot'
character(len=*), parameter :: parmfile = 'fort.parameters'
character(len=*), parameter :: timing_file = 'timing.txt'

! Open parameter and debug files
open(dbugunit,file=dbugfile,status='unknown',form='formatted')
Expand Down Expand Up @@ -492,17 +490,17 @@ program amr2
else

! Create new timing file
open(unit=out_unit, file=timing_file_name, form='formatted', &
status='unknown', action='write')
open(unit=timing_unit, file=timing_base_name//"csv", &
form='formatted', status='unknown', action='write')
! Construct header string
timing_line = 'output_time,total_wall_time,total_cpu_time,'
timing_substr = ""
do level=1, mxnest
write(timing_substr, timing_header_format) level, level, level
timing_line = trim(timing_line) // trim(timing_substr)
end do
write(out_unit, "(a)") timing_line
close(out_unit)
write(timing_unit, "(a)") timing_line
close(timing_unit)

open(outunit, file=outfile, status='unknown', form='formatted')

Expand Down Expand Up @@ -628,7 +626,8 @@ program amr2
call cpu_time(cpu_finish)

!output timing data
open(timing_unit, file=timing_file, status='unknown', form='formatted')
open(timing_unit, file=timing_base_name//"txt", status='unknown', &
form='formatted')
write(*,*)
write(timing_unit,*)
format_string="('============================== Timing Data ==============================')"
Expand Down Expand Up @@ -677,8 +676,6 @@ program amr2
write(*,format_string)
write(timing_unit,format_string)



!stepgrid
format_string="('stepgrid ',1f15.3,' ',1f15.3,' ',e17.3)"
write(timing_unit,format_string) &
Expand Down
60 changes: 17 additions & 43 deletions src/2d/valout.f90
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ subroutine valout(level_begin, level_end, time, num_eqn, num_aux)
! Locals
logical :: timing_file_exists
integer, parameter :: out_unit = 50
integer :: i, j, m, level, output_aux_num, num_stop, digit, num_dim
integer :: i, j, m, level, output_aux_num, num_stop, digit
integer :: grid_ptr, num_cells(2), num_grids, q_loc, aux_loc
real(kind=8) :: lower_corner(2), delta(2)
logical :: out_aux
Expand All @@ -48,12 +48,6 @@ subroutine valout(level_begin, level_end, time, num_eqn, num_aux)
character(len=256) :: timing_line, timing_substr
character(len=*), parameter :: timing_file_name = "timing.csv"

character(len=*), parameter :: header_format_1d = &
"(i6,' grid_number',/," // &
"i6,' AMR_level',/," // &
"i6,' mx',/," // &
"e26.16,' xlow', /, " // &
"e26.16,' dx',/)"
character(len=*), parameter :: header_format_2d = &
"(i6,' grid_number',/," // &
"i6,' AMR_level',/," // &
Expand Down Expand Up @@ -141,19 +135,13 @@ subroutine valout(level_begin, level_end, time, num_eqn, num_aux)
lower_corner = [rnode(cornxlo, grid_ptr), rnode(cornylo, grid_ptr)]

! Write out header data
if (num_dim == 1) then
write(out_unit, header_format_1d) grid_ptr, level, &
num_cells(1), &
lower_corner(1), &
delta(1)
else
write(out_unit, header_format_2d) grid_ptr, level, &
num_cells(1), &
num_cells(2), &
lower_corner(1), &
lower_corner(2), &
delta(1), delta(2)
end if

write(out_unit, header_format_2d) grid_ptr, level, &
num_cells(1), &
num_cells(2), &
lower_corner(1), &
lower_corner(2), &
delta(1), delta(2)

! Output grids
select case(output_format)
Expand Down Expand Up @@ -260,19 +248,12 @@ subroutine valout(level_begin, level_end, time, num_eqn, num_aux)

! We only output header info for aux data if writing
! ASCII data
if (num_dim == 1) then
write(out_unit, header_format_1d) grid_ptr, level, &
num_cells(1), &
lower_corner(1), &
delta(1)
else
write(out_unit, header_format_2d) grid_ptr, level, &
num_cells(1), &
num_cells(2), &
lower_corner(1), &
lower_corner(2), &
delta(1), delta(2)
end if
write(out_unit, header_format_2d) grid_ptr, level, &
num_cells(1), &
num_cells(2), &
lower_corner(1), &
lower_corner(2), &
delta(1), delta(2)

! Round off if nearly zero
forall (m = 1:num_aux, &
Expand Down Expand Up @@ -348,16 +329,9 @@ subroutine valout(level_begin, level_end, time, num_eqn, num_aux)
! Write fort.t file
open(unit=out_unit, file=file_name(2), status='unknown', form='formatted')

! Handle special case of using 2D AMR to do 1D AMR
if (num_cells(2) > 1) then
num_dim = 2
else
num_dim = 1
end if

! Note: We need to print out num_ghost too in order to strip ghost cells
! from q array when reading in pyclaw.io.binary
write(out_unit, t_file_format) time, num_eqn, num_grids, num_aux, num_dim, &
write(out_unit, t_file_format) time, num_eqn, num_grids, num_aux, 2, &
num_ghost
close(out_unit)

Expand All @@ -376,12 +350,12 @@ subroutine valout(level_begin, level_end, time, num_eqn, num_aux)
if (time == t0) then
t_CPU_overall = 0.d0
timeTick_overall = 0.d0
else
else
call cpu_time(t_CPU_overall)
call system_clock(tick_clock_finish,tick_clock_rate)
timeTick_int = timeTick + tick_clock_finish - tick_clock_start
timeTick_overall = real(timeTick_int, kind=8)/real(clock_rate,kind=8)
endif
endif

write(out_unit, timing_line) time, timeTick_overall, t_CPU_overall, &
(real(tvoll(i), kind=8) / real(clock_rate, kind=8), &
Expand Down
22 changes: 20 additions & 2 deletions src/3d/amr3.f90
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,12 @@ program amr3
integer :: clock_start, clock_finish, clock_rate, ttotal
real(kind=8) :: cpu_start, cpu_finish,ttotalcpu
integer, parameter :: timing_unit = 48
character(len=256) :: timing_line, timing_substr
character(len=*), parameter :: timing_base_name = "timing."
character(len=*), parameter :: timing_header_format = &
"(' wall time (', i2,')," // &
" CPU time (', i2,'), " // &
"cells updated (', i2,'),')"

! Common block variables
real(kind=8) :: dxmin, dymin, dzmin
Expand All @@ -125,7 +131,6 @@ program amr3
character(len=*), parameter :: dbugfile = 'fort.debug'
character(len=*), parameter :: matfile = 'fort.nplot'
character(len=*), parameter :: parmfile = 'fort.parameters'
character(len=*), parameter :: timing_file = 'timing.txt'

! Open parameter and debug files
open(dbugunit,file=dbugfile,status='unknown',form='formatted')
Expand Down Expand Up @@ -478,6 +483,18 @@ program amr3

call set_gauges(rest, nvar, naux)
else
! Write header out and continue
open(unit=timing_unit, file=timing_base_name//"csv", &
form='formatted', status='unknown', action='write')
! Construct header string
timing_line = 'output_time,total_wall_time,total_cpu_time,'
timing_substr = ""
do level=1, mxnest
write(timing_substr, timing_header_format) level, level, level
timing_line = trim(timing_line) // trim(timing_substr)
end do
write(timing_unit, "(a)") timing_line
close(timing_unit)

open(outunit, file=outfile, status='unknown', form='formatted')

Expand Down Expand Up @@ -608,7 +625,8 @@ program amr3
call cpu_time(cpu_finish)

!output timing data
open(timing_unit, file=timing_file, status='unknown', form='formatted')
open(timing_unit, file=timing_base_name//"txt", status='unknown', &
form='formatted')
write(*,*)
write(timing_unit,*)
format_string="('============================== Timing Data ==============================')"
Expand Down
17 changes: 1 addition & 16 deletions src/3d/valout.f90
Original file line number Diff line number Diff line change
Expand Up @@ -298,23 +298,8 @@ subroutine valout(level_begin, level_end, time, num_eqn, num_aux)
! ==========================================================================
! Write out timing stats
! Assume that this has been started some where
inquire(file=timing_file_name, exist=timing_file_exists)
if (frame == 0 .or. (.not. timing_file_exists)) then
! Write header out and continue
open(unit=out_unit, file=timing_file_name, form='formatted', &
status='unknown', action='write')
! Construct header string
timing_line = 'output_time,total_wall_time,total_cpu_time,'
timing_substr = ""
do level=1, mxnest
write(timing_substr, timing_header_format) level, level, level
timing_line = trim(timing_line) // trim(timing_substr)
end do
write(out_unit, "(a)") timing_line
else
open(unit=out_unit, file=timing_file_name, form='formatted', &
open(unit=out_unit, file=timing_file_name, form='formatted', &
status='old', action='write', position='append')
end if

timing_line = "(e16.6, ', ', e16.6, ', ', e16.6,"
do level=1, mxnest
Expand Down