Skip to content

Commit

Permalink
IMERG Precipitation Reader for LVT
Browse files Browse the repository at this point in the history
This update adds a reader to LVT that reads in GPM IMERG precipitation
data. This reader only works with the latest IMERG release (V05B) and
includes a configuration option that allows the user to switch between
the early, late, and final versions of the IMERG product.

Version NASA-LIS#2: Removed excessive whitespace from code.
  • Loading branch information
Daniel Sarmiento committed Feb 22, 2019
1 parent d290085 commit 3613d47
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 33 deletions.
17 changes: 0 additions & 17 deletions lvt/datastreams/IMERG/IMERG_dataMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
! NASA GSFC Land surface Verification Toolkit (LVT) V1.0
!-------------------------END NOTICE -- DO NOT EDIT-----------------------------
!
!
! NOTE: Currently only V05B IMERG data are supported
module IMERG_dataMod

Expand Down Expand Up @@ -43,10 +42,8 @@ module IMERG_dataMod
type(imergdatadec), allocatable :: imergdata(:)

contains

!---------------------------------------------------------------------------
subroutine IMERG_datainit(i)

! Imports
use ESMF
use LVT_coreMod
Expand All @@ -71,12 +68,10 @@ subroutine IMERG_datainit(i)
if(.not.allocated(imergdata)) then
allocate(imergdata(LVT_rc%nDataStreams))
endif

! Get top level IMERG data directory
call ESMF_ConfigGetAttribute(LVT_Config, imergdata(i)%odir, &
label='IMERG data directory:', rc=status)
call LVT_verify(status, 'IMERG data directory: not defined')

! Get IMERG version
call ESMF_ConfigFindLabel(LVT_config,"IMERG version:",rc=status)
if(status /= 0) then
Expand All @@ -87,11 +82,9 @@ subroutine IMERG_datainit(i)
else
call ESMF_ConfigGetAttribute(LVT_config,imergdata(i)%imergver,rc=status)
endif

! Allocate arrays on LVT grid
allocate(imergdata(i)%rlat(LVT_rc%lnc*LVT_rc%lnr))
allocate(imergdata(i)%rlon(LVT_rc%lnc*LVT_rc%lnr))

! Set IMERG grid and map projection information.
gridDesci(:) = 0
gridDesci(1) = 0 ! Lat/lon
Expand All @@ -105,18 +98,14 @@ subroutine IMERG_datainit(i)
gridDesci(9) = 0.1 ! Longitudinal direction increment
gridDesci(10) = 0.1 ! Latitude direction increment
gridDesci(20) = 64

! Set up interpolation data
imergdata(i)%datares = 0.1
imergdata(i)%nc = 3600
imergdata(i)%nr = 1800

! Use budget-bilinear interpolation if IMERG resolution (0.1 deg)
! is coarser than the analysis grid. Use upscale averaging if
! IMERG is finer than the analysis grid.

if (LVT_isAtAFinerResolution(imergdata(i)%datares)) then

! Used only with budget interpolation
allocate(imergdata(i)%n112(LVT_rc%lnc*LVT_rc%lnr,25))
allocate(imergdata(i)%n122(LVT_rc%lnc*LVT_rc%lnr,25))
Expand All @@ -126,7 +115,6 @@ subroutine IMERG_datainit(i)
allocate(imergdata(i)%w122(LVT_rc%lnc*LVT_rc%lnr,25))
allocate(imergdata(i)%w212(LVT_rc%lnc*LVT_rc%lnr,25))
allocate(imergdata(i)%w222(LVT_rc%lnc*LVT_rc%lnr,25))

imergdata(i)%n112 = 0
imergdata(i)%n122 = 0
imergdata(i)%n212 = 0
Expand All @@ -135,7 +123,6 @@ subroutine IMERG_datainit(i)
imergdata(i)%w122 = 0
imergdata(i)%w212 = 0
imergdata(i)%w222 = 0

call conserv_interp_input(gridDesci,LVT_rc%gridDesc,&
LVT_rc%lnc*LVT_rc%lnr, &
imergdata(i)%rlat, imergdata(i)%rlon,&
Expand All @@ -144,17 +131,13 @@ subroutine IMERG_datainit(i)
imergdata(i)%w112, imergdata(i)%w122, &
imergdata(i)%w212, imergdata(i)%w222)
else

