function  oct_create_nesteddust(dustname,parentname,grdname,title,dustt,dustc)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% 	Create an empty oct_netcdf dust forcing file (for PISCES)
%       dustname: name of the dust file
%       grdname: name of the grid file
%       title: title in the oct_netcdf file  
%
%  Further Information:  
%  http://www.croco-ocean.org
%  
%  This file is part of CROCOTOOLS
%
%  CROCOTOOLS is free software; you can redistribute it and/or modify
%  it under the terms of the GNU General Public License as published
%  by the Free Software Foundation; either version 2 of the License,
%  or (at your option) any later version.
%
%  CROCOTOOLS is distributed in the hope that it will be useful, but
%  WITHOUT ANY WARRANTY; without even the implied warranty of
%  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
%  GNU General Public License for more details.
%
%  You should have received a copy of the GNU General Public License
%  along with this program; if not, write to the Free Software
%  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
%  MA  02111-1307  USA
%
%  Copyright (c) 2004-2006 by Pierrick Penven 
%  e-mail:Pierrick.Penven@ird.fr  
%  Update : Gildas Cambon 13 Oct 2009
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% options for oct_write_time_attributes
insecond =  0 ;
add_cycle = 1 ; 
%
% Initialize Yorig if not provided
if ~exist('Yorig', 'var') ,  Yorig = []; , end
%
% Get time attributes
[time_unit_att,time_second_unit_att,calendar_att]=...
    oct_get_time_attributes(Yorig);
%
ncid = netcdf.open(grdname, 'NC_NOWRITE');
L=netcdf.inqDimLen(ncid, netcdf.inqDimID(ncid, 'xi_psi'));
M=netcdf.inqDimLen(ncid, netcdf.inqDimID(ncid, 'eta_psi'));
netcdf.close(ncid);
Lp=L+1;
Mp=M+1;
nw_id = netcdf.create(dustname, 'NC_CLOBBER');
%redef(nw);
%
%  Create dimensions
%
did_xi_u = netcdf.defDim(nw_id, 'xi_u', L);
did_eta_u = netcdf.defDim(nw_id, 'eta_u', Mp);
did_xi_v = netcdf.defDim(nw_id, 'xi_v', Lp);
did_eta_v = netcdf.defDim(nw_id, 'eta_v', M);
did_xi_rho = netcdf.defDim(nw_id, 'xi_rho', Lp);
did_eta_rho = netcdf.defDim(nw_id, 'eta_rho', Mp);
did_xi_psi = netcdf.defDim(nw_id, 'xi_psi', L);
did_eta_psi = netcdf.defDim(nw_id, 'eta_psi', M);
did_dust_time = netcdf.defDim(nw_id, 'dust_time', length(dustt));
%
%  Create variables and attributes
%
vid_dust_time = netcdf.defVar(nw_id, 'dust_time', 'NC_DOUBLE', did_dust_time);
% [conv] línea ncchar duplicada omitida
netcdf.putAtt(nw_id, netcdf.inqVarID(nw_id, 'dust_time'), 'long_name', 'dust time');
% [conv] línea ncchar duplicada omitida
netcdf.putAtt(nw_id, netcdf.inqVarID(nw_id, 'dust_time'), 'field', 'time, scalar, series');
oct_write_time_attributes(ncid,'dust_time',dustc,time_unit_att,time_second_unit_att,...
  calendar_att,insecond,add_cycle);

vid_dust = netcdf.defVar(nw_id, 'dust', 'NC_DOUBLE', [did_xi_rho, did_eta_rho, did_dust_time]);
% [conv] línea ncchar duplicada omitida
netcdf.putAtt(nw_id, netcdf.inqVarID(nw_id, 'dust'), 'long_name', 'Fe Dust Deposition');
% [conv] línea ncchar duplicada omitida
netcdf.putAtt(nw_id, netcdf.inqVarID(nw_id, 'dust'), 'units', 'nmol Fe m-3');
% [conv] línea ncchar duplicada omitida
netcdf.putAtt(nw_id, netcdf.inqVarID(nw_id, 'dust'), 'field', 'Fe Dust Deposition, scalar, series');

