How to declare a new variable in .f90 file and write the new variable to history file?

Status
Not open for further replies.

liyongkang

liyongkang
New Member
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 compute the npp of the last time node in " subroutine Summary_carbonflux() " and summed with the cumulative npp of the last time node.
I would be grateful if you could help me out.
 
Status
Not open for further replies.
Back
Top