can not understand the code in ana_nudgcoef.h

General scientific issues regarding ROMS

Moderators: arango, robertson

Post Reply
Message
Author
xiaozhu557
Posts: 62
Joined: Fri Sep 11, 2009 1:48 pm
Location: nmefc

can not understand the code in ana_nudgcoef.h

#1 Unread post by xiaozhu557 »

I have read the code in /ROMS/Functionals/ana_nudgcoef.h, I found its codes in line 460-469 as follow,

Code: Select all

460            IF (DOMAIN(ng)%SouthWest_Corner(tile)) THEN
461              Tobc_out(itrc,ng,iwest)=CLIMA(ng)%Tnudgcof([b]0,1[/b],itrc)
462              Tobc_in (itrc,ng,iwest)=obcfac(ng)*                       &
463     &                                Tobc_out(itrc,ng,iwest)
464            END IF
465            IF (DOMAIN(ng)%Western_Edge(tile)) THEN
466              DO j=JstrT,JendT
467                CLIMA(ng)%Tnudgcof([b]0,j[/b],itrc)=[b]0.0_r8[/b]
468              END DO
469            END IF
and its friends in the define TCLM_NUDGING for northern, southern, eastern boundaries . I can not understand that why use 0,1 in line 461, 0,j in line 467 or set as 0.0_r8 for Tnudgcof(0,j,itrc) in line 467. It is wired for me? Anybody can explain it for me?

Thanks.

User avatar
kate
Posts: 4091
Joined: Wed Jul 02, 2003 5:29 pm
Location: CFOS/UAF, USA

Re: can not understand the code in ana_nudgcoef.h

#2 Unread post by kate »

I agree that the first part of that is odd. You left out the # ifdef TCLM_NUDGING surrounding this code. It is effectively saying that the behaviour of the tracer boundary condition depends on whether or not you have TCLM_NUDGING on. That is not what I want, so I set Tobc_out and Tobc_in the same either way in my ana_nudgcoef.h.

You have my permission to ignore this:

Code: Select all

!! WARNING:  This section is generic for all applications. Please do not 
!!           change the code below.
The second part doesn't bother me. One shouldn't be nudging tracers out in the boundary zone anyway.

xiaozhu557
Posts: 62
Joined: Fri Sep 11, 2009 1:48 pm
Location: nmefc

Re: can not understand the code in ana_nudgcoef.h

#3 Unread post by xiaozhu557 »

Hi Kate, thanks for your response. Two comments based on your reply, as follow

(1) I know that

Code: Select all

# ifdef TCLM_NUDGING
is in your ana_nudgcoef.h, and the codes posted in my last post just can work when I defined TCLM_NUDGING in *.h file. Of course, I have defined it. I just did not post it with them together on yesterday.

(2) I also have not ignored your permission

Code: Select all

!! WARNING:  This section is generic for all applications. Please do not 
!!           change the code below.
I do not want to change anything for those code. I just do not understand it, so I want to ask.
kate wrote:That is not what I want, so I set Tobc_out and Tobc_in the same either way in my ana_nudgcoef.h.
Based on your this response, do you mean that I don't need to turn TCLM_NUDGING on, just use the other way to set boundary nudging coef, is it correct?

User avatar
wilkin
Posts: 922
Joined: Mon Apr 28, 2003 5:44 pm
Location: Rutgers University
Contact:

Re: can not understand the code in ana_nudgcoef.h

#4 Unread post by wilkin »

For other readers on the User Forum it helps to see the whole logic here:

Code: Select all

          IF (LBC(iwest,isTvar(itrc),ng)%nudging) THEN
# ifdef TCLM_NUDGING
            IF (DOMAIN(ng)%SouthWest_Corner(tile)) THEN
              Tobc_out(itrc,ng,iwest)=CLIMA(ng)%Tnudgcof(0,1,itrc)
              Tobc_in (itrc,ng,iwest)=obcfac(ng)*                       &
     &                                Tobc_out(itrc,ng,iwest)
            END IF
            IF (DOMAIN(ng)%Western_Edge(tile)) THEN
              DO j=JstrT,JendT
                CLIMA(ng)%Tnudgcof(0,j,itrc)=0.0_r8
              END DO
            END IF
# else
            IF (DOMAIN(ng)%SouthWest_Test(tile)) THEN
              Tobc_out(itrc,ng,iwest)=Tnudg(itrc,ng)
              Tobc_in (itrc,ng,iwest)=obcfac(ng)*Tnudg(itrc,ng)
            END IF
# endif
          END IF
If TCLM_NUDGING is not defined (the ELSE block) the inflow/outflow nudging time scales are simply set on the basis of values in ocean.in (TNUDG and OBCFAC). In this case there is no nudging anywhere else in the domain but on the perimeter.

But if TCLM_NUDGING is defined then the nudging on the boundary due to Tobc_in/out would "double" the nudging. So this is suppressed by the block that includes

Code: Select all

          CLIMA(ng)%Tnudgcof(0,j,itrc)=0.0_r8
The spatial distribution of 3-D nudging applied by TCLM_NUDGING is set in the code that precedes all this. The default code follows the lines:

Code: Select all

#else
!
!  Default nudging coefficients.  Set nudging coefficients uniformly to
!  the values specified in the standard input file.
But this is preceded by possible individual user customizations. If a user makes modifications then the nudging values due to TCLM_NUDGING can differ from Tnudg on the boundary. So the lines of code you question with the 0,1 index are intended to extract the customized values on the perimeter and use those for boundary nudging. A single value is required because Tobc_in/out are scalars.

Like Kate, I tend to modify this code chunk myself to set TCLM_NUDGING and boundary nudging coefficients as I wish.
John Wilkin: DMCS Rutgers University
71 Dudley Rd, New Brunswick, NJ 08901-8521, USA. ph: 609-630-0559 jwilkin@rutgers.edu

Post Reply