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

Commit

Permalink
Fixed issue involving reading in NetCDF files when there are no test …
Browse files Browse the repository at this point in the history
…particles (and/or no planets)
  • Loading branch information
daminton committed Nov 23, 2021
1 parent 5b00001 commit e08ed09
Showing 1 changed file with 41 additions and 39 deletions.
80 changes: 41 additions & 39 deletions src/netcdf/netcdf.f90
Original file line number Diff line number Diff line change
Expand Up @@ -544,113 +544,115 @@ module function netcdf_read_frame_system(self, iu, 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(iu%ncid, iu%xhx_varid, rtemp, start=[1, tslot]) )
pl%xh(1,:) = pack(rtemp, plmask)
tp%xh(1,:) = pack(rtemp, tpmask)
if (npl > 0) pl%xh(1,:) = pack(rtemp, plmask)
if (ntp > 0) tp%xh(1,:) = pack(rtemp, tpmask)

call check( nf90_get_var(iu%ncid, iu%xhy_varid, rtemp, start=[1, tslot]) )
pl%xh(2,:) = pack(rtemp, plmask)
tp%xh(2,:) = pack(rtemp, tpmask)
if (npl > 0) pl%xh(2,:) = pack(rtemp, plmask)
if (ntp > 0) tp%xh(2,:) = pack(rtemp, tpmask)

call check( nf90_get_var(iu%ncid, iu%xhz_varid, rtemp, start=[1, tslot]) )
pl%xh(3,:) = pack(rtemp, plmask)
tp%xh(3,:) = pack(rtemp, tpmask)
if (npl > 0) pl%xh(3,:) = pack(rtemp, plmask)
if (ntp > 0) tp%xh(3,:) = pack(rtemp, tpmask)

call check( nf90_get_var(iu%ncid, iu%vhx_varid, rtemp, start=[1, tslot]) )
pl%vh(1,:) = pack(rtemp, plmask)
tp%vh(1,:) = pack(rtemp, tpmask)
if (npl > 0) pl%vh(1,:) = pack(rtemp, plmask)
if (ntp > 0) tp%vh(1,:) = pack(rtemp, tpmask)

call check( nf90_get_var(iu%ncid, iu%vhy_varid, rtemp, start=[1, tslot]) )
pl%vh(2,:) = pack(rtemp, plmask)
tp%vh(2,:) = pack(rtemp, tpmask)
if (npl > 0) pl%vh(2,:) = pack(rtemp, plmask)
if (ntp > 0) tp%vh(2,:) = pack(rtemp, tpmask)

call check( nf90_get_var(iu%ncid, iu%vhz_varid, rtemp, start=[1, tslot]) )
pl%vh(3,:) = pack(rtemp, plmask)
tp%vh(3,:) = pack(rtemp, tpmask)
if (npl > 0) pl%vh(3,:) = pack(rtemp, plmask)
if (ntp > 0) tp%vh(3,:) = pack(rtemp, tpmask)
end if

if ((param%in_form == EL) .or. (param%in_form == XVEL)) then

call check( nf90_get_var(iu%ncid, iu%a_varid, rtemp, start=[1, tslot]) )
pl%a(:) = pack(rtemp, plmask)
tp%a(:) = pack(rtemp, tpmask)
if (npl > 0) pl%a(:) = pack(rtemp, plmask)
if (ntp > 0) tp%a(:) = pack(rtemp, tpmask)

call check( nf90_get_var(iu%ncid, iu%e_varid, rtemp, start=[1, tslot]) )
pl%e(:) = pack(rtemp, plmask)
tp%e(:) = pack(rtemp, tpmask)
if (npl > 0) pl%e(:) = pack(rtemp, plmask)
if (ntp > 0) tp%e(:) = pack(rtemp, tpmask)

call check( nf90_get_var(iu%ncid, iu%inc_varid, rtemp, start=[1, tslot]) )
pl%inc(:) = pack(rtemp, plmask)
tp%inc(:) = pack(rtemp, tpmask)
if (npl > 0) pl%inc(:) = pack(rtemp, plmask)
if (ntp > 0) tp%inc(:) = pack(rtemp, tpmask)

call check( nf90_get_var(iu%ncid, iu%capom_varid, rtemp, start=[1, tslot]) )
pl%capom(:) = pack(rtemp, plmask)
tp%capom(:) = pack(rtemp, tpmask)
if (npl > 0) pl%capom(:) = pack(rtemp, plmask)
if (ntp > 0) tp%capom(:) = pack(rtemp, tpmask)

