function create_forcing(frcname,grdname,title,smst,... shft,swft,srft,sstt,ssst,smsc,... shfc,swfc,srfc,sstc,sssc) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Create an empty netcdf forcing file % frcname: name of the forcing file % grdname: name of the grid file % title: title in the netcdf file % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% nc=netcdf(grdname); L=length(nc('xi_psi')); M=length(nc('eta_psi')); result=close(nc); Lp=L+1; Mp=M+1; %nw = netcdf(frcname, 'clobber'); %result = redef(nw); ncid=netcdf.create(frcname,'64BIT_OFFSET'); netcdf.close(ncid); nw = netcdf(frcname,'write'); result = redef(nw) % % Create dimensions % nw('xi_u') = L; nw('eta_u') = Mp; nw('xi_v') = Lp; nw('eta_v') = M; nw('xi_rho') = Lp; nw('eta_rho') = Mp; nw('xi_psi') = L; nw('eta_psi') = M; N=30; nc('s_rho') = N; nw('ocean_time') = length(smst); nw('sms_time') = length(smst); nw('shf_time') = length(shft); nw('swf_time') = length(swft); nw('sst_time') = length(sstt); nw('srf_time') = length(srft); nw('sss_time') = length(ssst); % % Create variables and attributes % nw{'ocean_time'} = ncdouble('ocean_time'); nw{'ocean_time'}.long_name = ncchar('surface momentum stress time'); nw{'ocean_time'}.long_name = 'surface momentum stress time'; nw{'ocean_time'}.units = ncchar('days'); nw{'ocean_time'}.units = 'days'; nw{'ocean_time'}.cycle_length = length(smsc); % nw{'sms_time'} = ncdouble('sms_time'); nw{'sms_time'}.long_name = ncchar('surface momentum stress time'); nw{'sms_time'}.long_name = 'surface momentum stress time'; nw{'sms_time'}.units = ncchar('days'); nw{'sms_time'}.units = 'days'; nw{'sms_time'}.cycle_length = length(smsc); nw{'shf_time'} = ncdouble('shf_time'); nw{'shf_time'}.long_name = ncchar('surface heat flux time'); nw{'shf_time'}.long_name = 'surface heat flux time'; nw{'shf_time'}.units = ncchar('days'); nw{'shf_time'}.units = 'days'; nw{'shf_time'}.cycle_length =length(shfc) ; nw{'swf_time'} = ncdouble('swf_time'); nw{'swf_time'}.long_name = ncchar('surface freshwater flux time'); nw{'swf_time'}.long_name = 'surface freshwater flux time'; nw{'swf_time'}.units = ncchar('days'); nw{'swf_time'}.units = 'days'; nw{'swf_time'}.cycle_length = length(swfc); nw{'sst_time'} = ncdouble('sst_time'); nw{'sst_time'}.long_name = ncchar('sea surface temperature time'); nw{'sst_time'}.long_name = 'sea surface temperature time'; nw{'sst_time'}.units = ncchar('days'); nw{'sst_time'}.units = 'days'; nw{'sst_time'}.cycle_length = length(sstc); nw{'sss_time'} = ncdouble('sss_time'); nw{'sss_time'}.long_name = ncchar('sea surface salinity time'); nw{'sss_time'}.long_name = 'sea surface salinity time'; nw{'sss_time'}.units = ncchar('days'); nw{'sss_time'}.units = 'days'; nw{'sss_time'}.cycle_length = length(sssc); nw{'srf_time'} = ncdouble('srf_time'); nw{'srf_time'}.long_name = ncchar('solar shortwave radiation time'); nw{'srf_time'}.long_name = 'solar shortwave radiation time'; nw{'srf_time'}.units = ncchar('days'); nw{'srf_time'}.units = 'days'; nw{'srf_time'}.cycle_length = length(srfc); nw{'sustr'} = ncdouble('sms_time', 'eta_u', 'xi_u'); nw{'sustr'}.long_name = ncchar('surface u-momentum stress'); nw{'sustr'}.long_name = 'surface u-momentum stress'; nw{'sustr'}.units = ncchar('Newton meter-2'); nw{'sustr'}.units = 'Newton meter-2'; nw{'svstr'} = ncdouble('sms_time', 'eta_v', 'xi_v'); nw{'svstr'}.long_name = ncchar('surface v-momentum stress'); nw{'svstr'}.long_name = 'surface v-momentum stress'; nw{'svstr'}.units = ncchar('Newton meter-2'); nw{'svstr'}.units = 'Newton meter-2'; nw{'shflux'} = ncdouble('shf_time', 'eta_rho', 'xi_rho'); nw{'shflux'}.long_name = ncchar('surface net heat flux'); nw{'shflux'}.long_name = 'surface net heat flux'; nw{'shflux'}.units = ncchar('Watts meter-2'); nw{'shflux'}.units = 'Watts meter-2'; nw{'swflux'} = ncdouble('swf_time', 'eta_rho', 'xi_rho'); nw{'swflux'}.long_name = ncchar('surface freshwater flux (E-P)'); nw{'swflux'}.long_name = 'surface freshwater flux (E-P)'; nw{'swflux'}.units = ncchar('centimeter day-1'); nw{'swflux'}.units = 'centimeter day-1'; nw{'swflux'}.positive = ncchar('net evaporation'); nw{'swflux'}.positive = 'net evaporation'; nw{'swflux'}.negative = ncchar('net precipitation'); nw{'swflux'}.negative = 'net precipitation'; nw{'SST'} = ncdouble('sst_time', 'eta_rho', 'xi_rho'); nw{'SST'}.long_name = ncchar('sea surface temperature'); nw{'SST'}.long_name = 'sea surface temperature'; nw{'SST'}.units = ncchar('Celsius'); nw{'SST'}.units = 'Celsius'; nw{'SSS'} = ncdouble('sss_time', 'eta_rho', 'xi_rho'); nw{'SSS'}.long_name = ncchar('sea surface salinity'); nw{'SSS'}.long_name = 'sea surface salinity'; nw{'SSS'}.units = ncchar('PSU'); nw{'SSS'}.units = 'PSU'; nw{'dQdSST'} = ncdouble('sst_time', 'eta_rho', 'xi_rho'); nw{'dQdSST'}.long_name = ncchar('surface net heat flux sensitivity to SST'); nw{'dQdSST'}.long_name = 'surface net heat flux sensitivity to SST'; nw{'dQdSST'}.units = ncchar('Watts meter-2 Celsius-1'); nw{'dQdSST'}.units = 'Watts meter-2 Celsius-1'; nw{'swrad'} = ncdouble('srf_time', 'eta_rho', 'xi_rho'); nw{'swrad'}.long_name = ncchar('solar shortwave radiation'); nw{'swrad'}.long_name = 'solar shortwave radiation'; nw{'swrad'}.units = ncchar('Watts meter-2'); nw{'swrad'}.units = 'Watts meter-2'; nw{'swrad'}.positive = ncchar('downward flux, heating'); nw{'swrad'}.positive = 'downward flux, heating'; nw{'swrad'}.negative = ncchar('upward flux, cooling'); nw{'swrad'}.negative = 'upward flux, cooling'; % nc{'mud_01_sflux'} = ncdouble('ocean_time','s_rho','eta_rho','xi_rho') ; nc{'sand_01_sflux'} = ncdouble('ocean_time','s_rho','eta_rho','xi_rho') ; % nc{'mud_01_sflux'}.long_name = ncchar('suspended cohesive sediment'); nc{'mud_01_sflux'}.long_name = 'suspended cohesive sediment'; nc{'mud_01_sflux'}.units = ncchar('kilogram meter-3'); nc{'mud_01_sflux'}.units = 'kilogram meter-3'; % nc{'sand_01_sflux'}.long_name = ncchar('suspended noncohesive sediment'); nc{'sand_01_sflux'}.long_name = 'suspended cohesive sediment'; nc{'sand_01_sflux'}.units = ncchar('kilogram meter-3'); nc{'sand_01_sflux'}.units = 'kilogram meter-3'; % result = endef(nw); % % Create global attributes % nw.title = ncchar(title); nw.title = title; nw.date = ncchar(date); nw.date = date; nw.grd_file = ncchar(grdname); nw.grd_file = grdname; nw.type = ncchar('ROMS forcing file'); nw.type = 'ROMS forcing file'; % % Write time variables % nw{'ocean_time'}(:) = smst; nw{'sms_time'}(:) = smst; nw{'shf_time'}(:) = shft; nw{'swf_time'}(:) = swft; nw{'sst_time'}(:) = sstt; nw{'srf_time'}(:) = srft; nw{'sss_time'}(:) = ssst; nc{'mud_01_sflux'}(:) = 0.1; nc{'sand_01_sflux'}(:) = 0.2; close(nw);