diff --git a/.gitmodules b/.gitmodules index 3e52658..ede25be 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,4 +1,4 @@ [submodule "noahmp"] path = noahmp - url = https://github.com/NCAR/noahmp - branch = develop + url = https://github.com/prasanthvkrishna/noahmp + branch = subgrid diff --git a/hrldas/IO_code/Makefile b/hrldas/IO_code/Makefile index 2f9737c..5103739 100644 --- a/hrldas/IO_code/Makefile +++ b/hrldas/IO_code/Makefile @@ -1,7 +1,7 @@ # Makefile # .SUFFIXES: -.SUFFIXES: .o .F +.SUFFIXES: .o .F .F90 include ../user_build_options @@ -9,7 +9,12 @@ OBJS_NoahMP = module_NoahMP_hrldas_driver.o OBJS = \ main_hrldas_driver.o \ - module_hrldas_netcdf_io.o + module_hrldas_netcdf_io.o\ + MosaicAverageMod.o\ + WriteNoahmpMosaicGridAverageOutputMod.o\ + WriteNoahmpMosaicSubgridOutputMod.o\ + WriteNoahmpMosaicRestartMod.o\ + ReadNoahmpMosaicRestartMod.o CPPHRLDAS = -D_HRLDAS_OFFLINE_ $(MOD_OPT) @@ -47,14 +52,41 @@ module_hrldas_netcdf_io.o: module_hrldas_netcdf_io.F $(COMPILERF90) -o $(@) -c $(F90FLAGS) $(FREESOURCE) $(*).f90 @echo "" - +.F90.o: + @echo "" + $(RM) $(*).f90 + $(CPP) $(CPPFLAGS) $(CPPHRLDAS) $(*).F90 > $(*).f90 + $(COMPILERF90) -o $(@) -c $(F90FLAGS) $(FREESOURCE) -I. -I../../noahmp/utility -I../../noahmp/drivers/hrldas $(*).f90 + @echo "" # # Dependencies: # main_hrldas_driver.o: $(OBJS_NoahMP) -$(OBJS_NoahMP): module_hrldas_netcdf_io.o +$(OBJS_NoahMP): module_hrldas_netcdf_io.o\ + MosaicAverageMod.o\ + WriteNoahmpMosaicGridAverageOutputMod.o\ + WriteNoahmpMosaicSubgridOutputMod.o\ + WriteNoahmpMosaicRestartMod.o\ + ReadNoahmpMosaicRestartMod.o\ + ../../noahmp/drivers/hrldas/NoahmpMosaicSortTileCatMod.o + +MosaicAverageMod.o: ../../noahmp/utility/Machine.o\ + ../../noahmp/drivers/hrldas/NoahmpIOVarType.o +WriteNoahmpMosaicGridAverageOutputMod.o: ../../noahmp/utility/Machine.o\ + ../../noahmp/drivers/hrldas/NoahmpIOVarType.o\ + module_hrldas_netcdf_io.o\ + MosaicAverageMod.o +WriteNoahmpMosaicSubgridOutputMod.o: ../../noahmp/utility/Machine.o\ + ../../noahmp/drivers/hrldas/NoahmpIOVarType.o\ + module_hrldas_netcdf_io.o +WriteNoahmpMosaicRestartMod.o: ../../noahmp/utility/Machine.o\ + ../../noahmp/drivers/hrldas/NoahmpIOVarType.o\ + module_hrldas_netcdf_io.o +ReadNoahmpMosaicRestartMod.o: ../../noahmp/utility/Machine.o\ + ../../noahmp/drivers/hrldas/NoahmpIOVarType.o\ + module_hrldas_netcdf_io.o # This command cleans up object files, etc. clean: diff --git a/hrldas/IO_code/MosaicAverageMod.F90 b/hrldas/IO_code/MosaicAverageMod.F90 new file mode 100644 index 0000000..9d9bed7 --- /dev/null +++ b/hrldas/IO_code/MosaicAverageMod.F90 @@ -0,0 +1,116 @@ +module MosaicAverageMod + + !!! This module is part of NoahMP Mosaic/Subgrid Tiling Scheme + !!! Purpose: To calculate grid average value from all subgrid fractions + + ! ------------------------ Code history ----------------------------------- + ! Original code : Prasanth Valayamkunnath (IISER Thiruvananthapuram) + ! Date : September 12, 2025 + ! ------------------------------------------------------------------------- + + use Machine + use NoahmpIOVarType + + implicit none + + ! Interface block for MosaicAverage + interface MosaicAverage + module procedure MosaicAverage_2d + module procedure MosaicAverage_3d + module procedure MosaicAverage_2d_int + end interface MosaicAverage + + contains + + !=== Calculate averages along subgrid fractions ===! + + function MosaicAverage_2d(InVariable,NMPIO) result(OutAverage) + real(kind=kind_noahmp), dimension(:,:,:), intent(in) :: InVariable + real(kind=kind_noahmp), allocatable, dimension(:,:) :: OutAverage + type(NoahmpIO_type), intent(in) :: NMPIO + integer :: ixpar, jxpar, nxpar + + ! Get dimensions + ixpar = size(InVariable, 1) + jxpar = size(InVariable, 2) + nxpar = size(InVariable, 3) + + ! Check dimensions of SubGrdFracMosaic + if (size(NMPIO%SubGrdFracMosaic, 1) /= ixpar .or. & + size(NMPIO%SubGrdFracMosaic, 2) /= jxpar .or. & + size(NMPIO%SubGrdFracMosaic, 3) /= nxpar) then + stop "Error: Dimension mismatch in NoahmpIO%SubGrdFracMosaic for MosaicAverage_2d" + end if + + ! Allocate output array + allocate(OutAverage(ixpar, jxpar)) + + ! Calculate weighted average + OutAverage = sum(InVariable * NMPIO%SubGrdFracMosaic, dim=3) + + end function MosaicAverage_2d + + function MosaicAverage_3d(InVariable,NMPIO) result(OutAverage) + real(kind=kind_noahmp), dimension(:,:,:,:), intent(in) :: InVariable + real(kind=kind_noahmp), allocatable, dimension(:,:,:) :: OutAverage + real(kind=kind_noahmp), allocatable, dimension(:,:,:,:) :: SubGrdFrac + type(NoahmpIO_type), intent(in) :: NMPIO + integer :: ixpar, jxpar, kxpar, nxpar, k + + ! Get dimensions + ixpar = size(InVariable, 1) + kxpar = size(InVariable, 2) + jxpar = size(InVariable, 3) + nxpar = size(InVariable, 4) + + ! Check dimensions of SubGrdFracMosaic + if (size(NMPIO%SubGrdFracMosaic, 1) /= ixpar .or. & + size(NMPIO%SubGrdFracMosaic, 2) /= jxpar .or. & + size(NMPIO%SubGrdFracMosaic, 3) /= nxpar) then + stop "Error: Dimension mismatch in NoahmpIO%SubGrdFracMosaic for MosaicAverage_3d" + end if + + ! Allocate arrays + allocate(OutAverage(ixpar, kxpar, jxpar)) + allocate(SubGrdFrac(ixpar, kxpar, jxpar, nxpar)) + + ! Populate SubGrdFrac + do k = 1, kxpar + SubGrdFrac(:, k, :, :) = NMPIO%SubGrdFracMosaic + end do + + ! Calculate weighted average + OutAverage = sum(InVariable * SubGrdFrac, dim=4) + + ! Deallocate temporary array + deallocate(SubGrdFrac) + + end function MosaicAverage_3d + + function MosaicAverage_2d_int (InVariable, NMPIO) result(OutAverage) + integer, dimension(:,:,:), intent(in) :: InVariable + integer, allocatable, dimension(:,:) :: OutAverage + type(NoahmpIO_type), intent(in) :: NMPIO + integer :: ixpar, jxpar, nxpar + + ! Get dimensions + ixpar = size(InVariable, 1) + jxpar = size(InVariable, 2) + nxpar = size(InVariable, 3) + + ! Check dimensions of SubGrdFracMosaic + if (size(NMPIO%SubGrdFracMosaic, 1) /= ixpar .or. & + size(NMPIO%SubGrdFracMosaic, 2) /= jxpar .or. & + size(NMPIO%SubGrdFracMosaic, 3) /= nxpar) then + stop "Error: Dimension mismatch in NoahmpIO%SubGrdFracMosaic for MosaicAverage_2d" + end if + + ! Allocate output array + allocate(OutAverage(ixpar, jxpar)) + + ! Calculate weighted average + OutAverage = nint(sum(InVariable * NMPIO%SubGrdFracMosaic, dim=3)) + + end function MosaicAverage_2d_int + +end module MosaicAverageMod \ No newline at end of file diff --git a/hrldas/IO_code/ReadNoahmpMosaicRestartMod.F90 b/hrldas/IO_code/ReadNoahmpMosaicRestartMod.F90 new file mode 100644 index 0000000..59ddda2 --- /dev/null +++ b/hrldas/IO_code/ReadNoahmpMosaicRestartMod.F90 @@ -0,0 +1,250 @@ +module ReadNoahmpMosaicRestartMod + +!!! This module part of NoahMP Mosaic/Subgrid Tiling Scheme +!!! Purpose: To write grid average values of Noah-MP Mosaic. + +! ------------------------ Code history ----------------------------------- +! Original code : Prasanth Valayamkunnath (IISER Thiruvananthapuram) +! Date : September 12, 2025 +! ------------------------------------------------------------------------- + + use Machine + use NoahmpIOVarType + use module_hrldas_netcdf_io + + implicit none + +contains + +!=== sort landuse/soiltype/hydrotype index based on area fraction and identify most dominant types + + subroutine ReadNoahmpMosaicRestart (NoahmpIO) + + implicit none + + type(NoahmpIO_type), intent(inout) :: NoahmpIO + + ! local + integer :: xstart + integer :: xend + integer :: ixfull + integer :: jxfull + integer :: ntile + + xstart = NoahmpIO%xstart + xend = NoahmpIO%xend + ixfull = NoahmpIO%ixfull + jxfull = NoahmpIO%jxfull + ntile = NoahmpIO%NTilesMax + + call get_from_restart_mosaic(xstart, xend, xstart, ixfull, jxfull, ntile, "SOIL_T" , NoahmpIO%TSLB ) + call get_from_restart_mosaic(xstart, xend, xstart, ixfull, jxfull, ntile, "SNOW_T" , NoahmpIO%TSNOXY ) + call get_from_restart_mosaic(xstart, xend, xstart, ixfull, jxfull, ntile, "SMC" , NoahmpIO%SMOIS ) + call get_from_restart_mosaic(xstart, xend, xstart, ixfull, jxfull, ntile, "SH2O" , NoahmpIO%SH2O ) + call get_from_restart_mosaic(xstart, xend, xstart, ixfull, jxfull, ntile, "ZSNSO" , NoahmpIO%ZSNSOXY ) + call get_from_restart_mosaic(xstart, xend, xstart, ixfull, jxfull, ntile, "SNICE" , NoahmpIO%SNICEXY ) + call get_from_restart_mosaic(xstart, xend, xstart, ixfull, jxfull, ntile, "SNLIQ" , NoahmpIO%SNLIQXY ) + call get_from_restart_mosaic(xstart, xend, xstart, ixfull, jxfull, ntile, "FWET" , NoahmpIO%FWETXY ) + call get_from_restart_mosaic(xstart, xend, xstart, ixfull, jxfull, ntile, "SNEQVO" , NoahmpIO%SNEQVOXY ) + call get_from_restart_mosaic(xstart, xend, xstart, ixfull, jxfull, ntile, "EAH" , NoahmpIO%EAHXY ) + call get_from_restart_mosaic(xstart, xend, xstart, ixfull, jxfull, ntile, "TAH" , NoahmpIO%TAHXY ) + call get_from_restart_mosaic(xstart, xend, xstart, ixfull, jxfull, ntile, "ALBOLD" , NoahmpIO%ALBOLDXY ) + call get_from_restart_mosaic(xstart, xend, xstart, ixfull, jxfull, ntile, "CM" , NoahmpIO%CMXY ) + call get_from_restart_mosaic(xstart, xend, xstart, ixfull, jxfull, ntile, "CH" , NoahmpIO%CHXY ) + call get_from_restart_mosaic(xstart, xend, xstart, ixfull, jxfull, ntile, "ISNOW" , NoahmpIO%ISNOWXY ) + call get_from_restart_mosaic(xstart, xend, xstart, ixfull, jxfull, ntile, "CANLIQ" , NoahmpIO%CANLIQXY ) + call get_from_restart_mosaic(xstart, xend, xstart, ixfull, jxfull, ntile, "CANICE" , NoahmpIO%CANICEXY ) + call get_from_restart_mosaic(xstart, xend, xstart, ixfull, jxfull, ntile, "SNEQV" , NoahmpIO%SNOW ) + call get_from_restart_mosaic(xstart, xend, xstart, ixfull, jxfull, ntile, "SNOWH" , NoahmpIO%SNOWH ) + call get_from_restart_mosaic(xstart, xend, xstart, ixfull, jxfull, ntile, "TV" , NoahmpIO%TVXY ) + call get_from_restart_mosaic(xstart, xend, xstart, ixfull, jxfull, ntile, "TG" , NoahmpIO%TGXY ) + call get_from_restart_mosaic(xstart, xend, xstart, ixfull, jxfull, ntile, "ZWT" , NoahmpIO%ZWTXY ) + call get_from_restart_mosaic(xstart, xend, xstart, ixfull, jxfull, ntile, "WA" , NoahmpIO%WAXY ) + call get_from_restart_mosaic(xstart, xend, xstart, ixfull, jxfull, ntile, "WT" , NoahmpIO%WTXY ) + call get_from_restart_mosaic(xstart, xend, xstart, ixfull, jxfull, ntile, "WSLAKE" , NoahmpIO%WSLAKEXY ) + call get_from_restart_mosaic(xstart, xend, xstart, ixfull, jxfull, ntile, "LFMASS" , NoahmpIO%LFMASSXY ) + call get_from_restart_mosaic(xstart, xend, xstart, ixfull, jxfull, ntile, "RTMASS" , NoahmpIO%RTMASSXY ) + call get_from_restart_mosaic(xstart, xend, xstart, ixfull, jxfull, ntile, "STMASS" , NoahmpIO%STMASSXY ) + + call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "CROPCAT" , NoahmpIO%CROPCAT ) + + call get_from_restart_mosaic(xstart, xend, xstart, ixfull, jxfull, ntile, "WOOD" , NoahmpIO%WOODXY ) + call get_from_restart_mosaic(xstart, xend, xstart, ixfull, jxfull, ntile, "GRAIN" , NoahmpIO%GRAINXY ) + call get_from_restart_mosaic(xstart, xend, xstart, ixfull, jxfull, ntile, "GDD" , NoahmpIO%GDDXY ) + call get_from_restart_mosaic(xstart, xend, xstart, ixfull, jxfull, ntile, "STBLCP" , NoahmpIO%STBLCPXY ) + call get_from_restart_mosaic(xstart, xend, xstart, ixfull, jxfull, ntile, "FASTCP" , NoahmpIO%FASTCPXY ) + call get_from_restart_mosaic(xstart, xend, xstart, ixfull, jxfull, ntile, "LAI" , NoahmpIO%LAI ) + call get_from_restart_mosaic(xstart, xend, xstart, ixfull, jxfull, ntile, "SAI" , NoahmpIO%XSAIXY ) + call get_from_restart_mosaic(xstart, xend, xstart, ixfull, jxfull, ntile, "VEGFRA" , NoahmpIO%VEGFRA ) + call get_from_restart_mosaic(xstart, xend, xstart, ixfull, jxfull, ntile, "GVFMIN" , NoahmpIO%GVFMIN ) + call get_from_restart_mosaic(xstart, xend, xstart, ixfull, jxfull, ntile, "GVFMAX" , NoahmpIO%GVFMAX ) + call get_from_restart_mosaic(xstart, xend, xstart, ixfull, jxfull, ntile, "ACMELT" , NoahmpIO%ACSNOM ) + call get_from_restart_mosaic(xstart, xend, xstart, ixfull, jxfull, ntile, "ACSNOW" , NoahmpIO%ACSNOW ) + call get_from_restart_mosaic(xstart, xend, xstart, ixfull, jxfull, ntile, "TAUSS" , NoahmpIO%TAUSSXY ) + call get_from_restart_mosaic(xstart, xend, xstart, ixfull, jxfull, ntile, "QSFC" , NoahmpIO%QSFC ) + call get_from_restart_mosaic(xstart, xend, xstart, ixfull, jxfull, ntile, "SFCRUNOFF",NoahmpIO%SFCRUNOFF) + call get_from_restart_mosaic(xstart, xend, xstart, ixfull, jxfull, ntile, "UDRUNOFF" ,NoahmpIO%UDRUNOFF ) + call get_from_restart_mosaic(xstart, xend, xstart, ixfull, jxfull, ntile, "QTDRAIN" ,NoahmpIO%QTDRAIN ) + call get_from_restart_mosaic(xstart, xend, xstart, ixfull, jxfull, ntile, "ACC_SSOIL" , NoahmpIO%ACC_SSOILXY ) + call get_from_restart_mosaic(xstart, xend, xstart, ixfull, jxfull, ntile, "ACC_QINSUR", NoahmpIO%ACC_QINSURXY) + call get_from_restart_mosaic(xstart, xend, xstart, ixfull, jxfull, ntile, "ACC_QSEVA" , NoahmpIO%ACC_QSEVAXY ) + call get_from_restart_mosaic(xstart, xend, xstart, ixfull, jxfull, ntile, "ACC_ETRANI", NoahmpIO%ACC_ETRANIXY) + call get_from_restart_mosaic(xstart, xend, xstart, ixfull, jxfull, ntile, "ACC_DWATER", NoahmpIO%ACC_DWATERXY) + call get_from_restart_mosaic(xstart, xend, xstart, ixfull, jxfull, ntile, "ACC_PRCP" , NoahmpIO%ACC_PRCPXY ) + call get_from_restart_mosaic(xstart, xend, xstart, ixfull, jxfull, ntile, "ACC_ECAN" , NoahmpIO%ACC_ECANXY ) + call get_from_restart_mosaic(xstart, xend, xstart, ixfull, jxfull, ntile, "ACC_ETRAN" , NoahmpIO%ACC_ETRANXY ) + call get_from_restart_mosaic(xstart, xend, xstart, ixfull, jxfull, ntile, "ACC_EDIR" , NoahmpIO%ACC_EDIRXY ) + call get_from_restart_mosaic(xstart, xend, xstart, ixfull, jxfull, ntile, "ACC_GLAFLW", NoahmpIO%ACC_GLAFLWXY) + call get_from_restart_mosaic(xstart, xend, xstart, ixfull, jxfull, ntile, "ALBSOILDIR", NoahmpIO%ALBSOILDIRXY) + call get_from_restart_mosaic(xstart, xend, xstart, ixfull, jxfull, ntile, "ALBSOILDIF", NoahmpIO%ALBSOILDIFXY) + + ! below for SNICAR snow albedo scheme + if (NoahmpIO%IOPT_ALB == 3)then + call get_from_restart_mosaic(xstart, xend, xstart, ixfull, jxfull, ntile, "SNRDS" , NoahmpIO%SNRDSXY ) + call get_from_restart_mosaic(xstart, xend, xstart, ixfull, jxfull, ntile, "SNFR" , NoahmpIO%SNFRXY ) + call get_from_restart_mosaic(xstart, xend, xstart, ixfull, jxfull, ntile, "BCPHI" , NoahmpIO%BCPHIXY ) + call get_from_restart_mosaic(xstart, xend, xstart, ixfull, jxfull, ntile, "BCPHO" , NoahmpIO%BCPHOXY ) + call get_from_restart_mosaic(xstart, xend, xstart, ixfull, jxfull, ntile, "OCPHI" , NoahmpIO%OCPHIXY ) + call get_from_restart_mosaic(xstart, xend, xstart, ixfull, jxfull, ntile, "OCPHO" , NoahmpIO%OCPHOXY ) + call get_from_restart_mosaic(xstart, xend, xstart, ixfull, jxfull, ntile, "DUST1" , NoahmpIO%DUST1XY ) + call get_from_restart_mosaic(xstart, xend, xstart, ixfull, jxfull, ntile, "DUST2" , NoahmpIO%DUST2XY ) + call get_from_restart_mosaic(xstart, xend, xstart, ixfull, jxfull, ntile, "DUST3" , NoahmpIO%DUST3XY ) + call get_from_restart_mosaic(xstart, xend, xstart, ixfull, jxfull, ntile, "DUST4" , NoahmpIO%DUST4XY ) + call get_from_restart_mosaic(xstart, xend, xstart, ixfull, jxfull, ntile, "DUST5" , NoahmpIO%DUST5XY ) + endif + + ! below for irrigation scheme + if ( NoahmpIO%IOPT_IRR > 0 ) then + call get_from_restart_mosaic(xstart, xend, xstart, ixfull, jxfull, ntile, "IRNUMSI" , NoahmpIO%IRNUMSI ) + call get_from_restart_mosaic(xstart, xend, xstart, ixfull, jxfull, ntile, "IRNUMMI" , NoahmpIO%IRNUMMI ) + call get_from_restart_mosaic(xstart, xend, xstart, ixfull, jxfull, ntile, "IRNUMFI" , NoahmpIO%IRNUMFI ) + call get_from_restart_mosaic(xstart, xend, xstart, ixfull, jxfull, ntile, "IRWATSI" , NoahmpIO%IRWATSI ) + call get_from_restart_mosaic(xstart, xend, xstart, ixfull, jxfull, ntile, "IRWATMI" , NoahmpIO%IRWATMI ) + call get_from_restart_mosaic(xstart, xend, xstart, ixfull, jxfull, ntile, "IRWATFI" , NoahmpIO%IRWATFI ) + call get_from_restart_mosaic(xstart, xend, xstart, ixfull, jxfull, ntile, "IRSIVOL" , NoahmpIO%IRSIVOL ) + call get_from_restart_mosaic(xstart, xend, xstart, ixfull, jxfull, ntile, "IRMIVOL" , NoahmpIO%IRMIVOL ) + call get_from_restart_mosaic(xstart, xend, xstart, ixfull, jxfull, ntile, "IRFIVOL" , NoahmpIO%IRFIVOL ) + call get_from_restart_mosaic(xstart, xend, xstart, ixfull, jxfull, ntile, "IRELOSS" , NoahmpIO%IRELOSS ) + call get_from_restart_mosaic(xstart, xend, xstart, ixfull, jxfull, ntile, "IRRSPLH" , NoahmpIO%IRRSPLH ) + endif + + ! below for MMF groundwater scheme + if ( NoahmpIO%IOPT_RUNSUB == 5 ) then + call get_from_restart_mosaic(xstart, xend, xstart, ixfull, jxfull, ntile, "SMOISEQ" , NoahmpIO%SMOISEQ ) + call get_from_restart_mosaic(xstart, xend, xstart, ixfull, jxfull, ntile, "DEEPRECHXY", NoahmpIO%DEEPRECHXY ) + call get_from_restart_mosaic(xstart, xend, xstart, ixfull, jxfull, ntile, "SMCWTDXY" , NoahmpIO%SMCWTDXY ) + + call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "AREAXY" , NoahmpIO%AREAXY ) + call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "QRFXY" , NoahmpIO%QRFXY ) + call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "QSPRINGXY" , NoahmpIO%QSPRINGXY ) + call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "QSLATXY" , NoahmpIO%QSLATXY ) + call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "QRFSXY" , NoahmpIO%QRFSXY ) + call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "QSPRINGSXY", NoahmpIO%QSPRINGSXY ) + call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "RECHXY" , NoahmpIO%RECHXY ) + call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "FDEPTHXY" ,NoahmpIO%FDEPTHXY ) + call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "RIVERCONDXY",NoahmpIO%RIVERCONDXY) + call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "RIVERBEDXY" ,NoahmpIO%RIVERBEDXY ) + call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "EQZWT" ,NoahmpIO%EQZWT ) + call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "PEXPXY" ,NoahmpIO%PEXPXY ) + endif + + ! for wetland scheme + if ( NoahmpIO%IOPT_WETLAND > 0 ) then + call get_from_restart_mosaic(xstart, xend, xstart, ixfull, jxfull, ntile, "FSATXY" , NoahmpIO%FSATXY ) + call get_from_restart_mosaic(xstart, xend, xstart, ixfull, jxfull, ntile, "WSURFXY" , NoahmpIO%WSURFXY ) + endif + + ! below for urban model + if ( NoahmpIO%SF_URBAN_PHYSICS > 0 ) then + call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "SH_URB2D" , NoahmpIO%SH_URB2D ) + call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "LH_URB2D" , NoahmpIO%LH_URB2D ) + call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "G_URB2D" , NoahmpIO%G_URB2D ) + call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "RN_URB2D" , NoahmpIO%RN_URB2D ) + call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "TS_URB2D" , NoahmpIO%TS_URB2D ) + call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "FRC_URB2D" , NoahmpIO%FRC_URB2D ) + call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "UTYPE_URB2D" , NoahmpIO%UTYPE_URB2D ) + call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "LP_URB2D" , NoahmpIO%LP_URB2D ) + call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "LB_URB2D" , NoahmpIO%LB_URB2D ) + call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "HGT_URB2D" , NoahmpIO%HGT_URB2D ) + call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "MH_URB2D" , NoahmpIO%MH_URB2D ) + call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "STDH_URB2D" , NoahmpIO%STDH_URB2D ) + call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "HI_URB2D" , NoahmpIO%HI_URB2D ) + call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "LF_URB2D" , NoahmpIO%LF_URB2D ) + + if ( NoahmpIO%SF_URBAN_PHYSICS == 1 ) then ! single layer urban model + call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "CMR_SFCDIF" , NoahmpIO%CMR_SFCDIF ) + call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "CHR_SFCDIF" , NoahmpIO%CHR_SFCDIF ) + call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "CMC_SFCDIF" , NoahmpIO%CMC_SFCDIF ) + call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "CHC_SFCDIF" , NoahmpIO%CHC_SFCDIF ) + call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "CMGR_SFCDIF" , NoahmpIO%CMGR_SFCDIF ) + call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "CHGR_SFCDIF" , NoahmpIO%CHGR_SFCDIF ) + call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "TR_URB2D" , NoahmpIO%TR_URB2D ) + call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "TB_URB2D" , NoahmpIO%TB_URB2D ) + call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "TG_URB2D" , NoahmpIO%TG_URB2D ) + call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "TC_URB2D" , NoahmpIO%TC_URB2D ) + call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "QC_URB2D" , NoahmpIO%QC_URB2D ) + call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "UC_URB2D" , NoahmpIO%UC_URB2D ) + call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "XXXR_URB2D" , NoahmpIO%XXXR_URB2D ) + call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "XXXB_URB2D" , NoahmpIO%XXXB_URB2D ) + call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "XXXG_URB2D" , NoahmpIO%XXXG_URB2D ) + call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "XXXC_URB2D" , NoahmpIO%XXXC_URB2D ) + call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "TRL_URB3D" , NoahmpIO%TRL_URB3D ) + call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "TBL_URB3D" , NoahmpIO%TBL_URB3D ) + call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "TGL_URB3D" , NoahmpIO%TGL_URB3D ) + call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "CMCR_URB2D" , NoahmpIO%CMCR_URB2D ) + call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "TGR_URB2D" , NoahmpIO%TGR_URB2D ) + call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "TGRL_URB3D" , NoahmpIO%TGRL_URB3D ) + call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "SMR_URB3D" , NoahmpIO%SMR_URB3D ) + call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "DRELR_URB2D" , NoahmpIO%DRELR_URB2D ) + call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "DRELB_URB2D" , NoahmpIO%DRELB_URB2D ) + call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "DRELG_URB2D" , NoahmpIO%DRELG_URB2D ) + call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "FLXHUMR_URB2D" ,NoahmpIO%FLXHUMR_URB2D ) + call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "FLXHUMB_URB2D" ,NoahmpIO%FLXHUMB_URB2D ) + call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "FLXHUMG_URB2D" ,NoahmpIO%FLXHUMG_URB2D ) + endif + + if ( (NoahmpIO%SF_URBAN_PHYSICS == 2) .or. (NoahmpIO%SF_URBAN_PHYSICS == 3) ) then ! BEP or BEM urban models + call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "TRB_URB4D" , NoahmpIO%TRB_URB4D ) + call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "TW1_URB4D" , NoahmpIO%TW1_URB4D ) + call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "TW2_URB4D" , NoahmpIO%TW2_URB4D ) + call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "TGB_URB4D" , NoahmpIO%TGB_URB4D ) + call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "SFW1_URB3D" , NoahmpIO%SFW1_URB3D ) + call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "SFW2_URB3D" , NoahmpIO%SFW2_URB3D ) + call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "SFR_URB3D" , NoahmpIO%SFR_URB3D ) + call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "SFG_URB3D" , NoahmpIO%SFG_URB3D ) + endif + + if ( NoahmpIO%SF_URBAN_PHYSICS == 3 ) then ! BEM urban model + call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "TLEV_URB3D" , NoahmpIO%TLEV_URB3D ) + call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "QLEV_URB3D" , NoahmpIO%QLEV_URB3D ) + call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "TW1LEV_URB3D" , NoahmpIO%TW1LEV_URB3D ) + call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "TW2LEV_URB3D" , NoahmpIO%TW2LEV_URB3D ) + call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "TGLEV_URB3D" , NoahmpIO%TGLEV_URB3D ) + call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "TFLEV_URB3D" , NoahmpIO%TFLEV_URB3D ) + call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "SF_AC_URB3D" , NoahmpIO%SF_AC_URB3D ) + call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "LF_AC_URB3D" , NoahmpIO%LF_AC_URB3D ) + call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "CM_AC_URB3D" , NoahmpIO%CM_AC_URB3D ) + call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "SFVENT_URB3D" , NoahmpIO%SFVENT_URB3D ) + call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "LFVENT_URB3D" , NoahmpIO%LFVENT_URB3D ) + call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "SFWIN1_URB3D" , NoahmpIO%SFWIN1_URB3D ) + call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "SFWIN2_URB3D" , NoahmpIO%SFWIN2_URB3D ) + call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "EP_PV_URB3D" , NoahmpIO%EP_PV_URB3D ) + call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "T_PV_URB3D" , NoahmpIO%T_PV_URB3D ) + call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "TRV_URB4D" , NoahmpIO%TRV_URB4D ) + call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "QR_URB4D" , NoahmpIO%QR_URB4D ) + call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "QGR_URB3D" , NoahmpIO%QGR_URB3D ) + call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "TGR_URB3D" , NoahmpIO%TGR_URB3D ) + call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "DRAIN_URB4D" , NoahmpIO%DRAIN_URB4D ) + call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "DRAINGR_URB3D" ,NoahmpIO%DRAINGR_URB3D ) + call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "SFRV_URB3D" , NoahmpIO%SFRV_URB3D ) + call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "LFRV_URB3D" , NoahmpIO%LFRV_URB3D ) + call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "DGR_URB3D" , NoahmpIO%DGR_URB3D ) + call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "DG_URB3D" , NoahmpIO%DG_URB3D ) + call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "LFR_URB3D" , NoahmpIO%LFR_URB3D ) + call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "LFG_URB3D" , NoahmpIO%LFG_URB3D ) + endif + endif + + end subroutine ReadNoahmpMosaicRestart + +end module ReadNoahmpMosaicRestartMod \ No newline at end of file diff --git a/hrldas/IO_code/WriteNoahmpMosaicGridAverageOutputMod.F90 b/hrldas/IO_code/WriteNoahmpMosaicGridAverageOutputMod.F90 new file mode 100644 index 0000000..34b686b --- /dev/null +++ b/hrldas/IO_code/WriteNoahmpMosaicGridAverageOutputMod.F90 @@ -0,0 +1,245 @@ +module WriteNoahmpMosaicGridAverageOutputMod + +!!! This module part of NoahMP Mosaic/Subgrid Tiling Scheme +!!! Purpose: To write grid average values of Noah-MP Mosaic. + +! ------------------------ Code history ----------------------------------- +! Original code : Prasanth Valayamkunnath (IISER Thiruvananthapuram) +! Date : September 12, 2025 +! ------------------------------------------------------------------------- + + use Machine + use NoahmpIOVarType + use module_hrldas_netcdf_io + use MosaicAverageMod + + implicit none + +contains + +!=== sort landuse/soiltype/hydrotype index based on area fraction and identify most dominant types + + subroutine WriteNoahmpMosaicGridAverageOutput (NoahmpIO) + + implicit none + + type(NoahmpIO_type), intent(inout) :: NoahmpIO + + + ! For 3D arrays, we need to know whether the Z dimension is snow layers, or soil layers. + + ! Properties - Assigned or predicted + call add_to_output( NoahmpIO%IVGTYP , "IVGTYP" , "Dominant vegetation category" , "category" ) + call add_to_output( NoahmpIO%ISLTYP , "ISLTYP" , "Dominant soil category" , "category" ) + call add_to_output( MosaicAverage(NoahmpIO%FVEGXY, NoahmpIO) , "FVEG" , "Green Vegetation Fraction" , "-" ) + call add_to_output( MosaicAverage(NoahmpIO%LAI, NoahmpIO) , "LAI" , "Leaf area index" , "m2/m2" ) + call add_to_output( MosaicAverage(NoahmpIO%XSAIXY, NoahmpIO) , "SAI" , "Stem area index" , "m2/m2" ) + ! Forcing + call add_to_output( NoahmpIO%SWDOWN , "SWFORC" , "Shortwave forcing" , "W/m2" ) + call add_to_output( NoahmpIO%COSZEN , "COSZ" , "Cosine of zenith angle" , "-" ) + call add_to_output( NoahmpIO%GLW , "LWFORC" , "Longwave forcing" , "W/m2" ) + call add_to_output( NoahmpIO%RAINBL , "RAINRATE", "Precipitation rate" , "mm/timestep" ) + ! Grid energy budget terms + call add_to_output( MosaicAverage(NoahmpIO%EMISS, NoahmpIO) , "EMISS" , "Grid emissivity" , "-" ) + call add_to_output( MosaicAverage(NoahmpIO%FSAXY, NoahmpIO) , "FSA" , "Total absorbed SW radiation" , "W/m2" ) + call add_to_output( MosaicAverage(NoahmpIO%FIRAXY, NoahmpIO) , "FIRA" , "Total net LW radiation to atmosphere" , "W/m2" ) + call add_to_output( MosaicAverage(NoahmpIO%GRDFLX, NoahmpIO) , "GRDFLX" , "Heat flux into the soil" , "W/m2" ) + call add_to_output( MosaicAverage(NoahmpIO%HFX, NoahmpIO) , "HFX" , "Total sensible heat to atmosphere" , "W/m2" ) + call add_to_output( MosaicAverage(NoahmpIO%LH, NoahmpIO) , "LH" , "Total latent heat to atmosphere" , "W/m2" ) + call add_to_output( MosaicAverage(NoahmpIO%ECANXY, NoahmpIO) , "ECAN" , "Canopy water evaporation rate" , "mm/s" ) + call add_to_output( MosaicAverage(NoahmpIO%ETRANXY, NoahmpIO) , "ETRAN" , "Transpiration rate" , "mm/s" ) + call add_to_output( MosaicAverage(NoahmpIO%EDIRXY, NoahmpIO) , "EDIR" , "Direct from soil evaporation rate" , "mm/s" ) + call add_to_output( MosaicAverage(NoahmpIO%ALBEDO, NoahmpIO) , "ALBEDO" , "Surface albedo" , "-" ) + ! Grid water budget terms - in addition to above + call add_to_output( MosaicAverage(NoahmpIO%UDRUNOFF, NoahmpIO) , "UGDRNOFF", "Accumulated underground runoff" , "mm" ) + call add_to_output( MosaicAverage(NoahmpIO%SFCRUNOFF, NoahmpIO) , "SFCRNOFF", "Accumulatetd surface runoff" , "mm" ) + call add_to_output( MosaicAverage(NoahmpIO%CANLIQXY, NoahmpIO) , "CANLIQ" , "Canopy liquid water content" , "mm" ) + call add_to_output( MosaicAverage(NoahmpIO%CANICEXY, NoahmpIO) , "CANICE" , "Canopy ice water content" , "mm" ) + call add_to_output( MosaicAverage(NoahmpIO%ZWTXY, NoahmpIO) , "ZWT" , "Depth to water table" , "m" ) + call add_to_output( MosaicAverage(NoahmpIO%WAXY, NoahmpIO) , "WA" , "Water in aquifer" , "mm" ) + call add_to_output( MosaicAverage(NoahmpIO%WTXY, NoahmpIO) , "WT" , "Water in aquifer and saturated soil" , "mm" ) + call add_to_output( MosaicAverage(NoahmpIO%QTDRAIN, NoahmpIO) , "QTDRAIN" , "Accumulated tile drainage" , "mm" ) + call add_to_output( MosaicAverage(NoahmpIO%PONDINGXY, NoahmpIO) , "PONDING" , "total surface ponding per time step" , "mm/s" ) + ! Additional needed to close the canopy energy budget + call add_to_output( MosaicAverage(NoahmpIO%SAVXY, NoahmpIO) , "SAV" , "Solar radiation absorbed by canopy" , "W/m2" ) + call add_to_output( MosaicAverage(NoahmpIO%TRXY, NoahmpIO) , "TR" , "Transpiration heat" , "W/m2" ) + call add_to_output( MosaicAverage(NoahmpIO%EVCXY, NoahmpIO) , "EVC" , "Canopy evap heat" , "W/m2" ) + call add_to_output( MosaicAverage(NoahmpIO%IRCXY, NoahmpIO) , "IRC" , "Canopy net LW rad" , "W/m2" ) + call add_to_output( MosaicAverage(NoahmpIO%SHCXY, NoahmpIO) , "SHC" , "Canopy sensible heat" , "W/m2" ) + ! Additional needed to close the under canopy ground energy budget + call add_to_output( MosaicAverage(NoahmpIO%IRGXY, NoahmpIO) , "IRG" , "below-canopy ground net LW rad" , "W/m2" ) + call add_to_output( MosaicAverage(NoahmpIO%SHGXY, NoahmpIO) , "SHG" , "below-canopy ground sensible heat" , "W/m2" ) + call add_to_output( MosaicAverage(NoahmpIO%EVGXY, NoahmpIO) , "EVG" , "below-canopy ground evap heat" , "W/m2" ) + call add_to_output( MosaicAverage(NoahmpIO%GHVXY, NoahmpIO) , "GHV" , "below-canopy ground heat to soil" , "W/m2" ) + ! Needed to close the bare ground energy budget + call add_to_output( MosaicAverage(NoahmpIO%SAGXY, NoahmpIO) , "SAG" , "Solar radiation absorbed by ground" , "W/m2" ) + call add_to_output( MosaicAverage(NoahmpIO%IRBXY, NoahmpIO) , "IRB" , "Net LW rad to atm bare ground" , "W/m2" ) + call add_to_output( MosaicAverage(NoahmpIO%SHBXY, NoahmpIO) , "SHB" , "Sensible heat to atm bare ground" , "W/m2" ) + call add_to_output( MosaicAverage(NoahmpIO%EVBXY, NoahmpIO) , "EVB" , "Evaporation heat to atm bare ground" , "W/m2" ) + call add_to_output( MosaicAverage(NoahmpIO%GHBXY, NoahmpIO) , "GHB" , "Ground heat flux to soil bare ground" , "W/m2" ) + ! Above-soil temperatures + call add_to_output( MosaicAverage(NoahmpIO%TRADXY, NoahmpIO) , "TRAD" , "Surface radiative temperature" , "K" ) + call add_to_output( MosaicAverage(NoahmpIO%TGXY, NoahmpIO) , "TG" , "Ground temperature" , "K" ) + call add_to_output( MosaicAverage(NoahmpIO%TVXY, NoahmpIO) , "TV" , "Vegetation temperature" , "K" ) + call add_to_output( MosaicAverage(NoahmpIO%TAHXY, NoahmpIO) , "TAH" , "Canopy air temperature" , "K" ) + call add_to_output( MosaicAverage(NoahmpIO%TGVXY, NoahmpIO) , "TGV" , "Ground surface Temp vegetated" , "K" ) + call add_to_output( MosaicAverage(NoahmpIO%TGBXY, NoahmpIO) , "TGB" , "Ground surface Temp bare" , "K" ) + call add_to_output( MosaicAverage(NoahmpIO%T2MVXY, NoahmpIO) , "T2MV" , "2m Air Temp vegetated" , "K" ) + call add_to_output( MosaicAverage(NoahmpIO%T2MBXY, NoahmpIO) , "T2MB" , "2m Air Temp bare" , "K" ) + ! Above-soil moisture + call add_to_output( MosaicAverage(NoahmpIO%Q2MVXY, NoahmpIO) , "Q2MV" , "2m mixing ratio vegetated" , "kg/kg" ) + call add_to_output( MosaicAverage(NoahmpIO%Q2MBXY, NoahmpIO) , "Q2MB" , "2m mixing ratio bare" , "kg/kg" ) + call add_to_output( MosaicAverage(NoahmpIO%EAHXY, NoahmpIO) , "EAH" , "Canopy air vapor pressure" , "Pa" ) + call add_to_output( MosaicAverage(NoahmpIO%FWETXY, NoahmpIO) , "FWET" , "Wetted fraction of canopy" , "fraction" ) + ! Snow and soil - 3D terms + call add_to_output( MosaicAverage(NoahmpIO%ZSNSOXY(:,-NoahmpIO%nsnow+1:0,:,:), NoahmpIO),"ZSNSO_SN","Snow layer depth from snow surface","m","SNOW") + call add_to_output( MosaicAverage(NoahmpIO%SNICEXY, NoahmpIO) , "SNICE" , "Snow layer ice" , "mm" , "SNOW") + call add_to_output( MosaicAverage(NoahmpIO%SNLIQXY, NoahmpIO) , "SNLIQ" , "Snow layer liquid water" , "mm" , "SNOW") + call add_to_output( MosaicAverage(NoahmpIO%TSLB, NoahmpIO) , "SOIL_T" , "soil temperature" , "K" , "SOIL") + call add_to_output( MosaicAverage(NoahmpIO%SMOIS, NoahmpIO) , "SOIL_M" , "volumetric soil moisture" , "m3/m3" , "SOIL") + call add_to_output( MosaicAverage(NoahmpIO%SH2O, NoahmpIO) , "SOIL_W" , "liquid volumetric soil moisture" , "m3/m3" , "SOIL") + call add_to_output( MosaicAverage(NoahmpIO%TSNOXY, NoahmpIO) , "SNOW_T" , "snow temperature" , "K" , "SNOW") + call add_to_output( MosaicAverage(NoahmpIO%ALBSNOWDIRXY, NoahmpIO), "ALBSNOWDIR" , "Snow albedo (direct)" , "-" , "RADN") + call add_to_output( MosaicAverage(NoahmpIO%ALBSNOWDIFXY, NoahmpIO), "ALBSNOWDIF" , "Snow albedo (diffuse)" , "-" , "RADN") + call add_to_output( MosaicAverage(NoahmpIO%ALBSFCDIRXY, NoahmpIO) , "ALBSFCDIR" , "Surface albedo (direct)" , "-" , "RADN") + call add_to_output( MosaicAverage(NoahmpIO%ALBSFCDIFXY, NoahmpIO) , "ALBSFCDIF" , "Surface albedo (diffuse)" , "-" , "RADN") + call add_to_output( MosaicAverage(NoahmpIO%ALBSOILDIRXY, NoahmpIO), "ALBSOILDIR" , "Soil albedo (direct)" , "-" , "RADN") + call add_to_output( MosaicAverage(NoahmpIO%ALBSOILDIFXY, NoahmpIO), "ALBSOILDIF" , "Soil albedo (diffuse)" , "-" , "RADN") + ! Snow - 2D terms + call add_to_output( MosaicAverage(NoahmpIO%SNOWH, NoahmpIO) , "SNOWH" , "Snow depth" , "m" ) + call add_to_output( MosaicAverage(NoahmpIO%SNOW, NoahmpIO) , "SNEQV" , "Snow water equivalent" , "mm" ) + call add_to_output( MosaicAverage(NoahmpIO%QSNOWXY, NoahmpIO) , "QSNOW" , "Snowfall rate on the ground" , "mm/s" ) + call add_to_output( MosaicAverage(NoahmpIO%QRAINXY, NoahmpIO) , "QRAIN" , "Rainfall rate on the ground" , "mm/s" ) + call add_to_output( MosaicAverage(NoahmpIO%ISNOWXY, NoahmpIO) , "ISNOW" , "Number of snow layers" , "-" ) + call add_to_output( MosaicAverage(NoahmpIO%SNOWC, NoahmpIO) , "FSNO" , "Snow-cover fraction on the ground" , "-" ) + call add_to_output( MosaicAverage(NoahmpIO%ACSNOW, NoahmpIO) , "ACSNOW" , "accumulated snow fall" , "mm" ) + call add_to_output( MosaicAverage(NoahmpIO%ACSNOM, NoahmpIO) , "ACSNOM" , "accumulated snow melt water" , "mm" ) + call add_to_output( MosaicAverage(NoahmpIO%QSNBOTXY, NoahmpIO) , "QSNBOT" , "water (melt+rain through) out of snow bottom" , "mm/s" ) + call add_to_output( MosaicAverage(NoahmpIO%QMELTXY, NoahmpIO) , "QMELT" , "snow melt due to phase change" , "mm/s" ) + ! SNICAR snow albedo scheme + if (NoahmpIO%IOPT_ALB == 3)then + call add_to_output( MosaicAverage(NoahmpIO%SNRDSXY, NoahmpIO) , "SNRDS" , "Snow layer effective grain radius" , "m-6" , "SNOW") + call add_to_output( MosaicAverage(NoahmpIO%SNFRXY, NoahmpIO) , "SNFR" , "Snow layer rate of freezing" , "mm/s" , "SNOW") + call add_to_output( MosaicAverage(NoahmpIO%BCPHIXY, NoahmpIO) , "BCPHI_Mass","hydrophilic BC mass in snow" , "kg/m2" , "SNOW") + call add_to_output( MosaicAverage(NoahmpIO%BCPHOXY, NoahmpIO) , "BCPHO_Mass","hydrophobic BC mass in snow" , "kg/m2" , "SNOW") + call add_to_output( MosaicAverage(NoahmpIO%OCPHIXY, NoahmpIO) , "OCPHI_Mass","hydrophilic OC mass in snow" , "kg/m2" , "SNOW") + call add_to_output( MosaicAverage(NoahmpIO%OCPHOXY, NoahmpIO) , "OCPHO_Mass","hydrophobic OC mass in snow" , "kg/m2" , "SNOW") + call add_to_output( MosaicAverage(NoahmpIO%DUST1XY, NoahmpIO) , "DUST1_Mass","dust size bin 1 mass in snow" , "kg/m2" , "SNOW") + call add_to_output( MosaicAverage(NoahmpIO%DUST2XY, NoahmpIO) , "DUST2_Mass","dust size bin 2 mass in snow" , "kg/m2" , "SNOW") + call add_to_output( MosaicAverage(NoahmpIO%DUST3XY, NoahmpIO) , "DUST3_Mass","dust size bin 3 mass in snow" , "kg/m2" , "SNOW") + call add_to_output( MosaicAverage(NoahmpIO%DUST4XY, NoahmpIO) , "DUST4_Mass","dust size bin 4 mass in snow" , "kg/m2" , "SNOW") + call add_to_output( MosaicAverage(NoahmpIO%DUST5XY, NoahmpIO) , "DUST5_Mass","dust size bin 5 mass in snow" , "kg/m2" , "SNOW") + call add_to_output( MosaicAverage(NoahmpIO%MassConcBCPHIXY, NoahmpIO), "BCPHI_MassConc","hydrophilic BC mass concentration in snow", "kg/kg", "SNOW") + call add_to_output( MosaicAverage(NoahmpIO%MassConcBCPHOXY, NoahmpIO), "BCPHO_MassConc","hydrophobic BC mass concentration in snow", "kg/kg", "SNOW") + call add_to_output( MosaicAverage(NoahmpIO%MassConcOCPHIXY, NoahmpIO), "OCPHI_MassConc","hydrophilic OC mass concentration in snow", "kg/kg", "SNOW") + call add_to_output( MosaicAverage(NoahmpIO%MassConcOCPHOXY, NoahmpIO), "OCPHO_MassConc","hydrophobic OC mass concentration in snow", "kg/kg", "SNOW") + call add_to_output( MosaicAverage(NoahmpIO%MassConcDUST1XY, NoahmpIO), "DUST1_MassConc","dust size bin 1 mass concentration in snow", "kg/kg", "SNOW") + call add_to_output( MosaicAverage(NoahmpIO%MassConcDUST2XY, NoahmpIO), "DUST2_MassConc","dust size bin 2 mass concentration in snow", "kg/kg", "SNOW") + call add_to_output( MosaicAverage(NoahmpIO%MassConcDUST3XY, NoahmpIO), "DUST3_MassConc","dust size bin 3 mass concentration in snow", "kg/kg", "SNOW") + call add_to_output( MosaicAverage(NoahmpIO%MassConcDUST4XY, NoahmpIO), "DUST4_MassConc","dust size bin 4 mass concentration in snow", "kg/kg", "SNOW") + call add_to_output( MosaicAverage(NoahmpIO%MassConcDUST5XY, NoahmpIO), "DUST5_MassConc","dust size bin 5 mass concentration in snow", "kg/kg", "SNOW") + endif + ! Exchange coefficients + call add_to_output( MosaicAverage(NoahmpIO%CMXY, NoahmpIO) , "CM" , "Momentum drag coefficient" , "m/s" ) + call add_to_output( MosaicAverage(NoahmpIO%CHXY, NoahmpIO) , "CH" , "Sensible heat exchange coefficient" , "m/s" ) + call add_to_output( MosaicAverage(NoahmpIO%CHVXY, NoahmpIO) , "CHV" , "Exchange coefficient vegetated" , "m/s" ) + call add_to_output( MosaicAverage(NoahmpIO%CHBXY, NoahmpIO) , "CHB" , "Exchange coefficient bare" , "m/s" ) + call add_to_output( MosaicAverage(NoahmpIO%CHLEAFXY, NoahmpIO) , "CHLEAF" , "Exchange coefficient leaf" , "m/s" ) + call add_to_output( MosaicAverage(NoahmpIO%CHUCXY, NoahmpIO) , "CHUC" , "Exchange coefficient bare" , "m/s" ) + call add_to_output( MosaicAverage(NoahmpIO%CHV2XY, NoahmpIO) , "CHV2" , "Exchange coefficient 2-m vegetated" , "m/s" ) + call add_to_output( MosaicAverage(NoahmpIO%CHB2XY, NoahmpIO) , "CHB2" , "Exchange coefficient 2-m bare" , "m/s" ) + ! Carbon allocation model + call add_to_output( MosaicAverage(NoahmpIO%LFMASSXY, NoahmpIO) , "LFMASS" , "Leaf mass" , "g/m2" ) + call add_to_output( MosaicAverage(NoahmpIO%RTMASSXY, NoahmpIO) , "RTMASS" , "Mass of fine roots" , "g/m2" ) + call add_to_output( MosaicAverage(NoahmpIO%STMASSXY, NoahmpIO) , "STMASS" , "Stem mass" , "g/m2" ) + call add_to_output( MosaicAverage(NoahmpIO%WOODXY, NoahmpIO) , "WOOD" , "Mass of wood and woody roots" , "g/m2" ) + call add_to_output( MosaicAverage(NoahmpIO%GRAINXY, NoahmpIO) , "GRAIN" , "Mass of grain" , "g/m2" ) + call add_to_output( MosaicAverage(NoahmpIO%GDDXY, NoahmpIO) , "GDD" , "Growing degree days " , "-" ) + call add_to_output( MosaicAverage(NoahmpIO%STBLCPXY, NoahmpIO) , "STBLCP" , "Stable carbon in deep soil" , "gC/m2" ) + call add_to_output( MosaicAverage(NoahmpIO%FASTCPXY, NoahmpIO) , "FASTCP" , "Short-lived carbon in shallow soil" , "gC/m2" ) + call add_to_output( MosaicAverage(NoahmpIO%NEEXY, NoahmpIO) , "NEE" , "Net ecosystem exchange" , "gCO2/m2/s" ) + call add_to_output( MosaicAverage(NoahmpIO%GPPXY, NoahmpIO) , "GPP" , "Net instantaneous assimilation" , "gC/m2/s" ) + call add_to_output( MosaicAverage(NoahmpIO%NPPXY, NoahmpIO) , "NPP" , "Net primary productivity" , "gC/m2/s" ) + call add_to_output( MosaicAverage(NoahmpIO%PSNXY, NoahmpIO) , "PSN" , "Total photosynthesis" , "umol CO2/m2/s" ) + call add_to_output( MosaicAverage(NoahmpIO%APARXY, NoahmpIO) , "APAR" , "Photosynthesis active energy by canopy", "W/m2" ) + ! additional NoahMP output + if (NoahmpIO%noahmp_output > 0) then + ! additional water budget terms + call add_to_output( MosaicAverage(NoahmpIO%QINTSXY, NoahmpIO) , "QINTS" , "canopy interception (loading) rate for snowfall", "mm/s" ) + call add_to_output( MosaicAverage(NoahmpIO%QINTRXY, NoahmpIO) , "QINTR" , "canopy interception rate for rain" , "mm/s" ) + call add_to_output( MosaicAverage(NoahmpIO%QDRIPSXY, NoahmpIO) , "QDRIPS" , "drip (unloading) rate for intercepted snow" , "mm/s" ) + call add_to_output( MosaicAverage(NoahmpIO%QDRIPRXY, NoahmpIO) , "QDRIPR" , "drip rate for canopy intercepted rain" , "mm/s" ) + call add_to_output( MosaicAverage(NoahmpIO%QTHROSXY, NoahmpIO) , "QTHROS" , "throughfall of snowfall" , "mm/s" ) + call add_to_output( MosaicAverage(NoahmpIO%QTHRORXY, NoahmpIO) , "QTHROR" , "throughfall for rain" , "mm/s" ) + call add_to_output( MosaicAverage(NoahmpIO%QSNSUBXY, NoahmpIO) , "QSNSUB" , "snow surface sublimation rate" , "mm/s" ) + call add_to_output( MosaicAverage(NoahmpIO%QSNFROXY, NoahmpIO) , "QSNFRO" , "snow surface frost rate" , "mm/s" ) + call add_to_output( MosaicAverage(NoahmpIO%QSUBCXY, NoahmpIO) , "QSUBC" , "canopy snow sublimation rate" , "mm/s" ) + call add_to_output( MosaicAverage(NoahmpIO%QFROCXY, NoahmpIO) , "QFROC" , "canopy snow frost rate" , "mm/s" ) + call add_to_output( MosaicAverage(NoahmpIO%QEVACXY, NoahmpIO) , "QEVAC" , "canopy snow evaporation rate" , "mm/s" ) + call add_to_output( MosaicAverage(NoahmpIO%QDEWCXY, NoahmpIO) , "QDEWC" , "canopy snow dew rate" , "mm/s" ) + call add_to_output( MosaicAverage(NoahmpIO%QFRZCXY, NoahmpIO) , "QFRZC" , "refreezing rate of canopy liquid water" , "mm/s" ) + call add_to_output( MosaicAverage(NoahmpIO%QMELTCXY, NoahmpIO) , "QMELTC" , "melting rate of canopy snow" , "mm/s" ) + call add_to_output( MosaicAverage(NoahmpIO%FPICEXY, NoahmpIO) , "FPICE" , "snow fraction in precipitation" , "-" ) + call add_to_output( MosaicAverage(NoahmpIO%ACC_QINSURXY, NoahmpIO),"ACC_QINSUR", "accumuated water flux to soil within soil timestep" , "m/s*dt_soil/dt_main") + call add_to_output( MosaicAverage(NoahmpIO%ACC_QSEVAXY, NoahmpIO) ,"ACC_QSEVA" , "accumulated soil surface evap rate within soil timestep", "m/s*dt_soil/dt_main") + call add_to_output( MosaicAverage(NoahmpIO%ACC_ETRANIXY, NoahmpIO),"ACC_ETRANI", "accumualted transpiration rate within soil timestep" , "m/s*dt_soil/dt_main","SOIL") + call add_to_output( MosaicAverage(NoahmpIO%ACC_DWATERXY, NoahmpIO),"ACC_DWATER", "accumulated water storage change within soil timestep" , "mm") + call add_to_output( MosaicAverage(NoahmpIO%ACC_PRCPXY, NoahmpIO) ,"ACC_PRCP" , "accumulated precipitation within soil timestep" , "mm") + call add_to_output( MosaicAverage(NoahmpIO%ACC_ECANXY, NoahmpIO) ,"ACC_ECAN" , "accumulated net canopy evaporation within soil timestep", "mm") + call add_to_output( MosaicAverage(NoahmpIO%ACC_ETRANXY, NoahmpIO) ,"ACC_ETRAN" , "accumulated transpiration within soil timestep" , "mm") + call add_to_output( MosaicAverage(NoahmpIO%ACC_EDIRXY, NoahmpIO) ,"ACC_EDIR" , "accumulated net ground evaporation within soil timestep", "mm") + call add_to_output( MosaicAverage(NoahmpIO%ACC_GLAFLWXY, NoahmpIO),"ACC_GLAFLW", "accumuated glacier excessive flow per soil timestep" , "mm") + ! additional energy terms + call add_to_output( MosaicAverage(NoahmpIO%PAHXY, NoahmpIO) , "PAH" , "Precipitation advected heat flux" , "W/m2" ) + call add_to_output( MosaicAverage(NoahmpIO%PAHGXY, NoahmpIO) , "PAHG" , "Precipitation advected heat flux to below-canopy ground" , "W/m2" ) + call add_to_output( MosaicAverage(NoahmpIO%PAHBXY, NoahmpIO) , "PAHB" , "Precipitation advected heat flux to bare ground" , "W/m2" ) + call add_to_output( MosaicAverage(NoahmpIO%PAHVXY, NoahmpIO) , "PAHV" , "Precipitation advected heat flux to canopy" , "W/m2" ) + call add_to_output( MosaicAverage(NoahmpIO%ACC_SSOILXY, NoahmpIO), "ACC_SSOIL","accumulated heat flux into snow/soil within soil timestep", "W/m2" ) + call add_to_output( MosaicAverage(NoahmpIO%EFLXBXY, NoahmpIO) , "EFLXB" , "accumulated heat flux through soil bottom" , "J/m2" ) + call add_to_output( MosaicAverage(NoahmpIO%SOILENERGY, NoahmpIO) , "SOILENERGY","energy content in soil relative to 273.16" , "KJ/m2" ) + call add_to_output( MosaicAverage(NoahmpIO%SNOWENERGY, NoahmpIO) , "SNOWENERGY","energy content in snow relative to 273.16" , "KJ/m2" ) + call add_to_output( MosaicAverage(NoahmpIO%CANHSXY, NoahmpIO) , "CANHS" , "canopy heat storage change" , "W/m2" ) + ! additional forcing terms + call add_to_output( MosaicAverage(NoahmpIO%RAINLSM, NoahmpIO) , "RAINLSM" , "lowest model liquid precipitation into LSM" , "mm/s" ) + call add_to_output( MosaicAverage(NoahmpIO%SNOWLSM, NoahmpIO) , "SNOWLSM" , "lowest model snowfall into LSM" , "mm/s" ) + call add_to_output( MosaicAverage(NoahmpIO%FORCTLSM, NoahmpIO) , "FORCTLSM", "lowest model temperature into LSM" , "K" ) + call add_to_output( MosaicAverage(NoahmpIO%FORCQLSM, NoahmpIO) , "FORCQLSM", "lowest model specific humidty into LSM" , "kg/kg" ) + call add_to_output( MosaicAverage(NoahmpIO%FORCPLSM, NoahmpIO) , "FORCPLSM", "lowest model pressure into LSM" , "Pa" ) + call add_to_output( MosaicAverage(NoahmpIO%FORCZLSM, NoahmpIO) , "FORCZLSM", "lowest model forcing height into LSM" , "m" ) + call add_to_output( MosaicAverage(NoahmpIO%FORCWLSM, NoahmpIO) , "FORCWLSM", "lowest model wind speed into LSM" , "m/s" ) + call add_to_output( MosaicAverage(NoahmpIO%RadSwVisFrac, NoahmpIO) , "SWVISFRAC", "Fraction of visible band downward solar radiation", "-" ) + call add_to_output( MosaicAverage(NoahmpIO%RadSwDirFrac, NoahmpIO) , "SWDIRFRAC", "Fraction of downward solar direct radiation", "-" ) + endif + + ! Irrigation + if ( NoahmpIO%IOPT_IRR > 0 ) then + call add_to_output( MosaicAverage(NoahmpIO%IRNUMSI, NoahmpIO) , "IRNUMSI" , "Sprinkler irrigation count" , "-" ) + call add_to_output( MosaicAverage(NoahmpIO%IRNUMMI, NoahmpIO) , "IRNUMMI" , "Micro irrigation count" , "-" ) + call add_to_output( MosaicAverage(NoahmpIO%IRNUMFI, NoahmpIO) , "IRNUMFI" , "Flood irrigation count" , "-" ) + call add_to_output( MosaicAverage(NoahmpIO%IRELOSS, NoahmpIO) , "IRELOSS" , "Accumulated sprinkler Evaporation" , "mm" ) + call add_to_output( MosaicAverage(NoahmpIO%IRSIVOL, NoahmpIO) , "IRSIVOL" , "Sprinkler irrigation amount" , "mm" ) + call add_to_output( MosaicAverage(NoahmpIO%IRMIVOL, NoahmpIO) , "IRMIVOL" , "Micro irrigation amount" , "mm" ) + call add_to_output( MosaicAverage(NoahmpIO%IRFIVOL, NoahmpIO) , "IRFIVOL" , "Flood irrigation amount" , "mm" ) + call add_to_output( MosaicAverage(NoahmpIO%IRRSPLH, NoahmpIO) , "IRRSPLH" , "Accumulated latent heating due to sprinkler" , "J/m2" ) + endif + ! MMF groundwater model + if ( NoahmpIO%IOPT_RUNSUB == 5 ) then + call add_to_output( MosaicAverage(NoahmpIO%SMCWTDXY, NoahmpIO) , "SMCWTD" , "soil water content between bottom of the soil and water table", "m3/m3" ) + call add_to_output( MosaicAverage(NoahmpIO%RECHXY, NoahmpIO) , "RECH" , "recharge to or from the water table when shallow" , "m" ) + call add_to_output( MosaicAverage(NoahmpIO%DEEPRECHXY, NoahmpIO) , "DEEPRECH" , "recharge to or from the water table when deep" , "m" ) + call add_to_output( NoahmpIO%QRFSXY , "QRFS" , "accumulated groundwater baselow" , "mm" ) + call add_to_output( NoahmpIO%QRFXY , "QRF" , "groundwater baseflow" , "m" ) + call add_to_output( NoahmpIO%QSPRINGSXY , "QSPRINGS" , "accumulated seeping water" , "mm" ) + call add_to_output( NoahmpIO%QSPRINGXY , "QSPRING" , "instantaneous seeping water" , "m" ) + call add_to_output( NoahmpIO%QSLATXY , "QSLAT" , "accumulated lateral flow" , "mm" ) + call add_to_output( NoahmpIO%QLATXY , "QLAT" , "instantaneous lateral flow" , "m" ) + endif + ! Wetland model + if ( NoahmpIO%IOPT_WETLAND > 0 ) then + call add_to_output( MosaicAverage(NoahmpIO%FSATXY, NoahmpIO) , "FSAT" , "saturated fraction of the grid" , "-" ) + call add_to_output( MosaicAverage(NoahmpIO%WSURFXY, NoahmpIO) , "WSURF" , "Wetland Water Storage" , "mm") + endif + + end subroutine WriteNoahmpMosaicGridAverageOutput + +end module WriteNoahmpMosaicGridAverageOutputMod \ No newline at end of file diff --git a/hrldas/IO_code/WriteNoahmpMosaicRestartMod.F90 b/hrldas/IO_code/WriteNoahmpMosaicRestartMod.F90 new file mode 100644 index 0000000..b4be3df --- /dev/null +++ b/hrldas/IO_code/WriteNoahmpMosaicRestartMod.F90 @@ -0,0 +1,239 @@ +module WriteNoahmpMosaicRestartMod + +!!! This module part of NoahMP Mosaic/Subgrid Tiling Scheme +!!! Purpose: To write grid average values of Noah-MP Mosaic. + +! ------------------------ Code history ----------------------------------- +! Original code : Prasanth Valayamkunnath (IISER Thiruvananthapuram) +! Date : September 12, 2025 +! ------------------------------------------------------------------------- + + use Machine + use NoahmpIOVarType + use module_hrldas_netcdf_io + + implicit none + +contains + +!=== sort landuse/soiltype/hydrotype index based on area fraction and identify most dominant types + + subroutine WriteNoahmpMosaicRestart (NoahmpIO) + + implicit none + + type(NoahmpIO_type), intent(inout) :: NoahmpIO + + call add_to_restart_mosaic(NoahmpIO%TSLB , "SOIL_T", NoahmpIO%NTilesMax, layers="SOIL") + call add_to_restart_mosaic(NoahmpIO%TSNOXY , "SNOW_T", NoahmpIO%NTilesMax, layers="SNOW") + call add_to_restart_mosaic(NoahmpIO%SMOIS , "SMC" , NoahmpIO%NTilesMax, layers="SOIL") + call add_to_restart_mosaic(NoahmpIO%SH2O , "SH2O" , NoahmpIO%NTilesMax, layers="SOIL") + call add_to_restart_mosaic(NoahmpIO%ZSNSOXY , "ZSNSO" , NoahmpIO%NTilesMax, layers="SOSN") + call add_to_restart_mosaic(NoahmpIO%SNICEXY , "SNICE" , NoahmpIO%NTilesMax, layers="SNOW") + call add_to_restart_mosaic(NoahmpIO%SNLIQXY , "SNLIQ" , NoahmpIO%NTilesMax, layers="SNOW") + call add_to_restart_mosaic(NoahmpIO%FWETXY , "FWET" , NoahmpIO%NTilesMax) + call add_to_restart_mosaic(NoahmpIO%SNEQVOXY , "SNEQVO", NoahmpIO%NTilesMax) + call add_to_restart_mosaic(NoahmpIO%EAHXY , "EAH" , NoahmpIO%NTilesMax) + call add_to_restart_mosaic(NoahmpIO%TAHXY , "TAH" , NoahmpIO%NTilesMax) + call add_to_restart_mosaic(NoahmpIO%ALBOLDXY , "ALBOLD", NoahmpIO%NTilesMax) + call add_to_restart_mosaic(NoahmpIO%CMXY , "CM" , NoahmpIO%NTilesMax) + call add_to_restart_mosaic(NoahmpIO%CHXY , "CH" , NoahmpIO%NTilesMax) + call add_to_restart_mosaic(NoahmpIO%ISNOWXY , "ISNOW" , NoahmpIO%NTilesMax) + call add_to_restart_mosaic(NoahmpIO%CANLIQXY , "CANLIQ", NoahmpIO%NTilesMax) + call add_to_restart_mosaic(NoahmpIO%CANICEXY , "CANICE", NoahmpIO%NTilesMax) + call add_to_restart_mosaic(NoahmpIO%SNOW , "SNEQV" , NoahmpIO%NTilesMax) + call add_to_restart_mosaic(NoahmpIO%SNOWH , "SNOWH" , NoahmpIO%NTilesMax) + call add_to_restart_mosaic(NoahmpIO%TVXY , "TV" , NoahmpIO%NTilesMax) + call add_to_restart_mosaic(NoahmpIO%TGXY , "TG" , NoahmpIO%NTilesMax) + call add_to_restart_mosaic(NoahmpIO%ZWTXY , "ZWT" , NoahmpIO%NTilesMax) + call add_to_restart_mosaic(NoahmpIO%WAXY , "WA" , NoahmpIO%NTilesMax) + call add_to_restart_mosaic(NoahmpIO%WTXY , "WT" , NoahmpIO%NTilesMax) + call add_to_restart_mosaic(NoahmpIO%WSLAKEXY , "WSLAKE", NoahmpIO%NTilesMax) + call add_to_restart_mosaic(NoahmpIO%LFMASSXY , "LFMASS", NoahmpIO%NTilesMax) + call add_to_restart_mosaic(NoahmpIO%RTMASSXY , "RTMASS", NoahmpIO%NTilesMax) + call add_to_restart_mosaic(NoahmpIO%STMASSXY , "STMASS", NoahmpIO%NTilesMax) + + call add_to_restart(NoahmpIO%CROPCAT , "CROPCAT" ) + + call add_to_restart_mosaic(NoahmpIO%WOODXY , "WOOD" , NoahmpIO%NTilesMax) + call add_to_restart_mosaic(NoahmpIO%GRAINXY , "GRAIN" , NoahmpIO%NTilesMax) + call add_to_restart_mosaic(NoahmpIO%GDDXY , "GDD" , NoahmpIO%NTilesMax) + call add_to_restart_mosaic(NoahmpIO%STBLCPXY , "STBLCP", NoahmpIO%NTilesMax) + call add_to_restart_mosaic(NoahmpIO%FASTCPXY , "FASTCP", NoahmpIO%NTilesMax) + call add_to_restart_mosaic(NoahmpIO%LAI , "LAI" , NoahmpIO%NTilesMax) + call add_to_restart_mosaic(NoahmpIO%XSAIXY , "SAI" , NoahmpIO%NTilesMax) + call add_to_restart_mosaic(NoahmpIO%VEGFRA , "VEGFRA", NoahmpIO%NTilesMax) + call add_to_restart_mosaic(NoahmpIO%GVFMIN , "GVFMIN", NoahmpIO%NTilesMax) + call add_to_restart_mosaic(NoahmpIO%GVFMAX , "GVFMAX", NoahmpIO%NTilesMax) + call add_to_restart_mosaic(NoahmpIO%ACSNOM , "ACMELT", NoahmpIO%NTilesMax) + call add_to_restart_mosaic(NoahmpIO%ACSNOW , "ACSNOW", NoahmpIO%NTilesMax) + call add_to_restart_mosaic(NoahmpIO%TAUSSXY , "TAUSS" , NoahmpIO%NTilesMax) + call add_to_restart_mosaic(NoahmpIO%QSFC , "QSFC" , NoahmpIO%NTilesMax) + call add_to_restart_mosaic(NoahmpIO%SFCRUNOFF , "SFCRUNOFF", NoahmpIO%NTilesMax) + call add_to_restart_mosaic(NoahmpIO%UDRUNOFF , "UDRUNOFF" , NoahmpIO%NTilesMax) + call add_to_restart_mosaic(NoahmpIO%QTDRAIN , "QTDRAIN" , NoahmpIO%NTilesMax) + call add_to_restart_mosaic(NoahmpIO%ACC_SSOILXY ,"ACC_SSOIL" , NoahmpIO%NTilesMax) + call add_to_restart_mosaic(NoahmpIO%ACC_QINSURXY,"ACC_QINSUR", NoahmpIO%NTilesMax) + call add_to_restart_mosaic(NoahmpIO%ACC_QSEVAXY ,"ACC_QSEVA" , NoahmpIO%NTilesMax) + call add_to_restart_mosaic(NoahmpIO%ACC_ETRANIXY,"ACC_ETRANI", NoahmpIO%NTilesMax, layers="SOIL") + call add_to_restart_mosaic(NoahmpIO%ACC_DWATERXY,"ACC_DWATER", NoahmpIO%NTilesMax) + call add_to_restart_mosaic(NoahmpIO%ACC_PRCPXY ,"ACC_PRCP" , NoahmpIO%NTilesMax) + call add_to_restart_mosaic(NoahmpIO%ACC_ECANXY ,"ACC_ECAN" , NoahmpIO%NTilesMax) + call add_to_restart_mosaic(NoahmpIO%ACC_ETRANXY ,"ACC_ETRAN" , NoahmpIO%NTilesMax) + call add_to_restart_mosaic(NoahmpIO%ACC_EDIRXY ,"ACC_EDIR" , NoahmpIO%NTilesMax) + call add_to_restart_mosaic(NoahmpIO%ACC_GLAFLWXY,"ACC_GLAFLW", NoahmpIO%NTilesMax) + call add_to_restart_mosaic(NoahmpIO%ALBSOILDIRXY, "ALBSOILDIR", NoahmpIO%NTilesMax, layers="RADN") + call add_to_restart_mosaic(NoahmpIO%ALBSOILDIFXY, "ALBSOILDIF", NoahmpIO%NTilesMax, layers="RADN") + + ! SNICAR snow albedo scheme + if (NoahmpIO%IOPT_ALB == 3)then + call add_to_restart_mosaic(NoahmpIO%SNFRXY , "SNFR" , NoahmpIO%NTilesMax, layers="SNOW") + call add_to_restart_mosaic(NoahmpIO%SNRDSXY , "SNRDS" , NoahmpIO%NTilesMax, layers="SNOW") + call add_to_restart_mosaic(NoahmpIO%BCPHIXY , "BCPHI" , NoahmpIO%NTilesMax, layers="SNOW") + call add_to_restart_mosaic(NoahmpIO%BCPHOXY , "BCPHO" , NoahmpIO%NTilesMax, layers="SNOW") + call add_to_restart_mosaic(NoahmpIO%OCPHIXY , "OCPHI" , NoahmpIO%NTilesMax, layers="SNOW") + call add_to_restart_mosaic(NoahmpIO%OCPHOXY , "OCPHO" , NoahmpIO%NTilesMax, layers="SNOW") + call add_to_restart_mosaic(NoahmpIO%DUST1XY , "DUST1" , NoahmpIO%NTilesMax, layers="SNOW") + call add_to_restart_mosaic(NoahmpIO%DUST2XY , "DUST2" , NoahmpIO%NTilesMax, layers="SNOW") + call add_to_restart_mosaic(NoahmpIO%DUST3XY , "DUST3" , NoahmpIO%NTilesMax, layers="SNOW") + call add_to_restart_mosaic(NoahmpIO%DUST4XY , "DUST4" , NoahmpIO%NTilesMax, layers="SNOW") + call add_to_restart_mosaic(NoahmpIO%DUST5XY , "DUST5" , NoahmpIO%NTilesMax, layers="SNOW") + endif + + ! irrigation scheme + if ( NoahmpIO%IOPT_IRR > 0 ) then + call add_to_restart_mosaic(NoahmpIO%IRNUMSI , "IRNUMSI", NoahmpIO%NTilesMax) + call add_to_restart_mosaic(NoahmpIO%IRNUMMI , "IRNUMMI", NoahmpIO%NTilesMax) + call add_to_restart_mosaic(NoahmpIO%IRNUMFI , "IRNUMFI", NoahmpIO%NTilesMax) + call add_to_restart_mosaic(NoahmpIO%IRWATSI , "IRWATSI", NoahmpIO%NTilesMax) + call add_to_restart_mosaic(NoahmpIO%IRWATMI , "IRWATMI", NoahmpIO%NTilesMax) + call add_to_restart_mosaic(NoahmpIO%IRWATFI , "IRWATFI", NoahmpIO%NTilesMax) + call add_to_restart_mosaic(NoahmpIO%IRSIVOL , "IRSIVOL", NoahmpIO%NTilesMax) + call add_to_restart_mosaic(NoahmpIO%IRMIVOL , "IRMIVOL", NoahmpIO%NTilesMax) + call add_to_restart_mosaic(NoahmpIO%IRFIVOL , "IRFIVOL", NoahmpIO%NTilesMax) + call add_to_restart_mosaic(NoahmpIO%IRELOSS , "IRELOSS", NoahmpIO%NTilesMax) + call add_to_restart_mosaic(NoahmpIO%IRRSPLH , "IRRSPLH", NoahmpIO%NTilesMax) + endif + + ! below for MMF groundwater scheme + if ( NoahmpIO%IOPT_RUNSUB == 5 ) then + call add_to_restart_mosaic(NoahmpIO%SMOISEQ , "SMOISEQ" , NoahmpIO%NTilesMax, layers="SOIL" ) + call add_to_restart_mosaic(NoahmpIO%SMCWTDXY , "SMCWTDXY" , NoahmpIO%NTilesMax) + call add_to_restart_mosaic(NoahmpIO%DEEPRECHXY , "DEEPRECHXY" , NoahmpIO%NTilesMax) + + ! following are grid values only from input. So NO mosaic for now + call add_to_restart(NoahmpIO%AREAXY , "AREAXY" ) + call add_to_restart(NoahmpIO%QSLATXY , "QSLATXY" ) + call add_to_restart(NoahmpIO%QRFSXY , "QRFSXY" ) + call add_to_restart(NoahmpIO%QSPRINGSXY , "QSPRINGSXY" ) + call add_to_restart(NoahmpIO%RECHXY , "RECHXY" ) + call add_to_restart(NoahmpIO%QRFXY , "QRFXY" ) + call add_to_restart(NoahmpIO%QSPRINGXY , "QSPRINGXY" ) + call add_to_restart(NoahmpIO%FDEPTHXY , "FDEPTHXY" ) + call add_to_restart(NoahmpIO%RIVERCONDXY , "RIVERCONDXY") + call add_to_restart(NoahmpIO%RIVERBEDXY , "RIVERBEDXY" ) + call add_to_restart(NoahmpIO%EQZWT , "EQZWT" ) + call add_to_restart(NoahmpIO%PEXPXY , "PEXPXY" ) + endif + + ! for wetland scheme + if ( NoahmpIO%IOPT_WETLAND > 0 ) then + call add_to_restart_mosaic(NoahmpIO%FSATXY , "FSATXY" , NoahmpIO%NTilesMax) + call add_to_restart_mosaic(NoahmpIO%WSURFXY , "WSURFXY" , NoahmpIO%NTilesMax) + endif + + ! below for urban model + if ( NoahmpIO%SF_URBAN_PHYSICS > 0 ) then + call add_to_restart( NoahmpIO%SH_URB2D , "SH_URB2D" ) + call add_to_restart( NoahmpIO%LH_URB2D , "LH_URB2D" ) + call add_to_restart( NoahmpIO%G_URB2D , "G_URB2D" ) + call add_to_restart( NoahmpIO%RN_URB2D , "RN_URB2D" ) + call add_to_restart( NoahmpIO%TS_URB2D , "TS_URB2D" ) + call add_to_restart( NoahmpIO%FRC_URB2D , "FRC_URB2D" ) + call add_to_restart( NoahmpIO%UTYPE_URB2D , "UTYPE_URB2D" ) + call add_to_restart( NoahmpIO%LP_URB2D , "LP_URB2D" ) + call add_to_restart( NoahmpIO%LB_URB2D , "LB_URB2D" ) + call add_to_restart( NoahmpIO%HGT_URB2D , "HGT_URB2D" ) + call add_to_restart( NoahmpIO%MH_URB2D , "MH_URB2D" ) + call add_to_restart( NoahmpIO%STDH_URB2D , "STDH_URB2D" ) + call add_to_restart( NoahmpIO%HI_URB2D , "HI_URB2D", layers="URBN") + call add_to_restart( NoahmpIO%LF_URB2D , "LF_URB2D", layers="URBN") + + if ( NoahmpIO%SF_URBAN_PHYSICS == 1 ) then ! single layer urban model + call add_to_restart( NoahmpIO%CMR_SFCDIF , "CMR_SFCDIF" ) + call add_to_restart( NoahmpIO%CHR_SFCDIF , "CHR_SFCDIF" ) + call add_to_restart( NoahmpIO%CMC_SFCDIF , "CMC_SFCDIF" ) + call add_to_restart( NoahmpIO%CHC_SFCDIF , "CHC_SFCDIF" ) + call add_to_restart( NoahmpIO%CMGR_SFCDIF , "CMGR_SFCDIF" ) + call add_to_restart( NoahmpIO%CHGR_SFCDIF , "CHGR_SFCDIF" ) + call add_to_restart( NoahmpIO%TR_URB2D , "TR_URB2D" ) + call add_to_restart( NoahmpIO%TB_URB2D , "TB_URB2D" ) + call add_to_restart( NoahmpIO%TG_URB2D , "TG_URB2D" ) + call add_to_restart( NoahmpIO%TC_URB2D , "TC_URB2D" ) + call add_to_restart( NoahmpIO%QC_URB2D , "QC_URB2D" ) + call add_to_restart( NoahmpIO%UC_URB2D , "UC_URB2D" ) + call add_to_restart( NoahmpIO%XXXR_URB2D , "XXXR_URB2D" ) + call add_to_restart( NoahmpIO%XXXB_URB2D , "XXXB_URB2D" ) + call add_to_restart( NoahmpIO%XXXG_URB2D , "XXXG_URB2D" ) + call add_to_restart( NoahmpIO%XXXC_URB2D , "XXXC_URB2D" ) + call add_to_restart( NoahmpIO%TRL_URB3D , "TRL_URB3D", layers="SOIL" ) + call add_to_restart( NoahmpIO%TBL_URB3D , "TBL_URB3D", layers="SOIL" ) + call add_to_restart( NoahmpIO%TGL_URB3D , "TGL_URB3D", layers="SOIL" ) + call add_to_restart( NoahmpIO%CMCR_URB2D , "CMCR_URB2D" ) + call add_to_restart( NoahmpIO%TGR_URB2D , "TGR_URB2D" ) + call add_to_restart( NoahmpIO%TGRL_URB3D , "TGRL_URB3D", layers="SOIL" ) + call add_to_restart( NoahmpIO%SMR_URB3D , "SMR_URB3D", layers="SOIL" ) + call add_to_restart( NoahmpIO%DRELR_URB2D , "DRELR_URB2D" ) + call add_to_restart( NoahmpIO%DRELB_URB2D , "DRELB_URB2D" ) + call add_to_restart( NoahmpIO%DRELG_URB2D , "DRELG_URB2D" ) + call add_to_restart(NoahmpIO%FLXHUMR_URB2D , "FLXHUMR_URB2D" ) + call add_to_restart(NoahmpIO%FLXHUMB_URB2D , "FLXHUMB_URB2D" ) + call add_to_restart(NoahmpIO%FLXHUMG_URB2D , "FLXHUMG_URB2D" ) + endif + + if ( (NoahmpIO%SF_URBAN_PHYSICS == 2) .or. (NoahmpIO%SF_URBAN_PHYSICS == 3) ) then ! BEP or BEM urban models + call add_to_restart( NoahmpIO%TRB_URB4D , "TRB_URB4D", layers="URBN" ) + call add_to_restart( NoahmpIO%TW1_URB4D , "TW1_URB4D", layers="URBN" ) + call add_to_restart( NoahmpIO%TW2_URB4D , "TW2_URB4D", layers="URBN" ) + call add_to_restart( NoahmpIO%TGB_URB4D , "TGB_URB4D", layers="URBN" ) + call add_to_restart( NoahmpIO%SFW1_URB3D , "SFW1_URB3D", layers="URBN" ) + call add_to_restart( NoahmpIO%SFW2_URB3D , "SFW2_URB3D", layers="URBN" ) + call add_to_restart( NoahmpIO%SFR_URB3D , "SFR_URB3D", layers="URBN" ) + call add_to_restart( NoahmpIO%SFG_URB3D , "SFG_URB3D", layers="URBN" ) + endif + + if ( NoahmpIO%SF_URBAN_PHYSICS == 3 ) then ! BEM urban model + call add_to_restart( NoahmpIO%TLEV_URB3D , "TLEV_URB3D", layers="URBN" ) + call add_to_restart( NoahmpIO%QLEV_URB3D , "QLEV_URB3D", layers="URBN" ) + call add_to_restart( NoahmpIO%TW1LEV_URB3D , "TW1LEV_URB3D", layers="URBN" ) + call add_to_restart( NoahmpIO%TW2LEV_URB3D , "TW2LEV_URB3D", layers="URBN" ) + call add_to_restart( NoahmpIO%TGLEV_URB3D , "TGLEV_URB3D", layers="URBN" ) + call add_to_restart( NoahmpIO%TFLEV_URB3D , "TFLEV_URB3D", layers="URBN" ) + call add_to_restart( NoahmpIO%SF_AC_URB3D , "SF_AC_URB3D" ) + call add_to_restart( NoahmpIO%LF_AC_URB3D , "LF_AC_URB3D" ) + call add_to_restart( NoahmpIO%CM_AC_URB3D , "CM_AC_URB3D" ) + call add_to_restart( NoahmpIO%SFVENT_URB3D , "SFVENT_URB3D" ) + call add_to_restart( NoahmpIO%LFVENT_URB3D , "LFVENT_URB3D" ) + call add_to_restart( NoahmpIO%SFWIN1_URB3D , "SFWIN1_URB3D", layers="URBN" ) + call add_to_restart( NoahmpIO%SFWIN2_URB3D , "SFWIN2_URB3D", layers="URBN" ) + call add_to_restart( NoahmpIO%EP_PV_URB3D , "EP_PV_URB3D" ) + call add_to_restart( NoahmpIO%T_PV_URB3D , "T_PV_URB3D", layers="URBN" ) + call add_to_restart( NoahmpIO%TRV_URB4D , "TRV_URB4D" , layers="URBN" ) + call add_to_restart( NoahmpIO%QR_URB4D , "QR_URB4D" , layers="URBN" ) + call add_to_restart( NoahmpIO%QGR_URB3D , "QGR_URB3D" ) + call add_to_restart( NoahmpIO%TGR_URB3D , "TGR_URB3D" ) + call add_to_restart( NoahmpIO%DRAIN_URB4D , "DRAIN_URB4D", layers="URBN" ) + call add_to_restart( NoahmpIO%DRAINGR_URB3D , "DRAINGR_URB3D" ) + call add_to_restart( NoahmpIO%SFRV_URB3D , "SFRV_URB3D", layers="URBN" ) + call add_to_restart( NoahmpIO%LFRV_URB3D , "LFRV_URB3D", layers="URBN" ) + call add_to_restart( NoahmpIO%DGR_URB3D , "DGR_URB3D", layers="URBN" ) + call add_to_restart( NoahmpIO%DG_URB3D , "DG_URB3D", layers="URBN" ) + call add_to_restart( NoahmpIO%LFR_URB3D , "LFR_URB3D", layers="URBN" ) + call add_to_restart( NoahmpIO%LFG_URB3D , "LFG_URB3D", layers="URBN" ) + endif + endif + + + end subroutine WriteNoahmpMosaicRestart + +end module WriteNoahmpMosaicRestartMod \ No newline at end of file diff --git a/hrldas/IO_code/WriteNoahmpMosaicSubgridOutputMod.F90 b/hrldas/IO_code/WriteNoahmpMosaicSubgridOutputMod.F90 new file mode 100644 index 0000000..a3b6edd --- /dev/null +++ b/hrldas/IO_code/WriteNoahmpMosaicSubgridOutputMod.F90 @@ -0,0 +1,243 @@ +module WriteNoahmpMosaicSubgridOutputMod + +!!! This module part of NoahMP Mosaic/Subgrid Tiling Scheme +!!! Purpose: To write grid average values of Noah-MP Mosaic. + +! ------------------------ Code history ----------------------------------- +! Original code : Prasanth Valayamkunnath (IISER Thiruvananthapuram) +! Date : September 12, 2025 +! ------------------------------------------------------------------------- + + use Machine + use NoahmpIOVarType + use module_hrldas_netcdf_io + + implicit none + +contains + +!=== sort landuse/soiltype/hydrotype index based on area fraction and identify most dominant types + + subroutine WriteNoahmpMosaicSubgridOutput (NoahmpIO) + + implicit none + + type(NoahmpIO_type), intent(in) :: NoahmpIO + + ! For 3D arrays, we need to know whether the Z dimension is snow layers, or soil layers. + + ! Properties - Assigned or predicted + call add_to_output(NoahmpIO%IVGTYP , "IVGTYP" , "Dominant vegetation category" , "category" ) + call add_to_output(NoahmpIO%ISLTYP , "ISLTYP" , "Dominant soil category" , "category" ) + call add_to_output_mosaic(NoahmpIO%FVEGXY , "FVEG" ,NoahmpIO%NTilesMax , "Green Vegetation Fraction" , "-" ) + call add_to_output_mosaic(NoahmpIO%LAI , "LAI" ,NoahmpIO%NTilesMax , "Leaf area index" , "m2/m2" ) + call add_to_output_mosaic(NoahmpIO%XSAIXY , "SAI" ,NoahmpIO%NTilesMax , "Stem area index" , "m2/m2" ) + ! Forcing + call add_to_output(NoahmpIO%SWDOWN , "SWFORC" , "Shortwave forcing" , "W/m2" ) + call add_to_output(NoahmpIO%COSZEN , "COSZ" , "Cosine of zenith angle" , "-" ) + call add_to_output(NoahmpIO%GLW , "LWFORC" , "Longwave forcing" , "W/m2" ) + call add_to_output(NoahmpIO%RAINBL , "RAINRATE", "Precipitation rate" , "mm/timestep" ) + ! Grid energy budget terms + call add_to_output_mosaic(NoahmpIO%EMISS , "EMISS" ,NoahmpIO%NTilesMax , "Grid emissivity" , "-" ) + call add_to_output_mosaic(NoahmpIO%FSAXY , "FSA" ,NoahmpIO%NTilesMax , "Total absorbed SW radiation" , "W/m2" ) + call add_to_output_mosaic(NoahmpIO%FIRAXY , "FIRA" ,NoahmpIO%NTilesMax , "Total net LW radiation to atmosphere" , "W/m2" ) + call add_to_output_mosaic(NoahmpIO%GRDFLX , "GRDFLX" ,NoahmpIO%NTilesMax , "Heat flux into the soil" , "W/m2" ) + call add_to_output_mosaic(NoahmpIO%HFX , "HFX" ,NoahmpIO%NTilesMax , "Total sensible heat to atmosphere" , "W/m2" ) + call add_to_output_mosaic(NoahmpIO%LH , "LH" ,NoahmpIO%NTilesMax , "Total latent heat to atmosphere" , "W/m2" ) + call add_to_output_mosaic(NoahmpIO%ECANXY , "ECAN" ,NoahmpIO%NTilesMax , "Canopy water evaporation rate" , "mm/s" ) + call add_to_output_mosaic(NoahmpIO%ETRANXY , "ETRAN" ,NoahmpIO%NTilesMax , "Transpiration rate" , "mm/s" ) + call add_to_output_mosaic(NoahmpIO%EDIRXY , "EDIR" ,NoahmpIO%NTilesMax , "Direct from soil evaporation rate" , "mm/s" ) + call add_to_output_mosaic(NoahmpIO%ALBEDO , "ALBEDO" ,NoahmpIO%NTilesMax , "Surface albedo" , "-" ) + ! Grid water budget terms - in addition to above + call add_to_output_mosaic(NoahmpIO%UDRUNOFF , "UGDRNOFF",NoahmpIO%NTilesMax , "Accumulated underground runoff" , "mm" ) + call add_to_output_mosaic(NoahmpIO%SFCRUNOFF , "SFCRNOFF",NoahmpIO%NTilesMax , "Accumulatetd surface runoff" , "mm" ) + call add_to_output_mosaic(NoahmpIO%CANLIQXY , "CANLIQ" ,NoahmpIO%NTilesMax , "Canopy liquid water content" , "mm" ) + call add_to_output_mosaic(NoahmpIO%CANICEXY , "CANICE" ,NoahmpIO%NTilesMax , "Canopy ice water content" , "mm" ) + call add_to_output_mosaic(NoahmpIO%ZWTXY , "ZWT" ,NoahmpIO%NTilesMax , "Depth to water table" , "m" ) + call add_to_output_mosaic(NoahmpIO%WAXY , "WA" ,NoahmpIO%NTilesMax , "Water in aquifer" , "mm" ) + call add_to_output_mosaic(NoahmpIO%WTXY , "WT" ,NoahmpIO%NTilesMax , "Water in aquifer and saturated soil" , "mm" ) + call add_to_output_mosaic(NoahmpIO%QTDRAIN , "QTDRAIN" ,NoahmpIO%NTilesMax , "Accumulated tile drainage" , "mm" ) + call add_to_output_mosaic(NoahmpIO%PONDINGXY , "PONDING" ,NoahmpIO%NTilesMax , "total surface ponding per time step" , "mm/s" ) + ! Additional needed to close the canopy energy budget + call add_to_output_mosaic(NoahmpIO%SAVXY , "SAV" ,NoahmpIO%NTilesMax , "Solar radiation absorbed by canopy" , "W/m2" ) + call add_to_output_mosaic(NoahmpIO%TRXY , "TR" ,NoahmpIO%NTilesMax , "Transpiration heat" , "W/m2" ) + call add_to_output_mosaic(NoahmpIO%EVCXY , "EVC" ,NoahmpIO%NTilesMax , "Canopy evap heat" , "W/m2" ) + call add_to_output_mosaic(NoahmpIO%IRCXY , "IRC" ,NoahmpIO%NTilesMax , "Canopy net LW rad" , "W/m2" ) + call add_to_output_mosaic(NoahmpIO%SHCXY , "SHC" ,NoahmpIO%NTilesMax , "Canopy sensible heat" , "W/m2" ) + ! Additional needed to close the under canopy ground energy budget + call add_to_output_mosaic(NoahmpIO%IRGXY , "IRG" ,NoahmpIO%NTilesMax , "below-canopy ground net LW rad" , "W/m2" ) + call add_to_output_mosaic(NoahmpIO%SHGXY , "SHG" ,NoahmpIO%NTilesMax , "below-canopy ground sensible heat" , "W/m2" ) + call add_to_output_mosaic(NoahmpIO%EVGXY , "EVG" ,NoahmpIO%NTilesMax , "below-canopy ground evap heat" , "W/m2" ) + call add_to_output_mosaic(NoahmpIO%GHVXY , "GHV" ,NoahmpIO%NTilesMax , "below-canopy ground heat to soil" , "W/m2" ) + ! Needed to close the bare ground energy budget + call add_to_output_mosaic(NoahmpIO%SAGXY , "SAG" ,NoahmpIO%NTilesMax , "Solar radiation absorbed by ground" , "W/m2" ) + call add_to_output_mosaic(NoahmpIO%IRBXY , "IRB" ,NoahmpIO%NTilesMax , "Net LW rad to atm bare ground" , "W/m2" ) + call add_to_output_mosaic(NoahmpIO%SHBXY , "SHB" ,NoahmpIO%NTilesMax , "Sensible heat to atm bare ground" , "W/m2" ) + call add_to_output_mosaic(NoahmpIO%EVBXY , "EVB" ,NoahmpIO%NTilesMax , "Evaporation heat to atm bare ground" , "W/m2" ) + call add_to_output_mosaic(NoahmpIO%GHBXY , "GHB" ,NoahmpIO%NTilesMax , "Ground heat flux to soil bare ground" , "W/m2" ) + ! Above-soil temperatures + call add_to_output_mosaic(NoahmpIO%TRADXY , "TRAD" ,NoahmpIO%NTilesMax , "Surface radiative temperature" , "K" ) + call add_to_output_mosaic(NoahmpIO%TGXY , "TG" ,NoahmpIO%NTilesMax , "Ground temperature" , "K" ) + call add_to_output_mosaic(NoahmpIO%TVXY , "TV" ,NoahmpIO%NTilesMax , "Vegetation temperature" , "K" ) + call add_to_output_mosaic(NoahmpIO%TAHXY , "TAH" ,NoahmpIO%NTilesMax , "Canopy air temperature" , "K" ) + call add_to_output_mosaic(NoahmpIO%TGVXY , "TGV" ,NoahmpIO%NTilesMax , "Ground surface Temp vegetated" , "K" ) + call add_to_output_mosaic(NoahmpIO%TGBXY , "TGB" ,NoahmpIO%NTilesMax , "Ground surface Temp bare" , "K" ) + call add_to_output_mosaic(NoahmpIO%T2MVXY , "T2MV" ,NoahmpIO%NTilesMax , "2m Air Temp vegetated" , "K" ) + call add_to_output_mosaic(NoahmpIO%T2MBXY , "T2MB" ,NoahmpIO%NTilesMax , "2m Air Temp bare" , "K" ) + ! Above-soil moisture + call add_to_output_mosaic(NoahmpIO%Q2MVXY , "Q2MV" ,NoahmpIO%NTilesMax , "2m mixing ratio vegetated" , "kg/kg" ) + call add_to_output_mosaic(NoahmpIO%Q2MBXY , "Q2MB" ,NoahmpIO%NTilesMax , "2m mixing ratio bare" , "kg/kg" ) + call add_to_output_mosaic(NoahmpIO%EAHXY , "EAH" ,NoahmpIO%NTilesMax , "Canopy air vapor pressure" , "Pa" ) + call add_to_output_mosaic(NoahmpIO%FWETXY , "FWET" ,NoahmpIO%NTilesMax , "Wetted fraction of canopy" , "fraction" ) + ! Snow and soil - 3D terms + call add_to_output_mosaic(NoahmpIO%ZSNSOXY(:,-NoahmpIO%nsnow+1:0,:,:),"ZSNSO_SN",NoahmpIO%NTilesMax ,"Snow layer depth from snow surface","m","SNOW") + call add_to_output_mosaic(NoahmpIO%SNICEXY , "SNICE" ,NoahmpIO%NTilesMax , "Snow layer ice" , "mm" , "SNOW") + call add_to_output_mosaic(NoahmpIO%SNLIQXY , "SNLIQ" ,NoahmpIO%NTilesMax , "Snow layer liquid water" , "mm" , "SNOW") + call add_to_output_mosaic(NoahmpIO%TSLB , "SOIL_T" ,NoahmpIO%NTilesMax , "soil temperature" , "K" , "SOIL") + call add_to_output_mosaic(NoahmpIO%SMOIS , "SOIL_M" ,NoahmpIO%NTilesMax , "volumetric soil moisture" , "m3/m3" , "SOIL") + call add_to_output_mosaic(NoahmpIO%SH2O , "SOIL_W" ,NoahmpIO%NTilesMax , "liquid volumetric soil moisture" , "m3/m3" , "SOIL") + call add_to_output_mosaic(NoahmpIO%TSNOXY , "SNOW_T" ,NoahmpIO%NTilesMax , "snow temperature" , "K" , "SNOW") + call add_to_output_mosaic(NoahmpIO%ALBSNOWDIRXY, "ALBSNOWDIR" ,NoahmpIO%NTilesMax , "Snow albedo (direct)" , "-" , "RADN") + call add_to_output_mosaic(NoahmpIO%ALBSNOWDIFXY, "ALBSNOWDIF" ,NoahmpIO%NTilesMax , "Snow albedo (diffuse)" , "-" , "RADN") + call add_to_output_mosaic(NoahmpIO%ALBSFCDIRXY , "ALBSFCDIR" ,NoahmpIO%NTilesMax , "Surface albedo (direct)" , "-" , "RADN") + call add_to_output_mosaic(NoahmpIO%ALBSFCDIFXY , "ALBSFCDIF" ,NoahmpIO%NTilesMax , "Surface albedo (diffuse)" , "-" , "RADN") + call add_to_output_mosaic(NoahmpIO%ALBSOILDIRXY, "ALBSOILDIR" ,NoahmpIO%NTilesMax , "Soil albedo (direct)" , "-" , "RADN") + call add_to_output_mosaic(NoahmpIO%ALBSOILDIFXY, "ALBSOILDIF" ,NoahmpIO%NTilesMax , "Soil albedo (diffuse)" , "-" , "RADN") + ! Snow - 2D terms + call add_to_output_mosaic(NoahmpIO%SNOWH , "SNOWH" ,NoahmpIO%NTilesMax , "Snow depth" , "m" ) + call add_to_output_mosaic(NoahmpIO%SNOW , "SNEQV" ,NoahmpIO%NTilesMax , "Snow water equivalent" , "mm" ) + call add_to_output_mosaic(NoahmpIO%QSNOWXY , "QSNOW" ,NoahmpIO%NTilesMax , "Snowfall rate on the ground" , "mm/s" ) + call add_to_output_mosaic(NoahmpIO%QRAINXY , "QRAIN" ,NoahmpIO%NTilesMax , "Rainfall rate on the ground" , "mm/s" ) + call add_to_output_mosaic(NoahmpIO%ISNOWXY , "ISNOW" ,NoahmpIO%NTilesMax , "Number of snow layers" , "-" ) + call add_to_output_mosaic(NoahmpIO%SNOWC , "FSNO" ,NoahmpIO%NTilesMax , "Snow-cover fraction on the ground" , "-" ) + call add_to_output_mosaic(NoahmpIO%ACSNOW , "ACSNOW" ,NoahmpIO%NTilesMax , "accumulated snow fall" , "mm" ) + call add_to_output_mosaic(NoahmpIO%ACSNOM , "ACSNOM" ,NoahmpIO%NTilesMax , "accumulated snow melt water" , "mm" ) + call add_to_output_mosaic(NoahmpIO%QSNBOTXY , "QSNBOT" ,NoahmpIO%NTilesMax , "water (melt+rain through) out of snow bottom" , "mm/s" ) + call add_to_output_mosaic(NoahmpIO%QMELTXY , "QMELT" ,NoahmpIO%NTilesMax , "snow melt due to phase change" , "mm/s" ) + ! SNICAR snow albedo scheme + if (NoahmpIO%IOPT_ALB == 3)then + call add_to_output_mosaic(NoahmpIO%SNRDSXY , "SNRDS" ,NoahmpIO%NTilesMax , "Snow layer effective grain radius" , "m-6" , "SNOW") + call add_to_output_mosaic(NoahmpIO%SNFRXY , "SNFR" ,NoahmpIO%NTilesMax , "Snow layer rate of freezing" , "mm/s" , "SNOW") + call add_to_output_mosaic(NoahmpIO%BCPHIXY , "BCPHI_Mass",NoahmpIO%NTilesMax ,"hydrophilic BC mass in snow" , "kg/m2" , "SNOW") + call add_to_output_mosaic(NoahmpIO%BCPHOXY , "BCPHO_Mass",NoahmpIO%NTilesMax ,"hydrophobic BC mass in snow" , "kg/m2" , "SNOW") + call add_to_output_mosaic(NoahmpIO%OCPHIXY , "OCPHI_Mass",NoahmpIO%NTilesMax ,"hydrophilic OC mass in snow" , "kg/m2" , "SNOW") + call add_to_output_mosaic(NoahmpIO%OCPHOXY , "OCPHO_Mass",NoahmpIO%NTilesMax ,"hydrophobic OC mass in snow" , "kg/m2" , "SNOW") + call add_to_output_mosaic(NoahmpIO%DUST1XY , "DUST1_Mass",NoahmpIO%NTilesMax ,"dust size bin 1 mass in snow" , "kg/m2" , "SNOW") + call add_to_output_mosaic(NoahmpIO%DUST2XY , "DUST2_Mass",NoahmpIO%NTilesMax ,"dust size bin 2 mass in snow" , "kg/m2" , "SNOW") + call add_to_output_mosaic(NoahmpIO%DUST3XY , "DUST3_Mass",NoahmpIO%NTilesMax ,"dust size bin 3 mass in snow" , "kg/m2" , "SNOW") + call add_to_output_mosaic(NoahmpIO%DUST4XY , "DUST4_Mass",NoahmpIO%NTilesMax ,"dust size bin 4 mass in snow" , "kg/m2" , "SNOW") + call add_to_output_mosaic(NoahmpIO%DUST5XY , "DUST5_Mass",NoahmpIO%NTilesMax ,"dust size bin 5 mass in snow" , "kg/m2" , "SNOW") + call add_to_output_mosaic(NoahmpIO%MassConcBCPHIXY, "BCPHI_MassConc",NoahmpIO%NTilesMax ,"hydrophilic BC mass concentration in snow", "kg/kg", "SNOW") + call add_to_output_mosaic(NoahmpIO%MassConcBCPHOXY, "BCPHO_MassConc",NoahmpIO%NTilesMax ,"hydrophobic BC mass concentration in snow", "kg/kg", "SNOW") + call add_to_output_mosaic(NoahmpIO%MassConcOCPHIXY, "OCPHI_MassConc",NoahmpIO%NTilesMax ,"hydrophilic OC mass concentration in snow", "kg/kg", "SNOW") + call add_to_output_mosaic(NoahmpIO%MassConcOCPHOXY, "OCPHO_MassConc",NoahmpIO%NTilesMax ,"hydrophobic OC mass concentration in snow", "kg/kg", "SNOW") + call add_to_output_mosaic(NoahmpIO%MassConcDUST1XY, "DUST1_MassConc",NoahmpIO%NTilesMax ,"dust size bin 1 mass concentration in snow", "kg/kg", "SNOW") + call add_to_output_mosaic(NoahmpIO%MassConcDUST2XY, "DUST2_MassConc",NoahmpIO%NTilesMax ,"dust size bin 2 mass concentration in snow", "kg/kg", "SNOW") + call add_to_output_mosaic(NoahmpIO%MassConcDUST3XY, "DUST3_MassConc",NoahmpIO%NTilesMax ,"dust size bin 3 mass concentration in snow", "kg/kg", "SNOW") + call add_to_output_mosaic(NoahmpIO%MassConcDUST4XY, "DUST4_MassConc",NoahmpIO%NTilesMax ,"dust size bin 4 mass concentration in snow", "kg/kg", "SNOW") + call add_to_output_mosaic(NoahmpIO%MassConcDUST5XY, "DUST5_MassConc",NoahmpIO%NTilesMax ,"dust size bin 5 mass concentration in snow", "kg/kg", "SNOW") + endif + ! Exchange coefficients + call add_to_output_mosaic(NoahmpIO%CMXY , "CM" ,NoahmpIO%NTilesMax , "Momentum drag coefficient" , "m/s" ) + call add_to_output_mosaic(NoahmpIO%CHXY , "CH" ,NoahmpIO%NTilesMax , "Sensible heat exchange coefficient" , "m/s" ) + call add_to_output_mosaic(NoahmpIO%CHVXY , "CHV" ,NoahmpIO%NTilesMax , "Exchange coefficient vegetated" , "m/s" ) + call add_to_output_mosaic(NoahmpIO%CHBXY , "CHB" ,NoahmpIO%NTilesMax , "Exchange coefficient bare" , "m/s" ) + call add_to_output_mosaic(NoahmpIO%CHLEAFXY , "CHLEAF" ,NoahmpIO%NTilesMax , "Exchange coefficient leaf" , "m/s" ) + call add_to_output_mosaic(NoahmpIO%CHUCXY , "CHUC" ,NoahmpIO%NTilesMax , "Exchange coefficient bare" , "m/s" ) + call add_to_output_mosaic(NoahmpIO%CHV2XY , "CHV2" ,NoahmpIO%NTilesMax , "Exchange coefficient 2-m vegetated" , "m/s" ) + call add_to_output_mosaic(NoahmpIO%CHB2XY , "CHB2" ,NoahmpIO%NTilesMax , "Exchange coefficient 2-m bare" , "m/s" ) + ! Carbon allocation model + call add_to_output_mosaic(NoahmpIO%LFMASSXY , "LFMASS" ,NoahmpIO%NTilesMax , "Leaf mass" , "g/m2" ) + call add_to_output_mosaic(NoahmpIO%RTMASSXY , "RTMASS" ,NoahmpIO%NTilesMax , "Mass of fine roots" , "g/m2" ) + call add_to_output_mosaic(NoahmpIO%STMASSXY , "STMASS" ,NoahmpIO%NTilesMax , "Stem mass" , "g/m2" ) + call add_to_output_mosaic(NoahmpIO%WOODXY , "WOOD" ,NoahmpIO%NTilesMax , "Mass of wood and woody roots" , "g/m2" ) + call add_to_output_mosaic(NoahmpIO%GRAINXY , "GRAIN" ,NoahmpIO%NTilesMax , "Mass of grain" , "g/m2" ) + call add_to_output_mosaic(NoahmpIO%GDDXY , "GDD" ,NoahmpIO%NTilesMax , "Growing degree days " , "-" ) + call add_to_output_mosaic(NoahmpIO%STBLCPXY , "STBLCP" ,NoahmpIO%NTilesMax , "Stable carbon in deep soil" , "gC/m2" ) + call add_to_output_mosaic(NoahmpIO%FASTCPXY , "FASTCP" ,NoahmpIO%NTilesMax , "Short-lived carbon in shallow soil" , "gC/m2" ) + call add_to_output_mosaic(NoahmpIO%NEEXY , "NEE" ,NoahmpIO%NTilesMax , "Net ecosystem exchange" , "gCO2/m2/s" ) + call add_to_output_mosaic(NoahmpIO%GPPXY , "GPP" ,NoahmpIO%NTilesMax , "Net instantaneous assimilation" , "gC/m2/s" ) + call add_to_output_mosaic(NoahmpIO%NPPXY , "NPP" ,NoahmpIO%NTilesMax , "Net primary productivity" , "gC/m2/s" ) + call add_to_output_mosaic(NoahmpIO%PSNXY , "PSN" ,NoahmpIO%NTilesMax , "Total photosynthesis" , "umol CO2/m2/s" ) + call add_to_output_mosaic(NoahmpIO%APARXY , "APAR" ,NoahmpIO%NTilesMax , "Photosynthesis active energy by canopy", "W/m2" ) + ! additional NoahMP output + if (NoahmpIO%noahmp_output > 0) then + ! additional water budget terms + call add_to_output_mosaic(NoahmpIO%QINTSXY , "QINTS" ,NoahmpIO%NTilesMax , "canopy interception (loading) rate for snowfall", "mm/s" ) + call add_to_output_mosaic(NoahmpIO%QINTRXY , "QINTR" ,NoahmpIO%NTilesMax , "canopy interception rate for rain" , "mm/s" ) + call add_to_output_mosaic(NoahmpIO%QDRIPSXY , "QDRIPS" ,NoahmpIO%NTilesMax , "drip (unloading) rate for intercepted snow" , "mm/s" ) + call add_to_output_mosaic(NoahmpIO%QDRIPRXY , "QDRIPR" ,NoahmpIO%NTilesMax , "drip rate for canopy intercepted rain" , "mm/s" ) + call add_to_output_mosaic(NoahmpIO%QTHROSXY , "QTHROS" ,NoahmpIO%NTilesMax , "throughfall of snowfall" , "mm/s" ) + call add_to_output_mosaic(NoahmpIO%QTHRORXY , "QTHROR" ,NoahmpIO%NTilesMax , "throughfall for rain" , "mm/s" ) + call add_to_output_mosaic(NoahmpIO%QSNSUBXY , "QSNSUB" ,NoahmpIO%NTilesMax , "snow surface sublimation rate" , "mm/s" ) + call add_to_output_mosaic(NoahmpIO%QSNFROXY , "QSNFRO" ,NoahmpIO%NTilesMax , "snow surface frost rate" , "mm/s" ) + call add_to_output_mosaic(NoahmpIO%QSUBCXY , "QSUBC" ,NoahmpIO%NTilesMax , "canopy snow sublimation rate" , "mm/s" ) + call add_to_output_mosaic(NoahmpIO%QFROCXY , "QFROC" ,NoahmpIO%NTilesMax , "canopy snow frost rate" , "mm/s" ) + call add_to_output_mosaic(NoahmpIO%QEVACXY , "QEVAC" ,NoahmpIO%NTilesMax , "canopy snow evaporation rate" , "mm/s" ) + call add_to_output_mosaic(NoahmpIO%QDEWCXY , "QDEWC" ,NoahmpIO%NTilesMax , "canopy snow dew rate" , "mm/s" ) + call add_to_output_mosaic(NoahmpIO%QFRZCXY , "QFRZC" ,NoahmpIO%NTilesMax , "refreezing rate of canopy liquid water" , "mm/s" ) + call add_to_output_mosaic(NoahmpIO%QMELTCXY , "QMELTC" ,NoahmpIO%NTilesMax , "melting rate of canopy snow" , "mm/s" ) + call add_to_output_mosaic(NoahmpIO%FPICEXY , "FPICE" ,NoahmpIO%NTilesMax , "snow fraction in precipitation" , "-" ) + call add_to_output_mosaic(NoahmpIO%ACC_QINSURXY,"ACC_QINSUR",NoahmpIO%NTilesMax , "accumuated water flux to soil within soil timestep" , "m/s*dt_soil/dt_main") + call add_to_output_mosaic(NoahmpIO%ACC_QSEVAXY ,"ACC_QSEVA" ,NoahmpIO%NTilesMax , "accumulated soil surface evap rate within soil timestep", "m/s*dt_soil/dt_main") + call add_to_output_mosaic(NoahmpIO%ACC_ETRANIXY,"ACC_ETRANI",NoahmpIO%NTilesMax , "accumualted transpiration rate within soil timestep" , "m/s*dt_soil/dt_main","SOIL") + call add_to_output_mosaic(NoahmpIO%ACC_DWATERXY,"ACC_DWATER",NoahmpIO%NTilesMax , "accumulated water storage change within soil timestep" , "mm") + call add_to_output_mosaic(NoahmpIO%ACC_PRCPXY ,"ACC_PRCP" ,NoahmpIO%NTilesMax , "accumulated precipitation within soil timestep" , "mm") + call add_to_output_mosaic(NoahmpIO%ACC_ECANXY ,"ACC_ECAN" ,NoahmpIO%NTilesMax , "accumulated net canopy evaporation within soil timestep", "mm") + call add_to_output_mosaic(NoahmpIO%ACC_ETRANXY ,"ACC_ETRAN" ,NoahmpIO%NTilesMax , "accumulated transpiration within soil timestep" , "mm") + call add_to_output_mosaic(NoahmpIO%ACC_EDIRXY ,"ACC_EDIR" ,NoahmpIO%NTilesMax , "accumulated net ground evaporation within soil timestep", "mm") + call add_to_output_mosaic(NoahmpIO%ACC_GLAFLWXY,"ACC_GLAFLW",NoahmpIO%NTilesMax , "accumuated glacier excessive flow per soil timestep" , "mm") + ! additional energy terms + call add_to_output_mosaic(NoahmpIO%PAHXY , "PAH" ,NoahmpIO%NTilesMax , "Precipitation advected heat flux" , "W/m2" ) + call add_to_output_mosaic(NoahmpIO%PAHGXY , "PAHG" ,NoahmpIO%NTilesMax , "Precipitation advected heat flux to below-canopy ground" , "W/m2" ) + call add_to_output_mosaic(NoahmpIO%PAHBXY , "PAHB" ,NoahmpIO%NTilesMax , "Precipitation advected heat flux to bare ground" , "W/m2" ) + call add_to_output_mosaic(NoahmpIO%PAHVXY , "PAHV" ,NoahmpIO%NTilesMax , "Precipitation advected heat flux to canopy" , "W/m2" ) + call add_to_output_mosaic(NoahmpIO%ACC_SSOILXY, "ACC_SSOIL",NoahmpIO%NTilesMax ,"accumulated heat flux into snow/soil within soil timestep", "W/m2" ) + call add_to_output_mosaic(NoahmpIO%EFLXBXY , "EFLXB" ,NoahmpIO%NTilesMax , "accumulated heat flux through soil bottom" , "J/m2" ) + call add_to_output_mosaic(NoahmpIO%SOILENERGY , "SOILENERGY",NoahmpIO%NTilesMax ,"energy content in soil relative to 273.16" , "KJ/m2" ) + call add_to_output_mosaic(NoahmpIO%SNOWENERGY , "SNOWENERGY",NoahmpIO%NTilesMax ,"energy content in snow relative to 273.16" , "KJ/m2" ) + call add_to_output_mosaic(NoahmpIO%CANHSXY , "CANHS" ,NoahmpIO%NTilesMax , "canopy heat storage change" , "W/m2" ) + ! additional forcing terms + call add_to_output_mosaic(NoahmpIO%RAINLSM , "RAINLSM" ,NoahmpIO%NTilesMax , "lowest model liquid precipitation into LSM" , "mm/s" ) + call add_to_output_mosaic(NoahmpIO%SNOWLSM , "SNOWLSM" ,NoahmpIO%NTilesMax , "lowest model snowfall into LSM" , "mm/s" ) + call add_to_output_mosaic(NoahmpIO%FORCTLSM , "FORCTLSM",NoahmpIO%NTilesMax , "lowest model temperature into LSM" , "K" ) + call add_to_output_mosaic(NoahmpIO%FORCQLSM , "FORCQLSM",NoahmpIO%NTilesMax , "lowest model specific humidty into LSM" , "kg/kg" ) + call add_to_output_mosaic(NoahmpIO%FORCPLSM , "FORCPLSM",NoahmpIO%NTilesMax , "lowest model pressure into LSM" , "Pa" ) + call add_to_output_mosaic(NoahmpIO%FORCZLSM , "FORCZLSM",NoahmpIO%NTilesMax , "lowest model forcing height into LSM" , "m" ) + call add_to_output_mosaic(NoahmpIO%FORCWLSM , "FORCWLSM",NoahmpIO%NTilesMax , "lowest model wind speed into LSM" , "m/s" ) + call add_to_output_mosaic(NoahmpIO%RadSwVisFrac , "SWVISFRAC",NoahmpIO%NTilesMax , "Fraction of visible band downward solar radiation", "-" ) + call add_to_output_mosaic(NoahmpIO%RadSwDirFrac , "SWDIRFRAC",NoahmpIO%NTilesMax , "Fraction of downward solar direct radiation", "-" ) + endif + + ! Irrigation + if ( NoahmpIO%IOPT_IRR > 0 ) then + call add_to_output_mosaic(NoahmpIO%IRNUMSI , "IRNUMSI" ,NoahmpIO%NTilesMax , "Sprinkler irrigation count" , "-" ) + call add_to_output_mosaic(NoahmpIO%IRNUMMI , "IRNUMMI" ,NoahmpIO%NTilesMax , "Micro irrigation count" , "-" ) + call add_to_output_mosaic(NoahmpIO%IRNUMFI , "IRNUMFI" ,NoahmpIO%NTilesMax , "Flood irrigation count" , "-" ) + call add_to_output_mosaic(NoahmpIO%IRELOSS , "IRELOSS" ,NoahmpIO%NTilesMax , "Accumulated sprinkler Evaporation" , "mm" ) + call add_to_output_mosaic(NoahmpIO%IRSIVOL , "IRSIVOL" ,NoahmpIO%NTilesMax , "Sprinkler irrigation amount" , "mm" ) + call add_to_output_mosaic(NoahmpIO%IRMIVOL , "IRMIVOL" ,NoahmpIO%NTilesMax , "Micro irrigation amount" , "mm" ) + call add_to_output_mosaic(NoahmpIO%IRFIVOL , "IRFIVOL" ,NoahmpIO%NTilesMax , "Flood irrigation amount" , "mm" ) + call add_to_output_mosaic(NoahmpIO%IRRSPLH , "IRRSPLH" ,NoahmpIO%NTilesMax , "Accumulated latent heating due to sprinkler" , "J/m2" ) + endif + ! MMF groundwater model + if ( NoahmpIO%IOPT_RUNSUB == 5 ) then + call add_to_output_mosaic(NoahmpIO%SMCWTDXY , "SMCWTD" ,NoahmpIO%NTilesMax , "soil water content between bottom of the soil and water table", "m3/m3" ) + call add_to_output_mosaic(NoahmpIO%RECHXY , "RECH" ,NoahmpIO%NTilesMax , "recharge to or from the water table when shallow" , "m" ) + call add_to_output_mosaic(NoahmpIO%DEEPRECHXY , "DEEPRECH" ,NoahmpIO%NTilesMax , "recharge to or from the water table when deep" , "m" ) + call add_to_output(NoahmpIO%QRFSXY , "QRFS" , "accumulated groundwater baselow" , "mm" ) + call add_to_output(NoahmpIO%QRFXY , "QRF" , "groundwater baseflow" , "m" ) + call add_to_output(NoahmpIO%QSPRINGSXY , "QSPRINGS" , "accumulated seeping water" , "mm" ) + call add_to_output(NoahmpIO%QSPRINGXY , "QSPRING" , "instantaneous seeping water" , "m" ) + call add_to_output(NoahmpIO%QSLATXY , "QSLAT" , "accumulated lateral flow" , "mm" ) + call add_to_output(NoahmpIO%QLATXY , "QLAT" , "instantaneous lateral flow" , "m" ) + endif + ! Wetland model + if ( NoahmpIO%IOPT_WETLAND > 0 ) then + call add_to_output_mosaic(NoahmpIO%FSATXY , "FSAT" ,NoahmpIO%NTilesMax , "saturated fraction of the grid" , "-" ) + call add_to_output_mosaic(NoahmpIO%WSURFXY , "WSURF" ,NoahmpIO%NTilesMax , "Wetland Water Storage" , "mm") + endif + + end subroutine WriteNoahmpMosaicSubgridOutput + +end module WriteNoahmpMosaicSubgridOutputMod \ No newline at end of file diff --git a/hrldas/IO_code/module_NoahMP_hrldas_driver.F b/hrldas/IO_code/module_NoahMP_hrldas_driver.F index 69e6d8a..19ae8d8 100644 --- a/hrldas/IO_code/module_NoahMP_hrldas_driver.F +++ b/hrldas/IO_code/module_NoahMP_hrldas_driver.F @@ -14,6 +14,11 @@ module module_NoahMP_hrldas_driver use module_sf_urban, only : urban_param_init, urban_var_init use module_date_utilities use SnowInputSnicarMod, only : SnowInputSnicar + use WriteNoahmpMosaicGridAverageOutputMod + use WriteNoahmpMosaicSubgridOutputMod + use WriteNoahmpMosaicRestartMod + use ReadNoahmpMosaicRestartMod + use NoahmpMosaicSortTileCatMod #ifdef MPP_LAND use module_mpp_land, only: MPP_LAND_PAR_INI, mpp_land_init, getLocalXY, mpp_land_bcast_char @@ -50,6 +55,7 @@ module module_NoahMP_hrldas_driver integer :: I integer :: J integer :: imode + integer :: N contains @@ -163,30 +169,99 @@ subroutine land_driver_ini(NTIME_out,wrfits,wrfite,wrfjts,wrfjte) #endif NoahmpIO%ids = NoahmpIO%xstart - NoahmpIO%ide = NoahmpIO%xend + NoahmpIO%ide = NoahmpIO%xend NoahmpIO%jds = NoahmpIO%ystart - NoahmpIO%jde = NoahmpIO%yend + NoahmpIO%jde = NoahmpIO%yend NoahmpIO%kds = 1 NoahmpIO%kde = 2 NoahmpIO%its = NoahmpIO%xstart - NoahmpIO%ite = NoahmpIO%xend + NoahmpIO%ite = NoahmpIO%xend NoahmpIO%jts = NoahmpIO%ystart - NoahmpIO%jte = NoahmpIO%yend + NoahmpIO%jte = NoahmpIO%yend NoahmpIO%kts = 1 NoahmpIO%kte = 2 NoahmpIO%ims = NoahmpIO%xstart - NoahmpIO%ime = NoahmpIO%xend + NoahmpIO%ime = NoahmpIO%xend NoahmpIO%jms = NoahmpIO%ystart - NoahmpIO%jme = NoahmpIO%yend + NoahmpIO%jme = NoahmpIO%yend NoahmpIO%kms = 1 NoahmpIO%kme = 2 - + xstart = NoahmpIO%xstart + xend = NoahmpIO%xend + ystart = NoahmpIO%ystart + yend = NoahmpIO%yend + if ( (NoahmpIO%sf_urban_physics == 2) .or. (NoahmpIO%sf_urban_physics == 3) ) then NoahmpIO%kde = NoahmpIO%num_urban_atmosphere + 1 ! to be consistent with kme NoahmpIO%kme = NoahmpIO%num_urban_atmosphere + 1 ! bug fix for dimension of urban cell interfaces NoahmpIO%kte = NoahmpIO%num_urban_atmosphere endif +!--------------------------------------------------------------------- +! Noah-MP Mosiac Scheme: Read Subgrid Fractions (3D) ! Prasanth V. +!--------------------------------------------------------------------- + + if(NoahmpIO%IOPT_MOSAIC .eq. 1) then ! subgrid tiling based on land cover type only + + if ( .not. allocated (NoahmpIO%SubGrdFrac) ) & + allocate ( NoahmpIO%SubGrdFrac (XSTART:XEND, YSTART:YEND, 1:noahmpio%NumMosaicCat) ) + if ( .not. allocated (NoahmpIO%SubGrdFracRescaled)) & + allocate ( NoahmpIO%SubGrdFracRescaled (XSTART:XEND, YSTART:YEND, 1:noahmpio%NumMosaicCat) ) + if ( .not. allocated (NoahmpIO%SubGrdIndexSorted) ) & + allocate ( NoahmpIO%SubGrdIndexSorted (XSTART:XEND, YSTART:YEND, 1:noahmpio%NumMosaicCat) ) + if ( .not. allocated (NoahmpIO%NumberOfTiles) ) & + allocate ( NoahmpIO%NumberOfTiles (XSTART:XEND, YSTART:YEND) ) + +! NumMosaicCat is read from namelist.hrldas for now +! if ( trim(noahmpio%llanduse) == "usgs" ) then +! noahmpio%NumMosaicCat = 28 +! else if ( trim(noahmpio%llanduse) == "modified_igbp_modis_noah") then +! noahmpio%NumMosaicCat = 21 +! else if ( trim(noahmpio%llanduse) == "NLCD40") THEN +! noahmpio%NumMosaicCat = 40 +! end if + + NoahmpIO%SubGrdFrac = 0.0 + NoahmpIO%SubGrdFracRescaled = 0.0 + NoahmpIO%SubGrdIndexSorted = 0 + NoahmpIO%NumberOfTiles = 1 + NoahmpIO%NTilesMax = 1 + + call ReadMosaicTileFrac (NoahmpIO%HRLDAS_SETUP_FILE, & + NoahmpIO%XSTART,NoahmpIO%XEND, & + NoahmpIO%YSTART, NoahmpIO%YEND, & + noahmpio%NumMosaicCat, & + NoahmpIO%SubGrdFracName, & + NoahmpIO%SubGrdFrac & + ) + + call NoahmpMosaicSortTileCat (NoahmpIO) ! sort the landuse fraction decreasing order and identify maximum number of title + ! based on 90% area fraction criteria. and rescale them to 100% + if ( .not. allocated (NoahmpIO%SubGrdFracMosaic) ) & + allocate ( NoahmpIO%SubGrdFracMosaic (XSTART:XEND, YSTART:YEND, 1:noahmpio%NTilesMax) ) + NoahmpIO%SubGrdFracMosaic(:,:,1:noahmpio%NTilesMax) = NoahmpIO%SubGrdFracRescaled (:,:,1:noahmpio%NTilesMax) + + else ! more options can be added with a else option for soil type or hydro type etc. + + if ( .not. allocated (NoahmpIO%SubGrdFrac) ) & + allocate ( NoahmpIO%SubGrdFrac (XSTART:XEND, YSTART:YEND, 1) ) + if ( .not. allocated (NoahmpIO%SubGrdFracRescaled)) & + allocate ( NoahmpIO%SubGrdFracRescaled (XSTART:XEND, YSTART:YEND, 1) ) + if ( .not. allocated (NoahmpIO%SubGrdIndexSorted) ) & + allocate ( NoahmpIO%SubGrdIndexSorted (XSTART:XEND, YSTART:YEND, 1) ) + if ( .not. allocated (NoahmpIO%NumberOfTiles) ) & + allocate ( NoahmpIO%NumberOfTiles (XSTART:XEND, YSTART:YEND) ) + + ! since all variables are with subgrid dimension, it should be 1 when mosaic is off + NoahmpIO%NTilesMax = 1 ! maximum subgrid tiles + NoahmpIO%NumberOfTiles = 1 ! 2D array of number of subgrid tiles + NoahmpIO%SubGrdFracRescaled = 1 ! 3D array of subgrid fractions + NoahmpIO%SubGrdFracMosaic = 1 + + endif + +! Noah-MP Mosiac Scheme: Initialization Ends + !--------------------------------------------------------------------- ! Allocate multi-dimension fields for subwindow calculation !--------------------------------------------------------------------- @@ -308,7 +383,12 @@ subroutine land_driver_ini(NTIME_out,wrfits,wrfite,wrfjts,wrfjte) NoahmpIO%FSATMX = 0.38 NoahmpIO%WCAP = 0.1 call READ_WETLAND_INPUT(NoahmpIO%HRLDAS_SETUP_FILE, NoahmpIO%XSTART, NoahmpIO%XEND, NoahmpIO%YSTART, NoahmpIO%YEND,& - NoahmpIO%FSATMX,NoahmpIO%WCAP) + NoahmpIO%FSATMX(:,:,1),NoahmpIO%WCAP(:,:,1)) + do N = 1,NoahmpIO%NTilesMax + NoahmpIO%FSATMX(:,:,N) = NoahmpIO%FSATMX(:,:,1) + NoahmpIO%WCAP(:,:,N) = NoahmpIO%WCAP(:,:,1) + end do + endif !------------------------------------------------------------------------ @@ -328,12 +408,12 @@ subroutine land_driver_ini(NTIME_out,wrfits,wrfite,wrfjts,wrfjte) NoahmpIO%DZS = NoahmpIO%SOIL_THICK_INPUT(1:NoahmpIO%NSOIL) NoahmpIO%ITIMESTEP = 1 xstart = NoahmpIO%xstart - xend = NoahmpIO%xend + xend = NoahmpIO%xend ystart = NoahmpIO%ystart - yend = NoahmpIO%yend + yend = NoahmpIO%yend ixfull = NoahmpIO%ixfull - jxfull = NoahmpIO%jxfull - + jxfull = NoahmpIO%jxfull + if (NoahmpIO%restart_filename_requested /= " ") then NoahmpIO%restart_flag = .true. @@ -346,211 +426,10 @@ subroutine land_driver_ini(NTIME_out,wrfits,wrfite,wrfjts,wrfjte) call mpp_land_bcast_char(19,NoahmpIO%OLDDATE(1:19)) #endif - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "SOIL_T" , NoahmpIO%TSLB ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "SNOW_T" , NoahmpIO%TSNOXY ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "SMC" , NoahmpIO%SMOIS ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "SH2O" , NoahmpIO%SH2O ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "ZSNSO" , NoahmpIO%ZSNSOXY ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "SNICE" , NoahmpIO%SNICEXY ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "SNLIQ" , NoahmpIO%SNLIQXY ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "FWET" , NoahmpIO%FWETXY ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "SNEQVO" , NoahmpIO%SNEQVOXY ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "EAH" , NoahmpIO%EAHXY ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "TAH" , NoahmpIO%TAHXY ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "ALBOLD" , NoahmpIO%ALBOLDXY ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "CM" , NoahmpIO%CMXY ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "CH" , NoahmpIO%CHXY ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "ISNOW" , NoahmpIO%ISNOWXY ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "CANLIQ" , NoahmpIO%CANLIQXY ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "CANICE" , NoahmpIO%CANICEXY ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "SNEQV" , NoahmpIO%SNOW ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "SNOWH" , NoahmpIO%SNOWH ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "TV" , NoahmpIO%TVXY ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "TG" , NoahmpIO%TGXY ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "ZWT" , NoahmpIO%ZWTXY ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "WA" , NoahmpIO%WAXY ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "WT" , NoahmpIO%WTXY ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "WSLAKE" , NoahmpIO%WSLAKEXY ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "LFMASS" , NoahmpIO%LFMASSXY ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "RTMASS" , NoahmpIO%RTMASSXY ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "STMASS" , NoahmpIO%STMASSXY ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "CROPCAT" , NoahmpIO%CROPCAT ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "WOOD" , NoahmpIO%WOODXY ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "GRAIN" , NoahmpIO%GRAINXY ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "GDD" , NoahmpIO%GDDXY ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "STBLCP" , NoahmpIO%STBLCPXY ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "FASTCP" , NoahmpIO%FASTCPXY ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "LAI" , NoahmpIO%LAI ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "SAI" , NoahmpIO%XSAIXY ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "VEGFRA" , NoahmpIO%VEGFRA ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "GVFMIN" , NoahmpIO%GVFMIN ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "GVFMAX" , NoahmpIO%GVFMAX ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "ACMELT" , NoahmpIO%ACSNOM ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "ACSNOW" , NoahmpIO%ACSNOW ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "TAUSS" , NoahmpIO%TAUSSXY ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "QSFC" , NoahmpIO%QSFC ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "SFCRUNOFF",NoahmpIO%SFCRUNOFF) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "UDRUNOFF" ,NoahmpIO%UDRUNOFF ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "QTDRAIN" ,NoahmpIO%QTDRAIN ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "ACC_SSOIL" , NoahmpIO%ACC_SSOILXY ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "ACC_QINSUR", NoahmpIO%ACC_QINSURXY) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "ACC_QSEVA" , NoahmpIO%ACC_QSEVAXY ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "ACC_ETRANI", NoahmpIO%ACC_ETRANIXY) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "ACC_DWATER", NoahmpIO%ACC_DWATERXY) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "ACC_PRCP" , NoahmpIO%ACC_PRCPXY ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "ACC_ECAN" , NoahmpIO%ACC_ECANXY ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "ACC_ETRAN" , NoahmpIO%ACC_ETRANXY ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "ACC_EDIR" , NoahmpIO%ACC_EDIRXY ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "ACC_GLAFLW", NoahmpIO%ACC_GLAFLWXY) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "ALBSOILDIR", NoahmpIO%ALBSOILDIRXY) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "ALBSOILDIF", NoahmpIO%ALBSOILDIFXY) - - ! below for SNICAR snow albedo scheme - if (NoahmpIO%IOPT_ALB == 3)then - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "SNRDS" , NoahmpIO%SNRDSXY ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "SNFR" , NoahmpIO%SNFRXY ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "BCPHI" , NoahmpIO%BCPHIXY ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "BCPHO" , NoahmpIO%BCPHOXY ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "OCPHI" , NoahmpIO%OCPHIXY ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "OCPHO" , NoahmpIO%OCPHOXY ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "DUST1" , NoahmpIO%DUST1XY ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "DUST2" , NoahmpIO%DUST2XY ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "DUST3" , NoahmpIO%DUST3XY ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "DUST4" , NoahmpIO%DUST4XY ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "DUST5" , NoahmpIO%DUST5XY ) - endif - - ! below for irrigation scheme - if ( NoahmpIO%IOPT_IRR > 0 ) then - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "IRNUMSI" , NoahmpIO%IRNUMSI ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "IRNUMMI" , NoahmpIO%IRNUMMI ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "IRNUMFI" , NoahmpIO%IRNUMFI ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "IRWATSI" , NoahmpIO%IRWATSI ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "IRWATMI" , NoahmpIO%IRWATMI ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "IRWATFI" , NoahmpIO%IRWATFI ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "IRSIVOL" , NoahmpIO%IRSIVOL ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "IRMIVOL" , NoahmpIO%IRMIVOL ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "IRFIVOL" , NoahmpIO%IRFIVOL ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "IRELOSS" , NoahmpIO%IRELOSS ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "IRRSPLH" , NoahmpIO%IRRSPLH ) - endif - - ! below for MMF groundwater scheme - if ( NoahmpIO%IOPT_RUNSUB == 5 ) then - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "SMOISEQ" , NoahmpIO%SMOISEQ ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "AREAXY" , NoahmpIO%AREAXY ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "SMCWTDXY" , NoahmpIO%SMCWTDXY ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "QRFXY" , NoahmpIO%QRFXY ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "DEEPRECHXY", NoahmpIO%DEEPRECHXY ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "QSPRINGXY" , NoahmpIO%QSPRINGXY ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "QSLATXY" , NoahmpIO%QSLATXY ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "QRFSXY" , NoahmpIO%QRFSXY ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "QSPRINGSXY", NoahmpIO%QSPRINGSXY ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "RECHXY" , NoahmpIO%RECHXY ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "FDEPTHXY" ,NoahmpIO%FDEPTHXY ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "RIVERCONDXY",NoahmpIO%RIVERCONDXY) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "RIVERBEDXY" ,NoahmpIO%RIVERBEDXY ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "EQZWT" ,NoahmpIO%EQZWT ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "PEXPXY" ,NoahmpIO%PEXPXY ) - endif - - ! for wetland scheme - if ( NoahmpIO%IOPT_WETLAND > 0 ) then - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "FSATXY" , NoahmpIO%FSATXY ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "WSURFXY" , NoahmpIO%WSURFXY ) - endif +! Read restart files - ! below for urban model - if ( NoahmpIO%SF_URBAN_PHYSICS > 0 ) then - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "SH_URB2D" , NoahmpIO%SH_URB2D ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "LH_URB2D" , NoahmpIO%LH_URB2D ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "G_URB2D" , NoahmpIO%G_URB2D ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "RN_URB2D" , NoahmpIO%RN_URB2D ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "TS_URB2D" , NoahmpIO%TS_URB2D ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "FRC_URB2D" , NoahmpIO%FRC_URB2D ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "UTYPE_URB2D" , NoahmpIO%UTYPE_URB2D ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "LP_URB2D" , NoahmpIO%LP_URB2D ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "LB_URB2D" , NoahmpIO%LB_URB2D ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "HGT_URB2D" , NoahmpIO%HGT_URB2D ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "MH_URB2D" , NoahmpIO%MH_URB2D ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "STDH_URB2D" , NoahmpIO%STDH_URB2D ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "HI_URB2D" , NoahmpIO%HI_URB2D ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "LF_URB2D" , NoahmpIO%LF_URB2D ) - - if ( NoahmpIO%SF_URBAN_PHYSICS == 1 ) then ! single layer urban model - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "CMR_SFCDIF" , NoahmpIO%CMR_SFCDIF ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "CHR_SFCDIF" , NoahmpIO%CHR_SFCDIF ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "CMC_SFCDIF" , NoahmpIO%CMC_SFCDIF ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "CHC_SFCDIF" , NoahmpIO%CHC_SFCDIF ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "CMGR_SFCDIF" , NoahmpIO%CMGR_SFCDIF ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "CHGR_SFCDIF" , NoahmpIO%CHGR_SFCDIF ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "TR_URB2D" , NoahmpIO%TR_URB2D ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "TB_URB2D" , NoahmpIO%TB_URB2D ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "TG_URB2D" , NoahmpIO%TG_URB2D ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "TC_URB2D" , NoahmpIO%TC_URB2D ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "QC_URB2D" , NoahmpIO%QC_URB2D ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "UC_URB2D" , NoahmpIO%UC_URB2D ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "XXXR_URB2D" , NoahmpIO%XXXR_URB2D ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "XXXB_URB2D" , NoahmpIO%XXXB_URB2D ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "XXXG_URB2D" , NoahmpIO%XXXG_URB2D ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "XXXC_URB2D" , NoahmpIO%XXXC_URB2D ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "TRL_URB3D" , NoahmpIO%TRL_URB3D ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "TBL_URB3D" , NoahmpIO%TBL_URB3D ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "TGL_URB3D" , NoahmpIO%TGL_URB3D ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "CMCR_URB2D" , NoahmpIO%CMCR_URB2D ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "TGR_URB2D" , NoahmpIO%TGR_URB2D ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "TGRL_URB3D" , NoahmpIO%TGRL_URB3D ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "SMR_URB3D" , NoahmpIO%SMR_URB3D ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "DRELR_URB2D" , NoahmpIO%DRELR_URB2D ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "DRELB_URB2D" , NoahmpIO%DRELB_URB2D ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "DRELG_URB2D" , NoahmpIO%DRELG_URB2D ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "FLXHUMR_URB2D" ,NoahmpIO%FLXHUMR_URB2D ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "FLXHUMB_URB2D" ,NoahmpIO%FLXHUMB_URB2D ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "FLXHUMG_URB2D" ,NoahmpIO%FLXHUMG_URB2D ) - endif + call ReadNoahmpMosaicRestart (NoahmpIO) - if ( (NoahmpIO%SF_URBAN_PHYSICS == 2) .or. (NoahmpIO%SF_URBAN_PHYSICS == 3) ) then ! BEP or BEM urban models - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "TRB_URB4D" , NoahmpIO%TRB_URB4D ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "TW1_URB4D" , NoahmpIO%TW1_URB4D ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "TW2_URB4D" , NoahmpIO%TW2_URB4D ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "TGB_URB4D" , NoahmpIO%TGB_URB4D ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "SFW1_URB3D" , NoahmpIO%SFW1_URB3D ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "SFW2_URB3D" , NoahmpIO%SFW2_URB3D ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "SFR_URB3D" , NoahmpIO%SFR_URB3D ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "SFG_URB3D" , NoahmpIO%SFG_URB3D ) - endif - - if ( NoahmpIO%SF_URBAN_PHYSICS == 3 ) then ! BEM urban model - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "TLEV_URB3D" , NoahmpIO%TLEV_URB3D ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "QLEV_URB3D" , NoahmpIO%QLEV_URB3D ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "TW1LEV_URB3D" , NoahmpIO%TW1LEV_URB3D ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "TW2LEV_URB3D" , NoahmpIO%TW2LEV_URB3D ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "TGLEV_URB3D" , NoahmpIO%TGLEV_URB3D ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "TFLEV_URB3D" , NoahmpIO%TFLEV_URB3D ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "SF_AC_URB3D" , NoahmpIO%SF_AC_URB3D ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "LF_AC_URB3D" , NoahmpIO%LF_AC_URB3D ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "CM_AC_URB3D" , NoahmpIO%CM_AC_URB3D ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "SFVENT_URB3D" , NoahmpIO%SFVENT_URB3D ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "LFVENT_URB3D" , NoahmpIO%LFVENT_URB3D ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "SFWIN1_URB3D" , NoahmpIO%SFWIN1_URB3D ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "SFWIN2_URB3D" , NoahmpIO%SFWIN2_URB3D ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "EP_PV_URB3D" , NoahmpIO%EP_PV_URB3D ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "T_PV_URB3D" , NoahmpIO%T_PV_URB3D ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "TRV_URB4D" , NoahmpIO%TRV_URB4D ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "QR_URB4D" , NoahmpIO%QR_URB4D ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "QGR_URB3D" , NoahmpIO%QGR_URB3D ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "TGR_URB3D" , NoahmpIO%TGR_URB3D ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "DRAIN_URB4D" , NoahmpIO%DRAIN_URB4D ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "DRAINGR_URB3D" ,NoahmpIO%DRAINGR_URB3D ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "SFRV_URB3D" , NoahmpIO%SFRV_URB3D ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "LFRV_URB3D" , NoahmpIO%LFRV_URB3D ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "DGR_URB3D" , NoahmpIO%DGR_URB3D ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "DG_URB3D" , NoahmpIO%DG_URB3D ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "LFR_URB3D" , NoahmpIO%LFR_URB3D ) - call get_from_restart(xstart, xend, xstart, ixfull, jxfull, "LFG_URB3D" , NoahmpIO%LFG_URB3D ) - endif - endif - NoahmpIO%STEPWTD = nint(NoahmpIO%WTDDT*60.0/NoahmpIO%DTBL) NoahmpIO%STEPWTD = max(NoahmpIO%STEPWTD,1) @@ -641,16 +520,31 @@ subroutine land_driver_ini(NTIME_out,wrfits,wrfite,wrfjts,wrfjte) ".LDASIN_DOMAIN"//NoahmpIO%hgrid #endif - call READINIT_HRLDAS(NoahmpIO%HRLDAS_SETUP_FILE, NoahmpIO%xstart, NoahmpIO%xend, & - NoahmpIO%ystart, NoahmpIO%yend, NoahmpIO%NSOIL, NoahmpIO%DZS, & - NoahmpIO%OLDDATE, LDASIN_VERSION, NoahmpIO%SMOIS, & - NoahmpIO%TSLB, NoahmpIO%CANWAT, NoahmpIO%TSK, NoahmpIO%SNOW, & - NoahmpIO%SNOWH, NoahmpIO%FNDSNOWH) + call READINIT_HRLDAS(NoahmpIO%HRLDAS_SETUP_FILE, NoahmpIO%xstart, NoahmpIO%xend, & + NoahmpIO%ystart, NoahmpIO%yend, NoahmpIO%NSOIL, NoahmpIO%DZS, & + NoahmpIO%OLDDATE, LDASIN_VERSION, NoahmpIO%SMOIS(:,:,:,1), & + NoahmpIO%TSLB(:,:,:,1), NoahmpIO%CANWAT(:,:,1), NoahmpIO%TSK(:,:,1), & + NoahmpIO%SNOW(:,:,1), NoahmpIO%SNOWH(:,:,1), NoahmpIO%FNDSNOWH) NoahmpIO%VEGFRA = 0.0 - call READVEG_HRLDAS(NoahmpIO%HRLDAS_SETUP_FILE, NoahmpIO%xstart, NoahmpIO%xend, & - NoahmpIO%ystart, NoahmpIO%yend, NoahmpIO%OLDDATE, NoahmpIO%IVGTYP, & - NoahmpIO%VEGFRA, NoahmpIO%LAI, NoahmpIO%GVFMIN, NoahmpIO%GVFMAX) + call READVEG_HRLDAS(NoahmpIO%HRLDAS_SETUP_FILE, NoahmpIO%xstart, NoahmpIO%xend, & + NoahmpIO%ystart, NoahmpIO%yend, NoahmpIO%OLDDATE, NoahmpIO%IVGTYP, & + NoahmpIO%VEGFRA(:,:,1), NoahmpIO%LAI(:,:,1), NoahmpIO%GVFMIN(:,:,1), & + NoahmpIO%GVFMAX(:,:,1)) + + ! copy 2D static fields to mosaic dimension + do N = 1,NoahmpIO%NTilesMax + NoahmpIO%SMOIS(:,:,:,N) = NoahmpIO%SMOIS(:,:,:,1) + NoahmpIO%TSLB(:,:,:,N) = NoahmpIO%TSLB(:,:,:,1) + NoahmpIO%CANWAT(:,:,N) = NoahmpIO%CANWAT(:,:,1) + NoahmpIO%TSK(:,:,N) = NoahmpIO%TSK(:,:,1) + NoahmpIO%SNOW(:,:,N) = NoahmpIO%SNOW(:,:,1) + NoahmpIO%SNOWH(:,:,N) = NoahmpIO%SNOWH(:,:,1) + NoahmpIO%VEGFRA(:,:,N) = NoahmpIO%VEGFRA(:,:,1) + NoahmpIO%LAI(:,:,N) = NoahmpIO%LAI(:,:,1) + NoahmpIO%GVFMIN(:,:,N) = NoahmpIO%GVFMIN(:,:,1) + NoahmpIO%GVFMAX(:,:,N) = NoahmpIO%GVFMAX(:,:,1) + end do #ifdef WRF_HYDRO else ! HRLDAS_ini_typ @@ -665,13 +559,13 @@ subroutine land_driver_ini(NTIME_out,wrfits,wrfite,wrfjts,wrfjte) NoahmpIO%CANWAT, NoahmpIO%TSK, NoahmpIO%SNOW, NoahmpIO%SNOWH, NoahmpIO%lai, NoahmpIO%VEGFRA, NoahmpIO%IVGTYP, & NoahmpIO%FNDSNOWH) - NoahmpIO%greenfrac = 0.0 + greenfrac = 0.0 #ifdef MPP_LAND call get_greenfrac_mpp & #else call get_greenfrac & #endif - (trim(NoahmpIO%GEO_STATIC_FLNM),NoahmpIO%greenfrac, NoahmpIO%ix, NoahmpIO%jx, NoahmpIO%olddate, NoahmpIO%SHDMAX) + (trim(NoahmpIO%GEO_STATIC_FLNM),greenfrac, NoahmpIO%ix, NoahmpIO%jx, NoahmpIO%olddate, NoahmpIO%SHDMAX) !yw GVFMAX = maxval(greenfrac) endif #endif @@ -845,10 +739,16 @@ subroutine land_driver_exe(itime) NoahmpIO%QV_CURR(:,1,:),NoahmpIO%U_PHY(:,1,:), & NoahmpIO%V_PHY(:,1,:),NoahmpIO%P8W(:,1,:), NoahmpIO%GLW, & NoahmpIO%SWDOWN, NoahmpIO%RAINBL, NoahmpIO%SNOWBL, & - NoahmpIO%VEGFRA, NoahmpIO%update_veg, NoahmpIO%LAI, & - NoahmpIO%update_lai, NoahmpIO%reset_spinup_date, & - NoahmpIO%startdate, NoahmpIO%RadSwDirFrac, NoahmpIO%RadSwVisFrac) - + NoahmpIO%VEGFRA(:,:,1), NoahmpIO%update_veg, & + NoahmpIO%LAI(:,:,1), NoahmpIO%update_lai, & + NoahmpIO%reset_spinup_date, NoahmpIO%startdate, & + NoahmpIO%RadSwDirFrac(:,:,1), NoahmpIO%RadSwVisFrac(:,:,1)) + + ! copy 2D static fields to mosaic dimension + do N = 1,NoahmpIO%NTilesMax + NoahmpIO%VEGFRA(:,:,N) = NoahmpIO%VEGFRA(:,:,1) + NoahmpIO%LAI(:,:,N) = NoahmpIO%LAI(:,:,1) + enddo NoahmpIO%VEGFRA = NoahmpIO%VEGFRA * 100.0 else if(NoahmpIO%olddate == forcDate) then @@ -873,24 +773,47 @@ subroutine land_driver_exe(itime) NoahmpIO%forcing_name_DirFrac,NoahmpIO%forcing_name_VisFrac, & NoahmpIO%T_PHY(:,1,:),NoahmpIO%QV_CURR(:,1,:),NoahmpIO%U_PHY(:,1,:), & NoahmpIO%V_PHY(:,1,:),NoahmpIO%P8W(:,1,:), NoahmpIO%GLW, NoahmpIO%SWDOWN, & - NoahmpIO%RAINBL, NoahmpIO%SNOWBL, NoahmpIO%VEGFRA, NoahmpIO%update_veg, & - NoahmpIO%LAI, NoahmpIO%update_lai, NoahmpIO%reset_spinup_date, NoahmpIO%startdate, & - NoahmpIO%RadSwDirFrac, NoahmpIO%RadSwVisFrac ) - + NoahmpIO%RAINBL, NoahmpIO%SNOWBL, NoahmpIO%VEGFRA(:,:,1), NoahmpIO%update_veg, & + NoahmpIO%LAI(:,:,1), NoahmpIO%update_lai, NoahmpIO%reset_spinup_date, & + NoahmpIO%startdate, NoahmpIO%RadSwDirFrac(:,:,1), NoahmpIO%RadSwVisFrac(:,:,1)) + + ! copy 2D static fields to mosaic dimension + do N = 1,NoahmpIO%NTilesMax + NoahmpIO%VEGFRA(:,:,N) = NoahmpIO%VEGFRA(:,:,1) + NoahmpIO%LAI(:,:,N) = NoahmpIO%LAI(:,:,1) + NoahmpIO%RadSwDirFrac(:,:,N) = NoahmpIO%RadSwDirFrac(:,:,1) + NoahmpIO%RadSwVisFrac(:,:,N) = NoahmpIO%RadSwVisFrac(:,:,1) + enddo + if(maxval(NoahmpIO%VEGFRA) <= 1 ) then NoahmpIO%VEGFRA = NoahmpIO%VEGFRA * 100. ! added for input vegfra as a fraction (0~1) endif #endif if((NoahmpIO%IOPT_ALB == 3) .and. (NoahmpIO%SNICAR_AEROSOL_READTABLE .eqv. .false.)) then - call READFORC_AEROSOL(NoahmpIO%INFLNM_TEMPLATE, NoahmpIO%FORCING_TIMESTEP, & - NoahmpIO%OLDDATE, NoahmpIO%XSTART, NoahmpIO%XEND, NoahmpIO%YSTART, NoahmpIO%YEND, & + call READFORC_AEROSOL(NoahmpIO%INFLNM_TEMPLATE, NoahmpIO%FORCING_TIMESTEP, & + NoahmpIO%OLDDATE, NoahmpIO%XSTART, NoahmpIO%XEND, NoahmpIO%YSTART, NoahmpIO%YEND, & NoahmpIO%reset_spinup_datea, NoahmpIO%startdate, & - NoahmpIO%forcing_name_BCPHI, NoahmpIO%forcing_name_BCPHO, NoahmpIO%forcing_name_OCPHI,& - NoahmpIO%forcing_name_OCPHO, NoahmpIO%forcing_name_DUST1, NoahmpIO%forcing_name_DUST2,& - NoahmpIO%forcing_name_DUST3, NoahmpIO%forcing_name_DUST4, NoahmpIO%forcing_name_DUST5, NoahmpIO%DepBChydrophiXY, & - NoahmpIO%DepBChydrophoXY, NoahmpIO%DepOChydrophiXY, NoahmpIO%DepOChydrophoXY, & - NoahmpIO%DepDust1XY, NoahmpIO%DepDust2XY, NoahmpIO%DepDust3XY, NoahmpIO%DepDust4XY, NoahmpIO%DepDust5XY ) + NoahmpIO%forcing_name_BCPHI, NoahmpIO%forcing_name_BCPHO, NoahmpIO%forcing_name_OCPHI, & + NoahmpIO%forcing_name_OCPHO, NoahmpIO%forcing_name_DUST1, NoahmpIO%forcing_name_DUST2, & + NoahmpIO%forcing_name_DUST3, NoahmpIO%forcing_name_DUST4, NoahmpIO%forcing_name_DUST5, & + NoahmpIO%DepBChydrophiXY(:,:,1), NoahmpIO%DepBChydrophoXY(:,:,1), & + NoahmpIO%DepOChydrophiXY(:,:,1), NoahmpIO%DepOChydrophoXY(:,:,1), & + NoahmpIO%DepDust1XY(:,:,1), NoahmpIO%DepDust2XY(:,:,1), NoahmpIO%DepDust3XY(:,:,1), & + NoahmpIO%DepDust4XY(:,:,1), NoahmpIO%DepDust5XY(:,:,1)) + + ! copy 2D static fields to mosaic dimension + do N = 1,NoahmpIO%NTilesMax + NoahmpIO%DepBChydrophiXY(:,:,N) = NoahmpIO%DepBChydrophiXY(:,:,1) + NoahmpIO%DepBChydrophoXY(:,:,N) = NoahmpIO%DepBChydrophoXY(:,:,1) + NoahmpIO%DepOChydrophiXY(:,:,N) = NoahmpIO%DepOChydrophiXY(:,:,1) + NoahmpIO%DepOChydrophoXY(:,:,N) = NoahmpIO%DepOChydrophoXY(:,:,1) + NoahmpIO%DepDust1XY(:,:,N) = NoahmpIO%DepDust1XY(:,:,1) + NoahmpIO%DepDust2XY(:,:,N) = NoahmpIO%DepDust2XY(:,:,1) + NoahmpIO%DepDust3XY(:,:,N) = NoahmpIO%DepDust3XY(:,:,1) + NoahmpIO%DepDust4XY(:,:,N) = NoahmpIO%DepDust4XY(:,:,1) + NoahmpIO%DepDust5XY(:,:,N) = NoahmpIO%DepDust5XY(:,:,1) + enddo endif 991 continue @@ -998,10 +921,12 @@ subroutine land_driver_exe(itime) endif IF (ITIME == 1 .AND. .NOT. NoahmpIO%RESTART_FLAG ) THEN - NoahmpIO%EAHXY = (NoahmpIO%P8W(:,1,:)*NoahmpIO%QV_CURR(:,1,:))/(0.622+NoahmpIO%QV_CURR(:,1,:)) ! Initial guess only. - NoahmpIO%TAHXY = NoahmpIO%T_PHY(:,1,:) ! Initial guess only. - NoahmpIO%CHXY = 0.1 - NoahmpIO%CMXY = 0.1 + do N=1,NoahmpIO%NTilesMax + NoahmpIO%EAHXY(:,:,N) = (NoahmpIO%P8W(:,1,:)*NoahmpIO%QV_CURR(:,1,:))/(0.622+NoahmpIO%QV_CURR(:,1,:)) ! Initial guess only. + NoahmpIO%TAHXY(:,:,N) = NoahmpIO%T_PHY(:,1,:) ! Initial guess only. + NoahmpIO%CHXY(:,:,N) = 0.1 + NoahmpIO%CMXY(:,:,N) = 0.1 + enddo ENDIF !------------------------------------------------------------------------ @@ -1105,23 +1030,9 @@ subroutine land_driver_exe(itime) call wrf_message('calling WTABLE') !gmm update wtable from lateral flow and shed water to rivers - call WTABLE_MMF_NOAHMP(NoahmpIO, & - NoahmpIO%NSOIL, NoahmpIO%XLAND, NoahmpIO%XICE, & - NoahmpIO%XICE_THRESHOLD, NoahmpIO%ISICE, & - NoahmpIO%ISLTYP, NoahmpIO%SMOISEQ, NoahmpIO%DZS, & - NoahmpIO%WTDDT, NoahmpIO%FDEPTHXY, NoahmpIO%AREAXY, & - NoahmpIO%TERRAIN, NoahmpIO%ISURBAN, NoahmpIO%IVGTYP, & - NoahmpIO%RIVERCONDXY, NoahmpIO%RIVERBEDXY, NoahmpIO%EQZWT,& - NoahmpIO%PEXPXY, NoahmpIO%SMOIS, NoahmpIO%SH2O, & - NoahmpIO%SMCWTDXY, NoahmpIO%ZWTXY, NoahmpIO%QLATXY, & - NoahmpIO%QRFXY, NoahmpIO%DEEPRECHXY, NoahmpIO%QSPRINGXY, & - NoahmpIO%QSLATXY, NoahmpIO%QRFSXY, NoahmpIO%QSPRINGSXY, & - NoahmpIO%RECHXY, & - NoahmpIO%IDS, NoahmpIO%IDE, NoahmpIO%JDS, NoahmpIO%JDE, & - NoahmpIO%KDS, NoahmpIO%KDE, NoahmpIO%IMS, NoahmpIO%IME, & - NoahmpIO%JMS,NoahmpIO%JME, NoahmpIO%KMS,NoahmpIO%KME, & - NoahmpIO%ITS,NoahmpIO%ITE, NoahmpIO%JTS,NoahmpIO%JTE, & - NoahmpIO%KTS,NoahmpIO%KTE) + + call WTABLE_MMF_NOAHMP(NoahmpIO) + endif ! MMF timestep endif ! MMF groundwater @@ -1136,242 +1047,39 @@ subroutine land_driver_exe(itime) if (mod(ITIME*NoahmpIO%noah_timestep, NoahmpIO%output_timestep) == 0 & .and. .not. NoahmpIO%skip_first_output ) then - call prepare_output_file (trim(NoahmpIO%outdir), version, & - NoahmpIO%igrid, NoahmpIO%output_timestep, NoahmpIO%llanduse, & - NoahmpIO%split_output_count, NoahmpIO%hgrid, & - NoahmpIO%ixfull, NoahmpIO%jxfull, NoahmpIO%ixpar, NoahmpIO%jxpar, & - NoahmpIO%xstartpar, NoahmpIO%ystartpar, & - NoahmpIO%iswater, NoahmpIO%mapproj, NoahmpIO%lat1, NoahmpIO%lon1, & - NoahmpIO%dx, NoahmpIO%dy, NoahmpIO%truelat1, NoahmpIO%truelat2, & - NoahmpIO%cen_lon, NoahmpIO%NSOIL, NoahmpIO%nsnow, NoahmpIO%NUMRAD,& - NoahmpIO%dzs, NoahmpIO%startdate, NoahmpIO%olddate, & - NoahmpIO%spinup_loop, & - NoahmpIO%spinup_loops, NoahmpIO%IVGTYP, NoahmpIO%ISLTYP) + call prepare_output_file (trim(NoahmpIO%outdir), version, & + NoahmpIO%igrid, NoahmpIO%output_timestep, NoahmpIO%llanduse, & + NoahmpIO%split_output_count, NoahmpIO%hgrid, & + NoahmpIO%ixfull, NoahmpIO%jxfull, NoahmpIO%ixpar, NoahmpIO%jxpar, & + NoahmpIO%xstartpar, NoahmpIO%ystartpar, & + NoahmpIO%iswater, NoahmpIO%mapproj, NoahmpIO%lat1, NoahmpIO%lon1, & + NoahmpIO%dx, NoahmpIO%dy, NoahmpIO%truelat1, NoahmpIO%truelat2, & + NoahmpIO%cen_lon, NoahmpIO%NSOIL, NoahmpIO%nsnow, NoahmpIO%NUMRAD,& + NoahmpIO%dzs, NoahmpIO%startdate, NoahmpIO%olddate, & + NoahmpIO%spinup_loop, & + NoahmpIO%spinup_loops, NoahmpIO%IVGTYP, NoahmpIO%ISLTYP, & + NoahmpIO%NTilesMax) DEFINE_MODE_LOOP : do imode = 1, 2 call set_output_define_mode(imode) - - ! For 3D arrays, we need to know whether the Z dimension is snow layers, or soil layers. - - ! Properties - Assigned or predicted - call add_to_output(NoahmpIO%IVGTYP , "IVGTYP" , "Dominant vegetation category" , "category" ) - call add_to_output(NoahmpIO%ISLTYP , "ISLTYP" , "Dominant soil category" , "category" ) - call add_to_output(NoahmpIO%FVEGXY , "FVEG" , "Green Vegetation Fraction" , "-" ) - call add_to_output(NoahmpIO%LAI , "LAI" , "Leaf area index" , "m2/m2" ) - call add_to_output(NoahmpIO%XSAIXY , "SAI" , "Stem area index" , "m2/m2" ) - ! Forcing - call add_to_output(NoahmpIO%SWDOWN , "SWFORC" , "Shortwave forcing" , "W/m2" ) - call add_to_output(NoahmpIO%COSZEN , "COSZ" , "Cosine of zenith angle" , "-" ) - call add_to_output(NoahmpIO%GLW , "LWFORC" , "Longwave forcing" , "W/m2" ) - call add_to_output(NoahmpIO%RAINBL , "RAINRATE", "Precipitation rate" , "mm/timestep" ) - ! Grid energy budget terms - call add_to_output(NoahmpIO%EMISS , "EMISS" , "Grid emissivity" , "-" ) - call add_to_output(NoahmpIO%FSAXY , "FSA" , "Total absorbed SW radiation" , "W/m2" ) - call add_to_output(NoahmpIO%FIRAXY , "FIRA" , "Total net LW radiation to atmosphere" , "W/m2" ) - call add_to_output(NoahmpIO%GRDFLX , "GRDFLX" , "Heat flux into the soil" , "W/m2" ) - call add_to_output(NoahmpIO%HFX , "HFX" , "Total sensible heat to atmosphere" , "W/m2" ) - call add_to_output(NoahmpIO%LH , "LH" , "Total latent heat to atmosphere" , "W/m2" ) - call add_to_output(NoahmpIO%ECANXY , "ECAN" , "Canopy water evaporation rate" , "mm/s" ) - call add_to_output(NoahmpIO%ETRANXY , "ETRAN" , "Transpiration rate" , "mm/s" ) - call add_to_output(NoahmpIO%EDIRXY , "EDIR" , "Direct from soil evaporation rate" , "mm/s" ) - call add_to_output(NoahmpIO%ALBEDO , "ALBEDO" , "Surface albedo" , "-" ) - ! Grid water budget terms - in addition to above - call add_to_output(NoahmpIO%UDRUNOFF , "UGDRNOFF", "Accumulated underground runoff" , "mm" ) - call add_to_output(NoahmpIO%SFCRUNOFF , "SFCRNOFF", "Accumulatetd surface runoff" , "mm" ) - call add_to_output(NoahmpIO%CANLIQXY , "CANLIQ" , "Canopy liquid water content" , "mm" ) - call add_to_output(NoahmpIO%CANICEXY , "CANICE" , "Canopy ice water content" , "mm" ) - call add_to_output(NoahmpIO%ZWTXY , "ZWT" , "Depth to water table" , "m" ) - call add_to_output(NoahmpIO%WAXY , "WA" , "Water in aquifer" , "mm" ) - call add_to_output(NoahmpIO%WTXY , "WT" , "Water in aquifer and saturated soil" , "mm" ) - call add_to_output(NoahmpIO%QTDRAIN , "QTDRAIN" , "Accumulated tile drainage" , "mm" ) - call add_to_output(NoahmpIO%PONDINGXY , "PONDING" , "total surface ponding per time step" , "mm/s" ) - ! Additional needed to close the canopy energy budget - call add_to_output(NoahmpIO%SAVXY , "SAV" , "Solar radiation absorbed by canopy" , "W/m2" ) - call add_to_output(NoahmpIO%TRXY , "TR" , "Transpiration heat" , "W/m2" ) - call add_to_output(NoahmpIO%EVCXY , "EVC" , "Canopy evap heat" , "W/m2" ) - call add_to_output(NoahmpIO%IRCXY , "IRC" , "Canopy net LW rad" , "W/m2" ) - call add_to_output(NoahmpIO%SHCXY , "SHC" , "Canopy sensible heat" , "W/m2" ) - ! Additional needed to close the under canopy ground energy budget - call add_to_output(NoahmpIO%IRGXY , "IRG" , "below-canopy ground net LW rad" , "W/m2" ) - call add_to_output(NoahmpIO%SHGXY , "SHG" , "below-canopy ground sensible heat" , "W/m2" ) - call add_to_output(NoahmpIO%EVGXY , "EVG" , "below-canopy ground evap heat" , "W/m2" ) - call add_to_output(NoahmpIO%GHVXY , "GHV" , "below-canopy ground heat to soil" , "W/m2" ) - ! Needed to close the bare ground energy budget - call add_to_output(NoahmpIO%SAGXY , "SAG" , "Solar radiation absorbed by ground" , "W/m2" ) - call add_to_output(NoahmpIO%IRBXY , "IRB" , "Net LW rad to atm bare ground" , "W/m2" ) - call add_to_output(NoahmpIO%SHBXY , "SHB" , "Sensible heat to atm bare ground" , "W/m2" ) - call add_to_output(NoahmpIO%EVBXY , "EVB" , "Evaporation heat to atm bare ground" , "W/m2" ) - call add_to_output(NoahmpIO%GHBXY , "GHB" , "Ground heat flux to soil bare ground" , "W/m2" ) - ! Above-soil temperatures - call add_to_output(NoahmpIO%TRADXY , "TRAD" , "Surface radiative temperature" , "K" ) - call add_to_output(NoahmpIO%TGXY , "TG" , "Ground temperature" , "K" ) - call add_to_output(NoahmpIO%TVXY , "TV" , "Vegetation temperature" , "K" ) - call add_to_output(NoahmpIO%TAHXY , "TAH" , "Canopy air temperature" , "K" ) - call add_to_output(NoahmpIO%TGVXY , "TGV" , "Ground surface Temp vegetated" , "K" ) - call add_to_output(NoahmpIO%TGBXY , "TGB" , "Ground surface Temp bare" , "K" ) - call add_to_output(NoahmpIO%T2MVXY , "T2MV" , "2m Air Temp vegetated" , "K" ) - call add_to_output(NoahmpIO%T2MBXY , "T2MB" , "2m Air Temp bare" , "K" ) - ! Above-soil moisture - call add_to_output(NoahmpIO%Q2MVXY , "Q2MV" , "2m mixing ratio vegetated" , "kg/kg" ) - call add_to_output(NoahmpIO%Q2MBXY , "Q2MB" , "2m mixing ratio bare" , "kg/kg" ) - call add_to_output(NoahmpIO%EAHXY , "EAH" , "Canopy air vapor pressure" , "Pa" ) - call add_to_output(NoahmpIO%FWETXY , "FWET" , "Wetted fraction of canopy" , "fraction" ) - ! Snow and soil - 3D terms - call add_to_output(NoahmpIO%ZSNSOXY(:,-NoahmpIO%nsnow+1:0,:),"ZSNSO_SN","Snow layer depth from snow surface","m","SNOW") - call add_to_output(NoahmpIO%SNICEXY , "SNICE" , "Snow layer ice" , "mm" , "SNOW") - call add_to_output(NoahmpIO%SNLIQXY , "SNLIQ" , "Snow layer liquid water" , "mm" , "SNOW") - call add_to_output(NoahmpIO%TSLB , "SOIL_T" , "soil temperature" , "K" , "SOIL") - call add_to_output(NoahmpIO%SMOIS , "SOIL_M" , "volumetric soil moisture" , "m3/m3" , "SOIL") - call add_to_output(NoahmpIO%SH2O , "SOIL_W" , "liquid volumetric soil moisture" , "m3/m3" , "SOIL") - call add_to_output(NoahmpIO%TSNOXY , "SNOW_T" , "snow temperature" , "K" , "SNOW") - call add_to_output(NoahmpIO%ALBSNOWDIRXY, "ALBSNOWDIR" , "Snow albedo (direct)" , "-" , "RADN") - call add_to_output(NoahmpIO%ALBSNOWDIFXY, "ALBSNOWDIF" , "Snow albedo (diffuse)" , "-" , "RADN") - call add_to_output(NoahmpIO%ALBSFCDIRXY , "ALBSFCDIR" , "Surface albedo (direct)" , "-" , "RADN") - call add_to_output(NoahmpIO%ALBSFCDIFXY , "ALBSFCDIF" , "Surface albedo (diffuse)" , "-" , "RADN") - call add_to_output(NoahmpIO%ALBSOILDIRXY, "ALBSOILDIR" , "Soil albedo (direct)" , "-" , "RADN") - call add_to_output(NoahmpIO%ALBSOILDIFXY, "ALBSOILDIF" , "Soil albedo (diffuse)" , "-" , "RADN") - ! Snow - 2D terms - call add_to_output(NoahmpIO%SNOWH , "SNOWH" , "Snow depth" , "m" ) - call add_to_output(NoahmpIO%SNOW , "SNEQV" , "Snow water equivalent" , "mm" ) - call add_to_output(NoahmpIO%QSNOWXY , "QSNOW" , "Snowfall rate on the ground" , "mm/s" ) - call add_to_output(NoahmpIO%QRAINXY , "QRAIN" , "Rainfall rate on the ground" , "mm/s" ) - call add_to_output(NoahmpIO%ISNOWXY , "ISNOW" , "Number of snow layers" , "-" ) - call add_to_output(NoahmpIO%SNOWC , "FSNO" , "Snow-cover fraction on the ground" , "-" ) - call add_to_output(NoahmpIO%ACSNOW , "ACSNOW" , "accumulated snow fall" , "mm" ) - call add_to_output(NoahmpIO%ACSNOM , "ACSNOM" , "accumulated snow melt water" , "mm" ) - call add_to_output(NoahmpIO%QSNBOTXY , "QSNBOT" , "water (melt+rain through) out of snow bottom" , "mm/s" ) - call add_to_output(NoahmpIO%QMELTXY , "QMELT" , "snow melt due to phase change" , "mm/s" ) - ! SNICAR snow albedo scheme - if (NoahmpIO%IOPT_ALB == 3)then - call add_to_output(NoahmpIO%SNRDSXY , "SNRDS" , "Snow layer effective grain radius" , "m-6" , "SNOW") - call add_to_output(NoahmpIO%SNFRXY , "SNFR" , "Snow layer rate of freezing" , "mm/s" , "SNOW") - call add_to_output(NoahmpIO%BCPHIXY , "BCPHI_Mass","hydrophilic BC mass in snow" , "kg/m2" , "SNOW") - call add_to_output(NoahmpIO%BCPHOXY , "BCPHO_Mass","hydrophobic BC mass in snow" , "kg/m2" , "SNOW") - call add_to_output(NoahmpIO%OCPHIXY , "OCPHI_Mass","hydrophilic OC mass in snow" , "kg/m2" , "SNOW") - call add_to_output(NoahmpIO%OCPHOXY , "OCPHO_Mass","hydrophobic OC mass in snow" , "kg/m2" , "SNOW") - call add_to_output(NoahmpIO%DUST1XY , "DUST1_Mass","dust size bin 1 mass in snow" , "kg/m2" , "SNOW") - call add_to_output(NoahmpIO%DUST2XY , "DUST2_Mass","dust size bin 2 mass in snow" , "kg/m2" , "SNOW") - call add_to_output(NoahmpIO%DUST3XY , "DUST3_Mass","dust size bin 3 mass in snow" , "kg/m2" , "SNOW") - call add_to_output(NoahmpIO%DUST4XY , "DUST4_Mass","dust size bin 4 mass in snow" , "kg/m2" , "SNOW") - call add_to_output(NoahmpIO%DUST5XY , "DUST5_Mass","dust size bin 5 mass in snow" , "kg/m2" , "SNOW") - call add_to_output(NoahmpIO%MassConcBCPHIXY, "BCPHI_MassConc","hydrophilic BC mass concentration in snow", "kg/kg", "SNOW") - call add_to_output(NoahmpIO%MassConcBCPHOXY, "BCPHO_MassConc","hydrophobic BC mass concentration in snow", "kg/kg", "SNOW") - call add_to_output(NoahmpIO%MassConcOCPHIXY, "OCPHI_MassConc","hydrophilic OC mass concentration in snow", "kg/kg", "SNOW") - call add_to_output(NoahmpIO%MassConcOCPHOXY, "OCPHO_MassConc","hydrophobic OC mass concentration in snow", "kg/kg", "SNOW") - call add_to_output(NoahmpIO%MassConcDUST1XY, "DUST1_MassConc","dust size bin 1 mass concentration in snow", "kg/kg", "SNOW") - call add_to_output(NoahmpIO%MassConcDUST2XY, "DUST2_MassConc","dust size bin 2 mass concentration in snow", "kg/kg", "SNOW") - call add_to_output(NoahmpIO%MassConcDUST3XY, "DUST3_MassConc","dust size bin 3 mass concentration in snow", "kg/kg", "SNOW") - call add_to_output(NoahmpIO%MassConcDUST4XY, "DUST4_MassConc","dust size bin 4 mass concentration in snow", "kg/kg", "SNOW") - call add_to_output(NoahmpIO%MassConcDUST5XY, "DUST5_MassConc","dust size bin 5 mass concentration in snow", "kg/kg", "SNOW") - endif - ! Exchange coefficients - call add_to_output(NoahmpIO%CMXY , "CM" , "Momentum drag coefficient" , "m/s" ) - call add_to_output(NoahmpIO%CHXY , "CH" , "Sensible heat exchange coefficient" , "m/s" ) - call add_to_output(NoahmpIO%CHVXY , "CHV" , "Exchange coefficient vegetated" , "m/s" ) - call add_to_output(NoahmpIO%CHBXY , "CHB" , "Exchange coefficient bare" , "m/s" ) - call add_to_output(NoahmpIO%CHLEAFXY , "CHLEAF" , "Exchange coefficient leaf" , "m/s" ) - call add_to_output(NoahmpIO%CHUCXY , "CHUC" , "Exchange coefficient bare" , "m/s" ) - call add_to_output(NoahmpIO%CHV2XY , "CHV2" , "Exchange coefficient 2-m vegetated" , "m/s" ) - call add_to_output(NoahmpIO%CHB2XY , "CHB2" , "Exchange coefficient 2-m bare" , "m/s" ) - ! Carbon allocation model - call add_to_output(NoahmpIO%LFMASSXY , "LFMASS" , "Leaf mass" , "g/m2" ) - call add_to_output(NoahmpIO%RTMASSXY , "RTMASS" , "Mass of fine roots" , "g/m2" ) - call add_to_output(NoahmpIO%STMASSXY , "STMASS" , "Stem mass" , "g/m2" ) - call add_to_output(NoahmpIO%WOODXY , "WOOD" , "Mass of wood and woody roots" , "g/m2" ) - call add_to_output(NoahmpIO%GRAINXY , "GRAIN" , "Mass of grain" , "g/m2" ) - call add_to_output(NoahmpIO%GDDXY , "GDD" , "Growing degree days " , "-" ) - call add_to_output(NoahmpIO%STBLCPXY , "STBLCP" , "Stable carbon in deep soil" , "gC/m2" ) - call add_to_output(NoahmpIO%FASTCPXY , "FASTCP" , "Short-lived carbon in shallow soil" , "gC/m2" ) - call add_to_output(NoahmpIO%NEEXY , "NEE" , "Net ecosystem exchange" , "gCO2/m2/s" ) - call add_to_output(NoahmpIO%GPPXY , "GPP" , "Net instantaneous assimilation" , "gC/m2/s" ) - call add_to_output(NoahmpIO%NPPXY , "NPP" , "Net primary productivity" , "gC/m2/s" ) - call add_to_output(NoahmpIO%PSNXY , "PSN" , "Total photosynthesis" , "umol CO2/m2/s" ) - call add_to_output(NoahmpIO%APARXY , "APAR" , "Photosynthesis active energy by canopy", "W/m2" ) - ! additional NoahMP output - if (NoahmpIO%noahmp_output > 0) then - ! additional water budget terms - call add_to_output(NoahmpIO%QINTSXY , "QINTS" , "canopy interception (loading) rate for snowfall", "mm/s" ) - call add_to_output(NoahmpIO%QINTRXY , "QINTR" , "canopy interception rate for rain" , "mm/s" ) - call add_to_output(NoahmpIO%QDRIPSXY , "QDRIPS" , "drip (unloading) rate for intercepted snow" , "mm/s" ) - call add_to_output(NoahmpIO%QDRIPRXY , "QDRIPR" , "drip rate for canopy intercepted rain" , "mm/s" ) - call add_to_output(NoahmpIO%QTHROSXY , "QTHROS" , "throughfall of snowfall" , "mm/s" ) - call add_to_output(NoahmpIO%QTHRORXY , "QTHROR" , "throughfall for rain" , "mm/s" ) - call add_to_output(NoahmpIO%QSNSUBXY , "QSNSUB" , "snow surface sublimation rate" , "mm/s" ) - call add_to_output(NoahmpIO%QSNFROXY , "QSNFRO" , "snow surface frost rate" , "mm/s" ) - call add_to_output(NoahmpIO%QSUBCXY , "QSUBC" , "canopy snow sublimation rate" , "mm/s" ) - call add_to_output(NoahmpIO%QFROCXY , "QFROC" , "canopy snow frost rate" , "mm/s" ) - call add_to_output(NoahmpIO%QEVACXY , "QEVAC" , "canopy snow evaporation rate" , "mm/s" ) - call add_to_output(NoahmpIO%QDEWCXY , "QDEWC" , "canopy snow dew rate" , "mm/s" ) - call add_to_output(NoahmpIO%QFRZCXY , "QFRZC" , "refreezing rate of canopy liquid water" , "mm/s" ) - call add_to_output(NoahmpIO%QMELTCXY , "QMELTC" , "melting rate of canopy snow" , "mm/s" ) - call add_to_output(NoahmpIO%FPICEXY , "FPICE" , "snow fraction in precipitation" , "-" ) - call add_to_output(NoahmpIO%ACC_QINSURXY,"ACC_QINSUR", "accumuated water flux to soil within soil timestep" , "m/s*dt_soil/dt_main") - call add_to_output(NoahmpIO%ACC_QSEVAXY ,"ACC_QSEVA" , "accumulated soil surface evap rate within soil timestep", "m/s*dt_soil/dt_main") - call add_to_output(NoahmpIO%ACC_ETRANIXY,"ACC_ETRANI", "accumualted transpiration rate within soil timestep" , "m/s*dt_soil/dt_main","SOIL") - call add_to_output(NoahmpIO%ACC_DWATERXY,"ACC_DWATER", "accumulated water storage change within soil timestep" , "mm") - call add_to_output(NoahmpIO%ACC_PRCPXY ,"ACC_PRCP" , "accumulated precipitation within soil timestep" , "mm") - call add_to_output(NoahmpIO%ACC_ECANXY ,"ACC_ECAN" , "accumulated net canopy evaporation within soil timestep", "mm") - call add_to_output(NoahmpIO%ACC_ETRANXY ,"ACC_ETRAN" , "accumulated transpiration within soil timestep" , "mm") - call add_to_output(NoahmpIO%ACC_EDIRXY ,"ACC_EDIR" , "accumulated net ground evaporation within soil timestep", "mm") - call add_to_output(NoahmpIO%ACC_GLAFLWXY,"ACC_GLAFLW", "accumuated glacier excessive flow per soil timestep" , "mm") - ! additional energy terms - call add_to_output(NoahmpIO%PAHXY , "PAH" , "Precipitation advected heat flux" , "W/m2" ) - call add_to_output(NoahmpIO%PAHGXY , "PAHG" , "Precipitation advected heat flux to below-canopy ground" , "W/m2" ) - call add_to_output(NoahmpIO%PAHBXY , "PAHB" , "Precipitation advected heat flux to bare ground" , "W/m2" ) - call add_to_output(NoahmpIO%PAHVXY , "PAHV" , "Precipitation advected heat flux to canopy" , "W/m2" ) - call add_to_output(NoahmpIO%ACC_SSOILXY, "ACC_SSOIL","accumulated heat flux into snow/soil within soil timestep", "W/m2" ) - call add_to_output(NoahmpIO%EFLXBXY , "EFLXB" , "accumulated heat flux through soil bottom" , "J/m2" ) - call add_to_output(NoahmpIO%SOILENERGY , "SOILENERGY","energy content in soil relative to 273.16" , "KJ/m2" ) - call add_to_output(NoahmpIO%SNOWENERGY , "SNOWENERGY","energy content in snow relative to 273.16" , "KJ/m2" ) - call add_to_output(NoahmpIO%CANHSXY , "CANHS" , "canopy heat storage change" , "W/m2" ) - ! additional forcing terms - call add_to_output(NoahmpIO%RAINLSM , "RAINLSM" , "lowest model liquid precipitation into LSM" , "mm/s" ) - call add_to_output(NoahmpIO%SNOWLSM , "SNOWLSM" , "lowest model snowfall into LSM" , "mm/s" ) - call add_to_output(NoahmpIO%FORCTLSM , "FORCTLSM", "lowest model temperature into LSM" , "K" ) - call add_to_output(NoahmpIO%FORCQLSM , "FORCQLSM", "lowest model specific humidty into LSM" , "kg/kg" ) - call add_to_output(NoahmpIO%FORCPLSM , "FORCPLSM", "lowest model pressure into LSM" , "Pa" ) - call add_to_output(NoahmpIO%FORCZLSM , "FORCZLSM", "lowest model forcing height into LSM" , "m" ) - call add_to_output(NoahmpIO%FORCWLSM , "FORCWLSM", "lowest model wind speed into LSM" , "m/s" ) - call add_to_output(NoahmpIO%RadSwVisFrac , "SWVISFRAC", "Fraction of visible band downward solar radiation", "-" ) - call add_to_output(NoahmpIO%RadSwDirFrac , "SWDIRFRAC", "Fraction of downward solar direct radiation", "-" ) - endif - - ! Irrigation - if ( NoahmpIO%IOPT_IRR > 0 ) then - call add_to_output(NoahmpIO%IRNUMSI , "IRNUMSI" , "Sprinkler irrigation count" , "-" ) - call add_to_output(NoahmpIO%IRNUMMI , "IRNUMMI" , "Micro irrigation count" , "-" ) - call add_to_output(NoahmpIO%IRNUMFI , "IRNUMFI" , "Flood irrigation count" , "-" ) - call add_to_output(NoahmpIO%IRELOSS , "IRELOSS" , "Accumulated sprinkler Evaporation" , "mm" ) - call add_to_output(NoahmpIO%IRSIVOL , "IRSIVOL" , "Sprinkler irrigation amount" , "mm" ) - call add_to_output(NoahmpIO%IRMIVOL , "IRMIVOL" , "Micro irrigation amount" , "mm" ) - call add_to_output(NoahmpIO%IRFIVOL , "IRFIVOL" , "Flood irrigation amount" , "mm" ) - call add_to_output(NoahmpIO%IRRSPLH , "IRRSPLH" , "Accumulated latent heating due to sprinkler" , "J/m2" ) - endif - ! MMF groundwater model - if ( NoahmpIO%IOPT_RUNSUB == 5 ) then - call add_to_output(NoahmpIO%SMCWTDXY , "SMCWTD" , "soil water content between bottom of the soil and water table", "m3/m3" ) - call add_to_output(NoahmpIO%RECHXY , "RECH" , "recharge to or from the water table when shallow" , "m" ) - call add_to_output(NoahmpIO%DEEPRECHXY , "DEEPRECH" , "recharge to or from the water table when deep" , "m" ) - call add_to_output(NoahmpIO%QRFSXY , "QRFS" , "accumulated groundwater baselow" , "mm" ) - call add_to_output(NoahmpIO%QRFXY , "QRF" , "groundwater baseflow" , "m" ) - call add_to_output(NoahmpIO%QSPRINGSXY , "QSPRINGS" , "accumulated seeping water" , "mm" ) - call add_to_output(NoahmpIO%QSPRINGXY , "QSPRING" , "instantaneous seeping water" , "m" ) - call add_to_output(NoahmpIO%QSLATXY , "QSLAT" , "accumulated lateral flow" , "mm" ) - call add_to_output(NoahmpIO%QLATXY , "QLAT" , "instantaneous lateral flow" , "m" ) - endif - ! Wetland model - if ( NoahmpIO%IOPT_WETLAND > 0 ) then - call add_to_output(NoahmpIO%FSATXY , "FSAT" , "saturated fraction of the grid" , "-" ) - call add_to_output(NoahmpIO%WSURFXY , "WSURF" , "Wetland Water Storage" , "mm") - endif - + + if(NoahmpIO%IOPT_MOSAIC >= 1) then + if(NoahmpIO%IOPT_MOSAIC_OUTPUT == 0) then + call WriteNoahmpMosaicGridAverageOutput(NoahmpIO) + else if(NoahmpIO%IOPT_MOSAIC_OUTPUT == 1) then + call WriteNoahmpMosaicSubgridOutput(NoahmpIO) + endif + else if(NoahmpIO%IOPT_MOSAIC == 0) then + call WriteNoahmpMosaicGridAverageOutput(NoahmpIO) + endif + ! For now, no urban output variables included enddo DEFINE_MODE_LOOP - - call finalize_output_file(NoahmpIO%split_output_count,itime) - + + call finalize_output_file(NoahmpIO%split_output_count,itime) + endif if(NoahmpIO%skip_first_output) NoahmpIO%skip_first_output = .false. @@ -1382,8 +1090,8 @@ subroutine land_driver_exe(itime) write(*,'(" ***DATE=", A19)', advance="NO") NoahmpIO%olddate else write(*,'(" ***DATE=", A19, 6F10.5)', advance="NO") & - NoahmpIO%olddate, NoahmpIO%TSLB(NoahmpIO%xstart,1,NoahmpIO%ystart), & - NoahmpIO%LAI(NoahmpIO%xstart,NoahmpIO%ystart) + NoahmpIO%olddate, NoahmpIO%TSLB(NoahmpIO%xstart,1,NoahmpIO%ystart,1), & + NoahmpIO%LAI(NoahmpIO%xstart,NoahmpIO%ystart,1) endif !------------------------------------------------------------------------ @@ -1447,212 +1155,10 @@ subroutine lsm_restart() NoahmpIO%NSOIL, NoahmpIO%nsnow, NoahmpIO%NUMRAD, NoahmpIO%max_urban_dim, & NoahmpIO%dx, NoahmpIO%dy, NoahmpIO%truelat1, NoahmpIO%truelat2, & NoahmpIO%mapproj, NoahmpIO%lat1, NoahmpIO%lon1, NoahmpIO%cen_lon, & - NoahmpIO%iswater, NoahmpIO%ivgtyp) + NoahmpIO%iswater, NoahmpIO%ivgtyp, NoahmpIO%NTilesMax) - call add_to_restart(NoahmpIO%TSLB , "SOIL_T", layers="SOIL") - call add_to_restart(NoahmpIO%TSNOXY , "SNOW_T", layers="SNOW") - call add_to_restart(NoahmpIO%SMOIS , "SMC" , layers="SOIL") - call add_to_restart(NoahmpIO%SH2O , "SH2O" , layers="SOIL") - call add_to_restart(NoahmpIO%ZSNSOXY , "ZSNSO" , layers="SOSN") - call add_to_restart(NoahmpIO%SNICEXY , "SNICE" , layers="SNOW") - call add_to_restart(NoahmpIO%SNLIQXY , "SNLIQ" , layers="SNOW") - call add_to_restart(NoahmpIO%FWETXY , "FWET" ) - call add_to_restart(NoahmpIO%SNEQVOXY , "SNEQVO") - call add_to_restart(NoahmpIO%EAHXY , "EAH" ) - call add_to_restart(NoahmpIO%TAHXY , "TAH" ) - call add_to_restart(NoahmpIO%ALBOLDXY , "ALBOLD") - call add_to_restart(NoahmpIO%CMXY , "CM" ) - call add_to_restart(NoahmpIO%CHXY , "CH" ) - call add_to_restart(NoahmpIO%ISNOWXY , "ISNOW" ) - call add_to_restart(NoahmpIO%CANLIQXY , "CANLIQ") - call add_to_restart(NoahmpIO%CANICEXY , "CANICE") - call add_to_restart(NoahmpIO%SNOW , "SNEQV" ) - call add_to_restart(NoahmpIO%SNOWH , "SNOWH" ) - call add_to_restart(NoahmpIO%TVXY , "TV" ) - call add_to_restart(NoahmpIO%TGXY , "TG" ) - call add_to_restart(NoahmpIO%ZWTXY , "ZWT" ) - call add_to_restart(NoahmpIO%WAXY , "WA" ) - call add_to_restart(NoahmpIO%WTXY , "WT" ) - call add_to_restart(NoahmpIO%WSLAKEXY , "WSLAKE") - call add_to_restart(NoahmpIO%LFMASSXY , "LFMASS") - call add_to_restart(NoahmpIO%RTMASSXY , "RTMASS") - call add_to_restart(NoahmpIO%STMASSXY , "STMASS") - call add_to_restart(NoahmpIO%CROPCAT , "CROPCAT") - call add_to_restart(NoahmpIO%WOODXY , "WOOD" ) - call add_to_restart(NoahmpIO%GRAINXY , "GRAIN" ) - call add_to_restart(NoahmpIO%GDDXY , "GDD" ) - call add_to_restart(NoahmpIO%STBLCPXY , "STBLCP") - call add_to_restart(NoahmpIO%FASTCPXY , "FASTCP") - call add_to_restart(NoahmpIO%LAI , "LAI" ) - call add_to_restart(NoahmpIO%XSAIXY , "SAI" ) - call add_to_restart(NoahmpIO%VEGFRA , "VEGFRA") - call add_to_restart(NoahmpIO%GVFMIN , "GVFMIN") - call add_to_restart(NoahmpIO%GVFMAX , "GVFMAX") - call add_to_restart(NoahmpIO%ACSNOM , "ACMELT") - call add_to_restart(NoahmpIO%ACSNOW , "ACSNOW") - call add_to_restart(NoahmpIO%TAUSSXY , "TAUSS" ) - call add_to_restart(NoahmpIO%QSFC , "QSFC" ) - call add_to_restart(NoahmpIO%SFCRUNOFF , "SFCRUNOFF") - call add_to_restart(NoahmpIO%UDRUNOFF , "UDRUNOFF" ) - call add_to_restart(NoahmpIO%QTDRAIN , "QTDRAIN" ) - call add_to_restart(NoahmpIO%ACC_SSOILXY ,"ACC_SSOIL" ) - call add_to_restart(NoahmpIO%ACC_QINSURXY,"ACC_QINSUR") - call add_to_restart(NoahmpIO%ACC_QSEVAXY ,"ACC_QSEVA" ) - call add_to_restart(NoahmpIO%ACC_ETRANIXY,"ACC_ETRANI", layers="SOIL") - call add_to_restart(NoahmpIO%ACC_DWATERXY,"ACC_DWATER") - call add_to_restart(NoahmpIO%ACC_PRCPXY ,"ACC_PRCP" ) - call add_to_restart(NoahmpIO%ACC_ECANXY ,"ACC_ECAN" ) - call add_to_restart(NoahmpIO%ACC_ETRANXY ,"ACC_ETRAN" ) - call add_to_restart(NoahmpIO%ACC_EDIRXY ,"ACC_EDIR" ) - call add_to_restart(NoahmpIO%ACC_GLAFLWXY,"ACC_GLAFLW") - call add_to_restart(NoahmpIO%ALBSOILDIRXY, "ALBSOILDIR", layers="RADN") - call add_to_restart(NoahmpIO%ALBSOILDIFXY, "ALBSOILDIF", layers="RADN") - - ! SNICAR snow albedo scheme - if (NoahmpIO%IOPT_ALB == 3)then - call add_to_restart(NoahmpIO%SNFRXY , "SNFR" , layers="SNOW") - call add_to_restart(NoahmpIO%SNRDSXY , "SNRDS" , layers="SNOW") - call add_to_restart(NoahmpIO%BCPHIXY , "BCPHI" , layers="SNOW") - call add_to_restart(NoahmpIO%BCPHOXY , "BCPHO" , layers="SNOW") - call add_to_restart(NoahmpIO%OCPHIXY , "OCPHI" , layers="SNOW") - call add_to_restart(NoahmpIO%OCPHOXY , "OCPHO" , layers="SNOW") - call add_to_restart(NoahmpIO%DUST1XY , "DUST1" , layers="SNOW") - call add_to_restart(NoahmpIO%DUST2XY , "DUST2" , layers="SNOW") - call add_to_restart(NoahmpIO%DUST3XY , "DUST3" , layers="SNOW") - call add_to_restart(NoahmpIO%DUST4XY , "DUST4" , layers="SNOW") - call add_to_restart(NoahmpIO%DUST5XY , "DUST5" , layers="SNOW") - endif - - ! irrigation scheme - if ( NoahmpIO%IOPT_IRR > 0 ) then - call add_to_restart(NoahmpIO%IRNUMSI , "IRNUMSI") - call add_to_restart(NoahmpIO%IRNUMMI , "IRNUMMI") - call add_to_restart(NoahmpIO%IRNUMFI , "IRNUMFI") - call add_to_restart(NoahmpIO%IRWATSI , "IRWATSI") - call add_to_restart(NoahmpIO%IRWATMI , "IRWATMI") - call add_to_restart(NoahmpIO%IRWATFI , "IRWATFI") - call add_to_restart(NoahmpIO%IRSIVOL , "IRSIVOL") - call add_to_restart(NoahmpIO%IRMIVOL , "IRMIVOL") - call add_to_restart(NoahmpIO%IRFIVOL , "IRFIVOL") - call add_to_restart(NoahmpIO%IRELOSS , "IRELOSS") - call add_to_restart(NoahmpIO%IRRSPLH , "IRRSPLH") - endif - - ! below for MMF groundwater scheme - if ( NoahmpIO%IOPT_RUNSUB == 5 ) then - call add_to_restart(NoahmpIO%SMOISEQ , "SMOISEQ" , layers="SOIL" ) - call add_to_restart(NoahmpIO%AREAXY , "AREAXY" ) - call add_to_restart(NoahmpIO%SMCWTDXY , "SMCWTDXY" ) - call add_to_restart(NoahmpIO%DEEPRECHXY , "DEEPRECHXY" ) - call add_to_restart(NoahmpIO%QSLATXY , "QSLATXY" ) - call add_to_restart(NoahmpIO%QRFSXY , "QRFSXY" ) - call add_to_restart(NoahmpIO%QSPRINGSXY , "QSPRINGSXY" ) - call add_to_restart(NoahmpIO%RECHXY , "RECHXY" ) - call add_to_restart(NoahmpIO%QRFXY , "QRFXY" ) - call add_to_restart(NoahmpIO%QSPRINGXY , "QSPRINGXY" ) - call add_to_restart(NoahmpIO%FDEPTHXY , "FDEPTHXY" ) - call add_to_restart(NoahmpIO%RIVERCONDXY , "RIVERCONDXY") - call add_to_restart(NoahmpIO%RIVERBEDXY , "RIVERBEDXY" ) - call add_to_restart(NoahmpIO%EQZWT , "EQZWT" ) - call add_to_restart(NoahmpIO%PEXPXY , "PEXPXY" ) - endif - - ! for wetland scheme - if ( NoahmpIO%IOPT_WETLAND > 0 ) then - call add_to_restart(NoahmpIO%FSATXY , "FSATXY" ) - call add_to_restart(NoahmpIO%WSURFXY , "WSURFXY" ) - endif - - ! below for urban model - if ( NoahmpIO%SF_URBAN_PHYSICS > 0 ) then - call add_to_restart( NoahmpIO%SH_URB2D , "SH_URB2D" ) - call add_to_restart( NoahmpIO%LH_URB2D , "LH_URB2D" ) - call add_to_restart( NoahmpIO%G_URB2D , "G_URB2D" ) - call add_to_restart( NoahmpIO%RN_URB2D , "RN_URB2D" ) - call add_to_restart( NoahmpIO%TS_URB2D , "TS_URB2D" ) - call add_to_restart( NoahmpIO%FRC_URB2D , "FRC_URB2D" ) - call add_to_restart( NoahmpIO%UTYPE_URB2D , "UTYPE_URB2D" ) - call add_to_restart( NoahmpIO%LP_URB2D , "LP_URB2D" ) - call add_to_restart( NoahmpIO%LB_URB2D , "LB_URB2D" ) - call add_to_restart( NoahmpIO%HGT_URB2D , "HGT_URB2D" ) - call add_to_restart( NoahmpIO%MH_URB2D , "MH_URB2D" ) - call add_to_restart( NoahmpIO%STDH_URB2D , "STDH_URB2D" ) - call add_to_restart( NoahmpIO%HI_URB2D , "HI_URB2D", layers="URBN") - call add_to_restart( NoahmpIO%LF_URB2D , "LF_URB2D", layers="URBN") - - if ( NoahmpIO%SF_URBAN_PHYSICS == 1 ) then ! single layer urban model - call add_to_restart( NoahmpIO%CMR_SFCDIF , "CMR_SFCDIF" ) - call add_to_restart( NoahmpIO%CHR_SFCDIF , "CHR_SFCDIF" ) - call add_to_restart( NoahmpIO%CMC_SFCDIF , "CMC_SFCDIF" ) - call add_to_restart( NoahmpIO%CHC_SFCDIF , "CHC_SFCDIF" ) - call add_to_restart( NoahmpIO%CMGR_SFCDIF , "CMGR_SFCDIF" ) - call add_to_restart( NoahmpIO%CHGR_SFCDIF , "CHGR_SFCDIF" ) - call add_to_restart( NoahmpIO%TR_URB2D , "TR_URB2D" ) - call add_to_restart( NoahmpIO%TB_URB2D , "TB_URB2D" ) - call add_to_restart( NoahmpIO%TG_URB2D , "TG_URB2D" ) - call add_to_restart( NoahmpIO%TC_URB2D , "TC_URB2D" ) - call add_to_restart( NoahmpIO%QC_URB2D , "QC_URB2D" ) - call add_to_restart( NoahmpIO%UC_URB2D , "UC_URB2D" ) - call add_to_restart( NoahmpIO%XXXR_URB2D , "XXXR_URB2D" ) - call add_to_restart( NoahmpIO%XXXB_URB2D , "XXXB_URB2D" ) - call add_to_restart( NoahmpIO%XXXG_URB2D , "XXXG_URB2D" ) - call add_to_restart( NoahmpIO%XXXC_URB2D , "XXXC_URB2D" ) - call add_to_restart( NoahmpIO%TRL_URB3D , "TRL_URB3D", layers="SOIL" ) - call add_to_restart( NoahmpIO%TBL_URB3D , "TBL_URB3D", layers="SOIL" ) - call add_to_restart( NoahmpIO%TGL_URB3D , "TGL_URB3D", layers="SOIL" ) - call add_to_restart( NoahmpIO%CMCR_URB2D , "CMCR_URB2D" ) - call add_to_restart( NoahmpIO%TGR_URB2D , "TGR_URB2D" ) - call add_to_restart( NoahmpIO%TGRL_URB3D , "TGRL_URB3D", layers="SOIL" ) - call add_to_restart( NoahmpIO%SMR_URB3D , "SMR_URB3D", layers="SOIL" ) - call add_to_restart( NoahmpIO%DRELR_URB2D , "DRELR_URB2D" ) - call add_to_restart( NoahmpIO%DRELB_URB2D , "DRELB_URB2D" ) - call add_to_restart( NoahmpIO%DRELG_URB2D , "DRELG_URB2D" ) - call add_to_restart(NoahmpIO%FLXHUMR_URB2D , "FLXHUMR_URB2D" ) - call add_to_restart(NoahmpIO%FLXHUMB_URB2D , "FLXHUMB_URB2D" ) - call add_to_restart(NoahmpIO%FLXHUMG_URB2D , "FLXHUMG_URB2D" ) - endif - - if ( (NoahmpIO%SF_URBAN_PHYSICS == 2) .or. (NoahmpIO%SF_URBAN_PHYSICS == 3) ) then ! BEP or BEM urban models - call add_to_restart( NoahmpIO%TRB_URB4D , "TRB_URB4D", layers="URBN" ) - call add_to_restart( NoahmpIO%TW1_URB4D , "TW1_URB4D", layers="URBN" ) - call add_to_restart( NoahmpIO%TW2_URB4D , "TW2_URB4D", layers="URBN" ) - call add_to_restart( NoahmpIO%TGB_URB4D , "TGB_URB4D", layers="URBN" ) - call add_to_restart( NoahmpIO%SFW1_URB3D , "SFW1_URB3D", layers="URBN" ) - call add_to_restart( NoahmpIO%SFW2_URB3D , "SFW2_URB3D", layers="URBN" ) - call add_to_restart( NoahmpIO%SFR_URB3D , "SFR_URB3D", layers="URBN" ) - call add_to_restart( NoahmpIO%SFG_URB3D , "SFG_URB3D", layers="URBN" ) - endif - - if ( NoahmpIO%SF_URBAN_PHYSICS == 3 ) then ! BEM urban model - call add_to_restart( NoahmpIO%TLEV_URB3D , "TLEV_URB3D", layers="URBN" ) - call add_to_restart( NoahmpIO%QLEV_URB3D , "QLEV_URB3D", layers="URBN" ) - call add_to_restart( NoahmpIO%TW1LEV_URB3D , "TW1LEV_URB3D", layers="URBN" ) - call add_to_restart( NoahmpIO%TW2LEV_URB3D , "TW2LEV_URB3D", layers="URBN" ) - call add_to_restart( NoahmpIO%TGLEV_URB3D , "TGLEV_URB3D", layers="URBN" ) - call add_to_restart( NoahmpIO%TFLEV_URB3D , "TFLEV_URB3D", layers="URBN" ) - call add_to_restart( NoahmpIO%SF_AC_URB3D , "SF_AC_URB3D" ) - call add_to_restart( NoahmpIO%LF_AC_URB3D , "LF_AC_URB3D" ) - call add_to_restart( NoahmpIO%CM_AC_URB3D , "CM_AC_URB3D" ) - call add_to_restart( NoahmpIO%SFVENT_URB3D , "SFVENT_URB3D" ) - call add_to_restart( NoahmpIO%LFVENT_URB3D , "LFVENT_URB3D" ) - call add_to_restart( NoahmpIO%SFWIN1_URB3D , "SFWIN1_URB3D", layers="URBN" ) - call add_to_restart( NoahmpIO%SFWIN2_URB3D , "SFWIN2_URB3D", layers="URBN" ) - call add_to_restart( NoahmpIO%EP_PV_URB3D , "EP_PV_URB3D" ) - call add_to_restart( NoahmpIO%T_PV_URB3D , "T_PV_URB3D", layers="URBN" ) - call add_to_restart( NoahmpIO%TRV_URB4D , "TRV_URB4D" , layers="URBN" ) - call add_to_restart( NoahmpIO%QR_URB4D , "QR_URB4D" , layers="URBN" ) - call add_to_restart( NoahmpIO%QGR_URB3D , "QGR_URB3D" ) - call add_to_restart( NoahmpIO%TGR_URB3D , "TGR_URB3D" ) - call add_to_restart( NoahmpIO%DRAIN_URB4D , "DRAIN_URB4D", layers="URBN" ) - call add_to_restart( NoahmpIO%DRAINGR_URB3D , "DRAINGR_URB3D" ) - call add_to_restart( NoahmpIO%SFRV_URB3D , "SFRV_URB3D", layers="URBN" ) - call add_to_restart( NoahmpIO%LFRV_URB3D , "LFRV_URB3D", layers="URBN" ) - call add_to_restart( NoahmpIO%DGR_URB3D , "DGR_URB3D", layers="URBN" ) - call add_to_restart( NoahmpIO%DG_URB3D , "DG_URB3D", layers="URBN" ) - call add_to_restart( NoahmpIO%LFR_URB3D , "LFR_URB3D", layers="URBN" ) - call add_to_restart( NoahmpIO%LFG_URB3D , "LFG_URB3D", layers="URBN" ) - endif - endif + + call WriteNoahmpMosaicRestart (NoahmpIO) call finalize_restart_file() diff --git a/hrldas/IO_code/module_hrldas_netcdf_io.F b/hrldas/IO_code/module_hrldas_netcdf_io.F index 0db5c93..70713ac 100644 --- a/hrldas/IO_code/module_hrldas_netcdf_io.F +++ b/hrldas/IO_code/module_hrldas_netcdf_io.F @@ -5,7 +5,8 @@ module module_hrldas_netcdf_io #ifdef MPP_LAND use module_mpp_land, only:mpp_land_bcast_int1, decompose_data_real, mpp_land_bcast_real1, decompose_data_int, & io_id, global_nx, global_ny, my_id, write_io_real, write_io_int, write_io_real3d,decompose_data_real3d, & - mpp_land_sync,mpp_land_bcast_char,mpp_land_bcast + mpp_land_sync,mpp_land_bcast_char,mpp_land_bcast,write_io_real3d_mosaic,write_IO_real_mosaic, & + write_io_int_mosaic #endif #ifdef _PARALLEL_ @@ -55,10 +56,12 @@ module module_hrldas_netcdf_io logical, private :: define_mode_remember integer, private :: dimid_ix_remember integer, private :: dimid_jx_remember + integer, private :: dimid_nx_remember integer, private :: dimid_times_remember integer, private :: dimid_layers_remember integer, private :: dimid_snow_layers_remember integer, private :: dimid_numrad_layers_remember + interface prepare_output_file #ifdef MPP_LAND module procedure prepare_output_file_mpp @@ -101,6 +104,33 @@ module module_hrldas_netcdf_io #endif end interface +! NoahMP Mosaic + + interface add_to_restart_mosaic +#ifdef MPP_LAND + module procedure add_to_restart_2d_float_mpp_mosaic, add_to_restart_2d_integer_mpp_mosaic, add_to_restart_3d_mpp_mosaic +#else + module procedure add_to_restart_2d_float_mosaic, add_to_restart_2d_integer_mosaic, add_to_restart_3d_mosaic +#endif + end interface + + interface get_from_restart_mosaic +#ifdef MPP_LAND + module procedure get_from_restart_2d_float_mpp_mosaic, get_from_restart_2d_integer_mpp_mosaic, get_from_restart_3d_mpp_mosaic, & + get_from_restart_att +#else + module procedure get_from_restart_2d_float_mosaic, get_from_restart_2d_integer_mosaic, get_from_restart_3d_mosaic, get_from_restart_att +#endif + end interface + + interface add_to_output_mosaic +#ifdef MPP_LAND + module procedure add_to_output_2d_float_mpp_mosaic, add_to_output_2d_integer_mpp_mosaic, add_to_output_3d_mpp_mosaic +#else + module procedure add_to_output_2d_float_mosaic, add_to_output_2d_integer_mosaic, add_to_output_3d_mosaic +#endif + end interface + contains !------------------------------------------------------------------------------------------------------- @@ -2994,7 +3024,7 @@ subroutine prepare_output_file_mpp(outdir, version, igrid, & ixfull, jxfull, ixpar, jxpar, xstartpar, ystartpar, iswater, & mapproj, lat1, lon1, dx, dy, truelat1, truelat2, cen_lon, & nsoil, nsnow, nrad, sldpth, startdate, date, spinup_loop, spinup_loops, & - vegtyp, soltyp) + vegtyp, soltyp, ntile) implicit none @@ -3023,6 +3053,7 @@ subroutine prepare_output_file_mpp(outdir, version, igrid, & integer, intent(in) :: nsoil integer, intent(in) :: nsnow integer, intent(in) :: nrad + integer, intent(in) :: ntile real(kind=kind_noahmp), dimension(nsoil), intent(in) :: sldpth character(len=19), intent(in) :: startdate character(len=19), intent(in) :: date @@ -3043,7 +3074,7 @@ subroutine prepare_output_file_mpp(outdir, version, igrid, & global_nx, global_ny, global_nx, global_ny, xstartpar, ystartpar, iswater, & mapproj, lat1, lon1, dx, dy, truelat1, truelat2, cen_lon, & nsoil, nsnow, nrad, sldpth, startdate, date, spinup_loop, spinup_loops, & - g_vegtyp, g_soltyp) + g_vegtyp, g_soltyp, ntile) end if end subroutine prepare_output_file_mpp @@ -3054,7 +3085,7 @@ subroutine prepare_output_file_seq(outdir, version, igrid, & ixfull, jxfull, ixpar, jxpar, xstartpar, ystartpar, iswater, & mapproj, lat1, lon1, dx, dy, truelat1, truelat2, cen_lon, & nsoil, nsnow, nrad, sldpth, startdate, date, spinup_loop, spinup_loops, & - vegtyp, soltyp) + vegtyp, soltyp, ntile) ! To prepare the output file, we create the file, write dimensions and attributes, write the time variable. ! At the end of this routine, the output file is out of define mode. implicit none @@ -3085,6 +3116,7 @@ subroutine prepare_output_file_seq(outdir, version, igrid, & integer, intent(in) :: nsoil integer, intent(in) :: nsnow integer, intent(in) :: nrad + integer, intent(in) :: ntile real(kind=kind_noahmp), dimension(nsoil), intent(in) :: sldpth character(len=19), intent(in) :: startdate character(len=19), intent(in) :: date @@ -3095,7 +3127,7 @@ subroutine prepare_output_file_seq(outdir, version, igrid, & integer :: ncid - integer :: dimid_ix, dimid_jx, dimid_times, dimid_datelen, varid, n + integer :: dimid_ix, dimid_jx, dimid_nx, dimid_times, dimid_datelen, varid, n integer :: dimid_dum, dimid_layers, dimid_snow_layers, dimid_numrad_layers integer :: iret character(len=256) :: output_flnm @@ -3137,6 +3169,7 @@ subroutine prepare_output_file_seq(outdir, version, igrid, & ! Dimensions reflect the full size of the subwindow (not the strip known by this particular process). iret = nf90_def_dim(ncid, "west_east", ixfull, dimid_ix) iret = nf90_def_dim(ncid, "south_north", jxfull, dimid_jx) + iret = nf90_def_dim(ncid, "tile_number", ntile, dimid_nx) iret = nf90_def_dim(ncid, "west_east_stag", ixfull+1, dimid_dum) iret = nf90_def_dim(ncid, "south_north_stag", jxfull+1, dimid_dum) iret = nf90_def_dim(ncid, "soil_layers_stag", nsoil, dimid_layers) @@ -3179,6 +3212,7 @@ subroutine prepare_output_file_seq(outdir, version, igrid, & xstartpar_remember = xstartpar dimid_ix_remember = dimid_ix dimid_jx_remember = dimid_jx + dimid_nx_remember = dimid_nx dimid_times_remember = dimid_times dimid_layers_remember = dimid_layers dimid_snow_layers_remember = dimid_snow_layers @@ -3577,7 +3611,7 @@ end subroutine finalize_restart_file subroutine prepare_restart_file_mpp(outdir, version, igrid, llanduse, olddate, startdate, & ixfull, jxfull, ixpar, jxpar, xstartpar, ystartpar, & nsoil, nsnow, nrad, num_urban_layers, dx, dy, truelat1, truelat2, mapproj, lat1, lon1, cen_lon, & - iswater, vegtyp) + iswater, vegtyp, ntile) implicit none @@ -3596,6 +3630,7 @@ subroutine prepare_restart_file_mpp(outdir, version, igrid, llanduse, olddate, s integer, intent(in) :: nsoil integer, intent(in) :: nsnow integer, intent(in) :: nrad + integer, intent(in) :: ntile integer, intent(in) :: num_urban_layers real(kind=kind_noahmp), intent(in) :: dx, dy real(kind=kind_noahmp), intent(in) :: truelat1, truelat2 @@ -3610,7 +3645,7 @@ subroutine prepare_restart_file_mpp(outdir, version, igrid, llanduse, olddate, s call prepare_restart_file_seq(outdir, version, igrid, llanduse, olddate, startdate, & global_nx, global_ny, global_nx, global_ny, xstartpar, ystartpar, & nsoil, nsnow, nrad, num_urban_layers, dx, dy, truelat1, truelat2, mapproj, lat1, lon1, cen_lon, & - iswater, gvegtyp) + iswater, gvegtyp, ntile) endif call mpp_land_sync() @@ -3621,7 +3656,7 @@ end subroutine prepare_restart_file_mpp subroutine prepare_restart_file_seq(outdir, version, igrid, llanduse, olddate, startdate, & ixfull, jxfull, ixpar, jxpar, xstartpar, ystartpar, & nsoil, nsnow, nrad, num_urban_layers, dx, dy, truelat1, truelat2, mapproj, lat1, lon1, cen_lon, & - iswater, vegtyp) + iswater, vegtyp, ntile) implicit none #include @@ -3641,6 +3676,7 @@ subroutine prepare_restart_file_seq(outdir, version, igrid, llanduse, olddate, s integer, intent(in) :: nsoil integer, intent(in) :: nsnow integer, intent(in) :: nrad + integer, intent(in) :: ntile integer, intent(in) :: num_urban_layers real(kind=kind_noahmp), intent(in) :: dx, dy real(kind=kind_noahmp), intent(in) :: truelat1, truelat2 @@ -3654,7 +3690,8 @@ subroutine prepare_restart_file_seq(outdir, version, igrid, llanduse, olddate, s character(len=256) :: output_flnm integer :: ierr integer :: varid - integer :: dimid_times, dimid_datelen, dimid_ix, dimid_jx, dimid_dum, dimid_layers, dimid_snow_layers, dimid_sosn_layers, dimid_urban,dimid_numrad_layers + integer :: dimid_times, dimid_datelen, dimid_ix, dimid_jx, dimid_nx, dimid_dum, dimid_layers, dimid_snow_layers, & + dimid_sosn_layers, dimid_urban,dimid_numrad_layers character(len=19) :: date19 integer :: rank @@ -3697,6 +3734,7 @@ subroutine prepare_restart_file_seq(outdir, version, igrid, llanduse, olddate, s ierr = nf90_def_dim(ncid, "DateStrLen", 19, dimid_datelen) ierr = nf90_def_dim(ncid, "west_east", ixfull, dimid_ix) ierr = nf90_def_dim(ncid, "south_north", jxfull, dimid_jx) + ierr = nf90_def_dim(ncid, "tile_number", ntile, dimid_nx) ierr = nf90_def_dim(ncid, "west_east_stag", ixfull+1, dimid_dum) ierr = nf90_def_dim(ncid, "south_north_stag", jxfull+1, dimid_dum) ierr = nf90_def_dim(ncid, "soil_layers_stag", nsoil, dimid_layers) @@ -4499,6 +4537,988 @@ subroutine read_additional(flnm_template, hdate, name, xstart, xend, ystart, yen end subroutine read_additional +!--------------------------------------------------------------------------------------------------------- +! NoahMP Mosaic IO: Restart and Output : Prasanth Valayamkunnath, July 22, 2025 +!--------------------------------------------------------------------------------------------------------- + +#ifdef MPP_LAND + subroutine add_to_restart_2d_float_mpp_mosaic(array, name, ntile, units, description) + implicit none + integer, intent(in) :: ntile + real(kind=kind_noahmp), dimension(:,:,:), intent(in) :: array + real(kind=kind_noahmp), dimension(global_nx,global_ny,ntile) :: garray + character(len=*), intent(in) :: name + character(len=*), optional, intent(in) :: units + character(len=*), optional, intent(in) :: description + + call write_io_real_mosaic(array,garray,ntile) + if(my_id .eq. IO_id) then + call add_to_restart_2d_float_mosaic(garray, name, ntile, units, description) + endif + call mpp_land_sync() + end subroutine add_to_restart_2d_float_mpp_mosaic + + subroutine add_to_restart_2d_integer_mpp_mosaic(array, name, ntile, units, description) + implicit none + integer, intent(in) :: ntile + integer, dimension(:,:,:), intent(in) :: array + integer, dimension(global_nx,global_ny, ntile) :: garray + character(len=*), intent(in) :: name + character(len=*), optional, intent(in) :: units + character(len=*), optional, intent(in) :: description + call write_io_int_mosaic(array,garray,ntile) + if(my_id .eq. IO_id) then + call add_to_restart_2d_integer_mosaic(garray, name, ntile, units, description) + endif + call mpp_land_sync() + end subroutine add_to_restart_2d_integer_mpp_mosaic + + subroutine add_to_restart_3d_mpp_mosaic(array, name, ntile, units, description, layers) + implicit none + integer, intent(in) :: ntile + real(kind=kind_noahmp), dimension(:,:,:,:), intent(in) :: array + character(len=*), intent(in) :: name + character(len=*), optional, intent(in) :: units + character(len=*), optional, intent(in) :: description + character(len=4), optional, intent(in) :: layers + integer :: k, klevel + + real(kind=kind_noahmp), allocatable, dimension(:,:,:,:) :: garray + klevel = size(array,2) + allocate(garray(global_nx,klevel,global_ny,ntile)) + + call write_io_real3d_mosaic(array,garray,klevel,ntile) + + if(my_id .eq. IO_id) then + call add_to_restart_3d_mosaic(garray, name, ntile, units, description, layers) + endif + deallocate(garray) + + call mpp_land_sync() + end subroutine add_to_restart_3d_mpp_mosaic +#endif + +!----------------------------------------------------------------------------------------- +!----------------------------------------------------------------------------------------- + + subroutine add_to_restart_2d_float_mosaic(array, name, ntile, units, description) + implicit none + integer, intent(in) :: ntile + real(kind=kind_noahmp), dimension(:,:,:), intent(in) :: array + character(len=*), intent(in) :: name + character(len=*), optional, intent(in) :: units + character(len=*), optional, intent(in) :: description + + character(len=256) :: output_flnm + integer :: ncid + integer :: ierr + integer :: dimid_ix + integer :: dimid_jx + integer :: dimid_nx + integer :: dimid_times + integer :: ixout + integer :: xstartout + integer :: iswater + character(len=256) :: local_units + character(len=256) :: local_description + + integer :: ixpar + integer :: jxpar + integer :: nxpar + + output_flnm = restart_filename_remember + iswater = iswater_remember + + ixpar = size(array,1) + jxpar = size(array,2) + nxpar = size(array,3) + + if (present(units)) then + local_units = units + else + local_units = "-" + endif + + if (present(description)) then + local_description = description + else + local_description = "-" + endif + +#ifdef _PARALLEL_ + ierr = nf90_open_par(trim(output_flnm), NF90_WRITE, MPI_COMM_WORLD, MPI_INFO_NULL, ncid) +#else + ierr = nf90_open(trim(output_flnm), NF90_WRITE, ncid) +#endif + call error_handler(ierr, "ADD_TO_RESTART_MOSAIC: nf90_open") + + ierr = nf90_inq_dimid(ncid, "west_east", dimid_ix) + call error_handler(ierr, "ADD_TO_RESTART_MOSAIC: nf90_inq_dimid for 'west_east'") + + ierr = nf90_inq_dimid(ncid, "south_north", dimid_jx) + call error_handler(ierr, "ADD_TO_RESTART_MOSAIC: nf90_inq_dimid for 'south_north'") + + ierr = nf90_inq_dimid(ncid, "tile_number", dimid_nx) + call error_handler(ierr, "ADD_TO_RESTART_MOSAIC: nf90_inq_dimid for 'tile_number'") + + ierr = nf90_inq_dimid(ncid, "Time", dimid_times) + call error_handler(ierr, "ADD_TO_RESTART_MOSAIC: nf90_inq_dimid for 'Time'") + + ierr = nf90_redef(ncid) + call error_handler(ierr, "ADD_TO_RESTART_MOSAIC: nf90_redef") + + call make_var_att_2d_mosaic(ncid, dimid_ix, dimid_jx, dimid_nx, dimid_times, NF90_FLOAT, name, trim(local_description), trim(local_units)) + + ierr = nf90_enddef(ncid) + call error_handler(ierr, "ADD_TO_RESTART_MOSAIC: nf90_enddef") + + call put_var_2d_mosaic(ncid, 1, vegtyp_remember, iswater, ixpar, jxpar, nxpar, xstartpar_remember, name, array, .true.) + + ierr = nf90_close(ncid) + call error_handler(ierr, "ADD_TO_RESTART_MOSAIC: nf90_close") + + end subroutine add_to_restart_2d_float_mosaic + +!----------------------------------------------------------------------------------------- +!----------------------------------------------------------------------------------------- + + subroutine add_to_restart_2d_integer_mosaic(array, name, ntile, units, description) + implicit none + integer, intent(in) :: ntile + integer, dimension(:,:,:), intent(in) :: array + character(len=*), intent(in) :: name + character(len=*), optional, intent(in) :: units + character(len=*), optional, intent(in) :: description + + character(len=256) :: output_flnm + integer :: ncid + integer :: ierr + integer :: dimid_ix + integer :: dimid_jx + integer :: dimid_nx + integer :: dimid_times + integer :: ixout + integer :: xstartout + integer :: iswater + character(len=256) :: local_units + character(len=256) :: local_description + + integer :: ixpar + integer :: jxpar + integer :: nxpar + + output_flnm = restart_filename_remember + iswater = iswater_remember + + ixpar = size(array,1) + jxpar = size(array,2) + nxpar = size(array,3) + + if (present(units)) then + local_units = units + else + local_units = "-" + endif + + if (present(description)) then + local_description = description + else + local_description = "-" + endif + +#ifdef _PARALLEL_ + ierr = nf90_open_par(trim(output_flnm), NF90_WRITE, MPI_COMM_WORLD, MPI_INFO_NULL, ncid) +#else + ierr = nf90_open(trim(output_flnm), NF90_WRITE, ncid) +#endif + call error_handler(ierr, "ADD_TO_RESTART_MOSAIC: nf90_open") + + ierr = nf90_inq_dimid(ncid, "west_east", dimid_ix) + call error_handler(ierr, "ADD_TO_RESTART_MOSAIC: nf90_inq_dimid for 'west_east'") + + ierr = nf90_inq_dimid(ncid, "south_north", dimid_jx) + call error_handler(ierr, "ADD_TO_RESTART_MOSAIC: nf90_inq_dimid for 'south_north'") + + ierr = nf90_inq_dimid(ncid, "tile_number", dimid_nx) + call error_handler(ierr, "ADD_TO_RESTART_MOSAIC: nf90_inq_dimid for 'tile_number'") + + ierr = nf90_inq_dimid(ncid, "Time", dimid_times) + call error_handler(ierr, "ADD_TO_RESTART_MOSAIC: nf90_inq_dimid for 'Time'") + + ierr = nf90_redef(ncid) + call error_handler(ierr, "ADD_TO_RESTART_MOSAIC: nf90_redef") + + call make_var_att_2d_mosaic(ncid, dimid_ix, dimid_jx, dimid_nx, dimid_times, NF90_INT, name, trim(local_description), trim(local_units)) + + ierr = nf90_enddef(ncid) + call error_handler(ierr, "ADD_TO_RESTART_MOSAIC: nf90_enddef") + + call put_var_int_mosaic(ncid, 1, vegtyp_remember, iswater, ixpar, jxpar, nxpar, xstartpar_remember, name, array) + + ierr = nf90_close(ncid) + call error_handler(ierr, "ADD_TO_RESTART_MOSAIC: nf90_close") + + end subroutine add_to_restart_2d_integer_mosaic + +!----------------------------------------------------------------------------------------- +!----------------------------------------------------------------------------------------- + + subroutine add_to_restart_3d_mosaic(array, name, ntile, units, description, layers) + implicit none + integer, intent(in) :: ntile + real(kind=kind_noahmp), dimension(:,:,:,:), intent(in) :: array + character(len=*), intent(in) :: name + character(len=*), optional, intent(in) :: units + character(len=*), optional, intent(in) :: description + character(len=4), optional, intent(in) :: layers + + character(len=256) :: output_flnm + integer :: ncid + integer :: ierr + integer :: dimid_ix + integer :: dimid_jx + integer :: dimid_kx + integer :: dimid_nx + integer :: dimid_times + integer :: ixout + integer :: xstartout + integer :: iswater + character(len=256) :: local_units + character(len=256) :: local_description + + integer :: ixpar + integer :: jxpar + integer :: kxpar + integer :: nxpar + character(len=4) :: output_layers + + output_flnm = restart_filename_remember + iswater = iswater_remember + + if (present(layers)) then + output_layers = layers + else + output_layers = "SOIL" + endif + + ixpar = size(array,1) + kxpar = size(array,2) + jxpar = size(array,3) + nxpar = size(array,4) + + if (present(units)) then + local_units = units + else + local_units = "-" + endif + + if (present(description)) then + local_description = description + else + local_description = "-" + endif + +#ifdef _PARALLEL_ + ierr = nf90_open_par(trim(output_flnm), NF90_WRITE, MPI_COMM_WORLD, MPI_INFO_NULL, ncid) +#else + ierr = nf90_open(trim(output_flnm), NF90_WRITE, ncid) +#endif + call error_handler(ierr, "ADD_TO_RESTART_MOSAIC: nf90_open") + + ierr = nf90_inq_dimid(ncid, "west_east", dimid_ix) + call error_handler(ierr, "ADD_TO_RESTART_MOSAIC: nf90_inq_dimid for 'west_east'") + + ierr = nf90_inq_dimid(ncid, "south_north", dimid_jx) + call error_handler(ierr, "ADD_TO_RESTART_MOSAIC: nf90_inq_dimid for 'south_north'") + + ierr = nf90_inq_dimid(ncid, "tile_number", dimid_nx) + call error_handler(ierr, "ADD_TO_RESTART_MOSAIC: nf90_inq_dimid for 'tile_number'") + + if (output_layers == "SOIL") then + ierr = nf90_inq_dimid(ncid, "soil_layers_stag", dimid_kx) + call error_handler(ierr, "ADD_TO_RESTART_MOSAIC: nf90_inq_dimid for 'soil_layers_stag'") + else if (output_layers == "SNOW") then + ierr = nf90_inq_dimid(ncid, "snow_layers", dimid_kx) + call error_handler(ierr, "ADD_TO_RESTART_MOSAIC: nf90_inq_dimid for 'snow_layers'") + else if (output_layers == "SOSN") then + ierr = nf90_inq_dimid(ncid, "sosn_layers", dimid_kx) + call error_handler(ierr, "ADD_TO_RESTART_MOSAIC: nf90_inq_dimid for 'sosn_layers'") + else if (output_layers == "URBN") then + ierr = nf90_inq_dimid(ncid, "urban_layers", dimid_kx) + call error_handler(ierr, "ADD_TO_RESTART_MOSAIC: nf90_inq_dimid for 'urban_layers'") + else if (output_layers == "RADN") then + ierr = nf90_inq_dimid(ncid, "rad_layers", dimid_kx) + call error_handler(ierr, "ADD_TO_RESTART_MOSAIC: nf90_inq_dimid for 'rad_layers'") + else + stop "PANIC!" + endif + + ierr = nf90_inq_dimid(ncid, "Time", dimid_times) + call error_handler(ierr, "ADD_TO_RESTART_MOSAIC: nf90_inq_dimid for 'Time'") + + ierr = nf90_redef(ncid) + call error_handler(ierr, "ADD_TO_RESTART_MOSAIC: nf90_redef") + + call make_var_att_3d_mosaic(ncid, dimid_ix, dimid_jx, dimid_nx, dimid_times, NF90_FLOAT, dimid_kx, name, trim(local_description), trim(local_units)) + + ierr = nf90_enddef(ncid) + call error_handler(ierr, "ADD_TO_RESTART_MOSAIC: nf90_enddef") + + call put_var_3d_mosaic(ncid, 1, vegtyp_remember, iswater, ixpar, jxpar, nxpar, xstartpar_remember, kxpar, name, array) + + ierr = nf90_close(ncid) + call error_handler(ierr, "ADD_TO_RESTART_MOSAIC: nf90_close") + + end subroutine add_to_restart_3d_mosaic + +!----------------------------------------------------------------------------------------- +!----------------------------------------------------------------------------------------- +!--------------------------------------------------------------------------------------------------------- + + subroutine put_var_int_mosaic(ncid, output_count, vegtyp, iswater, ix, jx, nx, xstart, varname, vardata) + implicit none + integer, intent(in) :: ncid + integer, intent(in) :: output_count + character(len=*), intent(in) :: varname + integer, intent(in) :: ix + integer, intent(in) :: jx + integer, intent(in) :: nx + integer, intent(in) :: xstart + integer, intent(in) :: iswater + integer, dimension(ix,jx), intent(in) :: vegtyp + integer, dimension(ix,jx,nx), intent(in) :: vardata + + integer :: iret + integer :: varid + + integer, dimension(4) :: nstart + integer, dimension(4) :: ncount + + nstart = (/ xstart , 1 , 1 , output_count /) + ncount = (/ ix , jx , nx , 1 /) + + iret = nf90_inq_varid(ncid, varname, varid) + call error_handler(iret, failure="Subroutine PUT_VAR_INT_MOSAIC: Problem finding variable id for variable: "//varname) + + iret = nf90_put_var(ncid, varid, vardata, nstart, ncount) + call error_handler(iret, failure="Subroutine PUT_VAR_INT_MOSAIC: Problem putting variable '"//varname//"' to NetCDF file.") + + end subroutine put_var_int_mosaic + +!--------------------------------------------------------------------------------------------------------- +!--------------------------------------------------------------------------------------------------------- + + subroutine put_var_2d_mosaic(ncid, output_count, vegtyp, iswater, ix, jx, nx, xstart, varname, vardata, restart_flag) + implicit none + integer, intent(in) :: ncid + integer, intent(in) :: output_count + character(len=*), intent(in) :: varname + integer, intent(in) :: ix + integer, intent(in) :: jx + integer, intent(in) :: nx + integer, intent(in) :: xstart + integer, dimension(ix,jx), intent(in) :: vegtyp + integer, intent(in) :: iswater + real(kind=kind_noahmp), dimension(ix,jx,nx), intent(in) :: vardata + logical, intent(in) :: restart_flag + + real(kind=kind_noahmp), dimension(ix,jx,nx) :: xdum + integer :: iret + integer :: varid + integer :: m + + integer, dimension(4) :: nstart + integer, dimension(4) :: ncount + + do m = 1, nx + where (vegtyp(:,:) == ISWATER .and. .not. restart_flag) + xdum(:,:,m) = -1.E33 + elsewhere + xdum(:,:,m) = vardata(:,:,m) + endwhere + end do + + iret = nf90_inq_varid(ncid, varname, varid) + call error_handler(iret, "Subroutine PUT_VAR_2D_MOSAIC: Problem finding variable id for "//trim(varname)//".") + + nstart = (/ xstart , 1 , 1, output_count /) + ncount = (/ ix , jx , nx, 1 /) + + iret = nf90_put_var(ncid, varid, xdum, start=nstart, count=ncount) + call error_handler(iret, "Subroutine PUT_VAR_2D_MOSAIC: Problem putting variable "//trim(varname)//" to NetCDF file.") + + end subroutine put_var_2d_mosaic + +!--------------------------------------------------------------------------------------------------------- +!--------------------------------------------------------------------------------------------------------- + + subroutine put_var_3d_mosaic(ncid, output_count, vegtyp, iswater, ix, jx, nx, xstart, nsoil, varname, vardata) + implicit none + integer, intent(in) :: ncid + integer, intent(in) :: output_count + character(len=*), intent(in) :: varname + integer, intent(in) :: ix + integer, intent(in) :: jx + integer, intent(in) :: nx + integer, intent(in) :: xstart + integer, intent(in) :: nsoil + integer, intent(in) :: iswater + integer, dimension(ix, jx), intent(in) :: vegtyp + real(kind=kind_noahmp), dimension(ix, nsoil, jx, nx), intent(in) :: vardata + real(kind=kind_noahmp), dimension(ix, nsoil, jx, nx) :: xdum + integer :: iret + integer :: varid + integer :: n + integer :: m + integer, dimension(5) :: nstart + integer, dimension(5) :: ncount + + nstart = (/ xstart , 1 , 1 , 1, output_count /) + ncount = (/ ix , nsoil , jx , nx, 1 /) + + xdum = vardata + do m = 1, nx + do n = 1, nsoil + where (vegtyp(:,:) == ISWATER) xdum(:,n,:,m) = -1.E33 + enddo + end do + + iret = nf90_inq_varid(ncid, varname, varid) + call error_handler(iret, "Subroutine PUT_VAR_3D_MOSAIC: Problem finding variable id for "//trim(varname)//".") + + iret = nf90_put_var(ncid, varid, xdum, start=nstart, count=ncount) + call error_handler(iret, "Subroutine PUT_VAR_3D_MOSAIC: Problem putting variable "//trim(varname)//" to NetCDF file.") + + end subroutine put_var_3d_mosaic + +!--------------------------------------------------------------------------------------------------------- +!--------------------------------------------------------------------------------------------------------- + + subroutine make_var_att_2d_mosaic(ncid, dimid_ix, dimid_jx, dimid_nx, dimid_times, itype, varname, vardesc, varunits) + implicit none + integer, intent(in) :: ncid + character(len=*), intent(in) :: varname + character(len=*), intent(in) :: vardesc + character(len=*), intent(in) :: varunits + integer, intent(in) :: dimid_ix + integer, intent(in) :: dimid_jx + integer, intent(in) :: dimid_nx + integer, intent(in) :: dimid_times + integer, intent(in) :: itype + integer :: iret + integer :: varid + + iret = nf90_def_var(ncid, varname, itype, (/dimid_ix,dimid_jx,dimid_nx,dimid_times/), varid) + call error_handler(iret, "MAKE_VAR_ATT_2D_MOSIAC: Failure defining variable "//trim(varname)) + + iret = nf90_put_att(ncid, varid, "MemoryOrder", "XYN ") + call error_handler(iret, "MAKE_VAR_ATT_2D_MOSAIC: Failure adding MemoryOrder attribute to variable "//trim(varname)) + + iret = nf90_put_att(ncid, varid, "description", vardesc) + call error_handler(iret, "MAKE_VAR_ATT_2D_MOSAIC: Failure adding description attribute to variable "//trim(varname)) + + iret = nf90_put_att(ncid, varid, "units", varunits) + call error_handler(iret, "MAKE_VAR_ATT_2D_MOSAIC: Failure adding units attribute '"//trim(varunits)//"' to variable "//trim(varname)) + + iret = nf90_put_att(ncid, varid, "stagger", "-") + call error_handler(iret, "MAKE_VAR_ATT_2D_MOSAIC: Failure adding stagger attribute to variable "//trim(varname)) + + end subroutine make_var_att_2d_mosaic + +!--------------------------------------------------------------------------------------------------------- +!--------------------------------------------------------------------------------------------------------- + + subroutine make_var_att_3d_mosaic(ncid, dimid_ix, dimid_jx, dimid_nx, dimid_times, itype, dimid_layers, varname, vardesc, varunits) + implicit none + integer, intent(in) :: ncid + character(len=*), intent(in) :: varname + character(len=*), intent(in) :: vardesc + character(len=*), intent(in) :: varunits + integer, intent(in) :: dimid_ix + integer, intent(in) :: dimid_jx + integer, intent(in) :: dimid_nx + integer, intent(in) :: dimid_times + integer, intent(in) :: dimid_layers + integer, intent(in) :: itype + integer :: iret + integer :: varid + + iret = nf90_def_var(ncid, varname, itype, (/dimid_ix,dimid_layers,dimid_jx,dimid_nx,dimid_times/), varid) + call error_handler(iret, "MAKE_VAR_ATT_3D_MOSAIC: Failure defining variable "//trim(varname)) + + iret = nf90_put_att(ncid, varid, "MemoryOrder", "XZYN") + call error_handler(iret, "MAKE_VAR_ATT_3D_MOSAIC: Failure adding MemoryOrder attribute for variable "//trim(varname)) + + iret = nf90_put_att(ncid, varid, "description", vardesc) + call error_handler(iret, "MAKE_VAR_ATT_3D_MOSAIC: Failure adding description attribute to variable "//trim(varname)) + + iret = nf90_put_att(ncid, varid, "units", varunits) + call error_handler(iret, "MAKE_VAR_ATT_3D_MOSAIC: Failure adding units attribute '"//trim(varunits)//"' to variable "//trim(varname)) + + iret = nf90_put_att(ncid, varid, "stagger", "Z") + call error_handler(iret, "MAKE_VAR_ATT_3D_MOSAIC: Failure adding stagger attribute to variable "//trim(varname)) + + end subroutine make_var_att_3d_mosaic + +!----------------------------------------------------------------------------------------- +!----------------------------------------------------------------------------------------- +#ifdef MPP_LAND + subroutine get_from_restart_2d_float_mpp_mosaic(parallel_xstart, parallel_xend, subwindow_xstart, ixfull, jxfull, ntile, name, array, return_error) + implicit none + integer, intent(in) :: parallel_xstart + integer, intent(in) :: parallel_xend + integer, intent(in) :: subwindow_xstart + integer, intent(in) :: ixfull + integer, intent(in) :: jxfull + integer, intent(in) :: ntile + character(len=*), intent(in) :: name + integer :: n + + real(kind=kind_noahmp), dimension(parallel_xstart:parallel_xend,jxfull,ntile), intent(out) :: array + real(kind=kind_noahmp), dimension(global_nx,global_ny,ntile) :: garray + integer, optional, intent(out):: return_error + + if(my_id .eq. IO_id) then + call get_from_restart_2d_float_mosaic(1, global_nx, 1, global_nx, global_ny, ntile, name, garray, return_error) + endif + + do n = 1, ntile + call decompose_data_real(garray(:,:,n),array(:,:,n)) + enddo + + end subroutine get_from_restart_2d_float_mpp_mosaic + + subroutine get_from_restart_2d_integer_mpp_mosaic(parallel_xstart, parallel_xend, subwindow_xstart, ixfull, jxfull, ntile, name, array, return_error) + implicit none + integer, intent(in) :: parallel_xstart + integer, intent(in) :: parallel_xend + integer, intent(in) :: subwindow_xstart + integer, intent(in) :: ixfull + integer, intent(in) :: jxfull + integer, intent(in) :: ntile + character(len=*), intent(in) :: name + integer, dimension(parallel_xstart:parallel_xend,jxfull,ntile), intent(out) :: array + integer, dimension(global_nx,global_ny,ntile) :: garray + integer, optional, intent(out) :: return_error + integer :: n + if(my_id .eq. IO_id) then + call get_from_restart_2d_integer_mosaic(1, global_nx, 1, global_nx, global_ny, ntile, name, garray, return_error) + endif + do n = 1, ntile + call decompose_data_int(garray(:,:,n),array(:,:,n)) + end do + end subroutine get_from_restart_2d_integer_mpp_mosaic + + subroutine get_from_restart_3d_mpp_mosaic(parallel_xstart, parallel_xend, subwindow_xstart, ixfull, jxfull, ntile, name, array, return_error) + implicit none + integer, intent(in) :: parallel_xstart + integer, intent(in) :: parallel_xend + integer, intent(in) :: subwindow_xstart + integer, intent(in) :: ixfull + integer, intent(in) :: jxfull + integer, intent(in) :: ntile + character(len=*), intent(in) :: name + real(kind=kind_noahmp), dimension(:,:,:,:), intent(out) :: array + integer, optional, intent(out) :: return_error + integer :: klevel,k,n + real(kind=kind_noahmp), allocatable, dimension(:,:,:,:) :: garray + + klevel = size(array,2) + allocate(garray(global_nx,klevel,global_ny,ntile)) + + + if(my_id .eq. IO_id) then + call get_from_restart_3d_mosaic(1, global_nx, 1, global_nx, global_ny, ntile, name, garray, return_error) + endif + do n = 1, ntile + do k = 1, klevel + call decompose_data_real(garray(:,k,:,n),array(:,k,:,n)) + end do + end do + deallocate(garray) + + end subroutine get_from_restart_3d_mpp_mosaic +#endif + + subroutine get_from_restart_2d_float_mosaic(parallel_xstart, parallel_xend, subwindow_xstart, ixfull, jxfull, ntile, name, array, return_error) + implicit none + integer, intent(in) :: parallel_xstart + integer, intent(in) :: parallel_xend + integer, intent(in) :: subwindow_xstart + integer, intent(in) :: ixfull + integer, intent(in) :: jxfull + integer, intent(in) :: ntile + character(len=*), intent(in) :: name + real(kind=kind_noahmp), dimension(parallel_xstart:parallel_xend,jxfull,ntile), intent(out) :: array + integer, optional, intent(out) :: return_error + + integer :: ierr + integer :: ncid + integer :: varid + integer, dimension(4) :: nstart + integer, dimension(4) :: ncount + integer :: rank + +#ifdef _PARALLEL_ + + call MPI_COMM_RANK(MPI_COMM_WORLD, rank, ierr) + if (ierr /= MPI_SUCCESS) stop "MPI_COMM_RANK" + + ierr = nf90_open_par(trim(restart_filename_remember), NF90_NOWRITE, MPI_COMM_WORLD, MPI_INFO_NULL, ncid) + +#else + rank = 0 + + ierr = nf90_open(trim(restart_filename_remember), NF90_NOWRITE, ncid) + +#endif + call error_handler(ierr, "GET_FROM_RESTART_MOSAIC: Problem opening restart file '"//trim(restart_filename_remember)//"'") + + nstart = (/ parallel_xstart-subwindow_xstart+1, 1, 1, 1 /) + ncount = (/ parallel_xend-parallel_xstart+1 , jxfull, ntile, 1 /) + + if (present(return_error)) then + ierr = nf90_inq_varid(ncid, name, varid) + if (ierr == NF90_NOERR) then + return_error = 0 + call error_handler(ierr, "Problem finding variable in restart file '"//trim(name)//"'") + + ierr = nf90_get_var(ncid, varid, array, start=nstart) + call error_handler(ierr, "Problem finding variable in restart file: '"//trim(name)//"'") + else + return_error = 1 + if (rank == 0) write(*,'("Did not find optional variable ''",A,"'' in restart file ''", A, "''")') trim(name), trim(restart_filename_remember) + endif + else + ierr = nf90_inq_varid(ncid, name, varid) + call error_handler(ierr, "Problem finding required variable in restart file: '"//trim(name)//"'") + + ierr = nf90_get_var(ncid, varid, array, start=nstart) + call error_handler(ierr, "Problem finding variable in restart file: '"//trim(name)//"'") + endif + + ierr = nf90_close(ncid) + call error_handler(ierr, "Problem closing restart file") + + end subroutine get_from_restart_2d_float_mosaic + +!----------------------------------------------------------------------------------------- +!----------------------------------------------------------------------------------------- + + subroutine get_from_restart_2d_integer_mosaic(parallel_xstart, parallel_xend, subwindow_xstart, ixfull, jxfull, ntile, name, array, return_error) + implicit none + integer, intent(in) :: parallel_xstart + integer, intent(in) :: parallel_xend + integer, intent(in) :: subwindow_xstart + integer, intent(in) :: ixfull + integer, intent(in) :: jxfull + integer, intent(in) :: ntile + character(len=*), intent(in) :: name + integer, dimension(parallel_xstart:parallel_xend,jxfull,ntile), intent(out) :: array + integer, optional, intent(out) :: return_error + + integer :: ierr + integer :: ncid + integer :: varid + integer, dimension(4) :: nstart + integer, dimension(4) :: ncount + +#ifdef _PARALLEL_ + ierr = nf90_open_par(trim(restart_filename_remember), NF90_NOWRITE, MPI_COMM_WORLD, MPI_INFO_NULL, ncid) +#else + ierr = nf90_open(trim(restart_filename_remember), NF90_NOWRITE, ncid) +#endif + call error_handler(ierr, "GET_FROM_RESTART_MOSAIC: Problem opening restart file '"//trim(restart_filename_remember)//"'") + + nstart = (/ parallel_xstart-subwindow_xstart+1, 1, 1, 1 /) + ncount = (/ parallel_xend-parallel_xstart+1 , jxfull, ntile, 1 /) + + if (present(return_error)) then + ierr = nf90_inq_varid(ncid, name, varid) + if (ierr == NF90_NOERR) then + return_error = 0 + call error_handler(ierr, "Problem finding variable in restart file '"//trim(name)//"'") + + ierr = nf90_get_var(ncid, varid, array, start=nstart) + call error_handler(ierr, "Problem finding variable in restart file: '"//trim(name)//"'") + else + return_error = 1 + write(*,'("Did not find optional variable ''",A,"'' in restart file ''", A, "''")') trim(name), trim(restart_filename_remember) + endif + else + ierr = nf90_inq_varid(ncid, name, varid) + call error_handler(ierr, "Problem finding required variable in restart file: '"//trim(name)//"'") + + ierr = nf90_get_var(ncid, varid, array, start=nstart) + call error_handler(ierr, "Problem finding variable in restart file: '"//trim(name)//"'") + endif + + ierr = nf90_close(ncid) + call error_handler(ierr, "Problem closing restart file") + + end subroutine get_from_restart_2d_integer_mosaic + +!----------------------------------------------------------------------------------------- +!----------------------------------------------------------------------------------------- + + subroutine get_from_restart_3d_mosaic(parallel_xstart, parallel_xend, subwindow_xstart, ixfull, jxfull, ntile, name, array, return_error) + implicit none + integer, intent(in) :: parallel_xstart + integer, intent(in) :: parallel_xend + integer, intent(in) :: subwindow_xstart + integer, intent(in) :: ixfull + integer, intent(in) :: jxfull + integer, intent(in) :: ntile + character(len=*), intent(in) :: name + real(kind=kind_noahmp), dimension(:,:,:,:), intent(out) :: array + integer, optional, intent(out) :: return_error + + integer :: ierr + integer :: ncid + integer :: varid + integer, dimension(5) :: nstart + integer, dimension(5) :: ncount + +#ifdef _PARALLEL_ + ierr = nf90_open_par(trim(restart_filename_remember), NF90_NOWRITE, MPI_COMM_WORLD, MPI_INFO_NULL, ncid) +#else + ierr = nf90_open(trim(restart_filename_remember), NF90_NOWRITE, ncid) +#endif + call error_handler(ierr, "GET_FROM_RESTART_MOSAIC: Problem opening restart file '"//trim(restart_filename_remember)//"'") + + nstart = (/parallel_xstart-subwindow_xstart+1, 1, 1, 1, 1/) + ncount = (/parallel_xend-parallel_xstart+1, size(array,2), size(array,3), ntile, 1/) + + if (present(return_error)) then + ierr = nf90_inq_varid(ncid, name, varid) + if (ierr == NF90_NOERR) then + return_error = 0 + call error_handler(ierr, "Problem finding variable in restart file '"//trim(name)//"'") + + ierr = nf90_get_var(ncid, varid, array, start=nstart) + call error_handler(ierr, "Problem finding variable in restart file: '"//trim(name)//"'") + else + return_error = 1 + write(*,'("Did not find optional variable ''",A,"'' in restart file ''", A, "''")') trim(name), trim(restart_filename_remember) + endif + else + ierr = nf90_inq_varid(ncid, name, varid) + call error_handler(ierr, "Problem finding required variable in restart file: '"//trim(name)//"'") + + ierr = nf90_get_var(ncid, varid, array, start=nstart) + call error_handler(ierr, "Problem finding variable in restart file: '"//trim(name)//"'") + endif + + ierr = nf90_close(ncid) + call error_handler(ierr, "Problem closing restart file") + + end subroutine get_from_restart_3d_mosaic + +!--------------------------------------------------------------------------------------------------------- +!--------------------------------------------------------------------------------------------------------- + +#ifdef MPP_LAND + subroutine add_to_output_2d_float_mpp_mosaic ( array, name, ntile, description, units ) + implicit none + integer, intent(in) :: ntile + real(kind=kind_noahmp), dimension(:,:,:), intent(in) :: array + real(kind=kind_noahmp), dimension(global_nx,global_ny,ntile) :: garray + character(len=*), intent(in) :: name, description, units + integer :: n + do n = 1, ntile + call write_io_real(array(:,:,n),garray(:,:,n)) + enddo + if(my_id .eq. io_id) then + call add_to_output_2d_float_mosaic( garray, name, ntile, description, units ) + endif + end subroutine add_to_output_2d_float_mpp_mosaic + + subroutine add_to_output_2d_integer_mpp_mosaic ( array, name, ntile, description, units ) + implicit none + integer, intent(in) :: ntile + integer, dimension(:,:,:), intent(in) :: array + character(len=*), intent(in) :: name, description, units + integer, dimension(global_nx,global_ny,ntile) :: garray + call write_io_int_mosaic(array,garray,ntile) + if(my_id .eq. io_id) then + call add_to_output_2d_integer_mosaic( garray, name, ntile, description, units ) + endif + end subroutine add_to_output_2d_integer_mpp_mosaic + + subroutine add_to_output_3d_mpp_mosaic ( array, name, ntile, description, units, snow_or_soil ) + implicit none + integer, intent(in) :: ntile + real(kind=kind_noahmp), dimension(:,:,:,:), intent(in) :: array + character(len=*), intent(in) :: name, description, units + character(len=4), intent(in) :: snow_or_soil + integer :: k, klevel + + real(kind=kind_noahmp), allocatable, dimension(:,:,:,:) :: garray + klevel = size(array,2) + + allocate(garray(global_nx,klevel,global_ny,ntile)) + + call write_io_real3d_mosaic(array,garray,klevel,ntile) + if(my_id .eq. io_id) then + call add_to_output_3d_mosaic( garray, name, ntile, description, units, snow_or_soil ) + endif + deallocate(garray) + + end subroutine add_to_output_3d_mpp_mosaic +#endif + + subroutine add_to_output_2d_float_mosaic ( array, name, ntile, description, units ) + implicit none + integer, intent(in) :: ntile + real(kind=kind_noahmp), dimension(:,:,:), intent(in) :: array + character(len=*), intent(in) :: name, description, units + integer :: ixpar, jxpar, nxpar + + if (define_mode_remember) then + call make_var_att_2d_mosaic ( ncid_remember , dimid_ix_remember , dimid_jx_remember , dimid_nx_remember, & + dimid_times_remember, NF90_FLOAT , trim(name) , trim(description) , trim(units) ) + else + ixpar = size(array,1) + jxpar = size(array,2) + nxpar = size(array,3) + + call put_var_2d_mosaic (ncid_remember , output_count_remember+1 , vegtyp_remember , iswater_remember , & + ixpar , jxpar , nxpar, xstartpar_remember , trim(name) , array, .false. ) + endif + end subroutine add_to_output_2d_float_mosaic + +!--------------------------------------------------------------------------------------------------------- +!--------------------------------------------------------------------------------------------------------- + + subroutine add_to_output_2d_integer_mosaic ( array, name, ntile, description, units ) + implicit none + integer, intent(in) :: ntile + integer, dimension(:,:,:), intent(in) :: array + character(len=*), intent(in) :: name, description, units + integer :: ixpar, jxpar, nxpar + + if (define_mode_remember) then + call make_var_att_2d_mosaic ( ncid_remember , dimid_ix_remember , dimid_jx_remember , dimid_nx_remember , & + dimid_times_remember , NF90_INT , trim(name) , trim(description) , trim(units) ) + else + ixpar = size(array,1) + jxpar = size(array,2) + nxpar = size(array,3) + + call put_var_int_mosaic (ncid_remember , output_count_remember+1 , vegtyp_remember , iswater_remember , & + ixpar , jxpar , nxpar , xstartpar_remember , trim(name) , array ) + endif + end subroutine add_to_output_2d_integer_mosaic + +!--------------------------------------------------------------------------------------------------------- +!--------------------------------------------------------------------------------------------------------- + + subroutine add_to_output_3d_mosaic ( array, name, ntile, description, units, snow_or_soil ) + implicit none + integer, intent(in) :: ntile + real(kind=kind_noahmp), dimension(:,:,:,:), intent(in) :: array + character(len=*), intent(in) :: name, description, units + character(len=4), intent(in) :: snow_or_soil + integer :: ixpar, jxpar, kxpar, nxpar + integer :: zdimid + + if (define_mode_remember) then + if (snow_or_soil == "SOIL") then + zdimid = dimid_layers_remember + elseif (snow_or_soil == "SNOW") then + zdimid = dimid_snow_layers_remember + elseif (snow_or_soil == "RADN") then + zdimid = dimid_numrad_layers_remember + else + write(*,'("SNOW_OR_SOIL unrecognized: ", A)') adjustl(trim(snow_or_soil)) + stop "SNOW_OR_SOIL" + endif + call make_var_att_3d_mosaic ( ncid_remember , dimid_ix_remember , dimid_jx_remember , dimid_nx_remember , & + dimid_times_remember , NF90_FLOAT , zdimid, trim(name) , trim(description) , trim(units) ) + else + + ixpar = size(array,1) + kxpar = size(array,2) + jxpar = size(array,3) + nxpar = size(array,4) + + call put_var_3d_mosaic (ncid_remember , output_count_remember+1 , vegtyp_remember , iswater_remember , & + ixpar , jxpar , nxpar , xstartpar_remember , kxpar, trim(name) , array ) + endif + end subroutine add_to_output_3d_mosaic + +!----------------------------------------------------------------------------------------- +!----------------------------------------------------------------------------------------- + + subroutine ReadMosaicTileFrac(wrfinput_flnm, & ! in + xstart, xend, & ! in + ystart, yend, & ! in + NumberLulcCat, & ! in + SubGrdFracName, & ! in + SubGrdFrac) ! out + + implicit none + character(len=*), intent(in) :: wrfinput_flnm + integer, intent(in) :: xstart, xend, ystart, yend, NumberLulcCat + real(kind=kind_noahmp), dimension(xstart:xend,ystart:yend,1:NumberLulcCat), intent(out) :: SubGrdFrac + character(len=24) :: name + character(len=256) :: units + integer :: ierr + integer :: iret + integer :: ncid + integer :: rank + integer :: iltype + integer :: varid + character(len=24), intent(in) :: SubGrdFracName + real(kind=kind_noahmp), dimension(xstart:xend,ystart:yend,1:NumberLulcCat) :: xdum + +#ifdef _PARALLEL_ + call MPI_COMM_RANK(MPI_COMM_WORLD, rank, ierr) + if (ierr /= MPI_SUCCESS) stop "MPI_COMM_RANK" +#else + rank = 0 +#endif + + + ! Open the NetCDF file. + if (rank == 0) write(*,'("wrfinput_flnm: ''", A, "''")') trim(wrfinput_flnm) +#ifdef _PARALLEL_ + ierr = nf90_open_par(wrfinput_flnm, NF90_NOWRITE, MPI_COMM_WORLD, MPI_INFO_NULL, ncid) +#else + ierr = nf90_open(wrfinput_flnm, NF90_NOWRITE, ncid) +#endif + if (ierr /= 0) then + write(*,'("ReadMosaicTileFrac: Problem opening wrfinput file: ''", A, "''")') trim(wrfinput_flnm) +#ifdef _PARALLEL_ + call mpi_finalize(ierr) + if (ierr /= 0) write(*, '("Problem with MPI_finalize.")') +#endif + stop + endif + + ! Get subgrid fraction + name = trim(SubGrdFracName)! "LANDUSEF" + iret = nf90_inq_varid(ncid, name, varid) + if (iret == 0) then + + ierr = nf90_get_var(ncid, varid, xdum, start=(/xstart,ystart,1/), count=(/xend-xstart+1,yend-ystart+1,NumberLulcCat/)) + + do iltype = 1,NumberLulcCat + SubGrdFrac(:,:,iltype) = xdum(:,:,iltype) + end do + + else + + write(*,*) "MODULE_HRLDAS_NETCDF_IO: Problem finding variable '"//trim(name)//"' in NetCDF file. Using default values." + + endif + + ! Close the NetCDF file + ierr = nf90_close(ncid) + if (ierr /= 0) stop "MODULE_HRLDAS_NETCDF_IO: ReadMosaicTileFrac: NF90_CLOSE" + + end subroutine ReadMosaicTileFrac + !--------------------------------------------------------------------------------------------------------- !--------------------------------------------------------------------------------------------------------- diff --git a/hrldas/MPP/mpp_land.F b/hrldas/MPP/mpp_land.F index 2135ae6..dd57d90 100644 --- a/hrldas/MPP/mpp_land.F +++ b/hrldas/MPP/mpp_land.F @@ -728,6 +728,40 @@ subroutine write_IO_real(in_buff,out_buff) return end subroutine write_IO_real +! NoahMP Mosaic + + subroutine write_IO_real_mosaic(in_buff,out_buff,ntile) + implicit none +! the IO node will receive the data from the rest process. + integer ntile, n + real,dimension(:,:,:) :: in_buff, out_buff + do n = 1, ntile + call write_IO_real(in_buff(:,:,n),out_buff(:,:,n)) + end do + end subroutine write_IO_real_mosaic + + subroutine write_IO_real3d_mosaic(in_buff,out_buff,klevel,ntile) + implicit none +! the IO node will receive the data from the rest process. + integer klevel, k, ntile + real,dimension(:,:,:,:) :: in_buff, out_buff + do k = 1, klevel + call write_IO_real_mosaic(in_buff(:,k,:,:),out_buff(:,k,:,:),ntile) + end do + end subroutine write_IO_real3d_mosaic + + subroutine write_io_int_mosaic(in_buff,out_buff,ntile) + implicit none +! the IO node will receive the data from the rest process. + integer ntile, n + integer,dimension(:,:,:) :: in_buff, out_buff + do n = 1, ntile + call write_io_int(in_buff(:,:,n),out_buff(:,:,n)) + end do + end subroutine write_io_int_mosaic + +! NoahMP Mosaic end + subroutine write_IO_RT_real(in_buff,out_buff) ! the IO node will receive the data from the rest process. real,dimension(:,:) :: in_buff, out_buff diff --git a/hrldas/run/Makefile b/hrldas/run/Makefile index 8c57bff..3901d59 100644 --- a/hrldas/run/Makefile +++ b/hrldas/run/Makefile @@ -22,6 +22,11 @@ OBJS_NoahMP = ../IO_code/module_NoahMP_hrldas_driver.o OBJS = \ ../IO_code/main_hrldas_driver.o \ ../IO_code/module_hrldas_netcdf_io.o \ + ../IO_code/MosaicAverageMod.o\ + ../IO_code/ReadNoahmpMosaicRestartMod.o\ + ../IO_code/WriteNoahmpMosaicGridAverageOutputMod.o\ + ../IO_code/WriteNoahmpMosaicRestartMod.o\ + ../IO_code/WriteNoahmpMosaicSubgridOutputMod.o\ ../../urban/wrf/module_bep_bem_helper.o \ ../../urban/wrf/module_sf_urban.o \ ../../urban/wrf/module_sf_bep.o \ @@ -54,6 +59,7 @@ OBJS = \ ../../noahmp/drivers/hrldas/WaterVarInTransferMod.o \ ../../noahmp/drivers/hrldas/BiochemVarInTransferMod.o \ ../../noahmp/drivers/hrldas/PedoTransferSR2006Mod.o \ + ../../noahmp/drivers/hrldas/NoahmpMosaicSortTileCatMod.o\ ../../noahmp/utility/Machine.o \ ../../noahmp/utility/CheckNanMod.o \ ../../noahmp/utility/PiecewiseLinearInterp1dMod.o \ diff --git a/hrldas/run/namelist.hrldas_example b/hrldas/run/namelist.hrldas_example index 28770ad..d1173d9 100644 --- a/hrldas/run/namelist.hrldas_example +++ b/hrldas/run/namelist.hrldas_example @@ -62,6 +62,13 @@ TILE_DRAINAGE_OPTION = 0 WETLAND_OPTION = 0 +! the following are options for NoahMP Mosaic Scheme +MOSAIC_SCHEME_OPTION = 0 +MOSAIC_FRACT_NAME = "LANDUSEF" +MOSAIC_NUMBER_OF_CATEGORIES = 21 +MOSAIC_NUMBER_OF_TILES = 5 +MOSAIC_WRITE_OUTPUT = 0 + ! the following options only work for SNICAR snow albedo scheme SNICAR_BANDNUMBER_OPTION = 1 SNICAR_SOLARSPEC_OPTION = 1 diff --git a/hrldas/user_build_options b/hrldas/user_build_options new file mode 100644 index 0000000..538a858 --- /dev/null +++ b/hrldas/user_build_options @@ -0,0 +1,27 @@ + +#============================================================================================= +# Options for Linux with gnu gfortran MPI +# Please change the library paths according to your computer setup +#============================================================================================= + + COMPILERF90 = mpif90 + MPPFLAG = YES + FREESOURCE = -ffree-form -ffree-line-length-none + F90FLAGS = -g -fconvert=big-endian -fbounds-check -fno-range-check + MODFLAG = -I ../MPP + HYDRO_LIB = ../MPP/mpp_land.o ../MPP/CPL_WRF.o + LDFLAGS = + CPP = cpp + CPPFLAGS = -P -traditional -DMPP_LAND -D_GFORTRAN_ # -DSPATIAL_SOIL + LIBS = + LIBJASPER = -L/opt/ohpc/pub/libs/gnu9/spack/0.21.2/opt/spack/linux-rocky8-x86_64_v4/gcc-9.4.0/jasper-1.900.1-fvgz2uy46evsmvewm7mav3tsg63m4kqw/lib -ljasper + INCJASPER = -I/opt/ohpc/pub/libs/gnu9/spack/0.21.2/opt/spack/linux-rocky8-x86_64_v4/gcc-9.4.0/jasper-1.900.1-fvgz2uy46evsmvewm7mav3tsg63m4kqw/include + NETCDFMOD = -I/home/prasanth/local/netcdf/include + NETCDFLIB = -L/home/prasanth/local/netcdf/lib -lnetcdf -lnetcdff +# NETCDFMOD = -I/opt/apps/netcdf/4.8.1/include +# NETCDFLIB = -L/opt/apps/netcdf/4.8.1/lib -lnetcdf -lnetcdff + BZIP2 = NO +# BZIP2_INCLUDE = -I/usr/include +# BZIP2_LIB = -L/usr/lib64 -lbz2 + RM = rm -f + CC = cc diff --git a/noahmp b/noahmp index 232fc41..40ddce9 160000 --- a/noahmp +++ b/noahmp @@ -1 +1 @@ -Subproject commit 232fc4155018bb8de923abd9bc77830b95067f28 +Subproject commit 40ddce96463ae2d25e0c79668c83882f943f1b0a