/[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.4 - (hide annotations) (download)
Mon Apr 11 20:56:08 2011 UTC (14 years, 3 months ago) by roquet
Branch: MAIN
Changes since 1.3: +14 -24 lines
use new interface for old/new netcdf toolbox

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     % list_vars variable list (optional)
12 gforget 1.1 %
13 gforget 1.2 %outputs: MITprof structure containing the various arrays
14 gforget 1.1
15 gforget 1.2 function []=MITprof_write(fileOut,MITprof);
16    
17 gforget 1.3
18 roquet 1.4 % re-check that file exists and add prefix and suffix if necessary
19     if isempty(strfind(fileOut,'/'));
20     fileOut=['./' fileOut];
21     end;
22     if ~exist(fileOut,'file')
23     if ~exist([fileOut '.nc'],'file')
24     error([fileOut ' : file not found']);
25     else
26     fileOut=[fileOut '.nc'];
27     end
28     end
29 gforget 1.3
30 gforget 1.2 %open file:
31 roquet 1.4 nc=ncopen(fileOut,'write');
32 gforget 1.1
33 gforget 1.3 %write to file:
34 gforget 1.1 list_vars=fieldnames(MITprof);
35     for ii=1:length(list_vars);
36 gforget 1.3 eval(['tmp1=MITprof.' list_vars{ii} ';']);
37     ncputvar(nc,list_vars{ii},tmp1);
38 gforget 1.1 end;
39    
40 roquet 1.4
41 gforget 1.3 %close file:
42 roquet 1.4 ncclose(nc);
43 gforget 1.3
44 gforget 1.1

  ViewVC Help
Powered by ViewVC 1.1.22