function  oct_create_nestedndepo(ndeponame,parentname,grdname,title,ndepot,ndepoc)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% 	Create an empty oct_netcdf ndepo forcing file (for PISCES)
%       ndeponame: name of the ndepo 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
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
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.open(ndeponame, 'NC_WRITE');
%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_ndepo_time = netcdf.defDim(nw_id, 'ndepo_time', length(ndepot));
%
%  Create variables and attributes
%
vid_ndepo_time = netcdf.defVar(nw_id, 'ndepo_time', 'NC_DOUBLE', did_ndepo_time);
% [conv] línea ncchar duplicada omitida
netcdf.putAtt(nw_id, netcdf.inqVarID(nw_id, 'ndepo_time'), 'long_name', 'ndepo time');
% [conv] línea ncchar duplicada omitida
netcdf.putAtt(nw_id, netcdf.inqVarID(nw_id, 'ndepo_time'), 'units', 'days');
netcdf.putAtt(nw_id, netcdf.inqVarID(nw_id, 'ndepo_time'), 'cycle_length', ndepoc);
% [conv] línea ncchar duplicada omitida
netcdf.putAtt(nw_id, netcdf.inqVarID(nw_id, 'ndepo_time'), 'field', 'time, scalar, series');

%
vid_ndepo = netcdf.defVar(nw_id, 'ndepo', 'NC_DOUBLE', [did_xi_rho, did_eta_rho, did_ndepo_time]);
% [conv] línea ncchar duplicada omitida
netcdf.putAtt(nw_id, netcdf.inqVarID(nw_id, 'ndepo'), 'long_name', 'Nitrogen Deposition');
% [conv] línea ncchar duplicada omitida
netcdf.putAtt(nw_id, netcdf.inqVarID(nw_id, 'ndepo'), 'units', 'KgN m-2 s-1');
% [conv] línea ncchar duplicada omitida
netcdf.putAtt(nw_id, netcdf.inqVarID(nw_id, 'ndepo'), 'field', 'ndepo, scalar, series');
%
vid_noyndepo = netcdf.defVar(nw_id, 'noyndepo', 'NC_DOUBLE', [did_xi_rho, did_eta_rho, did_ndepo_time]);
% [conv] línea ncchar duplicada omitida
netcdf.putAtt(nw_id, netcdf.inqVarID(nw_id, 'noyndepo'), 'long_name', 'NOy Deposition');
% [conv] línea ncchar duplicada omitida
netcdf.putAtt(nw_id, netcdf.inqVarID(nw_id, 'noyndepo'), 'units', 'KgN m-2 s-1');
% [conv] línea ncchar duplicada omitida
netcdf.putAtt(nw_id, netcdf.inqVarID(nw_id, 'noyndepo'), 'field', 'noyndepo, scalar, series');
%
vid_nhxndepo = netcdf.defVar(nw_id, 'nhxndepo', 'NC_DOUBLE', [did_xi_rho, did_eta_rho, did_ndepo_time]);
% [conv] línea ncchar duplicada omitida
netcdf.putAtt(nw_id, netcdf.inqVarID(nw_id, 'nhxndepo'), 'long_name', 'NHx Deposition');
% [conv] línea ncchar duplicada omitida
netcdf.putAtt(nw_id, netcdf.inqVarID(nw_id, 'nhxndepo'), 'units', 'KgN m-2 s-1');
% [conv] línea ncchar duplicada omitida
netcdf.putAtt(nw_id, netcdf.inqVarID(nw_id, 'nhxndepo'), 'field', 'nhxndepo, scalar, series');
%
%endef(nw);

%
% 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, 'ndepo_time'), ndepot);


netcdf.close(nw_id);
return
