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

Commit

Permalink
Fixed problems for runs where close encounter checks are turned off, …
Browse files Browse the repository at this point in the history
…and a bad deallocate statement on the gr and tide acceleration arrays
  • Loading branch information
daminton committed Oct 20, 2021
1 parent a90c125 commit 0f9bb1e
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 18 deletions.
22 changes: 16 additions & 6 deletions python/swiftest/swiftest/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,8 @@ def make_swiftest_labels(param):
tlab.append('capm')
plab = tlab.copy()
plab.append('Gmass')
plab.append('radius')
if param['CHK_CLOSE'] == 'YES':
plab.append('radius')
if param['RHILL_PRESENT'] == 'YES':
plab.append('rhill')
clab = ['Gmass', 'radius', 'J_2', 'J_4']
Expand Down Expand Up @@ -817,7 +818,10 @@ def swiftest_xr2infile(ds, param, framenum=-1):
tp = frame.where(np.isnan(frame['Gmass']), drop=True).drop_vars(['Gmass', 'radius', 'J_2', 'J_4'])

GMSun = np.double(cb['Gmass'])
RSun = np.double(cb['radius'])
if param['CHK_CLOSE'] == 'YES':
RSun = np.double(cb['radius'])
else:
RSun = param['CHK_RMIN']
J2 = np.double(cb['J_2'])
J4 = np.double(cb['J_4'])
cbname = cb['name'].values[0]
Expand Down Expand Up @@ -851,7 +855,8 @@ def swiftest_xr2infile(ds, param, framenum=-1):
print(pli['name'].values, pli['Gmass'].values, pli['rhill'].values, file=plfile)
else:
print(pli['name'].values, pli['Gmass'].values, file=plfile)
print(pli['radius'].values, file=plfile)
if param['CHK_CLOSE'] == 'YES':
print(pli['radius'].values, file=plfile)
if param['IN_FORM'] == 'XV':
print(pli['xhx'].values, pli['xhy'].values, pli['xhz'].values, file=plfile)
print(pli['vhx'].values, pli['vhy'].values, pli['vhz'].values, file=plfile)
Expand Down Expand Up @@ -918,7 +923,8 @@ def swiftest_xr2infile(ds, param, framenum=-1):
else:
print(f"{param['IN_FORM']} is not a valid input format type.")
Gmass = pl['Gmass'].values
radius = pl['radius'].values
if param['CHK_CLOSE'] == 'YES':
radius = pl['radius'].values

plfile.write_record(npl)
plfile.write_record(plid)
Expand All @@ -931,7 +937,8 @@ def swiftest_xr2infile(ds, param, framenum=-1):
plfile.write_record(Gmass)
if param['RHILL_PRESENT'] == 'YES':
plfile.write_record(pl['rhill'].values)
plfile.write_record(radius)
if param['CHK_CLOSE'] == 'YES':
plfile.write_record(radius)
if param['ROTATION'] == 'YES':
plfile.write_record(pl['Ip1'].values)
plfile.write_record(pl['Ip2'].values)
Expand Down Expand Up @@ -995,7 +1002,10 @@ def swifter_xr2infile(ds, param, framenum=-1):
tp = frame.where(np.isnan(frame['Gmass']), drop=True).drop_vars(['Gmass', 'radius', 'J_2', 'J_4'])

GMSun = np.double(cb['Gmass'])
RSun = np.double(cb['radius'])
if param['CHK_CLOSE'] == 'YES':
RSun = np.double(cb['radius'])
else:
RSun = param['CHK_RMIN']
param['J2'] = np.double(cb['J_2'])
param['J4'] = np.double(cb['J_4'])

