Skip to content
This repository was archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
Removed the first call to io_conservation_report from the first dump …
Browse files Browse the repository at this point in the history
…call, as no dumping is actually happening any more and it is confusing
  • Loading branch information
daminton committed Sep 23, 2021
1 parent 5f1dced commit be30886
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 48 deletions.
88 changes: 41 additions & 47 deletions src/io/io.f90
Original file line number Diff line number Diff line change
Expand Up @@ -277,57 +277,51 @@ module subroutine io_dump_system(self, param)
real(DP) :: tfrac
character(*), parameter :: statusfmt = '("Time = ", ES12.5, "; fraction done = ", F6.3, "; Number of active pl, tp = ", I5, ", ", I5)'
character(*), parameter :: symbastatfmt = '("Time = ", ES12.5, "; fraction done = ", F6.3, "; Number of active plm, pl, tp = ", I5, ", ", I5, ", ", I5)'
logical, save :: lfirst = .true.

if (lfirst) then
lfirst = .false.
if (param%lenergy) call self%conservation_report(param, lterminal=.false.)
else
allocate(dump_param, source=param)
param_file_name = trim(adjustl(DUMP_PARAM_FILE(idx)))
dump_param%in_form = XV
dump_param%out_form = XV
dump_param%out_stat = 'APPEND'
if ((param%out_type == REAL8_TYPE) .or. (param%out_type == REAL4_TYPE)) then
dump_param%incbfile = trim(adjustl(DUMP_CB_FILE(idx)))
dump_param%inplfile = trim(adjustl(DUMP_PL_FILE(idx)))
dump_param%intpfile = trim(adjustl(DUMP_TP_FILE(idx)))
dump_param%in_type = REAL8_TYPE
else if ((param%out_type == NETCDF_FLOAT_TYPE) .or. (param%out_type == NETCDF_DOUBLE_TYPE)) then
dump_param%outfile = trim(adjustl(DUMP_NC_FILE(idx)))
dump_param%in_type = NETCDF_DOUBLE_TYPE
end if
dump_param%T0 = param%t
dump_param%ioutput = 0

call dump_param%dump(param_file_name)

if ((param%out_type == REAL8_TYPE) .or. (param%out_type == REAL4_TYPE)) then
call self%cb%dump(dump_param)
call self%pl%dump(dump_param)
call self%tp%dump(dump_param)
else if ((param%out_type == NETCDF_FLOAT_TYPE) .or. (param%out_type == NETCDF_DOUBLE_TYPE)) then
call dump_param%nciu%initialize(dump_param)
call self%write_hdr(dump_param%nciu, dump_param)
call self%cb%write_frame(dump_param%nciu, dump_param)
call self%pl%write_frame(dump_param%nciu, dump_param)
call self%tp%write_frame(dump_param%nciu, dump_param)
call dump_param%nciu%close(dump_param)
end if

allocate(dump_param, source=param)
param_file_name = trim(adjustl(DUMP_PARAM_FILE(idx)))
dump_param%in_form = XV
dump_param%out_form = XV
dump_param%out_stat = 'APPEND'
if ((param%out_type == REAL8_TYPE) .or. (param%out_type == REAL4_TYPE)) then
dump_param%incbfile = trim(adjustl(DUMP_CB_FILE(idx)))
dump_param%inplfile = trim(adjustl(DUMP_PL_FILE(idx)))
dump_param%intpfile = trim(adjustl(DUMP_TP_FILE(idx)))
dump_param%in_type = REAL8_TYPE
else if ((param%out_type == NETCDF_FLOAT_TYPE) .or. (param%out_type == NETCDF_DOUBLE_TYPE)) then
dump_param%outfile = trim(adjustl(DUMP_NC_FILE(idx)))
dump_param%in_type = NETCDF_DOUBLE_TYPE
end if
dump_param%T0 = param%t
dump_param%ioutput = 0

idx = idx + 1
if (idx > NDUMPFILES) idx = 1
call dump_param%dump(param_file_name)

tfrac = (param%t - param%t0) / (param%tstop - param%t0)

select type(pl => self%pl)
class is (symba_pl)
write(*, symbastatfmt) param%t, tfrac, pl%nplm, pl%nbody, self%tp%nbody
class default
write(*, statusfmt) param%t, tfrac, pl%nbody, self%tp%nbody
end select
if ((param%out_type == REAL8_TYPE) .or. (param%out_type == REAL4_TYPE)) then
call self%cb%dump(dump_param)
call self%pl%dump(dump_param)
call self%tp%dump(dump_param)
else if ((param%out_type == NETCDF_FLOAT_TYPE) .or. (param%out_type == NETCDF_DOUBLE_TYPE)) then
call dump_param%nciu%initialize(dump_param)
call self%write_hdr(dump_param%nciu, dump_param)
call self%cb%write_frame(dump_param%nciu, dump_param)
call self%pl%write_frame(dump_param%nciu, dump_param)
call self%tp%write_frame(dump_param%nciu, dump_param)
call dump_param%nciu%close(dump_param)
end if

idx = idx + 1
if (idx > NDUMPFILES) idx = 1

tfrac = (param%t - param%t0) / (param%tstop - param%t0)

select type(pl => self%pl)
class is (symba_pl)
write(*, symbastatfmt) param%t, tfrac, pl%nplm, pl%nbody, self%tp%nbody
class default
write(*, statusfmt) param%t, tfrac, pl%nbody, self%tp%nbody
end select

return
end subroutine io_dump_system

Expand Down
2 changes: 1 addition & 1 deletion src/main/swiftest_driver.f90
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ program swiftest_driver
else
old_t_final = t0
if (istep_out > 0) call nbody_system%write_frame(param)
call nbody_system%dump(param)
if (param%lenergy) call nbody_system%conservation_report(param, lterminal=.false.) ! This will save the initial values of energy and momentum
end if

!> Define the maximum number of threads
Expand Down

0 comments on commit be30886

Please sign in to comment.