Using correct i/j indicies in development

Suggest improvements/optimizations to the ROMS code.

Moderators: arango, robertson

Post Reply
Message
Author
abever
Posts: 23
Joined: Tue Feb 17, 2004 6:15 pm
Location: Anchor QEA, LLC

Using correct i/j indicies in development

#1 Unread post by abever »

We are having problems along tiles, and one that is a little harder to track down, in our developmental bottom boundary layer gravity flow code. We want to make sure we are mapping u and v points to the rho points and the rho points to the u and v points properly. I have questions regarding the use of i and j indicies with tiling and their use in mapping variables to other grids, such as a rho point variable onto a u grid. Basically, I am confused by all the combinations of Istr, IstrU, IstrU-1, etc in the code. :?:

1. When exactly should IstrU / JstrV be used instead of Istr / Jstr?

2. Why do some places in the code use "DO IstrU-1,Iend+1" and others leave off the plus and minus one, or just leave off the minus one?

3. What is the correct way to map u and v points onto the rho grid, and rho points onto the u and v grids, in the middle of loops dealing mostly with rho points. I assume the rho points loop should go from Istr to Iend and Jstr to Jend?

4. Why might a person have to use Istr-1 and Jstr-1 to include the entire domain when dealing with strictly rho points? Should all rho loops be Istr-1?

Thanks
Aaron

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

Re: Using correct i/j indicies in development

#2 Unread post by kate »

abever wrote:We are having problems along tiles, and one that is a little harder to track down, in our developmental bottom boundary layer gravity flow code. We want to make sure we are mapping u and v points to the rho points and the rho points to the u and v points properly. I have questions regarding the use of i and j indicies with tiling and their use in mapping variables to other grids, such as a rho point variable onto a u grid. Basically, I am confused by all the combinations of Istr, IstrU, IstrU-1, etc in the code. :?:
Here are some images which might help. The entire grid is here:
http://people.arsc.edu/~kate/ROMS/whole_grid.png
Note that the thick outer line is where the walls would be, if it has walls. The regular model physics happens on the inner white portion and boundary conditions apply to the pinkish areas. If you are tiling in the i direction, it looks like this:
http://people.arsc.edu/~kate/ROMS/Istr.png
The domain is either periodic or not, periodic joins work similar to tile joins.
1. When exactly should IstrU / JstrV be used instead of Istr / Jstr?
When the fields being operated on are at U/V points and they care about the periodicity flag.
2. Why do some places in the code use "DO IstrU-1,Iend+1" and others leave off the plus and minus one, or just leave off the minus one?
If you are writing to a scratch array and you know you'll be wanting to use the IstrU-1 value, then load it up. Some operations are inherently 1-D in the vertical so you won't be needing the neighboring value - save by not computing it.
3. What is the correct way to map u and v points onto the rho grid, and rho points onto the u and v grids, in the middle of loops dealing mostly with rho points. I assume the rho points loop should go from Istr to Iend and Jstr to Jend?
If you want a u value at a rho point, then compute using rho loop bounds and average the u(i,j) with u(i+1,j) to get u at the (i,j) rho point.
4. Why might a person have to use Istr-1 and Jstr-1 to include the entire domain when dealing with strictly rho points? Should all rho loops be Istr-1?
It just depends. The code I use is written such that you never write to an i,j value not on your tile, even though there may be times that that could save an exchange (halo computation) unless it is a scratch array that's local to the tile. So, I can write to Istr-1 of the scratch arrays, but not the global tiled arrays. The code is parallel to both MPI and OpenMP, and there are strange things to watch out for if you don't want to break either one. Hernan is always having to remind me of this...

Post Reply