[MITgcm-devel] viscFacAdj = viscFacInAd has no effect on simulation

Matthew Mazloff mmazloff at ucsd.edu
Mon Nov 2 12:26:32 EST 2020


Its because its inside 
#ifdef ALLOW_3D_VISCAH
#endif


In mom_calc_visc.F I moved it:

C  Harmonic on Div.u points
         Alin=viscAhD+viscAhGrid*L2rdt
     &          +viscAh_DLth(i,j)+viscAh_DSmg(i,j)+viscAh_DLthQG(i,j)
#ifdef ALLOW_3D_VISCAH
     &          +viscAhDfld(i,j,k,bi,bj)
CMM(
#endif
CMM)
#ifdef ALLOW_AUTODIFF
     &          *viscFacAdj
#endif
CMM#endif
         viscAh_DMin(i,j)=MAX(viscAhGridMin*L2rdt,Uscl)
         viscAh_D(i,j)=MAX(viscAh_DMin(i,j),Alin)
         viscAh_DMax(i,j)=MIN(viscAhGridMax*L2rdt,viscAhMax)
         viscAh_D(i,j)=MIN(viscAh_DMax(i,j),viscAh_D(i,j))

C  BiHarmonic on Div.u points
         Alin=viscA4D+viscA4Grid*L4rdt
     &          +viscA4_DLth(i,j)+viscA4_DSmg(i,j)
#ifdef ALLOW_3D_VISCA4
     &          +viscA4Dfld(i,j,k,bi,bj)
CMM(
#endif
CMM)
#ifdef ALLOW_AUTODIFF
     &          *viscFacAdj
#endif
CMM#endif


Is this the problem?

Matt

> On Nov 2, 2020, at 9:21 AM, Martin Losch <Martin.Losch at awi.de> wrote:
> 
> Hi Matt,
> 
> you probably rely (or used to rely) on increased viscosity to stabilize the adjoint with viscFacAdj. 
> Together with a post-doc I am trying to use viscFacAdj with an ECCOv4ish variant of the llc90 configuration and find that this factor (via viscFacInAd) has no effect on the solution. I think store directives in mom_vecinv.F that suppress recomputing the viscosities via S/R mom_calc_visc are responsible for this (because the viscosities are saved in the tape computations). Before I make this an issue or even a PR on github I would like to hear from you how you actually do (or used to do) this (increase viscosity in AD-mode) and if you have an example that you are willing to share.
> 
> I know that you are working on combining high res forward with low res ad models (which I am also very much interested in), but for now I would be very happy to get the increased viscosity method to work with current code. Any help is appreciated.
> 
> There’s a second problem that I idendified:
> viscFacAdj = 0 (default) before autodiff_inadmode_set_ad is called for the first time, then it is set to viscFacInAd (which then has no effect), and then is is reset to 1 in autodiff_inadmode_unset_ad, so that part of the tape computations are with a different viscFacAdj than the forward simulation. I cannot imagine that this is intentional, but maybe I am overlooking something?
> I plan to have a new runtime parameter viscFacInFw (which defaults to zero) that then becomes the default for viscFacAdj, so that we can set this parameter to something that is the same in all forward and tape compuation parts of the code. Do you have an opinion on that?
> 
> Best,
> 
> Martin



More information about the MITgcm-devel mailing list