Skip to content

Commit

Permalink
add_lake_20200810: Update sfc_climo_gen to work with
Browse files Browse the repository at this point in the history
model points that can be partial land.

References ufs-community#111
  • Loading branch information
GeorgeGayno-NOAA committed Aug 17, 2020
1 parent d354b6e commit a76f303
Showing 1 changed file with 32 additions and 7 deletions.
39 changes: 32 additions & 7 deletions sorc/sfc_climo_gen.fd/model_grid.F90
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ subroutine get_model_info(orog_file, mask, lat2d, lon2d, idim, jdim)
real(esmf_kind_r4), intent(out) :: lat2d(idim,jdim)
real(esmf_kind_r4), intent(out) :: lon2d(idim,jdim)

integer :: error, lat, lon
integer :: error, lat, lon, i, j
integer :: ncid, id_dim, id_var

real(kind=4), allocatable :: dummy(:,:)
Expand Down Expand Up @@ -365,12 +365,37 @@ subroutine get_model_info(orog_file, mask, lat2d, lon2d, idim, jdim)

allocate(dummy(idim,jdim))

print*,"- READ LAND MASK"
error=nf90_inq_varid(ncid, 'slmsk', id_var)
call netcdf_err(error, "READING SLMSK ID")
error=nf90_get_var(ncid, id_var, dummy)
call netcdf_err(error, "READING SLMSK")
mask = nint(dummy)
!-----------------------------------------------------------------------
! If the lake maker was used, there will be a 'lake_frac' record.
! In that case, land/non-land is determined by 'land_frac'.
!
! If the lake maker was not used, use 'slmsk', which is defined
! as the nint(land_frac).
!-----------------------------------------------------------------------

error=nf90_inq_varid(ncid, 'lake_frac', id_var)
if (error /= 0) then
print*,"- READ LAND MASK (SLMSK)"
error=nf90_inq_varid(ncid, 'slmsk', id_var)
call netcdf_err(error, "READING SLMSK ID")
error=nf90_get_var(ncid, id_var, dummy)
call netcdf_err(error, "READING SLMSK")
mask = nint(dummy)
else
print*,"- READ LAND FRACTION"
error=nf90_inq_varid(ncid, 'land_frac', id_var)
call netcdf_err(error, "READING LAND_FRAC ID")
error=nf90_get_var(ncid, id_var, dummy)
call netcdf_err(error, "READING LAND_FRAC")
mask = 0
do j = 1, lat
do i = 1, lon
if (dummy(i,j) > 0.0) then
mask(i,j) = 1
endif
enddo
enddo
endif

print*,"- READ LATITUDE"
error=nf90_inq_varid(ncid, 'geolat', id_var)
Expand Down

0 comments on commit a76f303

Please sign in to comment.