choiceStruct=3; %=============== if choiceStruct==1; structIn=[]; % structIn.vars=mygrid; structIn.vars.RF=structIn.vars.RF(1:50); % structIn.descr={'C-grid parameters (see MITgcm documentation for details).'}; % vars=[]; nv=length(vars)+1; vars(nv).fldName='XC'; vars(nv).longName='longitude'; vars(nv).units='degrees_east'; nv=length(vars)+1; vars(nv).fldName='YC'; vars(nv).longName='latitude'; vars(nv).units='degrees_north'; nv=length(vars)+1; vars(nv).fldName='XG'; vars(nv).longName='longitude'; vars(nv).units='degrees_east'; nv=length(vars)+1; vars(nv).fldName='YG'; vars(nv).longName='latitude'; vars(nv).units='degrees_north'; nv=length(vars)+1; vars(nv).fldName='RAC'; vars(nv).longName='grid cell area'; vars(nv).units='m^2'; nv=length(vars)+1; vars(nv).fldName='RAZ'; vars(nv).longName='grid cell area'; vars(nv).units='m^2'; nv=length(vars)+1; vars(nv).fldName='DXC'; vars(nv).longName='grid spacing'; vars(nv).units='m'; nv=length(vars)+1; vars(nv).fldName='DYC'; vars(nv).longName='grid spacing'; vars(nv).units='m'; nv=length(vars)+1; vars(nv).fldName='DXG'; vars(nv).longName='grid spacing'; vars(nv).units='m'; nv=length(vars)+1; vars(nv).fldName='DYG'; vars(nv).longName='grid spacing'; vars(nv).units='m'; nv=length(vars)+1; vars(nv).fldName='hFacC'; vars(nv).longName='fractional thickness'; vars(nv).units='1'; nv=length(vars)+1; vars(nv).fldName='hFacW'; vars(nv).longName='fractional thickness'; vars(nv).units='1'; nv=length(vars)+1; vars(nv).fldName='hFacS'; vars(nv).longName='fractional thickness'; vars(nv).units='1'; nv=length(vars)+1; vars(nv).fldName='Depth'; vars(nv).longName='sea floor depth'; vars(nv).units='m'; nv=length(vars)+1; vars(nv).fldName='AngleCS'; vars(nv).longName='grid orientation (cosine)'; vars(nv).units='m'; nv=length(vars)+1; vars(nv).fldName='AngleSN'; vars(nv).longName='grid orientation (sine)'; vars(nv).units='m'; nv=length(vars)+1; vars(nv).fldName='RC'; vars(nv).longName='vertical coordinate'; vars(nv).units='m'; nv=length(vars)+1; vars(nv).fldName='RF'; vars(nv).longName='vertical coordinate'; vars(nv).units='m'; nv=length(vars)+1; vars(nv).fldName='DRC'; vars(nv).longName='grid spacing'; vars(nv).units='m'; nv=length(vars)+1; vars(nv).fldName='DRF'; vars(nv).longName='grid spacing'; vars(nv).units='m'; nv=length(vars)+1; % structIn.defs=vars; % struct2nctiles('release1/','GRID',structIn,[90 90]); end; %=============== if choiceStruct==2; budgName='budgHo' structIn=[]; % load release1/mat/diags_grid_parms.mat myparms; dirMat=['release1/mat/diags_set_' budgName '/']; fileMat=[budgName '_*.mat']; structIn.vars=diags_read_from_mat(dirMat,fileMat); %vector of time increment [listTimes]=diags_list_times({'release1/diags/BUDG/'},{'budg2d_hflux_set1'}); structIn.vars.dt=diff(listTimes); structIn.vars.dt=3600*structIn.vars.dt(1:end-1)'; % specs=structIn.vars.specs(1); if strcmp(specs.units,'W'); structIn.descr={'Heat budget in extensive form (in Watt, on C-Grid)'}; elseif strcmp(specs.units,'kg/s'); structIn.descr={'Mass budget in extensive form (in kg/s, on C-Grid)'}; elseif strcmp(specs.units,'g/s'); structIn.descr={'Salt budget in extensive form (in g/s, on C-Grid)'}; else; error('unknown budget'); end; structIn.descr={structIn.descr{:},'between',specs.top,'(top) and',specs.bottom,'(bottom)'}; % vars=[]; nv=length(vars)+1; vars(nv).fldName='tend'; vars(nv).longName='tendency term'; vars(nv).units=specs.units; nv=length(vars)+1; vars(nv).fldName='trU'; vars(nv).longName='horizontal transport'; vars(nv).units=specs.units; nv=length(vars)+1; vars(nv).fldName='trV'; vars(nv).longName='horizontal transport'; vars(nv).units=specs.units; nv=length(vars)+1; vars(nv).fldName='trWtop'; vars(nv).longName='vertical transport'; vars(nv).units=specs.units; nv=length(vars)+1; vars(nv).fldName='trWbot'; vars(nv).longName='vertical transport'; vars(nv).units=specs.units; nv=length(vars)+1; vars(nv).fldName='dt'; vars(nv).longName='time increment'; vars(nv).units='s'; nv=length(vars)+1; % structIn.defs=vars; % struct2nctiles('release1/',budgName,structIn,[90 90]); end; %=============== if choiceStruct==3; %budgName='budgHo'; if budgName(end)=='o'; listFlds={'tend','trU','trV','trWtop'}; else; listFlds={'tend','trU','trV','trWtop','trWbot'}; end; for ii=1:length(listFlds); fldName=listFlds{ii}; %fldName='trWtop'; [budgName ' -- ' fldName] %directories dirIn='r4it11.c65i/'; dirMat='mat_budg3d/'; dirOut=fullfile(dirIn,'nctiles_budg',filesep); if ~isdir(dirOut); mkdir(dirOut); end; dirOut=fullfile(dirOut,budgName,filesep); if ~isdir(dirOut); mkdir(dirOut); end; %load variable eval(['load ' dirIn dirMat 'diags_grid_parms.mat myparms;']); dirMat=[dirIn dirMat 'diags_set_' budgName '/']; fileMat=[budgName '_*.mat']; tic; structIn.vars=diags_read_from_mat(dirMat,fileMat,fldName); toc; %time vectors [listTimes]=diags_list_times({[dirIn 'diags/BUDG/']},{'budg2d_hflux_set1'}); structIn.vars.t0=3600*listTimes(1:end-2); structIn.vars.t1=3600*listTimes(2:end-1); %rename trWtop as trW if adequate if strcmp(fldName,'trWtop')&(budgName(end)=='o'); structIn.vars=setfield(structIn.vars,'trW',structIn.vars.trWtop); structIn.vars=rmfield(structIn.vars,'trWtop'); structIn.vars.listDiags={'trW'}; fldName='trW'; end; %switch back to upward convention if strcmp(fldName(1:3),'trW'); tmp1=getfield(structIn.vars,fldName); structIn.vars=setfield(structIn.vars,fldName,-tmp1); end; %general description tmp1=diags_read_from_mat(dirMat,fileMat,'specs',1); specs=tmp1.specs; if strcmp(specs.units,'W'); structIn.descr={'Heat budget in extensive form (in Watt, on C-Grid)'}; elseif strcmp(specs.units,'kg/s'); structIn.descr={'Mass budget in extensive form (in kg/s, on C-Grid)'}; elseif strcmp(specs.units,'g/s'); structIn.descr={'Salt budget in extensive form (in g/s, on C-Grid)'}; else; error('unknown budget'); end; %variables description vars=[]; nv=length(vars)+1; vars(nv).fldName=fldName; vars(nv).units=specs.units; switch fldName; case 'tend'; vars(nv).longName='tendency term'; case 'trU'; vars(nv).longName='horizontal transport (U)'; case 'trV'; vars(nv).longName='horizontal transport (V)'; case 'trW'; vars(nv).longName='upward vertical transport (W)'; case 'trWtop'; vars(nv).longName='upward vertical transport (W)'; case 'trWbot'; vars(nv).longName='upward vertical transport (W)'; end; nv=length(vars)+1; vars(nv).fldName='t0'; vars(nv).longName='initial time'; vars(nv).units='s'; nv=length(vars)+1; vars(nv).fldName='t1'; vars(nv).longName='final time'; vars(nv).units='s'; nv=length(vars)+1; % structIn.defs=vars; %create file tic; struct2nctiles(dirIn,fldName,structIn,[90 90]); toc; eval(['!mv ' pwd filesep dirIn filesep 'tmp_nctiles' filesep fldName ' ' pwd filesep dirOut]); end;%for fldName=listFlds; end;