subroutine stats_prepare implicit none if (lstatsprepared) return lstatsprepared = .true. if(lstatsdump) then call stats_allocate_interp_and_sgs_vel if (ltempeq) call stats_allocate_interp_and_sgs_temp if (lmoist) call stats_allocate_interp_and_sgs_moist if (lrh) call stats_allocate_relative_humidity end if if(ltavg3d .or. lytdump .or. lydump) then if (nsv>0) call stats_allocate_interp_and_sgs_scalar end if if(lstatstavgdump) then !> allocate variables to compute time-averaged quantities call stats_allocate_tavg_vel if (ltdump .or. ltkslicedump) call stats_allocate_tavg_pedestrian_wind if (ltempeq) call stats_allocate_tavg_temp if (lmoist) call stats_allocate_tavg_moist if (lrh) call stats_allocate_tavg_relative_humidity end if if(ltavg3d .or. lytdump) then if (nsv>0) call stats_allocate_tavg_scalar end if !> Variable table of the outputs built from the 3-D accumulators, shared by !> stats_t.xxx.xxx.nc and the time-averaged slice files; kept for the writers. if (ltavg3d) then !> Total numbers of variables to be written tVarsCount = 15 if (ltempeq) tVarsCount = tVarsCount + 7 if (lmoist) tVarsCount = tVarsCount + 5 if (lrh) tVarsCount = tVarsCount + 1 if (nsv>0) tVarsCount = tVarsCount + 6*nsv if ((lchem) .and. (nsv>2)) tVarsCount = tVarsCount + 1 allocate(tVars(tVarsCount,4)) !!> Array to store the variable description of the quantities to be written ctrt = 0 call stats_ncdescription_tavg_vel if (ltempeq) call stats_ncdescription_tavg_temp if (lmoist) call stats_ncdescription_tavg_moist if (lrh) call stats_ncdescription_tavg_relative_humidity if (nsv>0) call stats_ncdescription_tavg_scalar if ((lchem) .and. (nsv>2)) call stats_init_tavg_PSS if (ltdump) call stats_createnc_tavg if (ltislicedump) call stats_createnc_tislice if (ltjslicedump) call stats_createnc_tjslice if (ltkslicedump) call stats_createnc_tkslice end if !> Generate time, y and x averaged NetCDF: stats_xyt.xxx.nc if (lxytdump) then xytVarsCount = 21 if (ltempeq) xytVarsCount = xytVarsCount + 6 if (lmoist) xytVarsCount = xytVarsCount + 6 if (lrh) xytVarsCount = xytVarsCount + 1 allocate(xytVars(xytVarsCount,4)) !!> Array to store the variable description of the quantities to be written ctrxyt = 0 call stats_init_xytavg_vel if (ltempeq) call stats_init_xytavg_temp if (lmoist) call stats_init_xytavg_moist if (lrh) call stats_init_xytavg_relative_humidity call stats_createnc_xytavg deallocate(xytVars) end if !> Generate y and x averaged NetCDF: stats_xy.xxx.nc if (lxydump) then xyVarsCount = 17 if (ltempeq) xyVarsCount = xyVarsCount + 5 if (lmoist) xyVarsCount = xyVarsCount + 5 if (lrh) xyVarsCount = xyVarsCount + 1 allocate(xyVars(xyVarsCount,4)) !!> Array to store the variable description of the quantities to be written ctrxy = 0 call stats_init_xyavg_vel if (ltempeq) call stats_init_xyavg_temp if (lmoist) call stats_init_xyavg_moist if (lrh) call stats_init_xyavg_relative_humidity call stats_createnc_xyavg deallocate(xyVars) end if !> Generate time and y averaged NetCDF: stats_yt.xxx.xxx.nc if (lytdump) then ytVarsCount = 12 if (ltempeq) ytVarsCount = ytVarsCount + 6 if (lmoist) ytVarsCount = ytVarsCount + 6 if (lrh) ytVarsCount = ytVarsCount + 1 if (nsv>0) ytVarsCount = ytVarsCount + 5*nsv allocate(ytVars(ytVarsCount,4)) !!> Array to store the variable description of the quantities to be written ctryt = 0 call stats_init_ytavg_vel if (ltempeq) call stats_init_ytavg_temp if (lmoist) call stats_init_ytavg_moist if (lrh) call stats_init_ytavg_relative_humidity if (nsv>0) call stats_init_ytavg_scalar call stats_createnc_ytavg deallocate(ytVars) end if !> Generate y averaged NetCDF: stats_y.xxx.xxx.nc if (lydump) then yVarsCount = 9 if (ltempeq) yVarsCount = yVarsCount + 5 if (lmoist) yVarsCount = yVarsCount + 5 if (lrh) yVarsCount = yVarsCount + 1 if (nsv>0) yVarsCount = yVarsCount + 4*nsv allocate(yVars(yVarsCount,4)) !!> Array to store the variable description of the quantities to be written ctry = 0 call stats_init_yavg_vel if (ltempeq) call stats_init_yavg_temp if (lmoist) call stats_init_yavg_moist if (lrh) call stats_init_yavg_relative_humidity if (nsv>0) call stats_init_yavg_scalar call stats_createnc_yavg deallocate(yVars) end if !> Generate time averaged tree data NetCDF: stats_tree.xxx.xxx.xxx.nc if (ltreedump) then treeVarsCount = 3 if (ltempeq) treeVarsCount = treeVarsCount + 1 if (lmoist) treeVarsCount = treeVarsCount + 4 if (nsv>0) treeVarsCount = treeVarsCount + nsv allocate(treeVars(treeVarsCount,4)) !!> Array to store the variable description of the quantities to be written ctrtree = 0 call stats_init_tree_vel if (ltempeq) call stats_init_tree_temp if (lmoist) call stats_init_tree_moist if (nsv>0) call stats_init_tree_scalar call stats_createnc_tree deallocate(treeVars) end if end subroutine stats_prepare