/[MITgcm]/MITgcm_contrib/gael/matlab_class/gcmfaces_IO/prep2nctiles.m
ViewVC logotype

Diff of /MITgcm_contrib/gael/matlab_class/gcmfaces_IO/prep2nctiles.m

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

revision 1.1 by gforget, Tue Jan 20 12:01:19 2015 UTC revision 1.4 by gforget, Tue Feb 3 16:29:09 2015 UTC
# Line 1  Line 1 
1    
2  choiceStruct=1;  choiceStruct=3;
3    
4  %===============  %===============
5    
# Line 50  if choiceStruct==2; Line 50  if choiceStruct==2;
50      fileMat=[budgName '_*.mat'];      fileMat=[budgName '_*.mat'];
51      structIn.vars=diags_read_from_mat(dirMat,fileMat);      structIn.vars=diags_read_from_mat(dirMat,fileMat);
52    
53      %need vector of time increment      %vector of time increment
54      [listTimes]=diags_list_times({'release1/diags/BUDG/'},{'budg2d_hflux_set1'});      [listTimes]=diags_list_times({'release1/diags/BUDG/'},{'budg2d_hflux_set1'});
55      structIn.vars.dt=diff(listTimes);      structIn.vars.dt=diff(listTimes);
56      structIn.vars.dt=3600*structIn.vars.dt(1:end-1)';          structIn.vars.dt=3600*structIn.vars.dt(1:end-1)';    
# Line 81  if choiceStruct==2; Line 81  if choiceStruct==2;
81            
82  end;  end;
83    
84    %===============
85    
86    if choiceStruct==3;
87    
88      budgName='budgHo';
89    
90      if budgName(end)=='o'; listFlds={'tend','trU','trV','trWtop'};
91      else; listFlds={'tend','trU','trV','trWtop','trWbot'};
92      end;
93    
94      for ii=1:length(listFlds);
95        fldName=listFlds{ii};
96        %fldName='trWtop';
97        [budgName ' -- ' fldName]
98    
99        %directories
100        dirIn='r4it11.c65i/';
101        dirMat='mat_budg3d/';
102        dirOut=fullfile(dirIn,'nctiles_budg',filesep);
103        if ~isdir(dirOut); mkdir(dirOut); end;
104        dirOut=fullfile(dirOut,budgName,filesep);
105        if ~isdir(dirOut); mkdir(dirOut); end;
106    
107        %load variable
108        eval(['load ' dirIn dirMat 'diags_grid_parms.mat myparms;']);
109        dirMat=[dirIn dirMat 'diags_set_' budgName '/'];
110        fileMat=[budgName '_*.mat'];
111        tic; structIn.vars=diags_read_from_mat(dirMat,fileMat,fldName); toc;
112    
113        %time vectors
114        [listTimes]=diags_list_times({[dirIn 'diags/BUDG/']},{'budg2d_hflux_set1'});
115        structIn.vars.t0=3600*listTimes(1:end-2);
116        structIn.vars.t1=3600*listTimes(2:end-1);
117    
118        %rename trWtop as trW if adequate
119        if strcmp(fldName,'trWtop')&(budgName(end)=='o');
120          structIn.vars=setfield(structIn.vars,'trW',structIn.vars.trWtop);
121          structIn.vars=rmfield(structIn.vars,'trWtop');
122          structIn.vars.listDiags={'trW'};
123          fldName='trW';
124        end;
125    
126        %general description
127        tmp1=diags_read_from_mat(dirMat,fileMat,'specs',1);
128        specs=tmp1.specs;
129        if strcmp(specs.units,'W');
130            structIn.descr={'Heat budget in extensive form (in Watt, on C-Grid)'};
131        elseif strcmp(specs.units,'kg/s');
132            structIn.descr={'Mass budget in extensive form (in kg/s, on C-Grid)'};
133        elseif strcmp(specs.units,'g/s');
134            structIn.descr={'Salt budget in extensive form (in g/s, on C-Grid)'};
135        else;
136            error('unknown budget');
137        end;
138    
139        %variables description
140        vars=[]; nv=length(vars)+1;
141        vars(nv).fldName=fldName; vars(nv).units=specs.units;
142        switch fldName;
143        case 'tend'; vars(nv).longName='tendency term';
144        case 'trU'; vars(nv).longName='horizontal transport (U)';
145        case 'trV'; vars(nv).longName='horizontal transport (V)';
146        case 'trW'; vars(nv).longName='vertical transport (W)';
147        case 'trWtop'; vars(nv).longName='vertical transport (W)';
148        case 'trWbot'; vars(nv).longName='vertical transport (W)';
149        end;
150        nv=length(vars)+1;
151        vars(nv).fldName='t0'; vars(nv).longName='initial time'; vars(nv).units='s'; nv=length(vars)+1;
152        vars(nv).fldName='t1'; vars(nv).longName='final time'; vars(nv).units='s'; nv=length(vars)+1;
153        %
154        structIn.defs=vars;
155    
156        %create file
157        tic; struct2nctiles(dirIn,fldName,structIn,[90 90]); toc;
158        eval(['!mv ' pwd filesep dirIn filesep 'tmp_nctiles' filesep fldName ' ' pwd filesep dirOut]);
159    
160      end;%for fldName=listFlds;
161    
162    end;
163    

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.4

  ViewVC Help
Powered by ViewVC 1.1.22