I just started to play with the newest version of ROMS, and one important update is the way it handles grid nesting. The new ROMS now requires users to provide a 'contact' file to specify the overlapping regions between nesting grids. However I ran into some difficulties while trying to use the 'contact.m' script to generate 'contact' files. Following are the details:
I plan to do a 3-layer nesting, and I already have the parent grid. The parent grid is already created with reasonable bathymetry and masking, and the parent grid is named 'roms_grid_lyr1.nc' (size(h)=300x120).
I used the following code to create child and grand-child grids and create the contact file:
Code: Select all
netcdf_load roms_grid_lyr1.nc
% child grid lyr 2 - ref5
% Select child indices
Istr=130; Iend=174; Jstr=40; Jend=104; %
%now make some plots and call the coarse-> fine
ref_ratio=5;
F=coarse2fine('roms_grid_lyr1.nc','roms_grid_lyr2_ref5.nc', ...
ref_ratio,Istr,Iend,Jstr,Jend);
% grand-child grid lyr 3 - ref3
netcdf_load roms_grid_lyr2_ref5.nc
% Select child indices
Istr=75; Iend=171; Jstr=60; Jend=249; %
%now make some plots and call the coarse-> fine
ref_ratio=3;
F=coarse2fine('roms_grid_lyr2_ref5.nc','roms_grid_lyr3_ref3.nc', ...
ref_ratio,Istr,Iend,Jstr,Jend);
Code: Select all
Gnames={'roms_grid_lyr1.nc', 'roms_grid_lyr2_ref5.nc'};
[S,G]=contact(Gnames,'roms_contact.nc');
Code: Select all
Gnames={'roms_grid_lyr1.nc', 'roms_grid_lyr2_ref5.nc', 'roms_grid_lyr3_ref3.nc'};
[S,G]=contact(Gnames,'roms_contact.nc');
Code: Select all
Is =
Empty matrix: 0-by-1
Error using .*
Matrix dimensions must agree.
Error in grid_connections (line 224)
Iwest = ones(size(Jwest )).*Is;
Error in contact (line 316)
S = grid_connections(G, S);
Code: Select all
Gnames={'roms_grid_lyr2_ref5.nc', 'roms_grid_lyr3_ref3.nc'};
[S,G]=contact(Gnames,'roms_contact.nc');
Code: Select all
Error using .*
Matrix dimensions must agree.
Error in grid_connections (line 224)
Iwest = ones(size(Jwest )).*Is;
Error in contact (line 316)
S = grid_connections(G, S);
I've attached my parent grid file, so you can easily repeat the above problem.
I thank you for your kind help!
Xiufeng