2 ! Author(s)/Contact(s):
5 ! <brief list of changes to this source file>
8 ! Parameters: <Specify typical arguments passed>
10 ! <list file names and briefly describe the data they include>
12 ! <list file names and briefly describe the information they include>
15 ! <list exit condition or error codes returned >
16 ! If appropriate, descriptive troubleshooting instructions or
17 ! likely causes for failures could be mentioned here with the
18 ! appropriate error code
20 ! User controllable options: <if applicable>
22 module module_WRF_HYDRO
25 use module_mpp_land, only: global_nx, global_ny, decompose_data_real, &
26 write_io_real, my_id, mpp_land_bcast_real1, IO_id, &
27 mpp_land_bcast_real, mpp_land_bcast_int1
29 use module_HYDRO_drv, only: HYDRO_ini, HYDRO_exe
31 use module_rt_data, only: rt_domain
32 use module_CPL_LAND, only: cpl_outdate
33 use config_base, only: nlst
34 USE module_domain, ONLY : domain, domain_clock_get
38 !yw added for check soil moisture and soiltype
39 integer :: checkSOIL_flag
42 ! added to consider the adaptive time step from WRF model.
51 !wrf_cpl_HYDRO_finescale will not call the off-line lsm
52 subroutine wrf_cpl_HYDRO_finescale(HYDRO_dt,grid,its,ite,jts,jte)
53 use module_NoahMP_hrldas_driver, only: noah_timestep , land_driver_ini
55 TYPE ( domain ), INTENT(INOUT) :: grid
56 integer its, ite, jts, jte, ij
69 !output flux and state variable
75 if(HYDRO_dt .le. 0) then
76 write(6,*) "Warning: HYDRO_dt <= 0 from land input. set it to be 1 seconds."
83 nlst(did)%dt = HYDRO_dt
86 if(.not. RT_DOMAIN(did)%initialized) then
89 nlst(did)%nsoil = grid%num_soil_layers
92 call mpp_land_bcast_int1 (nlst(did)%nsoil)
94 allocate(nlst(did)%zsoil8(nlst(did)%nsoil))
95 if(grid%zs(1) < 0) then
96 nlst(did)%zsoil8(1:nlst(did)%nsoil) = grid%zs(1:nlst(did)%nsoil)
98 nlst(did)%zsoil8(1:nlst(did)%nsoil) = -1*grid%zs(1:nlst(did)%nsoil)
101 CALL domain_clock_get( grid, current_timestr=cpl_outdate)
102 nlst(did)%startdate(1:19) = cpl_outdate(1:19)
103 nlst(did)%olddate(1:19) = cpl_outdate(1:19)
107 call land_driver_ini(nn,its,ite,jts,jte)
110 write(6,*) "sf_surface_physics is ", grid%sf_surface_physics
112 nlst(did)%startdate(1:19) = cpl_outdate(1:19)
113 nlst(did)%olddate(1:19) = cpl_outdate(1:19)
115 nlst(did)%dt = HYDRO_dt
116 noah_timestep = nlst(did)%dt
118 if(nlst(did)%dtrt .lt. HYDRO_dt) then
119 nlst(did)%dtrt = HYDRO_dt
122 mm = HYDRO_dt/nlst(did)%dtrt
123 if(mm*nlst(did)%dtrt .lt. HYDRO_dt) nlst(did)%dtrt = HYDRO_dt/mm
127 dtrt0 = nlst(did)%dtrt
130 if((mm0*nlst(did)%dtrt) .ne. HYDRO_dt) then ! WRF model time step changed.
131 if(dtrt0 .lt. HYDRO_dt) then
132 nlst(did)%dtrt = HYDRO_dt
136 if(mm*dtrt0 .lt. HYDRO_dt) nlst(did)%dtrt = HYDRO_dt/mm
142 write(6,*) "mm, nlst(did)%dt = ",mm, nlst(did)%dt
145 ! get forcing data from WRF
146 call wrf2l_finemesh(grid,its,ite,jts,jte)
148 call HYDRO_land_finemesh_exe(itime)
150 call l_finemesh2wrf(grid)
152 RT_DOMAIN(did)%initialized = .true.
154 end subroutine wrf_cpl_HYDRO_finescale
156 ! get the forcing data from WRF
157 subroutine wrf2l_finemesh(,its,ite,jts,jte, T_PHY0,U_PHY0,V_PHY0,p_hyd_w0,RAINBL0,QV_CURR0,LAI0,VEGFRA0, &
159 use module_NoahMP_hrldas_driver, only: P8W, T_PHY, U_PHY, V_PHY, QV_CURR, RAINBL_tmp, LAI, VEGFRA, finemesh,finemesh_factor, &
163 real, domain(:,:),INTENT(IN) :: T_PHY0,U_PHY0,V_PHY0,p_hyd_w0,RAINBL0,QV_CURR0,LAI0,VEGFRA0, &
164 emiss0, albedo0, TSK0,HFX0, QFX0,LH0,GRDFLX0,SMSTAV0,SMSTOT0,SFCRUNOFF0, UDRUNOFF0, SNOWC0, SMOIS0, SH2O0, &
165 TSLB0, SNOW0,SNOWH0,CANWAT0,ACSNOM0,ACSNOW0,QSFC0,ISNOWXY0,TVXY0,TGXY0,CANICEXY0,CANLIQXY0,EAHXY0,TAHXY0,CMXY0, &
166 CHXY0,FWETXY0,SNEQVOXY0,ALBOLDXY0,QSNOWXY0,WSLAKEXY0,ZWTXY0,WAXY0,WTXY0,TSNOXY0,ZSNSOXY0,SNICEXY0,SNLIQXY0, &
167 LFMASSXY0,RTMASSXY0,STMASSXY0,WOODXY0,STBLCPXY0,FASTCPXY0,XLAIXY0,XSAIXY0,TAUSSXY0,SMOISEQ0,SMCWTDXY0,DEEPRECHXY0, &
170 integer, intent(in):: its,ite,jts,jte
171 call wrf2finegrid(T_PHY0(its:ite,jts:jte), T_PHY(:,1,:),ite-its+1,jte-jts+1,finemesh_factor)
172 call wrf2finegrid(U_PHY0(its:ite,jts:jte), U_PHY(:,1,:),ite-its+1,jte-jts+1,finemesh_factor)
173 call wrf2finegrid(V_PHY0(its:ite,jts:jte), V_PHY(:,1,:),ite-its+1,jte-jts+1,finemesh_factor)
174 call wrf2finegrid(p_hyd_w0(its:ite,jts:jte), P8W(:,1,:),ite-its+1,jte-jts+1,finemesh_factor)
175 call wrf2finegrid(RAINBL0(its:ite,jts:jte), RAINBL_tmp,ite-its+1,jte-jts+1,finemesh_factor)
176 call wrf2finegrid(QV_CURR0(its:ite,jts:jte), QV_CURR(:,1,:),ite-its+1,jte-jts+1,finemesh_factor)
177 ! update some varialbes.
178 if(finemesh .ne. 1) then ! update the LAI and VEGFRA for each time step. Note: this is from the WRF grid.
179 call wrf2finegrid(albedo0(its:ite,jts:jte), albedo)
180 call wrf2finegrid(emiss0(its:ite,jts:jte), emiss)
181 call wrf2finegrid(LAI0(its:ite,jts:jte), LAI)
182 call wrf2finegrid(VEGFRA0(its:ite,jts:jte), VEGFRA)
184 end subroutine wrf2l_finemesh
186 subroutine l_finemesh2wrf(T_PHY0,U_PHY0,V_PHY0,p_hyd_w0,RAINBL0,QV_CURR0,LAI0,VEGFRA0,its,ite,jts,jte)
187 use module_NoahMP_hrldas_driver, only: P8W, T_PHY, U_PHY, V_PHY, QV_CURR, RAINBL_tmp, LAI, VEGFRA, finemesh,finemesh_factor
189 !variable for output only
190 real,dimension(:,:), intent(out):: T2MVXY0,T2MBXY0,Q2MVXY0,Q2MBXY0,TRADXY0,NEEXY0,GPPXY0,NPPXY0,FVEGXY0,RUNSFXY0, &
191 RUNSBXY0,ECANXY0,EDIRXY0,ETRANXY0,FSAXY0,&
192 FIRAXY0,APARXY0,PSNXY0,SAVXY0,SAGXY0,RSSUNXY0,RSSHAXY0,BGAPXY0,WGAPXY0,TGVXY0,TGBXY0,CHVXY0,CHBXY0,SHGXY0,SHCXY0,SHBXY0, &
193 EVGXY0,EVBXY0,GHVXY0,GHBXY0,IRGXY0,IRCXY0,IRBXY0,TRXY0,EVCXY0,CHLEAFXY0,CHUCXY0,CHV2XY0,CHB2XY0
195 call finegrid2wrf(T2MVXY,T2MVXY0(its:ite,jts:jte),ite-its+1,jte-jts+1,finemesh_factor)
196 call finegrid2wrf(T2MBXY,tt0(its:ite,jts:jte),ite-its+1,jte-jts+1,finemesh_factor)
197 call finegrid2wrf(FVEGXY,FVEGXY0(its:ite,jts:jte),ite-its+1,jte-jts+1,finemesh_factor)
198 call finegrid2wrf(Q2MVXY,Q2MVXY0(its:ite,jts:jte),ite-its+1,jte-jts+1,finemesh_factor)
199 call finegrid2wrf(Q2MBXY,Q2MBXY0(its:ite,jts:jte),ite-its+1,jte-jts+1,finemesh_factor)
200 if(finemesh .ne. 1) then
201 call finegrid2wrf(TRADXY,TRADXY0(its:ite,jts:jte),ite-its+1,jte-jts+1,finemesh_factor)
202 call finegrid2wrf(NEEXY,NEEXY0(its:ite,jts:jte),ite-its+1,jte-jts+1,finemesh_factor)
203 call finegrid2wrf(GPPXY,GPPXY0(its:ite,jts:jte),ite-its+1,jte-jts+1,finemesh_factor)
204 call finegrid2wrf(NPPXY,NPPXY0(its:ite,jts:jte),ite-its+1,jte-jts+1,finemesh_factor)
205 call finegrid2wrf(RUNSFXY,RUNSFXY0(its:ite,jts:jte),ite-its+1,jte-jts+1,finemesh_factor)
206 call finegrid2wrf(RUNSBXY,RUNSBXY0(its:ite,jts:jte),ite-its+1,jte-jts+1,finemesh_factor)
207 call finegrid2wrf(ECANXY,ECANXY0(its:ite,jts:jte),ite-its+1,jte-jts+1,finemesh_factor)
208 call finegrid2wrf(EDIRXY,EDIRXY0(its:ite,jts:jte),ite-its+1,jte-jts+1,finemesh_factor)
209 call finegrid2wrf(ETRANXY,ETRANXY0(its:ite,jts:jte),ite-its+1,jte-jts+1,finemesh_factor)
210 call finegrid2wrf(FSAXY,FSAXY0(its:ite,jts:jte),ite-its+1,jte-jts+1,finemesh_factor)
211 call finegrid2wrf(FIRAXY,FIRAXY0(its:ite,jts:jte),ite-its+1,jte-jts+1,finemesh_factor)
212 call finegrid2wrf(APARXY,APARXY0(its:ite,jts:jte),ite-its+1,jte-jts+1,finemesh_factor)
213 call finegrid2wrf(PSNXY,PSNXY0(its:ite,jts:jte),ite-its+1,jte-jts+1,finemesh_factor)
214 call finegrid2wrf(SAVXY,SAVXY0(its:ite,jts:jte),ite-its+1,jte-jts+1,finemesh_factor)
215 call finegrid2wrf(SAGXY,SAGXY0(its:ite,jts:jte),ite-its+1,jte-jts+1,finemesh_factor)
216 call finegrid2wrf(RSSUNXY,RSSUNXY0(its:ite,jts:jte),ite-its+1,jte-jts+1,finemesh_factor)
217 call finegrid2wrf(RSSHAXY,RSSHAXY0(its:ite,jts:jte),ite-its+1,jte-jts+1,finemesh_factor)
218 call finegrid2wrf(BGAPXY,BGAPXY0(its:ite,jts:jte),ite-its+1,jte-jts+1,finemesh_factor)
219 call finegrid2wrf(WGAPXY,WGAPXY0(its:ite,jts:jte),ite-its+1,jte-jts+1,finemesh_factor)
220 call finegrid2wrf(TGVXY,TGVXY0(its:ite,jts:jte),ite-its+1,jte-jts+1,finemesh_factor)
222 call finegrid2wrf(TGBXY,TGBXY0(its:ite,jts:jte),ite-its+1,jte-jts+1,finemesh_factor)
223 call finegrid2wrf(CHVXY,CHVXY0(its:ite,jts:jte),ite-its+1,jte-jts+1,finemesh_factor)
224 call finegrid2wrf(CHBXY,CHBXY0(its:ite,jts:jte),ite-its+1,jte-jts+1,finemesh_factor)
225 call finegrid2wrf(SHGXY,SHGXY0(its:ite,jts:jte),ite-its+1,jte-jts+1,finemesh_factor)
226 call finegrid2wrf(SHCXY,SHCXY0(its:ite,jts:jte),ite-its+1,jte-jts+1,finemesh_factor)
227 call finegrid2wrf(SHBXY,SHBXY0(its:ite,jts:jte),ite-its+1,jte-jts+1,finemesh_factor)
228 call finegrid2wrf(EVGXY,EVGXY0(its:ite,jts:jte),ite-its+1,jte-jts+1,finemesh_factor)
229 call finegrid2wrf(EVBXY,EVBXY0(its:ite,jts:jte),ite-its+1,jte-jts+1,finemesh_factor)
230 call finegrid2wrf(GHVXY,GHVXY0(its:ite,jts:jte),ite-its+1,jte-jts+1,finemesh_factor)
231 call finegrid2wrf(GHBXY,GHBXY0(its:ite,jts:jte),ite-its+1,jte-jts+1,finemesh_factor)
232 call finegrid2wrf(IRGXY,IRGXY0(its:ite,jts:jte),ite-its+1,jte-jts+1,finemesh_factor)
233 call finegrid2wrf(IRCXY,IRCXY0(its:ite,jts:jte),ite-its+1,jte-jts+1,finemesh_factor)
234 call finegrid2wrf(IRBXY,IRBXY0(its:ite,jts:jte),ite-its+1,jte-jts+1,finemesh_factor)
235 call finegrid2wrf(TRXY,TRXY0(its:ite,jts:jte),ite-its+1,jte-jts+1,finemesh_factor)
236 call finegrid2wrf(EVCXY,EVCXY0(its:ite,jts:jte),ite-its+1,jte-jts+1,finemesh_factor)
237 call finegrid2wrf(CHLEAFXY,CHLEAFXY0(its:ite,jts:jte),ite-its+1,jte-jts+1,finemesh_factor)
238 call finegrid2wrf(CHUCXY,CHUCXY0(its:ite,jts:jte),ite-its+1,jte-jts+1,finemesh_factor)
239 call finegrid2wrf(CHV2XY,CHV2XY0(its:ite,jts:jte),ite-its+1,jte-jts+1,finemesh_factor)
240 call finegrid2wrf(CHB2XY,CHB2XY0(its:ite,jts:jte),ite-its+1,jte-jts+1,finemesh_factor)
242 end subroutine l_finemesh2wrf
244 subroutine wrf2finegrid(wrfGrid,fineGrid,ix,jx,AGGFACTRT)
246 real, dimension(:,:), intent(in)::wrfGrid
247 real, dimension(:,:), intent(out)::fineGrid
248 integer:: i,j,ii,jj,ix,jx, AGGFACTRT
251 do ii =AGGFACTRT-1,0,-1
252 do jj =AGGFACTRT-1,0,-1
255 fineGrid(ixxrt,jyyrt) = wrfGrid(i,j)
258 enddo ! end do loop for ix
259 enddo ! end do loop for jx
260 end subroutine wrf2finegrid
262 subroutine finegrid2wrf(fineGrid,wrfGrid,ix,jx,AGGFACTRT)
264 real, dimension(:,:), intent(out)::wrfGrid
265 real, dimension(:,:), intent(in)::fineGrid
266 integer:: i,j,ii,jj,ix,jx, AGGFACTRT
270 do ii =AGGFACTRT-1,0,-1
271 do jj =AGGFACTRT-1,0,-1
274 wrfGrid(i,j) = wrfGrid(i,j) + fineGrid(ixxrt,jyyrt)
277 wrfGrid(i,j) = wrfGrid(i,j) / (AGGFACTRT*AGGFACTRT)
278 enddo ! end do loop for ix
279 enddo ! end do loop for jx
280 end subroutine finegrid2wrf
284 !program drive rtland
285 ! This subroutine will be used if the 4-layer Noah lsm is not used.
286 subroutine wrf2lsm (z1,v1,kk1,z,vout,ix,jx,kk,vegtyp)
287 ! input: z1,v1,kk1,z,ix,jx,kk
289 ! interpolate based on soil layer: z1 and z
290 ! z : soil layer of output variable.
291 ! z1: array of soil layers of input variable.
294 integer:: kk1, ix,jx,kk, vegtyp(ix,jx)
295 real :: z1(kk1), z(kk), v1(ix,kk1,jx),vout(ix,jx,kk)
301 call interpLayer(Z1,v1(i,1:kk1,j),kk1,Z(k),vout(i,j,k))
305 end subroutine wrf2lsm
307 ! This subroutine will be used if the 4-layer Noah lsm is not used.
308 subroutine lsm2wrf (z1,v1,kk1,z,vout,ix,jx,kk,vegtyp)
309 ! input: z1,v1,kk1,z,ix,jx,kk
311 ! interpolate based on soil layer: z1 and z
312 ! z : soil layer of output variable.
313 ! z1: array of soil layers of input variable.
316 integer:: kk1, ix,jx,kk, vegtyp(ix,jx)
317 real :: z1(kk1), z(kk), v1(ix,jx,kk1),vout(ix,kk,jx)
323 call interpLayer(Z1,v1(i,j,1:kk1),kk1,Z(k),vout(i,k,j))
327 end subroutine lsm2wrf
329 subroutine interpLayer(inZ,inV,inK,outZ,outV)
333 real:: inV(inK),inZ(inK)
334 real:: outV, outZ, w1, w2
336 if(outZ .le. inZ(1)) then
337 w1 = (inZ(2)-outZ)/(inZ(2)-inZ(1))
338 w2 = (inZ(1)-outZ)/(inZ(2)-inZ(1))
339 outV = inV(1)*w1-inV(2)*w2
341 elseif(outZ .ge. inZ(inK)) then
342 w1 = (outZ-inZ(inK-1))/(inZ(inK)-inZ(inK-1))
343 w2 = (outZ-inZ(inK)) /(inZ(inK)-inZ(inK-1))
344 outV = inV(inK)*w1 -inV(inK-1)* w2
348 if((inZ(k) .ge. outZ).and.(inZ(k-1) .le. outZ) ) then
351 w1 = (outZ-inZ(k1))/(inZ(k2)-inZ(k1))
352 w2 = (inZ(k2)-outZ)/(inZ(k2)-inZ(k1))
353 outV = inV(k2)*w1 + inV(k1)*w2
358 end subroutine interpLayer
360 subroutine lsm_wrf_input(did,vegtyp,soltyp,ix,jx)
364 integer :: i,j, nn, ix,jx
365 integer, dimension(ix,jx) :: soltyp, vegtyp
366 real, dimension(leng) :: xdum1, MAXSMC,refsmc,wltsmc
369 where(soltyp == 14) VEGTYP = 16
370 where(VEGTYP == 16 ) soltyp = 14
372 RT_DOMAIN(did)%VEGTYP = vegtyp
374 ! input OV_ROUGH from OVROUGH.TBL
376 if(my_id .eq. IO_id) then
380 open(71,file="HYDRO.TBL", form="formatted")
385 read(71,*) RT_DOMAIN(did)%OV_ROUGH(i)
387 !read parameter for LKSAT
391 read(71,*) xdum1(i), MAXSMC(i),refsmc(i),wltsmc(i)
396 open(13, form="formatted")
401 read(13,*) RT_DOMAIN(did)%OV_ROUGH(i)
403 !read parameter for LKSAT
407 read(13,*) xdum1(i), MAXSMC(i),refsmc(i),wltsmc(i)
414 call mpp_land_bcast_real(leng,RT_DOMAIN(did)%OV_ROUGH)
415 call mpp_land_bcast_real(leng,xdum1)
416 call mpp_land_bcast_real(leng,MAXSMC)
417 call mpp_land_bcast_real(leng,refsmc)
418 call mpp_land_bcast_real(leng,wltsmc)
421 rt_domain(did)%lksat = 0.0
422 do j = 1, RT_DOMAIN(did)%jx
423 do i = 1, RT_DOMAIN(did)%ix
424 rt_domain(did)%lksat(i,j) = xdum1(soltyp(i,j) ) * 1000.0
425 IF(rt_domain(did)%VEGTYP(i,j) == 1 ) THEN ! urban
426 rt_domain(did)%SMCMAX1(i,j) = 0.45
427 rt_domain(did)%SMCREF1(i,j) = 0.42
428 rt_domain(did)%SMCWLT1(i,j) = 0.40
430 rt_domain(did)%SMCMAX1(i,j) = MAXSMC(soltyp(I,J))
431 rt_domain(did)%SMCREF1(i,j) = refsmc(soltyp(I,J))
432 rt_domain(did)%SMCWLT1(i,j) = wltsmc(soltyp(I,J))
437 end subroutine lsm_wrf_input
439 end module module_wrf_HYDRO