1 
% this is an exemple for how to use "fromPhys2Dyn.m" 
2 
% after running mitgcmuv in directory "build" 
3 
% note: all pressure variables need to be in the same units; 
4 

5 
dir0='../build/'; 
6 
Dp=rdmds([dir0,'Depth']); Dp=Dp/100 ; %< convert to [mb] 
7 
hFacC=rdmds([dir0,'hFacC']); 
8 
dp=rdmds([dir0,'fizhidt']); 
9 

10 
delR=100*ones(1,10); %< converted to [mb] 
11 
nP=size(dp,3); nr=length(delR); 
12 
% old version only: 
13 
% convert to mb & reverse level index in dp to match Physics levels order: 
14 
% var=dp/100; dp(:,:,[1:nP])=var(:,:,[nP:1:1]); 
15 

16 
% load the field to interpolate to the Dynamics grid: 
17 
it=5; vPh=rdmds([dir0,'fizhi_T'],it); 
18 

19 
%Do the mapping: Physics.grid > Dynamics.grid 
20 
% 1rst time: 
21 
[vDy,klev,dpDyn]=fromPhys2Dyn(vPh,dp,Dp,delR); 
22 
% next time: 
23 
%[vDy,klev,dpDyn]=fromPhys2Dyn(vPh,dp,klev); 
24 

25 
% check versus hFacC: 
26 
for k=1:nr, 
27 
dpDyn(:,:,k)=dpDyn(:,:,k)/delR(k); 
28 
end 
29 
dd=dpDynhFacC; 
30 
fprintf(' Check / hFac : max(Diff)= %e \n',max(max(max(abs(dd)))) ); 
31 
