1 |
gforget |
1.2 |
function [FLD]=convert2array_llpc(fld); |
2 |
|
|
%object: gcmfaces to array format conversion (if gcmfaces input) |
3 |
|
|
% or: array to gcmfaces format conversion (if array input) |
4 |
|
|
% |
5 |
|
|
%notes: if array input, the gcmfaces format will be the one of mygrid.XC, so |
6 |
|
|
% the array input must have originally been created according to convert2array |
7 |
|
|
|
8 |
|
|
global mygrid; |
9 |
gforget |
1.1 |
|
10 |
|
|
if isa(fld,'gcmfaces'); do_gcmfaces2array=1; else; do_gcmfaces2array=0; end; |
11 |
|
|
|
12 |
|
|
if do_gcmfaces2array; |
13 |
|
|
n3=max(size(fld.f1,3),1); n4=max(size(fld.f1,4),1); |
14 |
|
|
n1=size(fld.f1,1)*4; n2=size(fld.f1,2); |
15 |
|
|
FLD=squeeze(zeros(n1,n2,n3,n4)); |
16 |
|
|
else; |
17 |
|
|
n3=max(size(fld,3),1); n4=max(size(fld,4),1); |
18 |
gforget |
1.2 |
FLD=NaN*mygrid.XC; |
19 |
gforget |
1.1 |
for k3=1:n3; for k4=1:n4; for iFace=1:FLD.nFaces; |
20 |
|
|
iF=num2str(iFace); eval(['FLD.f' iF '(:,:,k3,k4)=FLD.f' iF '(:,:,1,1);']); |
21 |
|
|
end; end; end; |
22 |
|
|
end; |
23 |
|
|
|
24 |
|
|
for k3=1:n3; for k4=1:n4; |
25 |
|
|
|
26 |
|
|
if do_gcmfaces2array; |
27 |
|
|
%ASSEMBLE SIDE FACES: |
28 |
|
|
%---------------------- |
29 |
|
|
FLD1=[fld.f1(:,:,k3,k4);fld.f2(:,:,k3,k4);sym_g(fld.f3(:,:,k3,k4),7,0);sym_g(fld.f4(:,:,k3,k4),7,0)]; |
30 |
|
|
%store: |
31 |
|
|
%------ |
32 |
|
|
FLD(:,:,k3,k4)=FLD1; |
33 |
|
|
else; |
34 |
|
|
n1=size(FLD.f1,1); n2=size(FLD.f1,2); |
35 |
|
|
FLD.f1(:,:,k3,k4)=fld(1:n1,1:n2,k3,k4); |
36 |
|
|
FLD.f2(:,:,k3,k4)=fld(n1+[1:n1],1:n2,k3,k4); |
37 |
|
|
FLD.f3(:,:,k3,k4)=sym_g(fld(n1*2+[1:n1],1:n2,k3,k4),5,0); |
38 |
|
|
FLD.f4(:,:,k3,k4)=sym_g(fld(n1*3+[1:n1],1:n2,k3,k4),5,0); |
39 |
|
|
end; |
40 |
|
|
|
41 |
|
|
end; end; |
42 |
|
|
|