How do I input my own netCDF grid file for the ROMS Upwelling test case?

Discussion of how to use ROMS on different regional and basin scale applications.

Moderators: arango, robertson

Post Reply
Message
Author
satpal97

How do I input my own netCDF grid file for the ROMS Upwelling test case?

#1 Unread post by satpal97 »

Hi everyone, I am fairly new to ROMS and would like to ask for some assistance with this matter.

I have generated a ROMS grid file using GridBuilder but I am still at a loss on how exactly do I input it into ROMS so that i can use it to run the test case.

From what I've read, if I'm not mistaken, I need to change something in the .in file and specify the file path but I am still unsure of which lines to change and what to change them to.
I would really appreciate the help, thanks in advance.

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

Re: How do I input my own netCDF grid file for the ROMS Upwelling test case?

#2 Unread post by jcwarner »

for the upwelling case you would need to edit
ROMS/Include/upwelling.h and change
#define ANA_GRID
to
#undef ANA_GRID

recompile,

and change ROMS/External/roms_upwelling.in from
GRDNAME == roms_grd.nc
to
GRDNAME == YOUR GRID NAME here

-j

satpal97

Re: How do I input my own netCDF grid file for the ROMS Upwelling test case?

#3 Unread post by satpal97 »

Hi, thank you very much for the reply, with your instruction I've managed to input the grid file that I had created although I am now facing another error when trying to initialize the grid into ROMS. Below, I have quoted the part with the error report and I have also linked the grid file that I had used for reference. Any help would be much appreciated.


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

Minimum X-grid spacing, DXmin = 1.22457610E+00 km
Maximum X-grid spacing, DXmax = 1.23014833E+00 km
Minimum Y-grid spacing, DYmin = 1.31144803E+00 km
Maximum Y-grid spacing, DYmax = 1.31731833E+00 km
Minimum Z-grid spacing, DZmin = -5.58178863E+04 m
Maximum Z-grid spacing, DZmax = 6.41893191E+04 m

Minimum barotropic Courant Number = 6.17434678E-04
Maximum barotropic Courant Number = 5.67528612E-01
Maximum Coriolis Courant Number = 1.96322470E-03

ANA_INITIAL - vertically integrated u-momentum component: ubar
(Grid = 01, Min = 0.00000000E+00 Max = 0.00000000E+00)
ANA_INITIAL - vertically integrated v-momentum component: vbar
(Grid = 01, Min = 0.00000000E+00 Max = 0.00000000E+00)
ANA_INITIAL - free-surface: zeta
(Grid = 01, Min = 0.00000000E+00 Max = 0.00000000E+00)
ANA_INITIAL - u-momentum component: u
(Grid = 01, Min = 0.00000000E+00 Max = 0.00000000E+00)
ANA_INITIAL - v-momentum component: v
(Grid = 01, Min = 0.00000000E+00 Max = 0.00000000E+00)
ANA_INITIAL - potential temperature: temp
(Grid = 01, Min = 2.00000000E+01 Max = 2.00000000E+01)
ASAN:DEADLYSIGNAL
=================================================================
==4175==ERROR: AddressSanitizer: FPE on unknown address 0x55c2f55cc445 (pc 0x55c2f55cc445 bp 0x7ffd1492a2b0 sp 0x7ffd14929940 T0)
#0 0x55c2f55cc444 in stiffness_tile /home/satpal/roms_project/test/Windbasin/Build_romsG/stiffness.f90:179
#1 0x55c2f55da477 in __stiffness_mod_MOD_stiffness /home/satpal/roms_project/test/Windbasin/Build_romsG/stiffness.f90:72
#2 0x55c2f4a48d74 in initial_ /home/satpal/roms_project/test/Windbasin/Build_romsG/initial.f90:315
#3 0x55c2f48123b3 in __ocean_control_mod_MOD_roms_initialize /home/satpal/roms_project/test/Windbasin/Build_romsG/ocean_control.f90:120
#4 0x55c2f480d873 in ocean /home/satpal/roms_project/test/Windbasin/Build_romsG/master.f90:73
#5 0x55c2f480de15 in main /home/satpal/roms_project/test/Windbasin/Build_romsG/master.f90:50
#6 0x7f92fdcabb96 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21b96)
#7 0x55c2f480d639 in _start (/home/satpal/roms_project/test/Windbasin/romsG+0x1eab639)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: FPE /home/satpal/roms_project/test/Windbasin/Build_romsG/stiffness.f90:179 in stiffness_tile
https://drive.google.com/file/d/1lf0fsz ... sp=sharing

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

