/[MITgcm]/MITgcm_contrib/high_res_cube/matlab-grid-generator/write_tiles.m
ViewVC logotype

Contents of /MITgcm_contrib/high_res_cube/matlab-grid-generator/write_tiles.m

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


Revision 1.1.1.1 - (show annotations) (download) (vendor branch)
Tue Nov 11 18:08:08 2003 UTC (21 years, 8 months ago) by cnh
Branch: MAIN, initial
CVS Tags: baseline, HEAD
Changes since 1.1: +0 -0 lines
Checking in work done with Dimitri on high-resolution cube gridding and parallel 
communications. 
   o code is in a contrib experiment for now so we can continue collaborating
     on it. However most code is general and will be moved into main branch once 
     it is fully hardened.
   o There are README files in the contrib root and in the subdirectories that
     explain the contents

1 function [] = write_tiles(fn,A,varargin)
2 % Write tiled field to 6 files "fn.00?.001.data".
3 %
4 % Data is in IEEE-bigendian real*8 format by default.
5 %
6 % Dimensions of A must be (n,n,6)
7 %
8 % Usage:
9 % >> write_tiles('LATC',latC);
10 % >> write_tiles('LATC',latC,'real*4');
11
12 % Default precision
13 prec='real*8';
14 ieee='b';
15
16 % Check optional arguments
17 args=char(varargin);
18 while (size(args,1) > 0)
19 if deblank(args(1,:)) == 'real*4' | deblank(args(1,:)) == 'float32'
20 prec='real*4';
21 elseif deblank(args(1,:)) == 'real*8' | deblank(args(1,:)) == 'float64'
22 prec='real*8';
23 else
24 sprintf(['Optional argument ' args(1,:) ' is unknown'])
25 return
26 end
27 args=args(2:end,:);
28 end
29
30 for n=1:6,
31
32 fid=fopen(sprintf('%s.%3.3i.bin',fn,n),'w',ieee);
33 if fid<0
34 error('Unable to create file')
35 end
36 fwrite(fid,A(:,:,n),prec);
37 fclose(fid);
38
39 end

  ViewVC Help
Powered by ViewVC 1.1.22