[Dart-dev] [3741] DART/trunk/diagnostics/matlab/get_varnames.m:
graceful,
informative exit if file does not have any non-coordinate dimension
variables
nancy at ucar.edu
nancy at ucar.edu
Fri Jan 16 10:53:06 MST 2009
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/dart-dev/attachments/20090116/dc10f70b/attachment.html
-------------- next part --------------
Modified: DART/trunk/diagnostics/matlab/get_varnames.m
===================================================================
--- DART/trunk/diagnostics/matlab/get_varnames.m 2009-01-12 23:09:52 UTC (rev 3740)
+++ DART/trunk/diagnostics/matlab/get_varnames.m 2009-01-16 17:53:05 UTC (rev 3741)
@@ -27,7 +27,7 @@
variables = var(fid);
coordvars = coord(fid);
-atmosvarinds = VariableIndices(coordvars,variables);
+atmosvarinds = VariableIndices(coordvars,variables,fid);
% coerce just the names into a cell array
@@ -37,7 +37,7 @@
-function inds = VariableIndices(coordvars,variables)
+function inds = VariableIndices(coordvars,variables,f)
% returns the indices of the atmospheric variables.
inds = [];
@@ -49,13 +49,16 @@
for j = 1:length(coordvars)
if (strcmp( varname , name(coordvars{j}))), isatmosvar = 0; end
- if (strcmp( varname , 'time_bounds')), isatmosvar = 0; end
- if (strcmp( varname , 'region_names')), isatmosvar = 0; end
- if (strcmp( varname , 'CopyMetaData')), isatmosvar = 0; end
- if (strcmp( varname , 'ObservationTypes')), isatmosvar = 0; end
end
-
+
+ if (strcmp( varname , 'time_bounds')), isatmosvar = 0; end
+ if (strcmp( varname , 'region_names')), isatmosvar = 0; end
+ if (strcmp( varname , 'CopyMetaData')), isatmosvar = 0; end
+ if (strcmp( varname , 'ObservationTypes')), isatmosvar = 0; end
+
if (isatmosvar > 0)
inds = [inds i];
+ else
+ error('No atmospheric variables in %s.',name(f))
end
end
More information about the Dart-dev
mailing list