Re: How do I input my own netCDF grid file for the ROMS Upwelling test case?

#4 Unread post by jcwarner »

probably something to do with the bathy

Minimum Z-grid spacing, DZmin = -5.58178863E+04 m
Maximum Z-grid spacing, DZmax = 6.41893191E+04 m

at 1 km grid spacing, you probably should not have any negative depths (these would be elevations on land above the sea level).
suggest you set a min depth = 1 m or 2m ??

yusriy
Posts: 5
Joined: Wed Sep 25, 2019 9:23 pm
Location: Universiti Sains Malaysia

Re: How do I input my own netCDF grid file for the ROMS Upwelling test case?

#5 Unread post by yusriy »

Hi everyone!

I am in the same boat as satpal97. I want to run a local grid using the upwelling test case but faced the same error.

This is what I did so far. I created the grid using GridBuilder, changed #define to #undef for the ANA_GRID in the upwelling.h file, recompiled, edited the roms_upwelling.in from roms_grd.nc to my_own.nc. I have left everything else at default. I have also set the min depth = 2 m. Somehow I am still getting the DZmin = -4.4E+04 m. What am I missing?

PS. Anyway, is there a step-by-step tutorial somewhere on setting up a ROMS model for an area from scratch? Like building the local grid, setting the model parameters (grid and boundary conditions), and then running the model for a specific location on Earth? I've gone through all the video tutorials on myroms.org and they are on running the test cases, which has everything already set up.

Any assistance is greatly appreciated. Thanks!
Metrics information for Grid 01:
===============================

Minimum X-grid spacing, DXmin = 2.08667472E+00 km
Maximum X-grid spacing, DXmax = 2.09410389E+00 km
Minimum Y-grid spacing, DYmin = 5.91330658E-01 km
Maximum Y-grid spacing, DYmax = 5.94438630E-01 km
Minimum Z-grid spacing, DZmin = -4.43598035E+04 m
Maximum Z-grid spacing, DZmax = 2.67683452E+04 m

Minimum barotropic Courant Number = 1.84963855E-03
Maximum barotropic Courant Number = 1.77160519E+00
Maximum Coriolis Courant Number = 4.63724860E-03

ANA_INITIAL - vertically integrated u-momentum component: ubar
(Grid = 01, Min = 0.00000000E+00 Max = 0.00000000E+00)
ANA_INITIAL - vertically integrated v-momentum component: vbar
(Grid = 01, Min = 0.00000000E+00 Max = 0.00000000E+00)
ANA_INITIAL - free-surface: zeta
(Grid = 01, Min = 0.00000000E+00 Max = 0.00000000E+00)
ANA_INITIAL - u-momentum component: u
(Grid = 01, Min = 0.00000000E+00 Max = 0.00000000E+00)
ANA_INITIAL - v-momentum component: v
(Grid = 01, Min = 0.00000000E+00 Max = 0.00000000E+00)
ASAN:DEADLYSIGNAL
=================================================================
==5943==ERROR: AddressSanitizer: FPE on unknown address 0x5621c06303f2 (pc 0x5621c06303f2 bp 0x7ffcc2913270 sp 0x7ffcc2912c50 T0)
#0 0x5621c06303f1 in __stats_mod_MOD_stats_3dfld /home/eckeratong/roms_project/upwelling_local_grd/Build_romsG/stats.f90:350
#1 0x5621c060073e in __analytical_mod_MOD_ana_nlminitial_tile /home/eckeratong/roms_project/upwelling_local_grd/Build_romsG/analytical.f90:482
#2 0x5621c0607d82 in __analytical_mod_MOD_ana_initial /home/eckeratong/roms_project/upwelling_local_grd/Build_romsG/analytical.f90:233
#3 0x5621bf162ac1 in initial_ /home/eckeratong/roms_project/upwelling_local_grd/Build_romsG/initial.f90:212
#4 0x5621bee8d7c7 in __ocean_control_mod_MOD_roms_initialize /home/eckeratong/roms_project/upwelling_local_grd/Build_romsG/ocean_control.f90:120
#5 0x5621bee88e5c in ocean /home/eckeratong/roms_project/upwelling_local_grd/Build_romsG/master.f90:73
#6 0x5621bee893f2 in main /home/eckeratong/roms_project/upwelling_local_grd/Build_romsG/master.f90:50
#7 0x7fdf371643f0 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x203f0)
#8 0x5621bee88c29 in _start (/home/eckeratong/roms_project/upwelling_local_grd/romsG+0x2065c29)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: FPE /home/eckeratong/roms_project/upwelling_local_grd/Build_romsG/stats.f90:350 in __stats_mod_MOD_stats_3dfld
==5943==ABORTING

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

