﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
709	NADJ paramerter and 4D-Var dual formulation	arango	arango	"It had come to my attention that some users set '''NADJ''' in '''ocean.in''' to a large number to trigger strong constraint in 4D-Var dual formulation alogorithms ('''W4DPSAS''' or '''W4DVAR''').  Well, this is not a good idea because the algorithms will become unstable.

In the dual formulation, we need to set '''NADJ''' to '''NTIMES''' for strong constraint or to an exact multiple of '''NTIMES''' for weak constraint.  For example, in '''ocean.in''' we can have:

 {{{
      NTIMES == 192
...
        NADJ == 48                              ! weak constraint
or
        NADJ == 192                             ! strong constraint

}}}

In the primal formulation ('''IS4DVAR'''), you can put any number for '''NADJ''' because it is over-written internally in '''read_phypar.F''':

 {{{
#if defined IS4DVAR
!
!  If strong constraint, write only final adjoint solution since only
!  we are estimating initial conditions.
!
        nADJ(ng)=ntimes(ng)
#endif
}}}

To avoid similar problems in the future, a safeguard is added in '''read_phypar.F''' for the dual formulation:

 {{{
#if defined W4DPSAS || defined W4DVAR
!
!  If dual formulation and strong constraint, limit writing the adjoint
!  solution to the end of time-stepping.
!
        IF (nADJ(ng).gt.ntimes(ng)) THEN
          nADJ(ng)=ntimes(ng)
        END IF
#endif
}}}
"	upgrade	closed	major	Adjoint Based Algorithms	Adjoint	3.7	Done		
