Seagrid error

Discussion about analysis, visualization, and collaboration tools and techniques

Moderators: arango, robertson

Post Reply
Message
Author
drewa
Posts: 35
Joined: Mon Dec 17, 2007 5:34 pm
Location: SCCWRP, Costa Mesa, CA

Seagrid error

#1 Unread post by drewa »

I've been working on generating a grid using the ROMSgui interface. I'm using Matlab R2007b and have installed what I believe I need to (netcdf, mexnc, etc). I've also added the Presto (and sub-directories) and mex_matlab_linux32 to my path.

I've gone through the steps outlined in the tutorial and made a grid using the amazon coastline and depths. I am able to develop a grid and process it into a netCDF file but I got an error message that I don't understand.

************************************************
>> seagrid2roms('test_roms.mat')

theRomsFile =

/home/drew/Programs/Matlab75/Downloads/seagrid/test_roms_grd.nc

## SeaGrid Source File : test_roms.mat
## ROMS Destination File: /home/drew/Programs/Matlab75/Downloads/seagrid/test_roms_grd.nc
??? Error using ==> feval
Invalid MEX-file '/home/drew/Programs/Matlab75/Downloads/matlab/netcdf/mexcdf53.mexglx':
/home/drew/Programs/Matlab75/Downloads/matlab/netcdf/mexcdf53.mexglx: undefined symbol: _fxstat.

Error in ==> ncmex at 139
[varargout{:}] = feval(fcn, varargin{:});

Error in ==> netcdf.create at 13
[theNCid, status] = ncmex('create', name(self), thePermission);

Error in ==> netcdf.netcdf at 413
result = create(result, thePermission);

Error in ==> seagrid2roms at 142
nc = netcdf(theRomsFile, 'clobber');
************************************************

Is this a critical error or is it something that can be safely ignored?
Thanks

rouf

#2 Unread post by rouf »

I am using Matlab7.1(R14-SP3). My seagrid version of 23-Apr-2001 16:26:45. All Seagrid seems work very well except when I go to View and click Setup, it shows the following error

??? Error using ==> mat2str
Too many input arguments.

