Shah, I have faced the same problem in the past.

When using curvilinear grids, i.e. where grid lines are not straight lines (for instance they they might follow depth contours), you have to be careful with x coordinate __matrix__.

Bathymetries defined using a curvilinear grid will comprise 3 files:

- X coordinate matrix
- Y coordinate matrix
- Depth values (Z matrix)

Assuming your along-shore direction is North -South, and assume also that you have land on the west and water east.

In this case, higher X coordinates are the ones at the open boundaries (at sea) and lower coordinates are on land.

if your coordinate matrix will grow from left to right, what XB will understand when assimilating data is: open boundary is on land (lower X values,

lower X matrix indices) and land boundary is at sea (higher X values, and

higher X matrix indices).

What you want to do is flip the X matrix coordinate from left to right , so that what I have outlined above inverts and things where they should belong. The model understands open boundary not from the x

*value* but from the x

*matrix index*.

Y and Z remain untouched.

X will be flipped (in

*MatLab*: fliplr).

For creating and editing curvilinear grids, I use D3D software (quickin and refgrid). It is a great tool, and XB has an extra dedicated input format:

gridform = delft3d

depfile = Name_of_depth_file.dep

xyfile = Name_of_grid_file.grd

Did this help?