Variables for Masked Grid Cells

General scientific issues regarding ROMS

Moderators: arango, robertson

Post Reply
Message
Author
soilinkin
Posts: 11
Joined: Mon Apr 19, 2021 5:16 pm

Variables for Masked Grid Cells

#1 Unread post by soilinkin »

Hi, I have a model run blow-up at the first time step. My first suspect is the grid file generated with Delft3D.

Variables like coordinates are all set to -999 or Nan for the masked grid cells when the grid is generated in Delft3D, while all the unmasked cells have normal values. So there is no way I can calculate the rest of the variables like dmde/dndx.

My question is whether this is a potential reason that results the blow up of the model?

If so, has anybody run into the same issue and got an advice on how to handle the masked cells?

Or does anyone know is there any kind of requirement from ROMS for the variables of the grid file?

Thanks ahead.

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

Re: Variables for Masked Grid Cells

#2 Unread post by wilkin »

Yes, that's a problem. ROMS computes on all cells and then applies the masks. So, NaN values just inside the coastline can propagate into the interior. Zero values of, say, depth (but also other grid metrics) can cause divide-by-zero.

Just fill the land with modest finite values and the masks should make things OK. ROMS does not actually use lon/lat while running unless you are using the regrid option for surface forcing.
John Wilkin: DMCS Rutgers University
71 Dudley Rd, New Brunswick, NJ 08901-8521, USA. ph: 609-630-0559 jwilkin@rutgers.edu

soilinkin
Posts: 11
Joined: Mon Apr 19, 2021 5:16 pm

Re: Variables for Masked Grid Cells

#3 Unread post by soilinkin »

wilkin wrote: Mon Dec 20, 2021 12:39 pm Yes, that's a problem. ROMS computes on all cells and then applies the masks. So, NaN values just inside the coastline can propagate into the interior. Zero values of, say, depth (but also other grid metrics) can cause divide-by-zero.

Just fill the land with modest finite values and the masks should make things OK. ROMS does not actually use lon/lat while running unless you are using the regrid option for surface forcing.
Thanks a lot. But I am also seeing in the log file that spacing in x/y direction are calculated based on x_rho/y_rho (and also for psi and u/v points). Will this affect model runs in any way? By having -999 as coordinates will results in crazy spacing stats. I assume ROMS will still need X/Y coordinates (maybe not lon/lat?), at least for unmasked grid cells. Does assigning random values (-999, Nan or 0) for X/Y coordinates of masked cells also make a problem?

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

Re: Variables for Masked Grid Cells

#4 Unread post by wilkin »

The min/max grid spacings reported in the log ... e.g.

Code: Select all

 Metrics information for Grid 01:
 ===============================

 Minimum X-grid spacing, DXmin =  2.14507269E-01 km    Water points =  2.30213420E-01 km
 Maximum X-grid spacing, DXmax =  2.20401588E+00 km    Water points =  1.53947491E+00 km
are calculated from the grid Lamé coordinates (pm, pn), not x_rho etc. The values of pn,pn definitely have to be finite because metrics.F computes their reciprocal.

Don't use zeros or NaNs. Just fill the masked areas of all grid metrics (h, pn, pn, dmde, etc.) with finite positive values.
John Wilkin: DMCS Rutgers University
71 Dudley Rd, New Brunswick, NJ 08901-8521, USA. ph: 609-630-0559 jwilkin@rutgers.edu

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

Re: Variables for Masked Grid Cells

#5 Unread post by wilkin »

Here for example is what NOAA NOS did to pad out cells in the land for their Chesapeake Bay CBOFS grid, which was computed with Delft tools.

This shows "dy" grid spacing (1/pn) plotted in the grid i,j coordinates, because the filled bogus lon/lats in the land mess up my plotting routines (if lon_rho,lat_rho are not defined in the mask, Matlab pcolor can't correctly color the cells along the coast). But this is of no consequence to ROMS, because ROMS doesn't use the lon/lat (except, as I said, you are regridding meteorology inputs)
cbofs_dy_ijcoords.png
John Wilkin: DMCS Rutgers University
71 Dudley Rd, New Brunswick, NJ 08901-8521, USA. ph: 609-630-0559 jwilkin@rutgers.edu

soilinkin
Posts: 11
Joined: Mon Apr 19, 2021 5:16 pm

Re: Variables for Masked Grid Cells

#6 Unread post by soilinkin »

wilkin wrote: Mon Dec 20, 2021 5:51 pm Here for example is what NOAA NOS did to pad out cells in the land for their Chesapeake Bay CBOFS grid, which was computed with Delft tools.

This shows "dy" grid spacing (1/pn) plotted in the grid i,j coordinates, because the filled bogus lon/lats in the land mess up my plotting routines (if lon_rho,lat_rho are not defined in the mask, Matlab pcolor can't correctly color the cells along the coast). But this is of no consequence to ROMS, because ROMS doesn't use the lon/lat (except, as I said, you are regridding meteorology inputs)

cbofs_dy_ijcoords.png
Appreciate it. That definitely helps a lot. I will give it a try.

Post Reply