


function tmean(cdfin,cdfout,tind,tout)
TMEAN computes mean Calendar time over time steps tind
of a ecomsi model run. cdfin is the ecomsi.cdf run, and
cdfout is a dummy ecomsi.cdf.
tind is the indices of time steps to average over (1 is first step)
tout is the index of the time step in CDFOUT to write the mean

0001 function tmean(cdfin,cdfout,tind,tout) 0002 %function tmean(cdfin,cdfout,tind,tout) 0003 % 0004 % TMEAN computes mean Calendar time over time steps tind 0005 % of a ecomsi model run. cdfin is the ecomsi.cdf run, and 0006 % cdfout is a dummy ecomsi.cdf. 0007 % 0008 % tind is the indices of time steps to average over (1 is first step) 0009 % tout is the index of the time step in CDFOUT to write the mean 0010 % 0011 disp('averaging time') 0012 varin='time'; 0013 mexcdf('setopts',0); 0014 cdfid1=mexcdf('open',cdfin,'nowrite'); 0015 cdfid2=mexcdf('open',cdfout,'write'); 0016 0017 base_date=mexcdf('attget',cdfid1,'GLOBAL','base_date'); 0018 mexcdf('attput',cdfid2,'GLOBAL','base_date','long',3,base_date); 0019 0020 time=mexcdf('varget',cdfid1,varin,tind(1)-1,length(tind)) ; 0021 mtime=mean(time); 0022 mexcdf('varput',cdfid2,varin,tout-1,1,mtime); 0023 0024 mexcdf('close',cdfid1); 0025 mexcdf('close',cdfid2);