Commit 2b1090b0 authored by Pierre Cazenave's avatar Pierre Cazenave

Add support for creating a NetCDF global variable listing the names of the...

Add support for creating a NetCDF global variable listing the names of the components used in the NetCDF file
parent 5facc404
function write_FVCOM_spectide(ObcNodes,Period,Phase,Amp,BetaLove,EquilibriumAmp,SpectralFile,MyTitle)
function write_FVCOM_spectide(ObcNodes,StartDate,Components,Period,Phase,Amp,BetaLove,EquilibriumAmp,SpectralFile,MyTitle)
% Write an FVCOM spectral tidal elevation forcing file
%
% function write_FVCOM_spectide(ObcNodes,Period,Phase,Amp,BetaLove,EquilibriumAmp,SpectralFile,MyTitle)
% function write_FVCOM_spectide(ObcNodes,Components,Period,Phase,Amp,BetaLove,EquilibriumAmp,SpectralFile,MyTitle)
%
% DESCRIPTION:
% Write an FVCOM NetCDF spectral tidal elevation forcing file
......@@ -52,14 +52,14 @@ if(report); fprintf('Number of Open Boundary Nodes %d\n',nObcs); end;
[chk1,chk2] = size(Amp);
if( (nObcs-chk1)*(nComponents-chk2) ~= 0)
fprintf('Amp dimensions do not match!!!')
fprintf('nObcs %d nComponens %d\n',chk1,chk2)
fprintf('nObcs %d nComponents %d\n',chk1,chk2)
error('bad');
end;
[chk1,chk2] = size(Phase);
if( (nObcs-chk1)*(nComponents-chk2) ~= 0)
fprintf('Phase dimensions do not match!!!')
fprintf('nObcs %d nComponens %d\n',chk1,chk2)
fprintf('nObcs %d nComponents %d\n',chk1,chk2)
error('bad');
end;
......@@ -73,6 +73,11 @@ nc=netcdf.create(SpectralFile,'clobber');
% define global attributes
netcdf.putAtt(nc,netcdf.getConstant('NC_GLOBAL'),'type','FVCOM SPECTRAL ELEVATION FORCING FILE')
netcdf.putAtt(nc,netcdf.getConstant('NC_GLOBAL'),'title',MyTitle)
ComponentsOut = char();
for i=1:nComponents
ComponentsOut = [ComponentsOut, Components{i}];
end
netcdf.putAtt(nc,netcdf.getConstant('NC_GLOBAL'),'components',ComponentsOut)
netcdf.putAtt(nc,netcdf.getConstant('NC_GLOBAL'),'history','FILE CREATED using write_FVCOM_spectide')
% define dimensions
......@@ -144,7 +149,7 @@ for i=1:nComponents
end
end
netcdf.putVar(nc,date_str_len_varid,nStringOut);
netcdf.putVar(nc,time_origin_varid,0);
netcdf.putVar(nc,time_origin_varid,StartDate);
% close file
netcdf.close(nc);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment