Function roms_metrics

Discussion about analysis, visualization, and collaboration tools and techniques

Moderators: arango, robertson

Post Reply
Message
Author
MBendoni
Posts: 5
Joined: Thu Jan 24, 2019 7:16 pm
Location: CNR-ISMAR

Function roms_metrics

#1 Unread post by MBendoni »

Hello,

I am using the new roms_metrics.m function (track_ticket #879). I noticed it gives different x_rho and y_rho variables (x_psi,...) with respect to previous tools, only concerning the first (1) and last grid points (Lp and Mp). They indeed result to be dx/2 and dy/2 spaced with respect to the inner points, but that is not true for the corresponding lon_rho and lat_rho points. These are the lines of code producing x_rho and y_rho:

Code: Select all

% Compute Cartesian coordinates.

x_rho = zeros(size(dx));
for j=1:Mp
  x_rho(1,j) = -dx(1,j);
  for i=1:L
    x_rho(i+1,j) = x_rho(i,j) + dx(i+1,j);
  end
x_rho( 1,j) = x_rho( 1,j) + 0.5*dx( 1,j);
x_rho(Lp,j) = x_rho(Lp,j) - 0.5*dx(Lp,j);
end

y_rho = zeros(size(dy));
for i=1:Lp
  y_rho(i,1) = -dy(i,1);
  for j=1:M
    y_rho(i,j+1) = y_rho(i,j) + dy(i,j+1);
  end
y_rho(i,1 ) = y_rho(i,1 ) + 0.5*dy(i,1 );  
y_rho(i,Mp) = y_rho(i,Mp) - 0.5*dy(i,Mp);
end
Perhaps it is a naive question, but I do not understand why the following updates are necessary:

Code: Select all

x_rho( 1,j) = x_rho( 1,j) + 0.5*dx( 1,j);
x_rho(Lp,j) = x_rho(Lp,j) - 0.5*dx(Lp,j);

y_rho(i,1 ) = y_rho(i,1 ) + 0.5*dy(i,1 );  
y_rho(i,Mp) = y_rho(i,Mp) - 0.5*dy(i,Mp);
For example, they lead to the following:

Code: Select all

diff(x_rho(end-4:end,1))

ans =

  842.7449        
  842.7449 
  842.7449   
  421.3725  
and I was wondering if it may creat issues in case of nesting applications.

thank you in advance,
Michele

User avatar
arango
Site Admin
Posts: 1347
Joined: Wed Feb 26, 2003 4:41 pm
Location: DMCS, Rutgers University
Contact:

Re: Function roms_metrics

#2 Unread post by arango »

ROMS uses a horizontal, staggered Arakawa C-grid. You need to study and understand the following grid diagram in :arrow: WikiROMS. You need to look the grid spacing in terms of RHO-, PSI-, U-, and V-points. Then, you will answer your own questions. The code in roms.metrics.m is correct.

Post Reply