Changeset 515


Ignore:
Timestamp:
May 16, 2014 4:25:23 AM (8 years ago)
Author:
kulshres
Message:

Throw a std::exception instead of calling exit()

based on branch 'adolcerror' of https://github.com/b45ch1/adol-c

Suggested-by: Sebastian Walter <sebastian.walter@…>
Signed-off-by: Kshitij Kulshreshtha <kshitij@…>

Location:
trunk/ADOL-C
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/ADOL-C/include/adolc/adouble.h

    r498 r515  
    3030#include <iostream>
    3131#include <cmath>
     32#include <stdexcept>
     33
    3234using std::cout;
    3335using std::cin;
     
    3537using std::ostream;
    3638using std::istream;
     39using std::logic_error;
    3740
    3841#include <adolc/common.h>
     
    253256        fprintf(DIAG_OUT,"ADOL-C error: illegal default construction of adub"
    254257                " variable\n");
    255         exit(-2);
     258        throw logic_error("illegal constructor call, errorcode=-2");
    256259    };
    257260    explicit adub( double ):badouble(0) {
    258261        fprintf(DIAG_OUT,"ADOL-C error: illegal  construction of adub variable"
    259262                " from double\n");
    260         exit(-2);
     263        throw logic_error("illegal constructor call, errorcode=-2");
    261264    };
    262265
  • trunk/ADOL-C/include/adolc/adtl.h

    r510 r515  
    2121#include <adolc/common.h>
    2222#include <list>
     23#include <stdexcept>
    2324
    2425using std::ostream;
    2526using std::istream;
    2627using std::list;
     28using std::logic_error;
    2729
    2830namespace adtl {
     
    479481    if (unlikely(!adouble::_do_val() && adouble::_do_adval())) {
    480482        fprintf(DIAG_OUT, "ADOL-C error: Tapeless: Incorrect mode, call setMode(enum Mode mode)\n");
    481         exit(1);
     483        throw logic_error("incorrect function call, errorcode=1");
    482484    }
    483485    if (do_val())
     
    522524    if (unlikely(!adouble::_do_val() && adouble::_do_adval())) {
    523525        fprintf(DIAG_OUT, "ADOL-C error: Tapeless: Incorrect mode, call setMode(enum Mode mode)\n");
    524         exit(1);
     526        throw logic_error("incorrect function call, errorcode=1");
    525527    }
    526528    if (do_val())
     
    540542    if (unlikely(!adouble::_do_val() && adouble::_do_adval())) {
    541543        fprintf(DIAG_OUT, "ADOL-C error: Tapeless: Incorrect mode, call setMode(enum Mode mode)\n");
    542         exit(1);
     544        throw logic_error("incorrect function call, errorcode=1");
    543545    }
    544546    if (do_val())
     
    595597    if (unlikely(!adouble::_do_val() && adouble::_do_adval())) {
    596598        fprintf(DIAG_OUT, "ADOL-C error: Tapeless: Incorrect mode, call setMode(enum Mode mode)\n");
    597         exit(1);
     599        throw logic_error("incorrect function call, errorcode=1");
    598600    }
    599601    if (do_val())
     
    614616    if (unlikely(!adouble::_do_val() && adouble::_do_adval())) {
    615617        fprintf(DIAG_OUT, "ADOL-C error: Tapeless: Incorrect mode, call setMode(enum Mode mode)\n");
    616         exit(1);
     618        throw logic_error("incorrect function call, errorcode=1");
    617619    }
    618620    if (do_val())
     
    630632    if (unlikely(!adouble::_do_val() && adouble::_do_adval())) {
    631633        fprintf(DIAG_OUT, "ADOL-C error: Tapeless: Incorrect mode, call setMode(enum Mode mode)\n");
    632         exit(1);
     634        throw logic_error("incorrect function call, errorcode=1");
    633635    }
    634636    if (do_val())
     
    651653    if (unlikely(!adouble::_do_val() && adouble::_do_adval())) {
    652654        fprintf(DIAG_OUT, "ADOL-C error: Tapeless: Incorrect mode, call setMode(enum Mode mode)\n");
    653         exit(1);
     655        throw logic_error("incorrect function call, errorcode=1");
    654656    }
    655657    if (do_val())
     
    673675    if (unlikely(!adouble::_do_val() && adouble::_do_adval())) {
    674676        fprintf(DIAG_OUT, "ADOL-C error: Tapeless: Incorrect mode, call setMode(enum Mode mode)\n");
    675         exit(1);
     677        throw logic_error("incorrect function call, errorcode=1");
    676678    }
    677679    if (do_val())
     
    692694    if (unlikely(!adouble::_do_val() && adouble::_do_adval())) {
    693695        fprintf(DIAG_OUT, "ADOL-C error: Tapeless: Incorrect mode, call setMode(enum Mode mode)\n");
    694         exit(1);
     696        throw logic_error("incorrect function call, errorcode=1");
    695697    }
    696698    if (do_val())
     
    710712    if (unlikely(!adouble::_do_val() && adouble::_do_adval())) {
    711713        fprintf(DIAG_OUT, "ADOL-C error: Tapeless: Incorrect mode, call setMode(enum Mode mode)\n");
    712         exit(1);
     714        throw logic_error("incorrect function call, errorcode=1");
    713715    }
    714716    if (do_val())
     
    728730    if (unlikely(!adouble::_do_val() && adouble::_do_adval())) {
    729731        fprintf(DIAG_OUT, "ADOL-C error: Tapeless: Incorrect mode, call setMode(enum Mode mode)\n");
    730         exit(1);
     732        throw logic_error("incorrect function call, errorcode=1");
    731733    }
    732734    if (do_val())
     
    746748    if (unlikely(!adouble::_do_val() && adouble::_do_adval())) {
    747749        fprintf(DIAG_OUT, "ADOL-C error: Tapeless: Incorrect mode, call setMode(enum Mode mode)\n");
    748         exit(1);
     750        throw logic_error("incorrect function call, errorcode=1");
    749751    }
    750752    if (do_val())
     
    769771    if (unlikely(!adouble::_do_val() && adouble::_do_adval())) {
    770772        fprintf(DIAG_OUT, "ADOL-C error: Tapeless: Incorrect mode, call setMode(enum Mode mode)\n");
    771         exit(1);
     773        throw logic_error("incorrect function call, errorcode=1");
    772774    }
    773775    if (do_val())
     
    795797    if (unlikely(!adouble::_do_val() && adouble::_do_adval())) {
    796798        fprintf(DIAG_OUT, "ADOL-C error: Tapeless: Incorrect mode, call setMode(enum Mode mode)\n");
    797         exit(1);
     799        throw logic_error("incorrect function call, errorcode=1");
    798800    }
    799801    if (do_val())
     
    813815    if (unlikely(!adouble::_do_val() && adouble::_do_adval())) {
    814816        fprintf(DIAG_OUT, "ADOL-C error: Tapeless: Incorrect mode, call setMode(enum Mode mode)\n");
    815         exit(1);
     817        throw logic_error("incorrect function call, errorcode=1");
    816818    }
    817819    if (do_val())
     
    834836    if (unlikely(!adouble::_do_val() && adouble::_do_adval())) {
    835837        fprintf(DIAG_OUT, "ADOL-C error: Tapeless: Incorrect mode, call setMode(enum Mode mode)\n");
    836         exit(1);
     838        throw logic_error("incorrect function call, errorcode=1");
    837839    }
    838840    if (do_val())
     
    852854    if (unlikely(!adouble::_do_val() && adouble::_do_adval())) {
    853855        fprintf(DIAG_OUT, "ADOL-C error: Tapeless: Incorrect mode, call setMode(enum Mode mode)\n");
    854         exit(1);
     856        throw logic_error("incorrect function call, errorcode=1");
    855857    }
    856858    if (do_val())
     
    870872    if (unlikely(!adouble::_do_val() && adouble::_do_adval())) {
    871873        fprintf(DIAG_OUT, "ADOL-C error: Tapeless: Incorrect mode, call setMode(enum Mode mode)\n");
    872         exit(1);
     874        throw logic_error("incorrect function call, errorcode=1");
    873875    }
    874876    if (do_val())
     
    888890    if (unlikely(!adouble::_do_val() && adouble::_do_adval())) {
    889891        fprintf(DIAG_OUT, "ADOL-C error: Tapeless: Incorrect mode, call setMode(enum Mode mode)\n");
    890         exit(1);
     892        throw logic_error("incorrect function call, errorcode=1");
    891893    }
    892894    if (do_val())
     
    906908    if (unlikely(!adouble::_do_val() && adouble::_do_adval())) {
    907909        fprintf(DIAG_OUT, "ADOL-C error: Tapeless: Incorrect mode, call setMode(enum Mode mode)\n");
    908         exit(1);
     910        throw logic_error("incorrect function call, errorcode=1");
    909911    }
    910912    if (do_val())
     
    926928    if (unlikely(!adouble::_do_val() && adouble::_do_adval())) {
    927929        fprintf(DIAG_OUT, "ADOL-C error: Tapeless: Incorrect mode, call setMode(enum Mode mode)\n");
    928         exit(1);
     930        throw logic_error("incorrect function call, errorcode=1");
    929931    }
    930932    if (do_val())
     
    944946    if (unlikely(!adouble::_do_val() && adouble::_do_adval())) {
    945947        fprintf(DIAG_OUT, "ADOL-C error: Tapeless: Incorrect mode, call setMode(enum Mode mode)\n");
    946         exit(1);
     948        throw logic_error("incorrect function call, errorcode=1");
    947949    }
    948950    if (do_val())
     
    962964    if (unlikely(!adouble::_do_val() && adouble::_do_adval())) {
    963965        fprintf(DIAG_OUT, "ADOL-C error: Tapeless: Incorrect mode, call setMode(enum Mode mode)\n");
    964         exit(1);
     966        throw logic_error("incorrect function call, errorcode=1");
    965967    }
    966968    if (do_val())
     
    981983    if (unlikely(!adouble::_do_val() && adouble::_do_adval())) {
    982984        fprintf(DIAG_OUT, "ADOL-C error: Tapeless: Incorrect mode, call setMode(enum Mode mode)\n");
    983         exit(1);
     985        throw logic_error("incorrect function call, errorcode=1");
    984986    }
    985987    if (do_val())
     
    10291031    if (unlikely(!adouble::_do_val() && (adouble::_do_adval() || adouble::_do_indo()))) {
    10301032        fprintf(DIAG_OUT, "ADOL-C error: Tapeless: Incorrect mode, call setMode(enum Mode mode)\n");
    1031         exit(1);
     1033        throw logic_error("incorrect function call, errorcode=1");
    10321034    }   
    10331035    double tmp2=a.val-b.val;
     
    10691071    if (unlikely(!adouble::_do_val() && (adouble::_do_adval() || adouble::_do_indo()))) {
    10701072        fprintf(DIAG_OUT, "ADOL-C error: Tapeless: Incorrect mode, call setMode(enum Mode mode)\n");
    1071         exit(1);
     1073        throw logic_error("incorrect function call, errorcode=1");
    10721074    }   
    10731075    double tmp2=v-a.val;
     
    11051107    if (unlikely(!adouble::_do_val() && (adouble::_do_adval() || adouble::_do_indo()))) {
    11061108        fprintf(DIAG_OUT, "ADOL-C error: Tapeless: Incorrect mode, call setMode(enum Mode mode)\n");
    1107         exit(1);
     1109        throw logic_error("incorrect function call, errorcode=1");
    11081110    }   
    11091111    double tmp2=a.val-v;
     
    11411143    if (unlikely(!adouble::_do_val() && (adouble::_do_adval() || adouble::_do_indo()))) {
    11421144        fprintf(DIAG_OUT, "ADOL-C error: Tapeless: Incorrect mode, call setMode(enum Mode mode)\n");
    1143         exit(1);
     1145        throw logic_error("incorrect function call, errorcode=1");
    11441146    }   
    11451147    double tmp2=a.val-b.val;
     
    11821184    if (unlikely(!adouble::_do_val() && (adouble::_do_adval() || adouble::_do_indo()))) {
    11831185        fprintf(DIAG_OUT, "ADOL-C error: Tapeless: Incorrect mode, call setMode(enum Mode mode)\n");
    1184         exit(1);
     1186        throw logic_error("incorrect function call, errorcode=1");
    11851187    }   
    11861188    double tmp2=v-a.val;
     
    12181220    if (unlikely(!adouble::_do_val() && (adouble::_do_adval() || adouble::_do_indo()))) {
    12191221        fprintf(DIAG_OUT, "ADOL-C error: Tapeless: Incorrect mode, call setMode(enum Mode mode)\n");
    1220         exit(1);
     1222        throw logic_error("incorrect function call, errorcode=1");
    12211223    }   
    12221224    double tmp2=a.val-v;
     
    12731275    if (no_do_val()) {
    12741276        fprintf(DIAG_OUT, "ADOL-C error: Tapeless: Incorrect mode, call setMode(enum Mode mode)\n");
    1275         exit(1);
     1277        throw logic_error("incorrect function call, errorcode=1");
    12761278    }   
    12771279    return ADOLC_MATH_NSP::frexp(a.val, v);
     
    12831285    if (unlikely(!adouble::_do_val() && adouble::_do_adval())) {
    12841286        fprintf(DIAG_OUT, "ADOL-C error: Tapeless: Incorrect mode, call setMode(enum Mode mode)\n");
    1285         exit(1);
     1287        throw logic_error("incorrect function call, errorcode=1");
    12861288    }
    12871289    if (do_val())
     
    13041306    if (no_do_val()) {
    13051307        fprintf(DIAG_OUT, "ADOL-C error: Tapeless: Incorrect mode, call setMode(enum Mode mode)\n");
    1306         exit(1);
     1308        throw logic_error("incorrect function call, errorcode=1");
    13071309    }
    13081310    if (do_val()) {
     
    13181320    if (no_do_val()) {
    13191321        fprintf(DIAG_OUT, "ADOL-C error: Tapeless: Incorrect mode, call setMode(enum Mode mode)\n");
    1320         exit(1);
     1322        throw logic_error("incorrect function call, errorcode=1");
    13211323    }
    13221324    if (do_val()) {
     
    13991401    if (unlikely(!adouble::_do_val() && adouble::_do_adval())) {
    14001402        fprintf(DIAG_OUT, "ADOL-C error: Tapeless: Incorrect mode, call setMode(enum Mode mode)\n");
    1401         exit(1);
     1403        throw logic_error("incorrect function call, errorcode=1");
    14021404    }
    14031405    if (likely(adouble::_do_adval() && adouble::_do_val()))
     
    14231425    if (unlikely(!adouble::_do_val() && adouble::_do_adval())) {
    14241426        fprintf(DIAG_OUT, "ADOL-C error: Tapeless: Incorrect mode, call setMode(enum Mode mode)\n");
    1425         exit(1);
     1427        throw logic_error("incorrect function call, errorcode=1");
    14261428    }
    14271429    if (likely(adouble::_do_adval() && adouble::_do_val()))
     
    14391441    if (no_do_val()) {
    14401442        fprintf(DIAG_OUT, "ADOL-C error: Tapeless: Incorrect mode, call setMode(enum Mode mode)\n");
    1441         exit(1);
     1443        throw logic_error("incorrect function call, errorcode=1");
    14421444    }
    14431445    return val==0.0;
     
    14481450    if (no_do_val()) {
    14491451        fprintf(DIAG_OUT, "ADOL-C error: Tapeless: Incorrect mode, call setMode(enum Mode mode)\n");
    1450         exit(1);
     1452        throw logic_error("incorrect function call, errorcode=1");
    14511453    }
    14521454    return val!=a.val;
     
    14561458    if (no_do_val()) {
    14571459        fprintf(DIAG_OUT, "ADOL-C error: Tapeless: Incorrect mode, call setMode(enum Mode mode)\n");
    1458         exit(1);
     1460        throw logic_error("incorrect function call, errorcode=1");
    14591461    }
    14601462    return val!=v;
     
    14641466    if (no_do_val()) {
    14651467        fprintf(DIAG_OUT, "ADOL-C error: Tapeless: Incorrect mode, call setMode(enum Mode mode)\n");
    1466         exit(1);
     1468        throw logic_error("incorrect function call, errorcode=1");
    14671469    }
    14681470    return v!=a.val;
     
    14721474    if (no_do_val()) {
    14731475        fprintf(DIAG_OUT, "ADOL-C error: Tapeless: Incorrect mode, call setMode(enum Mode mode)\n");
    1474         exit(1);
     1476        throw logic_error("incorrect function call, errorcode=1");
    14751477    }
    14761478    return val==a.val;
     
    14801482    if (no_do_val()) {
    14811483        fprintf(DIAG_OUT, "ADOL-C error: Tapeless: Incorrect mode, call setMode(enum Mode mode)\n");
    1482         exit(1);
     1484        throw logic_error("incorrect function call, errorcode=1");
    14831485    }
    14841486    return val==v;
     
    14881490    if (no_do_val()) {
    14891491        fprintf(DIAG_OUT, "ADOL-C error: Tapeless: Incorrect mode, call setMode(enum Mode mode)\n");
    1490         exit(1);
     1492        throw logic_error("incorrect function call, errorcode=1");
    14911493    }
    14921494    return v==a.val;
     
    14961498    if (no_do_val()) {
    14971499        fprintf(DIAG_OUT, "ADOL-C error: Tapeless: Incorrect mode, call setMode(enum Mode mode)\n");
    1498         exit(1);
     1500        throw logic_error("incorrect function call, errorcode=1");
    14991501    }
    15001502    return val<=a.val;
     
    15041506    if (no_do_val()) {
    15051507        fprintf(DIAG_OUT, "ADOL-C error: Tapeless: Incorrect mode, call setMode(enum Mode mode)\n");
    1506         exit(1);
     1508        throw logic_error("incorrect function call, errorcode=1");
    15071509    }
    15081510    return val<=v;
     
    15121514    if (no_do_val()) {
    15131515        fprintf(DIAG_OUT, "ADOL-C error: Tapeless: Incorrect mode, call setMode(enum Mode mode)\n");
    1514         exit(1);
     1516        throw logic_error("incorrect function call, errorcode=1");
    15151517    }
    15161518    return v<=a.val;
     
    15201522    if (no_do_val()) {
    15211523        fprintf(DIAG_OUT, "ADOL-C error: Tapeless: Incorrect mode, call setMode(enum Mode mode)\n");
    1522         exit(1);
     1524        throw logic_error("incorrect function call, errorcode=1");
    15231525    }
    15241526    return val>=a.val;
     
    15281530    if (no_do_val()) {
    15291531        fprintf(DIAG_OUT, "ADOL-C error: Tapeless: Incorrect mode, call setMode(enum Mode mode)\n");
    1530         exit(1);
     1532        throw logic_error("incorrect function call, errorcode=1");
    15311533    }
    15321534    return val>=v;
     
    15361538    if (no_do_val()) {
    15371539        fprintf(DIAG_OUT, "ADOL-C error: Tapeless: Incorrect mode, call setMode(enum Mode mode)\n");
    1538         exit(1);
     1540        throw logic_error("incorrect function call, errorcode=1");
    15391541    }
    15401542    return v>=a.val;
     
    15441546    if (no_do_val()) {
    15451547        fprintf(DIAG_OUT, "ADOL-C error: Tapeless: Incorrect mode, call setMode(enum Mode mode)\n");
    1546         exit(1);
     1548        throw logic_error("incorrect function call, errorcode=1");
    15471549    }
    15481550    return val>a.val;
     
    15521554    if (no_do_val()) {
    15531555        fprintf(DIAG_OUT, "ADOL-C error: Tapeless: Incorrect mode, call setMode(enum Mode mode)\n");
    1554         exit(1);
     1556        throw logic_error("incorrect function call, errorcode=1");
    15551557    }
    15561558    return val>v;
     
    15601562    if (no_do_val()) {
    15611563        fprintf(DIAG_OUT, "ADOL-C error: Tapeless: Incorrect mode, call setMode(enum Mode mode)\n");
    1562         exit(1);
     1564        throw logic_error("incorrect function call, errorcode=1");
    15631565    }
    15641566    return v>a.val;
     
    15681570    if (no_do_val()) {
    15691571        fprintf(DIAG_OUT, "ADOL-C error: Tapeless: Incorrect mode, call setMode(enum Mode mode)\n");
    1570         exit(1);
     1572        throw logic_error("incorrect function call, errorcode=1");
    15711573    }
    15721574    return val<a.val;
     
    15761578    if (no_do_val()) {
    15771579        fprintf(DIAG_OUT, "ADOL-C error: Tapeless: Incorrect mode, call setMode(enum Mode mode)\n");
    1578         exit(1);
     1580        throw logic_error("incorrect function call, errorcode=1");
    15791581    }
    15801582    return val<v;
     
    15841586    if (no_do_val()) {
    15851587        fprintf(DIAG_OUT, "ADOL-C error: Tapeless: Incorrect mode, call setMode(enum Mode mode)\n");
    1586         exit(1);
     1588        throw logic_error("incorrect function call, errorcode=1");
    15871589    }
    15881590    return v<a.val;
     
    15931595    if (no_do_val()) {
    15941596        fprintf(DIAG_OUT, "ADOL-C error: Tapeless: Incorrect mode, call setMode(enum Mode mode)\n");
    1595         exit(1);
     1597        throw logic_error("incorrect function call, errorcode=1");
    15961598    }
    15971599    return val;
     
    16011603    if (no_do_val()) {
    16021604        fprintf(DIAG_OUT, "ADOL-C error: Tapeless: Incorrect mode, call setMode(enum Mode mode)\n");
    1603         exit(1);
     1605        throw logic_error("incorrect function call, errorcode=1");
    16041606    }
    16051607    val=v;
     
    16091611    if (no_do_adval()) {
    16101612        fprintf(DIAG_OUT, "ADOL-C error: Tapeless: Incorrect mode, call setMode(enum Mode mode)\n");
    1611         exit(1);
     1613        throw logic_error("incorrect function call, errorcode=1");
    16121614    }
    16131615    return adval;
     
    16171619    if (no_do_adval()) {
    16181620        fprintf(DIAG_OUT, "ADOL-C error: Tapeless: Incorrect mode, call setMode(enum Mode mode)\n");
    1619         exit(1);
     1621        throw logic_error("incorrect function call, errorcode=1");
    16201622    }
    16211623    FOR_I_EQ_0_LT_NUMDIR
     
    16261628    if (no_do_adval()) {
    16271629        fprintf(DIAG_OUT, "ADOL-C error: Tapeless: Incorrect mode, call setMode(enum Mode mode)\n");
    1628         exit(1);
     1630        throw logic_error("incorrect function call, errorcode=1");
    16291631    }
    16301632    if (p>=adouble::numDir)
     
    16321634        fprintf(DIAG_OUT, "Derivative array accessed out of bounds"\
    16331635                " while \"getADValue(...)\"!!!\n");
    1634         exit(-1);
     1636        throw logic_error("incorrect function call, errorcode=-1");
    16351637    }
    16361638    return adval[p];
     
    16401642    if (no_do_adval()) {
    16411643        fprintf(DIAG_OUT, "ADOL-C error: Tapeless: Incorrect mode, call setMode(enum Mode mode)\n");
    1642         exit(1);
     1644        throw logic_error("incorrect function call, errorcode=1");
    16431645    }
    16441646    if (p>=adouble::numDir)
     
    16461648        fprintf(DIAG_OUT, "Derivative array accessed out of bounds"\
    16471649                " while \"setADValue(...)\"!!!\n");
    1648         exit(-1);
     1650        throw logic_error("incorrect function call, errorcode=-1");
    16491651    }
    16501652    adval[p]=v;
     
    16541656    if (no_do_indo()) {
    16551657        fprintf(DIAG_OUT, "ADOL-C error: Tapeless: Incorrect mode, call setMode(enum Mode mode)\n");
    1656         exit(1);
     1658        throw logic_error("incorrect function call, errorcode=1");
    16571659    }
    16581660    return pattern;
     
    16621664    if (no_do_indo()) {
    16631665        fprintf(DIAG_OUT, "ADOL-C error: Tapeless: Incorrect mode, call setMode(enum Mode mode)\n");
    1664         exit(1);
     1666        throw logic_error("incorrect function call, errorcode=1");
    16651667    }
    16661668    if ( !pattern.empty() )
     
    16711673    if (no_do_indo()) {
    16721674        fprintf(DIAG_OUT, "ADOL-C error: Tapeless: Incorrect mode, call setMode(enum Mode mode)\n");
    1673         exit(1);
     1675        throw logic_error("incorrect function call, errorcode=1");
    16741676    }
    16751677    if (likely( pattern != v)) {
     
    16891691    if (no_do_indo()) {
    16901692     fprintf(DIAG_OUT, "ADOL-C error: Tapeless: Incorrect mode, call setMode(enum Mode mode)\n");
    1691      exit(1);
     1693     throw logic_error("incorrect function call, errorcode=1");
    16921694    }
    16931695    size_t s=0;
  • trunk/ADOL-C/src/adalloc.c

    r506 r515  
    3737BEGIN_C_DECLS
    3838
     39extern void adolc_exit(int errorcode, const char *what, const char* function, const char *file, int line);
     40
    3941/****************************************************************************/
    4042/*                                              MEMORY MANAGEMENT UTILITIES */
     
    4850        fprintf(DIAG_OUT,"ADOL-C error: myalloc1 cannot allocate %zd bytes\n",
    4951                (size_t)(m*sizeof(double)));
    50         exit (-1);
     52        adolc_exit(-1,"",__func__,__FILE__,__LINE__);
    5153      }
    5254    }
     
    6466        fprintf(DIAG_OUT,"ADOL-C error: myalloc2 cannot allocate %zd bytes\n",
    6567                (size_t)(m*n*sizeof(double)));
    66         exit (-1);
     68        adolc_exit(-1,"",__func__,__FILE__,__LINE__);
    6769      }
    6870      if (A == NULL) {
    6971        fprintf(DIAG_OUT,"ADOL-C error: myalloc2 cannot allocate %zd bytes\n",
    7072                (size_t)(m*sizeof(double*)));
    71         exit (-1);
     73        adolc_exit(-1,"",__func__,__FILE__,__LINE__);
    7274      }
    7375      for (i=0; i<m; i++) {
     
    9092        fprintf(DIAG_OUT,"ADOL-C error: myalloc3 cannot allocate %zd bytes\n",
    9193                (size_t)(m*n*p*sizeof(double)));
    92         exit (-1);
     94        adolc_exit(-1,"",__func__,__FILE__,__LINE__);
    9395      }
    9496      if (Apt == NULL) {
    9597        fprintf(DIAG_OUT,"ADOL-C error: myalloc3 cannot allocate %zd bytes\n",
    9698                (size_t)(m*n*sizeof(double*)));
    97         exit (-1);
     99        adolc_exit(-1,"",__func__,__FILE__,__LINE__);
    98100      }
    99101      if (A == NULL) {
    100102        fprintf(DIAG_OUT,"ADOL-C error: myalloc3 cannot allocate %zd bytes\n",
    101103                (size_t)(m*sizeof(double**)));
    102         exit (-1);
     104        adolc_exit(-1,"",__func__,__FILE__,__LINE__);
    103105      }
    104106      for (i=0; i<m; i++) {
     
    143145        fprintf(DIAG_OUT,"ADOL-C error: myallocI2 cannot allocate %i bytes\n",
    144146                (int)((2*n-1)*sizeof(double)));
    145         exit (-1);
     147        adolc_exit(-1,"",__func__,__FILE__,__LINE__);
    146148    }
    147149    if (I == NULL) {
    148150        fprintf(DIAG_OUT,"ADOL-C error: myallocI2 cannot allocate %i bytes\n",
    149151                (int)(n*sizeof(double*)));
    150         exit (-1);
     152        adolc_exit(-1,"",__func__,__FILE__,__LINE__);
    151153    }
    152154    Idum += (n - 1);
     
    180182                ":%i : \nmyalloc1_ushort cannot allocate %i bytes\n",
    181183                __LINE__, (int)(m*sizeof(unsigned int)));
    182         exit (-1);
     184        adolc_exit(-1,"",__func__,__FILE__,__LINE__);
    183185    } /* endif */
    184186    return A;
     
    193195                ":%i : \nmyalloc1_ulong cannot allocate %i bytes\n",
    194196                __LINE__, (int)(m*sizeof(unsigned long int)));
    195         exit (-1);
     197        adolc_exit(-1,"",__func__,__FILE__,__LINE__);
    196198    } /* endif */
    197199    return A;
     
    208210                ":%i : \nmyalloc2_ulong cannot allocate %i bytes\n",
    209211                __LINE__, (int)(m*n*sizeof(unsigned long int)));
    210         exit (-1);
     212        adolc_exit(-1,"",__func__,__FILE__,__LINE__);
    211213    } /* endif */
    212214    if (A == NULL) {
     
    214216                ":%i : \nmyalloc2_ulong cannot allocate %i bytes\n",
    215217                __LINE__, (int)(m*sizeof(unsigned long int*)));
    216         exit (-1);
     218        adolc_exit(-1,"",__func__,__FILE__,__LINE__);
    217219    } /* endif */
    218220    for(i=0;i<m;i++) {
  • trunk/ADOL-C/src/adouble_tl.cpp

    r493 r515  
    2828
    2929using std::cout;
     30
     31extern "C" void adolc_exit(int errorcode, const char *what, const char* function, const char *file, int line);
    3032
    3133namespace adtl {
     
    6365        {
    6466            cout << "ADOL-C error: to many directions in input\n";
    65             exit(-1);
     67            adolc_exit(-1,"",__func__,__FILE__,__LINE__);
    6668        }
    6769        do in >> c;
  • trunk/ADOL-C/src/advector.cpp

    r427 r515  
    3131        fprintf(DIAG_OUT,"ADOL-C error: strange construction of an active"
    3232                " vector subscript reference\n(passed ref = %d, stored refloc = %d)\n",ref,refloc);
    33         exit(-2);
     33        adolc_exit(-2,"",__func__,__FILE__,__LINE__);
    3434    }
    3535}
     
    467467    if (!nondecreasing()) {
    468468        fprintf(DIAG_OUT, "ADOL-C error: can only call lookup index if advector ist nondecreasing\n");
    469         exit(-2);
     469        adolc_exit(-2,"",__func__,__FILE__,__LINE__);
    470470    }
    471471    if (y.value() < 0) {
    472472        fprintf(DIAG_OUT, "ADOL-C error: index lookup needs a nonnegative denominator\n");
    473         exit(-2);
     473        adolc_exit(-2,"",__func__,__FILE__,__LINE__);
    474474    }
    475475    adouble r = 0;
  • trunk/ADOL-C/src/fixpoint.cpp

    r370 r515  
    7878    if (fpi_stack_iterator==fpi_stack.end()) {
    7979        fprintf(stderr,"ADOL-C Error! No edf found for fixpoint iteration.\n");
    80         exit(-1);
     80        adolc_exit(-1,"",__func__,__FILE__,__LINE__);
    8181    }
    8282    for (i=0; i<dim_x; i++) x_fix[i] = xu[i];
     
    109109    if (fpi_stack_iterator==fpi_stack.end()) {
    110110        fprintf(stderr,"ADOL-C Error! No edf found for fixpoint iteration.\n");
    111         exit(-1);
     111        adolc_exit(-1,"",__func__,__FILE__,__LINE__);
    112112    }
    113113    for (k=1; (k<current->N_max_deriv)|(k<current->N_max); k++) {
     
    143143    if (fpi_stack_iterator==fpi_stack.end()) {
    144144        fprintf(stderr,"ADOL-C Error! No edf found for fixpoint iteration.\n");
    145         exit(-1);
     145        adolc_exit(-1,"",__func__,__FILE__,__LINE__);
    146146    }
    147147    double *U = new double[dim_xu];
  • trunk/ADOL-C/src/fo_rev.c

    r510 r515  
    426426                "with %s(..)\n              Please call enableMinMaxUsingAbs() "
    427427                "before trace_on(%d)\n", tnum, GENERATED_FILENAME, tnum);
    428         exit(-1);
     428        adolc_exit(-1,"",__func__,__FILE__,__LINE__);
    429429    }
    430430    else if (swchk != ADOLC_CURRENT_TAPE_INFOS.stats[NUM_SWITCHES]) {
     
    432432                "match with the one recorded on tape %d (%zu)\n",swchk,tnum,
    433433                ADOLC_CURRENT_TAPE_INFOS.stats[NUM_SWITCHES]);
    434         exit(-1);
     434        adolc_exit(-1,"",__func__,__FILE__,__LINE__);
    435435    }
    436436    else
     
    517517        fprintf(DIAG_OUT,"\n ADOL-C error: reverse fails because it was not"
    518518                " preceded\nby a forward sweep with degree>0, keep=1!\n");
    519         exit(-2);
     519        adolc_exit(-2,"",__func__,__FILE__,__LINE__);
    520520    };
    521521
     
    18071807#else
    18081808                    fprintf(DIAG_OUT, "ADOL-C error: active subscripting does not work in safe mode, please use tight mode\n");
    1809                     exit(-2);
     1809                    adolc_exit(-2,"",__func__,__FILE__,__LINE__);
    18101810#endif /* !_NTIGHT_ */
    18111811                }
     
    18381838                    if (arg1 != vectorloc+idx) {
    18391839                        fprintf(DIAG_OUT, "ADOL-C error: indexed active position does not match referenced position\nindexed = %zu, referenced = %d\n", vectorloc+idx, arg1);
    1840                         exit(-2);
     1840                        adolc_exit(-2,"",__func__,__FILE__,__LINE__);
    18411841                    }
    18421842                    ADOLC_GET_TAYLOR(res);
    18431843#else
    18441844                    fprintf(DIAG_OUT, "ADOL-C error: active subscripting does not work in safe mode, please use tight mode\n");
    1845                     exit(-2);
     1845                    adolc_exit(-2,"",__func__,__FILE__,__LINE__);
    18461846#endif /* !_NTIGHT_ */
    18471847                }
     
    18691869#else
    18701870                fprintf(DIAG_OUT, "ADOL-C error: active vector element referencing does not work in safe mode, please use tight mode\n");
    1871                 exit(-2);
     1871                adolc_exit(-2,"",__func__,__FILE__,__LINE__);
    18721872#endif
    18731873                break;
     
    18831883#else
    18841884                fprintf(DIAG_OUT, "ADOL-C error: active vector element referencing does not work in safe mode, please use tight mode\n");
    1885                 exit(-2);
     1885                adolc_exit(-2,"",__func__,__FILE__,__LINE__);
    18861886#endif /* !_NTIGHT_ */
    18871887                break;
     
    19061906#else
    19071907                fprintf(DIAG_OUT, "ADOL-C error: active vector element referencing does not work in safe mode, please use tight mode\n");
    1908                 exit(-2);
     1908                adolc_exit(-2,"",__func__,__FILE__,__LINE__);
    19091909#endif /* !_NTIGHT_ */
    19101910                break;
     
    19281928#else
    19291929                fprintf(DIAG_OUT, "ADOL-C error: active vector element referencing does not work in safe mode, please use tight mode\n");
    1930                 exit(-2);
     1930                adolc_exit(-2,"",__func__,__FILE__,__LINE__);
    19311931#endif /* !_NTIGHT_ */
    19321932                break;
     
    19571957#else
    19581958                fprintf(DIAG_OUT, "ADOL-C error: active vector element referencing does not work in safe mode, please use tight mode\n");
    1959                 exit(-2);
     1959                adolc_exit(-2,"",__func__,__FILE__,__LINE__);
    19601960#endif /* !_NTIGHT_ */
    19611961                break;
     
    19761976#else
    19771977                fprintf(DIAG_OUT, "ADOL-C error: active vector element referencing does not work in safe mode, please use tight mode\n");
    1978                 exit(-2);
     1978                adolc_exit(-2,"",__func__,__FILE__,__LINE__);
    19791979#endif /* !_NTIGHT_ */
    19801980                indexi--;
     
    19911991#else
    19921992                fprintf(DIAG_OUT, "ADOL-C error: active vector element referencing does not work in safe mode, please use tight mode\n");
    1993                 exit(-2);
     1993                adolc_exit(-2,"",__func__,__FILE__,__LINE__);
    19941994#endif /* !_NTIGHT_ */
    19951995                break;
     
    20162016#else
    20172017                fprintf(DIAG_OUT, "ADOL-C error: active vector element referencing does not work in safe mode, please use tight mode\n");
    2018                 exit(-2);
     2018                adolc_exit(-2,"",__func__,__FILE__,__LINE__);
    20192019#endif /* !_NTIGHT_ */
    20202020                break;
     
    20302030#else
    20312031                fprintf(DIAG_OUT, "ADOL-C error: active vector element referencing does not work in safe mode, please use tight mode\n");
    2032                 exit(-2);
     2032                adolc_exit(-2,"",__func__,__FILE__,__LINE__);
    20332033#endif /* !_NTIGHT_ */
    20342034               break;
     
    20542054#else
    20552055                fprintf(DIAG_OUT, "ADOL-C error: active vector element referencing does not work in safe mode, please use tight mode\n");
    2056                 exit(-2);
     2056                adolc_exit(-2,"",__func__,__FILE__,__LINE__);
    20572057#endif /* !_NTIGHT_ */
    20582058                break;
     
    20752075#else
    20762076                fprintf(DIAG_OUT, "ADOL-C error: active vector element referencing does not work in safe mode, please use tight mode\n");
    2077                 exit(-2);
     2077                adolc_exit(-2,"",__func__,__FILE__,__LINE__);
    20782078#endif /* !_NTIGHT_ */
    20792079                break;
     
    21032103#else
    21042104                fprintf(DIAG_OUT, "ADOL-C error: active vector element referencing does not work in safe mode, please use tight mode\n");
    2105                 exit(-2);
     2105                adolc_exit(-2,"",__func__,__FILE__,__LINE__);
    21062106#endif /* !_NTIGHT_ */
    21072107                break;
     
    21622162#else
    21632163                fprintf(DIAG_OUT, "ADOL-C error: active vector element referencing does not work in safe mode, please use tight mode\n");
    2164                 exit(-2);
     2164                adolc_exit(-2,"",__func__,__FILE__,__LINE__);
    21652165#endif /* !_NTIGHT_ */
    21662166                }
     
    22032203#else
    22042204                fprintf(DIAG_OUT, "ADOL-C error: active vector element referencing does not work in safe mode, please use tight mode\n");
    2205                 exit(-2);
     2205                adolc_exit(-2,"",__func__,__FILE__,__LINE__);
    22062206#endif /* !_NTIGHT_ */
    22072207                break;
     
    25672567                        __FILE__
    25682568                        ") : no such operation %d\n", operation);
    2569                 exit(-1);
     2569                adolc_exit(-1,"",__func__,__FILE__,__LINE__);
    25702570                break;
    25712571        } /* endswitch */
  • trunk/ADOL-C/src/ho_rev.c

    r502 r515  
    559559                " preceded\nby a forward sweep with degree>%i,"
    560560                " keep=%i!\n",degre,degre+1);
    561         exit(-2);
     561        adolc_exit(-2,"",__func__,__FILE__,__LINE__);
    562562    };
    563563
     
    567567                " given to reverse are\ninconsistent with that of the"
    568568                "  internal taylor array.\n",tnum);
    569         exit(-2);
     569        adolc_exit(-2,"",__func__,__FILE__,__LINE__);
    570570    }
    571571
     
    21232123                    if (arg1 != vectorloc+idx) {
    21242124                        fprintf(DIAG_OUT, "ADOL-C error: indexed active position does not match referenced position\nindexed = %zu, referenced = %d\n", vectorloc+idx, arg1);
    2125                         exit(-2);
     2125                        adolc_exit(-2,"",__func__,__FILE__,__LINE__);
    21262126                    }
    21272127                    GET_TAYL(res,k,p)
     
    25582558                        __FILE__
    25592559                        ") : no such operation %d\n", operation);
    2560                 exit(-1);
     2560                adolc_exit(-1,"",__func__,__FILE__,__LINE__);
    25612561                break;
    25622562        } /* endswitch */
  • trunk/ADOL-C/src/interfaces.cpp

    r436 r515  
    2222#define ceil(x) ((int)((x)+1) - (int)((x) == (int)(x)))
    2323
     24extern "C" void adolc_exit(int errorcode, const char *what, const char* function, const char *file, int line);
    2425
    2526/****************************************************************************/
     
    163164    } else {
    164165        fprintf(DIAG_OUT,"ADOL-C error: wrong Y dimension in forward \n");
    165         exit(-1);
     166        adolc_exit(-1,"",__func__,__FILE__,__LINE__);
    166167    }
    167168
     
    185186    if (d != 0) {
    186187        fprintf(DIAG_OUT,"ADOL-C error:  wrong X and Y dimensions in forward \n");
    187         exit(-1);
     188        adolc_exit(-1,"",__func__,__FILE__,__LINE__);
    188189    } else
    189190        rc = zos_forward(tag,m,n,keep,X,Y);
     
    271272    if (m != 1) {
    272273        fprintf(DIAG_OUT,"ADOL-C error:  wrong u dimension in scalar-reverse \n");
    273         exit(-1);
     274        adolc_exit(-1,"",__func__,__FILE__,__LINE__);
    274275    } else
    275276        rc = hos_reverse(tag,m,n,d,&u,Z);
     
    291292{ if (d != 0) {
    292293        fprintf(DIAG_OUT,"ADOL-C error:  wrong Z dimension in scalar-reverse \n");
    293         exit(-1);
     294        adolc_exit(-1,"",__func__,__FILE__,__LINE__);
    294295    }
    295296
     
    312313    if (m != 1 || d != 0 ) {
    313314        fprintf(DIAG_OUT,"ADOL-C error:  wrong u or Z dimension in scalar-reverse \n");
    314         exit(-1);
     315        adolc_exit(-1,"",__func__,__FILE__,__LINE__);
    315316    } else
    316317        rc = fos_reverse(tag,m,n,&u,Z);
     
    352353    if (m != 1) {
    353354        fprintf(DIAG_OUT,"ADOL-C error:  wrong U dimension in vector-reverse \n");
    354         exit(-1);
     355        adolc_exit(-1,"",__func__,__FILE__,__LINE__);
    355356    } else { /* olvo 980727 ??? */
    356357        /* double** upp = new double*[nrows]; */
     
    382383    if (d != 0) {
    383384        fprintf(DIAG_OUT,"ADOL-C error:  wrong degree in vector-reverse \n");
    384         exit(-1);
     385        adolc_exit(-1,"",__func__,__FILE__,__LINE__);
    385386    } else
    386387        rc = fov_reverse(tag,m,n,q,U,Z);
     
    429430    if ((m != 1) || (d != 0)) {
    430431        fprintf(DIAG_OUT,"ADOL-C error:  wrong U dimension in vector-reverse \n");
    431         exit(-1);
     432        adolc_exit(-1,"",__func__,__FILE__,__LINE__);
    432433    } else { /* olvo 980727 ??? */
    433434        /* double ** upp = new double*[nrows]; */
  • trunk/ADOL-C/src/sparse/sparse_fo_rev.cpp

    r106 r515  
    1818
    1919#if defined(__cplusplus)
     20
     21extern "C" void adolc_exit(int errorcode, const char *what, const char* function, const char *file, int line);
    2022
    2123/****************************************************************************/
     
    4042            fprintf(DIAG_OUT,"ADOL-C error:  no basepoint for bit"
    4143                    " pattern forward tight.\n");
    42             exit(-1);
     44            adolc_exit(-1,"",__func__,__FILE__,__LINE__);
    4345        }
    4446    else
     
    4850            fprintf(DIAG_OUT,"ADOL-C error:  bad mode parameter to bit"
    4951                    " pattern forward.\n");
    50             exit(-1);
     52            adolc_exit(-1,"",__func__,__FILE__,__LINE__);
    5153        }
    5254    return (rc);
     
    6971    { fprintf(DIAG_OUT,"ADOL-C error:  bad mode parameter to bit"
    7072                  " pattern forward.\n");
    71         exit(-1);
     73        adolc_exit(-1,"",__func__,__FILE__,__LINE__);
    7274    }
    7375    return int_forward_safe(tag,m,n,p,X,Y);
     
    100102            fprintf(DIAG_OUT,"ADOL-C error:  bad mode parameter"
    101103                    " to bit pattern reverse.\n");
    102             exit(-1);
     104            adolc_exit(-1,"",__func__,__FILE__,__LINE__);
    103105        }
    104106    return rc;
  • trunk/ADOL-C/src/sparse/sparsedrivers.cpp

    r506 r515  
    7474        fprintf(DIAG_OUT,"ADOL-C user error in jac_pat(...) : "
    7575                "parameter crs may not be NULL !\n");
    76         exit(-1);
     76        adolc_exit(-1,"",__func__,__FILE__,__LINE__);
    7777    } else
    7878        for (i=0; i<depen; i++)
     
    133133{
    134134    fprintf(DIAG_OUT, "ADOL-C error: function %s can only be used if linked with ColPack\n", __FUNCTION__);
    135     exit(-1);
     135    adolc_exit(-1,"",__func__,__FILE__,__LINE__);
    136136}
    137137#endif
     
    166166        fprintf(DIAG_OUT,"ADOL-C user error in hess_pat(...) : "
    167167                "parameter crs may not be NULL !\n");
    168         exit(-1);
     168        adolc_exit(-1,"",__func__,__FILE__,__LINE__);
    169169    } else
    170170        for (i=0; i<indep; i++)
     
    214214{
    215215    fprintf(DIAG_OUT, "ADOL-C error: function %s can only be used if linked with ColPack\n", __FUNCTION__);
    216     exit(-1);
     216    adolc_exit(-1,"",__func__,__FILE__,__LINE__);
    217217}
    218218#endif
     
    415415{
    416416    fprintf(DIAG_OUT, "ADOL-C error: function %s can only be used if linked with ColPack\n", __FUNCTION__);
    417     exit(-1);
     417    adolc_exit(-1,"",__func__,__FILE__,__LINE__);
    418418}
    419419#endif
     
    485485            if (indep != ADOLC_CURRENT_TAPE_INFOS.pTapeInfos.sHinfos.indep) {
    486486                fprintf(DIAG_OUT,"ADOL-C Error: wrong number of independents stored in hessian pattern.\n");
    487                 exit(-1);
     487                adolc_exit(-1,"",__func__,__FILE__,__LINE__);
    488488            }
    489489            deepcopy_HP(&sHinfos.HP,ADOLC_CURRENT_TAPE_INFOS.pTapeInfos.sHinfos.HP,indep);         
     
    643643{
    644644    fprintf(DIAG_OUT, "ADOL-C error: function %s can only be used if linked with ColPack\n", __FUNCTION__);
    645     exit(-1);
     645    adolc_exit(-1,"",__func__,__FILE__,__LINE__);
    646646}
    647647#endif
     
    682682{
    683683    fprintf(DIAG_OUT, "ADOL-C error: function %s can only be used if sparse configuration option was used\n", __FUNCTION__);
    684     exit(-1);
     684    adolc_exit(-1,"",__func__,__FILE__,__LINE__);
    685685}
    686686#endif
     
    704704{
    705705    fprintf(DIAG_OUT, "ADOL-C error: function %s can only be used if sparse configuration option was used\n", __FUNCTION__);
    706     exit(-1);
     706    adolc_exit(-1,"",__func__,__FILE__,__LINE__);
    707707}
    708708#endif
     
    775775        if (( tight_mode ) && ( basepoint == NULL )) {
    776776            fprintf(DIAG_OUT, "ADOL-C error in jac_pat(...) :  supply basepoint x for tight mode.\n");
    777             exit(-1);
     777            adolc_exit(-1,"",__func__,__FILE__,__LINE__);
    778778        }
    779779
     
    804804                    ":%i : \njac_pat(...) unable to allocate %i bytes !\n",
    805805                    __LINE__, (int)(i_blocks_per_strip*sizeof(char)));
    806             exit(-1);
     806            adolc_exit(-1,"",__func__,__FILE__,__LINE__);
    807807        }
    808808
     
    881881                                 ":%i : \njac_pat(...) unable to allocate %i bytes !\n",
    882882                                __LINE__, (int)((k_old+k+1)*sizeof(unsigned int)));
    883                         exit(-1);
     883                        adolc_exit(-1,"",__func__,__FILE__,__LINE__);
    884884                    }
    885885                    if ( strip_idx == 0 )
     
    933933                    ":%i : \njac_pat(...) unable to allocate %i bytes !\n",
    934934                    __LINE__, (int)(indep*sizeof(unsigned char)));
    935             exit(-1);
     935            adolc_exit(-1,"",__func__,__FILE__,__LINE__);
    936936        }
    937937
     
    946946                fprintf(DIAG_OUT, "ADOL-C error in jac_pat(..) :  ");
    947947                fprintf(DIAG_OUT, "no basepoint x for tight mode supplied.\n");
    948                 exit(-1);
     948                adolc_exit(-1,"",__func__,__FILE__,__LINE__);
    949949            }
    950950
     
    10131013                            ":%i : \njac_pat(...) unable to allocate %i bytes !\n",
    10141014                            __LINE__, (int)((k+1)*sizeof(unsigned int)));
    1015                     exit(-1);
     1015                    adolc_exit(-1,"",__func__,__FILE__,__LINE__);
    10161016                }
    10171017                crs[d_bl_idx][0] = k; /* number of non-zero indep. blocks */
     
    12381238{
    12391239    fprintf(DIAG_OUT, "ADOL-C error: function %s can only be used if linked with ColPack\n", __FUNCTION__);
    1240     exit(-1);
     1240    adolc_exit(-1,"",__func__,__FILE__,__LINE__);
    12411241}
    12421242#endif
     
    13101310{
    13111311    fprintf(DIAG_OUT, "ADOL-C error: function %s can only be used if linked with ColPack\n", __FUNCTION__);
    1312     exit(-1);
     1312    adolc_exit(-1,"",__func__,__FILE__,__LINE__);
    13131313}
    13141314#endif
  • trunk/ADOL-C/src/tape_handling.cpp

    r512 r515  
    2727#include <stack>
    2828#include <errno.h>
     29#include <exception>
    2930
    3031using namespace std;
     
    154155      fprintf(DIAG_OUT,"maximal number (%d) of live active variables exceeded\n\n",
    155156              std::numeric_limits<locint>::max());
    156       exit(-3);
     157      adolc_exit(-3,"",__func__,__FILE__,__LINE__);
    157158    }
    158159
     
    13221323      fprintf(DIAG_OUT,"maximal number (%u) of live active variables exceeded\n\n",
    13231324           std::numeric_limits<locint>::max());
    1324       exit(-3);
     1325      adolc_exit(-3,"",__func__,__FILE__,__LINE__);
    13251326    }
    13261327
     
    14791480                ,__FUNCTION__);
    14801481}
     1482
     1483class FatalError: public exception{
     1484protected:
     1485    static const int MAX_MSG_SIZE = 4*1024;
     1486    char msg[MAX_MSG_SIZE];
     1487
     1488public:
     1489    explicit FatalError(int errorcode, const char* what, const char* function, const char* file, int line) {
     1490        // need to use C-style functions that do not use exceptions themselves
     1491        snprintf(this->msg, MAX_MSG_SIZE, "errorcode=%d function=%s file=%s line=%d what=%s", errorcode, function, file, line, what);
     1492    }
     1493
     1494    virtual const char* what() const throw() {
     1495        return msg;
     1496    }
     1497};
     1498
     1499void adolc_exit(int errorcode, const char *what, const char* function, const char *file, int line) {
     1500    throw FatalError(errorcode, what, function, file, line);
     1501}
  • trunk/ADOL-C/src/tapedoc/tapedoc.c

    r439 r515  
    6060    if ((fp = fopen(fileName,"w")) == NULL) {
    6161        fprintf(DIAG_OUT,"cannot open file !\n");
    62         exit(1);
     62        adolc_exit(1,"",__func__,__FILE__,__LINE__);
    6363    }
    6464    free((void*)fileName);
     
    277277                indcheck, tag, ADOLC_CURRENT_TAPE_INFOS.stats[NUM_DEPENDENTS],
    278278                ADOLC_CURRENT_TAPE_INFOS.stats[NUM_INDEPENDENTS]);
    279         exit (-1);
     279        adolc_exit(-1,"",__func__,__FILE__,__LINE__);
    280280    }
    281281
  • trunk/ADOL-C/src/taping.c

    r507 r515  
    293293        default:
    294294            fprintf(DIAG_OUT, "ADOL-C error => unknown error type!\n");
    295             exit (-1);
    296             break;
    297     }
    298     exit (error + 1);
     295            adolc_exit(-1, "", __func__, __FILE__, __LINE__);
     296            break;
     297    }
     298    adolc_exit(error+1, "", __func__,  __FILE__, __LINE__);
     299    // exit (error + 1);
    299300}
    300301
  • trunk/ADOL-C/src/taping_p.h

    r512 r515  
    662662void markNewTape();
    663663
     664/****************************************************************************/
     665/* Allows us to throw an exception instead of calling exit() in case of a   */
     666/* irrecoverable error                                                      */
     667/****************************************************************************/
     668void adolc_exit(int errorcode, const char *what, const char *function, const char* file, int line);
     669
    664670END_C_DECLS
    665671
  • trunk/ADOL-C/src/uni5_for.c

    r502 r515  
    10641064                ADOLC_CURRENT_TAPE_INFOS.stats[NUM_DEPENDENTS],
    10651065                ADOLC_CURRENT_TAPE_INFOS.stats[NUM_INDEPENDENTS]);
    1066         exit (-1);
     1066        adolc_exit(-1,"",__func__,__FILE__,__LINE__);
    10671067    }
    10681068#if defined(_ABS_NORM_)
     
    10711071                  "with %s\n              Please call enableMinMaxUsingAbs() "
    10721072                  "before trace_on(%d)\n", tnum, __FUNCTION__, tnum);
    1073           exit(-1);
     1073          adolc_exit(-1,"",__func__,__FILE__,__LINE__);
    10741074      }
    10751075#endif
     
    11021102        fprintf(DIAG_OUT,"\n ADOL-C error: zero order scalar forward cannot save"
    11031103                " more\nthan zero order taylor coefficients!\n");
    1104         exit (-1);
     1104        adolc_exit(-1,"",__func__,__FILE__,__LINE__);
    11051105    }
    11061106#endif
     
    11201120        fprintf(DIAG_OUT,"\n ADOL-C error: first order scalar forward cannot save"
    11211121                " more  \nthan first order taylor coefficients!\n");
    1122         exit (-1);
     1122        adolc_exit(-1,"",__func__,__FILE__,__LINE__);
    11231123    }
    11241124#endif
     
    42914291#else
    42924292                    fprintf(DIAG_OUT, "ADOL-C error: active subscripting does not work in safe mode, please use tight mode\n");
    4293                     exit(-2);
     4293                    adolc_exit(-2,"",__func__,__FILE__,__LINE__);
    42944294#endif /* ALL_TOGETHER_AGAIN */
    42954295                }
     
    43194319#else
    43204320                    fprintf(DIAG_OUT, "ADOL-C error: active subscripting does not work in safe mode, please use tight mode\n");
    4321                     exit(-2);
     4321                    adolc_exit(-2,"",__func__,__FILE__,__LINE__);
    43224322#endif
    43234323                }
     
    43494349#else
    43504350                fprintf(DIAG_OUT, "ADOL-C error: active vector element referencing does not work in safe mode, please use tight mode\n");
    4351                 exit(-2);
     4351                adolc_exit(-2,"",__func__,__FILE__,__LINE__);
    43524352#endif /* ALL_TOGETHER_AGAIN */
    43534353                break;
     
    43614361#else
    43624362                fprintf(DIAG_OUT, "ADOL-C error: active vector element referencing does not work in safe mode, please use tight mode\n");
    4363                 exit(-2);
     4363                adolc_exit(-2,"",__func__,__FILE__,__LINE__);
    43644364#endif
    43654365                break;
     
    43734373#else
    43744374                fprintf(DIAG_OUT, "ADOL-C error: active vector element referencing does not work in safe mode, please use tight mode\n");
    4375                 exit(-2);
     4375                adolc_exit(-2,"",__func__,__FILE__,__LINE__);
    43764376#endif
    43774377                break;
     
    44084408#else
    44094409                fprintf(DIAG_OUT, "ADOL-C error: active vector element referencing does not work in safe mode, please use tight mode\n");
    4410                 exit(-2);
     4410                adolc_exit(-2,"",__func__,__FILE__,__LINE__);
    44114411#endif
    44124412                break;
     
    44394439#else
    44404440                fprintf(DIAG_OUT, "ADOL-C error: active vector element referencing does not work in safe mode, please use tight mode\n");
    4441                 exit(-2);
     4441                adolc_exit(-2,"",__func__,__FILE__,__LINE__);
    44424442#endif
    44434443                break;
     
    44704470#else
    44714471                fprintf(DIAG_OUT, "ADOL-C error: active vector element referencing does not work in safe mode, please use tight mode\n");
    4472                 exit(-2);
     4472                adolc_exit(-2,"",__func__,__FILE__,__LINE__);
    44734473#endif
    44744474                break;
     
    45014501#else
    45024502                fprintf(DIAG_OUT, "ADOL-C error: active vector element referencing does not work in safe mode, please use tight mode\n");
    4503                 exit(-2);
     4503                adolc_exit(-2,"",__func__,__FILE__,__LINE__);
    45044504#endif /* ALL_TOGETHER_AGAIN */
    45054505                break;
     
    45414541#else
    45424542                fprintf(DIAG_OUT, "ADOL-C error: active vector element referencing does not work in safe mode, please use tight mode\n");
    4543                 exit(-2);
     4543                adolc_exit(-2,"",__func__,__FILE__,__LINE__);
    45444544#endif /* ALL_TOGETHER_AGAIN */
    45454545                ++indexi;
     
    45614561#else
    45624562                fprintf(DIAG_OUT, "ADOL-C error: active vector element referencing does not work in safe mode, please use tight mode\n");
    4563                 exit(-2);
     4563                adolc_exit(-2,"",__func__,__FILE__,__LINE__);
    45644564#endif /* !_NTIGHT_ */
    45654565                break;
     
    46014601#else
    46024602                fprintf(DIAG_OUT, "ADOL-C error: active vector element referencing does not work in safe mode, please use tight mode\n");
    4603                 exit(-2);
     4603                adolc_exit(-2,"",__func__,__FILE__,__LINE__);
    46044604#endif /* ALL_TOGETHER_AGAIN */
    46054605                break;
     
    46194619#else
    46204620                fprintf(DIAG_OUT, "ADOL-C error: active vector element referencing does not work in safe mode, please use tight mode\n");
    4621                 exit(-2);
     4621                adolc_exit(-2,"",__func__,__FILE__,__LINE__);
    46224622#endif /* !_NTIGHT_ */
    46234623                break;
     
    46594659#else
    46604660                fprintf(DIAG_OUT, "ADOL-C error: active vector element referencing does not work in safe mode, please use tight mode\n");
    4661                 exit(-2);
     4661                adolc_exit(-2,"",__func__,__FILE__,__LINE__);
    46624662#endif /* ALL_TOGETHER_AGAIN */
    46634663                break;
     
    46894689#else
    46904690                fprintf(DIAG_OUT, "ADOL-C error: active vector element referencing does not work in safe mode, please use tight mode\n");
    4691                 exit(-2);
     4691                adolc_exit(-2,"",__func__,__FILE__,__LINE__);
    46924692#endif /* ALL_TOGETHER_AGAIN */
    46934693                break;
     
    47484748#else
    47494749                fprintf(DIAG_OUT, "ADOL-C error: active vector element referencing does not work in safe mode, please use tight mode\n");
    4750                 exit(-2);
     4750                adolc_exit(-2,"",__func__,__FILE__,__LINE__);
    47514751#endif /* !_NTIGHT_ */
    47524752                break;
     
    48524852#else
    48534853                fprintf(DIAG_OUT, "ADOL-C error: active vector element referencing does not work in safe mode, please use tight mode\n");
    4854                 exit(-2);
     4854                adolc_exit(-2,"",__func__,__FILE__,__LINE__);
    48554855#endif /* ALL_TOGETHER_AGAIN */
    48564856                }
     
    49174917#else
    49184918                fprintf(DIAG_OUT, "ADOL-C error: active vector element referencing does not work in safe mode, please use tight mode\n");
    4919                 exit(-2);
     4919                adolc_exit(-2,"",__func__,__FILE__,__LINE__);
    49204920#endif /* ALL_TOGETHER_AGAIN */
    49214921                break;
     
    52865286                        __FILE__
    52875287                        ") : no such operation %d\n", operation);
    5288                 exit(-1);
     5288                adolc_exit(-1,"",__func__,__FILE__,__LINE__);
    52895289                break;
    52905290
     
    53945394                "with %s\n              Please call enableMinMaxUsingAbs() "
    53955395                "before trace_on(%d)\n", tapeID, __FUNCTION__, tapeID);
    5396         exit(-1);
     5396        adolc_exit(-1,"",__func__,__FILE__,__LINE__);
    53975397    }
    53985398    nswitch = ADOLC_CURRENT_TAPE_INFOS.stats[NUM_SWITCHES];
Note: See TracChangeset for help on using the changeset viewer.