1 
function [iTr] = ioLb2num( ioLb ); 
2 
% [iTr] = ioLb2num( ioLb ); 
3 
% convert MITgcm ptracerio 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 
% 09 :: 4857 
22 
% AZ :: 6590 
23 
% az :: 97122 
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=j1n1+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=j2n1+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 