function [u_out, v_out, rho_out, P_out, ui_out, vi_out, rhoi_out, Pi_out, Yi]...
    = BGC_DO_restart(app_in, u_in, v_in, rho_in, P_in, ui_in, ...
    vi_in, rhoi_in, Pi_in, idsu_in, idsv_in, ...
    idsP_in, Nodeu_in, Nodev_in, NodeP_in)

%-------------------------------------------------------------------------------
% Load small domain data.
%-------------------------------------------------------------------------------

% Load small domain geometry.

load (fullfile(app_in.DOicDir,'setup'));

% Load ICs.

load (fullfile(app_in.DOicDir,num2str(app_in.DOnumIC,'%3.3d')));

%-------------------------------------------------------------------------------
% Map small domain data to large domain.
%-------------------------------------------------------------------------------

if ( (app_in.Nx==app.Nx) && (app_in.Ny==app.Ny) )
    u_out    = u;
    v_out    = v;
    rho_out  = rho;
    P_out    = P;
    ui_out   = ui;
    vi_out   = vi;
    rhoi_out = rhoi;
    Pi_out   = Pi;
    return;
end;

%-----------------------------
%--- Reshape large domain. ---
%-----------------------------

P_in_2D = P_in;
P_in_2D(1:Nbcs) = NaN;
P_in_2D = P_in_2D(NodeP_in(2:app_in.Ny+1, 2:app_in.Nx+1));

%-----------------------------
%--- Reshape small domain. ---
%-----------------------------

P_2D = P;
P_2D(1:Nbcs) = NaN;
P_2D = P_2D(NodeP(2:app.Ny+1, 2:app.Nx+1));

%----------------------------------------------
%--- Put small domain data in large domain. ---
%----------------------------------------------

[Ny, Nx] = size(P_2D);

P_in_2D(1:Ny,1:Nx) = P_2D;

[Ny, Nx]=size(P_2D);
[Ny_in, Nx_in]=size(P_in_2D);

P_in_2D(Ny_in,:) = nanmin(P_2D(:,Nx));
P_in_2D(:,Nx_in) = nanmin(P_2D(:,Nx));
mask = ones(size(P_in_2D));
mask(find(isnan(P_in_2D))) = 0;
mask(1:(Ny_in-1),(Nx+1):(Nx_in-1)) = 0;

P_in_2D = smooth_under_iw(P_in_2D,mask);

P_out                           = P_in;
P_out(Nbcs+(1:length(idsP_in))) = P_in_2D(idsP_in);

for n = 1:app.S(1)
    Pi_out(:,n) = merge_small_large(Pi_in(:,n),Pi(:,n),Nbcs,...
        NodeP_in(2:app_in.Ny+1, 2:app_in.Nx+1), ...
        NodeP(2:app.Ny+1, 2:app.Nx+1),idsP_in);
end;

%-----------------------------
%--- Density. ---
%-----------------------------

rho_out = merge_small_large(rho_in,rho,Nbcs,...
    NodeP_in(2:app_in.Ny+1, 2:app_in.Nx+1), ...
    NodeP(2:app.Ny+1, 2:app.Nx+1),idsP_in);

for n = 1:app.S(1)
    rhoi_out(:,n) = merge_small_large(rhoi_in(:,n),rhoi(:,n),Nbcs,...
        NodeP_in(2:app_in.Ny+1, 2:app_in.Nx+1), ...
        NodeP(2:app.Ny+1, 2:app.Nx+1),idsP_in);
end;

%-----------------------------
%--- zonal velocity. ---
%-----------------------------

u_out = merge_small_large(u_in,u,Nbcs,Nodeu_in(2:app_in.Ny+1, 2:app_in.Nx), ...
    Nodeu(2:app.Ny+1, 2:app.Nx),idsu_in);

for n = 1:app.S(1)
    ui_out(:,n) = merge_small_large(ui_in(:,n),ui(:,n),Nbcs,...
        Nodeu_in(2:app_in.Ny+1, 2:app_in.Nx), ...
        Nodeu(2:app.Ny+1, 2:app.Nx),idsu_in);
end;

%-----------------------------
%--- meridional velocity. ---
%-----------------------------

v_out = merge_small_large (v_in,v,Nbcs,Nodev_in(2:app_in.Ny, 2:app_in.Nx+1), ...
    Nodev(2:app.Ny, 2:app.Nx+1),idsv_in);

for n = 1:app.S(1)
    vi_out(:,n) = merge_small_large(vi_in(:,n),vi(:,n),Nbcs,...
        Nodev_in(2:app_in.Ny, 2:app_in.Nx+1), ...
        Nodev(2:app.Ny, 2:app.Nx+1),idsv_in);
end;

