CAM
CAM copied to clipboard
Snapshots of integer pbuf fields are incorrect
What happened?
Snapshot writing of integer type (dtype_i4) pbuf fields are incorrect.
cam_snapshot_common.F90::cam_pbuf_snapshot_all_outfld reads all pbuf fields into a real(r8) array but if the data is in dtype_i4 the data read into the arrays will not be correct:
subroutine cam_pbuf_snapshot_all_outfld(lchnk, file_num, pbuf)
use physics_buffer, only: pbuf_is_used
integer, intent(in) :: lchnk
integer, intent(in) :: file_num
type(physics_buffer_desc), pointer, intent(in) :: pbuf(:)
integer :: i, pbuf_idx, ndims
real(r8), pointer, dimension(:,:) :: tmpptr2d
real(r8), pointer, dimension(:,:,:) :: tmpptr3d
real(r8), pointer, dimension(:,:,:,:) :: tmpptr4d
real(r8), pointer, dimension(:,:,:,:,:) :: tmpptr5d
do i=1, npbuf_var
pbuf_idx= pbuf_get_index(pbuf_snapshot(i)%ddt_string)
...
! Retrieve the pbuf data (dependent on the number of dimensions)
ndims = count(pbuf_snapshot(i)%dim_name(:) /= '')
select case (ndims) ! Note that dimension 5 and 6 do not work with pbuf_get_field, so these are not used here
case (1)
call pbuf_get_field(pbuf, pbuf_idx, tmpptr2d)
call outfld(pbuf_snapshot(i)%standard_name, tmpptr2d, pcols, lchnk)
...
What are the steps to reproduce the bug?
Observe saved snapshot files for pbuf fields that have dtype_i4, e.g.
! wg top level index of deep cumulus convection.
call pbuf_add_field('ZM_JT', 'physpkg', dtype_i4, (/pcols/), zm_jt_idx)
! wg gathered values of maxi.
call pbuf_add_field('ZM_MAXG', 'physpkg', dtype_i4, (/pcols/), zm_maxg_idx)
! map gathered points to chunk index
call pbuf_add_field('ZM_IDEEP', 'physpkg', dtype_i4, (/pcols/), zm_ideep_idx)
instead of actual values, the data is written incorrectly:
pbuf_ZM_JT =
4.03179200377274e-313, 4.24399158286927e-313, 4.03179200382215e-313,
4.03179200377274e-313, 4.88059032015885e-313, 4.88059032035648e-313,
4.88059032035648e-313, 3.81959242487384e-313, 4.45619116191639e-313,
What CAM tag were you using?
cam6_4_047
What machine were you running CAM on?
CISL machine (e.g. cheyenne)
What compiler were you using?
Intel
Path to a case directory, if applicable
No response
Will you be addressing this bug yourself?
Any CAM SE can do this
Extra info
No response
This also affects pbuf_clubbtop