/[MITgcm]/MITgcm_contrib/gael/matlab_class/gcmfaces_IO/ncgetFillVal.m
ViewVC logotype

Contents of /MITgcm_contrib/gael/matlab_class/gcmfaces_IO/ncgetFillVal.m

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


Revision 1.1 - (show annotations) (download)
Sun Jan 24 17:05:13 2016 UTC (9 years, 5 months ago) by gforget
Branch: MAIN
CVS Tags: checkpoint65x, checkpoint65v, checkpoint65w, checkpoint65t, checkpoint65u, checkpoint66f, checkpoint66e, checkpoint66d, checkpoint66c, checkpoint66b, checkpoint66a, checkpoint66o, HEAD
- move routines from MITprof/profiles_misc/ to gcmfaces/gcmfaces_IO/
  to allow for nctiles IO without having to rely on MITprof
- these wrapper routines were originally provided by F. Roquet
  that work both with the native implememtation of ncetcf in recent
  Matlab versions and the third party mex codes used earlier

1 function [FillVal]=ncgetFillVal(ncid,varname);
2 % [FillVal]=ncgetFillVal(ncid,varname)
3 % return the missing_value or _FillValue of varname
4 % return an error if varname does not exist
5
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 [varname,xtype,dimids,natts] = netcdf.inqVar(ncid,varid);
13 [atts]=ncatts(ncid,varid);
14 if any(ismember(atts,'missing_value'))
15 FillVal = netcdf.getAtt(ncid,varid,'missing_value');
16 elseif any(ismember(atts,'_FillValue'))
17 FillVal = netcdf.getAtt(ncid,varid,'_FillValue');
18 end
19 if strcmp(xtype,'single') | strcmp(xtype,'double')
20 FillVal=double(FillVal);
21 end
22 else
23 eval(['FillVal = ncid{''' varname '''}.missing_value(:);']);
24 if isempty(FillVal);
25 eval(['FillVal = ncid{''' varname '''}.FillValue_(:);']);
26 end
27 end
28

  ViewVC Help
Powered by ViewVC 1.1.22