TMinuit in a stand-alone c++ program

Hi,
I’m using TMinuit class in a stand alone program, w/o using TFitter ( or anything that inherits from TVirtualFitter)

I got the following issue:

TMinuit *a = new TMinuit(npars);
// ... set the FCN, fitting parameters, initial values etc
a->SetMaxIterations(100000);
a->Migrad();

This seems to have no effect
a->fNfcnmx
always stays at 545
although
a->fMaxIterations does change.

this is problematic because I get sometimes
a->fCstatu = “CALL LIMIT” due to
a->fNfcn being much larger
than a->fNfcnmx

Then I looked at the code for a->Migrad() (TMinuit.cxx) :

//______________________________________________________________________________
Int_t TMinuit::Migrad()
{
// invokes the MIGRAD minimizer
   Int_t err;
   Double_t tmp = 0;

   mnexcm( "MIGRAD", &tmp, 0, err );

   return err;
}

If I run MIGRAD differently:

Double_t arglist[1] = {100000.0};
Int_t err = 0;
a->mnexcm("MIGRAD",arglist,1,err);

then the fitter converges ok and checking
a->fNfcnmx gives 100000, as I would expect.

Could it be a bug in TMinuit::Migrad()? Maybe it should do something like

//(TMinuit.cxx)
// ....
Int_t TMinuit::Migrad()
{
   Int_t err;
   Double_t tmp = (double)fMaxIterations ;
   mnexcm( "MIGRAD", &tmp, 1, err );
   return err;
}

Thank you,
Dmitri