call check( nf90_get_var(iu%ncid, iu%omega_varid, rtemp, start=[1, tslot]) )
pl%omega(:) = pack(rtemp, plmask)
tp%omega(:) = pack(rtemp, tpmask)
if (npl > 0) pl%omega(:) = pack(rtemp, plmask)
if (ntp > 0) tp%omega(:) = pack(rtemp, tpmask)

call check( nf90_get_var(iu%ncid, iu%capm_varid, rtemp, start=[1, tslot]) )
pl%capm(:) = pack(rtemp, plmask)
tp%capm(:) = pack(rtemp, tpmask)
if (npl > 0) pl%capm(:) = pack(rtemp, plmask)
if (ntp > 0) tp%capm(:) = pack(rtemp, tpmask)

end if

call check( nf90_get_var(iu%ncid, iu%Gmass_varid, rtemp, start=[1, tslot]) )
cb%Gmass = rtemp(1)
cb%mass = cb%Gmass / param%GU

pl%Gmass(:) = pack(rtemp, plmask)
pl%mass(:) = pl%Gmass(:) / param%GU
if (npl > 0) then
pl%Gmass(:) = pack(rtemp, plmask)
pl%mass(:) = pl%Gmass(:) / param%GU

if (param%lrhill_present) then
call check( nf90_get_var(iu%ncid, iu%rhill_varid, rtemp, start=[1, tslot]) )
pl%rhill(:) = pack(rtemp, plmask)
if (param%lrhill_present) then
call check( nf90_get_var(iu%ncid, iu%rhill_varid, rtemp, start=[1, tslot]) )
pl%rhill(:) = pack(rtemp, plmask)
end if
end if

if (param%lclose) then
call check( nf90_get_var(iu%ncid, iu%radius_varid, rtemp, start=[1, tslot]) )
cb%radius = rtemp(1)
pl%radius(:) = pack(rtemp, plmask)
if (npl > 0) pl%radius(:) = pack(rtemp, plmask)
else
cb%radius = param%rmin
pl%radius(:) = 0.0_DP
if (npl > 0) pl%radius(:) = 0.0_DP
end if

if (param%lrotation) then
call check( nf90_get_var(iu%ncid, iu%Ip1_varid, rtemp, start=[1, tslot]) )
cb%Ip(1) = rtemp(1)
pl%Ip(1,:) = pack(rtemp, plmask)
if (npl > 0) pl%Ip(1,:) = pack(rtemp, plmask)

call check( nf90_get_var(iu%ncid, iu%Ip2_varid, rtemp, start=[1, tslot]) )
cb%Ip(2) = rtemp(1)
pl%Ip(2,:) = pack(rtemp, plmask)
if (npl > 0) pl%Ip(2,:) = pack(rtemp, plmask)

call check( nf90_get_var(iu%ncid, iu%Ip3_varid, rtemp, start=[1, tslot]) )
cb%Ip(3) = rtemp(1)
pl%Ip(3,:) = pack(rtemp, plmask)
if (npl > 0) pl%Ip(3,:) = pack(rtemp, plmask)

call check( nf90_get_var(iu%ncid, iu%rotx_varid, rtemp, start=[1, tslot]) )
cb%rot(1) = rtemp(1)
pl%rot(1,:) = pack(rtemp, plmask)
if (npl > 0) pl%rot(1,:) = pack(rtemp, plmask)

call check( nf90_get_var(iu%ncid, iu%roty_varid, rtemp, start=[1, tslot]) )
cb%rot(2) = rtemp(1)
pl%rot(2,:) = pack(rtemp, plmask)
if (npl > 0) pl%rot(2,:) = pack(rtemp, plmask)

call check( nf90_get_var(iu%ncid, iu%rotz_varid, rtemp, start=[1, tslot]) )
cb%rot(3) = rtemp(1)
pl%rot(3,:) = pack(rtemp, plmask)
if (npl > 0) pl%rot(3,:) = pack(rtemp, plmask)
end if

if (param%ltides) then
call check( nf90_get_var(iu%ncid, iu%k2_varid, rtemp, start=[1, tslot]) )
cb%k2 = rtemp(1)
pl%k2(:) = pack(rtemp, plmask)
if (npl > 0) pl%k2(:) = pack(rtemp, plmask)

call check( nf90_get_var(iu%ncid, iu%Q_varid, rtemp, start=[1, tslot]) )
cb%Q = rtemp(1)
pl%Q(:) = pack(rtemp, plmask)
if (npl > 0) pl%Q(:) = pack(rtemp, plmask)
end if

call self%read_particle_info(iu, param, plmask, tpmask)
Expand Down

0 comments on commit e08ed09

Please sign in to comment.