One possible nesting-related bug

Bug reports, work arounds and fixes

Moderators: arango, robertson

Post Reply
Posts: 5
Joined: Mon Dec 31, 2018 8:42 pm
Location: China Institute of Water Resources and Hydropower

One possible nesting-related bug

#1 Post by lizengocean09 »

contact.m works well for creating the nesting grid in the Cartesian coordinate system. However, when I made a nesting grid in the spherical coordinate system, I found there may be one bug in contact.m. Apologies if this is correct as it is.

lines 721-723
FSr.Values = G(dg).angle(:); R.angle = FCr(XrF, YrF);
FSr.Values = G(dg).f(:); R.f = FCr(XrF, YrF);
FSr.Values = G(dg).h(:); R.h = FCr(XrF, YrF);

should be
FSr.Values = G(dg).angle(:); R.angle = FSr(XrF, YrF);
FSr.Values = G(dg).f(:); R.f = FSr(XrF, YrF);
FSr.Values = G(dg).h(:); R.h = FSr(XrF, YrF);

However, one new problem occurs after I made these changes.

Subscripted assignment between dissimilar structures.
Error in contact (line 329)
S.refined(cr) = R;

Then I checked the function [S,G] = contact(Gnames, Cname, Lmask, MaskInterp, Lplot)
I found output S includs following two elements
S.refined(cr).xi_rho(:,:) - Receiver grid curvilinear
S.refined(cr).eta_rho(:,:) (XI,ETA) coordinates

However, R (R = refine_coordinates(cr, dg, rg, G, S, MaskInterp)) includes eight elements

Thanks a lot if you can look at them.

Posts: 6
Joined: Mon Jan 21, 2019 2:45 pm
Location: SNR Technology

Re: One possible nesting-related bug

#2 Post by Rintei »


Did you solve the problem? I tried to this problem,

Code: Select all

for cr=1:Ncontact
  dg =;
  rg =;
  if (
    P = coincident (cr, dg, rg, Lmask, G, S); = P;
  elseif (
    [P, R] = refinement (cr, dg, rg, Lmask, G, S, MaskInterp); = P;
    S.refined = R; %S.refined(cr) = R;
  Ndatum = Ndatum + length(                 ...
                  + length(                   ...
                  + length(;
S.refined(cr) = R; -> S.refined = R;
delete (cr) in matlab line 329.
I'm not sure if this is the way to go, but the problem with the code has been solved.

The struct type 'R' consists of:

Code: Select all

37th field data
spherical 1
uniform 0
xi_rho eta_rho lon_rho lat_rho Irg_rho Jrg_rho
xi_psi eta_psi lon_psi lat_psi Irg_psi Jrg_psi
xi_u eta_u lon_u lat_u Irg_u Jrg_u
xi_v eta_v lon_v lat_v Irg_v Jrg_v
angle f h pm pn dndx dmde
mask_rho mask_psi mask_u mask_v
This problem occurs because struct type 'R' cannot be changed into the 3D layers structure through the for loop in the usual way.
I can't say that's the right way, but if it's wrong, you'll need a different solution.

Look forward to hearing from you and others.



Post Reply