You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: nanland.m
    path of file: ./repos/tracacode/1911-COAWST/script/mfiles/rutgers/utility
    
    the code of the file until where you have to start completion: function Fout = nanland(Finp, Ginp)

%
% NANLAND:  Mask land points to NaNs to facilitate plotting
%
% Fout = nanland(Finp, Ginp)
%
% This function mask the land point to NaNs for any ROMS array
% variable to facilitate ploting.
%
% On Input:
%
%    Finp          ROMS variable (2D or 3D array)
%
%    Ginp          ROMS Grid/History file/URL name containing all
%                    Land/Sea masking variable (string)
%
%              or, ROMS Grid structure containing all the grid
%                    variables (struct array)

    
function Fout = nanland(Finp, Ginp)

%
% NANLAND:  Mask land points to NaNs to facilitate plotting
%
% Fout = nanland(Finp, Ginp)
%
% This function mask the land point to NaNs for any ROMS array
% variable to facilitate ploting.
%
% On Input:
%
%    Finp          ROMS variable (2D or 3D array)
%
%    Ginp          ROMS Grid/History file/URL name containing all
%                    Land/Sea masking variable (string)
%
%              or, ROMS Grid structure containing all the grid
%                    variables (struct array)
%
%              or, ROMS Land/Sea masking at the appropriate C-grid
%                    location of Finp (2D array)
%
% On Output:
%
%    Fout          ROMS variable with NaN values on land points
%                    (2D or 3D array)
%
% This function can be used during plotting to mask land points.
% For example:
%
%    pcolor(rlon, rlat, nanland(salt(:,:,20),'my_grid.nc'))
% or
%    pcolor(G.lon_rho, G.lat_rho, nanland(salt(:,:,20),G))
% or
%    pcolor(G.lon_rho, G.lat_rho, nanland(salt(:,:,20),G.mask_rho))
%

% svn $Id: nanland.m 938 2019-01-28 06:35:10Z arango $
%=========================================================================%
%  Copyright (c) 2002-2019 The ROMS/TOMS Group                            %
%    Licensed under a MIT/X style license                                 %
%    See License_ROMS.txt                           Hernan G. Arango      %
%=========================================================================%

%  Remove singleton dimension, if any.
  
Fout=squeeze(Finp);

Fsize=size(Fout);
ndims=length(Fsize);

switch ndims
  case 2
    Im=Fsize(1);
    Jm=Fsize(2);
    is3d=false;
  case 3
    Im=Fsize(1);
    Jm=Fsize(2);
    Km=Fsize(3);
    is3d=true;
end