I want to declare a variable to storage cumulative NPP and write it to history file. The cumulative NPP refers to total NPP from Jan. 1 to current run time. If the model is run to the next year, it is accumulated from the new year.
I guess the cumulative NPP variable needs to be declared in the CNVegCarbonFluxType.F90. Such as:
type, public :: cnveg_carbonflux_type
......
real(r8), pointer :: sumnpp_patch (:) ! (gC/m2/s) cumulative NPP
......
then, I need to give an initial value of nan:
subroutine InitAllocate(this, bounds, carbon_type)
......
allocate(this%sumnpp_patch (begp:endp)) ; this%sumnpp_patch (:) = nan
......
end subroutine InitAllocate
then, I need to call the hist_addfld1d function to output it to the history file:
this%sumnpp_patch(begp:endp) = spval
call hist_addfld1d (fname='SUMNPP', units='gC/m^2/s', &
avgflag='A', long_name='cumulative NPP', &
ptr_patch=this%sumnpp_patch)
then, set carbon state fluxes in subroutine SetValues: this%sumnpp_patch(i) = value_patch
Finally, I don't know how to get compute the npp of the last time node in " subroutine Summary_carbonflux() " and summed with the cumulative npp of the last time node.(In fact, I just need to get the NPP of the last time node in gC/m^2. Since the CTSM runs at the same time interval, I just multiply the final cumulative amount by the time interval. For example, my run interval is days. Then I only need to multiply 60*60*24 at the end of the year.)
I would be grateful if you could help me out.
I guess the cumulative NPP variable needs to be declared in the CNVegCarbonFluxType.F90. Such as:
type, public :: cnveg_carbonflux_type
......
real(r8), pointer :: sumnpp_patch (:) ! (gC/m2/s) cumulative NPP
......
then, I need to give an initial value of nan:
subroutine InitAllocate(this, bounds, carbon_type)
......
allocate(this%sumnpp_patch (begp:endp)) ; this%sumnpp_patch (:) = nan
......
end subroutine InitAllocate
then, I need to call the hist_addfld1d function to output it to the history file:
this%sumnpp_patch(begp:endp) = spval
call hist_addfld1d (fname='SUMNPP', units='gC/m^2/s', &
avgflag='A', long_name='cumulative NPP', &
ptr_patch=this%sumnpp_patch)
then, set carbon state fluxes in subroutine SetValues: this%sumnpp_patch(i) = value_patch
Finally, I don't know how to get compute the npp of the last time node in " subroutine Summary_carbonflux() " and summed with the cumulative npp of the last time node.(In fact, I just need to get the NPP of the last time node in gC/m^2. Since the CTSM runs at the same time interval, I just multiply the final cumulative amount by the time interval. For example, my run interval is days. Then I only need to multiply 60*60*24 at the end of the year.)
I would be grateful if you could help me out.