Hi,
I post this here because I have been trying desperately to create a 5 year running mean of single year temperature minimums. But instead of being updated every year and remaining stable, I see that the 5 year running mean behaves weirdly when I plot it (see figure), it should remain the same throughout the year. When I print it in the model it seems fine, but not when I plot from the output file.
Ps: I would also like T_REF24 and T_HARD1 to not contain NaNs, instead have similar values to the ones written before.
I hope someone will be able to have a look at the lines below or at the link and give me a hint of why the output is weird in the history file.
Best regards,
Marius
github.com
!-------------------------------------------------------- InitHistory
if (use_fates_hardening) then !Marius
this%t_ref2m_24_patch(begp:endp) = spval
call hist_addfld1d (fname='T2m_24', units='K', &
avgflag='A', long_name='average temperature 2m (24hrs)', &
ptr_patch=this%t_ref2m_24_patch, default='active')
this%t_mean_5yr_patch(begp:endp) = spval
call hist_addfld1d (fname='T_HARD5', units='K', &
avgflag='A', long_name='5 year mean of minimum yearly 2-m temperature for hardening', &
ptr_patch=this%t_mean_5yr_patch, default='active')
this%t_min_yr_patch(begp:endp) = spval
call hist_addfld1d (fname='T_HARD1', units='K', &
avgflag='A', long_name='minimum year 2-m temperature for hardening', &
ptr_patch=this%t_min_yr_patch, default='active')
end if
!----------------------------------- InitAccBuffer
this%t_mean_5yr_patch(bounds%begp:bounds%endp) = spval
call init_accum_field (name='T_HARD5', units='K', &
desc='5 year average of yearly min 2-m temperature for hardening', accum_type='runmean', accum_period=-5, &
subgrid_type='pft', numlev=1, init_value=0.0_r8)
end if
!------------------------------------- UpdateAccVars
if (use_fates_hardening) then
! Accumulate and extract T_REF24
call update_accum_field ('T_REF24' , this%t_ref2m_patch , nstep)
call extract_accum_field ('T_REF24' , rbufslp , nstep)
do p = begp,endp
this%t_ref2m_24_patch(p) = rbufslp(p)
end do
! Start 1 year minimum temperature loop for hardening
end_yr = is_end_curr_year()
do p = begp,endp
if (rbufslp(p) /= spval) then
this%t_min_yr_inst_patch(p) = min(rbufslp(p), this%t_min_yr_inst_patch(p))
endif
if (end_yr) then
this%t_min_yr_patch(p) = this%t_min_yr_inst_patch(p)
rbufslp(p)=this%t_min_yr_inst_patch(p)
this%t_min_yr_inst_patch(p) = spval
else if (secs == dtime) then
this%t_min_yr_patch(p) = spval
endif
end do
if (end_yr) then
call update_accum_field ('T_HARD5', rbufslp, nstep)
call extract_accum_field ('T_HARD5', this%t_mean_5yr_patch, nstep)
end if
end if

I post this here because I have been trying desperately to create a 5 year running mean of single year temperature minimums. But instead of being updated every year and remaining stable, I see that the 5 year running mean behaves weirdly when I plot it (see figure), it should remain the same throughout the year. When I print it in the model it seems fine, but not when I plot from the output file.
Ps: I would also like T_REF24 and T_HARD1 to not contain NaNs, instead have similar values to the ones written before.
I hope someone will be able to have a look at the lines below or at the link and give me a hint of why the output is weird in the history file.
Best regards,
Marius
CTSM_single_site_fateshydro/src/biogeophys/TemperatureType.F90 at c9a2bd4eba549e830c21cd330a2fdddadb58e737 · mariuslam/CTSM_single_site_fateshydro
Contribute to mariuslam/CTSM_single_site_fateshydro development by creating an account on GitHub.
!-------------------------------------------------------- InitHistory
if (use_fates_hardening) then !Marius
this%t_ref2m_24_patch(begp:endp) = spval
call hist_addfld1d (fname='T2m_24', units='K', &
avgflag='A', long_name='average temperature 2m (24hrs)', &
ptr_patch=this%t_ref2m_24_patch, default='active')
this%t_mean_5yr_patch(begp:endp) = spval
call hist_addfld1d (fname='T_HARD5', units='K', &
avgflag='A', long_name='5 year mean of minimum yearly 2-m temperature for hardening', &
ptr_patch=this%t_mean_5yr_patch, default='active')
this%t_min_yr_patch(begp:endp) = spval
call hist_addfld1d (fname='T_HARD1', units='K', &
avgflag='A', long_name='minimum year 2-m temperature for hardening', &
ptr_patch=this%t_min_yr_patch, default='active')
end if
!----------------------------------- InitAccBuffer
this%t_mean_5yr_patch(bounds%begp:bounds%endp) = spval
call init_accum_field (name='T_HARD5', units='K', &
desc='5 year average of yearly min 2-m temperature for hardening', accum_type='runmean', accum_period=-5, &
subgrid_type='pft', numlev=1, init_value=0.0_r8)
end if
!------------------------------------- UpdateAccVars
if (use_fates_hardening) then
! Accumulate and extract T_REF24
call update_accum_field ('T_REF24' , this%t_ref2m_patch , nstep)
call extract_accum_field ('T_REF24' , rbufslp , nstep)
do p = begp,endp
this%t_ref2m_24_patch(p) = rbufslp(p)
end do
! Start 1 year minimum temperature loop for hardening
end_yr = is_end_curr_year()
do p = begp,endp
if (rbufslp(p) /= spval) then
this%t_min_yr_inst_patch(p) = min(rbufslp(p), this%t_min_yr_inst_patch(p))
endif
if (end_yr) then
this%t_min_yr_patch(p) = this%t_min_yr_inst_patch(p)
rbufslp(p)=this%t_min_yr_inst_patch(p)
this%t_min_yr_inst_patch(p) = spval
else if (secs == dtime) then
this%t_min_yr_patch(p) = spval
endif
end do
if (end_yr) then
call update_accum_field ('T_HARD5', rbufslp, nstep)
call extract_accum_field ('T_HARD5', this%t_mean_5yr_patch, nstep)
end if
end if
