/[MITgcm]/MITgcm/utils/matlab/ioLb2num.m
ViewVC logotype

Contents of /MITgcm/utils/matlab/ioLb2num.m

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


Revision 1.1 - (show annotations) (download)
Mon Nov 5 17:04:16 2007 UTC (16 years, 7 months ago) by jmc
Branch: MAIN
CVS Tags: checkpoint64y, checkpoint64x, checkpoint64z, checkpoint64q, checkpoint64p, checkpoint64s, checkpoint64r, checkpoint64u, checkpoint64t, checkpoint64w, checkpoint64v, checkpoint64i, checkpoint64h, checkpoint64k, checkpoint64j, checkpoint64m, checkpoint64l, checkpoint64o, checkpoint64n, checkpoint64a, checkpoint64c, checkpoint64b, checkpoint64e, checkpoint64d, checkpoint64g, checkpoint64f, checkpoint63p, checkpoint63q, checkpoint63r, checkpoint63s, checkpoint63l, checkpoint63m, checkpoint63n, checkpoint63o, checkpoint63h, checkpoint63i, checkpoint63j, checkpoint63k, checkpoint63d, checkpoint63e, checkpoint63f, checkpoint63g, checkpoint63a, checkpoint63b, checkpoint63c, checkpoint64, checkpoint65, checkpoint60, checkpoint61, checkpoint62, checkpoint63, checkpoint66g, checkpoint66f, checkpoint66e, checkpoint66d, checkpoint66c, checkpoint66b, checkpoint66a, checkpoint66o, checkpoint66n, checkpoint66m, checkpoint66l, checkpoint66k, checkpoint66j, checkpoint66i, checkpoint66h, checkpoint65z, checkpoint65x, checkpoint65y, checkpoint65r, checkpoint65s, checkpoint65p, checkpoint65q, checkpoint65v, checkpoint65w, checkpoint65t, checkpoint65u, checkpoint65j, checkpoint65k, checkpoint65h, checkpoint65i, checkpoint65n, checkpoint65o, checkpoint65l, checkpoint65m, checkpoint65b, checkpoint65c, checkpoint65a, checkpoint65f, checkpoint65g, checkpoint65d, checkpoint65e, checkpoint59q, checkpoint59p, checkpoint59r, checkpoint59m, checkpoint59l, checkpoint59o, checkpoint59n, checkpoint59k, checkpoint59j, checkpoint62c, checkpoint62b, checkpoint62a, checkpoint62g, checkpoint62f, checkpoint62e, checkpoint62d, checkpoint62k, checkpoint62j, checkpoint62i, checkpoint62h, checkpoint62o, checkpoint62n, checkpoint62m, checkpoint62l, checkpoint62s, checkpoint62r, checkpoint62q, checkpoint62p, checkpoint62w, checkpoint62v, checkpoint62u, checkpoint62t, checkpoint62z, checkpoint62y, checkpoint62x, checkpoint61f, checkpoint61g, checkpoint61d, checkpoint61e, checkpoint61b, checkpoint61c, checkpoint61a, checkpoint61n, checkpoint61o, checkpoint61l, checkpoint61m, checkpoint61j, checkpoint61k, checkpoint61h, checkpoint61i, checkpoint61v, checkpoint61w, checkpoint61t, checkpoint61u, checkpoint61r, checkpoint61s, checkpoint61p, checkpoint61q, checkpoint61z, checkpoint61x, checkpoint61y, HEAD
add short matlab scripts to convert (both ways)
 ptracer number to ptracer io-label (2 character long).

1 function [iTr] = ioLb2num( ioLb );
2 % [iTr] = ioLb2num( ioLb );
3 % convert MITgcm ptracer-io label (2 characters) to ptracer number
4 % do conversion on individual 2c label
5 % or on character array ( N x 2c ) and then return number array (N x 1)
6
7 % $Header: $
8 % $Name: $
9
10 if size(ioLb,2) == 1 & size(ioLb,2) == 2,
11 N=1; ioLb=ioLb';
12 else
13 N=size(ioLb,1);
14 end
15
16 %- step 1 : convert to 2 ASCII code: j1,j2
17 jj=double(ioLb); j1=jj(:,1); j2=jj(:,2);
18 %fprintf(['%4i ',c1,c2,' %3i %3i\n'],i,j1,j2);
19
20 % native2unicode() ; unicode2native() :
21 % 0-9 :: 48-57
22 % A-Z :: 65-90
23 % a-z :: 97-122
24 n0=double('0'); ne=10+n0;
25 n1=double('A');
26 n2=double('a');
27 nd=double('-');
28
29 %- step 2 : convert to 2 digits k1,k2 (both in [0,61])
30 iTr=-ones(N,1);
31 k1=j1-n1+36;
32 [J]=find( j1 < ne ); k1(J)=j1(J)-n0;
33 [J]=find( j1 >= n2 ); k1(J)=j1(J)-n2+10;
34 [J]=find( j1 < n0 ); k1(J)=0;
35 k2=j2-n1+36;
36 [I]=find( j2 < ne ); k2(I)=j2(I)-n0;
37 [I]=find( j2 >= n2 ); k2(I)=j2(I)-n2+10;
38 [I]=find( j2 < n0 ); k2(I)=0;
39
40 %- step 3 : build number in modified 62 base from 2 digits k1,k2
41 % 620 = 100 + (10*2*26) ; 52 = 26+26 ; 62=10+26+26
42 iTr= 0 + 62*k1 + k2;
43 [I]=find( j1 < ne & j2 < ne ); iTr(I)= 0 + 10*k1(I) + k2(I);
44 [I]=find( j1 < ne & j2 > ne ); iTr(I)=90 + 52*k1(I) + k2(I);
45 [I]=find( j1 < n0 | j2 < n0 ); iTr(I)=0;
46
47 return

  ViewVC Help
Powered by ViewVC 1.1.22