1 |
gforget |
1.1 |
%function: MITprof_write |
2 |
|
|
%object: read netcdf data files in the "MIT format" |
3 |
|
|
%author: Gael Forget (gforget@mit.edu) |
4 |
|
|
%date: june 21th, 2006 |
5 |
|
|
% |
6 |
|
|
%usage: []=MITprof_write(dirIn,fileIn,MITprof); |
7 |
|
|
% ---> writes MITprof to the [dirIn fileIn] file |
8 |
|
|
% that has previously been created using MITprof_create |
9 |
|
|
% |
10 |
|
|
%inputs: dirIn data file directory |
11 |
|
|
% fileIn data file name |
12 |
|
|
% (list_vars optional variable list) |
13 |
|
|
% |
14 |
|
|
%outputs: MITprof structure containing the various fields/vectors |
15 |
|
|
|
16 |
|
|
function []=MITprof_write(dirIn,fileIn,MITprof); |
17 |
|
|
|
18 |
|
|
tmp1=dir([dirIn fileIn]); |
19 |
|
|
if isempty(tmp1); tmp1=dir([dirIn fileIn '.nc']); end; |
20 |
|
|
if isempty(tmp1); error([fileIn ' file not found']); end; |
21 |
|
|
nc=netcdf([dirIn tmp1.name],'write'); |
22 |
|
|
|
23 |
|
|
list_vars=fieldnames(MITprof); |
24 |
|
|
for ii=1:length(list_vars); |
25 |
|
|
eval(['tmp1=MITprof.' list_vars{ii} ';']); |
26 |
|
|
nc{list_vars{ii}}(:)=tmp1; |
27 |
|
|
end; |
28 |
|
|
|
29 |
|
|
close(nc); |
30 |
|
|
|