ASCOT5
Loading...
Searching...
No Matches
Functions
error.c File Reference

Error module for ASCOT5. More...

#include <stdlib.h>
#include <math.h>
#include "error.h"

Go to the source code of this file.

Functions

void error_parse (a5err err, int *msg, int *line, int *file)
 Retrieve stored data from the error flag.
 
void error_parse2str (a5err err, char *msg, char *line, char *file)
 Convert error flag in string format.
 

Detailed Description

Error module for ASCOT5.

This modules handles marker simulation time errors, i.e., errors that arise when a marker is being simulated and which do not lead to termination of the whole program, just to the termination of that marker.

Error flag is stored in particle_state struct and care should be taken that no error flag overwriting occurs by ceasing the simulation of that marker. Error flag is represented by a5err which is a 64 bit integer. Zero means no error. When error occurs, an error is raised with error_raise() which uses a5err to store the following data as follows:

Whenever adding a new error type, include that type to error_type enum. These types should be generic as line and file are enough to locate what exactly went wrong. Then add description of that error type to error_parse2str().

Whenever adding a new file where error can arise, add that file to error_file enum and write the file name to error_parse2str().

Definition in file error.c.

Function Documentation

◆ error_parse()

void error_parse ( a5err err,
int * msg,
int * line,
int * file )

Retrieve stored data from the error flag.

The values of type and file corresponds to the ones that were in error_type and error_file enums that were used when error was thrown with error_raise().

This function is host only.

Parameters
errthe error flag
msgpointer for storing type of the error
linepointer for storing the line where error originated from
filepointer for storing the file where error originated from

Definition at line 44 of file error.c.

◆ error_parse2str()

void error_parse2str ( a5err err,
char * msg,
char * line,
char * file )

Convert error flag in string format.

This function is host only.

Parameters
errthe error flag
msgpointer for error message
linepointer for storing the line where error originated from
filepointer for storing the file where error originated from

Definition at line 62 of file error.c.