
/** @file  psAbort.c
 *
 *  @brief Contains the definition for abort function
 *
 *  The abort logging and handling shall be performed by psAbort function.
 *  This will allow for consistent handling of other software units
 *  needing to abort from program execution.
 *
 *  @author Eric Van Alst, MHPCC
 *   
 *  @version $Revision: 1.14 $ $Name: not supported by cvs2svn $
 *  @date $Date: 2007-01-09 22:38:53 $
 *
 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
 */

#ifdef HAVE_CONFIG_H
# include "config.h"
#endif

#include <stdarg.h>
#include <stdlib.h>
#include "psAbort.h"
#include "psError.h"
#include "psLogMsg.h"

void psAbort(const char *name, const char *format, ...)
{
    psErrorStackPrint(stderr, "Aborting. Error stack:");

    va_list argPtr;             // variable list arguement pointer
    // Get the variable list parameters to pass to logging function
    va_start(argPtr, format);

    // Call logging function with PS_LOG_ABORT level
    psLogMsgV(name, PS_LOG_ABORT, format, argPtr);

    // Clean up stack after variable arguement has been used
    va_end(argPtr);

    // Call system abort function to terminate program execution
    abort();
}
