# [MITgcm-support] XU, YU and XV, YV coordinates in the curvilinear grid...

Simone Sammartino ssammartino at ctima.uma.es
Mon Nov 5 07:10:13 EST 2012

```Hi Martin
You're right...
These four lines are commented and I did not realize it...

And yes...your algorithm is quite easier and returns nearly the same
locations...:-)

Thank you
Simone

-------------------------------------
Simone Sammartino
Physical Oceanography Research Group
University of Málaga
GOFIMA
Campus Teatinos s/n
ETSI Telecomunicación
29071 Málaga (Spain)

Tel: +34 952 13 28 49
http://oceano.uma.es
--------------------------------------
Do you really need to print this message?
Let's protect the environment.
-----Mensaje original-----
From: Martin Losch
Sent: Monday, November 05, 2012 9:31 AM
To: mitgcm-support at mitgcm.org
Subject: Re: [MITgcm-support] XU, YU and XV,YV coordinates in the
curvilinear grid...

Hi Simone,

I meant:
XU(i,j) = 0.5*(XG(i,j)+XG(i,j+1))
YU(i,j)= 0.5*(YG(i,j)+YG(i,j+1))
XV(i,j) = 0.5*(XG(i,j)+XG(i+1,j))
YV(i,j)= 0.5*(YG(i,j)+YG(i+1,j))
or
XU(i,j) = 0.5*(XC(i,j)+XC(i-1,j))
YU(i,j)= 0.5*(YC(i,j)+YC(i-1,j))
XV(i,j) = 0.5*(XC(i,j)+XC(i,j-1))
YV(i,j)= 0.5*(YC(i,j)+YC(i,j-1))

If you look closely you will see that xU/V etc are not written to a netcdf
file, the corresponding lines in write_grid.F are commented out. As far as I
can see there are no variables XU/XV, etc in the code (and there needed be
any). I think that the above way of computing these variables is not perfect
but probably good enough for most purposes (e.g., plotting). If you want to
compute divergences, it's better to use the dx/dy information from the model
rather than computing it again from coordinates that you have to  construct
a posteriori, right?

Martin

On Nov 5, 2012, at 8:40 AM, Simone Sammartino wrote:

> Hi Martin
> Sorry for my late but I was out in the sea..:-)
> I had to calculate manually the XU/V and YU/V grid...
> The correct location of the XU/V and YU/V coordinates in a curvilinear
> grid is given by the following:
>
> XU(Ix,Iy) = XC(Ix,Iy)-((DXG(Ix,Iy)/2)*ACS(Ix,Iy))/faclon;
> YU(Ix,Iy) = YC(Ix,Iy)-((DXG(Ix,Iy)/2)*ASN(Ix,Iy))/faclat;
>
> XV(Ix,Iy) = XC(Ix,Iy)+((DYG(Ix,Iy)/2)*ASN(Ix,Iy))/faclon;
> YV(Ix,Iy) = YC(Ix,Iy)-((DYG(Ix,Iy)/2)*ACS(Ix,Iy))/faclat;
>
> where:
>
> - Ix,Iy is a couple of indexes of the grid
> - ACS and ASN are the cos and the sin, respectively, of the angle between
> the Ix,Iy -th cell and the equator
> - faclon and faclat are conversion factors representing the length in
> meters of one degree at the longitude and latitude of the Ix,Iy -th cell,
> which can be calculated respectively as, for instance:
>
> faclon = 1000*m_lldist([XC(Ix,Iy)-.5 XC(Ix,Iy)+.5],[YC(Ix,Iy) YC(Ix,Iy)]);
> faclat = 1000*m_lldist([XC(Ix,Iy) XC(Ix,Iy)],[YC(Ix,Iy)-.5 YC(Ix,Iy)+.5]);
>
> by using the m_lldist function of the m_map toolbox.
>
> In any case the discrepancy between the correct XY/UV location and the one
> calculated by half XY/CG cells is proportional to the angle of the cell
> and it is variable in a curvilinear grid.
> Hence, if the XY/UV grid is written as XU=XG, YU=YC, XV=XC and YV=YG in
> the NETCDF case (as it seems) it is correct only for the cartesian grid.
> Otherwise the grids are badly located.
>
> Thank you
>
> Simone
>
>
> -------------------------------------
> Simone Sammartino
> Physical Oceanography Research Group
> University of Málaga
> GOFIMA
> Campus Teatinos s/n
> ETSI Telecomunicación
> 29071 Málaga (Spain)
>
> Tel: +34 952 13 28 49
> http://oceano.uma.es
> --------------------------------------
> Do you really need to print this message?
> Let's protect the environment.
> -----Mensaje original----- From: Martin Losch
> Sent: Sunday, October 28, 2012 11:18 AM
> To: mitgcm-support at mitgcm.org
> Subject: Re: [MITgcm-support] XU, YU and XV,YV coordinates in the
> curvilinear grid...
>
> Simone,
>
> the location of the velocity points is the same on all of the grids.
> I am afraid, you'll have to compute XU/YU, and XV/YV yourself as averages
> of XC/G, and YC/G. That's usually good enough.
>
> Martin
>
> On Oct 24, 2012, at 11:51 AM, Simone Sammartino wrote:
>
>> Hi
>> I’m working on outputs on a curvilinear grid...
>> I saw that the X-YU and X-YV grid are written in the NETCDF case
>> (http://mitgcm.org/viewvc/MITgcm/MITgcm/model/src/write_grid.F?view=markup),
>> but it seems they are not in the binary output format case.
>> The U coordinates are defined as XU=XG and YU=YC and the V coordinates as
>> XV=XC and YV=YG, but it is correct only in the case of a cartesian grid.
>> It does not correspond to the real U and V coordinates on a curvilinear
>> grid, which instead depends on the angle in X-YC.
>> So, two questions:
>> - Where are located the U and V vectors in the curvilinear grid?
>> - Why the X-YU and X-YV grid are not written in the binary output format?
>>
>> Thank you in advance
>>
>> Simone
>>
>> -------------------------------------
>> Simone Sammartino
>> Physical Oceanography Research Group
>> University of Málaga
>> GOFIMA
>> Campus Teatinos s/n
>> ETSI Telecomunicación
>> 29071 Málaga (Spain)
>>
>> Tel: +34 952 13 28 49
>> http://oceano.uma.es
>> --------------------------------------
>> Do you really need to print this message?
>> Let's protect the environment.
>> _______________________________________________
>> MITgcm-support mailing list
>> MITgcm-support at mitgcm.org
>> http://mitgcm.org/mailman/listinfo/mitgcm-support
>
>
> _______________________________________________
> MITgcm-support mailing list
> MITgcm-support at mitgcm.org
> http://mitgcm.org/mailman/listinfo/mitgcm-support
>
> _______________________________________________
> MITgcm-support mailing list
> MITgcm-support at mitgcm.org
> http://mitgcm.org/mailman/listinfo/mitgcm-support

_______________________________________________
MITgcm-support mailing list
MITgcm-support at mitgcm.org
http://mitgcm.org/mailman/listinfo/mitgcm-support

```