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

Commit

Permalink
Added a safety check to ensure that l_dim_max and m_dim_max are the same
Browse files Browse the repository at this point in the history
  • Loading branch information
daminton committed Mar 1, 2024
1 parent a79319a commit c414bad
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/swiftest/swiftest_io.f90
Original file line number Diff line number Diff line change
Expand Up @@ -1592,16 +1592,22 @@ module function swiftest_io_netcdf_read_frame_system(self, nc, param) result(ier
"netcdf_io_read_frame_system nf90_inquire_dimension l_dimid" )
call netcdf_io_check( nf90_inquire_dimension(nc%id, nc%m_dimid, len = nc%m_dim_max), &
"netcdf_io_read_frame_system nf90_inquire_dimension m_dimid")


if (nc%l_dim_max /= nc%m_dim_max) then
write(*,*) "Error reading in NetCDF file: c_lm requires l_dim_max = m_dim_max"
call base_util_exit(FAILURE,param%display_unit)
end if

if(.not. allocated(cb%c_lm)) allocate(cb%c_lm(nc%m_dim_max, nc%l_dim_max, 2))
call netcdf_io_check( nf90_get_var(nc%id, nc%c_lm_varid, cb%c_lm, count = [nc%m_dim_max, nc%l_dim_max, 2]), &
"netcdf_io_read_frame_system nf90_getvar c_lm_varid")

nc%lc_lm_exists = .true.
if (abs(cb%j2rp2) > tiny(1.0_DP) .or. (abs(cb%j4rp4) > tiny(1.0_DP))) then
write(*,*) "Error reading in NetCDF file: cannot use both c_lm and j2rp2/j4rp4"
call base_util_exit(FAILURE,param%display_unit)
end if

nc%lc_lm_exists = .true.
else
if (allocated(cb%c_lm)) deallocate(cb%c_lm)
nc%lc_lm_exists = .false.
Expand Down

0 comments on commit c414bad

Please sign in to comment.