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

Contents of /MITgcm/utils/matlab/num2ioLb.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, 8 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 [ioLb] = num2ioLb( iTr );
2 % [ioLb ] = num2ioLb( iTr);
3 % convert ptracer number to MITgcm ptracer-io label (2 characters)
4 % do conversion on individual number (return a 2c label)
5 % or on number array (N x 1) and then return a character array ( N x 2c )
6
7 % $Header: $
8 % $Name: $
9
10 N=prod(size(iTr)); iTr=reshape(iTr,[N 1]);
11
12 %- step 1 : express number in modified 62/52/10 base, digits: k1,k2
13
14 %- base 52 in [100,620-1]
15 k2=fix(iTr-100);
16 k1=fix(k2/52);
17 k2=rem(k2,52)+10;
18 %- base 10 in [1,100-1]
19 [I]=find( iTr < 100 );
20 s0=fix(iTr-0);
21 tt=fix(s0/10);
22 k1(I)=tt(I);
23 tt=rem(s0,10);
24 k2(I)=tt(I);
25 %- base 62 in [620,62^2-1]
26 [I]=find( iTr >= 620 );
27 tt=fix(s0/62);
28 k1(I)=tt(I);
29 tt=rem(s0,62);
30 k2(I)=tt(I);
31
32 %- step 2 : convert digits k1,k2 to ASCII code: j1,j2
33 % 0-9 :: 48-57
34 % A-Z :: 65-90
35 % a-z :: 97-122
36 n0=double('0');
37 n1=double('A');
38 n2=double('a');
39 nd=double('-');
40 % -36+65 = +29 ; -10+97 = +87
41 j1=k1-10+n2;
42 [I]=find(k1 >= 36 ); j1(I)=k1(I)-36+n1;
43 [I]=find(k1 < 10 ) ; j1(I)=k1(I)+n0;
44 j2=k2-10+n2;
45 [I]=find(k2 >= 36 ); j2(I)=k2(I)-36+n1;
46 [I]=find(k2 < 10 ) ; j2(I)=k2(I)+n0;
47
48 [I]=find( iTr >= 62*62 ); j1(I)=nd; j2(I)=nd;
49
50 %- step 3 : do the conversion to ASCII code
51
52 % uses: char(); double();
53 ioLb=char([j1 j2]);
54
55 % native2unicode() ; unicode2native() : <- much slower
56 %c1=native2unicode(j1);
57 %c2=native2unicode(j2);
58 %ioLb=strcat(c1,c2);
59
60 return

  ViewVC Help
Powered by ViewVC 1.1.22