/[MITgcm]/MITgcm/verification/lab_sea/matlab/readbin.m
ViewVC logotype

Contents of /MITgcm/verification/lab_sea/matlab/readbin.m

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


Revision 1.1.2.1 - (show annotations) (download)
Thu Dec 5 08:06:18 2002 UTC (21 years, 4 months ago) by dimitri
Branch: release1
CVS Tags: release1_p13_pre, release1_p13, release1_p9, release1_p12, release1_p10, release1_p11, release1_p16, release1_p17, release1_p14, release1_p15, release1_p12_pre
Branch point for: release1_50yr
Changes since 1.1: +65 -0 lines
release1_p9
o pkg/seaice
  - removed GOTO's and added taf directives
  - double precision constants to reduce the g77 (Linux)
    to F77 (SGI) differences reported in release1_p8
o tools/genmake
  - added SGI options
o verification/testscript
  - updated to that of checkpoint47a_post
o verification/global_ocean.90x40x15/input/eedata
  - modified for SGI f77 compatibility
o verification/lab_sea
  - added description of sea-ice model
  - added missing matlab routines
  - added test of thermodynamics parallelization
Modified Files:
 Tag: release1
   doc/tag-index pkg/seaice/SEAICE_FFIELDS.h
   pkg/seaice/SEAICE_PARAMS.h pkg/seaice/adi.F
   pkg/seaice/advect.F pkg/seaice/budget.F pkg/seaice/diffus.F
   pkg/seaice/dynsolver.F pkg/seaice/groatb.F pkg/seaice/growth.F
   pkg/seaice/lsr.F pkg/seaice/ostres.F
   pkg/seaice/seaice_do_diags.F pkg/seaice/seaice_get_forcing.F
   pkg/seaice/seaice_init.F pkg/seaice/seaice_model.F
   pkg/seaice/seaice_readparms.F tools/genmake
   verification/testscript
   verification/global_ocean.90x40x15/input/eedata
   verification/lab_sea/README
   verification/lab_sea/code/CPP_EEOPTIONS.h
   verification/lab_sea/code/CPP_EEOPTIONS_MPI.h
   verification/lab_sea/code/CPP_OPTIONS.h
   verification/lab_sea/code/SIZE.h
   verification/lab_sea/code/SIZE_2x1.h
   verification/lab_sea/input/data
   verification/lab_sea/matlab/lookat_exp1.m
   verification/lab_sea/matlab/lookat_exp2.m
   verification/lab_sea/matlab/lookat_exp3.m
   verification/lab_sea/matlab/lookat_exp4.m
   verification/lab_sea/matlab/lookat_exp5.m
   verification/lab_sea/matlab/lookat_exp6.m
   verification/lab_sea/results/AREAtave.0000000010.data
   verification/lab_sea/results/HEFFtave.0000000010.data
   verification/lab_sea/results/UICEtave.0000000010.data
   verification/lab_sea/results/VICEtave.0000000010.data
   verification/lab_sea/results/output.txt
Added Files:
 Tag: release1
   verification/lab_sea/seaice.ps
   verification/lab_sea/matlab/lookat_exp7.m
   verification/lab_sea/matlab/mmax.m
   verification/lab_sea/matlab/mypcolor.m
   verification/lab_sea/matlab/myquiver.m
   verification/lab_sea/matlab/readbin.m
   verification/lab_sea/matlab/wysiwyg.m
Removed Files:
 Tag: release1
   verification/lab_sea/code/KPP_OPTIONS.h

1 function fld=readbin(fnam,siz,typ,prec,skip)
2
3 % Function fld=readbin(fnam,siz,typ,prec,skip)
4 % read in N-D binary field
5 %
6 % INPUTS
7 % fnam input path and file name
8 % siz grid dimension (default [360 224 46])
9 % typ 0: sequential FORTRAN (default); 1: plain binary
10 % prec numeric precision (default 'real*4')
11 % skip records to skip before reading (default 0)
12 %
13 % OUTPUTS
14 % fld output array of dimension siz
15 %
16 % SEE ALSO
17 % writebin
18
19 if nargin < 5, skip=0; end
20 if nargin < 4, prec='real*4'; end
21 if nargin < 3, typ=0; end
22 if nargin < 2, siz=[360 224 46]; end
23 if nargin < 1, t=1; end
24 if nargin < 0, error('please specify input file name'); end
25
26 fid=fopen(fnam,'r','ieee-be');
27
28 if skip>0
29 if typ==0
30 error('feature not implemented yet');
31 else
32 switch prec
33 case {'int8','integer*1'}
34 reclength=prod(siz);
35 case {'int16','integer*2','uint16','integer*2'}
36 reclength=2*prod(siz);
37 case {'int32','integer*4','uint32','single','real*4','float32'}
38 reclength=4*prod(siz);
39 case {'int64','integer*8','uint64','double','real*8','float64'}
40 reclength=8*prod(siz);
41 end
42 end
43 fseek(fid,skip*reclength,'bof');
44 end
45
46 switch typ
47 case 0
48 tmp=read_record(fid,prec);
49 case 1
50 tmp=fread(fid,[siz(1),prod(siz(2:length(siz)))],prec);
51 end
52 fid=fclose(fid);
53
54 switch length(siz)
55 case 2
56 fld=reshape(tmp,siz(1),siz(2));
57 case 3
58 fld=reshape(tmp,siz(1),siz(2),siz(3));
59 case 4
60 fld=reshape(tmp,siz(1),siz(2),siz(3),siz(4));
61 case 5
62 fld=reshape(tmp,siz(1),siz(2),siz(3),siz(4),siz(5));
63 otherwise
64 fld=tmp;
65 end

  ViewVC Help
Powered by ViewVC 1.1.22