Opened 9 years ago
Closed 9 years ago
#1755 closed Bug (fixed)
variable partially uninitialized in traadv_tvd_zts
Reported by: | mathiot | Owned by: | nemo |
---|---|---|---|
Priority: | normal | Milestone: | |
Component: | OCE | Version: | v3.6 |
Severity: | Keywords: | ||
Cc: |
Description
Context
On the MetO machine, traadv_tvd_zts is very unstable. NaN appeared sometimes during the restart time step with the sub time stepping activated.
Analysis
In traadv_tvd_zts, ztrs(:,:,:,1) is inialized to ptb(:,:,:,jn). However, ztrs(:,:,1,2:3) are not initialised or computed and are used to compute the interior value of zwz (l. 496).
DO jk = 2, jpkm1 ! Interior value DO jj = 2, jpjm1 DO ji = fs_2, fs_jpim1 zwz(ji,jj,jk) = 0.5_wp * pwn(ji,jj,jk) * ( ztrs(ji,jj,jk,jtn) + ztrs(ji,jj,jk-1,jtn) ) IF( jtaken == 0 ) zwzts(ji,jj,jk) = zwzts(ji,jj,jk) + zwz(ji,jj,jk)*zts(jk) ! Accumulate time-weighted vertcal flux END DO END DO END DO
Fix
As fix, I suggest, in traadv_tvd_zts, set ztrs(:,:,1,:) = 0.0. Maybe initialisation of the surface value to ptb(:,:,1,jn) for jtb, jtn and jta is better? other solution ? Could someone comment on it?
Commit History (2)
Changeset | Author | Time | ChangeLog |
---|---|---|---|
6771 | mathiot | 2016-07-01T16:53:13+02:00 | Add ztrs surface initialisation in traadv_tvd_zts in the trunk, as discussed in ticket #1755 |
6770 | mathiot | 2016-07-01T13:43:36+02:00 | Add ztrs surface initialisation in traadv_tvd_zts, as discussed in ticket #1755 |
Change History (4)
comment:1 Changed 9 years ago by acc
comment:2 Changed 9 years ago by mathiot
- : I agree with you, only ztrs(:,:,:,jl) is used with the index jl=jtb/jtn/jta used between 1 and 3 whatever is the tracer.
- : I agree ”for jl=1, only entry '1' appears on the RHS and entry '2' is set” but only for jk=2,jpkm1 (l.506, loop "interior value",“total advective trend”). For jl=2, ztrs(ji,jj,1,2) is used to compute zwz(ji,jj,2) and not set in the case jl=1 or in the intialisation.
I suggest to change the initialisation:
! antidiffusive flux on k zwz(:,:,1) = 0._wp ! Surface value zwz_sav(:,:,:) = zwz(:,:,:) ! ztrs(:,:,:,1) = ptb(:,:,:,jn) zwzts(:,:,:) = 0._wp
by:
! antidiffusive flux on k zwz(:,:,1) = 0._wp ! Surface value zwz_sav(:,:,:) = zwz(:,:,:) ! ztrs(:,:,:,1) = ptb(:,:,:,jn) ztrs(:,:,1,2) = ptb(:,:,1,jn) ztrs(:,:,1,3) = ptb(:,:,1,jn) zwzts(:,:,:) = 0._wp
comment:3 Changed 9 years ago by acc
Yes, I see your point about the surface values not being initialised for the second and third entries of ztrs(:,:,:,n). The proposed fix is valid and necessary.
comment:4 Changed 9 years ago by mathiot
- Resolution set to fixed
- Status changed from new to closed
A couple of comments:
If you are encountering undefined values in ztrs then they must be upstream in ptb itself unless I'm missing something more subtle?