/[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.2 - (hide annotations) (download)
Thu Nov 4 18:43:42 2010 UTC (14 years, 8 months ago) by gforget
Branch: MAIN
Changes since 1.1: +16 -11 lines
- remove the step 2 file update from profiles_prep_write_nc.
  It is now done directly in profiles_prep_main.m e.g.
- MITprof_create, MITprof_read, MITprof_write: get
  full filename (not dir,file) as argument.
- MITprof_create: hard-code fillval and length of prof_descr.

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 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     %get directory name:
18     tmp1=strfind(fileOut,'/');
19     if ~isempty(tmp1); dirOut=fileOut(1:tmp1(end)); else; dirOut='./'; end;
20     %check that file exists:
21     tmp1=dir(fileOut);
22     if isempty(tmp1); tmp1=dir([fileOut '.nc']); end;
23     if isempty(tmp1); error([fileOut ' file not found']); end;
24     %open file:
25     nc=netcdf([dirOut tmp1.name],'write');
26 gforget 1.1
27    
28     list_vars=fieldnames(MITprof);
29     for ii=1:length(list_vars);
30     eval(['tmp1=MITprof.' list_vars{ii} ';']);
31     nc{list_vars{ii}}(:)=tmp1;
32     end;
33    
34     close(nc);
35    

  ViewVC Help
Powered by ViewVC 1.1.22