diff --git a/src/swiftest/swiftest_io.f90 b/src/swiftest/swiftest_io.f90 index 8209f2a34..4d1bcc185 100644 --- a/src/swiftest/swiftest_io.f90 +++ b/src/swiftest/swiftest_io.f90 @@ -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.