function iebcdic = ic_to_iebcdic ( ic )

%*****************************************************************************80
%
%% IC_TO_IEBCDIC converts an ASCII character code to an EBCDIC code.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    29 March 2006
%
%  Author:
%
%    John Burkardt
%
%  Parameters:
%
%    Input, integer IC, the integer code for the ASCII character.
%
%    Output, intege IEBCDIC, the integer code for the EBCDIC character,
%    or -1 if no corresponding EBCDIC code is available.
%
  junk = [ ...
     0,  1,  2,  3, 56, 45, 46, 47, 22,  5, 37, 11, 12, 13, 60, 61, ...
    16, 17, 18, -1, -1, -1, 50, 38, 24, 25, 63, 39, 28, 29, 30, 31, ...
    64, 90,127,123, 91,108, 80,125, 77, 93, 92, 78,107, 96, -1, 97, ...
   240,241,242,243,244,245,246,247,248,249,122, 94, 76,126,110,111, ...
   124,193,194,195,196,197,198,199,200,201,209,210,211,212,213,214, ...
   215,216,217,226,227,228,229,230,231,232,233, -1, -1, -1, -1,109, ...
    -1,129,130,131,132,133,134,135,136,137,145,146,147,148,149,150, ...
   151,152,153,162,163,164,165,166,167,168,169, -1, 79, -1, -1,  7, ...
    -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, ...
    -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, ...
    -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, ...
    -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, ...
    -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, ...
    -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, ...
    -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, ...
    -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 ];

  if ( 0 <= ic .and. ic <= 255 )
    iebcdic = junk(ic+1);
  else
    iebcdic = -1;
  end

  return
end
