Code owners
Assign users and groups as approvers for specific file changes. Learn more.
nrcheck.c 22.59 KiB
/* nrcheck.c **************************************************************
NR Library Package - Wrapper functions for thorough checking
James Trevelyan, University of Western Australia
Revision 2 January 1996
To use this to add safty checks to your program, add the
module NRCHECK.C to your project, and #define NR_CHECK before
including "nrlin.h" in your source file.
**************************************************************************/
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include "nrlin.h"
/* #define TEST */ /* use to activate test program at end of source */
#define valid_dvector(v,nl,nh) ((v!=(double *)NULL) && \
((v[(nl)-1]==-322.0)&&(v[(nh)+1]==-722.0)))
#define valid_vector(v,nl,nh) ((v!=(float *)NULL) && \
((v[(nl)-1]==-322.0)&&(v[(nh)+1]==-722.0)))
#define valid_dvector_b(v) ( (v!=(double *)NULL) && (*(v)==-322.0) )
#define valid_vector_b(v) ( (v!=(float *)NULL) && (*(v)==-322.0) )
#define valid_matrix(m,nrl,nrh,ncl,nch) ((m!=(float **)NULL) && \
((m[(nrl)-2]==(float*)0x555) \
&&(m[(nrl)][(ncl)-1]==-422.00)&&(m[nrh][nch+1]==-822.0)))
#define valid_dmatrix(m,nrl,nrh,ncl,nch) ((m!=(double **)NULL) && \
((m[(nrl)-2]==(double*)0x555) \
&&(m[(nrl)][(ncl)-1]==-422.00)&&(m[nrh][nch+1]==-822.0)))
#define valid_matrix_b(m) ( (m != (float **)NULL ) && ((*(m-1)==(float*)0x555)&&(*m[1]==-422.00)))
#define valid_dmatrix_b(m) ((m != (double **)NULL ) && ((*(m-1)==(double*)0x555)&&(*m[1]==-422.00)))
#define valid_d4vector( y ) valid_dvector( y, 1, 4 )
#define valid_d4vector_b( y ) valid_dvector_b( y )
#define valid_dframe( y ) valid_dmatrix( y, 1, 4, 1, 4 )
#define NoText (char *)NULL
#define NoFile (FILE *)NULL
/* Global storage */
static linenum = 0;
static char *filetext = NoText;
static char *funcname = NoText;
static error_connect = 0;
static char ms[50];
/* function declaration */
void nrerror_handler( void(*handler)(char error_text[]) ); /* nrlin.c */
/* Error handler derived from Numerical Recipes standard error handler */
void nrerror_DNR(char error_text[])
{
fprintf(stderr,"Numerical Recipes run-time error...\n");
fprintf(stderr,"%s\n",error_text);
if ( linenum != 0 ){
fprintf(stderr,"Call to %s at line %d in %s\n",
funcname, linenum, filetext);
} else {
fprintf(stderr,"Call location unknown\n");
}
fprintf(stderr,"Press <ENTER> to return to system...");
getchar();
exit(1);