Expand Down
6 changes: 3 additions & 3 deletions src/io/io.f90
Original file line number Diff line number Diff line change
Expand Up @@ -1525,7 +1525,7 @@ module function io_read_frame_body(self, iu, param) result(ierr)
read(iu, err = 667, iomsg = errmsg) pl%Gmass(:)
pl%mass(:) = pl%Gmass(:) / param%GU
if (param%lrhill_present) read(iu, err = 667, iomsg = errmsg) pl%rhill(:)
read(iu, err = 667, iomsg = errmsg) pl%radius(:)
if (param%lclose) read(iu, err = 667, iomsg = errmsg) pl%radius(:)
if (param%lrotation) then
read(iu, err = 667, iomsg = errmsg) pl%Ip(1, :)
read(iu, err = 667, iomsg = errmsg) pl%Ip(2, :)
Expand Down Expand Up @@ -1553,7 +1553,7 @@ module function io_read_frame_body(self, iu, param) result(ierr)
end if
self%Gmass(i) = real(val, kind=DP)
self%mass(i) = real(val / param%GU, kind=DP)
read(iu, *, err = 667, iomsg = errmsg) self%radius(i)
if (param%lclose) read(iu, *, err = 667, iomsg = errmsg) self%radius(i)
class is (swiftest_tp)
read(iu, *, err = 667, iomsg = errmsg) name(i)
end select
Expand Down Expand Up @@ -2027,7 +2027,7 @@ module subroutine io_write_frame_body(self, iu, param)
class is (swiftest_pl) ! Additional output if the passed polymorphic object is a massive body
write(iu, err = 667, iomsg = errmsg) pl%Gmass(1:n)
if (param%lrhill_present) write(iu, err = 667, iomsg = errmsg) pl%rhill(1:n)
write(iu, err = 667, iomsg = errmsg) pl%radius(1:n)
if (param%lclose) write(iu, err = 667, iomsg = errmsg) pl%radius(1:n)
if (param%lrotation) then
write(iu, err = 667, iomsg = errmsg) pl%Ip(1, 1:n)
write(iu, err = 667, iomsg = errmsg) pl%Ip(2, 1:n)
Expand Down
13 changes: 6 additions & 7 deletions src/netcdf/netcdf.f90
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,9 @@ module function netcdf_read_frame_system(self, iu, param) result(ierr)
call check( nf90_get_var(iu%ncid, iu%radius_varid, rtemp, start=[1, tslot]) )
cb%radius = rtemp(1)
pl%radius(:) = pack(rtemp, plmask)
else
cb%radius = param%rmin
pl%radius(:) = 0.0_DP
end if

if (param%lrotation) then
Expand Down Expand Up @@ -896,12 +899,8 @@ module subroutine netcdf_write_frame_base(self, iu, param)
select type(self)
class is (swiftest_pl) ! Additional output if the passed polymorphic object is a massive body
call check( nf90_put_var(iu%ncid, iu%Gmass_varid, self%Gmass(j), start=[idslot, tslot]) )
if (param%lrhill_present) then
call check( nf90_put_var(iu%ncid, iu%rhill_varid, self%rhill(j), start=[idslot, tslot]) )
end if
if (param%lclose) then
call check( nf90_put_var(iu%ncid, iu%radius_varid, self%radius(j), start=[idslot, tslot]) )
end if
if (param%lrhill_present) call check( nf90_put_var(iu%ncid, iu%rhill_varid, self%rhill(j), start=[idslot, tslot]) )
if (param%lclose) call check( nf90_put_var(iu%ncid, iu%radius_varid, self%radius(j), start=[idslot, tslot]) )
if (param%lrotation) then
call check( nf90_put_var(iu%ncid, iu%Ip1_varid, self%Ip(1, j), start=[idslot, tslot]) )
call check( nf90_put_var(iu%ncid, iu%Ip2_varid, self%Ip(2, j), start=[idslot, tslot]) )
Expand All @@ -923,7 +922,7 @@ module subroutine netcdf_write_frame_base(self, iu, param)
call check( nf90_put_var(iu%ncid, iu%id_varid, self%id, start=[idslot]) )

call check( nf90_put_var(iu%ncid, iu%Gmass_varid, self%Gmass, start=[idslot, tslot]) )
call check( nf90_put_var(iu%ncid, iu%radius_varid, self%radius, start=[idslot, tslot]) )
if (param%lclose) call check( nf90_put_var(iu%ncid, iu%radius_varid, self%radius, start=[idslot, tslot]) )
if (param%lrotation) then
call check( nf90_put_var(iu%ncid, iu%Ip1_varid, self%Ip(1), start=[idslot, tslot]) )
call check( nf90_put_var(iu%ncid, iu%Ip2_varid, self%Ip(2), start=[idslot, tslot]) )
Expand Down
4 changes: 2 additions & 2 deletions src/util/util_dealloc.f90
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ module subroutine util_dealloc_body(self)
if (allocated(self%vb)) deallocate(self%vb)
if (allocated(self%ah)) deallocate(self%ah)
if (allocated(self%aobl)) deallocate(self%aobl)
if (allocated(self%agr)) deallocate(self%lmask)
if (allocated(self%atide)) deallocate(self%lmask)
if (allocated(self%agr)) deallocate(self%agr)
if (allocated(self%atide)) deallocate(self%atide)
if (allocated(self%ir3h)) deallocate(self%ir3h)
if (allocated(self%a)) deallocate(self%a)
if (allocated(self%e)) deallocate(self%e)
Expand Down

0 comments on commit 0f9bb1e

Please sign in to comment.