Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
TSG QC
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
US191
TSG QC
Commits
481bd1d1
Commit
481bd1d1
authored
6 years ago
by
jacques.grelet_ird.fr
Browse files
Options
Downloads
Patches
Plain Diff
add try catch and errordlg if file not found
parent
cab858a5
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
@netcdf_native/private/read.m
+32
-33
32 additions, 33 deletions
@netcdf_native/private/read.m
with
32 additions
and
33 deletions
@netcdf_native/private/read.m
+
32
−
33
View file @
481bd1d1
...
...
@@ -18,12 +18,11 @@ end
% check file validity
% -------------------
self
.
nc_id
=
netcdf
.
open
(
self
.
file
,
self
.
mode
);
if
self
.
nc_id
==
-
1
error
([
'netcdf:netcdf'
,
...
'The specified data file
''
%s
''
does not exist\n'
...
'or is not in the directory which is on the MATLAB path'
],
...
self
.
file
);
try
self
.
nc_id
=
netcdf
.
open
(
self
.
file
,
self
.
mode
);
catch
me
errordlg
(
me
.
message
,
'Read NetCDF file error'
);
error
(
me
.
identifier
,
me
.
message
);
end
% update waitbar title with Tex mode disable
...
...
@@ -136,10 +135,10 @@ for id = 0:nvars-1
% -------------------------------------
try
s
.
data__
=
netcdf
.
getVar
(
self
.
nc_id
,
id
);
% under Matlab R2011b, getVar thrown an error when all _EXT dimensions
% are 0. In that case, set data to empty
% ------------------------------------------------------------------
% under Matlab R2011b, getVar thrown an error when all _EXT dimensions
% are 0. In that case, set data to empty
% ------------------------------------------------------------------
catch
ME
fprintf
(
'Notice: netcdf_native:read: %s set to empty\n'
,
varName
);
% fprintf('Notice: netcdf_native:read: %s: %s\n', varName, ME.message);
...
...
@@ -186,34 +185,34 @@ for id = 0:nvars-1
end
end
% % if var is char and as vertical alignment, transpose it
% % ------------------------------------------------------
% % if xtype == self.NC_CHAR && (size(s.data__, 1) ~= 1)
% % s.data__ = s.data__';
% % end
%
% % add internal dimension__ member
% % Because MATLAB uses FORTRAN-style ordering, however, the order of
% % the dimension IDs is reversed relative to what would be obtained
% % from the C API
% % ----------------------------
% if length(dimids) > 1
% s.data__ = permute(s.data__, fliplr(1:length(dimids)));
% dimids = fliplr(dimids);
% end
% % if var is char and as vertical alignment, transpose it
% % ------------------------------------------------------
% % if xtype == self.NC_CHAR && (size(s.data__, 1) ~= 1)
% % s.data__ = s.data__';
% % end
%
% % add internal dimension__ member
% % Because MATLAB uses FORTRAN-style ordering, however, the order of
% % the dimension IDs is reversed relative to what would be obtained
% % from the C API
% % ----------------------------
% if length(dimids) > 1
% s.data__ = permute(s.data__, fliplr(1:length(dimids)));
% dimids = fliplr(dimids);
% end
% if var is char and as vertical alignment, transpose it
% ------------------------------------------------------
if
xtype
==
self
.
NC_CHAR
&&
(
size
(
s
.
data__
'
,
1
)
==
1
)
s
.
data__
=
s
.
data__
'
;
% Because MATLAB uses FORTRAN-style indexing, we need to transpose
% N-D array (k,i,j,...) to (i,j,k,...) however, the order of
% the dimension IDs is reversed relative to what would be obtained
% from the C API
% If s.data__ is a vector, NetCDF API return vertical vector,
% do nothing, it's OK
% -----------------------------------------------------------------
% Because MATLAB uses FORTRAN-style indexing, we need to transpose
% N-D array (k,i,j,...) to (i,j,k,...) however, the order of
% the dimension IDs is reversed relative to what would be obtained
% from the C API
% If s.data__ is a vector, NetCDF API return vertical vector,
% do nothing, it's OK
% -----------------------------------------------------------------
elseif
length
(
dimids
)
>
1
s
.
data__
=
permute
(
s
.
data__
,
fliplr
(
1
:
length
(
dimids
)));
dimids
=
fliplr
(
dimids
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment