diff --git a/src/dynamics/none/dyn_grid.F90 b/src/dynamics/none/dyn_grid.F90 index 8d2b0431..64cc20b8 100644 --- a/src/dynamics/none/dyn_grid.F90 +++ b/src/dynamics/none/dyn_grid.F90 @@ -62,13 +62,15 @@ subroutine model_grid_init() use pio, only: PIO_BCAST_ERROR, pio_seterrorhandling use pio, only: pio_get_var, pio_freedecomp use pio, only: pio_read_darray + use pio, only: pio_inq_vartype, PIO_NOERR use spmd_utils, only: npes, iam use cam_pio_utils, only: cam_pio_handle_error, cam_pio_find_var use cam_pio_utils, only: cam_pio_var_info, pio_subsystem use cam_pio_utils, only: cam_pio_newdecomp use cam_abortutils, only: endrun use cam_logfile, only: cam_log_multiwrite - use cam_initfiles, only: initial_file_get_id + use cam_initfiles, only: initial_file_get_id, unset_path_str + use phys_comp, only: ncdata_check use vert_coord, only: vert_coord_init, pver use hycoef, only: hycoef_init, hypi, hypm, nprlev, & hyam, hybm, hyai, hybi, ps0 @@ -107,6 +109,7 @@ subroutine model_grid_init() character(len=8) :: lat_dim_name character(len=8) :: lon_dim_name character(len=128) :: errormsg + integer :: xtype character(len=*), parameter :: subname = 'model_grid_init' @@ -225,6 +228,27 @@ subroutine model_grid_init() 'eastward_wind' /), & fieldname, vardesc, var_found) if (var_found) then + ! Check that snapshot file has 64-bit floats (ndens=1). + ! Running with 32-bit (FLOAT32) snapshots will definitely cause + ! answer differences between CAM-SIMA and the CAM snapshot + ! leading to wasted debugging time, so disallow this configuration. + ! Only check when running a snapshot test (ncdata_check is set), + ! since the null dycore may also be used for other purposes + ! (e.g. single-column model) where lower-precision data is fine. + if (trim(ncdata_check) /= trim(unset_path_str)) then + iret = pio_inq_vartype(fh_ini, vardesc, xtype) + if (iret /= PIO_NOERR) then + call endrun(subname//': Unable to inquire variable type for '// & + trim(fieldname)) + end if + if (xtype /= PIO_DOUBLE) then + call endrun(subname//': Snapshot file has non-FLOAT64 data '// & + '(variable '//trim(fieldname)//'). '// & + 'This will cause answer differences! '// & + 'Please rerun CAM with ndens = 1 to write 64-bit float '// & + 'snapshots for use with CAM-SIMA.') + end if + end if ! Find the variable dimension info dimnames = '' dimids = -1 diff --git a/src/physics/utils/phys_comp.F90 b/src/physics/utils/phys_comp.F90 index 471ee9e0..4db7c9c7 100644 --- a/src/physics/utils/phys_comp.F90 +++ b/src/physics/utils/phys_comp.F90 @@ -22,11 +22,14 @@ module phys_comp ! suite_name: Suite we are running character(len=SHR_KIND_CS), public, protected :: phys_suite_name = unset_str + ! ncdata_check: Path to file for physics_check_data to verify against + ! at the end of every timestep (if not unset) + character(len=SHR_KIND_CL), public, protected :: ncdata_check = unset_str + ! Private module data character(len=SHR_KIND_CS), allocatable :: suite_names(:) character(len=SHR_KIND_CS) :: suite_parts_expect(2) = (/"physics_before_coupler", "physics_after_coupler "/) character(len=SHR_KIND_CS), allocatable :: suite_parts(:) - character(len=SHR_KIND_CL) :: ncdata_check = unset_str logical :: ncdata_check_err = .false. character(len=SHR_KIND_CL) :: cam_physics_mesh = unset_str character(len=SHR_KIND_CS) :: cam_take_snapshot_before = unset_str