rep_out='/bay/scratch2/TAO_PIRATA/'; filename_out='tao_pirata_92_08'; for num_var=1:3; if num_var==1; nom_var='T';list_files=strvcat('tao_92_08T.nc','pirata_92_08T.nc','rama_92_08T.nc'); elseif num_var==2; nom_var='S';list_files=strvcat('tao_92_08S.nc','pirata_92_08S.nc','rama_92_08S.nc'); else; nom_var='UV';list_files=strvcat('tao_92_08UV.nc','pirata_92_08UV.nc','rama_92_08UV.nc'); end; %compile lists and handle different depths nb_prof=0; list_alldepth=[]; for num_file=1:size(list_files,1) eval(['ncload ' rep_out deblank(list_files(num_file,:)) ' prof_lon depth;']); nb_prof=nb_prof+length(prof_lon); depth %CKCKCKC if ~isempty(strfind(nom_var,'U')); eval(['ncload ' rep_out deblank(list_files(num_file,:)) ' prof_Uweight;']); prof_w=prof_Uweight; else eval(['ncload ' rep_out deblank(list_files(num_file,:)) ' prof_' nom_var 'weight']); %CKCKCKCK prof_w=(['prof_' nom_var 'weight']); eval(['prof_w=prof_' nom_var 'weight' ';']) end tmp1=sum(prof_w,1); tmp1=find(tmp1>0); for kcur=1:length(tmp1); if isempty(find(list_alldepth==depth(tmp1(kcur)))); list_alldepth=[list_alldepth depth(tmp1(kcur))]; end; list_alldepth %CKCKCKCKC end;%for kcur=1:length(tmp1); end;%for num_file=1:size(list_files,1) dmod=sort(list_alldepth); nb_lev=length(dmod); nb_char=30; %create the combined file: %------------------------ fcdf=netcdf([rep_out filename_out nom_var '.nc'], 'clobber'); %define netcdf dimensions : fcdf('iPROF') = nb_prof; fcdf('iDEPTH') = nb_lev; fcdf('lTXT') = nb_char; %define netcdf variables : fcdf{'depth'} = ncdouble('iDEPTH'); fcdf{'depth'}.units='meters'; fcdf{'prof_YYYYMMDD'} = ncdouble('iPROF'); fcdf{'prof_YYYYMMDD'}.missing_value=-9999; fcdf{'prof_YYYYMMDD'}.long_name='year (4 digits), month (2 digits), day (2 digits)'; fcdf{'prof_HHMMSS'} = ncdouble('iPROF'); fcdf{'prof_HHMMSS'}.missing_value=-9999; fcdf{'prof_HHMMSS'}.long_name='hour (2 digits), minute (2 digits), seconde (2 digits)'; fcdf{'prof_lon'} = ncdouble('iPROF'); fcdf{'prof_lon'}.units='(degree E)'; fcdf{'prof_lon'}.missing_value=-9999; fcdf{'prof_lat'} = ncdouble('iPROF'); fcdf{'prof_lat'}.units='(degree N)'; fcdf{'prof_lat'}.missing_value=-9999; if ~isempty(strfind(nom_var,'T')); fcdf{'prof_T'} = ncdouble('iPROF','iDEPTH'); fcdf{'prof_T'}.long_name='potential temperature'; fcdf{'prof_T'}.units='degree Celsius'; fcdf{'prof_T'}.missing_value=-9999; fcdf{'prof_Tweight'} = ncdouble('iPROF','iDEPTH'); fcdf{'prof_Tweight'}.long_name='weights'; fcdf{'prof_Tweight'}.units='(degree Celsius)^-2'; fcdf{'prof_Tweight'}.missing_value=0; elseif ~isempty(strfind(nom_var,'S')); fcdf{'prof_S'} = ncdouble('iPROF','iDEPTH'); fcdf{'prof_S'}.long_name='salinity'; fcdf{'prof_S'}.units='(no units)'; fcdf{'prof_S'}.missing_value=-9999; fcdf{'prof_Sweight'} = ncdouble('iPROF','iDEPTH'); fcdf{'prof_Sweight'}.long_name='weights'; fcdf{'prof_Sweight'}.units='(no units)^-2'; fcdf{'prof_Sweight'}.missing_value=0; else fcdf{'prof_U'} = ncdouble('iPROF','iDEPTH'); fcdf{'prof_U'}.long_name='zonal velocity'; fcdf{'prof_U'}.units='m/s'; fcdf{'prof_U'}.missing_value=-9999; fcdf{'prof_Uweight'} = ncdouble('iPROF','iDEPTH'); fcdf{'prof_Uweight'}.long_name='weights'; fcdf{'prof_Uweight'}.units='(m/s)^-2'; fcdf{'prof_Uweight'}.missing_value=0; fcdf{'prof_V'} = ncdouble('iPROF','iDEPTH'); fcdf{'prof_V'}.long_name='meridional velocity'; fcdf{'prof_V'}.units='m/s'; fcdf{'prof_V'}.missing_value=-9999; fcdf{'prof_Vweight'} = ncdouble('iPROF','iDEPTH'); fcdf{'prof_Vweight'}.long_name='weights'; fcdf{'prof_Vweight'}.units='(m/s)^-2'; fcdf{'prof_Vweight'}.missing_value=0; end fcdf{'prof_descr'} = ncchar('iPROF','lTXT'); fcdf{'prof_descr'}.long_name='profile description'; %fill the vector of the standard depths : fcdf{'depth'}(1:nb_lev)=dmod; %fill the rest of the variables: prev_ind=0; for num_file=1:size(list_files,1) eval(['ncload ' rep_out deblank(list_files(num_file,:)) ';']); prof_lon(find(prof_lon>360))=prof_lon(find(prof_lon>360))-360; list_prof=[1:length(prof_lon)]; fprintf(num2str(num_file)); if ~isempty(strfind(nom_var,'U')); prof_w=prof_Uweight; else; eval(['prof_w=prof_' nom_var 'weight;']); end; tmp1=sum(prof_w,1); tmp1=find(tmp1>0); kcur_glob=zeros(length(tmp1),1); for kcur=1:length(tmp1); kcur_glob(kcur)=find(dmod==depth(tmp1(kcur))); end; kcur_loc=tmp1; %fill the date and position vectors : fcdf{'prof_YYYYMMDD'}(prev_ind+list_prof)=prof_YYYYMMDD(list_prof); fcdf{'prof_HHMMSS'}(prev_ind+list_prof)=prof_HHMMSS(list_prof); fcdf{'prof_lon'}(prev_ind+list_prof)=prof_lon(list_prof); fcdf{'prof_lat'}(prev_ind+list_prof)=prof_lat(list_prof); %fill the data matrices : for kcur=1:length(kcur_glob) if ~isempty(strfind(nom_var,'T')); fcdf{'prof_T'}(prev_ind+list_prof,kcur_glob(kcur))=prof_T(list_prof,kcur_loc(kcur)); fcdf{'prof_Tweight'}(prev_ind+list_prof,kcur_glob(kcur))=prof_Tweight(list_prof,kcur_loc(kcur)); elseif ~isempty(strfind(nom_var,'S')); fcdf{'prof_S'}(prev_ind+list_prof,kcur_glob(kcur))=prof_S(list_prof,kcur_loc(kcur)); fcdf{'prof_Sweight'}(prev_ind+list_prof,kcur_glob(kcur))=prof_Sweight(list_prof,kcur_loc(kcur)); else fcdf{'prof_U'}(prev_ind+list_prof,kcur_glob(kcur))=prof_U(list_prof,kcur_loc(kcur)); fcdf{'prof_Uweight'}(prev_ind+list_prof,kcur_glob(kcur))=prof_Uweight(list_prof,kcur_loc(kcur)); fcdf{'prof_V'}(prev_ind+list_prof,kcur_glob(kcur))=prof_V(list_prof,kcur_loc(kcur)); fcdf{'prof_Vweight'}(prev_ind+list_prof,kcur_glob(kcur))=prof_Vweight(list_prof,kcur_loc(kcur)); end end for kcur=1:length(dmod) if isempty(find(kcur_glob==kcur)) if ~isempty(strfind(nom_var,'T')); fcdf{'prof_T'}(prev_ind+list_prof,kcur)=-9999*ones(length(list_prof),1); fcdf{'prof_Tweight'}(prev_ind+list_prof,kcur)=0*ones(length(list_prof),1); elseif ~isempty(strfind(nom_var,'S')); fcdf{'prof_S'}(prev_ind+list_prof,kcur)=-9999*ones(length(list_prof),1); fcdf{'prof_Sweight'}(prev_ind+list_prof,kcur)=0*ones(length(list_prof),1); else fcdf{'prof_U'}(prev_ind+list_prof,kcur)=-9999*ones(length(list_prof),1); fcdf{'prof_Uweight'}(prev_ind+list_prof,kcur)=0*ones(length(list_prof),1); fcdf{'prof_V'}(prev_ind+list_prof,kcur)=-9999*ones(length(list_prof),1); fcdf{'prof_Vweight'}(prev_ind+list_prof,kcur)=0*ones(length(list_prof),1); end end end %fill the field describing the instruments : fcdf{'prof_descr'}(prev_ind+list_prof,:)=prof_descr(list_prof,:); prev_ind=prev_ind+length(list_prof); end %close the file : fcdf=close(fcdf); end;%for num_var=1:2;