/[MITgcm]/MITgcm_contrib/gael/profilesMatlabProcessing/profiles_misc/ncgetFillVal.m
ViewVC logotype

Contents of /MITgcm_contrib/gael/profilesMatlabProcessing/profiles_misc/ncgetFillVal.m

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.3 - (show annotations) (download)
Wed Apr 13 22:56:19 2011 UTC (14 years, 3 months ago) by roquet
Branch: MAIN
Changes since 1.2: +2 -2 lines
fix bugs relative to old netcdf toolbox

1 function [FillVal]=ncgetFillVal(ncid,varname);
2 % [FillVal]=ncgetFillVal(ncid,varname)
3 % return the missing_value or _FillValue of varname
4
5 global useNativeMatlabNetcdf;
6 if isempty(useNativeMatlabNetcdf); useNativeMatlabNetcdf = ~isempty(which('netcdf.open')); end;
7
8 FillVal=[];
9 if useNativeMatlabNetcdf;
10 varid = netcdf.inqVarID(ncid,varname);
11 [varname,xtype,dimids,natts] = netcdf.inqVar(ncid,varid);
12 [atts]=ncatts(ncid,varid);
13 if any(ismember(atts,'missing_value'))
14 FillVal = netcdf.getAtt(ncid,varid,'missing_value');
15 elseif any(ismember(atts,'_FillValue'))
16 FillVal = netcdf.getAtt(ncid,varid,'_FillValue');
17 end
18 if strcmp(xtype,'single') | strcmp(xtype,'double')
19 FillVal=double(FillVal);
20 end
21 else
22 eval(['FillVal = ncid{''' varname '''}.missing_value(:);']);
23 if isempty(FillVal);
24 eval(['FillVal = ncid{''' varname '''}.FillValue_(:);']);
25 end
26 end
27

  ViewVC Help
Powered by ViewVC 1.1.22