From 013178900a92946143f52e3aac8c30bf3a169592 Mon Sep 17 00:00:00 2001 From: David A Minton Date: Sat, 3 Dec 2022 15:51:00 -0500 Subject: [PATCH] Major refactoring! Changed all NetCDF component variables to vectors in the SPACE DIMENSION. Also refactored xh to rh, as that's has been bugging me for years. --- src/discard/discard.f90 | 16 +- src/drift/drift.f90 | 2 +- src/encounter/encounter_io.f90 | 104 +++--- src/fraggle/fraggle_io.f90 | 4 +- src/fraggle/fraggle_util.f90 | 2 +- src/gr/gr.f90 | 22 +- src/helio/helio_drift.f90 | 26 +- src/helio/helio_gr.f90 | 8 +- src/helio/helio_kick.f90 | 4 +- src/io/io.f90 | 2 +- src/kick/kick.f90 | 10 +- src/modules/swiftest_classes.f90 | 32 +- src/netcdf/netcdf.f90 | 517 ++++++++-------------------- src/obl/obl.f90 | 10 +- src/orbel/orbel.f90 | 4 +- src/rmvs/rmvs_discard.f90 | 2 +- src/rmvs/rmvs_encounter_check.f90 | 2 +- src/rmvs/rmvs_kick.f90 | 12 +- src/rmvs/rmvs_step.f90 | 30 +- src/setup/setup.f90 | 14 +- src/setup/symba_collision.f90 | 36 +- src/symba/symba_collision.f90 | 36 +- src/symba/symba_discard.f90 | 10 +- src/symba/symba_encounter_check.f90 | 14 +- src/symba/symba_kick.f90 | 14 +- src/symba/symba_util.f90 | 6 +- src/tides/tides_getacch_pl.f90 | 4 +- src/util/util_append.f90 | 2 +- src/util/util_coord.f90 | 24 +- src/util/util_copy.f90 | 4 +- src/util/util_dealloc.f90 | 2 +- src/util/util_fill.f90 | 2 +- src/util/util_peri.f90 | 4 +- src/util/util_rescale.f90 | 2 +- src/util/util_resize.f90 | 2 +- src/util/util_set.f90 | 20 +- src/util/util_sort.f90 | 4 +- src/util/util_spill.f90 | 2 +- src/whm/whm_coord.f90 | 14 +- src/whm/whm_gr.f90 | 4 +- src/whm/whm_kick.f90 | 8 +- src/whm/whm_util.f90 | 2 +- 42 files changed, 404 insertions(+), 635 deletions(-) diff --git a/src/discard/discard.f90 b/src/discard/discard.f90 index 2019774a8..41ece554b 100644 --- a/src/discard/discard.f90 +++ b/src/discard/discard.f90 @@ -131,7 +131,7 @@ subroutine discard_cb_tp(tp, system, param) rmaxu2 = param%rmaxu**2 do i = 1, ntp if (tp%status(i) == ACTIVE) then - rh2 = dot_product(tp%xh(:, i), tp%xh(:, i)) + rh2 = dot_product(tp%rh(:, i), tp%rh(:, i)) if ((param%rmax >= 0.0_DP) .and. (rh2 > rmax2)) then tp%status(i) = DISCARDED_RMAX write(idstr, *) tp%id(i) @@ -140,7 +140,7 @@ subroutine discard_cb_tp(tp, system, param) " too far from the central body at t = " // trim(adjustl(timestr)) tp%ldiscard(i) = .true. tp%lmask(i) = .false. - call tp%info(i)%set_value(status="DISCARDED_RMAX", discard_time=system%t, discard_xh=tp%xh(:,i), & + call tp%info(i)%set_value(status="DISCARDED_RMAX", discard_time=system%t, discard_rh=tp%rh(:,i), & discard_vh=tp%vh(:,i)) else if ((param%rmin >= 0.0_DP) .and. (rh2 < rmin2)) then tp%status(i) = DISCARDED_RMIN @@ -150,7 +150,7 @@ subroutine discard_cb_tp(tp, system, param) " too close to the central body at t = " // trim(adjustl(timestr)) tp%ldiscard(i) = .true. tp%lmask(i) = .false. - call tp%info(i)%set_value(status="DISCARDED_RMIN", discard_time=system%t, discard_xh=tp%xh(:,i), & + call tp%info(i)%set_value(status="DISCARDED_RMIN", discard_time=system%t, discard_rh=tp%rh(:,i), & discard_vh=tp%vh(:,i), discard_body_id=cb%id) else if (param%rmaxu >= 0.0_DP) then rb2 = dot_product(tp%xb(:, i), tp%xb(:, i)) @@ -164,7 +164,7 @@ subroutine discard_cb_tp(tp, system, param) " is unbound and too far from barycenter at t = " // trim(adjustl(timestr)) tp%ldiscard(i) = .true. tp%lmask(i) = .false. - call tp%info(i)%set_value(status="DISCARDED_RMAXU", discard_time=system%t, discard_xh=tp%xh(:,i), & + call tp%info(i)%set_value(status="DISCARDED_RMAXU", discard_time=system%t, discard_rh=tp%rh(:,i), & discard_vh=tp%vh(:,i)) end if end if @@ -201,7 +201,7 @@ subroutine discard_peri_tp(tp, system, param) if (tp%isperi(i) == 0) then ih = 1 do j = 1, npl - dx(:) = tp%xh(:, i) - pl%xh(:, j) + dx(:) = tp%rh(:, i) - pl%rh(:, j) r2 = dot_product(dx(:), dx(:)) if (r2 <= (pl%rhill(j))**2) ih = 0 end do @@ -215,7 +215,7 @@ subroutine discard_peri_tp(tp, system, param) write(*, *) "Particle " // trim(adjustl(tp%info(i)%name)) // " (" // trim(adjustl(idstr)) // ")" // & " perihelion distance too small at t = " // trim(adjustl(timestr)) tp%ldiscard(i) = .true. - call tp%info(i)%set_value(status="DISCARDED_PERI", discard_time=system%t, discard_xh=tp%xh(:,i), & + call tp%info(i)%set_value(status="DISCARDED_PERI", discard_time=system%t, discard_rh=tp%rh(:,i), & discard_vh=tp%vh(:,i), discard_body_id=pl%id(j)) end if end if @@ -250,7 +250,7 @@ subroutine discard_pl_tp(tp, system, param) do i = 1, ntp if (tp%status(i) == ACTIVE) then do j = 1, npl - dx(:) = tp%xh(:, i) - pl%xh(:, j) + dx(:) = tp%rh(:, i) - pl%rh(:, j) dv(:) = tp%vh(:, i) - pl%vh(:, j) radius = pl%radius(j) call discard_pl_close(dx(:), dv(:), dt, radius**2, isp, r2min) @@ -265,7 +265,7 @@ subroutine discard_pl_tp(tp, system, param) // " too close to massive body " // trim(adjustl(pl%info(j)%name)) // " (" // trim(adjustl(idstrj)) // ")" & // " at t = " // trim(adjustl(timestr)) tp%ldiscard(i) = .true. - call tp%info(i)%set_value(status="DISCARDED_PLR", discard_time=system%t, discard_xh=tp%xh(:,i), & + call tp%info(i)%set_value(status="DISCARDED_PLR", discard_time=system%t, discard_rh=tp%rh(:,i), & discard_vh=tp%vh(:,i), discard_body_id=pl%id(j)) exit end if diff --git a/src/drift/drift.f90 b/src/drift/drift.f90 index b2e3c1b9a..7c7c2bdba 100644 --- a/src/drift/drift.f90 +++ b/src/drift/drift.f90 @@ -39,7 +39,7 @@ module subroutine drift_body(self, system, param, dt) associate(n => self%nbody) allocate(iflag(n)) iflag(:) = 0 - call drift_all(self%mu, self%xh, self%vh, self%nbody, param, dt, self%lmask, iflag) + call drift_all(self%mu, self%rh, self%vh, self%nbody, param, dt, self%lmask, iflag) if (any(iflag(1:n) /= 0)) then where(iflag(1:n) /= 0) self%status(1:n) = DISCARDED_DRIFTERR do i = 1, n diff --git a/src/encounter/encounter_io.f90 b/src/encounter/encounter_io.f90 index e425c0ae1..d28ecd1f5 100644 --- a/src/encounter/encounter_io.f90 +++ b/src/encounter/encounter_io.f90 @@ -81,19 +81,15 @@ module subroutine encounter_io_initialize_output(self, param) self%out_type = NF90_DOUBLE end select - call check( nf90_def_var(self%id, self%time_dimname, self%out_type, self%time_dimid, self%time_varid), "encounter_io_initialize_output nf90_def_var time_varid" ) - call check( nf90_def_var(self%id, self%nenc_varname, NF90_INT, self%time_dimid, self%nenc_varid), "encounter_io_initialize_output nf90_def_var nenc_varid" ) - call check( nf90_def_var(self%id, self%name_varname, NF90_CHAR, [self%str_dimid, self%collider_dimid, self%eid_dimid], self%name_varid), "encounter_io_initialize_output nf90_def_var name_varid" ) - call check( nf90_def_var(self%id, self%id_dimname, NF90_INT, [self%collider_dimid, self%eid_dimid, self%time_dimid], self%id_varid), "encounter_io_initialize_output nf90_def_var id_varid" ) - call check( nf90_def_var(self%id, self%xhx_varname, self%out_type, [self%collider_dimid, self%eid_dimid, self%time_dimid], self%xhx_varid), "encounter_io_initialize_output nf90_def_var xhx_varid" ) - call check( nf90_def_var(self%id, self%xhy_varname, self%out_type, [self%collider_dimid, self%eid_dimid, self%time_dimid], self%xhy_varid), "encounter_io_initialize_output nf90_def_var xhy_varid" ) - call check( nf90_def_var(self%id, self%xhz_varname, self%out_type, [self%collider_dimid, self%eid_dimid, self%time_dimid], self%xhz_varid), "encounter_io_initialize_output nf90_def_var xhz_varid" ) - call check( nf90_def_var(self%id, self%vhx_varname, self%out_type, [self%collider_dimid, self%eid_dimid, self%time_dimid], self%vhx_varid), "encounter_io_initialize_output nf90_def_var vhx_varid" ) - call check( nf90_def_var(self%id, self%vhy_varname, self%out_type, [self%collider_dimid, self%eid_dimid, self%time_dimid], self%vhy_varid), "encounter_io_initialize_output nf90_def_var vhy_varid" ) - call check( nf90_def_var(self%id, self%vhz_varname, self%out_type, [self%collider_dimid, self%eid_dimid, self%time_dimid], self%vhz_varid), "encounter_io_initialize_output nf90_def_var vhz_varid" ) - call check( nf90_def_var(self%id, self%level_varname, NF90_INT, [self%eid_dimid, self%time_dimid], self%level_varid), "encounter_io_initialize_output nf90_def_var level_varid" ) - call check( nf90_def_var(self%id, self%gmass_varname, self%out_type, [self%collider_dimid, self%eid_dimid, self%time_dimid], self%Gmass_varid), "encounter_io_initialize_output nf90_def_var Gmass_varid" ) - call check( nf90_def_var(self%id, self%radius_varname, self%out_type, [self%collider_dimid, self%eid_dimid, self%time_dimid], self%radius_varid), "encounter_io_initialize_output nf90_def_var radius_varid" ) + ! call check( nf90_def_var(self%id, self%time_dimname, self%out_type, self%time_dimid, self%time_varid), "encounter_io_initialize_output nf90_def_var time_varid" ) + ! call check( nf90_def_var(self%id, self%nenc_varname, NF90_INT, self%time_dimid, self%nenc_varid), "encounter_io_initialize_output nf90_def_var nenc_varid" ) + ! call check( nf90_def_var(self%id, self%name_varname, NF90_CHAR, [self%str_dimid, self%collider_dimid, self%eid_dimid], self%name_varid), "encounter_io_initialize_output nf90_def_var name_varid" ) + ! call check( nf90_def_var(self%id, self%id_dimname, NF90_INT, [self%collider_dimid, self%eid_dimid, self%time_dimid], self%id_varid), "encounter_io_initialize_output nf90_def_var id_varid" ) + ! call check( nf90_def_var(self%id, self%rh_varname, self%out_type, [self%collider_dimid, self%eid_dimid, self%time_dimid], self%rh_varid), "encounter_io_initialize_output nf90_def_var rh_varid" ) + ! call check( nf90_def_var(self%id, self%vh_varname, self%out_type, [self%collider_dimid, self%eid_dimid, self%time_dimid], self%vh_varid), "encounter_io_initialize_output nf90_def_var vh_varid" ) + ! call check( nf90_def_var(self%id, self%level_varname, NF90_INT, [self%eid_dimid, self%time_dimid], self%level_varid), "encounter_io_initialize_output nf90_def_var level_varid" ) + ! call check( nf90_def_var(self%id, self%gmass_varname, self%out_type, [self%collider_dimid, self%eid_dimid, self%time_dimid], self%Gmass_varid), "encounter_io_initialize_output nf90_def_var Gmass_varid" ) + ! call check( nf90_def_var(self%id, self%radius_varname, self%out_type, [self%collider_dimid, self%eid_dimid, self%time_dimid], self%radius_varid), "encounter_io_initialize_output nf90_def_var radius_varid" ) ! Take the file out of define mode @@ -128,24 +124,24 @@ module subroutine encounter_io_open_file(self, param, readonly) write(errmsg,*) "encounter_io_open_file nf90_open ",trim(adjustl(param%outfile)) call check( nf90_open(self%enc_file, mode, self%id), errmsg) - call check( nf90_inq_dimid(self%id, self%time_dimname, self%time_dimid), "encounter_io_open_file nf90_inq_dimid time_dimid" ) - call check( nf90_inq_dimid(self%id, self%eid_dimname, self%eid_dimid), "encounter_io_open_file nf90_inq_dimid eid_dimid" ) - call check( nf90_inq_dimid(self%id, self%collider_dimname, self%collider_dimid), "encounter_io_open_file nf90_inq_dimid collider_dimid" ) - call check( nf90_inq_dimid(self%id, self%str_dimname, self%str_dimid), "encounter_io_open_file nf90_inq_dimid collider_str" ) - - call check( nf90_inq_varid(self%id, self%time_dimname, self%time_varid), "encounter_io_open_file nf90_inq_varid time_varid" ) - call check( nf90_inq_varid(self%id, self%name_varname, self%name_varid), "encounter_io_open_file nf90_inq_varid name_varid" ) - call check( nf90_inq_varid(self%id, self%nenc_varname, self%nenc_varid), "encounter_io_open_file nf90_inq_varid nenc_varid" ) - - call check( nf90_inq_varid(self%id, self%xhx_varname, self%xhx_varid), "encounter_io_open_file nf90_inq_varid xhx_varid" ) - call check( nf90_inq_varid(self%id, self%xhy_varname, self%xhy_varid), "encounter_io_open_file nf90_inq_varid xhy_varid" ) - call check( nf90_inq_varid(self%id, self%xhz_varname, self%xhz_varid), "encounter_io_open_file nf90_inq_varid xhz_varid" ) - call check( nf90_inq_varid(self%id, self%vhx_varname, self%vhx_varid), "encounter_io_open_file nf90_inq_varid vhx_varid" ) - call check( nf90_inq_varid(self%id, self%vhy_varname, self%vhy_varid), "encounter_io_open_file nf90_inq_varid vhy_varid" ) - call check( nf90_inq_varid(self%id, self%vhz_varname, self%vhz_varid), "encounter_io_open_file nf90_inq_varid vhz_varid" ) - call check( nf90_inq_varid(self%id, self%level_varname, self%level_varid), "encounter_io_open_file nf90_inq_varid level_varid" ) - call check( nf90_inq_varid(self%id, self%gmass_varname, self%Gmass_varid), "encounter_io_open_file nf90_inq_varid Gmass_varid" ) - call check( nf90_inq_varid(self%id, self%radius_varname, self%radius_varid), "encounter_io_open_file nf90_inq_varid radius_varid" ) + ! call check( nf90_inq_dimid(self%id, self%time_dimname, self%time_dimid), "encounter_io_open_file nf90_inq_dimid time_dimid" ) + ! call check( nf90_inq_dimid(self%id, self%eid_dimname, self%eid_dimid), "encounter_io_open_file nf90_inq_dimid eid_dimid" ) + ! call check( nf90_inq_dimid(self%id, self%collider_dimname, self%collider_dimid), "encounter_io_open_file nf90_inq_dimid collider_dimid" ) + ! call check( nf90_inq_dimid(self%id, self%str_dimname, self%str_dimid), "encounter_io_open_file nf90_inq_dimid collider_str" ) + + ! call check( nf90_inq_varid(self%id, self%time_dimname, self%time_varid), "encounter_io_open_file nf90_inq_varid time_varid" ) + ! call check( nf90_inq_varid(self%id, self%name_varname, self%name_varid), "encounter_io_open_file nf90_inq_varid name_varid" ) + ! call check( nf90_inq_varid(self%id, self%nenc_varname, self%nenc_varid), "encounter_io_open_file nf90_inq_varid nenc_varid" ) + + ! call check( nf90_inq_varid(self%id, self%xhx_varname, self%xhx_varid), "encounter_io_open_file nf90_inq_varid xhx_varid" ) + ! call check( nf90_inq_varid(self%id, self%xhy_varname, self%xhy_varid), "encounter_io_open_file nf90_inq_varid xhy_varid" ) + ! call check( nf90_inq_varid(self%id, self%xhz_varname, self%xhz_varid), "encounter_io_open_file nf90_inq_varid xhz_varid" ) + ! call check( nf90_inq_varid(self%id, self%vhx_varname, self%vhx_varid), "encounter_io_open_file nf90_inq_varid vhx_varid" ) + ! call check( nf90_inq_varid(self%id, self%vhy_varname, self%vhy_varid), "encounter_io_open_file nf90_inq_varid vhy_varid" ) + ! call check( nf90_inq_varid(self%id, self%vhz_varname, self%vhz_varid), "encounter_io_open_file nf90_inq_varid vhz_varid" ) + ! call check( nf90_inq_varid(self%id, self%level_varname, self%level_varid), "encounter_io_open_file nf90_inq_varid level_varid" ) + ! call check( nf90_inq_varid(self%id, self%gmass_varname, self%Gmass_varid), "encounter_io_open_file nf90_inq_varid Gmass_varid" ) + ! call check( nf90_inq_varid(self%id, self%radius_varname, self%radius_varid), "encounter_io_open_file nf90_inq_varid radius_varid" ) return end subroutine encounter_io_open_file @@ -167,29 +163,29 @@ module subroutine encounter_io_write_frame(self, iu, param) call check( nf90_set_fill(iu%id, nf90_nofill, old_mode), "encounter_io_write_frame_base nf90_set_fill" ) call check( nf90_put_var(iu%id, iu%time_varid, self%t, start=[i]), "encounter_io_write_frame nf90_put_var time_varid" ) - call check( nf90_put_var(iu%id, iu%nenc_varid, self%nenc, start=[i]), "encounter_io_frame nf90_put_var nenc_varid" ) - call check( nf90_put_var(iu%id, iu%name_varid, self%name1(1:n), start=[1, 1, i], count=[NAMELEN,1,1]), "netcdf_write_frame nf90_put_var name 1" ) - call check( nf90_put_var(iu%id, iu%name_varid, self%name2(1:n), start=[1, 2, i], count=[NAMELEN,1,1]), "netcdf_write_frame nf90_put_var name 2" ) - call check( nf90_put_var(iu%id, iu%xhx_varid, self%x1(1, 1:n), start=[1, 1, i], count=[1,n,1]), "netcdf_write_frame nf90_put_var xhx_varid 1" ) - call check( nf90_put_var(iu%id, iu%xhy_varid, self%x1(2, 1:n), start=[1, 1, i], count=[1,n,1]), "netcdf_write_frame nf90_put_var xhy_varid 1" ) - call check( nf90_put_var(iu%id, iu%xhz_varid, self%x1(3, 1:n), start=[1, 1, i], count=[1,n,1]), "netcdf_write_frame nf90_put_var xhz_varid 1" ) - call check( nf90_put_var(iu%id, iu%xhx_varid, self%x2(1, 1:n), start=[2, 1, i], count=[1,n,1]), "netcdf_write_frame nf90_put_var xhx_varid 2" ) - call check( nf90_put_var(iu%id, iu%xhy_varid, self%x2(2, 1:n), start=[2, 1, i], count=[1,n,1]), "netcdf_write_frame nf90_put_var xhy_varid 2" ) - call check( nf90_put_var(iu%id, iu%xhz_varid, self%x2(3, 1:n), start=[2, 1, i], count=[1,n,1]), "netcdf_write_frame nf90_put_var xhz_varid 2" ) - call check( nf90_put_var(iu%id, iu%vhx_varid, self%v1(1, 1:n), start=[1, 1, i], count=[1,n,1]), "netcdf_write_frame nf90_put_var vhx_varid 1" ) - call check( nf90_put_var(iu%id, iu%vhy_varid, self%v1(2, 1:n), start=[1, 1, i], count=[1,n,1]), "netcdf_write_frame nf90_put_var vhy_varid 1" ) - call check( nf90_put_var(iu%id, iu%vhz_varid, self%v1(3, 1:n), start=[1, 1, i], count=[1,n,1]), "netcdf_write_frame nf90_put_var vhz_varid 1" ) - call check( nf90_put_var(iu%id, iu%vhx_varid, self%v2(1, 1:n), start=[2, 1, i], count=[1,n,1]), "netcdf_write_frame nf90_put_var vhx_varid 2" ) - call check( nf90_put_var(iu%id, iu%vhy_varid, self%v2(2, 1:n), start=[2, 1, i], count=[1,n,1]), "netcdf_write_frame nf90_put_var vhy_varid 2" ) - call check( nf90_put_var(iu%id, iu%vhz_varid, self%v2(3, 1:n), start=[2, 1, i], count=[1,n,1]), "netcdf_write_frame nf90_put_var vhz_varid 2" ) - call check( nf90_put_var(iu%id, iu%Gmass_varid, self%Gmass1(1:n), start=[1, 1, i], count=[1,n,1]), "netcdf_write_frame nf90_put_var Gmass 1" ) - call check( nf90_put_var(iu%id, iu%Gmass_varid, self%Gmass2(1:n), start=[2, 1, i], count=[1,n,1]), "netcdf_write_frame nf90_put_var Gmass 2" ) - call check( nf90_put_var(iu%id, iu%radius_varid, self%radius1(1:n), start=[1, 1, i], count=[1,n,1]), "netcdf_write_frame nf90_put_var radius 1" ) - call check( nf90_put_var(iu%id, iu%radius_varid, self%radius2(1:n), start=[2, 1, i], count=[1,n,1]), "netcdf_write_frame nf90_put_var radius 2" ) - select type(self) - class is (symba_encounter) - call check( nf90_put_var(iu%id, iu%level_varid, self%level(1:n), start=[1, i], count=[n,1]), "netcdf_write_frame nf90_put_var level" ) - end select + ! call check( nf90_put_var(iu%id, iu%nenc_varid, self%nenc, start=[i]), "encounter_io_frame nf90_put_var nenc_varid" ) + ! call check( nf90_put_var(iu%id, iu%name_varid, self%name1(1:n), start=[1, 1, i], count=[NAMELEN,1,1]), "netcdf_write_frame nf90_put_var name 1" ) + ! call check( nf90_put_var(iu%id, iu%name_varid, self%name2(1:n), start=[1, 2, i], count=[NAMELEN,1,1]), "netcdf_write_frame nf90_put_var name 2" ) + ! call check( nf90_put_var(iu%id, iu%xhx_varid, self%x1(1, 1:n), start=[1, 1, i], count=[1,n,1]), "netcdf_write_frame nf90_put_var xhx_varid 1" ) + ! call check( nf90_put_var(iu%id, iu%xhy_varid, self%x1(2, 1:n), start=[1, 1, i], count=[1,n,1]), "netcdf_write_frame nf90_put_var xhy_varid 1" ) + ! call check( nf90_put_var(iu%id, iu%xhz_varid, self%x1(3, 1:n), start=[1, 1, i], count=[1,n,1]), "netcdf_write_frame nf90_put_var xhz_varid 1" ) + ! call check( nf90_put_var(iu%id, iu%xhx_varid, self%x2(1, 1:n), start=[2, 1, i], count=[1,n,1]), "netcdf_write_frame nf90_put_var xhx_varid 2" ) + ! call check( nf90_put_var(iu%id, iu%xhy_varid, self%x2(2, 1:n), start=[2, 1, i], count=[1,n,1]), "netcdf_write_frame nf90_put_var xhy_varid 2" ) + ! call check( nf90_put_var(iu%id, iu%xhz_varid, self%x2(3, 1:n), start=[2, 1, i], count=[1,n,1]), "netcdf_write_frame nf90_put_var xhz_varid 2" ) + ! call check( nf90_put_var(iu%id, iu%vhx_varid, self%v1(1, 1:n), start=[1, 1, i], count=[1,n,1]), "netcdf_write_frame nf90_put_var vhx_varid 1" ) + ! call check( nf90_put_var(iu%id, iu%vhy_varid, self%v1(2, 1:n), start=[1, 1, i], count=[1,n,1]), "netcdf_write_frame nf90_put_var vhy_varid 1" ) + ! call check( nf90_put_var(iu%id, iu%vhz_varid, self%v1(3, 1:n), start=[1, 1, i], count=[1,n,1]), "netcdf_write_frame nf90_put_var vhz_varid 1" ) + ! call check( nf90_put_var(iu%id, iu%vhx_varid, self%v2(1, 1:n), start=[2, 1, i], count=[1,n,1]), "netcdf_write_frame nf90_put_var vhx_varid 2" ) + ! call check( nf90_put_var(iu%id, iu%vhy_varid, self%v2(2, 1:n), start=[2, 1, i], count=[1,n,1]), "netcdf_write_frame nf90_put_var vhy_varid 2" ) + ! call check( nf90_put_var(iu%id, iu%vhz_varid, self%v2(3, 1:n), start=[2, 1, i], count=[1,n,1]), "netcdf_write_frame nf90_put_var vhz_varid 2" ) + ! call check( nf90_put_var(iu%id, iu%Gmass_varid, self%Gmass1(1:n), start=[1, 1, i], count=[1,n,1]), "netcdf_write_frame nf90_put_var Gmass 1" ) + ! call check( nf90_put_var(iu%id, iu%Gmass_varid, self%Gmass2(1:n), start=[2, 1, i], count=[1,n,1]), "netcdf_write_frame nf90_put_var Gmass 2" ) + ! call check( nf90_put_var(iu%id, iu%radius_varid, self%radius1(1:n), start=[1, 1, i], count=[1,n,1]), "netcdf_write_frame nf90_put_var radius 1" ) + ! call check( nf90_put_var(iu%id, iu%radius_varid, self%radius2(1:n), start=[2, 1, i], count=[1,n,1]), "netcdf_write_frame nf90_put_var radius 2" ) + ! select type(self) + ! class is (symba_encounter) + ! call check( nf90_put_var(iu%id, iu%level_varid, self%level(1:n), start=[1, i], count=[n,1]), "netcdf_write_frame nf90_put_var level" ) + ! end select return end subroutine encounter_io_write_frame diff --git a/src/fraggle/fraggle_io.f90 b/src/fraggle/fraggle_io.f90 index b1a60a25b..87d2d7d11 100644 --- a/src/fraggle/fraggle_io.f90 +++ b/src/fraggle/fraggle_io.f90 @@ -108,9 +108,9 @@ module subroutine fraggle_io_log_pl(pl, param) do i = 1, pl%nbody write(LUN, *) i, pl%vb(:,i) end do - write(LUN, *) "xh" + write(LUN, *) "rh" do i = 1, pl%nbody - write(LUN, *) i, pl%xh(:,i) + write(LUN, *) i, pl%rh(:,i) end do write(LUN, *) "vh" do i = 1, pl%nbody diff --git a/src/fraggle/fraggle_util.f90 b/src/fraggle/fraggle_util.f90 index e03e30eb5..5c0803912 100644 --- a/src/fraggle/fraggle_util.f90 +++ b/src/fraggle/fraggle_util.f90 @@ -37,7 +37,7 @@ module subroutine fraggle_util_add_fragments_to_system(frag, colliders, system, do concurrent (i = 1:nfrag) pl%xb(:,npl_before+i) = frag%xb(:,i) pl%vb(:,npl_before+i) = frag%vb(:,i) - pl%xh(:,npl_before+i) = frag%xb(:,i) - cb%xb(:) + pl%rh(:,npl_before+i) = frag%xb(:,i) - cb%xb(:) pl%vh(:,npl_before+i) = frag%vb(:,i) - cb%vb(:) end do if (param%lrotation) then diff --git a/src/gr/gr.f90 b/src/gr/gr.f90 index 8b32c7654..0d7fb7aaa 100644 --- a/src/gr/gr.f90 +++ b/src/gr/gr.f90 @@ -34,11 +34,11 @@ pure module subroutine gr_kick_getaccb_ns_body(self, system, param) associate(n => self%nbody, cb => system%cb, inv_c2 => param%inv_c2) if (n == 0) return do i = 1, n - rmag = norm2(self%xh(:,i)) + rmag = norm2(self%rh(:,i)) vmag2 = dot_product(self%vh(:,i), self%vh(:,i)) - rdotv = dot_product(self%xh(:,i), self%vh(:,i)) + rdotv = dot_product(self%rh(:,i), self%vh(:,i)) self%agr(:, i) = self%mu * inv_c2 / rmag**3 * ((4 * self%mu(i) / rmag - vmag2) & - * self%xh(:,i) + 4 * rdotv * self%vh(:,i)) + * self%rh(:,i) + 4 * rdotv * self%vh(:,i)) end do select type(self) @@ -113,7 +113,7 @@ pure module subroutine gr_p4_pos_kick(param, x, v, dt) end subroutine gr_p4_pos_kick - pure module subroutine gr_pseudovel2vel(param, mu, xh, pv, vh) + pure module subroutine gr_pseudovel2vel(param, mu, rh, pv, vh) !! author: David A. Minton !! !! Converts the relativistic pseudovelocity back into a veliocentric velocity @@ -128,7 +128,7 @@ pure module subroutine gr_pseudovel2vel(param, mu, xh, pv, vh) ! Arguments class(swiftest_parameters), intent(in) :: param !! Current run configuration parameters real(DP), intent(in) :: mu !! G * (Mcb + m), G = gravitational constant, Mcb = mass of central body, m = mass of body - real(DP), dimension(:), intent(in) :: xh !! Heliocentric position vector + real(DP), dimension(:), intent(in) :: rh !! Heliocentric position vector real(DP), dimension(:), intent(in) :: pv !! Pseudovelocity velocity vector - see Saha & Tremain (1994), eq. (32) real(DP), dimension(:), intent(out) :: vh !! Heliocentric velocity vector ! Internals @@ -136,7 +136,7 @@ pure module subroutine gr_pseudovel2vel(param, mu, xh, pv, vh) associate(inv_c2 => param%inv_c2) vmag2 = dot_product(pv(:), pv(:)) - rmag = norm2(xh(:)) + rmag = norm2(rh(:)) grterm = 1.0_DP - inv_c2 * (0.5_DP * vmag2 + 3 * mu / rmag) vh(:) = pv(:) * grterm end associate @@ -161,7 +161,7 @@ pure module subroutine gr_pv2vh_body(self, param) if (n == 0) return allocate(vh, mold = self%vh) do i = 1, n - call gr_pseudovel2vel(param, self%mu(i), self%xh(:, i), self%vh(:, i), vh(:, i)) + call gr_pseudovel2vel(param, self%mu(i), self%rh(:, i), self%vh(:, i), vh(:, i)) end do call move_alloc(vh, self%vh) end associate @@ -170,7 +170,7 @@ pure module subroutine gr_pv2vh_body(self, param) end subroutine gr_pv2vh_body - pure module subroutine gr_vel2pseudovel(param, mu, xh, vh, pv) + pure module subroutine gr_vel2pseudovel(param, mu, rh, vh, pv) !! author: David A. Minton !! !! Converts the heliocentric velocity into a pseudovelocity with relativistic corrections. @@ -186,7 +186,7 @@ pure module subroutine gr_vel2pseudovel(param, mu, xh, vh, pv) ! Arguments class(swiftest_parameters), intent(in) :: param !! Current run configuration parameters real(DP), intent(in) :: mu !! G * (Mcb + m), G = gravitational constant, Mcb = mass of central body, m = mass of body - real(DP), dimension(:), intent(in) :: xh !! Heliocentric position vector + real(DP), dimension(:), intent(in) :: rh !! Heliocentric position vector real(DP), dimension(:), intent(in) :: vh !! Heliocentric velocity vector real(DP), dimension(:), intent(out) :: pv !! Pseudovelocity vector - see Saha & Tremain (1994), eq. (32) ! Internals @@ -199,7 +199,7 @@ pure module subroutine gr_vel2pseudovel(param, mu, xh, vh, pv) associate(inv_c2 => param%inv_c2) pv(1:NDIM) = vh(1:NDIM) ! Initial guess - rterm = 3 * mu / norm2(xh(:)) + rterm = 3 * mu / norm2(rh(:)) v2 = dot_product(vh(:), vh(:)) do n = 1, MAXITER pv2 = dot_product(pv(:), pv(:)) @@ -263,7 +263,7 @@ pure module subroutine gr_vh2pv_body(self, param) if (n == 0) return allocate(pv, mold = self%vh) do i = 1, n - call gr_vel2pseudovel(param, self%mu(i), self%xh(:, i), self%vh(:, i), pv(:, i)) + call gr_vel2pseudovel(param, self%mu(i), self%rh(:, i), self%vh(:, i), pv(:, i)) end do call move_alloc(pv, self%vh) end associate diff --git a/src/helio/helio_drift.f90 b/src/helio/helio_drift.f90 index 1076532c0..06e98e0fa 100644 --- a/src/helio/helio_drift.f90 +++ b/src/helio/helio_drift.f90 @@ -36,7 +36,7 @@ module subroutine helio_drift_body(self, system, param, dt) iflag(:) = 0 allocate(mu(n)) mu(:) = system%cb%Gmass - call drift_all(mu, self%xh, self%vb, self%nbody, param, dt, self%lmask, iflag) + call drift_all(mu, self%rh, self%vb, self%nbody, param, dt, self%lmask, iflag) if (any(iflag(1:n) /= 0)) then where(iflag(1:n) /= 0) self%status(1:n) = DISCARDED_DRIFTERR do i = 1, n @@ -84,29 +84,29 @@ module subroutine helio_drift_tp(self, system, param, dt) end subroutine helio_drift_tp - pure elemental subroutine helio_drift_linear_one(xhx, xhy, xhz, ptx, pty, ptz, dt) + pure elemental subroutine helio_drift_linear_one(rhx, rhy, rhz, ptx, pty, ptz, dt) !! author: David A. Minton !! !! Calculate the linear drift for a single body implicit none - real(DP), intent(inout) :: xhx, xhy, xhz + real(DP), intent(inout) :: rhx, rhy, rhz real(DP), intent(in) :: ptx, pty, ptz, dt - xhx = xhx + ptx * dt - xhy = xhy + pty * dt - xhz = xhz + ptz * dt + rhx = rhx + ptx * dt + rhy = rhy + pty * dt + rhz = rhz + ptz * dt return end subroutine helio_drift_linear_one - subroutine helio_drift_linear_all(xh, pt, dt, n, lmask) + subroutine helio_drift_linear_all(rh, pt, dt, n, lmask) !! author: David A. Minton !! !! Loop through all the bodies and calculate the linear drift implicit none ! Arguments - real(DP), dimension(:,:), intent(inout) :: xh + real(DP), dimension(:,:), intent(inout) :: rh real(DP), dimension(:), intent(in) :: pt real(DP), intent(in) :: dt integer(I4B), intent(in) :: n @@ -115,7 +115,7 @@ subroutine helio_drift_linear_all(xh, pt, dt, n, lmask) integer(I4B) :: i do i = 1, n - if (lmask(i)) call helio_drift_linear_one(xh(1,i), xh(2,i), xh(3,i), pt(1), pt(2), pt(3), dt) + if (lmask(i)) call helio_drift_linear_one(rh(1,i), rh(2,i), rh(3,i), pt(1), pt(2), pt(3), dt) end do return @@ -146,7 +146,7 @@ module subroutine helio_drift_linear_pl(self, cb, dt, lbeg) pt(2) = sum(pl%Gmass(1:npl) * pl%vb(2,1:npl), self%lmask(1:npl)) pt(3) = sum(pl%Gmass(1:npl) * pl%vb(3,1:npl), self%lmask(1:npl)) pt(:) = pt(:) / cb%Gmass - call helio_drift_linear_all(pl%xh(:,:), pt(:), dt, npl, pl%lmask(:)) + call helio_drift_linear_all(pl%rh(:,:), pt(:), dt, npl, pl%lmask(:)) if (lbeg) then cb%ptbeg = pt(:) @@ -186,9 +186,9 @@ module subroutine helio_drift_linear_tp(self, cb, dt, lbeg) pt(:) = cb%ptend end if where (self%lmask(1:ntp)) - tp%xh(1, 1:ntp) = tp%xh(1, 1:ntp) + pt(1) * dt - tp%xh(2, 1:ntp) = tp%xh(2, 1:ntp) + pt(2) * dt - tp%xh(3, 1:ntp) = tp%xh(3, 1:ntp) + pt(3) * dt + tp%rh(1, 1:ntp) = tp%rh(1, 1:ntp) + pt(1) * dt + tp%rh(2, 1:ntp) = tp%rh(2, 1:ntp) + pt(2) * dt + tp%rh(3, 1:ntp) = tp%rh(3, 1:ntp) + pt(3) * dt end where end associate diff --git a/src/helio/helio_gr.f90 b/src/helio/helio_gr.f90 index 5ffbf60b2..13209ce1a 100644 --- a/src/helio/helio_gr.f90 +++ b/src/helio/helio_gr.f90 @@ -26,7 +26,7 @@ pure module subroutine helio_gr_kick_getacch_pl(self, param) if (self%nbody == 0) return associate(pl => self, npl => self%nbody) - call gr_kick_getacch(pl%mu, pl%xh, pl%lmask, npl, param%inv_c2, pl%agr) + call gr_kick_getacch(pl%mu, pl%rh, pl%lmask, npl, param%inv_c2, pl%agr) pl%ah(:,1:npl) = pl%ah(:,1:npl) + pl%agr(:,1:npl) end associate @@ -49,7 +49,7 @@ pure module subroutine helio_gr_kick_getacch_tp(self, param) if (self%nbody == 0) return associate(tp => self, ntp => self%nbody) - call gr_kick_getacch(tp%mu, tp%xh, tp%lmask, ntp, param%inv_c2, tp%agr) + call gr_kick_getacch(tp%mu, tp%rh, tp%lmask, ntp, param%inv_c2, tp%agr) tp%ah(:,1:ntp) = tp%ah(:,1:ntp) + tp%agr(:,1:ntp) end associate @@ -77,7 +77,7 @@ pure module subroutine helio_gr_p4_pl(self, system, param, dt) associate(pl => self, npl => self%nbody) do concurrent(i = 1:npl, pl%lmask(i)) - call gr_p4_pos_kick(param, pl%xh(:, i), pl%vb(:, i), dt) + call gr_p4_pos_kick(param, pl%rh(:, i), pl%vb(:, i), dt) end do end associate @@ -105,7 +105,7 @@ pure module subroutine helio_gr_p4_tp(self, system, param, dt) associate(tp => self, ntp => self%nbody) do concurrent(i = 1:ntp, tp%lmask(i)) - call gr_p4_pos_kick(param, tp%xh(:, i), tp%vb(:, i), dt) + call gr_p4_pos_kick(param, tp%rh(:, i), tp%vb(:, i), dt) end do end associate diff --git a/src/helio/helio_kick.f90 b/src/helio/helio_kick.f90 index 067a6195c..b5161b405 100644 --- a/src/helio/helio_kick.f90 +++ b/src/helio/helio_kick.f90 @@ -112,9 +112,9 @@ module subroutine helio_kick_vb_pl(self, system, param, t, dt, lbeg) pl%ah(:, 1:npl) = 0.0_DP call pl%accel(system, param, t, lbeg) if (lbeg) then - call pl%set_beg_end(xbeg = pl%xh) + call pl%set_beg_end(xbeg = pl%rh) else - call pl%set_beg_end(xend = pl%xh) + call pl%set_beg_end(xend = pl%rh) end if do concurrent(i = 1:npl, pl%lmask(i)) pl%vb(1, i) = pl%vb(1, i) + pl%ah(1, i) * dt diff --git a/src/io/io.f90 b/src/io/io.f90 index b0a752863..e0b381aec 100644 --- a/src/io/io.f90 +++ b/src/io/io.f90 @@ -1381,7 +1381,7 @@ module function io_read_frame_body(self, iu, param) result(ierr) select case(param%in_form) case ("XV") - read(iu, *, err = 667, iomsg = errmsg) self%xh(1, i), self%xh(2, i), self%xh(3, i) + read(iu, *, err = 667, iomsg = errmsg) self%rh(1, i), self%rh(2, i), self%rh(3, i) read(iu, *, err = 667, iomsg = errmsg) self%vh(1, i), self%vh(2, i), self%vh(3, i) case ("EL") read(iu, *, err = 667, iomsg = errmsg) self%a(i), self%e(i), self%inc(i) diff --git a/src/kick/kick.f90 b/src/kick/kick.f90 index dd0682bf0..40b238fec 100644 --- a/src/kick/kick.f90 +++ b/src/kick/kick.f90 @@ -43,15 +43,15 @@ module subroutine kick_getacch_int_pl(self, param) if (param%lflatten_interactions) then if (param%lclose) then - call kick_getacch_int_all_flat_pl(self%nbody, self%nplpl, self%k_plpl, self%xh, self%Gmass, self%radius, self%ah) + call kick_getacch_int_all_flat_pl(self%nbody, self%nplpl, self%k_plpl, self%rh, self%Gmass, self%radius, self%ah) else - call kick_getacch_int_all_flat_pl(self%nbody, self%nplpl, self%k_plpl, self%xh, self%Gmass, acc=self%ah) + call kick_getacch_int_all_flat_pl(self%nbody, self%nplpl, self%k_plpl, self%rh, self%Gmass, acc=self%ah) end if else if (param%lclose) then - call kick_getacch_int_all_triangular_pl(self%nbody, self%nbody, self%xh, self%Gmass, self%radius, self%ah) + call kick_getacch_int_all_triangular_pl(self%nbody, self%nbody, self%rh, self%Gmass, self%radius, self%ah) else - call kick_getacch_int_all_triangular_pl(self%nbody, self%nbody, self%xh, self%Gmass, acc=self%ah) + call kick_getacch_int_all_triangular_pl(self%nbody, self%nbody, self%rh, self%Gmass, acc=self%ah) end if end if @@ -80,7 +80,7 @@ module subroutine kick_getacch_int_tp(self, param, GMpl, xhp, npl) if ((self%nbody == 0) .or. (npl == 0)) return - call kick_getacch_int_all_tp(self%nbody, npl, self%xh, xhp, GMpl, self%lmask, self%ah) + call kick_getacch_int_all_tp(self%nbody, npl, self%rh, xhp, GMpl, self%lmask, self%ah) return end subroutine kick_getacch_int_tp diff --git a/src/modules/swiftest_classes.f90 b/src/modules/swiftest_classes.f90 index 302d09eea..73ad063e6 100644 --- a/src/modules/swiftest_classes.f90 +++ b/src/modules/swiftest_classes.f90 @@ -244,11 +244,11 @@ module swiftest_classes character(len=NAMELEN) :: origin_type !! String containing a description of the origin of the particle (e.g. Initial Conditions, Supercatastrophic, Disruption, etc.) real(DP) :: origin_time !! The time of the particle's formation integer(I4B) :: collision_id !! The ID of the collision that formed the particle - real(DP), dimension(NDIM) :: origin_xh !! The heliocentric distance vector at the time of the particle's formation + real(DP), dimension(NDIM) :: origin_rh !! The heliocentric distance vector at the time of the particle's formation real(DP), dimension(NDIM) :: origin_vh !! The heliocentric velocity vector at the time of the particle's formation real(DP) :: discard_time !! The time of the particle's discard character(len=NAMELEN) :: status !! Particle status description: Active, Merged, Fragmented, etc. - real(DP), dimension(NDIM) :: discard_xh !! The heliocentric distance vector at the time of the particle's discard + real(DP), dimension(NDIM) :: discard_rh !! The heliocentric distance vector at the time of the particle's discard real(DP), dimension(NDIM) :: discard_vh !! The heliocentric velocity vector at the time of the particle's discard integer(I4B) :: discard_body_id !! The id of the other body involved in the discard (0 if no other body involved) contains @@ -314,7 +314,7 @@ module swiftest_classes logical, dimension(:), allocatable :: ldiscard !! Body should be discarded logical, dimension(:), allocatable :: lmask !! Logical mask used to select a subset of bodies when performing certain operations (drift, kick, accel, etc.) real(DP), dimension(:), allocatable :: mu !! G * (Mcb + [m]) - real(DP), dimension(:,:), allocatable :: xh !! Swiftestcentric position + real(DP), dimension(:,:), allocatable :: rh !! Swiftestcentric position real(DP), dimension(:,:), allocatable :: vh !! Swiftestcentric velocity real(DP), dimension(:,:), allocatable :: xb !! Barycentric position real(DP), dimension(:,:), allocatable :: vb !! Barycentric velocity @@ -396,7 +396,7 @@ module swiftest_classes procedure :: b2h => util_coord_b2h_pl !! Convert massive bodies from barycentric to heliocentric coordinates (position and velocity) procedure :: vh2vb => util_coord_vh2vb_pl !! Convert massive bodies from heliocentric to barycentric coordinates (velocity only) procedure :: vb2vh => util_coord_vb2vh_pl !! Convert massive bodies from barycentric to heliocentric coordinates (velocity only) - procedure :: xh2xb => util_coord_xh2xb_pl !! Convert massive bodies from heliocentric to barycentric coordinates (position only) + procedure :: xh2xb => util_coord_rh2xb_pl !! Convert massive bodies from heliocentric to barycentric coordinates (position only) procedure :: dealloc => util_dealloc_pl !! Deallocates all allocatable arrays procedure :: fill => util_fill_pl !! "Fills" bodies from one object into another depending on the results of a mask (uses the UNPACK intrinsic) procedure :: resize => util_resize_pl !! Checks the current size of a Swiftest body against the requested size and resizes it if it is too small. @@ -436,7 +436,7 @@ module swiftest_classes procedure :: b2h => util_coord_b2h_tp !! Convert test particles from barycentric to heliocentric coordinates (position and velocity) procedure :: vb2vh => util_coord_vb2vh_tp !! Convert test particles from barycentric to heliocentric coordinates (velocity only) procedure :: vh2vb => util_coord_vh2vb_tp !! Convert test particles from heliocentric to barycentric coordinates (velocity only) - procedure :: xh2xb => util_coord_xh2xb_tp !! Convert test particles from heliocentric to barycentric coordinates (position only) + procedure :: xh2xb => util_coord_rh2xb_tp !! Convert test particles from heliocentric to barycentric coordinates (position only) procedure :: dealloc => util_dealloc_tp !! Deallocates all allocatable arrays procedure :: fill => util_fill_tp !! "Fills" bodies from one object into another depending on the results of a mask (uses the UNPACK intrinsic) procedure :: get_peri => util_peri_tp !! Determine system pericenter passages for test particles @@ -688,11 +688,11 @@ pure module subroutine gr_p4_pos_kick(param, x, v, dt) real(DP), intent(in) :: dt !! Step size end subroutine gr_p4_pos_kick - pure module subroutine gr_pseudovel2vel(param, mu, xh, pv, vh) + pure module subroutine gr_pseudovel2vel(param, mu, rh, pv, vh) implicit none class(swiftest_parameters), intent(in) :: param !! Current run configuration parameters real(DP), intent(in) :: mu !! G * (Mcb + m), G = gravitational constant, Mcb = mass of central body, m = mass of body - real(DP), dimension(:), intent(in) :: xh !! Swiftestcentric position vector + real(DP), dimension(:), intent(in) :: rh !! Swiftestcentric position vector real(DP), dimension(:), intent(in) :: pv !! Pseudovelocity velocity vector - see Saha & Tremain (1994), eq. (32) real(DP), dimension(:), intent(out) :: vh !! Swiftestcentric velocity vector end subroutine gr_pseudovel2vel @@ -703,11 +703,11 @@ pure module subroutine gr_pv2vh_body(self, param) class(swiftest_parameters), intent(in) :: param !! Current run configuration parameters end subroutine gr_pv2vh_body - pure module subroutine gr_vel2pseudovel(param, mu, xh, vh, pv) + pure module subroutine gr_vel2pseudovel(param, mu, rh, vh, pv) implicit none class(swiftest_parameters), intent(in) :: param !! Current run configuration parameters real(DP), intent(in) :: mu !! G * (Mcb + m), G = gravitational constant, Mcb = mass of central body, m = mass of body - real(DP), dimension(:), intent(in) :: xh !! Swiftestcentric position vector + real(DP), dimension(:), intent(in) :: rh !! Swiftestcentric position vector real(DP), dimension(:), intent(in) :: vh !! Swiftestcentric velocity vector real(DP), dimension(:), intent(out) :: pv !! Pseudovelocity vector - see Saha & Tremain (1994), eq. (32) end subroutine gr_vel2pseudovel @@ -1336,17 +1336,17 @@ module subroutine util_coord_vh2vb_tp(self, vbcb) real(DP), dimension(:), intent(in) :: vbcb !! Barycentric velocity of the central body end subroutine util_coord_vh2vb_tp - module subroutine util_coord_xh2xb_pl(self, cb) + module subroutine util_coord_rh2xb_pl(self, cb) implicit none class(swiftest_pl), intent(inout) :: self !! Swiftest massive body object class(swiftest_cb), intent(inout) :: cb !! Swiftest central body object - end subroutine util_coord_xh2xb_pl + end subroutine util_coord_rh2xb_pl - module subroutine util_coord_xh2xb_tp(self, cb) + module subroutine util_coord_rh2xb_tp(self, cb) implicit none class(swiftest_tp), intent(inout) :: self !! Swiftest test particle object class(swiftest_cb), intent(in) :: cb !! Swiftest central body object - end subroutine util_coord_xh2xb_tp + end subroutine util_coord_rh2xb_tp module subroutine util_copy_particle_info(self, source) implicit none @@ -1618,7 +1618,7 @@ module subroutine util_set_mu_tp(self, cb) end subroutine util_set_mu_tp module subroutine util_set_particle_info(self, name, particle_type, status, origin_type, origin_time, collision_id, & - origin_xh, origin_vh, discard_time, discard_xh, discard_vh, discard_body_id) + origin_rh, origin_vh, discard_time, discard_rh, discard_vh, discard_body_id) implicit none class(swiftest_particle_info), intent(inout) :: self character(len=*), intent(in), optional :: name !! Non-unique name @@ -1627,10 +1627,10 @@ module subroutine util_set_particle_info(self, name, particle_type, status, orig character(len=*), intent(in), optional :: origin_type !! String containing a description of the origin of the particle (e.g. Initial Conditions, Supercatastrophic, Disruption, etc.) real(DP), intent(in), optional :: origin_time !! The time of the particle's formation integer(I4B), intent(in), optional :: collision_id !! The ID fo the collision that formed the particle - real(DP), dimension(:), intent(in), optional :: origin_xh !! The heliocentric distance vector at the time of the particle's formation + real(DP), dimension(:), intent(in), optional :: origin_rh !! The heliocentric distance vector at the time of the particle's formation real(DP), dimension(:), intent(in), optional :: origin_vh !! The heliocentric velocity vector at the time of the particle's formation real(DP), intent(in), optional :: discard_time !! The time of the particle's discard - real(DP), dimension(:), intent(in), optional :: discard_xh !! The heliocentric distance vector at the time of the particle's discard + real(DP), dimension(:), intent(in), optional :: discard_rh !! The heliocentric distance vector at the time of the particle's discard real(DP), dimension(:), intent(in), optional :: discard_vh !! The heliocentric velocity vector at the time of the particle's discard integer(I4B), intent(in), optional :: discard_body_id !! The id of the other body involved in the discard (0 if no other body involved) end subroutine util_set_particle_info diff --git a/src/netcdf/netcdf.f90 b/src/netcdf/netcdf.f90 index 818fa3302..fd3bf2ec5 100644 --- a/src/netcdf/netcdf.f90 +++ b/src/netcdf/netcdf.f90 @@ -76,51 +76,37 @@ module function netcdf_get_old_t_final_system(self, param) result(old_t_final) ! Internals integer(I4B) :: itmax, idmax real(DP), dimension(:), allocatable :: vals - real(DP), dimension(1) :: val - real(DP), dimension(NDIM) :: rot0, Ip0, Lnow + real(DP), dimension(1) :: rtemp + real(DP), dimension(NDIM) :: vectemp, rot0, Ip0, Lnow real(DP) :: KE_orb_orig, KE_spin_orig, PE_orig call param%nciu%open(param) call check( nf90_inquire_dimension(param%nciu%id, param%nciu%time_dimid, len=itmax), "netcdf_get_old_t_final_system time_dimid" ) call check( nf90_inquire_dimension(param%nciu%id, param%nciu%id_dimid, len=idmax), "netcdf_get_old_t_final_system id_dimid" ) allocate(vals(idmax)) - call check( nf90_get_var(param%nciu%id, param%nciu%time_varid, val, start=[1], count=[1]), "netcdf_get_old_t_final_system time_varid" ) + call check( nf90_get_var(param%nciu%id, param%nciu%time_varid, rtemp, start=[1], count=[1]), "netcdf_get_old_t_final_system time_varid" ) - !old_t_final = val(1) + !old_t_final = rtemp(1) old_t_final = param%t0 ! For NetCDF it is safe to overwrite the final t value on a restart if (param%lenergy) then - call check( nf90_get_var(param%nciu%id, param%nciu%KE_orb_varid, val, start=[1], count=[1]), "netcdf_get_old_t_final_system KE_orb_varid" ) - KE_orb_orig = val(1) + call check( nf90_get_var(param%nciu%id, param%nciu%KE_orb_varid, rtemp, start=[1], count=[1]), "netcdf_get_old_t_final_system KE_orb_varid" ) + KE_orb_orig = rtemp(1) - call check( nf90_get_var(param%nciu%id, param%nciu%KE_spin_varid, val, start=[1], count=[1]), "netcdf_get_old_t_final_system KE_spin_varid" ) - KE_spin_orig = val(1) + call check( nf90_get_var(param%nciu%id, param%nciu%KE_spin_varid, rtemp, start=[1], count=[1]), "netcdf_get_old_t_final_system KE_spin_varid" ) + KE_spin_orig = rtemp(1) - call check( nf90_get_var(param%nciu%id, param%nciu%PE_varid, val, start=[1], count=[1]), "netcdf_get_old_t_final_system PE_varid" ) - PE_orig = val(1) + call check( nf90_get_var(param%nciu%id, param%nciu%PE_varid, rtemp, start=[1], count=[1]), "netcdf_get_old_t_final_system PE_varid" ) + PE_orig = rtemp(1) call check( nf90_get_var(param%nciu%id, param%nciu%Ecollisions_varid, self%Ecollisions, start=[1]), "netcdf_get_old_t_final_system Ecollisions_varid" ) call check( nf90_get_var(param%nciu%id, param%nciu%Euntracked_varid, self%Euntracked, start=[1]), "netcdf_get_old_t_final_system Euntracked_varid" ) self%Eorbit_orig = KE_orb_orig + KE_spin_orig + PE_orig + self%Ecollisions + self%Euntracked - call check( nf90_get_var(param%nciu%id, param%nciu%L_orbx_varid, val, start=[1], count=[1]), "netcdf_get_old_t_final_system L_orbx_varid" ) - self%Lorbit_orig(1) = val(1) - call check( nf90_get_var(param%nciu%id, param%nciu%L_orby_varid, val, start=[1], count=[1]), "netcdf_get_old_t_final_system L_orby_varid" ) - self%Lorbit_orig(2) = val(1) - call check( nf90_get_var(param%nciu%id, param%nciu%L_orbz_varid, val, start=[1], count=[1]), "netcdf_get_old_t_final_system L_orbz_varid" ) - self%Lorbit_orig(3) = val(1) - - call check( nf90_get_var(param%nciu%id, param%nciu%L_spinx_varid, val, start=[1], count=[1]), "netcdf_get_old_t_final_system L_spinx_varid" ) - self%Lspin_orig(1) = val(1) - call check( nf90_get_var(param%nciu%id, param%nciu%L_spiny_varid, val, start=[1], count=[1]), "netcdf_get_old_t_final_system L_spiny_varid" ) - self%Lspin_orig(2) = val(1) - call check( nf90_get_var(param%nciu%id, param%nciu%L_spinz_varid, val, start=[1], count=[1]), "netcdf_get_old_t_final_system L_spinz_varid" ) - self%Lspin_orig(3) = val(1) - - call check( nf90_get_var(param%nciu%id, param%nciu%L_escapex_varid, self%Lescape(1), start=[1]), "netcdf_get_old_t_final_system L_escapex_varid" ) - call check( nf90_get_var(param%nciu%id, param%nciu%L_escapey_varid, self%Lescape(2), start=[1]), "netcdf_get_old_t_final_system L_escapey_varid" ) - call check( nf90_get_var(param%nciu%id, param%nciu%L_escapez_varid, self%Lescape(3), start=[1]), "netcdf_get_old_t_final_system L_escapez_varid" ) + call check( nf90_get_var(param%nciu%id, param%nciu%L_orb_varid, self%Lorbit_orig(:), start=[1,1], count=[NDIM,1]), "netcdf_get_old_t_final_system L_orb_varid" ) + call check( nf90_get_var(param%nciu%id, param%nciu%L_spin_varid, self%Lspin_orig(:), start=[1,1], count=[NDIM,1]), "netcdf_get_old_t_final_system L_spin_varid" ) + call check( nf90_get_var(param%nciu%id, param%nciu%L_escape_varid, self%Lescape(:), start=[1,1], count=[NDIM,1]), "netcdf_get_old_t_final_system L_escape_varid" ) self%Ltot_orig(:) = self%Lorbit_orig(:) + self%Lspin_orig(:) + self%Lescape(:) @@ -133,24 +119,13 @@ module function netcdf_get_old_t_final_system(self, param) result(old_t_final) cb%GM0 = vals(1) cb%dGM = cb%Gmass - cb%GM0 - call check( nf90_get_var(param%nciu%id, param%nciu%radius_varid, val, start=[1,1], count=[1,1]), "netcdf_get_old_t_final_system radius_varid" ) - cb%R0 = val(1) + call check( nf90_get_var(param%nciu%id, param%nciu%radius_varid, rtemp, start=[1,1], count=[1,1]), "netcdf_get_old_t_final_system radius_varid" ) + cb%R0 = rtemp(1) if (param%lrotation) then - call check( nf90_get_var(param%nciu%id, param%nciu%rotx_varid, val, start=[1,1], count=[1,1]), "netcdf_get_old_t_final_system rotx_varid" ) - rot0(1) = val(1) - call check( nf90_get_var(param%nciu%id, param%nciu%roty_varid, val, start=[1,1], count=[1,1]), "netcdf_get_old_t_final_system roty_varid" ) - rot0(2) = val(1) - call check( nf90_get_var(param%nciu%id, param%nciu%rotz_varid, val, start=[1,1], count=[1,1]), "netcdf_get_old_t_final_system rotz_varid" ) - rot0(3) = val(1) - - call check( nf90_get_var(param%nciu%id, param%nciu%Ip1_varid, val, start=[1,1], count=[1,1]), "netcdf_get_old_t_final_system Ip1_varid" ) - Ip0(1) = val(1) - call check( nf90_get_var(param%nciu%id, param%nciu%Ip2_varid, val, start=[1,1], count=[1,1]), "netcdf_get_old_t_final_system Ip2_varid" ) - Ip0(2) = val(1) - call check( nf90_get_var(param%nciu%id, param%nciu%Ip3_varid, val, start=[1,1], count=[1,1]), "netcdf_get_old_t_final_system Ip3_varid" ) - Ip0(3) = val(1) + call check( nf90_get_var(param%nciu%id, param%nciu%rot_varid, rot0, start=[1,1,1], count=[NDIM,1,1]), "netcdf_get_old_t_final_system rot_varid" ) + call check( nf90_get_var(param%nciu%id, param%nciu%Ip_varid, Ip0, start=[1,1,1], count=[NDIM,1,1]), "netcdf_get_old_t_final_system Ip_varid" ) cb%L0(:) = Ip0(3) * cb%GM0 * cb%R0**2 * rot0(:) @@ -208,7 +183,7 @@ module subroutine netcdf_initialize_output(self, param) ! Dimensions call check( nf90_def_dim(nciu%id, nciu%time_dimname, NF90_UNLIMITED, nciu%time_dimid), "netcdf_initialize_output nf90_def_dim time_dimid" ) ! Simulation time dimension - call check( nf90_def_dim(nciu%id, nciu%space_dimname, 3, nciu%space_dimid), "netcdf_initialize_output nf90_def_dim space_dimid" ) ! 3D space dimension + call check( nf90_def_dim(nciu%id, nciu%space_dimname, NDIM, nciu%space_dimid), "netcdf_initialize_output nf90_def_dim space_dimid" ) ! 3D space dimension call check( nf90_def_dim(nciu%id, nciu%id_dimname, NF90_UNLIMITED, nciu%id_dimid), "netcdf_initialize_output nf90_def_dim id_dimid" ) ! dimension to store particle id numbers call check( nf90_def_dim(nciu%id, nciu%str_dimname, NAMELEN, nciu%str_dimid), "netcdf_initialize_output nf90_def_dim str_dimid" ) ! Dimension for string variables (aka character arrays) @@ -228,19 +203,11 @@ module subroutine netcdf_initialize_output(self, param) if ((param%out_form == "XV") .or. (param%out_form == "XVEL")) then call check( nf90_def_var(nciu%id, nciu%rh_varname, nciu%out_type, [nciu%space_dimid, nciu%id_dimid, nciu%time_dimid], nciu%rh_varid), "netcdf_initialize_output nf90_def_var rh_varid" ) call check( nf90_def_var(nciu%id, nciu%vh_varname, nciu%out_type, [nciu%space_dimid, nciu%id_dimid, nciu%time_dimid], nciu%vh_varid), "netcdf_initialize_output nf90_def_var vh_varid" ) - call check( nf90_def_var(nciu%id, nciu%xhx_varname, nciu%out_type, [nciu%id_dimid, nciu%time_dimid], nciu%xhx_varid), "netcdf_initialize_output nf90_def_var xhx_varid" ) - call check( nf90_def_var(nciu%id, nciu%xhy_varname, nciu%out_type, [nciu%id_dimid, nciu%time_dimid], nciu%xhy_varid), "netcdf_initialize_output nf90_def_var xhy_varid" ) - call check( nf90_def_var(nciu%id, nciu%xhz_varname, nciu%out_type, [nciu%id_dimid, nciu%time_dimid], nciu%xhz_varid), "netcdf_initialize_output nf90_def_var xhz_varid" ) - call check( nf90_def_var(nciu%id, nciu%vhx_varname, nciu%out_type, [nciu%id_dimid, nciu%time_dimid], nciu%vhx_varid), "netcdf_initialize_output nf90_def_var vhx_varid" ) - call check( nf90_def_var(nciu%id, nciu%vhy_varname, nciu%out_type, [nciu%id_dimid, nciu%time_dimid], nciu%vhy_varid), "netcdf_initialize_output nf90_def_var vhy_varid" ) - call check( nf90_def_var(nciu%id, nciu%vhz_varname, nciu%out_type, [nciu%id_dimid, nciu%time_dimid], nciu%vhz_varid), "netcdf_initialize_output nf90_def_var vhz_varid" ) !! When GR is enabled, we need to save the pseudovelocity vectors in addition to the true heliocentric velocity vectors, otherwise !! we cannnot expect bit-identical runs from restarted runs with GR enabled due to floating point errors during the conversion. if (param%lgr) then - call check( nf90_def_var(nciu%id, nciu%gr_pseudo_vhx_varname, nciu%out_type, [nciu%id_dimid, nciu%time_dimid], nciu%gr_pseudo_vhx_varid), "netcdf_initialize_output nf90_def_var gr_psuedo_vhx_varid" ) - call check( nf90_def_var(nciu%id, nciu%gr_pseudo_vhy_varname, nciu%out_type, [nciu%id_dimid, nciu%time_dimid], nciu%gr_pseudo_vhy_varid), "netcdf_initialize_output nf90_def_var gr_psuedo_vhy_varid" ) - call check( nf90_def_var(nciu%id, nciu%gr_pseudo_vhz_varname, nciu%out_type, [nciu%id_dimid, nciu%time_dimid], nciu%gr_pseudo_vhz_varid), "netcdf_initialize_output nf90_def_var gr_psuedo_vhz_varid" ) + call check( nf90_def_var(nciu%id, nciu%gr_pseudo_vh_varname, nciu%out_type, [nciu%space_dimid, nciu%id_dimid, nciu%time_dimid], nciu%gr_pseudo_vh_varid), "netcdf_initialize_output nf90_def_var gr_psuedo_vh_varid" ) nciu%lpseudo_vel_exists = .true. end if @@ -267,31 +234,19 @@ module subroutine netcdf_initialize_output(self, param) call check( nf90_def_var(nciu%id, nciu%origin_time_varname, nciu%out_type, nciu%id_dimid, nciu%origin_time_varid), "netcdf_initialize_output nf90_def_var origin_time_varid" ) call check( nf90_def_var(nciu%id, nciu%origin_type_varname, NF90_CHAR, [nciu%str_dimid, nciu%id_dimid], & nciu%origin_type_varid), "netcdf_initialize_output nf90_create" ) - call check( nf90_def_var(nciu%id, nciu%origin_xhx_varname, nciu%out_type, nciu%id_dimid, nciu%origin_xhx_varid), "netcdf_initialize_output nf90_def_var origin_xhx_varid" ) - call check( nf90_def_var(nciu%id, nciu%origin_xhy_varname, nciu%out_type, nciu%id_dimid, nciu%origin_xhy_varid), "netcdf_initialize_output nf90_def_var origin_xhy_varid" ) - call check( nf90_def_var(nciu%id, nciu%origin_xhz_varname, nciu%out_type, nciu%id_dimid, nciu%origin_xhz_varid), "netcdf_initialize_output nf90_def_var origin_xhz_varid" ) - call check( nf90_def_var(nciu%id, nciu%origin_vhx_varname, nciu%out_type, nciu%id_dimid, nciu%origin_vhx_varid), "netcdf_initialize_output nf90_def_var origin_vhx_varid" ) - call check( nf90_def_var(nciu%id, nciu%origin_vhy_varname, nciu%out_type, nciu%id_dimid, nciu%origin_vhy_varid), "netcdf_initialize_output nf90_def_var origin_vhy_varid" ) - call check( nf90_def_var(nciu%id, nciu%origin_vhz_varname, nciu%out_type, nciu%id_dimid, nciu%origin_vhz_varid), "netcdf_initialize_output nf90_def_var origin_vhz_varid" ) + call check( nf90_def_var(nciu%id, nciu%origin_rh_varname, nciu%out_type, [nciu%space_dimid, nciu%id_dimid], nciu%origin_rh_varid), "netcdf_initialize_output nf90_def_var origin_rh_varid" ) + call check( nf90_def_var(nciu%id, nciu%origin_vh_varname, nciu%out_type, [nciu%space_dimid, nciu%id_dimid], nciu%origin_vh_varid), "netcdf_initialize_output nf90_def_var origin_vh_varid" ) call check( nf90_def_var(nciu%id, nciu%collision_id_varname, NF90_INT, nciu%id_dimid, nciu%collision_id_varid), "netcdf_initialize_output nf90_def_var collision_id_varid" ) call check( nf90_def_var(nciu%id, nciu%discard_time_varname, nciu%out_type, nciu%id_dimid, nciu%discard_time_varid), "netcdf_initialize_output nf90_def_var discard_time_varid" ) - call check( nf90_def_var(nciu%id, nciu%discard_xhx_varname, nciu%out_type, nciu%id_dimid, nciu%discard_xhx_varid), "netcdf_initialize_output nf90_def_var discard_xhx_varid" ) - call check( nf90_def_var(nciu%id, nciu%discard_xhy_varname, nciu%out_type, nciu%id_dimid, nciu%discard_xhy_varid), "netcdf_initialize_output nf90_def_var discard_xhy_varid" ) - call check( nf90_def_var(nciu%id, nciu%discard_xhz_varname, nciu%out_type, nciu%id_dimid, nciu%discard_xhz_varid), "netcdf_initialize_output nf90_def_var discard_xhz_varid" ) - call check( nf90_def_var(nciu%id, nciu%discard_vhx_varname, nciu%out_type, nciu%id_dimid, nciu%discard_vhx_varid), "netcdf_initialize_output nf90_def_var discard_vhx_varid" ) - call check( nf90_def_var(nciu%id, nciu%discard_vhy_varname, nciu%out_type, nciu%id_dimid, nciu%discard_vhy_varid), "netcdf_initialize_output nf90_def_var discard_vhy_varid" ) - call check( nf90_def_var(nciu%id, nciu%discard_vhz_varname, nciu%out_type, nciu%id_dimid, nciu%discard_vhz_varid), "netcdf_initialize_output nf90_def_var discard_vhz_varid" ) + call check( nf90_def_var(nciu%id, nciu%discard_rh_varname, nciu%out_type, [nciu%space_dimid, nciu%id_dimid], nciu%discard_rh_varid), "netcdf_initialize_output nf90_def_var discard_rh_varid" ) + call check( nf90_def_var(nciu%id, nciu%discard_vh_varname, nciu%out_type, [nciu%space_dimid, nciu%id_dimid], nciu%discard_vh_varid), "netcdf_initialize_output nf90_def_var discard_vh_varid" ) call check( nf90_def_var(nciu%id, nciu%discard_body_id_varname, NF90_INT, nciu%id_dimid, nciu%discard_body_id_varid), "netcdf_initialize_output nf90_def_var discard_body_id_varid" ) end if if (param%lrotation) then - call check( nf90_def_var(nciu%id, nciu%ip1_varname, nciu%out_type, [nciu%id_dimid, nciu%time_dimid], nciu%Ip1_varid), "netcdf_initialize_output nf90_def_var Ip1_varid" ) - call check( nf90_def_var(nciu%id, nciu%ip2_varname, nciu%out_type, [nciu%id_dimid, nciu%time_dimid], nciu%Ip2_varid), "netcdf_initialize_output nf90_def_var Ip2_varid" ) - call check( nf90_def_var(nciu%id, nciu%ip3_varname, nciu%out_type, [nciu%id_dimid, nciu%time_dimid], nciu%Ip3_varid), "netcdf_initialize_output nf90_def_var Ip3_varid" ) - call check( nf90_def_var(nciu%id, nciu%rotx_varname, nciu%out_type, [nciu%id_dimid, nciu%time_dimid], nciu%rotx_varid), "netcdf_initialize_output nf90_def_var rotx_varid" ) - call check( nf90_def_var(nciu%id, nciu%roty_varname, nciu%out_type, [nciu%id_dimid, nciu%time_dimid], nciu%roty_varid), "netcdf_initialize_output nf90_def_var roty_varid" ) - call check( nf90_def_var(nciu%id, nciu%rotz_varname, nciu%out_type, [nciu%id_dimid, nciu%time_dimid], nciu%rotz_varid), "netcdf_initialize_output nf90_def_var rotz_varid" ) + call check( nf90_def_var(nciu%id, nciu%Ip_varname, nciu%out_type, [nciu%space_dimid, nciu%id_dimid, nciu%time_dimid], nciu%Ip_varid), "netcdf_initialize_output nf90_def_var Ip_varid" ) + call check( nf90_def_var(nciu%id, nciu%rot_varname, nciu%out_type, [nciu%space_dimid, nciu%id_dimid, nciu%time_dimid], nciu%rot_varid), "netcdf_initialize_output nf90_def_var rot_varid" ) end if ! if (param%ltides) then @@ -303,18 +258,12 @@ module subroutine netcdf_initialize_output(self, param) call check( nf90_def_var(nciu%id, nciu%ke_orb_varname, nciu%out_type, nciu%time_dimid, nciu%KE_orb_varid), "netcdf_initialize_output nf90_def_var KE_orb_varid" ) call check( nf90_def_var(nciu%id, nciu%ke_spin_varname, nciu%out_type, nciu%time_dimid, nciu%KE_spin_varid), "netcdf_initialize_output nf90_def_var KE_spin_varid" ) call check( nf90_def_var(nciu%id, nciu%pe_varname, nciu%out_type, nciu%time_dimid, nciu%PE_varid), "netcdf_initialize_output nf90_def_var PE_varid" ) - call check( nf90_def_var(nciu%id, nciu%l_orbx_varname, nciu%out_type, nciu%time_dimid, nciu%L_orbx_varid), "netcdf_initialize_output nf90_def_var L_orbx_varid" ) - call check( nf90_def_var(nciu%id, nciu%l_orby_varname, nciu%out_type, nciu%time_dimid, nciu%L_orby_varid), "netcdf_initialize_output nf90_def_var L_orby_varid" ) - call check( nf90_def_var(nciu%id, nciu%l_orbz_varname, nciu%out_type, nciu%time_dimid, nciu%L_orbz_varid), "netcdf_initialize_output nf90_def_var L_orbz_varid" ) - call check( nf90_def_var(nciu%id, nciu%l_spinx_varname, nciu%out_type, nciu%time_dimid, nciu%L_spinx_varid), "netcdf_initialize_output nf90_def_var L_spinx_varid" ) - call check( nf90_def_var(nciu%id, nciu%l_spiny_varname, nciu%out_type, nciu%time_dimid, nciu%L_spiny_varid), "netcdf_initialize_output nf90_def_var L_spiny_varid" ) - call check( nf90_def_var(nciu%id, nciu%l_spinz_varname, nciu%out_type, nciu%time_dimid, nciu%L_spinz_varid), "netcdf_initialize_output nf90_def_var L_spinz_varid" ) - call check( nf90_def_var(nciu%id, nciu%l_escapex_varname, nciu%out_type, nciu%time_dimid, nciu%L_escapex_varid), "netcdf_initialize_output nf90_def_var L_escapex_varid" ) - call check( nf90_def_var(nciu%id, nciu%l_escapey_varname, nciu%out_type, nciu%time_dimid, nciu%L_escapey_varid), "netcdf_initialize_output nf90_def_var L_escapey_varid" ) - call check( nf90_def_var(nciu%id, nciu%l_escapez_varname, nciu%out_type, nciu%time_dimid, nciu%L_escapez_varid), "netcdf_initialize_output nf90_def_var L_escapez_varid" ) - call check( nf90_def_var(nciu%id, nciu%ecollisions_varname, nciu%out_type, nciu%time_dimid, nciu%Ecollisions_varid), "netcdf_initialize_output nf90_def_var Ecollisions_varid" ) - call check( nf90_def_var(nciu%id, nciu%euntracked_varname, nciu%out_type, nciu%time_dimid, nciu%Euntracked_varid), "netcdf_initialize_output nf90_def_var Euntracked_varid" ) - call check( nf90_def_var(nciu%id, nciu%gmescape_varname, nciu%out_type, nciu%time_dimid, nciu%GMescape_varid), "netcdf_initialize_output nf90_def_var GMescape_varid" ) + call check( nf90_def_var(nciu%id, nciu%L_orb_varname, nciu%out_type, [nciu%space_dimid, nciu%time_dimid], nciu%L_orb_varid), "netcdf_initialize_output nf90_def_var L_orb_varid" ) + call check( nf90_def_var(nciu%id, nciu%L_spin_varname, nciu%out_type, [nciu%space_dimid, nciu%time_dimid], nciu%L_spin_varid), "netcdf_initialize_output nf90_def_var L_spin_varid" ) + call check( nf90_def_var(nciu%id, nciu%L_escape_varname, nciu%out_type, [nciu%space_dimid, nciu%time_dimid], nciu%L_escape_varid), "netcdf_initialize_output nf90_def_var L_escape_varid" ) + call check( nf90_def_var(nciu%id, nciu%Ecollisions_varname, nciu%out_type, nciu%time_dimid, nciu%Ecollisions_varid), "netcdf_initialize_output nf90_def_var Ecollisions_varid" ) + call check( nf90_def_var(nciu%id, nciu%Euntracked_varname, nciu%out_type, nciu%time_dimid, nciu%Euntracked_varid), "netcdf_initialize_output nf90_def_var Euntracked_varid" ) + call check( nf90_def_var(nciu%id, nciu%GMescape_varname, nciu%out_type, nciu%time_dimid, nciu%GMescape_varid), "netcdf_initialize_output nf90_def_var GMescape_varid" ) end if call check( nf90_def_var(nciu%id, nciu%j2rp2_varname, nciu%out_type, nciu%time_dimid, nciu%j2rp2_varid), "netcdf_initialize_output nf90_def_var j2rp2_varid" ) @@ -340,7 +289,7 @@ module subroutine netcdf_initialize_output(self, param) ! Take the file out of define mode call check( nf90_enddef(nciu%id), "netcdf_initialize_output nf90_enddef" ) - call check( nf90_put_var(nciu%id, nciu%space_varid, nciu%space_coords, start=[1], count=[3]), "netcdf_initialize_output nf90_put_var space" ) + call check( nf90_put_var(nciu%id, nciu%space_varid, nciu%space_coords, start=[1], count=[NDIM]), "netcdf_initialize_output nf90_put_var space" ) end associate return @@ -391,27 +340,13 @@ module subroutine netcdf_open(self, param, readonly) call check( nf90_inq_varid(nciu%id, nciu%gmass_varname, nciu%Gmass_varid), "netcdf_open nf90_inq_varid Gmass_varid" ) if ((param%out_form == "XV") .or. (param%out_form == "XVEL")) then - status = nf90_inq_varid(nciu%id, nciu%rh_varname, nciu%rh_varid) - status = nf90_inq_varid(nciu%id, nciu%vh_varname, nciu%vh_varid) - call check( nf90_inq_varid(nciu%id, nciu%xhx_varname, nciu%xhx_varid), "netcdf_open nf90_inq_varid xhx_varid" ) - call check( nf90_inq_varid(nciu%id, nciu%xhy_varname, nciu%xhy_varid), "netcdf_open nf90_inq_varid xhy_varid" ) - call check( nf90_inq_varid(nciu%id, nciu%xhz_varname, nciu%xhz_varid), "netcdf_open nf90_inq_varid xhz_varid" ) - call check( nf90_inq_varid(nciu%id, nciu%vhx_varname, nciu%vhx_varid), "netcdf_open nf90_inq_varid vhx_varid" ) - call check( nf90_inq_varid(nciu%id, nciu%vhy_varname, nciu%vhy_varid), "netcdf_open nf90_inq_varid vhy_varid" ) - call check( nf90_inq_varid(nciu%id, nciu%vhz_varname, nciu%vhz_varid), "netcdf_open nf90_inq_varid vhz_varid" ) + call check( nf90_inq_varid(nciu%id, nciu%rh_varname, nciu%rh_varid), "netcdf_open nf90_inq_varid rh_varid" ) + call check( nf90_inq_varid(nciu%id, nciu%vh_varname, nciu%vh_varid), "netcdf_open nf90_inq_varid vh_varid" ) if (param%lgr) then !! check if pseudovelocity vectors exist in this file. If they are, set the correct flag so we know whe should not do the conversion. - status = nf90_inq_varid(nciu%id, nciu%gr_pseudo_vhx_varname, nciu%gr_pseudo_vhx_varid) + status = nf90_inq_varid(nciu%id, nciu%gr_pseudo_vh_varname, nciu%gr_pseudo_vh_varid) nciu%lpseudo_vel_exists = (status == nf90_noerr) - if (nciu%lpseudo_vel_exists) then - status = nf90_inq_varid(nciu%id, nciu%gr_pseudo_vhy_varname, nciu%gr_pseudo_vhy_varid) - nciu%lpseudo_vel_exists = (status == nf90_noerr) - if (nciu%lpseudo_vel_exists) then - status = nf90_inq_varid(nciu%id, nciu%gr_pseudo_vhz_varname, nciu%gr_pseudo_vhz_varid) - nciu%lpseudo_vel_exists = (status == nf90_noerr) - end if - end if if (.not.nciu%lpseudo_vel_exists) then write(*,*) "Warning! Pseudovelocity not found in input file for GR enabled run. If this is a restarted run, bit-identical trajectories are not guarunteed!" end if @@ -433,12 +368,8 @@ module subroutine netcdf_open(self, param, readonly) end if if (param%lrotation) then - call check( nf90_inq_varid(nciu%id, nciu%ip1_varname, nciu%Ip1_varid), "netcdf_open nf90_inq_varid Ip1_varid" ) - call check( nf90_inq_varid(nciu%id, nciu%ip2_varname, nciu%Ip2_varid), "netcdf_open nf90_inq_varid Ip2_varid" ) - call check( nf90_inq_varid(nciu%id, nciu%ip3_varname, nciu%Ip3_varid), "netcdf_open nf90_inq_varid Ip3_varid" ) - call check( nf90_inq_varid(nciu%id, nciu%rotx_varname, nciu%rotx_varid), "netcdf_open nf90_inq_varid rotx_varid" ) - call check( nf90_inq_varid(nciu%id, nciu%roty_varname, nciu%roty_varid), "netcdf_open nf90_inq_varid roty_varid" ) - call check( nf90_inq_varid(nciu%id, nciu%rotz_varname, nciu%rotz_varid), "netcdf_open nf90_inq_varid rotz_varid" ) + call check( nf90_inq_varid(nciu%id, nciu%Ip_varname, nciu%Ip_varid), "netcdf_open nf90_inq_varid Ip_varid" ) + call check( nf90_inq_varid(nciu%id, nciu%rot_varname, nciu%rot_varid), "netcdf_open nf90_inq_varid rot_varid" ) end if ! if (param%ltides) then @@ -466,20 +397,12 @@ module subroutine netcdf_open(self, param, readonly) if (param%lclose) then status = nf90_inq_varid(nciu%id, nciu%origin_type_varname, nciu%origin_type_varid) status = nf90_inq_varid(nciu%id, nciu%origin_time_varname, nciu%origin_time_varid) - status = nf90_inq_varid(nciu%id, nciu%origin_xhx_varname, nciu%origin_xhx_varid) - status = nf90_inq_varid(nciu%id, nciu%origin_xhy_varname, nciu%origin_xhy_varid) - status = nf90_inq_varid(nciu%id, nciu%origin_xhz_varname, nciu%origin_xhz_varid) - status = nf90_inq_varid(nciu%id, nciu%origin_vhx_varname, nciu%origin_vhx_varid) - status = nf90_inq_varid(nciu%id, nciu%origin_vhy_varname, nciu%origin_vhy_varid) - status = nf90_inq_varid(nciu%id, nciu%origin_vhz_varname, nciu%origin_vhz_varid) + status = nf90_inq_varid(nciu%id, nciu%origin_rh_varname, nciu%origin_rh_varid) + status = nf90_inq_varid(nciu%id, nciu%origin_vh_varname, nciu%origin_vh_varid) status = nf90_inq_varid(nciu%id, nciu%collision_id_varname, nciu%collision_id_varid) status = nf90_inq_varid(nciu%id, nciu%discard_time_varname, nciu%discard_time_varid) - status = nf90_inq_varid(nciu%id, nciu%discard_xhx_varname, nciu%discard_xhx_varid) - status = nf90_inq_varid(nciu%id, nciu%discard_xhy_varname, nciu%discard_xhy_varid) - status = nf90_inq_varid(nciu%id, nciu%discard_xhz_varname, nciu%discard_xhz_varid) - status = nf90_inq_varid(nciu%id, nciu%discard_vhx_varname, nciu%discard_vhx_varid) - status = nf90_inq_varid(nciu%id, nciu%discard_vhy_varname, nciu%discard_vhy_varid) - status = nf90_inq_varid(nciu%id, nciu%discard_vhz_varname, nciu%discard_vhz_varid) + status = nf90_inq_varid(nciu%id, nciu%discard_rh_varname, nciu%discard_rh_varid) + status = nf90_inq_varid(nciu%id, nciu%discard_vh_varname, nciu%discard_vh_varid) status = nf90_inq_varid(nciu%id, nciu%discard_body_id_varname, nciu%discard_body_id_varid) end if @@ -487,18 +410,12 @@ module subroutine netcdf_open(self, param, readonly) status = nf90_inq_varid(nciu%id, nciu%ke_orb_varname, nciu%KE_orb_varid) status = nf90_inq_varid(nciu%id, nciu%ke_spin_varname, nciu%KE_spin_varid) status = nf90_inq_varid(nciu%id, nciu%pe_varname, nciu%PE_varid) - status = nf90_inq_varid(nciu%id, nciu%l_orbx_varname, nciu%L_orbx_varid) - status = nf90_inq_varid(nciu%id, nciu%l_orby_varname, nciu%L_orby_varid) - status = nf90_inq_varid(nciu%id, nciu%l_orbz_varname, nciu%L_orbz_varid) - status = nf90_inq_varid(nciu%id, nciu%l_spinx_varname, nciu%L_spinx_varid) - status = nf90_inq_varid(nciu%id, nciu%l_spiny_varname, nciu%L_spiny_varid) - status = nf90_inq_varid(nciu%id, nciu%l_spinz_varname, nciu%L_spinz_varid) - status = nf90_inq_varid(nciu%id, nciu%l_escapex_varname, nciu%L_escapex_varid) - status = nf90_inq_varid(nciu%id, nciu%l_escapey_varname, nciu%L_escapey_varid) - status = nf90_inq_varid(nciu%id, nciu%l_escapez_varname, nciu%L_escapez_varid) - status = nf90_inq_varid(nciu%id, nciu%ecollisions_varname, nciu%Ecollisions_varid) - status = nf90_inq_varid(nciu%id, nciu%euntracked_varname, nciu%Euntracked_varid) - status = nf90_inq_varid(nciu%id, nciu%gmescape_varname, nciu%GMescape_varid) + status = nf90_inq_varid(nciu%id, nciu%L_orb_varname, nciu%L_orb_varid) + status = nf90_inq_varid(nciu%id, nciu%L_spin_varname, nciu%L_spin_varid) + status = nf90_inq_varid(nciu%id, nciu%L_escape_varname, nciu%L_escape_varid) + status = nf90_inq_varid(nciu%id, nciu%Ecollisions_varname, nciu%Ecollisions_varid) + status = nf90_inq_varid(nciu%id, nciu%Euntracked_varname, nciu%Euntracked_varid) + status = nf90_inq_varid(nciu%id, nciu%GMescape_varname, nciu%GMescape_varid) end if end associate @@ -519,8 +436,9 @@ module function netcdf_read_frame_system(self, nciu, param) result(ierr) ! Return integer(I4B) :: ierr !! Error code: returns 0 if the read is successful ! Internals - integer(I4B) :: tslot, idmax, npl_check, ntp_check, nplm_check, t_max, str_max, status + integer(I4B) :: i, tslot, idmax, npl_check, ntp_check, nplm_check, t_max, str_max, status real(DP), dimension(:), allocatable :: rtemp + real(DP), dimension(:,:), allocatable :: vectemp integer(I4B), dimension(:), allocatable :: itemp logical, dimension(:), allocatable :: validmask, tpmask, plmask @@ -536,6 +454,7 @@ module function netcdf_read_frame_system(self, nciu, param) result(ierr) call check( nf90_inquire_dimension(nciu%id, nciu%id_dimid, len=idmax), "netcdf_read_frame_system nf90_inquire_dimension id_dimid" ) allocate(rtemp(idmax)) + allocate(vectemp(NDIM,idmax)) allocate(itemp(idmax)) allocate(validmask(idmax)) allocate(tpmask(idmax)) @@ -545,16 +464,16 @@ module function netcdf_read_frame_system(self, nciu, param) result(ierr) ! First filter out only the id slots that contain valid bodies if (param%in_form == "XV") then - call check( nf90_get_var(nciu%id, nciu%xhx_varid, rtemp(:), start=[1, tslot]), "netcdf_read_frame_system filter pass nf90_getvar xhx_varid" ) + call check( nf90_get_var(nciu%id, nciu%rh_varid, vectemp(:,:), start=[1, 1, tslot]), "netcdf_read_frame_system filter pass nf90_getvar rh_varid" ) + validmask(:) = vectemp(1,:) == vectemp(1,:) else call check( nf90_get_var(nciu%id, nciu%a_varid, rtemp(:), start=[1, tslot]), "netcdf_read_frame_system filter pass nf90_getvar a_varid" ) + validmask(:) = rtemp(:) == rtemp(:) end if - validmask(:) = rtemp(:) == rtemp(:) - ! Next, filter only bodies that don't have mass (test particles) - call check( nf90_get_var(nciu%id, nciu%Gmass_varid, rtemp(:), start=[1, tslot]), "netcdf_read_frame_system nf90_getvar Gmass_varid" ) - plmask(:) = rtemp(:) == rtemp(:) .and. validmask(:) + call check( nf90_get_var(nciu%id, nciu%Gmass_varid, vectemp(:,:), start=[1, 1, tslot]), "netcdf_read_frame_system nf90_getvar Gmass_varid" ) + plmask(:) = vectemp(1,:) == vectemp(1,:) .and. validmask(:) tpmask(:) = .not. plmask(:) .and. validmask(:) plmask(1) = .false. ! This is the central body @@ -586,80 +505,62 @@ module function netcdf_read_frame_system(self, nciu, param) result(ierr) ! Now read in each variable and split the outputs by body type if ((param%in_form == "XV") .or. (param%in_form == "XVEL")) then - call check( nf90_get_var(nciu%id, nciu%xhx_varid, rtemp, start=[1, tslot]), "netcdf_read_frame_system nf90_getvar xhx_varid" ) - if (npl > 0) pl%xh(1,:) = pack(rtemp, plmask) - if (ntp > 0) tp%xh(1,:) = pack(rtemp, tpmask) - - call check( nf90_get_var(nciu%id, nciu%xhy_varid, rtemp, start=[1, tslot]), "netcdf_read_frame_system nf90_getvar xhy_varid" ) - if (npl > 0) pl%xh(2,:) = pack(rtemp, plmask) - if (ntp > 0) tp%xh(2,:) = pack(rtemp, tpmask) - - call check( nf90_get_var(nciu%id, nciu%xhz_varid, rtemp, start=[1, tslot]), "netcdf_read_frame_system nf90_getvar xhz_varid" ) - if (npl > 0) pl%xh(3,:) = pack(rtemp, plmask) - if (ntp > 0) tp%xh(3,:) = pack(rtemp, tpmask) + call check( nf90_get_var(nciu%id, nciu%rh_varid, vectemp, start=[1, 1, tslot], count=[NDIM,idmax,1]), "netcdf_read_frame_system nf90_getvar rh_varid" ) + do i = 1, NDIM + if (npl > 0) pl%rh(i,:) = pack(vectemp(i,:), plmask(:)) + if (ntp > 0) tp%rh(i,:) = pack(vectemp(i,:), tpmask(:)) + end do if (param%lgr .and. nciu%lpseudo_vel_exists) then - call check( nf90_get_var(nciu%id, nciu%gr_pseudo_vhx_varid, rtemp, start=[1, tslot]), "netcdf_read_frame_system nf90_getvar gr_pseudo_vhx_varid" ) - if (npl > 0) pl%vh(1,:) = pack(rtemp, plmask) - if (ntp > 0) tp%vh(1,:) = pack(rtemp, tpmask) - - call check( nf90_get_var(nciu%id, nciu%gr_pseudo_vhy_varid, rtemp, start=[1, tslot]), "netcdf_read_frame_system nf90_getvar gr_pseudo_vhy_varid" ) - if (npl > 0) pl%vh(2,:) = pack(rtemp, plmask) - if (ntp > 0) tp%vh(2,:) = pack(rtemp, tpmask) - - call check( nf90_get_var(nciu%id, nciu%gr_pseudo_vhz_varid, rtemp, start=[1, tslot]), "netcdf_read_frame_system nf90_getvar gr_pseudo_vhz_varid" ) - if (npl > 0) pl%vh(3,:) = pack(rtemp, plmask) - if (ntp > 0) tp%vh(3,:) = pack(rtemp, tpmask) + call check( nf90_get_var(nciu%id, nciu%gr_pseudo_vh_varid, vectemp, start=[1, 1, tslot], count=[NDIM,idmax,1]), "netcdf_read_frame_system nf90_getvar gr_pseudo_vh_varid" ) + do i = 1, NDIM + if (npl > 0) pl%vh(i,:) = pack(vectemp(i,:), plmask(:)) + if (ntp > 0) tp%vh(i,:) = pack(vectemp(i,:), tpmask(:)) + end do else - call check( nf90_get_var(nciu%id, nciu%vhx_varid, rtemp, start=[1, tslot]), "netcdf_read_frame_system nf90_getvar vhx_varid" ) - if (npl > 0) pl%vh(1,:) = pack(rtemp, plmask) - if (ntp > 0) tp%vh(1,:) = pack(rtemp, tpmask) - - call check( nf90_get_var(nciu%id, nciu%vhy_varid, rtemp, start=[1, tslot]), "netcdf_read_frame_system nf90_getvar vhy_varid" ) - if (npl > 0) pl%vh(2,:) = pack(rtemp, plmask) - if (ntp > 0) tp%vh(2,:) = pack(rtemp, tpmask) - - call check( nf90_get_var(nciu%id, nciu%vhz_varid, rtemp, start=[1, tslot]), "netcdf_read_frame_system nf90_getvar vhz_varid" ) - if (npl > 0) pl%vh(3,:) = pack(rtemp, plmask) - if (ntp > 0) tp%vh(3,:) = pack(rtemp, tpmask) + call check( nf90_get_var(nciu%id, nciu%vh_varid, rtemp, start=[1, 1, tslot], count=[NDIM,idmax,1]), "netcdf_read_frame_system nf90_getvar vhx_varid" ) + do i = 1, NDIM + if (npl > 0) pl%vh(i,:) = pack(vectemp(i,:), plmask(:)) + if (ntp > 0) tp%vh(i,:) = pack(vectemp(i,:), tpmask(:)) + end do end if end if if ((param%in_form == "EL") .or. (param%in_form == "XVEL")) then - call check( nf90_get_var(nciu%id, nciu%a_varid, rtemp, start=[1, tslot]), "netcdf_read_frame_system nf90_getvar a_varid" ) + call check( nf90_get_var(nciu%id, nciu%a_varid, rtemp, start=[1, tslot], count=[idmax,1]), "netcdf_read_frame_system nf90_getvar a_varid" ) if (.not.allocated(pl%a)) allocate(pl%a(npl)) if (.not.allocated(tp%a)) allocate(tp%a(ntp)) if (npl > 0) pl%a(:) = pack(rtemp, plmask) if (ntp > 0) tp%a(:) = pack(rtemp, tpmask) - call check( nf90_get_var(nciu%id, nciu%e_varid, rtemp, start=[1, tslot]), "netcdf_read_frame_system nf90_getvar e_varid" ) + call check( nf90_get_var(nciu%id, nciu%e_varid, rtemp, start=[1, tslot], count=[idmax,1]), "netcdf_read_frame_system nf90_getvar e_varid" ) if (.not.allocated(pl%e)) allocate(pl%e(npl)) if (.not.allocated(tp%e)) allocate(tp%e(ntp)) if (npl > 0) pl%e(:) = pack(rtemp, plmask) if (ntp > 0) tp%e(:) = pack(rtemp, tpmask) - call check( nf90_get_var(nciu%id, nciu%inc_varid, rtemp, start=[1, tslot]), "netcdf_read_frame_system nf90_getvar inc_varid" ) + call check( nf90_get_var(nciu%id, nciu%inc_varid, rtemp, start=[1, tslot], count=[idmax,1]), "netcdf_read_frame_system nf90_getvar inc_varid" ) rtemp = rtemp * DEG2RAD if (.not.allocated(pl%inc)) allocate(pl%inc(npl)) if (.not.allocated(tp%inc)) allocate(tp%inc(ntp)) if (npl > 0) pl%inc(:) = pack(rtemp, plmask) if (ntp > 0) tp%inc(:) = pack(rtemp, tpmask) - call check( nf90_get_var(nciu%id, nciu%capom_varid, rtemp, start=[1, tslot]), "netcdf_read_frame_system nf90_getvar capom_varid" ) + call check( nf90_get_var(nciu%id, nciu%capom_varid, rtemp, start=[1, tslot], count=[idmax,1]), "netcdf_read_frame_system nf90_getvar capom_varid" ) rtemp = rtemp * DEG2RAD if (.not.allocated(pl%capom)) allocate(pl%capom(npl)) if (.not.allocated(tp%capom)) allocate(tp%capom(ntp)) if (npl > 0) pl%capom(:) = pack(rtemp, plmask) if (ntp > 0) tp%capom(:) = pack(rtemp, tpmask) - call check( nf90_get_var(nciu%id, nciu%omega_varid, rtemp, start=[1, tslot]), "netcdf_read_frame_system nf90_getvar omega_varid" ) + call check( nf90_get_var(nciu%id, nciu%omega_varid, rtemp, start=[1, tslot], count=[idmax,1]), "netcdf_read_frame_system nf90_getvar omega_varid" ) rtemp = rtemp * DEG2RAD if (.not.allocated(pl%omega)) allocate(pl%omega(npl)) if (.not.allocated(tp%omega)) allocate(tp%omega(ntp)) if (npl > 0) pl%omega(:) = pack(rtemp, plmask) if (ntp > 0) tp%omega(:) = pack(rtemp, tpmask) - call check( nf90_get_var(nciu%id, nciu%capm_varid, rtemp, start=[1, tslot]), "netcdf_read_frame_system nf90_getvar capm_varid" ) + call check( nf90_get_var(nciu%id, nciu%capm_varid, rtemp, start=[1, tslot], count=[idmax,1]), "netcdf_read_frame_system nf90_getvar capm_varid" ) rtemp = rtemp * DEG2RAD if (.not.allocated(pl%capm)) allocate(pl%capm(npl)) if (.not.allocated(tp%capm)) allocate(tp%capm(ntp)) @@ -668,7 +569,7 @@ module function netcdf_read_frame_system(self, nciu, param) result(ierr) end if - call check( nf90_get_var(nciu%id, nciu%Gmass_varid, rtemp, start=[1, tslot]), "netcdf_read_frame_system nf90_getvar Gmass_varid" ) + call check( nf90_get_var(nciu%id, nciu%Gmass_varid, rtemp, start=[1, tslot], count=[idmax,1]), "netcdf_read_frame_system nf90_getvar Gmass_varid" ) cb%Gmass = rtemp(1) cb%mass = cb%Gmass / param%GU @@ -684,13 +585,13 @@ module function netcdf_read_frame_system(self, nciu, param) result(ierr) pl%mass(:) = pl%Gmass(:) / param%GU if (param%lrhill_present) then - call check( nf90_get_var(nciu%id, nciu%rhill_varid, rtemp, start=[1, tslot]), "netcdf_read_frame_system nf90_getvar rhill_varid" ) + call check( nf90_get_var(nciu%id, nciu%rhill_varid, rtemp, start=[1, tslot], count=[idmax,1]), "netcdf_read_frame_system nf90_getvar rhill_varid" ) pl%rhill(:) = pack(rtemp, plmask) end if end if if (param%lclose) then - call check( nf90_get_var(nciu%id, nciu%radius_varid, rtemp, start=[1, tslot]), "netcdf_read_frame_system nf90_getvar radius_varid" ) + call check( nf90_get_var(nciu%id, nciu%radius_varid, rtemp, start=[1, tslot], count=[idmax,1]), "netcdf_read_frame_system nf90_getvar radius_varid" ) cb%radius = rtemp(1) ! Set initial central body radius for SyMBA bookkeeping @@ -705,29 +606,17 @@ module function netcdf_read_frame_system(self, nciu, param) result(ierr) end if if (param%lrotation) then - call check( nf90_get_var(nciu%id, nciu%Ip1_varid, rtemp, start=[1, tslot]), "netcdf_read_frame_system nf90_getvar Ip1_varid" ) - cb%Ip(1) = rtemp(1) - if (npl > 0) pl%Ip(1,:) = pack(rtemp, plmask) - - call check( nf90_get_var(nciu%id, nciu%Ip2_varid, rtemp, start=[1, tslot]), "netcdf_read_frame_system nf90_getvar Ip2_varid" ) - cb%Ip(2) = rtemp(1) - if (npl > 0) pl%Ip(2,:) = pack(rtemp, plmask) - - call check( nf90_get_var(nciu%id, nciu%Ip3_varid, rtemp, start=[1, tslot]), "netcdf_read_frame_system nf90_getvar Ip3_varid" ) - cb%Ip(3) = rtemp(1) - if (npl > 0) pl%Ip(3,:) = pack(rtemp, plmask) - - call check( nf90_get_var(nciu%id, nciu%rotx_varid, rtemp, start=[1, tslot]), "netcdf_read_frame_system nf90_getvar rotx_varid" ) - cb%rot(1) = rtemp(1) - if (npl > 0) pl%rot(1,:) = pack(rtemp, plmask) - - call check( nf90_get_var(nciu%id, nciu%roty_varid, rtemp, start=[1, tslot]), "netcdf_read_frame_system nf90_getvar roty_varid" ) - cb%rot(2) = rtemp(1) - if (npl > 0) pl%rot(2,:) = pack(rtemp, plmask) + call check( nf90_get_var(nciu%id, nciu%Ip_varid, vectemp, start=[1, 1, tslot], count=[NDIM,idmax,1]), "netcdf_read_frame_system nf90_getvar Ip_varid" ) + cb%Ip(:) = vectemp(:,1) + do i = 1, NDIM + if (npl > 0) pl%Ip(i,:) = pack(vectemp(i,:), plmask(:)) + end do - call check( nf90_get_var(nciu%id, nciu%rotz_varid, rtemp, start=[1, tslot]), "netcdf_read_frame_system nf90_getvar rotz_varid" ) - cb%rot(3) = rtemp(1) - if (npl > 0) pl%rot(3,:) = pack(rtemp, plmask) + call check( nf90_get_var(nciu%id, nciu%rot_varid, vectemp, start=[1, 1, tslot], count=[NDIM,idmax,1]), "netcdf_read_frame_system nf90_getvar rot_varid" ) + cb%rot(:) = vectemp(:,1) + do i = 1, NDIM + if (npl > 0) pl%rot(i,:) = pack(vectemp(i,:), plmask(:)) + end do ! Set initial central body angular momentum for Helio bookkeeping select type(cb) @@ -813,7 +702,7 @@ module subroutine netcdf_read_hdr_system(self, nciu, param) allocate(plmask(idmax)) allocate(plmmask(idmax)) - call check( nf90_get_var(nciu%id, nciu%Gmass_varid, gmtemp, start=[1,1]), "netcdf_read_frame_system nf90_getvar Gmass_varid" ) + call check( nf90_get_var(nciu%id, nciu%Gmass_varid, gmtemp, start=[1,1], count=[idmax,1]), "netcdf_read_frame_system nf90_getvar Gmass_varid" ) plmask(:) = gmtemp(:) == gmtemp(:) tpmask(:) = .not. plmask(:) @@ -859,29 +748,17 @@ module subroutine netcdf_read_hdr_system(self, nciu, param) if (status == nf90_noerr) call check( nf90_get_var(nciu%id, nciu%KE_spin_varid, self%ke_spin, start=[tslot]), "netcdf_read_hdr_system nf90_getvar KE_spin_varid" ) status = nf90_inq_varid(nciu%id, nciu%pe_varname, nciu%PE_varid) if (status == nf90_noerr) call check( nf90_get_var(nciu%id, nciu%PE_varid, self%pe, start=[tslot]), "netcdf_read_hdr_system nf90_getvar PE_varid" ) - status = nf90_inq_varid(nciu%id, nciu%l_orbx_varname, nciu%L_orbx_varid) - if (status == nf90_noerr) call check( nf90_get_var(nciu%id, nciu%L_orbx_varid, self%Lorbit(1), start=[tslot]), "netcdf_read_hdr_system nf90_getvar L_orbx_varid" ) - status = nf90_inq_varid(nciu%id, nciu%l_orby_varname, nciu%L_orby_varid) - if (status == nf90_noerr) call check( nf90_get_var(nciu%id, nciu%L_orby_varid, self%Lorbit(2), start=[tslot]), "netcdf_read_hdr_system nf90_getvar L_orby_varid" ) - status = nf90_inq_varid(nciu%id, nciu%l_orbz_varname, nciu%L_orbz_varid) - if (status == nf90_noerr) call check( nf90_get_var(nciu%id, nciu%L_orbz_varid, self%Lorbit(3), start=[tslot]), "netcdf_read_hdr_system nf90_getvar L_orbz_varid" ) - status = nf90_inq_varid(nciu%id, nciu%l_spinx_varname, nciu%L_spinx_varid) - if (status == nf90_noerr) call check( nf90_get_var(nciu%id, nciu%L_spinx_varid, self%Lspin(1), start=[tslot]), "netcdf_read_hdr_system nf90_getvar L_spinx_varid" ) - status = nf90_inq_varid(nciu%id, nciu%l_spiny_varname, nciu%L_spiny_varid) - if (status == nf90_noerr) call check( nf90_get_var(nciu%id, nciu%L_spiny_varid, self%Lspin(2), start=[tslot]), "netcdf_read_hdr_system nf90_getvar L_spiny_varid" ) - status = nf90_inq_varid(nciu%id, nciu%l_spinz_varname, nciu%L_spinz_varid) - if (status == nf90_noerr) call check( nf90_get_var(nciu%id, nciu%L_spinz_varid, self%Lspin(3), start=[tslot]), "netcdf_read_hdr_system nf90_getvar L_spinz_varid" ) - status = nf90_inq_varid(nciu%id, nciu%l_escapex_varname, nciu%L_escapex_varid) - if (status == nf90_noerr) call check( nf90_get_var(nciu%id, nciu%L_escapex_varid, self%Lescape(1), start=[tslot]), "netcdf_read_hdr_system nf90_getvar L_escapex_varid" ) - status = nf90_inq_varid(nciu%id, nciu%l_escapey_varname, nciu%L_escapey_varid) - if (status == nf90_noerr) call check( nf90_get_var(nciu%id, nciu%L_escapey_varid, self%Lescape(2), start=[tslot]), "netcdf_read_hdr_system nf90_getvar L_escapey_varid" ) - status = nf90_inq_varid(nciu%id, nciu%l_escapez_varname, nciu%L_escapez_varid) - if (status == nf90_noerr) call check( nf90_get_var(nciu%id, nciu%L_escapez_varid, self%Lescape(3), start=[tslot]), "netcdf_read_hdr_system nf90_getvar L_escapez_varid" ) - status = nf90_inq_varid(nciu%id, nciu%ecollisions_varname, nciu%Ecollisions_varid) + status = nf90_inq_varid(nciu%id, nciu%L_orb_varname, nciu%L_orb_varid) + if (status == nf90_noerr) call check( nf90_get_var(nciu%id, nciu%L_orb_varid, self%Lorbit(:), start=[1,tslot], count=[NDIM,1]), "netcdf_read_hdr_system nf90_getvar L_orb_varid" ) + status = nf90_inq_varid(nciu%id, nciu%L_spin_varname, nciu%L_spin_varid) + if (status == nf90_noerr) call check( nf90_get_var(nciu%id, nciu%L_spin_varid, self%Lspin(:), start=[1,tslot], count=[NDIM,1]), "netcdf_read_hdr_system nf90_getvar L_spin_varid" ) + status = nf90_inq_varid(nciu%id, nciu%L_escape_varname, nciu%L_escape_varid) + if (status == nf90_noerr) call check( nf90_get_var(nciu%id, nciu%L_escape_varid, self%Lescape(:), start=[1, tslot], count=[NDIM,1]), "netcdf_read_hdr_system nf90_getvar L_escape_varid" ) + status = nf90_inq_varid(nciu%id, nciu%Ecollisions_varname, nciu%Ecollisions_varid) if (status == nf90_noerr) call check( nf90_get_var(nciu%id, nciu%Ecollisions_varid, self%Ecollisions, start=[tslot]), "netcdf_read_hdr_system nf90_getvar Ecollisions_varid" ) - status = nf90_inq_varid(nciu%id, nciu%euntracked_varname, nciu%Euntracked_varid) + status = nf90_inq_varid(nciu%id, nciu%Euntracked_varname, nciu%Euntracked_varid) if (status == nf90_noerr) call check( nf90_get_var(nciu%id, nciu%Euntracked_varid, self%Euntracked, start=[tslot]), "netcdf_read_hdr_system nf90_getvar Euntracked_varid" ) - status = nf90_inq_varid(nciu%id, nciu%gmescape_varname, nciu%GMescape_varid) + status = nf90_inq_varid(nciu%id, nciu%GMescape_varname, nciu%GMescape_varid) if (status == nf90_noerr) call check( nf90_get_var(nciu%id, nciu%GMescape_varid, self%GMescape, start=[tslot]), "netcdf_read_hdr_system nf90_getvar GMescape_varid" ) end if @@ -903,7 +780,7 @@ module subroutine netcdf_read_particle_info_system(self, nciu, param, plmask, tp ! Internals integer(I4B) :: i, idmax, status real(DP), dimension(:), allocatable :: rtemp - real(DP), dimension(:,:), allocatable :: rtemp_arr + real(DP), dimension(:,:), allocatable :: vectemp integer(I4B), dimension(:), allocatable :: itemp character(len=NAMELEN), dimension(:), allocatable :: ctemp integer(I4B), dimension(:), allocatable :: plind, tpind @@ -911,7 +788,7 @@ module subroutine netcdf_read_particle_info_system(self, nciu, param, plmask, tp ! This string of spaces of length NAMELEN is used to clear out any old data left behind inside the string variables idmax = size(plmask) allocate(rtemp(idmax)) - allocate(rtemp_arr(NDIM,idmax)) + allocate(vectemp(NDIM,idmax)) allocate(itemp(idmax)) allocate(ctemp(idmax)) @@ -1005,72 +882,36 @@ module subroutine netcdf_read_particle_info_system(self, nciu, param, plmask, tp call tp%info(i)%set_value(origin_time=rtemp(tpind(i))) end do - status = nf90_inq_varid(nciu%id, nciu%origin_xhx_varname, nciu%origin_xhx_varid) - if (status == nf90_noerr) then - call check( nf90_get_var(nciu%id, nciu%origin_xhx_varid, rtemp_arr(1,:)), "netcdf_read_particle_info_system nf90_getvar origin_xhx_varid" ) - else if ((param%out_form == "XV") .or. (param%out_form == "XVEL")) then - call check( nf90_get_var(nciu%id, nciu%xhx_varid, rtemp_arr(1,:)), "netcdf_read_particle_info_system nf90_getvar xhx_varid" ) - else - rtemp_arr(1,:) = 0._DP - end if - - status = nf90_inq_varid(nciu%id, nciu%origin_xhy_varname, nciu%origin_xhy_varid) + status = nf90_inq_varid(nciu%id, nciu%origin_rh_varname, nciu%origin_rh_varid) if (status == nf90_noerr) then - call check( nf90_get_var(nciu%id, nciu%origin_xhy_varid, rtemp_arr(2,:)), "netcdf_read_particle_info_system nf90_getvar origin_xhy_varid" ) + call check( nf90_get_var(nciu%id, nciu%origin_rh_varid, vectemp(:,:)), "netcdf_read_particle_info_system nf90_getvar origin_rh_varid" ) else if ((param%out_form == "XV") .or. (param%out_form == "XVEL")) then - call check( nf90_get_var(nciu%id, nciu%xhy_varid, rtemp_arr(2,:)), "netcdf_read_particle_info_system nf90_getvar xhx_varid" ) + call check( nf90_get_var(nciu%id, nciu%rh_varid, vectemp(:,:)), "netcdf_read_particle_info_system nf90_getvar rh_varid" ) else - rtemp_arr(2,:) = 0._DP - end if - - status = nf90_inq_varid(nciu%id, nciu%origin_xhz_varname, nciu%origin_xhz_varid) - if (status == nf90_noerr) then - call check( nf90_get_var(nciu%id, nciu%origin_xhz_varid, rtemp_arr(3,:)), "netcdf_read_particle_info_system nf90_getvar origin_xhz_varid" ) - else if ((param%out_form == "XV") .or. (param%out_form == "XVEL")) then - call check( nf90_get_var(nciu%id, nciu%xhz_varid, rtemp_arr(3,:)), "netcdf_read_particle_info_system nf90_getvar xhz_varid" ) - else - rtemp_arr(3,:) = 0._DP + vectemp(:,:) = 0._DP end if do i = 1, npl - call pl%info(i)%set_value(origin_xh=rtemp_arr(:,plind(i))) + call pl%info(i)%set_value(origin_rh=vectemp(:,plind(i))) end do do i = 1, ntp - call tp%info(i)%set_value(origin_xh=rtemp_arr(:,tpind(i))) + call tp%info(i)%set_value(origin_rh=vectemp(:,tpind(i))) end do - status = nf90_inq_varid(nciu%id, nciu%origin_vhx_varname, nciu%origin_vhx_varid) + status = nf90_inq_varid(nciu%id, nciu%origin_vh_varname, nciu%origin_vh_varid) if (status == nf90_noerr) then - call check( nf90_get_var(nciu%id, nciu%origin_vhx_varid, rtemp_arr(1,:)), "netcdf_read_particle_info_system nf90_getvar origin_vhx_varid" ) + call check( nf90_get_var(nciu%id, nciu%origin_vh_varid, vectemp(:,:)), "netcdf_read_particle_info_system nf90_getvar origin_vh_varid" ) else if ((param%out_form == "XV") .or. (param%out_form == "XVEL")) then - call check( nf90_get_var(nciu%id, nciu%vhx_varid, rtemp_arr(1,:)), "netcdf_read_particle_info_system nf90_getvar vhx_varid" ) + call check( nf90_get_var(nciu%id, nciu%vh_varid, vectemp(:,:)), "netcdf_read_particle_info_system nf90_getvar vh_varid" ) else - rtemp_arr(1,:) = 0._DP + vectemp(:,:) = 0._DP end if - status = nf90_inq_varid(nciu%id, nciu%origin_vhy_varname, nciu%origin_vhy_varid) - if (status == nf90_noerr) then - call check( nf90_get_var(nciu%id, nciu%origin_vhy_varid, rtemp_arr(2,:)), "netcdf_read_particle_info_system nf90_getvar origin_vhy_varid" ) - else if ((param%out_form == "XV") .or. (param%out_form == "XVEL")) then - call check( nf90_get_var(nciu%id, nciu%vhy_varid, rtemp_arr(2,:)), "netcdf_read_particle_info_system nf90_getvar vhy_varid" ) - else - rtemp_arr(2,:) = 0._DP - end if - - status = nf90_inq_varid(nciu%id, nciu%origin_vhz_varname, nciu%origin_vhz_varid) - if (status == nf90_noerr) then - call check( nf90_get_var(nciu%id, nciu%origin_vhz_varid, rtemp_arr(3,:)), "netcdf_read_particle_info_system nf90_getvar origin_vhz_varid" ) - else if ((param%out_form == "XV") .or. (param%out_form == "XVEL")) then - call check( nf90_get_var(nciu%id, nciu%vhz_varid, rtemp_arr(3,:)), "netcdf_read_particle_info_system nf90_getvar vhz_varid" ) - else - rtemp_arr(3,:) = 0._DP - end if - do i = 1, npl - call pl%info(i)%set_value(origin_vh=rtemp_arr(:,plind(i))) + call pl%info(i)%set_value(origin_vh=vectemp(:,plind(i))) end do do i = 1, ntp - call tp%info(i)%set_value(origin_vh=rtemp_arr(:,tpind(i))) + call tp%info(i)%set_value(origin_vh=vectemp(:,tpind(i))) end do status = nf90_inq_varid(nciu%id, nciu%collision_id_varname, nciu%collision_id_varid) @@ -1102,60 +943,32 @@ module subroutine netcdf_read_particle_info_system(self, nciu, param, plmask, tp call tp%info(i)%set_value(discard_time=rtemp(tpind(i))) end do - status = nf90_inq_varid(nciu%id, nciu%discard_xhx_varname, nciu%discard_xhx_varid) + status = nf90_inq_varid(nciu%id, nciu%discard_rh_varname, nciu%discard_rh_varid) if (status == nf90_noerr) then - call check( nf90_get_var(nciu%id, nciu%discard_xhx_varid, rtemp_arr(1,:)), "netcdf_read_particle_info_system nf90_getvar discard_xhx_varid" ) + call check( nf90_get_var(nciu%id, nciu%discard_rh_varid, vectemp(:,:)), "netcdf_read_particle_info_system nf90_getvar discard_rh_varid" ) else - rtemp_arr(1,:) = 0.0_DP - end if - - status = nf90_inq_varid(nciu%id, nciu%discard_xhy_varname, nciu%discard_xhy_varid) - if (status == nf90_noerr) then - call check( nf90_get_var(nciu%id, nciu%discard_xhy_varid, rtemp_arr(2,:)), "netcdf_read_particle_info_system nf90_getvar discard_xhy_varid" ) - else - rtemp_arr(2,:) = 0.0_DP - end if - - status = nf90_inq_varid(nciu%id, nciu%discard_xhz_varname, nciu%discard_xhz_varid) - if (status == nf90_noerr) then - call check( nf90_get_var(nciu%id, nciu%discard_xhz_varid, rtemp_arr(3,:)), "netcdf_read_particle_info_system nf90_getvar discard_xhz_varid" ) - else - rtemp_arr(3,:) = 0.0_DP + vectemp(:,:) = 0.0_DP end if do i = 1, npl - call pl%info(i)%set_value(discard_xh=rtemp_arr(:,plind(i))) + call pl%info(i)%set_value(discard_rh=vectemp(:,plind(i))) end do do i = 1, ntp - call tp%info(i)%set_value(discard_xh=rtemp_arr(:,tpind(i))) + call tp%info(i)%set_value(discard_rh=vectemp(:,tpind(i))) end do - status = nf90_inq_varid(nciu%id, nciu%discard_vhx_varname, nciu%discard_vhx_varid) - if (status == nf90_noerr) then - call check( nf90_get_var(nciu%id, nciu%discard_vhx_varid, rtemp_arr(1,:)), "netcdf_read_particle_info_system nf90_getvar discard_vhx_varid" ) - else - rtemp_arr(1,:) = 0.0_DP - end if - - status = nf90_inq_varid(nciu%id, nciu%discard_vhy_varname, nciu%discard_vhy_varid) - if (status == nf90_noerr) then - call check( nf90_get_var(nciu%id, nciu%discard_vhy_varid, rtemp_arr(2,:)), "netcdf_read_particle_info_system nf90_getvar discard_vhy_varid" ) - else - rtemp_arr(2,:) = 0.0_DP - end if - - status = nf90_inq_varid(nciu%id, nciu%discard_vhz_varname, nciu%discard_vhz_varid) + status = nf90_inq_varid(nciu%id, nciu%discard_vh_varname, nciu%discard_vh_varid) if (status == nf90_noerr) then - call check( nf90_get_var(nciu%id, nciu%discard_vhz_varid, rtemp_arr(3,:)), "netcdf_read_particle_info_system nf90_getvar discard_vhz_varid" ) + call check( nf90_get_var(nciu%id, nciu%discard_vh_varid, vectemp(:,:)), "netcdf_read_particle_info_system nf90_getvar discard_vh_varid" ) else - rtemp_arr(3,:) = 0.0_DP + vectemp(:,:) = 0.0_DP end if do i = 1, npl - call pl%info(i)%set_value(discard_vh=rtemp_arr(:,plind(i))) + call pl%info(i)%set_value(discard_vh=vectemp(:,plind(i))) end do do i = 1, ntp - call tp%info(i)%set_value(discard_vh=rtemp_arr(:,tpind(i))) + call tp%info(i)%set_value(discard_vh=vectemp(:,tpind(i))) end do end if @@ -1213,36 +1026,26 @@ module subroutine netcdf_write_frame_base(self, nciu, param) idslot = self%id(j) + 1 !! Convert from pseudovelocity to heliocentric without replacing the current value of pseudovelocity - if (param%lgr) call gr_pseudovel2vel(param, self%mu(j), self%xh(:, j), self%vh(:, j), vh(:)) + if (param%lgr) call gr_pseudovel2vel(param, self%mu(j), self%rh(:, j), self%vh(:, j), vh(:)) if ((param%out_form == "XV") .or. (param%out_form == "XVEL")) then - call check( nf90_put_var(nciu%id, nciu%rh_varid, self%xh(:, j), start=[1,idslot, tslot], count=[3,1,1]), "netcdf_write_frame_base nf90_put_var rh_varid" ) - call check( nf90_put_var(nciu%id, nciu%vh_varid, self%vh(:, j), start=[1,idslot, tslot], count=[3,1,1]), "netcdf_write_frame_base nf90_put_var vh_varid" ) - call check( nf90_put_var(nciu%id, nciu%xhx_varid, self%xh(1, j), start=[idslot, tslot]), "netcdf_write_frame_base nf90_put_var xhx_varid" ) - call check( nf90_put_var(nciu%id, nciu%xhy_varid, self%xh(2, j), start=[idslot, tslot]), "netcdf_write_frame_base nf90_put_var xhy_varid" ) - call check( nf90_put_var(nciu%id, nciu%xhz_varid, self%xh(3, j), start=[idslot, tslot]), "netcdf_write_frame_base nf90_put_var xhz_varid" ) + call check( nf90_put_var(nciu%id, nciu%rh_varid, self%rh(:, j), start=[1,idslot, tslot], count=[NDIM,1,1]), "netcdf_write_frame_base nf90_put_var rh_varid" ) if (param%lgr) then !! Convert from pseudovelocity to heliocentric without replacing the current value of pseudovelocity - call check( nf90_put_var(nciu%id, nciu%vhx_varid, vh(1), start=[idslot, tslot]), "netcdf_write_frame_base nf90_put_var vhx_varid (gr case)" ) - call check( nf90_put_var(nciu%id, nciu%vhy_varid, vh(2), start=[idslot, tslot]), "netcdf_write_frame_base nf90_put_var vhy_varid (gr case)" ) - call check( nf90_put_var(nciu%id, nciu%vhz_varid, vh(3), start=[idslot, tslot]), "netcdf_write_frame_base nf90_put_var vhz_varid (gr case)" ) - call check( nf90_put_var(nciu%id, nciu%gr_pseudo_vhx_varid, self%vh(1, j), start=[idslot, tslot]), "netcdf_write_frame_base nf90_put_var gr_pseudo_vhx_varid" ) - call check( nf90_put_var(nciu%id, nciu%gr_pseudo_vhy_varid, self%vh(2, j), start=[idslot, tslot]), "netcdf_write_frame_base nf90_put_var gr_pseudo_vhy_varid" ) - call check( nf90_put_var(nciu%id, nciu%gr_pseudo_vhz_varid, self%vh(3, j), start=[idslot, tslot]), "netcdf_write_frame_base nf90_put_var gr_pseudo_vhz_varid" ) + call check( nf90_put_var(nciu%id, nciu%vh_varid, vh(:), start=[1,idslot, tslot], count=[NDIM,1,1]), "netcdf_write_frame_base nf90_put_var vh_varid" ) + call check( nf90_put_var(nciu%id, nciu%gr_pseudo_vh_varid, self%vh(:, j), start=[1,idslot, tslot],count=[NDIM,1,1]), "netcdf_write_frame_base nf90_put_var gr_pseudo_vhx_varid" ) else - call check( nf90_put_var(nciu%id, nciu%vhx_varid, self%vh(1, j), start=[idslot, tslot]), "netcdf_write_frame_base nf90_put_var vhx_varid" ) - call check( nf90_put_var(nciu%id, nciu%vhy_varid, self%vh(2, j), start=[idslot, tslot]), "netcdf_write_frame_base nf90_put_var vhy_varid" ) - call check( nf90_put_var(nciu%id, nciu%vhz_varid, self%vh(3, j), start=[idslot, tslot]), "netcdf_write_frame_base nf90_put_var vhz_varid" ) + call check( nf90_put_var(nciu%id, nciu%vh_varid, self%vh(:, j), start=[1,idslot, tslot], count=[NDIM,1,1]), "netcdf_write_frame_base nf90_put_var vh_varid" ) end if end if if ((param%out_form == "EL") .or. (param%out_form == "XVEL")) then if (param%lgr) then !! For GR-enabled runs, use the true value of velocity computed above - call orbel_xv2el(self%mu(j), self%xh(1,j), self%xh(2,j), self%xh(3,j), & + call orbel_xv2el(self%mu(j), self%rh(1,j), self%rh(2,j), self%rh(3,j), & vh(1), vh(2), vh(3), & a, e, inc, capom, omega, capm) else !! For non-GR runs just convert from the velocity we have - call orbel_xv2el(self%mu(j), self%xh(1,j), self%xh(2,j), self%xh(3,j), & + call orbel_xv2el(self%mu(j), self%rh(1,j), self%rh(2,j), self%rh(3,j), & self%vh(1,j), self%vh(2,j), self%vh(3,j), & a, e, inc, capom, omega, capm) end if @@ -1262,12 +1065,8 @@ module subroutine netcdf_write_frame_base(self, nciu, param) end if if (param%lclose) call check( nf90_put_var(nciu%id, nciu%radius_varid, self%radius(j), start=[idslot, tslot]), "netcdf_write_frame_base nf90_put_var radius_varid" ) if (param%lrotation) then - call check( nf90_put_var(nciu%id, nciu%Ip1_varid, self%Ip(1, j), start=[idslot, tslot]), "netcdf_write_frame_base nf90_put_var Ip1_varid" ) - call check( nf90_put_var(nciu%id, nciu%Ip2_varid, self%Ip(2, j), start=[idslot, tslot]), "netcdf_write_frame_base nf90_put_var Ip2_varid" ) - call check( nf90_put_var(nciu%id, nciu%Ip3_varid, self%Ip(3, j), start=[idslot, tslot]), "netcdf_write_frame_base nf90_put_var Ip3_varid" ) - call check( nf90_put_var(nciu%id, nciu%rotx_varid, self%rot(1, j), start=[idslot, tslot]), "netcdf_write_frame_base nf90_put_var rotx_varid" ) - call check( nf90_put_var(nciu%id, nciu%roty_varid, self%rot(2, j), start=[idslot, tslot]), "netcdf_write_frame_base nf90_put_var roty_varid" ) - call check( nf90_put_var(nciu%id, nciu%rotz_varid, self%rot(3, j), start=[idslot, tslot]), "netcdf_write_frame_base nf90_put_var rotz_varid" ) + call check( nf90_put_var(nciu%id, nciu%Ip_varid, self%Ip(:, j), start=[1,idslot, tslot], count=[NDIM,1,1]), "netcdf_write_frame_base nf90_put_var Ip_varid" ) + call check( nf90_put_var(nciu%id, nciu%rot_varid, self%rot(:, j), start=[1,idslot, tslot], count=[NDIM,1,1]), "netcdf_write_frame_base nf90_put_var rotx_varid" ) end if ! if (param%ltides) then ! call check( nf90_put_var(nciu%id, nciu%k2_varid, self%k2(j), start=[idslot, tslot]), "netcdf_write_frame_base nf90_put_var k2_varid" ) @@ -1286,12 +1085,8 @@ module subroutine netcdf_write_frame_base(self, nciu, param) call check( nf90_put_var(nciu%id, nciu%j2rp2_varid, self%j2rp2, start=[tslot]), "netcdf_write_frame_base nf90_put_var cb j2rp2_varid" ) call check( nf90_put_var(nciu%id, nciu%j4rp4_varid, self%j4rp4, start=[tslot]), "netcdf_write_frame_base nf90_put_var cb j4rp4_varid" ) if (param%lrotation) then - call check( nf90_put_var(nciu%id, nciu%Ip1_varid, self%Ip(1), start=[idslot, tslot]), "netcdf_write_frame_base nf90_put_var cb Ip1_varid" ) - call check( nf90_put_var(nciu%id, nciu%Ip2_varid, self%Ip(2), start=[idslot, tslot]), "netcdf_write_frame_base nf90_put_var cb Ip2_varid" ) - call check( nf90_put_var(nciu%id, nciu%Ip3_varid, self%Ip(3), start=[idslot, tslot]), "netcdf_write_frame_base nf90_put_var cb Ip3_varid" ) - call check( nf90_put_var(nciu%id, nciu%rotx_varid, self%rot(1), start=[idslot, tslot]), "netcdf_write_frame_base nf90_put_var cb rotx_varid" ) - call check( nf90_put_var(nciu%id, nciu%roty_varid, self%rot(2), start=[idslot, tslot]), "netcdf_write_frame_base nf90_put_var cb roty_varid" ) - call check( nf90_put_var(nciu%id, nciu%rotz_varid, self%rot(3), start=[idslot, tslot]), "netcdf_write_frame_base nf90_put_var cb rotz_varid" ) + call check( nf90_put_var(nciu%id, nciu%Ip_varid, self%Ip(:), start=[1, idslot, tslot], count=[NDIM,1,1]), "netcdf_write_frame_base nf90_put_var cb Ip_varid" ) + call check( nf90_put_var(nciu%id, nciu%rot_varid, self%rot(:), start=[1, idslot, tslot], count=[NDIM,1,1]), "netcdf_write_frame_base nf90_put_var cb rot_varid" ) end if ! if (param%ltides) then ! call check( nf90_put_var(nciu%id, nciu%k2_varid, self%k2, start=[idslot, tslot]), "netcdf_write_frame_base nf90_put_var cb k2_varid" ) @@ -1365,21 +1160,13 @@ module subroutine netcdf_write_info_base(self, nciu, param) charstring = trim(adjustl(self%info(j)%origin_type)) call check( nf90_put_var(nciu%id, nciu%origin_type_varid, charstring, start=[1, idslot], count=[NAMELEN, 1]), "netcdf_write_info_base nf90_put_var origin_type_varid" ) call check( nf90_put_var(nciu%id, nciu%origin_time_varid, self%info(j)%origin_time, start=[idslot]), "netcdf_write_info_base nf90_put_var origin_time_varid" ) - call check( nf90_put_var(nciu%id, nciu%origin_xhx_varid, self%info(j)%origin_xh(1), start=[idslot]), "netcdf_write_info_base nf90_put_var origin_xhx_varid" ) - call check( nf90_put_var(nciu%id, nciu%origin_xhy_varid, self%info(j)%origin_xh(2), start=[idslot]), "netcdf_write_info_base nf90_put_var origin_xhy_varid" ) - call check( nf90_put_var(nciu%id, nciu%origin_xhz_varid, self%info(j)%origin_xh(3), start=[idslot]), "netcdf_write_info_base nf90_put_var origin_xhz_varid" ) - call check( nf90_put_var(nciu%id, nciu%origin_vhx_varid, self%info(j)%origin_vh(1), start=[idslot]), "netcdf_write_info_base nf90_put_var origin_vhx_varid" ) - call check( nf90_put_var(nciu%id, nciu%origin_vhy_varid, self%info(j)%origin_vh(2), start=[idslot]), "netcdf_write_info_base nf90_put_var origin_vhy_varid" ) - call check( nf90_put_var(nciu%id, nciu%origin_vhz_varid, self%info(j)%origin_vh(3), start=[idslot]), "netcdf_write_info_base nf90_put_var origin_vhz_varid" ) + call check( nf90_put_var(nciu%id, nciu%origin_rh_varid, self%info(j)%origin_rh(:), start=[1,idslot], count=[NDIM,1]), "netcdf_write_info_base nf90_put_var origin_rh_varid" ) + call check( nf90_put_var(nciu%id, nciu%origin_vh_varid, self%info(j)%origin_vh(:), start=[1,idslot], count=[NDIM,1]), "netcdf_write_info_base nf90_put_var origin_vh_varid" ) call check( nf90_put_var(nciu%id, nciu%collision_id_varid, self%info(j)%collision_id, start=[idslot]), "netcdf_write_info_base nf90_put_var collision_id_varid" ) call check( nf90_put_var(nciu%id, nciu%discard_time_varid, self%info(j)%discard_time, start=[idslot]), "netcdf_write_info_base nf90_put_var discard_time_varid" ) - call check( nf90_put_var(nciu%id, nciu%discard_xhx_varid, self%info(j)%discard_xh(1), start=[idslot]), "netcdf_write_info_base nf90_put_var discard_xhx_varid" ) - call check( nf90_put_var(nciu%id, nciu%discard_xhy_varid, self%info(j)%discard_xh(2), start=[idslot]), "netcdf_write_info_base nf90_put_var discard_xhy_varid" ) - call check( nf90_put_var(nciu%id, nciu%discard_xhz_varid, self%info(j)%discard_xh(3), start=[idslot]), "netcdf_write_info_base nf90_put_var discard_xhz_varid" ) - call check( nf90_put_var(nciu%id, nciu%discard_vhx_varid, self%info(j)%discard_vh(1), start=[idslot]), "netcdf_write_info_base nf90_put_var discard_vhx_varid" ) - call check( nf90_put_var(nciu%id, nciu%discard_vhy_varid, self%info(j)%discard_vh(2), start=[idslot]), "netcdf_write_info_base nf90_put_var discard_vhy_varid" ) - call check( nf90_put_var(nciu%id, nciu%discard_vhz_varid, self%info(j)%discard_vh(3), start=[idslot]), "netcdf_write_info_base nf90_put_var discard_vhz_varid" ) + call check( nf90_put_var(nciu%id, nciu%discard_rh_varid, self%info(j)%discard_rh(:), start=[1,idslot], count=[NDIM,1]), "netcdf_write_info_base nf90_put_var discard_rh_varid" ) + call check( nf90_put_var(nciu%id, nciu%discard_vh_varid, self%info(j)%discard_vh(:), start=[1,idslot], count=[NDIM,1]), "netcdf_write_info_base nf90_put_var discard_vh_varid" ) end if end do @@ -1403,21 +1190,13 @@ module subroutine netcdf_write_info_base(self, nciu, param) call check( nf90_put_var(nciu%id, nciu%origin_type_varid, charstring, start=[1, idslot], count=[NAMELEN, 1]), "netcdf_write_info_base nf90_put_var cb origin_type_varid" ) call check( nf90_put_var(nciu%id, nciu%origin_time_varid, self%info%origin_time, start=[idslot]), "netcdf_write_info_base nf90_put_var cb origin_time_varid" ) - call check( nf90_put_var(nciu%id, nciu%origin_xhx_varid, self%info%origin_xh(1), start=[idslot]), "netcdf_write_info_base nf90_put_var cb origin_xhx_varid" ) - call check( nf90_put_var(nciu%id, nciu%origin_xhy_varid, self%info%origin_xh(2), start=[idslot]), "netcdf_write_info_base nf90_put_var cb origin_xhy_varid" ) - call check( nf90_put_var(nciu%id, nciu%origin_xhz_varid, self%info%origin_xh(3), start=[idslot]), "netcdf_write_info_base nf90_put_var cb origin_xhz_varid" ) - call check( nf90_put_var(nciu%id, nciu%origin_vhx_varid, self%info%origin_vh(1), start=[idslot]), "netcdf_write_info_base nf90_put_var cb origin_vhx_varid" ) - call check( nf90_put_var(nciu%id, nciu%origin_vhy_varid, self%info%origin_vh(2), start=[idslot]), "netcdf_write_info_base nf90_put_var cb origin_vhy_varid" ) - call check( nf90_put_var(nciu%id, nciu%origin_vhz_varid, self%info%origin_vh(3), start=[idslot]), "netcdf_write_info_base nf90_put_var cb origin_vhz_varid" ) + call check( nf90_put_var(nciu%id, nciu%origin_rh_varid, self%info%origin_rh(:), start=[1, idslot], count=[NDIM,1]), "netcdf_write_info_base nf90_put_var cb origin_rh_varid" ) + call check( nf90_put_var(nciu%id, nciu%origin_vh_varid, self%info%origin_vh(:), start=[1, idslot], count=[NDIM,1]), "netcdf_write_info_base nf90_put_var cb origin_vh_varid" ) call check( nf90_put_var(nciu%id, nciu%collision_id_varid, self%info%collision_id, start=[idslot]), "netcdf_write_info_base nf90_put_var cb collision_id_varid" ) call check( nf90_put_var(nciu%id, nciu%discard_time_varid, self%info%discard_time, start=[idslot]), "netcdf_write_info_base nf90_put_var cb discard_time_varid" ) - call check( nf90_put_var(nciu%id, nciu%discard_xhx_varid, self%info%discard_xh(1), start=[idslot]), "netcdf_write_info_base nf90_put_var cb discard_xhx_varid" ) - call check( nf90_put_var(nciu%id, nciu%discard_xhy_varid, self%info%discard_xh(2), start=[idslot]), "netcdf_write_info_base nf90_put_var cb discard_xhy_varid" ) - call check( nf90_put_var(nciu%id, nciu%discard_xhz_varid, self%info%discard_xh(3), start=[idslot]), "netcdf_write_info_base nf90_put_var cb discard_xhz_varid" ) - call check( nf90_put_var(nciu%id, nciu%discard_vhx_varid, self%info%discard_vh(1), start=[idslot]), "netcdf_write_info_base nf90_put_var cb discard_vhx_varid" ) - call check( nf90_put_var(nciu%id, nciu%discard_vhy_varid, self%info%discard_vh(2), start=[idslot]), "netcdf_write_info_base nf90_put_var cb discard_vhy_varid" ) - call check( nf90_put_var(nciu%id, nciu%discard_vhz_varid, self%info%discard_vh(3), start=[idslot]), "netcdf_write_info_base nf90_put_var cb discard_vhz_varid" ) + call check( nf90_put_var(nciu%id, nciu%discard_rh_varid, self%info%discard_rh(:), start=[1, idslot], count=[NDIM,1]), "netcdf_write_info_base nf90_put_var cb discard_rh_varid" ) + call check( nf90_put_var(nciu%id, nciu%discard_vh_varid, self%info%discard_vh(:), start=[1, idslot], count=[NDIM,1]), "netcdf_write_info_base nf90_put_var cb discard_vh_varid" ) end if end select @@ -1455,15 +1234,9 @@ module subroutine netcdf_write_hdr_system(self, nciu, param) call check( nf90_put_var(nciu%id, nciu%KE_orb_varid, self%ke_orbit, start=[tslot]), "netcdf_write_hdr_system nf90_put_var KE_orb_varid" ) call check( nf90_put_var(nciu%id, nciu%KE_spin_varid, self%ke_spin, start=[tslot]), "netcdf_write_hdr_system nf90_put_var KE_spin_varid" ) call check( nf90_put_var(nciu%id, nciu%PE_varid, self%pe, start=[tslot]), "netcdf_write_hdr_system nf90_put_var PE_varid" ) - call check( nf90_put_var(nciu%id, nciu%L_orbx_varid, self%Lorbit(1), start=[tslot]), "netcdf_write_hdr_system nf90_put_var L_orbx_varid" ) - call check( nf90_put_var(nciu%id, nciu%L_orby_varid, self%Lorbit(2), start=[tslot]), "netcdf_write_hdr_system nf90_put_var L_orby_varid" ) - call check( nf90_put_var(nciu%id, nciu%L_orbz_varid, self%Lorbit(3), start=[tslot]), "netcdf_write_hdr_system nf90_put_var L_orbz_varid" ) - call check( nf90_put_var(nciu%id, nciu%L_spinx_varid, self%Lspin(1), start=[tslot]), "netcdf_write_hdr_system nf90_put_var L_spinx_varid" ) - call check( nf90_put_var(nciu%id, nciu%L_spiny_varid, self%Lspin(2), start=[tslot]), "netcdf_write_hdr_system nf90_put_var L_spiny_varid" ) - call check( nf90_put_var(nciu%id, nciu%L_spinz_varid, self%Lspin(3), start=[tslot]), "netcdf_write_hdr_system nf90_put_var L_spinz_varid" ) - call check( nf90_put_var(nciu%id, nciu%L_escapex_varid, self%Lescape(1), start=[tslot]), "netcdf_write_hdr_system nf90_put_var L_escapex_varid" ) - call check( nf90_put_var(nciu%id, nciu%L_escapey_varid, self%Lescape(2), start=[tslot]), "netcdf_write_hdr_system nf90_put_var L_escapey_varid" ) - call check( nf90_put_var(nciu%id, nciu%L_escapez_varid, self%Lescape(3), start=[tslot]), "netcdf_write_hdr_system nf90_put_var L_escapez_varid" ) + call check( nf90_put_var(nciu%id, nciu%L_orb_varid, self%Lorbit(:), start=[1,tslot], count=[NDIM,1]), "netcdf_write_hdr_system nf90_put_var L_orb_varid" ) + call check( nf90_put_var(nciu%id, nciu%L_spin_varid, self%Lspin(:), start=[1,tslot], count=[NDIM,1]), "netcdf_write_hdr_system nf90_put_var L_spin_varid" ) + call check( nf90_put_var(nciu%id, nciu%L_escape_varid, self%Lescape(:), start=[1,tslot], count=[NDIM,1]), "netcdf_write_hdr_system nf90_put_var L_escape_varid" ) call check( nf90_put_var(nciu%id, nciu%Ecollisions_varid, self%Ecollisions, start=[tslot]), "netcdf_write_hdr_system nf90_put_var Ecollisions_varid" ) call check( nf90_put_var(nciu%id, nciu%Euntracked_varid, self%Euntracked, start=[tslot]), "netcdf_write_hdr_system nf90_put_var Euntracked_varid" ) call check( nf90_put_var(nciu%id, nciu%GMescape_varid, self%GMescape, start=[tslot]), "netcdf_write_hdr_system nf90_put_var GMescape_varid" ) diff --git a/src/obl/obl.f90 b/src/obl/obl.f90 index 9ae30a5e4..be964c3e5 100644 --- a/src/obl/obl.f90 +++ b/src/obl/obl.f90 @@ -31,17 +31,17 @@ module subroutine obl_acc_body(self, system) associate(n => self%nbody, cb => system%cb) self%aobl(:,:) = 0.0_DP do concurrent(i = 1:n, self%lmask(i)) - r2 = dot_product(self%xh(:, i), self%xh(:, i)) + r2 = dot_product(self%rh(:, i), self%rh(:, i)) irh = 1.0_DP / sqrt(r2) rinv2 = irh**2 t0 = -cb%Gmass * rinv2 * rinv2 * irh t1 = 1.5_DP * cb%j2rp2 - t2 = self%xh(3, i) * self%xh(3, i) * rinv2 + t2 = self%rh(3, i) * self%rh(3, i) * rinv2 t3 = 1.875_DP * cb%j4rp4 * rinv2 fac1 = t0 * (t1 - t3 - (5 * t1 - (14.0_DP - 21.0_DP * t2) * t3) * t2) fac2 = 2 * t0 * (t1 - (2.0_DP - (14.0_DP * t2 / 3.0_DP)) * t3) - self%aobl(:, i) = fac1 * self%xh(:, i) - self%aobl(3, i) = fac2 * self%xh(3, i) + self%aobl(3, i) + self%aobl(:, i) = fac1 * self%rh(:, i) + self%aobl(3, i) = fac2 * self%rh(3, i) + self%aobl(3, i) end do end associate return @@ -137,7 +137,7 @@ module subroutine obl_pot_system(self) associate(system => self, pl => self%pl, npl => self%pl%nbody, cb => self%cb) if (.not. any(pl%lmask(1:npl))) return do concurrent (i = 1:npl, pl%lmask(i)) - oblpot_arr(i) = obl_pot_one(cb%Gmass, pl%Gmass(i), cb%j2rp2, cb%j4rp4, pl%xh(3,i), 1.0_DP / norm2(pl%xh(:,i))) + oblpot_arr(i) = obl_pot_one(cb%Gmass, pl%Gmass(i), cb%j2rp2, cb%j4rp4, pl%rh(3,i), 1.0_DP / norm2(pl%rh(:,i))) end do system%oblpot = sum(oblpot_arr, pl%lmask(1:npl)) end associate diff --git a/src/orbel/orbel.f90 b/src/orbel/orbel.f90 index 5e7c4a989..014fe9bae 100644 --- a/src/orbel/orbel.f90 +++ b/src/orbel/orbel.f90 @@ -28,7 +28,7 @@ module subroutine orbel_el2xv_vec(self, cb) call self%set_mu(cb) do concurrent (i = 1:self%nbody) call orbel_el2xv(self%mu(i), self%a(i), self%e(i), self%inc(i), self%capom(i), & - self%omega(i), self%capm(i), self%xh(:, i), self%vh(:, i)) + self%omega(i), self%capm(i), self%rh(:, i), self%vh(:, i)) end do return end subroutine orbel_el2xv_vec @@ -885,7 +885,7 @@ module subroutine orbel_xv2el_vec(self, cb) if (allocated(self%omega)) deallocate(self%omega); allocate(self%omega(self%nbody)) if (allocated(self%capm)) deallocate(self%capm); allocate(self%capm(self%nbody)) do concurrent (i = 1:self%nbody) - call orbel_xv2el(self%mu(i), self%xh(1,i), self%xh(2,i), self%xh(3,i), & + call orbel_xv2el(self%mu(i), self%rh(1,i), self%rh(2,i), self%rh(3,i), & self%vh(1,i), self%vh(2,i), self%vh(3,i), & self%a(i), self%e(i), self%inc(i), & self%capom(i), self%omega(i), self%capm(i)) diff --git a/src/rmvs/rmvs_discard.f90 b/src/rmvs/rmvs_discard.f90 index 60be2f6b0..1b3a58ddc 100644 --- a/src/rmvs/rmvs_discard.f90 +++ b/src/rmvs/rmvs_discard.f90 @@ -43,7 +43,7 @@ module subroutine rmvs_discard_tp(self, system, param) // " (" // trim(adjustl(idstrj)) // ") is too small at t = " // trim(adjustl(timestr)) tp%ldiscard(i) = .true. tp%lmask(i) = .false. - call tp%info(i)%set_value(status="DISCARDED_PLQ", discard_time=t, discard_xh=tp%xh(:,i), & + call tp%info(i)%set_value(status="DISCARDED_PLQ", discard_time=t, discard_rh=tp%rh(:,i), & discard_vh=tp%vh(:,i), discard_body_id=pl%id(iplperP)) end if end if diff --git a/src/rmvs/rmvs_encounter_check.f90 b/src/rmvs/rmvs_encounter_check.f90 index cf6b73624..860bcacfb 100644 --- a/src/rmvs/rmvs_encounter_check.f90 +++ b/src/rmvs/rmvs_encounter_check.f90 @@ -42,7 +42,7 @@ module function rmvs_encounter_check_tp(self, param, system, dt) result(lencount class is (rmvs_pl) associate(tp => self, ntp => self%nbody, npl => pl%nbody) tp%plencP(1:ntp) = 0 - call encounter_check_all_pltp(param, npl, ntp, pl%xbeg, pl%vbeg, tp%xh, tp%vh, pl%renc, dt, & + call encounter_check_all_pltp(param, npl, ntp, pl%xbeg, pl%vbeg, tp%rh, tp%vh, pl%renc, dt, & nenc, index1, index2, lvdotr) lencounter = (nenc > 0_I8B) diff --git a/src/rmvs/rmvs_kick.f90 b/src/rmvs/rmvs_kick.f90 index 91e63a62e..bb43aba94 100644 --- a/src/rmvs/rmvs_kick.f90 +++ b/src/rmvs/rmvs_kick.f90 @@ -42,11 +42,11 @@ module subroutine rmvs_kick_getacch_tp(self, system, param, t, lbeg) class is (rmvs_pl) select type (cb => system%cb) class is (rmvs_cb) - associate(xpc => pl%xh, xpct => self%xh, apct => self%ah, system_planetocen => system) + associate(xpc => pl%rh, xpct => self%rh, apct => self%ah, system_planetocen => system) system_planetocen%lbeg = lbeg ! Save the original heliocentric position for later - allocate(xh_original, source=tp%xh) + allocate(xh_original, source=tp%rh) ! Temporarily turn off the heliocentric-dependent acceleration terms during an inner encounter using a copy of the parameter list with all of the heliocentric-specific acceleration terms turned off allocate(param_planetocen, source=param) @@ -60,17 +60,17 @@ module subroutine rmvs_kick_getacch_tp(self, system, param, t, lbeg) ! Now compute any heliocentric values of acceleration if (tp%lfirst) then do concurrent(i = 1:ntp, tp%lmask(i)) - tp%xheliocentric(:,i) = tp%xh(:,i) + cb%inner(inner_index - 1)%x(:,1) + tp%xheliocentric(:,i) = tp%rh(:,i) + cb%inner(inner_index - 1)%x(:,1) end do else do concurrent(i = 1:ntp, tp%lmask(i)) - tp%xheliocentric(:,i) = tp%xh(:,i) + cb%inner(inner_index )%x(:,1) + tp%xheliocentric(:,i) = tp%rh(:,i) + cb%inner(inner_index )%x(:,1) end do end if ! Swap the planetocentric and heliocentric position vectors and central body masses do concurrent(i = 1:ntp, tp%lmask(i)) - tp%xh(:, i) = tp%xheliocentric(:, i) + tp%rh(:, i) = tp%xheliocentric(:, i) end do GMcb_original = cb%Gmass cb%Gmass = tp%cb_heliocentric%Gmass @@ -81,7 +81,7 @@ module subroutine rmvs_kick_getacch_tp(self, system, param, t, lbeg) if (param%lgr) call tp%accel_gr(param) ! Put everything back the way we found it - call move_alloc(xh_original, tp%xh) + call move_alloc(xh_original, tp%rh) cb%Gmass = GMcb_original end associate diff --git a/src/rmvs/rmvs_step.f90 b/src/rmvs/rmvs_step.f90 index 7c39614e1..132139e33 100644 --- a/src/rmvs/rmvs_step.f90 +++ b/src/rmvs/rmvs_step.f90 @@ -38,7 +38,7 @@ module subroutine rmvs_step_system(self, param, t, dt) select type(tp => self%tp) class is (rmvs_tp) associate(system => self, ntp => tp%nbody, npl => pl%nbody) - allocate(xbeg, source=pl%xh) + allocate(xbeg, source=pl%rh) allocate(vbeg, source=pl%vh) call pl%set_beg_end(xbeg = xbeg, vbeg = vbeg) ! ****** Check for close encounters ***** ! @@ -49,7 +49,7 @@ module subroutine rmvs_step_system(self, param, t, dt) pl%outer(0)%x(:, 1:npl) = xbeg(:, 1:npl) pl%outer(0)%v(:, 1:npl) = vbeg(:, 1:npl) call pl%step(system, param, t, dt) - pl%outer(NTENC)%x(:, 1:npl) = pl%xh(:, 1:npl) + pl%outer(NTENC)%x(:, 1:npl) = pl%rh(:, 1:npl) pl%outer(NTENC)%v(:, 1:npl) = pl%vh(:, 1:npl) call rmvs_interp_out(cb, pl, dt) call rmvs_step_out(cb, pl, tp, system, param, t, dt) @@ -96,7 +96,7 @@ subroutine rmvs_interp_out(cb, pl, dt) dntenc = real(NTENC, kind=DP) associate (npl => pl%nbody) - allocate(xtmp, mold = pl%xh) + allocate(xtmp, mold = pl%rh) allocate(vtmp, mold = pl%vh) allocate(GMcb(npl)) allocate(dto(npl)) @@ -247,7 +247,7 @@ subroutine rmvs_interp_in(cb, pl, system, param, dt, outer_index) pl%inner(NTPHENC)%x(:, 1:npl) = pl%outer(outer_index)%x(:, 1:npl) pl%inner(NTPHENC)%v(:, 1:npl) = pl%outer(outer_index)%v(:, 1:npl) - allocate(xtmp,mold=pl%xh) + allocate(xtmp,mold=pl%rh) allocate(vtmp,mold=pl%vh) allocate(GMcb(npl)) allocate(dti(npl)) @@ -258,9 +258,9 @@ subroutine rmvs_interp_in(cb, pl, system, param, dt, outer_index) vtmp(:, 1:npl) = pl%inner(0)%v(:, 1:npl) if ((param%loblatecb) .or. (param%ltides)) then - allocate(xh_original, source=pl%xh) + allocate(xh_original, source=pl%rh) allocate(ah_original, source=pl%ah) - pl%xh(:, 1:npl) = xtmp(:, 1:npl) ! Temporarily replace heliocentric position with inner substep values to calculate the oblateness terms + pl%rh(:, 1:npl) = xtmp(:, 1:npl) ! Temporarily replace heliocentric position with inner substep values to calculate the oblateness terms end if if (param%loblatecb) then call pl%accel_obl(system) @@ -317,7 +317,7 @@ subroutine rmvs_interp_in(cb, pl, system, param, dt, outer_index) pl%inner(inner_index)%v(:, 1:npl) = pl%inner(inner_index)%v(:, 1:npl) + frac * vtmp(:, 1:npl) if (param%loblatecb) then - pl%xh(:,1:npl) = pl%inner(inner_index)%x(:, 1:npl) + pl%rh(:,1:npl) = pl%inner(inner_index)%x(:, 1:npl) call pl%accel_obl(system) pl%inner(inner_index)%aobl(:, 1:npl) = pl%aobl(:, 1:npl) end if @@ -329,7 +329,7 @@ subroutine rmvs_interp_in(cb, pl, system, param, dt, outer_index) end do if (param%loblatecb) then ! Calculate the final value of oblateness accelerations at the final inner substep - pl%xh(:, 1:npl) = pl%inner(NTPHENC)%x(:, 1:npl) + pl%rh(:, 1:npl) = pl%inner(NTPHENC)%x(:, 1:npl) call pl%accel_obl(system) pl%inner(NTPHENC)%aobl(:, 1:npl) = pl%aobl(:, 1:npl) end if @@ -339,7 +339,7 @@ subroutine rmvs_interp_in(cb, pl, system, param, dt, outer_index) ! pl%inner(NTPHENC)%atide(:, 1:npl) = pl%atide(:, 1:npl) ! end if ! Put the planet positions and accelerations back into place - if (allocated(xh_original)) call move_alloc(xh_original, pl%xh) + if (allocated(xh_original)) call move_alloc(xh_original, pl%rh) if (allocated(ah_original)) call move_alloc(ah_original, pl%ah) end associate return @@ -388,7 +388,7 @@ subroutine rmvs_step_in(cb, pl, tp, param, outer_time, dto) ! now step the encountering test particles fully through the inner encounter lfirsttp = .true. do inner_index = 1, NTPHENC ! Integrate over the encounter region, using the "substitute" planetocentric systems at each level - plenci%xh(:, 1:npl) = plenci%inner(inner_index - 1)%x(:, 1:npl) + plenci%rh(:, 1:npl) = plenci%inner(inner_index - 1)%x(:, 1:npl) call plenci%set_beg_end(xbeg = plenci%inner(inner_index - 1)%x, & xend = plenci%inner(inner_index)%x) @@ -403,7 +403,7 @@ subroutine rmvs_step_in(cb, pl, tp, param, outer_time, dto) call tpenci%step(planetocen_system, param, inner_time, dti) do j = 1, pl%nenc(i) - tpenci%xheliocentric(:, j) = tpenci%xh(:, j) + pl%inner(inner_index)%x(:,i) + tpenci%xheliocentric(:, j) = tpenci%rh(:, j) + pl%inner(inner_index)%x(:,i) end do inner_time = outer_time + j * dti call rmvs_peri_tp(tpenci, pl, inner_time, dti, .false., inner_index, i, param) @@ -464,8 +464,8 @@ subroutine rmvs_make_planetocentric(param, cb, pl, tp) ! Grab all the encountering test particles and convert them to a planetocentric frame tpenci%id(1:nenci) = pack(tp%id(1:ntp), encmask(1:ntp)) do j = 1, NDIM - tpenci%xheliocentric(j, 1:nenci) = pack(tp%xh(j,1:ntp), encmask(:)) - tpenci%xh(j, 1:nenci) = tpenci%xheliocentric(j, 1:nenci) - pl%inner(0)%x(j, i) + tpenci%xheliocentric(j, 1:nenci) = pack(tp%rh(j,1:ntp), encmask(:)) + tpenci%rh(j, 1:nenci) = tpenci%xheliocentric(j, 1:nenci) - pl%inner(0)%x(j, i) tpenci%vh(j, 1:nenci) = pack(tp%vh(j, 1:ntp), encmask(1:ntp)) - pl%inner(0)%v(j, i) end do tpenci%lperi(1:nenci) = pack(tp%lperi(1:ntp), encmask(1:ntp)) @@ -538,7 +538,7 @@ subroutine rmvs_peri_tp(tp, pl, t, dt, lfirst, inner_index, ipleP, param) rhill2 = pl%rhill(ipleP)**2 mu = pl%Gmass(ipleP) - associate(nenc => tp%nbody, xpc => tp%xh, vpc => tp%vh) + associate(nenc => tp%nbody, xpc => tp%rh, vpc => tp%vh) if (lfirst) then do i = 1, nenc if (tp%lmask(i)) then @@ -625,7 +625,7 @@ subroutine rmvs_end_planetocentric(pl, tp) tp%status(tpind(1:nenci)) = tpenci%status(1:nenci) tp%lmask(tpind(1:nenci)) = tpenci%lmask(1:nenci) do j = 1, NDIM - tp%xh(j, tpind(1:nenci)) = tpenci%xh(j,1:nenci) + pl%inner(NTPHENC)%x(j, i) + tp%rh(j, tpind(1:nenci)) = tpenci%rh(j,1:nenci) + pl%inner(NTPHENC)%x(j, i) tp%vh(j, tpind(1:nenci)) = tpenci%vh(j,1:nenci) + pl%inner(NTPHENC)%v(j, i) end do tp%lperi(tpind(1:nenci)) = tpenci%lperi(1:nenci) diff --git a/src/setup/setup.f90 b/src/setup/setup.f90 index 655d15b58..26aed237c 100644 --- a/src/setup/setup.f90 +++ b/src/setup/setup.f90 @@ -113,14 +113,14 @@ module subroutine setup_initialize_particle_info_system(self, param) associate(cb => self%cb, pl => self%pl, npl => self%pl%nbody, tp => self%tp, ntp => self%tp%nbody) call cb%info%set_value(particle_type=CB_TYPE_NAME, status="ACTIVE", origin_type="Initial conditions", & - origin_time=param%t0, origin_xh=[0.0_DP, 0.0_DP, 0.0_DP], origin_vh=[0.0_DP, 0.0_DP, 0.0_DP]) + origin_time=param%t0, origin_rh=[0.0_DP, 0.0_DP, 0.0_DP], origin_vh=[0.0_DP, 0.0_DP, 0.0_DP]) do i = 1, self%pl%nbody call pl%info(i)%set_value(particle_type=PL_TYPE_NAME, status="ACTIVE", origin_type="Initial conditions", & - origin_time=param%t0, origin_xh=self%pl%xh(:,i), origin_vh=self%pl%vh(:,i)) + origin_time=param%t0, origin_rh=self%pl%rh(:,i), origin_vh=self%pl%vh(:,i)) end do do i = 1, self%tp%nbody call tp%info(i)%set_value(particle_type=TP_TYPE_NAME, status="ACTIVE", origin_type="Initial conditions", & - origin_time=param%t0, origin_xh=self%tp%xh(:,i), origin_vh=self%tp%vh(:,i)) + origin_time=param%t0, origin_rh=self%tp%rh(:,i), origin_vh=self%tp%vh(:,i)) end do end associate @@ -193,7 +193,7 @@ module subroutine setup_body(self, n, param) allocate(self%ldiscard(n)) allocate(self%lmask(n)) allocate(self%mu(n)) - allocate(self%xh(NDIM, n)) + allocate(self%rh(NDIM, n)) allocate(self%vh(NDIM, n)) allocate(self%xb(NDIM, n)) allocate(self%vb(NDIM, n)) @@ -210,10 +210,10 @@ module subroutine setup_body(self, n, param) origin_type = "UNKNOWN", & collision_id = 0, & origin_time = -huge(1.0_DP), & - origin_xh = [0.0_DP, 0.0_DP, 0.0_DP], & + origin_rh = [0.0_DP, 0.0_DP, 0.0_DP], & origin_vh = [0.0_DP, 0.0_DP, 0.0_DP], & discard_time = -huge(1.0_DP), & - discard_xh = [0.0_DP, 0.0_DP, 0.0_DP], & + discard_rh = [0.0_DP, 0.0_DP, 0.0_DP], & discard_vh = [0.0_DP, 0.0_DP, 0.0_DP], & discard_body_id = -1 & ) @@ -223,7 +223,7 @@ module subroutine setup_body(self, n, param) self%ldiscard(:) = .false. self%lmask(:) = .false. self%mu(:) = 0.0_DP - self%xh(:,:) = 0.0_DP + self%rh(:,:) = 0.0_DP self%vh(:,:) = 0.0_DP self%xb(:,:) = 0.0_DP self%vb(:,:) = 0.0_DP diff --git a/src/setup/symba_collision.f90 b/src/setup/symba_collision.f90 index e839af1de..c4d04ee75 100644 --- a/src/setup/symba_collision.f90 +++ b/src/setup/symba_collision.f90 @@ -314,7 +314,7 @@ module function symba_collision_check_encounter(self, system, param, t, dt, irec do concurrent(k = 1:nenc, lmask(k)) i = self%index1(k) j = self%index2(k) - xr(:) = pl%xh(:, i) - pl%xh(:, j) + xr(:) = pl%rh(:, i) - pl%rh(:, j) vr(:) = pl%vb(:, i) - pl%vb(:, j) rlim = pl%radius(i) + pl%radius(j) Gmtot = pl%Gmass(i) + pl%Gmass(j) @@ -325,7 +325,7 @@ module function symba_collision_check_encounter(self, system, param, t, dt, irec do concurrent(k = 1:nenc, lmask(k)) i = self%index1(k) j = self%index2(k) - xr(:) = pl%xh(:, i) - tp%xh(:, j) + xr(:) = pl%rh(:, i) - tp%rh(:, j) vr(:) = pl%vb(:, i) - tp%vb(:, j) lcollision(k) = symba_collision_check_one(xr(1), xr(2), xr(3), vr(1), vr(2), vr(3), & pl%Gmass(i), pl%radius(i), dt, self%lvdotr(k)) @@ -340,10 +340,10 @@ module function symba_collision_check_encounter(self, system, param, t, dt, irec j = self%index2(k) if (lcollision(k)) self%status(k) = COLLISION self%t(k) = t - self%x1(:,k) = pl%xh(:,i) + system%cb%xb(:) + self%x1(:,k) = pl%rh(:,i) + system%cb%xb(:) self%v1(:,k) = pl%vb(:,i) if (isplpl) then - self%x2(:,k) = pl%xh(:,j) + system%cb%xb(:) + self%x2(:,k) = pl%rh(:,j) + system%cb%xb(:) self%v2(:,k) = pl%vb(:,j) if (lcollision(k)) then ! Check to see if either of these bodies has been involved with a collision before, and if so, make this a collisional colliders%idx @@ -352,11 +352,11 @@ module function symba_collision_check_encounter(self, system, param, t, dt, irec ! Set the collision flag for these to bodies to true in case they become involved in another collision later in the step pl%lcollision([i, j]) = .true. pl%status([i, j]) = COLLISION - call pl%info(i)%set_value(status="COLLISION", discard_time=t, discard_xh=pl%xh(:,i), discard_vh=pl%vh(:,i)) - call pl%info(j)%set_value(status="COLLISION", discard_time=t, discard_xh=pl%xh(:,j), discard_vh=pl%vh(:,j)) + call pl%info(i)%set_value(status="COLLISION", discard_time=t, discard_rh=pl%rh(:,i), discard_vh=pl%vh(:,i)) + call pl%info(j)%set_value(status="COLLISION", discard_time=t, discard_rh=pl%rh(:,j), discard_vh=pl%vh(:,j)) end if else - self%x2(:,k) = tp%xh(:,j) + system%cb%xb(:) + self%x2(:,k) = tp%rh(:,j) + system%cb%xb(:) self%v2(:,k) = tp%vb(:,j) if (lcollision(k)) then tp%status(j) = DISCARDED_PLR @@ -364,7 +364,7 @@ module function symba_collision_check_encounter(self, system, param, t, dt, irec write(idstri, *) pl%id(i) write(idstrj, *) tp%id(j) write(timestr, *) t - call tp%info(j)%set_value(status="DISCARDED_PLR", discard_time=t, discard_xh=tp%xh(:,j), discard_vh=tp%vh(:,j)) + call tp%info(j)%set_value(status="DISCARDED_PLR", discard_time=t, discard_rh=tp%rh(:,j), discard_vh=tp%vh(:,j)) write(message, *) "Particle " // trim(adjustl(tp%info(j)%name)) // " (" // trim(adjustl(idstrj)) // ")" & // " collided with massive body " // trim(adjustl(pl%info(i)%name)) // " (" // trim(adjustl(idstri)) // ")" & // " at t = " // trim(adjustl(timestr)) @@ -508,7 +508,7 @@ function symba_collision_consolidate_colliders(pl, cb, param, idx_parent, collid ! Find the barycenter of each body along with its children, if it has any do j = 1, 2 - colliders%xb(:, j) = pl%xh(:, idx_parent(j)) + cb%xb(:) + colliders%xb(:, j) = pl%rh(:, idx_parent(j)) + cb%xb(:) colliders%vb(:, j) = pl%vb(:, idx_parent(j)) ! Assume principal axis rotation about axis corresponding to highest moment of inertia (3rd Ip) if (param%lrotation) then @@ -521,7 +521,7 @@ function symba_collision_consolidate_colliders(pl, cb, param, idx_parent, collid idx_child = parent_child_index_array(j)%idx(i + 1) if (.not. pl%lcollision(idx_child)) cycle mchild = pl%mass(idx_child) - xchild(:) = pl%xh(:, idx_child) + cb%xb(:) + xchild(:) = pl%rh(:, idx_child) + cb%xb(:) vchild(:) = pl%vb(:, idx_child) volchild = (4.0_DP / 3.0_DP) * PI * pl%radius(idx_child)**3 volume(j) = volume(j) + volchild @@ -747,7 +747,7 @@ subroutine symba_collision_mergeaddsub(system, param, colliders, frag, status) call pl%vb2vh(cb) call pl%xh2xb(cb) do i = 1, nfrag - plnew%xh(:,i) = frag%xb(:, i) - cb%xb(:) + plnew%rh(:,i) = frag%xb(:, i) - cb%xb(:) plnew%vh(:,i) = frag%vb(:, i) - cb%vb(:) end do plnew%mass(1:nfrag) = frag%mass(1:nfrag) @@ -762,7 +762,7 @@ subroutine symba_collision_mergeaddsub(system, param, colliders, frag, status) do i = 1, nfrag write(newname, FRAGFMT) frag%id(i) call plnew%info(i)%set_value(origin_type="Disruption", origin_time=system%t, name=newname, & - origin_xh=plnew%xh(:,i), & + origin_rh=plnew%rh(:,i), & origin_vh=plnew%vh(:,i), collision_id=param%maxid_collision) end do do i = 1, ncolliders @@ -772,14 +772,14 @@ subroutine symba_collision_mergeaddsub(system, param, colliders, frag, status) iother = ibiggest end if call pl%info(colliders%idx(i))%set_value(status="Disruption", discard_time=system%t, & - discard_xh=pl%xh(:,i), discard_vh=pl%vh(:,i), discard_body_id=iother) + discard_rh=pl%rh(:,i), discard_vh=pl%vh(:,i), discard_body_id=iother) end do case(SUPERCATASTROPHIC) plnew%status(1:nfrag) = NEW_PARTICLE do i = 1, nfrag write(newname, FRAGFMT) frag%id(i) call plnew%info(i)%set_value(origin_type="Supercatastrophic", origin_time=system%t, name=newname, & - origin_xh=plnew%xh(:,i), origin_vh=plnew%vh(:,i), & + origin_rh=plnew%rh(:,i), origin_vh=plnew%vh(:,i), & collision_id=param%maxid_collision) end do do i = 1, ncolliders @@ -789,7 +789,7 @@ subroutine symba_collision_mergeaddsub(system, param, colliders, frag, status) iother = ibiggest end if call pl%info(colliders%idx(i))%set_value(status="Supercatastrophic", discard_time=system%t, & - discard_xh=pl%xh(:,i), discard_vh=pl%vh(:,i), & + discard_rh=pl%rh(:,i), discard_vh=pl%vh(:,i), & discard_body_id=iother) end do case(HIT_AND_RUN_DISRUPT) @@ -798,14 +798,14 @@ subroutine symba_collision_mergeaddsub(system, param, colliders, frag, status) do i = 2, nfrag write(newname, FRAGFMT) frag%id(i) call plnew%info(i)%set_value(origin_type="Hit and run fragment", origin_time=system%t, name=newname, & - origin_xh=plnew%xh(:,i), origin_vh=plnew%vh(:,i), & + origin_rh=plnew%rh(:,i), origin_vh=plnew%vh(:,i), & collision_id=param%maxid_collision) end do do i = 1, ncolliders if (colliders%idx(i) == ibiggest) cycle iother = ibiggest call pl%info(colliders%idx(i))%set_value(status="Hit and run fragmention", discard_time=system%t, & - discard_xh=pl%xh(:,i), discard_vh=pl%vh(:,i), & + discard_rh=pl%rh(:,i), discard_vh=pl%vh(:,i), & discard_body_id=iother) end do case(MERGED) @@ -815,7 +815,7 @@ subroutine symba_collision_mergeaddsub(system, param, colliders, frag, status) if (colliders%idx(i) == ibiggest) cycle iother = ibiggest - call pl%info(colliders%idx(i))%set_value(status="MERGED", discard_time=system%t, discard_xh=pl%xh(:,i), & + call pl%info(colliders%idx(i))%set_value(status="MERGED", discard_time=system%t, discard_rh=pl%rh(:,i), & discard_vh=pl%vh(:,i), discard_body_id=iother) end do end select diff --git a/src/symba/symba_collision.f90 b/src/symba/symba_collision.f90 index 04ec18b46..06c474078 100644 --- a/src/symba/symba_collision.f90 +++ b/src/symba/symba_collision.f90 @@ -314,7 +314,7 @@ module function symba_collision_check_encounter(self, system, param, t, dt, irec do concurrent(k = 1:nenc, lmask(k)) i = self%index1(k) j = self%index2(k) - xr(:) = pl%xh(:, i) - pl%xh(:, j) + xr(:) = pl%rh(:, i) - pl%rh(:, j) vr(:) = pl%vb(:, i) - pl%vb(:, j) rlim = pl%radius(i) + pl%radius(j) Gmtot = pl%Gmass(i) + pl%Gmass(j) @@ -325,7 +325,7 @@ module function symba_collision_check_encounter(self, system, param, t, dt, irec do concurrent(k = 1:nenc, lmask(k)) i = self%index1(k) j = self%index2(k) - xr(:) = pl%xh(:, i) - tp%xh(:, j) + xr(:) = pl%rh(:, i) - tp%rh(:, j) vr(:) = pl%vb(:, i) - tp%vb(:, j) lcollision(k) = symba_collision_check_one(xr(1), xr(2), xr(3), vr(1), vr(2), vr(3), & pl%Gmass(i), pl%radius(i), dt, self%lvdotr(k)) @@ -340,10 +340,10 @@ module function symba_collision_check_encounter(self, system, param, t, dt, irec j = self%index2(k) if (lcollision(k)) self%status(k) = COLLISION self%tcollision(k) = t - self%x1(:,k) = pl%xh(:,i) + system%cb%xb(:) + self%x1(:,k) = pl%rh(:,i) + system%cb%xb(:) self%v1(:,k) = pl%vb(:,i) if (isplpl) then - self%x2(:,k) = pl%xh(:,j) + system%cb%xb(:) + self%x2(:,k) = pl%rh(:,j) + system%cb%xb(:) self%v2(:,k) = pl%vb(:,j) if (lcollision(k)) then ! Check to see if either of these bodies has been involved with a collision before, and if so, make this a collisional colliders%idx @@ -352,11 +352,11 @@ module function symba_collision_check_encounter(self, system, param, t, dt, irec ! Set the collision flag for these to bodies to true in case they become involved in another collision later in the step pl%lcollision([i, j]) = .true. pl%status([i, j]) = COLLISION - call pl%info(i)%set_value(status="COLLISION", discard_time=t, discard_xh=pl%xh(:,i), discard_vh=pl%vh(:,i)) - call pl%info(j)%set_value(status="COLLISION", discard_time=t, discard_xh=pl%xh(:,j), discard_vh=pl%vh(:,j)) + call pl%info(i)%set_value(status="COLLISION", discard_time=t, discard_rh=pl%rh(:,i), discard_vh=pl%vh(:,i)) + call pl%info(j)%set_value(status="COLLISION", discard_time=t, discard_rh=pl%rh(:,j), discard_vh=pl%vh(:,j)) end if else - self%x2(:,k) = tp%xh(:,j) + system%cb%xb(:) + self%x2(:,k) = tp%rh(:,j) + system%cb%xb(:) self%v2(:,k) = tp%vb(:,j) if (lcollision(k)) then tp%status(j) = DISCARDED_PLR @@ -364,7 +364,7 @@ module function symba_collision_check_encounter(self, system, param, t, dt, irec write(idstri, *) pl%id(i) write(idstrj, *) tp%id(j) write(timestr, *) t - call tp%info(j)%set_value(status="DISCARDED_PLR", discard_time=t, discard_xh=tp%xh(:,j), discard_vh=tp%vh(:,j)) + call tp%info(j)%set_value(status="DISCARDED_PLR", discard_time=t, discard_rh=tp%rh(:,j), discard_vh=tp%vh(:,j)) write(message, *) "Particle " // trim(adjustl(tp%info(j)%name)) // " (" // trim(adjustl(idstrj)) // ")" & // " collided with massive body " // trim(adjustl(pl%info(i)%name)) // " (" // trim(adjustl(idstri)) // ")" & // " at t = " // trim(adjustl(timestr)) @@ -508,7 +508,7 @@ function symba_collision_consolidate_colliders(pl, cb, param, idx_parent, collid ! Find the barycenter of each body along with its children, if it has any do j = 1, 2 - colliders%xb(:, j) = pl%xh(:, idx_parent(j)) + cb%xb(:) + colliders%xb(:, j) = pl%rh(:, idx_parent(j)) + cb%xb(:) colliders%vb(:, j) = pl%vb(:, idx_parent(j)) ! Assume principal axis rotation about axis corresponding to highest moment of inertia (3rd Ip) if (param%lrotation) then @@ -521,7 +521,7 @@ function symba_collision_consolidate_colliders(pl, cb, param, idx_parent, collid idx_child = parent_child_index_array(j)%idx(i + 1) if (.not. pl%lcollision(idx_child)) cycle mchild = pl%mass(idx_child) - xchild(:) = pl%xh(:, idx_child) + cb%xb(:) + xchild(:) = pl%rh(:, idx_child) + cb%xb(:) vchild(:) = pl%vb(:, idx_child) volchild = (4.0_DP / 3.0_DP) * PI * pl%radius(idx_child)**3 volume(j) = volume(j) + volchild @@ -747,7 +747,7 @@ subroutine symba_collision_mergeaddsub(system, param, colliders, frag, status) call pl%vb2vh(cb) call pl%xh2xb(cb) do i = 1, nfrag - plnew%xh(:,i) = frag%xb(:, i) - cb%xb(:) + plnew%rh(:,i) = frag%xb(:, i) - cb%xb(:) plnew%vh(:,i) = frag%vb(:, i) - cb%vb(:) end do plnew%mass(1:nfrag) = frag%mass(1:nfrag) @@ -762,7 +762,7 @@ subroutine symba_collision_mergeaddsub(system, param, colliders, frag, status) do i = 1, nfrag write(newname, FRAGFMT) frag%id(i) call plnew%info(i)%set_value(origin_type="Disruption", origin_time=system%t, name=newname, & - origin_xh=plnew%xh(:,i), & + origin_rh=plnew%rh(:,i), & origin_vh=plnew%vh(:,i), collision_id=param%maxid_collision) end do do i = 1, ncolliders @@ -772,14 +772,14 @@ subroutine symba_collision_mergeaddsub(system, param, colliders, frag, status) iother = ibiggest end if call pl%info(colliders%idx(i))%set_value(status="Disruption", discard_time=system%t, & - discard_xh=pl%xh(:,i), discard_vh=pl%vh(:,i), discard_body_id=iother) + discard_rh=pl%rh(:,i), discard_vh=pl%vh(:,i), discard_body_id=iother) end do case(SUPERCATASTROPHIC) plnew%status(1:nfrag) = NEW_PARTICLE do i = 1, nfrag write(newname, FRAGFMT) frag%id(i) call plnew%info(i)%set_value(origin_type="Supercatastrophic", origin_time=system%t, name=newname, & - origin_xh=plnew%xh(:,i), origin_vh=plnew%vh(:,i), & + origin_rh=plnew%rh(:,i), origin_vh=plnew%vh(:,i), & collision_id=param%maxid_collision) end do do i = 1, ncolliders @@ -789,7 +789,7 @@ subroutine symba_collision_mergeaddsub(system, param, colliders, frag, status) iother = ibiggest end if call pl%info(colliders%idx(i))%set_value(status="Supercatastrophic", discard_time=system%t, & - discard_xh=pl%xh(:,i), discard_vh=pl%vh(:,i), & + discard_rh=pl%rh(:,i), discard_vh=pl%vh(:,i), & discard_body_id=iother) end do case(HIT_AND_RUN_DISRUPT) @@ -798,14 +798,14 @@ subroutine symba_collision_mergeaddsub(system, param, colliders, frag, status) do i = 2, nfrag write(newname, FRAGFMT) frag%id(i) call plnew%info(i)%set_value(origin_type="Hit and run fragment", origin_time=system%t, name=newname, & - origin_xh=plnew%xh(:,i), origin_vh=plnew%vh(:,i), & + origin_rh=plnew%rh(:,i), origin_vh=plnew%vh(:,i), & collision_id=param%maxid_collision) end do do i = 1, ncolliders if (colliders%idx(i) == ibiggest) cycle iother = ibiggest call pl%info(colliders%idx(i))%set_value(status="Hit and run fragmention", discard_time=system%t, & - discard_xh=pl%xh(:,i), discard_vh=pl%vh(:,i), & + discard_rh=pl%rh(:,i), discard_vh=pl%vh(:,i), & discard_body_id=iother) end do case(MERGED) @@ -815,7 +815,7 @@ subroutine symba_collision_mergeaddsub(system, param, colliders, frag, status) if (colliders%idx(i) == ibiggest) cycle iother = ibiggest - call pl%info(colliders%idx(i))%set_value(status="MERGED", discard_time=system%t, discard_xh=pl%xh(:,i), & + call pl%info(colliders%idx(i))%set_value(status="MERGED", discard_time=system%t, discard_rh=pl%rh(:,i), & discard_vh=pl%vh(:,i), discard_body_id=iother) end do end select diff --git a/src/symba/symba_discard.f90 b/src/symba/symba_discard.f90 index 76bcbaf41..a380487f7 100644 --- a/src/symba/symba_discard.f90 +++ b/src/symba/symba_discard.f90 @@ -38,7 +38,7 @@ subroutine symba_discard_cb_pl(pl, system, param) rmaxu2 = param%rmaxu**2 do i = 1, npl if (pl%status(i) == ACTIVE) then - rh2 = dot_product(pl%xh(:,i), pl%xh(:,i)) + rh2 = dot_product(pl%rh(:,i), pl%rh(:,i)) if ((param%rmax >= 0.0_DP) .and. (rh2 > rmax2)) then pl%ldiscard(i) = .true. pl%lcollision(i) = .false. @@ -54,7 +54,7 @@ subroutine symba_discard_cb_pl(pl, system, param) call io_log_one_message(FRAGGLE_LOG_OUT, "***********************************************************" // & "***********************************************************") call io_log_one_message(FRAGGLE_LOG_OUT, "") - call pl%info(i)%set_value(status="DISCARDED_RMAX", discard_time=system%t, discard_xh=pl%xh(:,i), & + call pl%info(i)%set_value(status="DISCARDED_RMAX", discard_time=system%t, discard_rh=pl%rh(:,i), & discard_vh=pl%vh(:,i)) else if ((param%rmin >= 0.0_DP) .and. (rh2 < rmin2)) then pl%ldiscard(i) = .true. @@ -71,7 +71,7 @@ subroutine symba_discard_cb_pl(pl, system, param) call io_log_one_message(FRAGGLE_LOG_OUT, "************************************************************" // & "************************************************************") call io_log_one_message(FRAGGLE_LOG_OUT, "") - call pl%info(i)%set_value(status="DISCARDED_RMIN", discard_time=system%t, discard_xh=pl%xh(:,i), & + call pl%info(i)%set_value(status="DISCARDED_RMIN", discard_time=system%t, discard_rh=pl%rh(:,i), & discard_vh=pl%vh(:,i), discard_body_id=cb%id) else if (param%rmaxu >= 0.0_DP) then rb2 = dot_product(pl%xb(:,i), pl%xb(:,i)) @@ -92,7 +92,7 @@ subroutine symba_discard_cb_pl(pl, system, param) call io_log_one_message(FRAGGLE_LOG_OUT, "************************************************************" // & "************************************************************") call io_log_one_message(FRAGGLE_LOG_OUT, "") - call pl%info(i)%set_value(status="DISCARDED_RMAXU", discard_time=system%t, discard_xh=pl%xh(:,i), & + call pl%info(i)%set_value(status="DISCARDED_RMAXU", discard_time=system%t, discard_rh=pl%rh(:,i), & discard_vh=pl%vh(:,i)) end if end if @@ -330,7 +330,7 @@ subroutine symba_discard_peri_pl(pl, system, param) write(*, *) trim(adjustl(pl%info(i)%name)) // " (" // trim(adjustl(idstr)) // & ") perihelion distance too small at t = " // trim(adjustl(timestr)) call pl%info(i)%set_value(status="DISCARDED_PERI", discard_time=system%t, & - discard_xh=pl%xh(:,i), discard_vh=pl%vh(:,i), discard_body_id=system%cb%id) + discard_rh=pl%rh(:,i), discard_vh=pl%vh(:,i), discard_body_id=system%cb%id) end if end if end if diff --git a/src/symba/symba_encounter_check.f90 b/src/symba/symba_encounter_check.f90 index 1cfa81c88..b955d4998 100644 --- a/src/symba/symba_encounter_check.f90 +++ b/src/symba/symba_encounter_check.f90 @@ -43,9 +43,9 @@ module function symba_encounter_check_pl(self, param, system, dt, irec) result(l call pl%set_renc(irec) if (nplt == 0) then - call encounter_check_all_plpl(param, npl, pl%xh, pl%vb, pl%renc, dt, nenc, index1, index2, lvdotr) + call encounter_check_all_plpl(param, npl, pl%rh, pl%vb, pl%renc, dt, nenc, index1, index2, lvdotr) else - call encounter_check_all_plplm(param, nplm, nplt, pl%xh(:,1:nplm), pl%vb(:,1:nplm), pl%xh(:,nplm+1:npl), & + call encounter_check_all_plplm(param, nplm, nplt, pl%rh(:,1:nplm), pl%vb(:,1:nplm), pl%rh(:,nplm+1:npl), & pl%vb(:,nplm+1:npl), pl%renc(1:nplm), pl%renc(nplm+1:npl), dt, nenc, index1, index2, lvdotr) end if @@ -65,8 +65,8 @@ module function symba_encounter_check_pl(self, param, system, dt, irec) result(l plplenc_list%id2(k) = pl%id(j) plplenc_list%status(k) = ACTIVE plplenc_list%level(k) = irec - plplenc_list%x1(:,k) = pl%xh(:,i) - plplenc_list%x2(:,k) = pl%xh(:,j) + plplenc_list%x1(:,k) = pl%rh(:,i) + plplenc_list%x2(:,k) = pl%rh(:,j) plplenc_list%v1(:,k) = pl%vb(:,i) - cb%vb(:) plplenc_list%v2(:,k) = pl%vb(:,j) - cb%vb(:) plplenc_list%Gmass1(k) = pl%Gmass(i) @@ -151,7 +151,7 @@ module function symba_encounter_check(self, param, system, dt, irec) result(lany k = eidx(lidx) i = self%index1(k) j = self%index2(k) - xr(:) = pl%xh(:,j) - pl%xh(:,i) + xr(:) = pl%rh(:,j) - pl%rh(:,i) vr(:) = pl%vb(:,j) - pl%vb(:,i) rcrit12 = pl%renc(i) + pl%renc(j) call encounter_check_one(xr(1), xr(2), xr(3), vr(1), vr(2), vr(3), rcrit12, dt, lencounter(lidx), self%lvdotr(k)) @@ -166,7 +166,7 @@ module function symba_encounter_check(self, param, system, dt, irec) result(lany k = eidx(lidx) i = self%index1(k) j = self%index2(k) - xr(:) = tp%xh(:,j) - pl%xh(:,i) + xr(:) = tp%rh(:,j) - pl%rh(:,i) vr(:) = tp%vb(:,j) - pl%vb(:,i) call encounter_check_one(xr(1), xr(2), xr(3), vr(1), vr(2), vr(3), pl%renc(i), dt, & lencounter(lidx), self%lvdotr(k)) @@ -229,7 +229,7 @@ module function symba_encounter_check_tp(self, param, system, dt, irec) result(l associate(tp => self, ntp => self%nbody, pl => system%pl, npl => system%pl%nbody) call pl%set_renc(irec) - call encounter_check_all_pltp(param, npl, ntp, pl%xh, pl%vb, tp%xh, tp%vb, pl%renc, dt, nenc, index1, index2, lvdotr) + call encounter_check_all_pltp(param, npl, ntp, pl%rh, pl%vb, tp%rh, tp%vb, pl%renc, dt, nenc, index1, index2, lvdotr) lany_encounter = nenc > 0 if (lany_encounter) then diff --git a/src/symba/symba_kick.f90 b/src/symba/symba_kick.f90 index 476fd1697..114160f9a 100644 --- a/src/symba/symba_kick.f90 +++ b/src/symba/symba_kick.f90 @@ -42,9 +42,9 @@ module subroutine symba_kick_getacch_int_pl(self, param) end if if (param%lflatten_interactions) then - call kick_getacch_int_all_flat_pl(self%nbody, self%nplplm, self%k_plpl, self%xh, self%Gmass, self%radius, self%ah) + call kick_getacch_int_all_flat_pl(self%nbody, self%nplplm, self%k_plpl, self%rh, self%Gmass, self%radius, self%ah) else - call kick_getacch_int_all_triangular_pl(self%nbody, self%nplm, self%xh, self%Gmass, self%radius, self%ah) + call kick_getacch_int_all_triangular_pl(self%nbody, self%nplm, self%rh, self%Gmass, self%radius, self%ah) end if if (param%ladaptive_interactions .and. self%nplplm > 0) then @@ -87,7 +87,7 @@ module subroutine symba_kick_getacch_pl(self, system, param, t, lbeg) allocate(k_plpl_enc(2,nplplenc)) k_plpl_enc(1,1:nplplenc) = plplenc_list%index1(1:nplplenc) k_plpl_enc(2,1:nplplenc) = plplenc_list%index2(1:nplplenc) - call kick_getacch_int_all_flat_pl(npl, nplplenc, k_plpl_enc, pl%xh, pl%Gmass, pl%radius, ah_enc) + call kick_getacch_int_all_flat_pl(npl, nplplenc, k_plpl_enc, pl%rh, pl%Gmass, pl%radius, ah_enc) pl%ah(:,1:npl) = pl%ah(:,1:npl) - ah_enc(:,1:npl) end if @@ -129,9 +129,9 @@ module subroutine symba_kick_getacch_tp(self, system, param, t, lbeg) j = pltpenc_list%index2(k) if (tp%lmask(j)) then if (lbeg) then - dx(:) = tp%xh(:,j) - pl%xbeg(:,i) + dx(:) = tp%rh(:,j) - pl%xbeg(:,i) else - dx(:) = tp%xh(:,j) - pl%xend(:,i) + dx(:) = tp%rh(:,j) - pl%xend(:,i) end if rjj = dot_product(dx(:), dx(:)) fac = pl%Gmass(i) / (rjj * sqrt(rjj)) @@ -232,11 +232,11 @@ module subroutine symba_kick_encounter(self, system, dt, irec, sgn) if (isplpl) then ri = ((pl%rhill(i) + pl%rhill(j))**2) * (RHSCALE**2) * (RSHELL**(2*irecl)) rim1 = ri * (RSHELL**2) - dx(:) = pl%xh(:,j) - pl%xh(:,i) + dx(:) = pl%rh(:,j) - pl%rh(:,i) else ri = ((pl%rhill(i))**2) * (RHSCALE**2) * (RSHELL**(2*irecl)) rim1 = ri * (RSHELL**2) - dx(:) = tp%xh(:,j) - pl%xh(:,i) + dx(:) = tp%rh(:,j) - pl%rh(:,i) end if r2 = dot_product(dx(:), dx(:)) if (r2 < rim1) then diff --git a/src/symba/symba_util.f90 b/src/symba/symba_util.f90 index b7cc9c915..621287433 100644 --- a/src/symba/symba_util.f90 +++ b/src/symba/symba_util.f90 @@ -534,7 +534,7 @@ module subroutine symba_util_peri_pl(self, system, param) if (param%qmin_coord == "HELIO") then do i = 1, npl if (pl%status(i) == ACTIVE) then - vdotr = dot_product(pl%xh(:,i), pl%vh(:,i)) + vdotr = dot_product(pl%rh(:,i), pl%vh(:,i)) if (vdotr > 0.0_DP) then pl%isperi(i) = 1 else @@ -558,11 +558,11 @@ module subroutine symba_util_peri_pl(self, system, param) if (param%qmin_coord == "HELIO") then do i = 1, npl if (pl%status(i) == ACTIVE) then - vdotr = dot_product(pl%xh(:,i), pl%vh(:,i)) + vdotr = dot_product(pl%rh(:,i), pl%vh(:,i)) if (pl%isperi(i) == -1) then if (vdotr >= 0.0_DP) then pl%isperi(i) = 0 - CALL orbel_xv2aeq(pl%mu(i), pl%xh(1,i), pl%xh(2,i), pl%xh(3,i), pl%vh(1,i), pl%vh(2,i), pl%vh(3,i), & + CALL orbel_xv2aeq(pl%mu(i), pl%rh(1,i), pl%rh(2,i), pl%rh(3,i), pl%vh(1,i), pl%vh(2,i), pl%vh(3,i), & pl%atp(i), e, pl%peri(i)) end if else diff --git a/src/tides/tides_getacch_pl.f90 b/src/tides/tides_getacch_pl.f90 index 4feb76221..c37e84b88 100644 --- a/src/tides/tides_getacch_pl.f90 +++ b/src/tides/tides_getacch_pl.f90 @@ -29,9 +29,9 @@ module subroutine tides_kick_getacch_pl(self, system) pl%atide(:,:) = 0.0_DP cb%atide(:) = 0.0_DP do i = 1, npl - rmag = norm2(pl%xh(:,i)) + rmag = norm2(pl%rh(:,i)) vmag = norm2(pl%vh(:,i)) - r_unit(:) = pl%xh(:,i) / rmag + r_unit(:) = pl%rh(:,i) / rmag v_unit(:) = pl%vh(:,i) / vmag h_unit(:) = r_unit(:) .cross. v_unit(:) theta_unit(:) = h_unit(:) .cross. r_unit(:) diff --git a/src/util/util_append.f90 b/src/util/util_append.f90 index d59704374..a02b28f2b 100644 --- a/src/util/util_append.f90 +++ b/src/util/util_append.f90 @@ -209,7 +209,7 @@ module subroutine util_append_body(self, source, lsource_mask) call util_append(self%ldiscard, source%ldiscard, nold, nsrc, lsource_mask) call util_append(self%lmask, source%lmask, nold, nsrc, lsource_mask) call util_append(self%mu, source%mu, nold, nsrc, lsource_mask) - call util_append(self%xh, source%xh, nold, nsrc, lsource_mask) + call util_append(self%rh, source%rh, nold, nsrc, lsource_mask) call util_append(self%vh, source%vh, nold, nsrc, lsource_mask) call util_append(self%xb, source%xb, nold, nsrc, lsource_mask) call util_append(self%vb, source%vb, nold, nsrc, lsource_mask) diff --git a/src/util/util_coord.f90 b/src/util/util_coord.f90 index 21b57844d..98a5549ac 100644 --- a/src/util/util_coord.f90 +++ b/src/util/util_coord.f90 @@ -35,14 +35,14 @@ module subroutine util_coord_h2b_pl(self, cb) do i = 1, npl if (pl%status(i) == INACTIVE) cycle Gmtot = Gmtot + pl%Gmass(i) - xtmp(:) = xtmp(:) + pl%Gmass(i) * pl%xh(:,i) + xtmp(:) = xtmp(:) + pl%Gmass(i) * pl%rh(:,i) vtmp(:) = vtmp(:) + pl%Gmass(i) * pl%vh(:,i) end do cb%xb(:) = -xtmp(:) / Gmtot cb%vb(:) = -vtmp(:) / Gmtot do i = 1, npl if (pl%status(i) == INACTIVE) cycle - pl%xb(:,i) = pl%xh(:,i) + cb%xb(:) + pl%xb(:,i) = pl%rh(:,i) + cb%xb(:) pl%vb(:,i) = pl%vh(:,i) + cb%vb(:) end do end associate @@ -68,7 +68,7 @@ module subroutine util_coord_h2b_tp(self, cb) if (self%nbody == 0) return associate(tp => self, ntp => self%nbody) do concurrent (i = 1:ntp, tp%status(i) /= INACTIVE) - tp%xb(:, i) = tp%xh(:, i) + cb%xb(:) + tp%xb(:, i) = tp%rh(:, i) + cb%xb(:) tp%vb(:, i) = tp%vh(:, i) + cb%vb(:) end do end associate @@ -95,7 +95,7 @@ module subroutine util_coord_b2h_pl(self, cb) associate(pl => self, npl => self%nbody) do concurrent (i = 1:npl, pl%status(i) /= INACTIVE) - pl%xh(:, i) = pl%xb(:, i) - cb%xb(:) + pl%rh(:, i) = pl%xb(:, i) - cb%xb(:) pl%vh(:, i) = pl%vb(:, i) - cb%vb(:) end do end associate @@ -122,7 +122,7 @@ module subroutine util_coord_b2h_tp(self, cb) associate(tp => self, ntp => self%nbody) do concurrent(i = 1:ntp, tp%status(i) /= INACTIVE) - tp%xh(:, i) = tp%xb(:, i) - cb%xb(:) + tp%rh(:, i) = tp%xb(:, i) - cb%xb(:) tp%vh(:, i) = tp%vb(:, i) - cb%vb(:) end do end associate @@ -246,7 +246,7 @@ module subroutine util_coord_vh2vb_tp(self, vbcb) end subroutine util_coord_vh2vb_tp - module subroutine util_coord_xh2xb_pl(self, cb) + module subroutine util_coord_rh2xb_pl(self, cb) !! author: David A. Minton !! !! Convert position vectors of massive bodies from heliocentric to barycentric coordinates (position only) @@ -269,20 +269,20 @@ module subroutine util_coord_xh2xb_pl(self, cb) do i = 1, npl if (pl%status(i) == INACTIVE) cycle Gmtot = Gmtot + pl%Gmass(i) - xtmp(:) = xtmp(:) + pl%Gmass(i) * pl%xh(:,i) + xtmp(:) = xtmp(:) + pl%Gmass(i) * pl%rh(:,i) end do cb%xb(:) = -xtmp(:) / Gmtot do i = 1, npl if (pl%status(i) == INACTIVE) cycle - pl%xb(:,i) = pl%xh(:,i) + cb%xb(:) + pl%xb(:,i) = pl%rh(:,i) + cb%xb(:) end do end associate return - end subroutine util_coord_xh2xb_pl + end subroutine util_coord_rh2xb_pl - module subroutine util_coord_xh2xb_tp(self, cb) + module subroutine util_coord_rh2xb_tp(self, cb) !! author: David A. Minton !! !! Convert test particles from heliocentric to barycentric coordinates (position only) @@ -299,11 +299,11 @@ module subroutine util_coord_xh2xb_tp(self, cb) if (self%nbody == 0) return associate(tp => self, ntp => self%nbody) do concurrent (i = 1:ntp, tp%status(i) /= INACTIVE) - tp%xb(:, i) = tp%xh(:, i) + cb%xb(:) + tp%xb(:, i) = tp%rh(:, i) + cb%xb(:) end do end associate return - end subroutine util_coord_xh2xb_tp + end subroutine util_coord_rh2xb_tp end submodule s_util_coord \ No newline at end of file diff --git a/src/util/util_copy.f90 b/src/util/util_copy.f90 index 6674cf431..bef861d07 100644 --- a/src/util/util_copy.f90 +++ b/src/util/util_copy.f90 @@ -26,10 +26,10 @@ module subroutine util_copy_particle_info(self, source) origin_type = source%origin_type, & origin_time = source%origin_time, & collision_id = source%collision_id, & - origin_xh = source%origin_xh(:), & + origin_rh = source%origin_rh(:), & origin_vh = source%origin_vh(:), & discard_time = source%discard_time, & - discard_xh = source%discard_xh(:), & + discard_rh = source%discard_rh(:), & discard_vh = source%discard_vh(:), & discard_body_id = source%discard_body_id & ) diff --git a/src/util/util_dealloc.f90 b/src/util/util_dealloc.f90 index 107a7c478..b3fb38fd9 100644 --- a/src/util/util_dealloc.f90 +++ b/src/util/util_dealloc.f90 @@ -25,7 +25,7 @@ module subroutine util_dealloc_body(self) if (allocated(self%ldiscard)) deallocate(self%ldiscard) if (allocated(self%lmask)) deallocate(self%lmask) if (allocated(self%mu)) deallocate(self%mu) - if (allocated(self%xh)) deallocate(self%xh) + if (allocated(self%rh)) deallocate(self%rh) if (allocated(self%vh)) deallocate(self%vh) if (allocated(self%xb)) deallocate(self%xb) if (allocated(self%vb)) deallocate(self%vb) diff --git a/src/util/util_fill.f90 b/src/util/util_fill.f90 index deb78f4ee..9b542d19c 100644 --- a/src/util/util_fill.f90 +++ b/src/util/util_fill.f90 @@ -160,7 +160,7 @@ module subroutine util_fill_body(self, inserts, lfill_list) call util_fill(keeps%ldiscard, inserts%ldiscard, lfill_list) call util_fill(keeps%lmask, inserts%lmask, lfill_list) call util_fill(keeps%mu, inserts%mu, lfill_list) - call util_fill(keeps%xh, inserts%xh, lfill_list) + call util_fill(keeps%rh, inserts%rh, lfill_list) call util_fill(keeps%vh, inserts%vh, lfill_list) call util_fill(keeps%xb, inserts%xb, lfill_list) call util_fill(keeps%vb, inserts%vb, lfill_list) diff --git a/src/util/util_peri.f90 b/src/util/util_peri.f90 index bed29c58a..badd0e328 100644 --- a/src/util/util_peri.f90 +++ b/src/util/util_peri.f90 @@ -34,11 +34,11 @@ module subroutine util_peri_tp(self, system, param) allocate(vdotr(ntp)) if (param%qmin_coord == "HELIO") then do i = 1, ntp - vdotr(i) = dot_product(tp%xh(:, i), tp%vh(:, i)) + vdotr(i) = dot_product(tp%rh(:, i), tp%vh(:, i)) if (tp%isperi(i) == -1) then if (vdotr(i) >= 0.0_DP) then tp%isperi(i) = 0 - call orbel_xv2aeq(tp%mu(i), tp%xh(1,i), tp%xh(2,i), tp%xh(3,i), tp%vh(1,i), tp%vh(2,i), tp%vh(3,i), & + call orbel_xv2aeq(tp%mu(i), tp%rh(1,i), tp%rh(2,i), tp%rh(3,i), tp%vh(1,i), tp%vh(2,i), tp%vh(3,i), & tp%atp(i), e, tp%peri(i)) end if else diff --git a/src/util/util_rescale.f90 b/src/util/util_rescale.f90 index 482089859..deb3e0e1e 100644 --- a/src/util/util_rescale.f90 +++ b/src/util/util_rescale.f90 @@ -48,7 +48,7 @@ module subroutine util_rescale_system(self, param, mscale, dscale, tscale) pl%mass(1:npl) = pl%mass(1:npl) / mscale pl%Gmass(1:npl) = param%GU * pl%mass(1:npl) pl%radius(1:npl) = pl%radius(1:npl) / dscale - pl%xh(:,1:npl) = pl%xh(:,1:npl) / dscale + pl%rh(:,1:npl) = pl%rh(:,1:npl) / dscale pl%vh(:,1:npl) = pl%vh(:,1:npl) / vscale pl%xb(:,1:npl) = pl%xb(:,1:npl) / dscale pl%vb(:,1:npl) = pl%vb(:,1:npl) / vscale diff --git a/src/util/util_resize.f90 b/src/util/util_resize.f90 index 01cf544ac..eee6b0e4c 100644 --- a/src/util/util_resize.f90 +++ b/src/util/util_resize.f90 @@ -297,7 +297,7 @@ module subroutine util_resize_body(self, nnew) call util_resize(self%ldiscard, nnew) call util_resize(self%lmask, nnew) call util_resize(self%mu, nnew) - call util_resize(self%xh, nnew) + call util_resize(self%rh, nnew) call util_resize(self%vh, nnew) call util_resize(self%xb, nnew) call util_resize(self%vb, nnew) diff --git a/src/util/util_set.f90 b/src/util/util_set.f90 index 1a67efcbe..05e4b41f9 100644 --- a/src/util/util_set.f90 +++ b/src/util/util_set.f90 @@ -53,7 +53,7 @@ module subroutine util_set_ir3h(self) if (self%nbody > 0) then do i = 1, self%nbody - r2 = dot_product(self%xh(:, i), self%xh(:, i)) + r2 = dot_product(self%rh(:, i), self%rh(:, i)) irh = 1.0_DP / sqrt(r2) self%ir3h(i) = irh / r2 end do @@ -107,8 +107,8 @@ module subroutine util_set_mu_tp(self, cb) return end subroutine util_set_mu_tp - module subroutine util_set_particle_info(self, name, particle_type, status, origin_type, origin_time, collision_id, origin_xh,& - origin_vh, discard_time, discard_xh, discard_vh, discard_body_id) + module subroutine util_set_particle_info(self, name, particle_type, status, origin_type, origin_time, collision_id, origin_rh,& + origin_vh, discard_time, discard_rh, discard_vh, discard_body_id) !! author: David A. Minton !! !! Sets one or more values of the particle information metadata object @@ -121,10 +121,10 @@ module subroutine util_set_particle_info(self, name, particle_type, status, orig character(len=*), intent(in), optional :: origin_type !! String containing a description of the origin of the particle (e.g. Initial Conditions, Supercatastrophic, Disruption, etc.) real(DP), intent(in), optional :: origin_time !! The time of the particle's formation integer(I4B), intent(in), optional :: collision_id !! The ID fo the collision that formed the particle - real(DP), dimension(:), intent(in), optional :: origin_xh !! The heliocentric distance vector at the time of the particle's formation + real(DP), dimension(:), intent(in), optional :: origin_rh !! The heliocentric distance vector at the time of the particle's formation real(DP), dimension(:), intent(in), optional :: origin_vh !! The heliocentric velocity vector at the time of the particle's formation real(DP), intent(in), optional :: discard_time !! The time of the particle's discard - real(DP), dimension(:), intent(in), optional :: discard_xh !! The heliocentric distance vector at the time of the particle's discard + real(DP), dimension(:), intent(in), optional :: discard_rh !! The heliocentric distance vector at the time of the particle's discard real(DP), dimension(:), intent(in), optional :: discard_vh !! The heliocentric velocity vector at the time of the particle's discard integer(I4B), intent(in), optional :: discard_body_id !! The id of the other body involved in the discard (0 if no other body involved) ! Internals @@ -152,8 +152,8 @@ module subroutine util_set_particle_info(self, name, particle_type, status, orig if (present(collision_id)) then self%collision_id = collision_id end if - if (present(origin_xh)) then - self%origin_xh(:) = origin_xh(:) + if (present(origin_rh)) then + self%origin_rh(:) = origin_rh(:) end if if (present(origin_vh)) then self%origin_vh(:) = origin_vh(:) @@ -161,8 +161,8 @@ module subroutine util_set_particle_info(self, name, particle_type, status, orig if (present(discard_time)) then self%discard_time = discard_time end if - if (present(discard_xh)) then - self%discard_xh(:) = discard_xh(:) + if (present(discard_rh)) then + self%discard_rh(:) = discard_rh(:) end if if (present(discard_vh)) then self%discard_vh(:) = discard_vh(:) @@ -242,7 +242,7 @@ module subroutine util_set_rhill_approximate(self,cb) if (self%nbody == 0) return - rh(1:self%nbody) = .mag. self%xh(:,1:self%nbody) + rh(1:self%nbody) = .mag. self%rh(:,1:self%nbody) self%rhill(1:self%nbody) = rh(1:self%nbody) * (self%Gmass(1:self%nbody) / cb%Gmass / 3)**THIRD return diff --git a/src/util/util_sort.f90 b/src/util/util_sort.f90 index dde5d7dfe..b1500afab 100644 --- a/src/util/util_sort.f90 +++ b/src/util/util_sort.f90 @@ -51,7 +51,7 @@ module subroutine util_sort_body(self, sortby, ascending) call util_sort(direction * body%capom(1:n), ind) case("mu") call util_sort(direction * body%mu(1:n), ind) - case("lfirst", "nbody", "ldiscard", "xh", "vh", "xb", "vb", "ah", "aobl", "atide", "agr") + case("lfirst", "nbody", "ldiscard", "rh", "vh", "xb", "vb", "ah", "aobl", "atide", "agr") write(*,*) 'Cannot sort by ' // trim(adjustl(sortby)) // '. Component not sortable!' case default write(*,*) 'Cannot sort by ' // trim(adjustl(sortby)) // '. Component not found!' @@ -760,7 +760,7 @@ module subroutine util_sort_rearrange_body(self, ind) call util_sort_rearrange(self%info, ind, n) call util_sort_rearrange(self%status, ind, n) call util_sort_rearrange(self%ldiscard, ind, n) - call util_sort_rearrange(self%xh, ind, n) + call util_sort_rearrange(self%rh, ind, n) call util_sort_rearrange(self%vh, ind, n) call util_sort_rearrange(self%xb, ind, n) call util_sort_rearrange(self%vb, ind, n) diff --git a/src/util/util_spill.f90 b/src/util/util_spill.f90 index 63d7fe1d9..9b9208252 100644 --- a/src/util/util_spill.f90 +++ b/src/util/util_spill.f90 @@ -339,7 +339,7 @@ module subroutine util_spill_body(self, discards, lspill_list, ldestructive) call util_spill(keeps%lmask, discards%lmask, lspill_list, ldestructive) call util_spill(keeps%ldiscard, discards%ldiscard, lspill_list, ldestructive) call util_spill(keeps%mu, discards%mu, lspill_list, ldestructive) - call util_spill(keeps%xh, discards%xh, lspill_list, ldestructive) + call util_spill(keeps%rh, discards%rh, lspill_list, ldestructive) call util_spill(keeps%vh, discards%vh, lspill_list, ldestructive) call util_spill(keeps%xb, discards%xb, lspill_list, ldestructive) call util_spill(keeps%vb, discards%vb, lspill_list, ldestructive) diff --git a/src/whm/whm_coord.f90 b/src/whm/whm_coord.f90 index 2b888a279..4af8b56a9 100644 --- a/src/whm/whm_coord.f90 +++ b/src/whm/whm_coord.f90 @@ -31,18 +31,18 @@ module subroutine whm_coord_h2j_pl(self, cb) if (self%nbody == 0) return - associate(npl => self%nbody, GMpl => self%Gmass, eta => self%eta, xh => self%xh, vh => self%vh, & + associate(npl => self%nbody, GMpl => self%Gmass, eta => self%eta, rh => self%rh, vh => self%vh, & xj => self%xj, vj => self%vj) - xj(:, 1) = xh(:, 1) + xj(:, 1) = rh(:, 1) vj(:, 1) = vh(:, 1) sumx(:) = 0.0_DP sumv(:) = 0.0_DP do i = 2, npl - sumx(:) = sumx(:) + GMpl(i - 1) * xh(:, i - 1) + sumx(:) = sumx(:) + GMpl(i - 1) * rh(:, i - 1) sumv(:) = sumv(:) + GMpl(i - 1) * vh(:, i - 1) cap(:) = sumx(:) / eta(i - 1) capv(:) = sumv(:) / eta(i - 1) - xj(:, i) = xh(:, i) - cap(:) + xj(:, i) = rh(:, i) - cap(:) vj(:, i) = vh(:, i) - capv(:) end do end associate @@ -72,16 +72,16 @@ module subroutine whm_coord_j2h_pl(self, cb) if (self%nbody == 0) return - associate(npl => self%nbody, GMpl => self%Gmass, eta => self%eta, xh => self%xh, vh => self%vh, & + associate(npl => self%nbody, GMpl => self%Gmass, eta => self%eta, rh => self%rh, vh => self%vh, & xj => self%xj, vj => self%vj) - xh(:, 1) = xj(:, 1) + rh(:, 1) = xj(:, 1) vh(:, 1) = vj(:, 1) sumx(:) = 0.0_DP sumv(:) = 0.0_DP do i = 2, npl sumx(:) = sumx(:) + GMpl(i - 1) * xj(:, i - 1) / eta(i - 1) sumv(:) = sumv(:) + GMpl(i - 1) * vj(:, i - 1) / eta(i - 1) - xh(:, i) = xj(:, i) + sumx(:) + rh(:, i) = xj(:, i) + sumx(:) vh(:, i) = vj(:, i) + sumv(:) end do end associate diff --git a/src/whm/whm_gr.f90 b/src/whm/whm_gr.f90 index 02dc7d4a4..01bd6f285 100644 --- a/src/whm/whm_gr.f90 +++ b/src/whm/whm_gr.f90 @@ -62,7 +62,7 @@ pure module subroutine whm_gr_kick_getacch_tp(self, param) if (self%nbody == 0) return associate(tp => self, ntp => self%nbody, inv_c2 => param%inv_c2) - call gr_kick_getacch(tp%mu, tp%xh, tp%lmask, ntp, param%inv_c2, tp%agr) + call gr_kick_getacch(tp%mu, tp%rh, tp%lmask, ntp, param%inv_c2, tp%agr) tp%ah(:,1:ntp) = tp%ah(:,1:ntp) + tp%agr(:,1:ntp) end associate @@ -116,7 +116,7 @@ pure module subroutine whm_gr_p4_tp(self, system, param, dt) associate(tp => self, ntp => self%nbody) if (ntp == 0) return do concurrent(i = 1:ntp, tp%lmask(i)) - call gr_p4_pos_kick(param, tp%xh(:, i), tp%vh(:, i), dt) + call gr_p4_pos_kick(param, tp%rh(:, i), tp%vh(:, i), dt) end do end associate diff --git a/src/whm/whm_kick.f90 b/src/whm/whm_kick.f90 index 54a6ef621..d782c89f4 100644 --- a/src/whm/whm_kick.f90 +++ b/src/whm/whm_kick.f90 @@ -34,7 +34,7 @@ module subroutine whm_kick_getacch_pl(self, system, param, t, lbeg) associate(cb => system%cb, pl => self, npl => self%nbody) call pl%set_ir3() - ah0(:) = whm_kick_getacch_ah0(pl%Gmass(2:npl), pl%xh(:,2:npl), npl-1) + ah0(:) = whm_kick_getacch_ah0(pl%Gmass(2:npl), pl%rh(:,2:npl), npl-1) do i = 1, npl pl%ah(:, i) = pl%ah(:, i) + ah0(:) end do @@ -158,7 +158,7 @@ pure subroutine whm_kick_getacch_ah1(cb, pl) associate(npl => pl%nbody) do concurrent (i = 2:npl, pl%lmask(i)) ah1j(:) = pl%xj(:, i) * pl%ir3j(i) - ah1h(:) = pl%xh(:, i) * pl%ir3h(i) + ah1h(:) = pl%rh(:, i) * pl%ir3h(i) pl%ah(:, i) = pl%ah(:, i) + cb%Gmass * (ah1j(:) - ah1h(:)) end do end associate @@ -227,11 +227,11 @@ module subroutine whm_kick_vh_pl(self, system, param, t, dt, lbeg) call pl%accel(system, param, t, lbeg) pl%lfirst = .false. end if - call pl%set_beg_end(xbeg = pl%xh) + call pl%set_beg_end(xbeg = pl%rh) else pl%ah(:, 1:npl) = 0.0_DP call pl%accel(system, param, t, lbeg) - call pl%set_beg_end(xend = pl%xh) + call pl%set_beg_end(xend = pl%rh) end if do concurrent(i = 1:npl, pl%lmask(i)) pl%vh(:, i) = pl%vh(:, i) + pl%ah(:, i) * dt diff --git a/src/whm/whm_util.f90 b/src/whm/whm_util.f90 index 2143cf0e9..9c6efdd41 100644 --- a/src/whm/whm_util.f90 +++ b/src/whm/whm_util.f90 @@ -171,7 +171,7 @@ module subroutine whm_util_set_ir3j(self) if (self%nbody > 0) then do i = 1, self%nbody - r2 = dot_product(self%xh(:, i), self%xh(:, i)) + r2 = dot_product(self%rh(:, i), self%rh(:, i)) ir = 1.0_DP / sqrt(r2) self%ir3h(i) = ir / r2 r2 = dot_product(self%xj(:, i), self%xj(:, i))