Opened 16 years ago
Last modified 16 years ago
#384 closed bug
Incorrectly coded option UV_PSOURCE in step2d_LF_AM3.h — at Initial Version
| Reported by: | arango | Owned by: | arango |
|---|---|---|---|
| Priority: | major | Milestone: | Adjoint Based Algorithms |
| Component: | Adjoint | Version: | 3.3 |
| Keywords: | Cc: |
Description
I have been hunting for an adjoint bug in tl_step2d_LF_AM3.h and ad_step2d_LF_AM3.h for two days. It occurs when the mass point sources UV_PSOURCE option is activated. It turns out the the bug was in the nonlinear code step2d_LF_AM3.h:
DO is=1,Nsrc
i=Isrc(is)
j=Jsrc(is)
IF (((IstrR.le.i).and.(i.le.IendR)).and. &
& ((JstrR.le.j).and.(j.le.JendR))) THEN
IF (INT(Dsrc(is)).eq.0) THEN
cff=1.0_r8/(on_u(i,j)* &
& 0.5_r8*(zeta(i-1,j,knew)+h(i-1,j)+ &
& zeta(i ,j,knew)+h(i ,j)))
ubar(i,j,knew)=Qbar(is)*cff
# ifdef SOLVE3D
DU_avg1(i,j)=Qbar(is)
# endif
ELSE
cff=1.0_r8/(om_v(i,j)* &
& 0.5_r8*(zeta(i,j-1,knew)+h(i,j-1)+ &
& zeta(i,j ,knew)+h(i,j )))
vbar(i,j,knew)=Qbar(is)*cff
# ifdef SOLVE3D
DV_avg1(i,j)=Qbar(is)
# endif
END IF
END IF
END DO
The override of variables DU_av1 and DV_avg1 is completely incorrect here and should be done separately after all the barotropic time-steps have been carry-out. That is, when
IF ((iif(ng).eq.(nfast(ng)+1)).and.PREDICTOR_2D_STEP(ng)) THEN
# ifdef UV_PSOURCE
DO is=1,Nsrc
i=Isrc(is)
j=Jsrc(is)
IF (((IstrR.le.i).and.(i.le.IendR)).and. &
& ((JstrR.le.j).and.(j.le.JendR))) THEN
IF (INT(Dsrc(is)).eq.0) THEN
DU_avg1(i,j)=Qbar(is)
ELSE
DV_avg1(i,j)=Qbar(is)
END IF
END IF
END DO
# endif
...
END IF
This generated a nasty bug in the adjoint codes. There cannot be redundant operations in the adjoint model... This bug have been in the adjoint codes since the beginning. In the nonlinear model is it a minor correction and not identical results can be achived after this update.
