Skip to content

Commit

Permalink
added a tmp field
Browse files Browse the repository at this point in the history
  • Loading branch information
Amin Ilia committed Feb 10, 2025
1 parent bd28fb3 commit a8c9ead
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/ocnicepost.fd/utils_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,7 @@ subroutine write_grib2_2d(fname, gcf, dims, nflds, field, rgmask2d, vfill)
integer :: lunout, ierr
integer :: fortime, dij, npt
CHARACTER(len=1),allocatable,dimension(:) :: cgrib
real :: tmpfld(size(field(:,1))

! GRIB2 metadata arrays
integer :: listsec0(2), listsec1(13)
Expand Down Expand Up @@ -797,9 +798,11 @@ subroutine write_grib2_2d(fname, gcf, dims, nflds, field, rgmask2d, vfill)

if (debug) write(logunit, *) 'idrtmpl: ', idrtmpl

tmpfld=0
tmpfld =field(:,n)

call addfield(cgrib, max_bytes, ipdtnum, jpdt, ipdtlen, coordlist, numcoord, &
idrtnum, idrtmpl, idrtlen, field(:,n), npt, ibmap, bmp, ierr)
idrtnum, idrtmpl, idrtlen, tmpfld, npt, ibmap, bmp, ierr)
if (ierr /= 0) then
write(0, *) 'Error adding field to GRIB2 message', ierr
return
Expand Down Expand Up @@ -1027,18 +1030,18 @@ subroutine write_grib2_3d(fname, gcf, dims, nflds, field, rgmask3d, vfill)

numcoord=0
coordlist=0. ! needed for hybrid vertical coordinate
ibmap=0 ! Bitmap indicator ( see Code Table 6.0 ) -255 no bitmap
ibmap=255 ! Bitmap indicator ( see Code Table 6.0 ) -255 no bitmap
bmp=.true.

if (gcf(n)%var_name .eq. 'WTMP') then
where ( field(:,lyr,n) .ne. vfill ) field(:,lyr,n) = field(:,lyr,n) + 273.15
endif

where ( field(:,lyr,n) .eq. vfill ) bmp(:)= .false.
! where ( field(:,lyr,n) .eq. vfill ) bmp(:)= .false.

! Assign Template 5

idrtnum = 2 ! Template 5.2 (Grid Point Data - complex Packing)
idrtnum = 0 ! Template 5.2 (Grid Point Data - complex Packing)

idrtmpl(:)=0
! Populate idrtmpl
Expand All @@ -1056,7 +1059,7 @@ subroutine write_grib2_3d(fname, gcf, dims, nflds, field, rgmask3d, vfill)

call addfield(cgrib, max_bytes, ipdtnum, jpdt, ipdtlen, coordlist, numcoord, &
idrtnum, idrtmpl, idrtlen, field(:,lyr,n), npt, ibmap, bmp, ierr)
if (ierr /= 0) then
if (ierr /=- 0) then
write(0, *) 'Error adding field to GRIB2 message', ierr
return
end if
Expand Down

0 comments on commit a8c9ead

Please sign in to comment.