vid_dustfer = netcdf.defVar(nw_id, 'dustfer', 'NC_DOUBLE', [did_xi_rho, did_eta_rho, did_dust_time]);
% [conv] línea ncchar duplicada omitida
netcdf.putAtt(nw_id, netcdf.inqVarID(nw_id, 'dustfer'), 'long_name', 'Fe Dust Deposition');
% [conv] línea ncchar duplicada omitida
netcdf.putAtt(nw_id, netcdf.inqVarID(nw_id, 'dustfer'), 'units', 'Kg m-2 s-1');
% [conv] línea ncchar duplicada omitida
netcdf.putAtt(nw_id, netcdf.inqVarID(nw_id, 'dustfer'), 'field', 'dustfer, scalar, series');
%
vid_dustpo4 = netcdf.defVar(nw_id, 'dustpo4', 'NC_DOUBLE', [did_xi_rho, did_eta_rho, did_dust_time]);
% [conv] línea ncchar duplicada omitida
netcdf.putAtt(nw_id, netcdf.inqVarID(nw_id, 'dustpo4'), 'long_name', 'PO4 Dust Deposition');
% [conv] línea ncchar duplicada omitida
netcdf.putAtt(nw_id, netcdf.inqVarID(nw_id, 'dustpo4'), 'units', 'Kg m-2 s-1');
% [conv] línea ncchar duplicada omitida
netcdf.putAtt(nw_id, netcdf.inqVarID(nw_id, 'dustpo4'), 'field', 'dustpo4, scalar, series');
%
vid_dustsi = netcdf.defVar(nw_id, 'dustsi', 'NC_DOUBLE', [did_xi_rho, did_eta_rho, did_dust_time]);
% [conv] línea ncchar duplicada omitida
netcdf.putAtt(nw_id, netcdf.inqVarID(nw_id, 'dustsi'), 'long_name', 'Si Dust Deposition');
% [conv] línea ncchar duplicada omitida
netcdf.putAtt(nw_id, netcdf.inqVarID(nw_id, 'dustsi'), 'units', 'Kg m-2 s-1');
% [conv] línea ncchar duplicada omitida
netcdf.putAtt(nw_id, netcdf.inqVarID(nw_id, 'dustsi'), 'field', 'dustsi, scalar, series');
%
vid_solubility2 = netcdf.defVar(nw_id, 'solubility2', 'NC_DOUBLE', [did_xi_rho, did_eta_rho, did_dust_time]);
% [conv] línea ncchar duplicada omitida
netcdf.putAtt(nw_id, netcdf.inqVarID(nw_id, 'solubility2'), 'long_name', 'Fe solubility from Mahowald');
% [conv] línea ncchar duplicada omitida
netcdf.putAtt(nw_id, netcdf.inqVarID(nw_id, 'solubility2'), 'units', ');  %';
% [conv] línea ncchar duplicada omitida
netcdf.putAtt(nw_id, netcdf.inqVarID(nw_id, 'solubility2'), 'field', 'solubility2, scalar, series');

netcdf.endDef(nw_id);

%
% Create global attributes
%

% [conv] línea ncchar duplicada omitida
netcdf.putAtt(nw_id, netcdf.getConstant('NC_GLOBAL'), 'title', title);
% [conv] línea ncchar duplicada omitida
netcdf.putAtt(nw_id, netcdf.getConstant('NC_GLOBAL'), 'date', date);
% [conv] línea ncchar duplicada omitida
netcdf.putAtt(nw_id, netcdf.getConstant('NC_GLOBAL'), 'grd_file', grdname);
% [conv] línea ncchar duplicada omitida
netcdf.putAtt(nw_id, netcdf.getConstant('NC_GLOBAL'), 'parent_file', parentname);

%
% Write time variables
%

netcdf.putVar(nw_id, netcdf.inqVarID(nw_id, 'dust_time'), dustt);


netcdf.close(nw_id);
return
