%2) If you want to read the forcing data from another netcdf file, then % enter read_forcing=1 and provide a name of history or rst file to read data from. % Otherwise set read_forcing=0. read_forcing=0; data_file='coawst_us_20121024_13.nc'; %3) Enter start time of forcing file, in seconds. % This time needs to be consistent with model time (ie dstart and time_ref). % See *.in files for more detail. if (read_forcing) time=ncread(data_file,'sms_time'); t=length(sms_time); sms_time=sms_time(t); else time = [0 1 2]; sms_time = [0 1 2]; end %4) Obtain grid information. grid_file='/home/hpd14/Documents/COAWST_V3.2/Projects/afirst/afirst_grid.nc' %<-enter name of grid here lon_rho=ncread(grid_file,'lon_rho'); lat_rho=ncread(grid_file,'lat_rho'); [ix iy]=size(lon_rho); t=length(sms_time); xrho = ix; yrho = iy; %5) Forcing sustr, svstr. % Forcing values for sustr, svstr. display('Forcing sustr, svstr') % if (read_forcing) sustr=ncread(data_file,'sustr',[1 1 t],[Inf Inf 1]); sustr(isnan(sustr))=0; % svstr=ncread(data_file,'svstr',[1 1 t],[Inf Inf 1]); svstr(isnan(svstr))=0; else sustr(1:length(sms_time),1:xrho,1:yrho) = 0.15; svstr(1:length(sms_time),1:xrho,1:yrho) = 0; end %now write the data from the arrays to the netcdf file disp(' ## Filling Variables in netcdf file with data...') ncwrite('frc_uvstress.nc','sms_time',sms_time); ncwrite('frc_uvstress.nc','sustr',sustr); ncwrite('frc_uvstress.nc','svstr',svstr); %close file disp(['created ', 'frc_uvstress.nc'])