Error in ==> guido at 316
theControls(end+1) = uicontrol( ...

Error in ==> seagrid.dosetup at 83
s = guido(SeaGrid_Setup);

Error in ==> seagrid.doevent at 187
dosetup(self)

Error in ==> psevent at 25
doevent(ps(gcbf), theEvent, theMessage);

??? Error while evaluating uimenu Callback.


can anyone help me?

Rouf

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

#3 Unread post by wilkin »

I think you're going to have to provide a little more information than that before anyone can help you.

First of all, and you *ever* been able to get seagrid to work for you on a test case? We need to know whether your set-up simply does not work, or whether is does not work they way you are trying to use it for your own project.

There is a seagrid tutorial at http://woodshole.er.usgs.gov/operations ... orial.html

If the download source noted in the tutorial page is not where you got the code, then perhaps that is your problem.

The tutorial clearly lays out the steps

* A -- Getting Started, Loading Data
* B -- Corner Points, Edge Points
* C -- Orthogonality, Spacers
* D -- Saving, Masking
* E -- Bathymetry

In your next posting, indicate where in this process seagrid fails for you.
John Wilkin: DMCS Rutgers University
71 Dudley Rd, New Brunswick, NJ 08901-8521, USA. ph: 609-630-0559 jwilkin@rutgers.edu

rouf

#4 Unread post by rouf »

I am using seagrid Version of 23-Apr-2001 16:26:45. I downloaded the source from http://woodshole.er.usgs.gov/operations ... agrid.html
And followed the tutorial. Tutorial section A,C,D and E work properly except the section B. According to this section B, I can Define corner points, Add edge points and Zoom. After that, when I go to the setup dialog, I select View/Setup in seagrid but no screen appear to change grid size and shows following error in Matlab 7.1. So I cant change the grid-sizes.

??? Error using ==> mat2str
Too many input arguments.

Error in ==> guido at 316
theControls(end+1) = uicontrol( ...

Error in ==> seagrid.dosetup at 83
s = guido(SeaGrid_Setup);

Error in ==> seagrid.doevent at 187
dosetup(self)

Error in ==> psevent at 25
doevent(ps(gcbf), theEvent, theMessage);

??? Error while evaluating uimenu Callback.


I hope the explanation will make clear about my problem.

Rouf

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

#5 Unread post by wilkin »

In the very first window that seagrid opens (immediately after you start the seagrid function) can you follow the tutorial instructions to define 4 corner points? You should get a simple 10x10 mesh looking something like:
http://woodshole.er.usgs.gov/operations ... al_050.jpg
(never mind about the coastline etc. - that can come later.)
Define Corner Points -- In the main "SeaGrid" window, click on four points with mouse button #1 to define the grid boundary approximately. Once established, the corner points can be refined by dragging with mouse button #1. The starting corner point, marked by an asterisk (*), can be rolled counter-clockwise to the next corner by selecting the "View/Roll" menu item. Edge #1 follows counterclockwise from the (*) to the next corner. Edge #2 is the next one along. Grid-cell spacings are determined along those two edges. (See "spacer" steps below.)
If you get the simple mesh, can you then select the menu VIEW > SETUP ... to define a new number of points.

If this doesn't work, I can only assume there is something nonstandard with your Matlabpath, or your download of the seagrid code was corrupted.
John Wilkin: DMCS Rutgers University
71 Dudley Rd, New Brunswick, NJ 08901-8521, USA. ph: 609-630-0559 jwilkin@rutgers.edu

rouf

#6 Unread post by rouf »

Yes I can follow the tutorial instructions to define 4 corner points immediately after the seagrid function. I can get simple mesh. But VIEW>SETUP is showing the above errors.

I am bit worried about seagrid code corruption. As you know, earlier I faced a problem with Mex files then according to you and John Evans suggestion (I quoted here) I download the seagrid version of 23-Apr-2001 16:26:45.
I asked John Evans at The Mathworks about this, and he is as mystified as me. Here is his reply:
Quote:
Uhm, hmm, my first thought was that the user must be using an old mex-file, because the 7.1 release is supposed to be using "*.mexw32" instead of "*.dll" for an extension... but it looks like I was the one who built it as a *.dll in the first place. Looking a bit further, it seems that dropping the dll extension is strongly recommended, but not required for 7.1. It *should* still work, though. I went ahead and rebuilt the win32 mex-file for 7.1 (R14sp3) as having the "*.mexw32" extention. It tests ok and is posted at the sourceforge site. Tell the user to try it out.


So I suggest you try John's new mex files posted on sourceforge where you got the files before, and let us know what happens.
It solved the error regarding Mex files. But I am worried about the corruption of seagrid code even it solved Mex related errors earlier. Is it possible to crosscheck the seagrid version of 23-Apr-2001 16:26:45, particularly in changing grid size (in menu VIEW>SETUP)?

Rouf

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

#7 Unread post by wilkin »

Then if you think your code is corrupted, download it again, unzip it, and do a diff on all the files. Or just run the new version (possibly with the new mex files you already have) and see if that works.

The tests I've led you through certainly indicate it is failing for no obvious other reason.
John Wilkin: DMCS Rutgers University
71 Dudley Rd, New Brunswick, NJ 08901-8521, USA. ph: 609-630-0559 jwilkin@rutgers.edu

leon
Posts: 78
Joined: Mon Mar 03, 2008 4:14 am

Re: Seagrid error

#8 Unread post by leon »

There are two mat2str functions, one is in the mexcdf5 directory of ROMS matlab tool, and the other one is in matlab/toolbox/matlab/strfun/ directory. The two mat2str functions are different.
The first one is :
function s = mat2str(x)

% MAT2STR String equivalent to a matrix.
% MAT2STR(X) converts matrix X to a one-line
% string which is roughly equivalent
% to X, for display purposes. If X is
% larger than a scalar, then its values are
% written between square brackets.

% Copyright (C) 1991 Charles R. Denham, Zydeco.

if nargin < 1
help mat2str
x = [1 2 3; pi inf nan];
disp(' The matrix:'), disp(' ')
disp(x), disp(' becomes the string:'), disp(' ')
disp([' ' mat2str(x)])
return
end

quote = '''';

[m, n] = size(x);

s = '';
bracket = isstr(x) & m > 1 | ~isstr(x) & length(x) > 1;
if bracket, s = ['[']; end

for i = 1:m
if isstr(x)
t = [quote x(i, :) quote];
s = [s t];
else
for j = 1:n
z = x(i, j);
if isnan(z)
t = 'nan';
elseif z == inf
t = 'inf';
elseif z == -inf
t = '-inf';
elseif z == fix(z)
t = int2str(z);
else
t = num2str(z);
end
s = [s t];
if j < n, s = [s ' ']; end
end
end
if i < m, s = [s '; ']; end
end

if bracket, s = [s ']']; end


The other one is :
function string = mat2str(matrix, varargin)
%MAT2STR Convert a 2-D matrix to a string in MATLAB syntax.
% STR = MAT2STR(MAT) converts the 2-D matrix MAT to a MATLAB
% string so that EVAL(STR) produces the original matrix (to
% within 15 digits of precision). Non-scalar matrices are
% converted to a string containing brackets [].
%
% STR = MAT2STR(MAT,N) uses N digits of precision.
%
% STR = MAT2STR(MAT, 'class') creates a string with the name of the class
% of MAT included. This option ensures that the result of evaluating STR
% will also contain the class information.
%
% STR = MAT2STR(MAT, N, 'class') uses N digits of precision and includes
% the class information.
%
% Example
% mat2str(magic(3)) produces the string '[8 1 6; 3 5 7; 4 9 2]'.
% a = int8(magic(3))
% mat2str(a,'class') produces the string
% 'int8([8 1 6; 3 5 7; 4 9 2])'.
%
% See also NUM2STR, INT2STR, SPRINTF, CLASS, EVAL.

% Copyright 1984-2005 The MathWorks, Inc.
% $Revision: 1.28.4.8 $ $Date: 2006/12/20 07:18:24 $

if nargin<1 || nargin>3
error(nargchk(1,3,nargin,'struct'));
end

numoptions = length(varargin);
useclass = false;
usedigits = false;
for i = 1:numoptions
if ischar(varargin{i})
switch lower(varargin{i})
case 'class'
useclass = true;
otherwise
error('MATLAB:mat2str:InvalidOptionString','Optional string argument ''%s'' not supported.', varargin{i});
end
elseif isnumeric(varargin{i})
usedigits = true;
n = varargin{i};
else
error('MATLAB:mat2str:InvalidOptionType','Optional arguments must be numeric or strings.');
end
end

if (ndims(matrix) > 2)
error('MATLAB:mat2str:TwoDInput','Input matrix must be 2-D.');
end

if ~(isnumeric(matrix) || ischar(matrix) || islogical(matrix))
error('MATLAB:mat2str:NumericInput','Input matrix must be numeric.');
end

[rows, cols] = size(matrix);

if useclass
string = [class(matrix), '('];
else
if ischar(matrix) && ~isempty(matrix)
strings = cell(rows,1);
for row=1:rows
strings{row} = matrix(row,:);
end
needsConcatenation = rows > 1;

dangerousPattern = '[\0\n]';
hasDangerousChars = regexp(strings, dangerousPattern, 'once');

needsConcatenation = needsConcatenation | ~isempty([hasDangerousChars{:}]);

strings = strrep(strings, '''', '''''');
strings = regexprep(strings, dangerousPattern, ''' char(${sprintf(''%d'',$0)}) ''');

if needsConcatenation
string = '[';
else
string = '';
end

string = [string '''' strings{1} ''''];

for row = 2:rows
string = [string ';''' strings{row} '''']; %#ok
end

if needsConcatenation
string = [string ']'];
end

return;
end
string = '';
end

if isempty(matrix)
if (rows==0) && (cols==0)
if ischar(matrix)
string = [string ''''''];
else
string = [string '[]'];
end
else
string = [string 'zeros(' int2str(rows) ',' int2str(cols) ')'];
end
if useclass
string = [string, ')'];
end
return
end

if usedigits == false
n = 15;
form = '%.15g';
else
form = sprintf('%%.%dg',n);
end
pos = length(string)+1;
% now guess how big string will need to be
% n+7 covers (space) or +-i at the start of the string, the decimal point
% and E+-00. The +10 covers class string and parentheses.
if ~isreal(matrix)
spaceRequired = (2*(n+7)) * numel(matrix) + 10;
realFlag = false;
else
spaceRequired = ((n+7) * numel(matrix)) + 10;
realFlag = true;
end
string(1,spaceRequired) = char(0);

if rows*cols ~= 1
string(pos) = '[';
pos = pos + 1;
end

for i = 1:rows
for j = 1:cols
if(matrix(i,j) == Inf)
string(pos:pos+2) = 'Inf';
pos = pos + 3;
elseif (matrix(i,j) == -Inf)
string(pos:pos+3) = '-Inf';
pos = pos + 4;
elseif islogical(matrix(i,j))
if matrix(i,j) % == true
string(pos:pos+3) = 'true';
pos = pos + 4;
else
string(pos:pos+4) = 'false';
pos = pos + 5;
end
else
if realFlag || isreal(matrix(i,j))
tempStr = sprintf(form,matrix(i,j));
len = length(tempStr);
string(pos:pos+len-1) = tempStr;
pos = pos+len;
else
tempStr = sprintf(form,real(matrix(i,j)));
len = length(tempStr);
string(pos:pos+len-1) = tempStr;
pos = pos+len;
if(imag(matrix(i,j)) < 0)
tempStr = ['-i*',sprintf(form,abs(imag(matrix(i,j))))];
else
tempStr = ['+i*',sprintf(form,imag(matrix(i,j)))];
end
len = length(tempStr);
string(pos:pos+len-1) = tempStr;
pos = pos+len;
end
end
string(pos) = ' ';
pos = pos + 1;
end
string(pos-1) = ';';
end
% clean up the end of the string
if rows * cols ~= 1
string(pos-1) = ']';
else
% remove trailing space from scalars
pos = pos - 1;
end
if useclass
string(pos) = ')';
pos = pos+1;
end
string = string(1:pos-1);
% end mat2str



You should check the mat2str function by type "<which mat2str" to see the seagrid invoking which mat2str. The correct one which seagrid should to invoke is the second.

Enjoy it!

User avatar
size
Posts: 3
Joined: Mon Nov 24, 2008 6:27 pm
Location: Ocean University of China

Re: Seagrid error

#9 Unread post by size »

hi everyone i'm very new to ROMS. My Matlab version is R2008a .I download mexnc_matlab_r2008a.tar from mexnc's source site. I install the mexnc following the installing guide in the tar file, and I install the seagrid ,add matlab's path /seagrid and /seagrid/mex_matlab76_win32 . The test goes very well until I use seagrid2roms,then it comes out erro like below:


## SeaGrid Source File : seagrid2.mat
## ROMS Destination File: seagrid.nc
Mex file entry point is missing. Please check the (case-sensitive)
spelling of mexFunction (for C MEX-files), or the (case-insensitive)
spelling of MEXFUNCTION (for FORTRAN MEX-files).
??? Invalid MEX-file 'D:\Users\size\Documents\MATLAB\tools\mexnc\win32\netcdf.dll': .

Error in ==> seagrid2roms at 142
nc = netcdf(theRomsFile, 'clobber');


Can anybody help me to solve this problem? Thanks!

wgjlove
Posts: 5
Joined: Wed Nov 12, 2008 4:24 pm
Location: Ocean University of China

Re: Seagrid error

#10 Unread post by wgjlove »

Hello,everyone!
I just began to learn how to use seagrid.I use windows as my system.I followed 'the seaGrid For matlab' tutorial,but when I dragged one point to a new position,the 'seagrid'window never show anything unless i click it,and the matlab will say:
theOrthogonalityFlag =

[]


theBathymetryFlag =

[]


theMaskingFlag =

[]


theMaskTool =

[]


theMaskToolFlag =

0


theOrthogonalityFlag =

[]


theBathymetryFlag =

[]


theMaskingFlag =

[]


theMaskTool =

[]


theMaskToolFlag =

0


theOrthogonalityFlag =

[]


theBathymetryFlag =

[]


theMaskingFlag =

[]


theMaskTool =

[]


theMaskToolFlag =

0


theOrthogonalityFlag =

[]


theBathymetryFlag =

[]


theMaskingFlag =

[]


theMaskTool =

[]
and
Error in ==> zoomsafe>doubleclick at 459
drawnow % Process the event-cue.

Error in ==> zoomsafe at 141
d = doubleclick; % Trap any double-click.

>>
Error in ==> zoomsafe>doubleclick at 459
drawnow % Process the event-cue.

Error in ==> zoomsafe at 141
d = doubleclick; % Trap any double-click.

??? Interrupt while evaluating figure WindowButtonDownFcn.

I did't know what's wrong with it ,can sb help me? I really appreciate it!Thank u very very very much!

angelolemos
Posts: 34
Joined: Wed Mar 11, 2009 4:24 pm
Location: UFES

Re: Seagrid error

#11 Unread post by angelolemos »

Hi everybody.
I have the same problem of DREWA, in the top of the session.
drewa, do you solved the problem?!
Someone can help us?!

Thanks!

mlicer
Posts: 5
Joined: Tue Jan 26, 2010 4:24 pm
Location: EARS

Re: Seagrid error

#12 Unread post by mlicer »

@rouf: i had the exact same error and i solved it using wgjlove's comment.

all you need to do is
0. type to matlab console: 'which -all mat2str'. this should show you two paths like this:
C:\Program Files\MATLAB\...\mexcdf5\mat2str.m
C:\Program Files\MATLAB\...\matlab\strfun\mat2str.m % Shadowed
you need to call the shadowed function ..\strfun\mat2str.m. this means you have to remove the other folder ..\mexcdf5\ from your matlab path - at least at the time of the call to mat2str! this is done as follows.

1. open guido.m (the function that crashes)
2. search for mat2str call in guido.m
3. remove the \mexcdf5\ folder from your matlab path AND add it back AFTER the mat2str call is made. the part around mat2str in guido.m should then look something like this:

%my addition: remove the path of the shadowing function:
rmpath('C:\Program Files\MATLAB\...\mexcdf5\');

%make the call to the correct mat2str, which is not shadowed anymore:
theControls(end+1) = uicontrol( ...
'Style', 'text', ...
'String', theField);
theControls(end+1) = uicontrol( ...
'Style', 'edit', ...
'Max', 1000, ...
'String', mat2str(theValue, thePrecision));

% my addition: add the mexcdf5 folder back to path:
addpath('C:\Program Files\MATLAB\...\mexcdf5\');


that worked for me. setup now works ok. hope this helps.

Post Reply