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

Annotation of /MITgcm_contrib/gael/profilesMatlabProcessing/profiles_IO_v2/MITprof_write.m

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


Revision 1.5 - (hide annotations) (download)
Wed Apr 13 21:01:34 2011 UTC (14 years, 3 months ago) by roquet
Branch: MAIN
Changes since 1.4: +5 -13 lines
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 gforget 1.1 %function: MITprof_write
2 gforget 1.3 %object: write netcdf data files in the "MIT format"
3 gforget 1.1 %author: Gael Forget (gforget@mit.edu)
4 gforget 1.3 %date: Nov 5th, 2010
5 gforget 1.1 %
6 gforget 1.2 %usage: []=MITprof_write(fileOut,MITprof);
7     % ---> writes MITprof to the fileOut file
8 gforget 1.1 % that has previously been created using MITprof_create
9     %
10 gforget 1.2 %inputs: fileOut data file name
11 roquet 1.5 % MITprof struct containing profiles
12 gforget 1.1
13 gforget 1.2 function []=MITprof_write(fileOut,MITprof);
14    
15 gforget 1.3
16 roquet 1.4 % re-check that file exists and add prefix and suffix if necessary
17 roquet 1.5 [pathstr, name, ext] = fileparts(fileOut);
18     if isempty(pathstr) | strcmp(pathstr,'.'), pathstr=pwd; end
19     if isempty(ext) | ~strcmp(ext,'.nc'), ext='.nc'; end
20     fileOut=[pathstr '/' name ext];
21 gforget 1.3
22 gforget 1.2 %open file:
23 roquet 1.4 nc=ncopen(fileOut,'write');
24 gforget 1.1
25 gforget 1.3 %write to file:
26 gforget 1.1 list_vars=fieldnames(MITprof);
27     for ii=1:length(list_vars);
28 gforget 1.3 eval(['tmp1=MITprof.' list_vars{ii} ';']);
29     ncputvar(nc,list_vars{ii},tmp1);
30 gforget 1.1 end;
31    
32 roquet 1.4
33 gforget 1.3 %close file:
34 roquet 1.4 ncclose(nc);
35 gforget 1.3
36 gforget 1.1

  ViewVC Help
Powered by ViewVC 1.1.22