@@ -84,7 +84,7 @@ module cam_snapshot_common
8484type (snapshot_type) :: state_snapshot(30 )
8585type (snapshot_type) :: cnst_snapshot(pcnst)
8686type (snapshot_type) :: tend_snapshot(6 )
87- type (snapshot_type) :: cam_in_snapshot(30 )
87+ type (snapshot_type) :: cam_in_snapshot(pcnst +31 ) ! needs to be bigger than pcnst because cam_in is split by constituent.
8888type (snapshot_type) :: cam_out_snapshot(30 )
8989type (snapshot_type_nd) :: pbuf_snapshot(300 )
9090
@@ -1218,6 +1218,9 @@ subroutine cam_pbuf_snapshot_all_outfld(lchnk, file_num, pbuf)
12181218 real (r8 ), pointer , dimension (:,:,:,:) :: tmpptr4 d
12191219 real (r8 ), pointer , dimension (:,:,:,:,:) :: tmpptr5d
12201220
1221+ ! Special handling of integer type fields (output as real)
1222+ integer , pointer , dimension (:,:) :: tmpptr2d_int
1223+
12211224
12221225 do i= 1 , npbuf_var
12231226
@@ -1227,28 +1230,40 @@ subroutine cam_pbuf_snapshot_all_outfld(lchnk, file_num, pbuf)
12271230 ! Turn on the writing for only the requested tape (file_num)
12281231 call cam_history_snapshot_activate(trim (pbuf_snapshot(i)% standard_name), file_num)
12291232
1230- ! Retrieve the pbuf data (dependent on the number of dimensions)
1231- ndims = count (pbuf_snapshot(i)% dim_name(:) /= ' ' )
1233+ ! Retrieve the pbuf data. Special handling for certain
1234+ ! integer-type fields.
1235+ if ( trim (pbuf_snapshot(i)% ddt_string) == ' clubbtop' ) then
1236+ call pbuf_get_field(pbuf, pbuf_idx, tmpptr2d_int)
1237+ ! copy into real
1238+ allocate (tmpptr2d(size (tmpptr2d_int, 1 ), size (tmpptr2d_int, 2 )))
1239+ tmpptr2d = real (tmpptr2d_int, r8 )
1240+ call outfld(pbuf_snapshot(i)% standard_name, tmpptr2d, pcols, lchnk)
1241+ deallocate (tmpptr2d)
1242+ else
1243+ ! For regular real-type data:
1244+ ! Retrieve the pbuf data (dependent on the number of dimensions)
1245+ ndims = count (pbuf_snapshot(i)% dim_name(:) /= ' ' )
12321246
1233- select case (ndims) ! Note that dimension 5 and 6 do not work with pbuf_get_field, so these are not used here
1247+ select case (ndims) ! Note that dimension 5 and 6 do not work with pbuf_get_field, so these are not used here
12341248
1235- case (1 )
1236- call pbuf_get_field(pbuf, pbuf_idx, tmpptr2d)
1237- call outfld(pbuf_snapshot(i)% standard_name, tmpptr2d, pcols, lchnk)
1249+ case (1 )
1250+ call pbuf_get_field(pbuf, pbuf_idx, tmpptr2d)
1251+ call outfld(pbuf_snapshot(i)% standard_name, tmpptr2d, pcols, lchnk)
12381252
1239- case (2 )
1240- call pbuf_get_field(pbuf, pbuf_idx, tmpptr3d)
1241- call outfld(pbuf_snapshot(i)% standard_name, tmpptr3d, pcols, lchnk)
1253+ case (2 )
1254+ call pbuf_get_field(pbuf, pbuf_idx, tmpptr3d)
1255+ call outfld(pbuf_snapshot(i)% standard_name, tmpptr3d, pcols, lchnk)
12421256
1243- case (3 )
1244- call pbuf_get_field(pbuf, pbuf_idx, tmpptr3d)
1245- call outfld(pbuf_snapshot(i)% standard_name, tmpptr4 d, pcols, lchnk)
1257+ case (3 )
1258+ call pbuf_get_field(pbuf, pbuf_idx, tmpptr3d)
1259+ call outfld(pbuf_snapshot(i)% standard_name, tmpptr4 d, pcols, lchnk)
12461260
1247- case (4 )
1248- call pbuf_get_field(pbuf, pbuf_idx, tmpptr5d)
1249- call outfld(pbuf_snapshot(i)% standard_name, tmpptr5d, pcols, lchnk)
1261+ case (4 )
1262+ call pbuf_get_field(pbuf, pbuf_idx, tmpptr5d)
1263+ call outfld(pbuf_snapshot(i)% standard_name, tmpptr5d, pcols, lchnk)
12501264
1251- end select
1265+ end select
1266+ endif
12521267
12531268 ! Now that the field has been written, turn off the writing for field
12541269 call cam_history_snapshot_deactivate(trim (pbuf_snapshot(i)% standard_name))
0 commit comments