admb-project / admb

AD Model Builder
http://admb-project.org
Other
64 stars 19 forks source link

Request to turn off exit on error for sqrt #264

Closed Cole-Monnahan-NOAA closed 2 years ago

Cole-Monnahan-NOAA commented 2 years ago

In this line the program will quit early if taking sqrt(0). This makes sense as the derivative is undefined there (divide by 0). However, for MCMC and NUTS in particular, it would be preferable to skip the exit and let the program continue running as this is caught later.

So could we delete the ad_exit or disable it when in MCMC mode?

johnoel commented 2 years ago

A better alternative is to just reset ad_exit with one that does nothing (see below).

GLOBAL_SECTION
  extern "C"
  {
    void do_not_exit(const int exit_code)
    {
       // Does Nothing
    }
  }

PROCEDURE_SECTION
   ad_exit=&do_not_exit;
   .
   .
   .
Cole-Monnahan-NOAA commented 2 years ago

I suppose the downside of this approach is that it breaks the exit for all errors? An interesting approach and one that could be really useful on the user end. If you're opposed to modifying this then I'll stick with this fix.

johnoel commented 2 years ago

okay