/* nag_code_to_error_name (x04ndc) Example Program.
 *
 * Copyright 2014 Numerical Algorithms Group.
 *
 * Mark 9, 2009.
 */

#include <stdio.h>
#include <nag.h>
#include <nag_stdlib.h>
#include <nag_string.h>
#include <nagx04.h>

int main(void)
{
  /* Scalars */
  Integer    exit_status = 0;
  unsigned   i;
  /* Pointers */
  const char *str_error = 0;

  int        fail_code[] = { NE_BAD_PARAM, NE_INCOMPAT_PARAM, NE_COMPLEX_ZERO,
                             NE_NOT_MONOTONIC, NE_TOO_MANY_ITER, NE_SINGULAR,
                             NE_INITIALIZATION };

  printf("nag_code_to_error_name (x04ndc) Example Program Results\n\n");

  /* Print header. */
  printf("   Code value          Error name\n");
  printf("   ----------          ----------\n");

  /* Convert the error code to strings and print. */

  /* nag_code_to_error_name (x04ndc).
   * Converts NAG error code to its string value
   */
  for (i = 0; i < sizeof(fail_code)/sizeof(int); i++)
    {
      str_error = nag_code_to_error_name(fail_code[i]);
      if (str_error)
        printf("%7d              %-s\n", fail_code[i], str_error);
      else
        {
          exit_status = 1;
          goto END;
        }
    }
 END:
  return exit_status;
}