/[MITgcm]/MITgcm/verification/natl_box_forward/matlab/write_record.m
ViewVC logotype

Contents of /MITgcm/verification/natl_box_forward/matlab/write_record.m

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


Revision 1.1.2.1 - (show annotations) (download)
Tue Feb 5 20:34:50 2002 UTC (22 years, 3 months ago) by heimbach
Branch: ecco-branch
CVS Tags: ecco_c44_e19, ecco_c44_e18, ecco_c44_e16, ecco_c51_e34d, ecco_c51_e34e, ecco_c51_e34f, ecco_c51_e34g, ecco_c51_e34a, ecco_c51_e34b, ecco_c51_e34c, ecco-branch-mod1, ecco-branch-mod2, ecco-branch-mod3, ecco-branch-mod4, ecco-branch-mod5, ecco_c51_e34, ecco_c50_e29, ecco_c50_e28, ecco_c44_e17, ecco_c44_e22, ecco_c44_e23, ecco_c44_e20, ecco_c44_e21, ecco_c44_e26, ecco_c44_e27, ecco_c44_e24, ecco_c44_e25, icebear5, icebear4, icebear3, icebear2, ecco_c50_e33a, ecco_c50_e32, ecco_c50_e33, ecco_c50_e30, ecco_c50_e31, ecco_ice2, ecco_ice1
Branch point for: icebear, c24_e25_ice
Changes since 1.1: +23 -0 lines
o Updating adjoint/makefile to ECCO code
o Adding optim and lsopt for line search optimization.
o Adding verif. experiments for ECCO
Code will be tagged ecco-branch-mod1.

1 function write_record (file_id, field, record_type)
2 % function write_record (file_id, field, record_type)
3 % write a fortran record
4 % file needs to be previously opened in write binary mode, i.e.,
5 % file_id=fopen(fname,'w','b');
6 % field contains the variable to be written
7 % record_type defaults to real*4
8
9 if nargin<3, record_type='real*4'; end
10 switch lower(record_type)
11 case {'uint8','integer*1','int8', ...
12 'schar','signed char','uchar','unsigned char','char','char*1'}
13 record_length=length(field(:));
14 case {'uint16','integer*2','int16','integer*2'}
15 record_length=length(field(:))*2;
16 case {'float32','real*4','uint32','integer*4','int32','integer*4'}
17 record_length=length(field(:))*4;
18 case {'float64','real*8','uint64','integer*8','int64','integer*8'}
19 record_length=length(field(:))*8;
20 end
21 tmp=fwrite(file_id,record_length,'uint32'); % fortran record length
22 tmp=fwrite(file_id,field,record_type);
23 tmp=fwrite(file_id,record_length,'uint32'); % fortran record length

  ViewVC Help
Powered by ViewVC 1.1.22