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

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

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


Revision 1.4 - (hide annotations) (download)
Wed Apr 20 20:26:58 2011 UTC (14 years, 3 months ago) by roquet
Branch: MAIN
CVS Tags: checkpoint65r, checkpoint65p, checkpoint65q
Changes since 1.3: +1 -0 lines
add comment

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

  ViewVC Help
Powered by ViewVC 1.1.22