/* nag_implementation_separated_details (a00adc) Example Program.
 *
 * NAGPRODCODE Version.
 *
 * Copyright 2016 Numerical Algorithms Group.
 *
 * Mark 26, 2016.
 */

#include <nag.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
#include <nag_stdlib.h>
#include <naga00.h>

int main(void)
{
  int exit_status = 0;
  int max_char_len = 180;
  char *impl = 0, *prec = 0, *pcode = 0, *mkmaj = 0, *mkmin = 0,
         *hdware = 0, *opsys = 0, *ccomp = 0, *fcomp = 0, *vend = 0;
  Nag_Boolean licval;
  time_t t;

  printf("nag_implementation_separated_details (a00adc)"
         " Example Program Results\n\n");

  if (!(impl = NAG_ALLOC(max_char_len, char)) ||
      !(prec = NAG_ALLOC(max_char_len, char)) ||
      !(pcode = NAG_ALLOC(max_char_len, char)) ||
      !(mkmaj = NAG_ALLOC(max_char_len, char)) ||
      !(mkmin = NAG_ALLOC(max_char_len, char)) ||
      !(hdware = NAG_ALLOC(max_char_len, char)) ||
      !(opsys = NAG_ALLOC(max_char_len, char)) ||
      !(ccomp = NAG_ALLOC(max_char_len, char)) ||
      !(fcomp = NAG_ALLOC(max_char_len, char)) ||
      !(vend = NAG_ALLOC(max_char_len, char)))
  {
    printf("Allocation failure\n");
    exit_status = -1;
    goto END;
  }

  nag_implementation_separated_details(impl, prec, pcode, mkmaj, mkmin,
                                       hdware, opsys, ccomp, fcomp, vend,
                                       &licval);

  /* Print implementation details. */
  printf("*** Start of NAG C library implementation details ***\n\n");
  printf(" Implementation title: %s\n", impl);
  printf("            Precision: %s\n", prec);
  printf("         Product Code: %s\n", pcode);
  printf("                 Mark: %s.%s\n", mkmaj, mkmin);
  if (!strcmp(vend, "(self-contained)")) {
    printf("       Vendor library: None\n");
  }
  else {
    printf("       Vendor library: %s\n", vend);
  }
  printf(" Applicable to:\n");
  printf("             hardware: %s\n", hdware);
  printf("     operating system: %s\n", opsys);
  printf("           C compiler: %s\n", ccomp);
  printf("     Fortran compiler: %s\n", fcomp);
  printf(" and compatible systems.\n");
  if (!licval) {
    printf("        Licence query: %s\n\n", "Unsuccessful");
  }
  else {
    printf("        Licence query: %s\n\n", "Successful");
  }
  printf(" *** End of NAG C Library implementation details ***\n");

  printf("\n This program was run on the following date:\n");
  t = time(NULL);
  printf("   %s", ctime(&t));

END:

  NAG_FREE(impl);
  NAG_FREE(prec);
  NAG_FREE(pcode);
  NAG_FREE(mkmaj);
  NAG_FREE(mkmin);
  NAG_FREE(hdware);
  NAG_FREE(opsys);
  NAG_FREE(ccomp);
  NAG_FREE(fcomp);
  NAG_FREE(vend);

  return exit_status;
}