Skip to content

Commit

Permalink
Update regional FV3 read interface with parallel netcdf read (#441)
Browse files Browse the repository at this point in the history
* Changes for parallel netcdf read for regional FV3 interface

* Clean up debugging code

* Replace small with the one defined in params_mod based on Huiya's comments.
  • Loading branch information
WenMeng-NOAA committed Feb 11, 2022
1 parent 4a16052 commit 45e8fdc
Show file tree
Hide file tree
Showing 2 changed files with 515 additions and 595 deletions.
28 changes: 26 additions & 2 deletions sorc/ncep_post.fd/INITPOST_GFS_NETCDF_PARA.f
Original file line number Diff line number Diff line change
Expand Up @@ -2585,6 +2585,8 @@ subroutine read_netcdf_3d_para(ncid,im,jm,jsta,jsta_2l,jend,jend_2u, &
spval,varname,buf,lm)
use netcdf
use ctlblk_mod, only : me
use params_mod, only : small
implicit none
INCLUDE "mpif.h"
Expand All @@ -2594,10 +2596,12 @@ subroutine read_netcdf_3d_para(ncid,im,jm,jsta,jsta_2l,jend,jend_2u, &
real,intent(out) :: buf(im,jsta_2l:jend_2u,lm)
integer :: varid,iret,jj,i,j,l,kk
integer :: start(3), count(3), stride(3)
real,parameter :: spval_netcdf=9.99e+20
real :: fill_value
iret = nf90_inq_varid(ncid,trim(varname),varid)
if (iret /= 0) then
print*,VarName," not found -Assigned missing values"
if (me == 0) print*,VarName," not found -Assigned missing values"
!$omp parallel do private(i,j,l)
do l=1,lm
do j=jsta,jend
Expand All @@ -2607,10 +2611,19 @@ subroutine read_netcdf_3d_para(ncid,im,jm,jsta,jsta_2l,jend,jend_2u, &
enddo
enddo
else
iret = nf90_get_att(ncid,varid,"_FillValue",fill_value)
if (iret /= 0) fill_value = spval_netcdf
start = (/1,jsta,1/)
jj=jend-jsta+1
count = (/im,jj,lm/)
iret = nf90_get_var(ncid,varid,buf(1:im,jsta:jend,1:lm),start=start,count=count)
do l=1,lm
do j=jsta,jend
do i=1,im
if(abs(buf(i,j,l)-fill_value)<small)buf(i,j,l)=spval
end do
end do
end do
endif
end subroutine read_netcdf_3d_para
Expand All @@ -2619,6 +2632,8 @@ subroutine read_netcdf_2d_para(ncid,im,jsta,jsta_2l,jend,jend_2u, &
spval,VarName,buf)
use netcdf
use ctlblk_mod, only : me
use params_mod, only : small
implicit none
INCLUDE "mpif.h"
Expand All @@ -2628,21 +2643,30 @@ subroutine read_netcdf_2d_para(ncid,im,jsta,jsta_2l,jend,jend_2u, &
real,intent(out) :: buf(im,jsta_2l:jend_2u)
integer :: varid,iret,jj,i,j
integer :: start(2), count(2)
real,parameter :: spval_netcdf=9.99e+20
real :: fill_value
iret = nf90_inq_varid(ncid,trim(varname),varid)
if (iret /= 0) then
print*,VarName," not found -Assigned missing values"
if (me==0) print*,VarName," not found -Assigned missing values"
!$omp parallel do private(i,j)
do j=jsta,jend
do i=1,im
buf(i,j)=spval
enddo
enddo
else
iret = nf90_get_att(ncid,varid,"_FillValue",fill_value)
if (iret /= 0) fill_value = spval_netcdf
start = (/1,jsta/)
jj=jend-jsta+1
count = (/im,jj/)
iret = nf90_get_var(ncid,varid,buf(:,jsta),start=start,count=count)
do j=jsta,jend
do i=1,im
if(abs(buf(i,j)-fill_value)<small)buf(i,j)=spval
end do
end do
endif
end subroutine read_netcdf_2d_para
Loading

0 comments on commit 45e8fdc

Please sign in to comment.