! Used only with upscale averaging
allocate(imergdata(i)%n11(imergdata(i)%nc*imergdata(i)%nr))
imergdata(i)%n11 = 0

call upscaleByAveraging_input(gridDesci,LVT_rc%gridDesc,&
imergdata(i)%nc*imergdata(i)%nr, &
LVT_rc%lnc*LVT_rc%lnr, &
imergdata(i)%n11)
end if

end subroutine IMERG_datainit

end module IMERG_dataMod
16 changes: 0 additions & 16 deletions lvt/datastreams/IMERG/readIMERGdata.F90
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
! NASA GSFC Land surface Verification Toolkit (LVT) V1.0
!-------------------------END NOTICE -- DO NOT EDIT-----------------------------
#include "LVT_misc.h"

!------------------------------------------------------------------------------

!NOTE: Currently only V05B IMERG data are supported.
subroutine readIMERGdata(source)

Expand Down Expand Up @@ -88,7 +86,6 @@ subroutine readIMERGdata(source)
call LVT_verify(status)

if (alarmCheck) then

call create_IMERG_filename(imergdata(source)%odir, &
yr1,mo1,da1,hr1,mn1,filename)

Expand Down Expand Up @@ -147,9 +144,7 @@ subroutine readIMERGdata(source)
prcp_final(c,r) = prcp(c+(r-1)*LVT_rc%lnc)
end do ! c
end do ! r

end if ! alarmCheck

! Convert mm/hr to kg/m2s.
do r=1,LVT_rc%lnr
do c=1, LVT_rc%lnc
Expand All @@ -162,7 +157,6 @@ subroutine readIMERGdata(source)
end do ! r
call LVT_logSingleDataStreamVar(LVT_MOC_totalprecip,source,prcp_final,&
vlevel=1,units='kg/m2s')

! Now convert from kg/m2s to kg/m2
do r=1,LVT_rc%lnr
do c=1,LVT_rc%lnc
Expand All @@ -175,9 +169,7 @@ subroutine readIMERGdata(source)
enddo ! r
call LVT_logSingleDataStreamVar(LVT_MOC_totalprecip,source,prcp_final,&
vlevel=1,units='kg/m2')

end subroutine readIMERGdata

!------------------------------------------------------------------------------
subroutine read_imerghdf(filename, col, row, precipout, ireaderr)
#if(defined USE_HDF5)
Expand Down Expand Up @@ -212,9 +204,7 @@ subroutine read_imerghdf(filename, col, row, precipout, ireaderr)
ysize = row
dims(1) = xsize
dims(2) = ysize

bIsError=.false.

!open fortran interface
call h5open_f(istatus)
if(istatus.ne.0) then
Expand Down Expand Up @@ -250,7 +240,6 @@ subroutine read_imerghdf(filename, col, row, precipout, ireaderr)
!Put the real(1:,1:) on the precipout(0:,0:)
!precipin is (ysize,xsize) starting at (lon=-179.9,lat=-89.9)
precipout(1:xsize,1:ysize)=transpose(precipin)

!close dataset
call h5dclose_f(dsetid,istatus)
if(istatus.ne.0) then
Expand All @@ -277,14 +266,10 @@ subroutine read_imerghdf(filename, col, row, precipout, ireaderr)
endif
ireaderr = istatus
#endif

end subroutine read_imerghdf

!------------------------------------------------------------------------------

subroutine create_IMERG_filename(odir, &
yr,mo,da,hr,mn,filename)

use IMERG_dataMod
use LVT_logMod

Expand Down Expand Up @@ -333,7 +318,6 @@ subroutine create_IMERG_filename(odir, &
write(LVT_logunit,*) "[ERR] Please choose either 'early', 'late', or 'final'."
call LVT_endrun()
endif

filename = trim(odir)//"/"//cyr//cmo//trim(fstem)// &
cyr//cmo//cda//"-S"//chr//cmn//"00-E"//chr//cmnadd//"59."//cmnday//".V05B.HDF5"
end subroutine create_IMERG_filename

0 comments on commit 3613d47

Please sign in to comment.