Skip to content

Commit

Permalink
Added minimal set of time series statistics for the new LSM
Browse files Browse the repository at this point in the history
  • Loading branch information
bartvstratum committed Jun 30, 2020
1 parent 6b5d8be commit 3261422
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 6 deletions.
16 changes: 12 additions & 4 deletions src/modlsm.f90
Original file line number Diff line number Diff line change
Expand Up @@ -180,17 +180,25 @@ end subroutine create_soil_grid
subroutine allocate_fields
use modglobal, only : i2, j2
use modsurfdata, only : &
tsoil, phiw, lambda, lambdas, gammas
tsoil, phiw, lambda, lambdas, gammas, &
H, LE, G0, Qnet
implicit none

! Allocate soil variables
allocate(soil_index(i2, j2, kmax_soil))
allocate(tsoil (i2, j2, kmax_soil))
allocate(phiw (i2, j2, kmax_soil))

allocate(lambda (i2, j2, kmax_soil))
allocate(lambdas (i2, j2, kmax_soil))
allocate(gammas (i2, j2, kmax_soil))
! Soil conductivity and diffusivity
allocate(lambda (i2, j2, kmax_soil))
allocate(lambdas(i2, j2, kmax_soil))
allocate(gammas (i2, j2, kmax_soil))

! Tile averaged surface fluxes
allocate(Qnet (i2, j2))
allocate(H (i2, j2))
allocate(LE (i2, j2))
allocate(G0 (i2, j2))

! Allocate the tiled variables
call allocate_tile(tile_lv)
Expand Down
35 changes: 33 additions & 2 deletions src/modtimestat.f90
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,10 @@ subroutine inittimestat
endif

if (lnetcdf) then
if(isurf == 1) then
if (isurf == 1) then
nvar = 32
else if (isurf == 11) then
nvar = 25
else
nvar = 21
end if
Expand Down Expand Up @@ -271,7 +273,13 @@ subroutine inittimestat
call ncinfo(ncname(30,:),'Wl','Liquid water reservoir','m','time')
call ncinfo(ncname(31,:),'rssoil','Soil evaporation resistance','s/m','time')
call ncinfo(ncname(32,:),'rsveg','Vegitation resistance','s/m','time')
else if (isurf==11) then
call ncinfo(ncname(22,:),'Qnet','Net radiation','W/m^2','time')
call ncinfo(ncname(23,:),'H','Sensible heat flux','W/m^2','time')
call ncinfo(ncname(24,:),'LE','Latent heat flux','W/m^2','time')
call ncinfo(ncname(25,:),'G','Ground heat flux','W/m^2','time')
end if

call open_nc(fname, ncid,nrec)
if(nrec==0) call define_nc( ncid, NVar, ncname)
end if
Expand Down Expand Up @@ -344,7 +352,8 @@ subroutine timestat
use modsurfdata,only : wtsurf, wqsurf, isurf,ustar,thlflux,qtflux,z0,oblav,qts,thls,&
Qnet, H, LE, G0, rs, ra, tskin, tendskin, &
cliq,rsveg,rssoil,Wl, &
lhetero, xpatches, ypatches, qts_patch, wt_patch, wq_patch, thls_patch,obl,z0mav_patch, wco2av, Anav, Respav,gcco2av
lhetero, xpatches, ypatches, qts_patch, wt_patch, wq_patch, &
thls_patch,obl,z0mav_patch, wco2av, Anav, Respav,gcco2av
use modsurface, only : patchxnr,patchynr
use mpi
use modmpi, only : my_real,mpi_sum,mpi_max,mpi_min,comm3d,mpierr,myid
Expand Down Expand Up @@ -757,6 +766,22 @@ subroutine timestat
rssoil_patch = patchsum_1level(rssoil (2:i1, 2:j1)) * (xpatches*ypatches/ijtot)
tskin_patch = patchsum_1level(tskin (2:i1, 2:j1)) * (xpatches*ypatches/ijtot)
endif

else if(isurf == 11) then
Qnetavl = sum(Qnet(2:i1,2:j1))
Havl = sum(H(2:i1,2:j1))
LEavl = sum(LE(2:i1,2:j1))
G0avl = sum(G0(2:i1,2:j1))

call MPI_ALLREDUCE(Qnetavl, Qnetav, 1, MY_REAL,MPI_SUM, comm3d,mpierr)
call MPI_ALLREDUCE(Havl, Hav, 1, MY_REAL,MPI_SUM, comm3d,mpierr)
call MPI_ALLREDUCE(LEavl, LEav, 1, MY_REAL,MPI_SUM, comm3d,mpierr)
call MPI_ALLREDUCE(G0avl, G0av, 1, MY_REAL,MPI_SUM, comm3d,mpierr)

Qnetav = Qnetav / ijtot
Hav = Hav / ijtot
LEav = LEav / ijtot
G0av = G0av / ijtot
end if

! 9.8 write the results to output file
Expand Down Expand Up @@ -818,6 +843,7 @@ subroutine timestat
gcco2av
close(ifoutput)
end if

if (lnetcdf) then
vars( 1) = rtimee
vars( 2) = cc
Expand Down Expand Up @@ -856,6 +882,11 @@ subroutine timestat
vars(30) = wlav
vars(31) = rssoilav
vars(32) = rsvegav
else if (isurf == 11) then
vars(22) = Qnetav
vars(23) = Hav
vars(24) = LEav
vars(25) = G0av
end if

call writestat_nc(ncid,nvar,ncname,vars,nrec,.true.)
Expand Down

0 comments on commit 3261422

Please sign in to comment.