0001 function write_FVCOM_meanflow(Mobj, ncfile, data)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034 subname = 'write_FVCOM_meanflow';
0035
0036 global ftbverbose
0037 if ftbverbose
0038 fprintf('\n'); fprintf(['begin : ' subname '\n']);
0039 end
0040
0041
0042 nc = netcdf.create(ncfile, 'clobber');
0043
0044
0045 netcdf.putAtt(nc,netcdf.getConstant('NC_GLOBAL'), 'type', 'FVCOM MEANFLOW TIME SERIES FILE')
0046 netcdf.putAtt(nc,netcdf.getConstant('NC_GLOBAL'), 'title', 'FVCOM MEANFLOW TIME SERIES data for open boundary')
0047 netcdf.putAtt(nc,netcdf.getConstant('NC_GLOBAL'), 'history', sprintf('File created with %s from the MATLAB fvcom-toolbox', subname))
0048 netcdf.putAtt(nc,netcdf.getConstant('NC_GLOBAL'), 'filename', ncfile)
0049 netcdf.putAtt(nc,netcdf.getConstant('NC_GLOBAL'), 'Conventions', 'CF-1.0')
0050
0051
0052 nmfcell_dimid = netcdf.defDim(nc, 'nmfcell', Mobj.nObcElements);
0053 time_dimid = netcdf.defDim(nc, 'time', netcdf.getConstant('NC_UNLIMITED'));
0054 siglay_dimid = netcdf.defDim(nc, 'siglay', size(Mobj.siglay, 2));
0055 siglev_dimid = netcdf.defDim(nc, 'siglev', size(Mobj.siglev, 2));
0056
0057
0058 time_varid = netcdf.defVar(nc, 'time', 'NC_FLOAT', time_dimid);
0059 netcdf.putAtt(nc, time_varid, 'long_name', 'time');
0060 netcdf.putAtt(nc, time_varid, 'units', 'days since 1858-11-17 00:00:00');
0061 netcdf.putAtt(nc, time_varid, 'format', 'modified julian day (MJD)');
0062 netcdf.putAtt(nc, time_varid, 'time_zone', 'UTC');
0063
0064 itime_varid = netcdf.defVar(nc, 'Itime', 'NC_INT', time_dimid);
0065 netcdf.putAtt(nc, itime_varid, 'units', 'days since 1858-11-17 00:00:00');
0066 netcdf.putAtt(nc, itime_varid, 'format', 'modified julian day (MJD)');
0067 netcdf.putAtt(nc, itime_varid, 'time_zone', 'UTC');
0068
0069 itime2_varid = netcdf.defVar(nc, 'Itime2', 'NC_INT', time_dimid);
0070 netcdf.putAtt(nc, itime2_varid, 'units', 'msec since 00:00:00');
0071 netcdf.putAtt(nc, itime2_varid, 'time_zone', 'UTC');
0072
0073 nmfcell_varid = netcdf.defVar(nc, 'I_MFCELL_GL', 'NC_INT', nmfcell_dimid);
0074 netcdf.putAtt(nc, nmfcell_varid, 'long_name', 'Open Boundary Cell Number');
0075 netcdf.putAtt(nc, nmfcell_varid, 'grid', 'obc_grid');
0076 netcdf.putAtt(nc, nmfcell_varid, 'type', 'data');
0077
0078 mfdist_varid = netcdf.defVar(nc, 'MFDIST', 'NC_FLOAT', [siglay_dimid, nmfcell_dimid]);
0079 netcdf.putAtt(nc, mfdist_varid, 'long_name', 'Mean Flow Flux Vertical Distribution');
0080 netcdf.putAtt(nc, mfdist_varid, 'units', 'no units');
0081 netcdf.putAtt(nc, mfdist_varid, 'grid', 'obc_grid');
0082 netcdf.putAtt(nc, mfdist_varid, 'type', 'data');
0083
0084 dmfqdis_varid = netcdf.defVar(nc, 'DMFQDIS', 'NC_FLOAT', [nmfcell_dimid, time_dimid]);
0085 netcdf.putAtt(nc, dmfqdis_varid, 'long_name', 'open boundary mean flow flux');
0086 netcdf.putAtt(nc, dmfqdis_varid, 'units', 'm^3/s');
0087 netcdf.putAtt(nc, dmfqdis_varid, 'grid', 'obc_grid');
0088 netcdf.putAtt(nc, dmfqdis_varid, 'type', 'data');
0089
0090
0091 netcdf.endDef(nc);
0092
0093
0094 netcdf.putVar(nc, time_varid, 0, numel(Mobj.mf_times), Mobj.mf_times);
0095 netcdf.putVar(nc, itime_varid, floor(Mobj.mf_times));
0096 netcdf.putVar(nc, itime2_varid, 0, numel(Mobj.mf_times), mod(Mobj.mf_times, 1) * 24 * 3600 * 1000);
0097 netcdf.putVar(nc, nmfcell_varid, Mobj.read_obc_elements{1});
0098
0099
0100
0101 netcdf.putVar(nc, mfdist_varid, repmat(abs(diff(Mobj.siglev)), [numel([Mobj.read_obc_elements{:}]), 1])');
0102 netcdf.putVar(nc, dmfqdis_varid, [0, 0], [numel(Mobj.read_obc_elements{1}), numel(Mobj.mf_times)], data);
0103
0104 netcdf.close(nc);
0105
0106 if ftbverbose
0107 fprintf(['end : ' subname '\n'])
0108 end
0109