Re: How do I input my own netCDF grid file for the ROMS Upwelling test case?

#6 Unread post by wilkin »

When ROMS runs it writes the grid information to the output netcdf files. Everything is in there to actually use the history file as a grid file.

So test this out. Run UPWELLING with the ana_grid option for a brief simulation.

Then #undef ANA_GRID and instead point GRDNAME to the history file. Does that work?

If so, then look closely at h, pm, pn etc. in comparison to the values you created with grid builder to track the problem.
John Wilkin: DMCS Rutgers University
71 Dudley Rd, New Brunswick, NJ 08901-8521, USA. ph: 609-630-0559 jwilkin@rutgers.edu

yusriy
Posts: 5
Joined: Wed Sep 25, 2019 9:23 pm
Location: Universiti Sains Malaysia

Re: How do I input my own netCDF grid file for the ROMS Upwelling test case?

#7 Unread post by yusriy »

Thanks for the suggestion! I will try that now and post the result here.

yusriy
Posts: 5
Joined: Wed Sep 25, 2019 9:23 pm
Location: Universiti Sains Malaysia

Re: How do I input my own netCDF grid file for the ROMS Upwelling test case?

#8 Unread post by yusriy »

wilkin wrote: Wed Jun 10, 2020 11:45 am When ROMS runs it writes the grid information to the output netcdf files. Everything is in there to actually use the history file as a grid file.

So test this out. Run UPWELLING with the ana_grid option for a brief simulation.

Then #undef ANA_GRID and instead point GRDNAME to the history file. Does that work?

If so, then look closely at h, pm, pn etc. in comparison to the values you created with grid builder to track the problem.
I ran the UPWELLING test case with the ANA_GRID defined and then applied the rom_his.nc file. It worked. I then compared the roms_his.nc file with the output of GridBuilder and saw that the output still contains negative h values.

I proceeded to create another grid using GridBuilder and this time without the coast or land and the UPWELLING test case was able to run. So, we can conclude that the UPWELLING test case was not able to run with negative values of h.

My question is, how can we still run the test case but with land in the grid?

We have applied "mask" to tiles that are above the water surface and defined MASKING in the upwelling.h file. But the result is similar to the original post.

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

Re: How do I input my own netCDF grid file for the ROMS Upwelling test case?

#9 Unread post by wilkin »

ROMS computes on all points, even the land, and then masks the result afterward.

So you can't have h < 0 anywhere - including in the land. There are many places where terms in the ROMS equations involve a division by zeta+h, so if this is zero or close to it then there's your problem.

Where you have land (mask_rho = 0) set h to some finite positive value. Most users choose the minimum depth in the valid water points as the value to use where there is land.
John Wilkin: DMCS Rutgers University
71 Dudley Rd, New Brunswick, NJ 08901-8521, USA. ph: 609-630-0559 jwilkin@rutgers.edu

yusriy
Posts: 5
Joined: Wed Sep 25, 2019 9:23 pm
Location: Universiti Sains Malaysia

Re: How do I input my own netCDF grid file for the ROMS Upwelling test case?

#10 Unread post by yusriy »

Where you have land (mask_rho = 0) set h to some finite positive value. Most users choose the minimum depth in the valid water points as the value to use where there is land.
Thanks for the response! Do you have suggestions on how can I do the quoted above?

yusriy
Posts: 5
Joined: Wed Sep 25, 2019 9:23 pm
Location: Universiti Sains Malaysia

Re: How do I input my own netCDF grid file for the ROMS Upwelling test case?

#11 Unread post by yusriy »

Code: Select all

clear;

% Import the local grid netcdf file.
local_grid = '/your_folder/your_file.nc';
ncdisp(local_grid); % to preview the nc file
ncid3=netcdf.open(local_grid);

% Read the values from the original netcdf file
h(1:xi_rho,1:eta_rho) = ncread(local_grid,'h'); 
% Edit the values
h(h <= 0) = 2; % to a minimum of 2 m
depthmin = min(min(h));
depthmax = max(max(h));

% Write the values to the h value of the nc file
ncwrite(local_grid,'depthmin',depthmin);
ncwrite(local_grid,'depthmax',depthmax);
ncwrite(local_grid,'h',h);
For the benefit of other users, the above is the Matlab code to remove negative values of the h variable.

Post Reply