/[MITgcm]/MITgcm_contrib/gael/matlab_class/gcmfaces_diags/diags_diff_snapshots.m
ViewVC logotype

Annotation of /MITgcm_contrib/gael/matlab_class/gcmfaces_diags/diags_diff_snapshots.m

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.4 - (hide annotations) (download)
Mon Oct 5 16:51:44 2015 UTC (9 years, 9 months ago) by gforget
Branch: MAIN
CVS Tags: checkpoint65x, checkpoint65r, checkpoint65p, checkpoint65q, checkpoint65v, checkpoint65w, checkpoint65t, checkpoint65u, checkpoint66f, checkpoint66e, checkpoint66d, checkpoint66c, checkpoint66b, checkpoint66a, checkpoint66o, HEAD
Changes since 1.3: +7 -7 lines
- improved treatment of directory names, switches, and driver.

1 gforget 1.4 function []=diags_diff_snapshots(dirSnap,dirMat,fileStart);
2 gforget 1.1 %object: compute time derivatives between snapshots that
3     % will be compared with time mean flux terms in budgets
4 gforget 1.4 %input: dirSnap is the directory containing the binary snapshots
5 gforget 1.1 % fileStart is the root of file names (e.g. budg2d_snap_set1)
6     %result: create e.g. rate_budg2d_snap_set1 files
7    
8 gforget 1.3 gcmfaces_global; global myparms;
9    
10 gforget 1.4 fileList=dir([dirSnap fileStart '.*.data']);
11 gforget 1.1 for ii=1:length(fileList)-1;
12    
13     %1) get the time of fld0 & fld1, & the data precision
14 gforget 1.4 fileName0=fullfile(dirSnap,fileList(ii).name(1:end-5));
15 gforget 1.3 meta0=rdmds_meta(fileName0);
16 gforget 1.4 fileName1=fullfile(dirSnap,filesep,fileList(ii+1).name(1:end-5));
17 gforget 1.3 meta1=rdmds_meta(fileName1);
18     %
19     time1=meta1.timeInterval;
20     time0=meta0.timeInterval;
21     dataprec=str2num(meta1.dataprec(end-1:end));
22 gforget 1.1
23     %2) get the binary data:
24 gforget 1.3 fld0=rdmds(fileName0);
25     fld1=rdmds(fileName1);
26    
27     test3d=(length(size(fld0))==4);
28     if test3d&(myparms.useNLFS==2);
29     %3D diagnostics are multiplied by DRF*hFac*ETAN
30     %(2D diagnostics are expectedly vertically integrated by MITgcm)
31     for jj=0:1;
32     %get etan
33     etanName=['budg2d_snap_set1' fileList(ii+jj).name(end-15:end-5)];
34 gforget 1.4 etanName=fullfile(dirSnap,filesep,etanName);
35 gforget 1.3 etan=rdmds2gcmfaces(etanName,'rec',1);
36     %compute time variable thickness
37     tmp1=mk3D(mygrid.DRF,mygrid.hFacC).*mygrid.hFacC;
38     tmp2=tmp1./mk3D(mygrid.Depth,tmp1);
39     tmp2=tmp2.*mk3D(etan,tmp1);
40     drf=convert2gcmfaces(tmp1+tmp2);
41     %apply to scale fld
42     eval(['fld=fld' num2str(jj) ';']);
43     n4=size(fld,4);
44     drf=repmat(drf,[1 1 1 n4]);
45     fld=fld.*drf;
46     eval(['fld' num2str(jj) '=fld;']);
47     end;
48     elseif test3d;
49     %the non rstar case remains to be treated
50     error('missing implementation of diags_diff_snapshots\n');
51     end;
52 gforget 1.1
53     %3) compute the tendency term:
54     fld2=(fld1-fld0)/(time1-time0);
55    
56     %4) write to file:
57 gforget 1.4 fileMetaOld=[dirSnap fileList(ii+1).name(1:end-5) '.meta'];
58 gforget 1.1 fileMetaNew=[dirMat 'BUDG/rate_' fileList(ii+1).name(1:end-5) '.meta'];
59 gforget 1.2 copyfile(fileMetaOld , fileMetaNew);
60 gforget 1.1 fileDataNew=[dirMat 'BUDG/rate_' fileList(ii+1).name(1:end-5) '.data'];
61     write2file(fileDataNew,fld2,dataprec);
62    
63     end;
64    

  ViewVC Help
Powered by ViewVC 1.1.22