function gp = GP(c,i,N)

%
% gp = GP(c,i,N)
%
% This function returns the grid point number corresponding to 
% the column index c and the row index i, given the number of 
% perimeter nodes in the closure element.
%
% c - column index
% i - row index
% N - number of perimeter nodes
%
% Mark Trew - June 2001
%

% Calculate grid point number
  gp = rem(1,c) + ...        % account for apex grid point
       (c-1)*(c-2)*N/2 + ... % account for column in layer
       i + ...               % account for row in column
       (c-1)*N*(max(1-i,0)+min((c-1)*N-i,0)); 
              % account for wrapping of grid points in xi2 direction

return;