2008-02-26 14:55:23 +01:00
|
|
|
/*
|
|
|
|
LA: linear algebra C++ interface library
|
|
|
|
Copyright (C) 2008 Jiri Pittner <jiri.pittner@jh-inst.cas.cz> or <jiri@pittnerovi.com>
|
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2005-02-14 01:10:07 +01:00
|
|
|
// LA and general error handler
|
2005-02-04 15:31:42 +01:00
|
|
|
#include <iostream>
|
|
|
|
#include "laerror.h"
|
2005-02-14 01:10:07 +01:00
|
|
|
#include <stdio.h>
|
2008-11-26 14:30:30 +01:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2005-02-14 01:10:07 +01:00
|
|
|
#include <errno.h>
|
2006-08-16 23:43:45 +02:00
|
|
|
#include <stdarg.h>
|
|
|
|
|
2006-04-09 23:07:54 +02:00
|
|
|
|
|
|
|
#ifdef USE_TRACEBACK
|
|
|
|
#include "traceback.h"
|
|
|
|
#endif
|
|
|
|
|
2009-10-08 16:01:15 +02:00
|
|
|
bool _LA_count_check=true;
|
|
|
|
|
|
|
|
extern "C" void _findme(void) {}; //for autoconf test we need a function with C linkage
|
2008-12-17 16:34:25 +01:00
|
|
|
|
2005-02-04 15:31:42 +01:00
|
|
|
void laerror(const char *s1)
|
|
|
|
{
|
|
|
|
std::cerr << "LA:ERROR - ";
|
2005-02-14 01:10:07 +01:00
|
|
|
std::cout << "LA:ERROR - ";
|
|
|
|
if(s1)
|
|
|
|
{
|
|
|
|
std::cerr << s1 << "\n";
|
|
|
|
std::cout << s1 << "\n";
|
2005-02-04 15:31:42 +01:00
|
|
|
}
|
2005-02-14 01:10:07 +01:00
|
|
|
if(errno) perror("system error");
|
2006-04-09 23:07:54 +02:00
|
|
|
|
2008-12-17 16:34:25 +01:00
|
|
|
throw LAerror(s1);
|
2005-02-04 15:31:42 +01:00
|
|
|
}
|
|
|
|
|
2005-02-14 01:10:07 +01:00
|
|
|
//stub for f77 blas called from strassen routine
|
|
|
|
extern "C" void xerbla_(const char name[6], int *n)
|
|
|
|
{
|
2006-08-16 23:43:45 +02:00
|
|
|
char msg[1024];
|
2005-02-14 01:10:07 +01:00
|
|
|
strcpy(msg,"LAPACK or BLAS error in routine ");
|
|
|
|
strncat(msg,name,6);
|
|
|
|
sprintf(msg+strlen(msg),": illegal value of parameter #%d",*n);
|
|
|
|
laerror(msg);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-08-16 23:43:45 +02:00
|
|
|
//with atlas-cblas another error routine is necessary
|
|
|
|
|
|
|
|
extern "C" void ATL_xerbla(int p, char *rout, char *form, ...)
|
|
|
|
{
|
|
|
|
char msg0[1024], *msg;
|
|
|
|
va_list argptr;
|
|
|
|
va_start(argptr, form);
|
|
|
|
strcpy(msg0,"ATLAS error\n");
|
|
|
|
msg=msg0+strlen(msg0);
|
|
|
|
if (p) {sprintf(msg, "Parameter %d to routine %s was incorrect\n", p, rout); msg+=strlen(msg);}
|
|
|
|
vsprintf(msg, form, argptr);
|
|
|
|
va_end(argptr);
|
|
|
|
laerror(msg0);
|
|
|
|
}
|
|
|
|
|
|
|
|
int cblas_errprn(int ierr, int info, char *form, ...)
|
|
|
|
{
|
|
|
|
char msg0[1024], *msg;
|
|
|
|
va_list argptr;
|
|
|
|
va_start(argptr, form);
|
|
|
|
sprintf(msg0,"CBLAS error %d %d\n",ierr,info);
|
|
|
|
msg=msg0+strlen(msg0);
|
|
|
|
vsprintf(msg, form, argptr);
|
|
|
|
va_end(argptr);
|
|
|
|
laerror(msg0);
|
|
|
|
return 0;
|
|
|
|
}
|