
/** @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.13 $ $Name: not supported by cvs2svn $
 *  @date $Date: 2006-11-29 17:57:20 $
 *
 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
 */

#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();
}
