From 1dbe3369d48a570fb11cb1beb6dbc330645fbb78 Mon Sep 17 00:00:00 2001 From: David A Minton Date: Thu, 1 Dec 2022 16:11:45 -0500 Subject: [PATCH] Switched frame counter variables to I4B to simplify the code, as it really doesn't need to be I8B --- src/io/io.f90 | 11 ++++++----- src/main/swiftest_driver.f90 | 22 +++++++++++----------- src/modules/swiftest_classes.f90 | 4 ++-- src/netcdf/netcdf.f90 | 8 ++++---- 4 files changed, 23 insertions(+), 22 deletions(-) diff --git a/src/io/io.f90 b/src/io/io.f90 index 7ee5b9cbd..ce17cdadf 100644 --- a/src/io/io.f90 +++ b/src/io/io.f90 @@ -178,7 +178,7 @@ module subroutine io_conservation_report(self, param, lterminal) if (abs(system%Mtot_error) > 100 * epsilon(system%Mtot_error)) then write(*,*) "Severe error! Mass not conserved! Halting!" ! Save the frame of data to the bin file in the slot just after the present one for diagnostics - param%ioutput = param%ioutput + 1_I8B + param%ioutput = param%ioutput + 1 call self%write_frame(param%nciu, param) call param%nciu%close() call util_exit(FAILURE) @@ -282,12 +282,13 @@ module subroutine io_dump_system_storage(self, param) class(swiftest_storage(*)), intent(inout) :: self !! Swiftest simulation history storage object class(swiftest_parameters), intent(inout) :: param !! Current run configuration parameters ! Internals - integer(I8B) :: i, iloop_start + integer(I4B) :: i + integer(I8B) :: iloop_start - iloop_start = param%iloop - param%istep_out * param%dump_cadence + 1_I8B - do i = 1_I8B, param%dump_cadence + iloop_start = param%iloop - int(param%istep_out * param%dump_cadence + 1, kind=I8B) + do i = 1, param%dump_cadence if (allocated(self%frame(i)%system)) then - param%ioutput = int(iloop_start / param%istep_out, kind=I8B) + i + param%ioutput = int(iloop_start / param%istep_out, kind=I4B) + i call self%frame(i)%system%write_frame(param) deallocate(self%frame(i)%system) end if diff --git a/src/main/swiftest_driver.f90 b/src/main/swiftest_driver.f90 index a9af0cc71..b14abec80 100644 --- a/src/main/swiftest_driver.f90 +++ b/src/main/swiftest_driver.f90 @@ -18,16 +18,16 @@ program swiftest_driver use swiftest implicit none - class(swiftest_nbody_system), allocatable :: nbody_system !! Polymorphic object containing the nbody system to be integrated - class(swiftest_parameters), allocatable :: param !! Run configuration parameters - character(len=:), allocatable :: integrator !! Integrator type code (see swiftest_globals for symbolic names) - character(len=:),allocatable :: param_file_name !! Name of the file containing user-defined parameters - character(len=:), allocatable :: display_style !! Style of the output display {"STANDARD", "COMPACT", "PROGRESS"}). Default is "STANDARD" - integer(I8B) :: idump !! Dump cadence counter - integer(I8B) :: iout !! Output cadence counter - integer(I8B) :: istart !! Starting index for loop counter - integer(I8B) :: nloops !! Number of steps to take in the simulation - integer(I8B) :: iframe !! System history frame cindex + class(swiftest_nbody_system), allocatable :: nbody_system !! Polymorphic object containing the nbody system to be integrated + class(swiftest_parameters), allocatable :: param !! Run configuration parameters + character(len=:), allocatable :: integrator !! Integrator type code (see swiftest_globals for symbolic names) + character(len=:),allocatable :: param_file_name !! Name of the file containing user-defined parameters + character(len=:), allocatable :: display_style !! Style of the output display {"STANDARD", "COMPACT", "PROGRESS"}). Default is "STANDARD" + integer(I8B) :: istart !! Starting index for loop counter + integer(I8B) :: nloops !! Number of steps to take in the simulation + integer(I4B) :: iout !! Output cadence counter + integer(I4B) :: idump !! Dump cadence counter + integer(I4B) :: iframe !! System history frame cindex type(walltimer) :: integration_timer !! Object used for computing elapsed wall time real(DP) :: tfrac type(progress_bar) :: pbar !! Object used to print out a progress bar @@ -83,7 +83,7 @@ program swiftest_driver iout = istep_out nloops = ceiling((tstop - t0) / dt, kind=I8B) istart = ceiling((tstart - t0) / dt + 1, kind=I8B) - ioutput = int(istart / istep_out, kind=I8B) + ioutput = int(istart / istep_out, kind=I4B) ! Set up system storage for intermittent file dumps if (dump_cadence == 0) dump_cadence = ceiling(nloops / (1.0_DP * istep_out), kind=I8B) diff --git a/src/modules/swiftest_classes.f90 b/src/modules/swiftest_classes.f90 index a7d3965c5..6f0d10857 100644 --- a/src/modules/swiftest_classes.f90 +++ b/src/modules/swiftest_classes.f90 @@ -41,7 +41,7 @@ module swiftest_classes real(DP) :: tstop = -1.0_DP !! Integration stop time real(DP) :: dt = -1.0_DP !! Time step integer(I8B) :: iloop = 0_I8B !! Main loop counter - integer(I8B) :: ioutput = 0_I8B !! Output counter + integer(I4B) :: ioutput = 0 !! Output counter character(STRMAX) :: incbfile = CB_INFILE !! Name of input file for the central body character(STRMAX) :: inplfile = PL_INFILE !! Name of input file for massive bodies character(STRMAX) :: intpfile = TP_INFILE !! Name of input file for test particles @@ -425,7 +425,7 @@ module swiftest_classes end type type, extends(swiftest_base) :: swiftest_storage(nframes) - integer(I8B), len :: nframes + integer(I4B), len :: nframes !! A class that that is used to store simulation history data between file output type(storage_frame), dimension(nframes) :: frame contains diff --git a/src/netcdf/netcdf.f90 b/src/netcdf/netcdf.f90 index abd03f1d6..4b56715fd 100644 --- a/src/netcdf/netcdf.f90 +++ b/src/netcdf/netcdf.f90 @@ -519,7 +519,7 @@ module function netcdf_read_frame_system(self, iu, param) result(ierr) call pl%setup(npl, param) call tp%setup(ntp, param) - tslot = int(param%ioutput, kind=I4B) + 1 + tslot = param%ioutput + 1 call check( nf90_inquire_dimension(iu%ncid, iu%id_dimid, len=idmax), "netcdf_read_frame_system nf90_inquire_dimension id_dimid" ) allocate(rtemp(idmax)) @@ -791,7 +791,7 @@ module subroutine netcdf_read_hdr_system(self, iu, param) logical, dimension(:), allocatable :: plmask, tpmask, plmmask - tslot = int(param%ioutput, kind=I4B) + 1 + tslot = param%ioutput + 1 call check( nf90_inquire_dimension(iu%ncid, iu%id_dimid, len=idmax), "netcdf_read_frame_system nf90_inquire_dimension id_dimid" ) call check( nf90_get_var(iu%ncid, iu%time_varid, self%t, start=[tslot]), "netcdf_read_hdr_system nf90_getvar time_varid" ) @@ -1185,7 +1185,7 @@ module subroutine netcdf_write_frame_base(self, iu, param) call self%write_particle_info(iu, param) - tslot = int(param%ioutput, kind=I4B) + 1 + tslot = param%ioutput + 1 call check( nf90_set_fill(iu%ncid, nf90_nofill, old_mode), "netcdf_write_frame_base nf90_set_fill" ) select type(self) @@ -1426,7 +1426,7 @@ module subroutine netcdf_write_hdr_system(self, iu, param) ! Internals integer(I4B) :: tslot - tslot = int(param%ioutput, kind=I4B) + 1 + tslot = param%ioutput + 1 call check( nf90_put_var(iu%ncid, iu%time_varid, self%t, start=[tslot]), "netcdf_write_hdr_system nf90_put_var time_varid" ) call check( nf90_put_var(iu%ncid, iu%npl_varid, self%pl%nbody, start=[tslot]), "netcdf_write_hdr_system nf90_put_var npl_varid" )