contact.m issue with fine grid on border of coarse grid

Bug reports, work arounds and fixes

Moderators: arango, robertson

Post Reply
Message
Author
jpringle
Posts: 108
Joined: Sun Jul 27, 2003 6:49 pm
Location: UNH, USA

contact.m issue with fine grid on border of coarse grid

#1 Unread post by jpringle »

Dear all -- I just want to document a bug in contact.m, and to ask if anyone has succeed in putting a refined grid next to a model boundary?

I am using the latest version of the matlab tools, from SVN revision 722. I create a coarse resolution grid, which I have attached to this post. I then create a high resolution file with coarse2fine.m and then run contacts with the following code:

Code: Select all

cgridname='ocean_grid_SVD.nc'        %input
fgridname='ocean_grid_WB.nc'         %created
outname='baseTwoGrids_contacts.nc'   %created

Imin=3; Imax=36;
Jmin=3; Jmax=453;

fgrid=coarse2fine(cgridname,fgridname,3,Imin,Imax,Jmin,Jmax);
grids={cgridname,fgridname}
[S,G]=contact(grids,outname,false,false,false)
I would like the fine grid to lie along the Imin=1 boundary (this boundary is a wall; I am not trying to nest into an open boundary). But if Imin<3, contact.m fails. The failure mode is different between Imin=2 and Imin=1; the errors are documented below if anyone cares.

If anyone has got contact.m to work along a grid boundary, I would love to see their changes to the code.

I could deal with this fixing contact.m. But I am loath to do so when Hernan says he is about to release a revised version. Instead I could use a land mask to offset the land/sea boundary from the model boundary. Can anyone think of a better way? Has anyone sealed off an entire boundary of the fine grid with a mask?

Cheers, and thanks,
Jamie

Error if Imin=1 and Jmin=1:

Code: Select all

 Error in <a href="matlab:matlab.internal.language.introspective.errorDocCallback('contact>refinement', '/Users/pringle/workfiles/dPdy/runs/make_grids_and_contacts/matlab/grid/contact.m', 1505)" style="font-weight:bold">contact>refinement</a> (<a href="matlab: opentoline('/Users/pringle/workfiles/dPdy/runs/make_grids_and_contacts/matlab/grid/contact.m',1505,0)">line 1505</a>)
 Ngrids      = length(G);             % number of nested grids

 Output argument "R" (and maybe others) not assigned during call to
 "/Users/pringle/workfiles/dPdy/runs/make_grids_and_contacts/matlab/grid/contact.m>refinement".

 Error in contact (line 322)
     [P, R] = refinement (cr, dg, rg, Lmask, G, S, MaskInterp);

 Error in make_contacts (line 5)
 [S,G]=contact(grids,outname,false,false,true)
Error if Imin=2 and Jmin=2

Code: Select all

Error using sub2ind (line 52)
 Out of range subscript.

 Error in contact>Hweights (line 2453)
     RindexB = sub2ind([Ir, Jr],                                         ...

 Error in contact (line 352)
 S = Hweights(G, S, ImposeMask);

 Error in make_contacts (line 5)
 [S,G]=contact(grids,outname,false,false,true)
Attachments
ocean_grid_SVD.nc
(31.41 MiB) Downloaded 324 times

jpringle
Posts: 108
Joined: Sun Jul 27, 2003 6:49 pm
Location: UNH, USA

Re: contact.m issue with fine grid on border of coarse grid

#2 Unread post by jpringle »

Ah... I noticed in an email from John Wilkins that he told me
We are taking this a step at a time. As you say, presently the Matlab tools have been written assuming the nest is wholly within the parent, but the ROMS design anticipates the day that the contact file can allow a nest to cross the parent perimeter.

A complication is that in the most general case this might require that the open boundary condition along one boundary in the nest change from "nested" to e.g. "closed" at the parent perimeter. The logic is tortuous. A way around having to deal with this - the next intermediate step - would be to have the nest be strictly masked land around its entire perimeter outside the parent. I believe this is what JCW and Ralston did for the Hudson composite grid. I don't know if they have Matlab code for generating the contact points in this case in the new nesting paradigm. Feel free to write yourself and share ;-)
As mentioned above, I will make do with land masking. Thanks to everyone getting this to work.

Jamie

simion1232006
Posts: 60
Joined: Tue Sep 29, 2009 3:50 pm
Location: School of Environment System Engineering,UWA

Re: contact.m issue with fine grid on border of coarse grid

#3 Unread post by simion1232006 »

I assume this is not a bug but rather a limited functionality. As long as your nested grid would not cross the border or within few grid of the coarse model border, there should not be any issue. When doing interpolation from donor grid to receiver grid, I think you'd better allow couple of grids of buffer zone.

Post Reply