1 |
% invert S matrix and write it in MITGCMUV mdsio format |
2 |
%------------------------------------------------------ |
3 |
% input : sumij,npx,npy,ninterf |
4 |
% output : files |
5 |
|
6 |
% MITGCMUV has a funny distribution for 2x2=4 processors it is: |
7 |
% |
8 |
% 1 3 |
9 |
% 0 2 |
10 |
% |
11 |
% Thus, we have to permute the npx and npy dimension |
12 |
% write negative because we have used (-A) internally |
13 |
|
14 |
%old ok |
15 |
%sumij = full(sumij); |
16 |
%sumij = -permute(reshape(inv(sumij),ninterf,npx,npy,ninterf,npx,npy),[1,3,2,4,5,6]); |
17 |
|
18 |
sumij = full(sumij\eye(size(sumij))); |
19 |
sumij = -permute(reshape(sumij,ninterf,npx,npy,ninterf,npx,npy),[1,3,2,4,5,6]); |
20 |
|
21 |
ndims = 1; |
22 |
dimList = [32768, 1,16384]; |
23 |
format = 'float64'; |
24 |
sformat = '''float64'''; |
25 |
nrecords = 1; |
26 |
timeStepNumber = 0; |
27 |
|
28 |
for i = 1:npx, |
29 |
for j = 1:npy, |
30 |
fname = sprintf('ss_matrix.%03i.%03i.data', i, j ); |
31 |
fid = fopen(fname,'w'); |
32 |
fwrite( fid, sumij(:,:,:,:,i,j), format ); |
33 |
fclose(fid); |
34 |
fname = sprintf('ss_matrix.%03i.%03i.meta', i, j ); |
35 |
fid = fopen(fname,'w'); |
36 |
fprintf(fid, ' nDims = [ %3i ];\n', ndims); |
37 |
fprintf(fid, ' dimList = [\n'); |
38 |
fprintf(fid, ' dimList = [\n'); |
39 |
fprintf(fid, ' '); |
40 |
fprintf(fid, '%5i,', dimList); |
41 |
fprintf(fid, '\n ]\n'); |
42 |
fprintf(fid, 'format = [ %s ];\n', sformat); |
43 |
fprintf(fid, ' nrecords = [ %5i ];\n', nrecords); |
44 |
fprintf(fid, ' timeStepNumber = [ %8i ];\n', timeStepNumber); |
45 |
fclose(fid); |
46 |
end |
47 |
end |
48 |
%clear sumij; |