/[MITgcm]/MITgcm_contrib/gael/profilesMatlabProcessing/profiles_IO_v2/MITprof_addVar.m
ViewVC logotype

Contents of /MITgcm_contrib/gael/profilesMatlabProcessing/profiles_IO_v2/MITprof_addVar.m

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


Revision 1.1 - (show annotations) (download)
Wed Apr 13 21:01:33 2011 UTC (14 years, 3 months ago) by roquet
Branch: MAIN
CVS Tags: checkpoint65x, checkpoint65r, checkpoint65p, checkpoint65q, checkpoint65v, checkpoint65w, checkpoint65t, checkpoint65u, checkpoint66f, checkpoint66e, checkpoint66d, checkpoint66c, checkpoint66b, checkpoint66a, checkpoint66o, HEAD
Improvements of MITprof netcdf IO interface. Handling of file names modified.
New functions:
- MITprof_addVar : add a variable to an existing MITprof netcdf file
- MITprof_nc2odv : convert data into ODV4 format

1 %function: MITprof_addVar
2 %
3 %usage: []=MITprof_addVar(filenc,varname,xtype,dimlist,varvalue);
4 % ---> add a variable in a MITprof netcdf file
5 %
6 %inputs: filenc MITprof netcdf file name
7 % varname,xtype,dimlist,varvalue: variable information
8
9 function []=MITprof_addVar(filenc,varname,xtype,dimlist,varvalue);
10
11
12 % check that file exists and add prefix and suffix if necessary
13 [pathstr, name, ext] = fileparts(filenc);
14 if isempty(pathstr) | strcmp(pathstr,'.'), pathstr=pwd; end
15 if isempty(ext) | ~strcmp(ext,'.nc'), ext='.nc'; end
16 filenc=[pathstr '/' name ext];
17 if ~exist(filenc,'file'), error([filenc ' : file not found']); end
18
19 %open file:
20 nc=ncopen(filenc,'write');
21
22 %add variable:
23 vars=ncvars(nc);
24 if isempty(find(ismember(vars,varname)))
25 ncaddVar(nc,varname,xtype,dimlist);
26 end
27
28 %write data
29 ncputvar(nc,varname,varvalue);
30
31 %close file:
32 ncclose(nc);
33
34

  ViewVC Help
Powered by ViewVC 1.1.22