Question about tracer routine

Report or discuss software problems and other woes

Moderators: arango, robertson

Post Reply
Message
Author
yqli777
Posts: 3
Joined: Thu Jul 09, 2020 5:22 pm

Question about tracer routine

#1 Unread post by yqli777 »

Hi all,
Since I do not fully understand the tracer algorithm in ROMS, I have some question about the tracer routine.
I know in pre_step3d.F(line 891):

Code: Select all

          DO k=1,N(ng)
            DO i=Istr,Iend
              cff1=Hz(i,j,k)*t(i,j,k,nstp,itrc)
              cff2=FC(i,k)-FC(i,k-1)
              t(i,j,k,nnew,itrc)=cff1+cff2
            END DO
          END DO
So the unit of t(:,:,nnew,itrc) is m*Tunit, while t(:,:,nstp,itrc) is Tunit.
But in main3d.F(line 183), the time time indices are updated after this calculation:

Code: Select all

            DO ig=1,GridsInLayer(nl)
              ng=GridNumber(ig,nl)
              iic(ng)=iic(ng)+1
              nstp(ng)=1+MOD(iic(ng)-ntstart(ng),2)
              nnew(ng)=3-nstp(ng)
              nrhs(ng)=nstp(ng)
              ...
            END DO
In my understanding, the array t(i,j,k,nnew,itrc) computed at last step, will become t(i,j,k,nstp,itrc) at the next step, because the values of nnew and nstp are swapped. If so, wouldn't the units of t(:,:,:,nstp,itrc) become m*Tunits? And in output.F, the array to be written to nc file is t(:,:,:,nrhs,:), that is t(:,:,:,nstp,:), however, in this routine, the unit should be Tunit.
So my question is that, is the unit of t(nnew) always m*Tunit? Or in what line of code, is its unit converted? Do I miss some key points about this algorithm?
Greatly appreciate any hints!

jcwarner
Posts: 1172
Joined: Wed Dec 31, 2003 6:16 pm
Location: USGS, USA

Re: Question about tracer routine

#2 Unread post by jcwarner »

you need to be careful in here, as some routines (like MPDATA) are a little different than others.
but at the bottom of step3d_t is where the units become Tracer only. it can happen in the diffusion step, and here again you need to be careful if splines are on or not.

yqli777
Posts: 3
Joined: Thu Jul 09, 2020 5:22 pm

Re: Question about tracer routine

#3 Unread post by yqli777 »

Dr. Warner,
Thank you for your reply! I'll look at step3d.F carefully. Now my understanding is that unit conversion between t(:,:,:.nnew.itrc) and t(:,:,:,nstp,itrc) is done only in step3d_t.F, while in ohter subroutines like sediment and biology, the unit of t(:,:,:,nnew,itrc) is always m*Tunit, Am I correct?
Thank you very much!

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

Re: Question about tracer routine

#4 Unread post by wilkin »

It is my understanding that the conversion of t(nnew) back to tracer units,before switching nnew and nstp, occurs in step3d_t.F, but as John Warner points out this depends on the advection scheme (MPDATA is different) and the status of SPLINES _VDIFF.

See line 1190 in step3d_t.F:

Code: Select all

# ifdef SPLINES_VDIFF
                t(i,j,k,nnew,itrc)=t(i,j,k,nnew,itrc)*oHz(i,j,k)
# endif
Now, step3d_t is called after biology and sediment.

Notice in, e.g. fennel.h, that the calculations are based on t(nstp) which is copied to the temporary arrays Bio_old(i,k,itrc) and Bio(i,k,itrc). Once the biology state variables increments are computed (each BGC process adds to Bio(i,k,itrc)) the increments are then applied to t(nnew) in the final update global tracer variables step:

Code: Select all

              cff=Bio(i,k,ibio)-Bio_old(i,k,ibio)
              ...
              t(i,j,k,nnew,ibio)=t(i,j,k,nnew,ibio)+cff*Hz(i,j,k)          
              
which is m*Tunits because of the Hz factor.

Thus operations internal to biology routines using the Bio(i,k,itrc) values are in terms of Tunits, but biology.F exits with updated t(tnew) in m*Tunits, to then be passed to step3d_t to complete the time step of mixing and advection.
John Wilkin: DMCS Rutgers University
71 Dudley Rd, New Brunswick, NJ 08901-8521, USA. ph: 609-630-0559 jwilkin@rutgers.edu

yqli777
Posts: 3
Joined: Thu Jul 09, 2020 5:22 pm

Re: Question about tracer routine

#5 Unread post by yqli777 »

Hi John,
Thank you for your patient reply and clarification, and telling me exactly where the line is! My understanding of source code is much deeper!
Thanks again :D :D

Post Reply