Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
28 Views

Calling NAG e04ncf with ifail = 1 terminates app

I'm debugging an app in IVF that calls the NAG routine e04ncf. I have tried to use -1 and 1 for ifail but the app is still terminated by NAG.

I'm using the 32 bit intel compiler on Windows 7 32 bit and the NAG 20 library. I can run the Graph.exe example and this works Ok. 

0 Kudos
7 Replies
Highlighted
Valued Contributor II
28 Views

You give us very little information. Here a few questions:

  • Does the program print any error messages?
  • Have you checked the argument list?

It might be that you have made a mistake in the arguments (wrong type or left out an argument, for instance). That may cause the program to fail.

0 Kudos
Highlighted
Beginner
28 Views

The code used to wkr with a previous version of NAG with the same arguments.

There are no error messages.

Even if there is an argument problem, the ifail = 1 should tell the NAG library to return with an error in ifail?

The diagnositic file shows the following text:

*************************************************
 *                                               *
 *             Optimiser Tolerances              *
 *                                               *
 *************************************************
 
 Function Precision      :    0.0000000    
 Feasibility             :    0.0000000    
 Jacobian                :    0.0000000    
 Step Convergence        :    0.0000000    
 Optimality              :    0.0000000    
 Lagrange                :    0.0000000    
 Zeta                    :    0.0000000    
 Cost Convergence        :    0.0000000    
 
 *************************************************
 *                                               *
 *                Optimiser Flags                *
 *                                               *
 *************************************************
 
 Include FIXED Variables    :  No        
 NAG Calculated Gradients   :  No        
 Perturbation Gradients     :  Yes       
 Omit Technical Constraints :  No        
 Continuous Perturbations   :  No        
 Sparse Jacobian            :  No        
 Restricted Step            :  No        
 Gradient Differencing      :  One-sided 
 Fix Span                   :  No        
 Recentre                   :  No        
 De-Perturbation            :  No        
 Do NOT Optimise during FPS :  No        
 
 *************************************************
 *                                               *
 *             Optimiser Parameters              *
 *                                               *
 *************************************************
 
 Major Iterations     :     10
 Minor Iterations     :     10
 Verify Level         :      0
 Derivative Level     :      0
 Scale Factor         :    0.0000000    
 Base Step            :    0.0000000    
 Max move             :    0.0000000    
 Maximum CPU          :    0.0000000    
 Print Level          :  Partial 3 
 Perturbation         :    0.0000000    
 Line Search Accuracy :    0.0000000    
 Max Relaxation Steps :      0
 Max Hessian Resets   :      0
 Opt Hessian Diagonal :    0.0000000    
 FPS Hessian Diagonal :    0.0000000    
 
 FPS: Bad Fit Level   :    0.0000000    
 FPS: Good Fit Level  :    0.0000000    
 FPS: Reduction Factor:    0.0000000    
 FPS: Expansion Factor:    0.0000000    
 
 OPT: Bad Fit Level   :    0.0000000    
 OPT: Good Fit Level  :    0.0000000    
 OPT: Reduction Factor:    0.0000000    
 OPT: Expansion Factor:    0.0000000    
 
 *************************************************
 *                                               *
 *             Optimiser Block Names             *
 *                                               *
 *************************************************
 Plant Model              : MB_FN1    
 Cost Function            : COST_FN1  
 Cost Stream              : MONEY     
 
 Model Initialisation     :           
 Optimiser Initialisation :           
 
 Return Set-points        :           
 Inter-Iteration          :           
 
 Feasible Termination     :           
 Infeasible Termination   :           
 
********************************************************************************************************* PARAMETERS installed *****
 
***** set up VARIABLES *************************************************************************************************************
  
 Initial Values of Optimisation Variables
  Col  Variables                  Min     Unscaled          Max       Scaled
    1        VAR_FN1      -0.2000E+01   0.2000E+01   0.1000E+02   0.3333E+00
  
 Parameters for Optimisation Variables
  Col  Variables             Glob Min     Glob Max         Span        Range
    1        VAR_FN1      -0.2000E+01   0.1000E+02   0.1200E+02   0.0000E+00
 
************************************************************************************************************* VARIABLES set up *****
 
 *****************************************************
 *    Initial STATUS OF VARIABLES AND CONSTRAINTS    *
 *****************************************************
 
  Variables:
  ==========
  Col  Variables                  Min     Unscaled          Max       Scaled
    1        VAR_FN1      -.20000E+01  0.20000E+01  0.10000E+02  0.33333E+00
 
 Optim: After the initial call to PLANT MODEL
 Optim: Starting Cost                 Infinity
 1 constraint was identified as "used"
 
 ALL Constraints:
 ================
  No.  Constraints              Min         Current             Max
    1        CON_FN1    -.30000E+02     0.48000E+01     0.30000E+02
 
 Optim: Zeta of   -25.2000000000000       at Constraint            1
 Optim: The sum of c_squared is:  0.000000000000000E+000
 
***** set up JACOBIAN **************************************************************************************************************
  
 Set up Jacobian by perturbation
  
 No. of non-zero Jacobian elements:           2
  
 Location of Jacobian
 From          154  to          155
 Size :            2
 
 *** Normalization factor for constraints
 
   No.            Min      Approach           Max         Scale          Norm
     1   -0.30000E+02   0.48000E+01   0.30000E+02   0.10000E+01           NaN
  
 Initial Jacobian
 
 Jacobian matrix - zero supressed
 ... stored in DENSE form
 
 Constraint :           1  : CON_FN1   
   (Normalisation :                      NaN )
   1 VAR_FN1                           NaN
 
 Gradient Vector
 
           1  : VAR_FN1    :                      NaN
 
************************************************************************************************************** JACOBIAN set up *****
 
 Pointer Settings
  
     free:      157        x:      113   prev_x:      114   deltax:      134
      gc2:      138        g:      135   prev_g:      136   deltag:      137
    jacob:      153     hess:      139        R:        0
     bndl:      140     bndu:      143    lamda:      146
    vindx:       89    cindx:      106    state:      298    order:      300
        c:        0 ss_vindx:        0  ss_grad:        0 ss_jacob:        0
   Sindex:      303 Sparsity:      310
    iwork:        0     work:        0

 

 

0 Kudos
Highlighted
Valued Contributor II
28 Views

I am not familiar with the NAG library (that is, I have perhaps used one or two routines from it in a distant past), so I cannot help you with the details in the diagnostics file, but I do see something suspicious:

*** Normalization factor for constraints
 
   No.            Min      Approach           Max         Scale          Norm
     1   -0.30000E+02   0.48000E+01   0.30000E+02   0.10000E+01           NaN

The "NaN" that appears there might be the cause. I have no idea where it may be coming from, but it indicates some calculation is not behaving as it probably should.

As for the routine being able to detect wrong arguments:

  • If you leave out an argument in the call, the routine has no way of knowing that. It could very well try to access memory outside your program
  • If you pass the wrong real array, the routine has no way of knowing that, but it might render the calculation inconsistent
  • If you pass an array that does not actually have the size it is supposed to have, the routine has no way of knowing that and might start using information from outside the array. The result is unpredictable.

At least some of these and other mistakes can be caught by the compiler, if that has information about the interface, but not all errors can be caught that way.

0 Kudos
Highlighted
Beginner
28 Views

Yes, the Nan does looks suspicious and I have not used the NAG  routines much. I'm  C++ dev and have inherited Fortran and NAG to maintain ;-)

From reading the docs on NAG and about the IFAIL, I would think that setting the ifail=1 or -1 would prevent the abort being done. Certainly, if there is an access violation then the debug runtime would flag this up but the application is terminated without any exception handlers being hit.

0 Kudos
Highlighted
Valued Contributor II
28 Views

One way forward is to construct a small example exhibiting this behaviour that you can share. I guess that is not easy, given that you inherited the code and are not a Fortran programmer yourself. The alternative would be to contact NAG about this - see if they can offer more insight. It does not seem a problem related to the Intel compiler perse.

0 Kudos
Highlighted
Black Belt
28 Views

E04NCF is not thread-safe; E04NCA is provided if you require thread-safety, and comes with a set up routine that should be called first: E04WBF. 

The NAG library routines are for "professional use", that is, they take many arguments (22 in the case of E04NCF) for controlling the algorithm and specifying termination criteria. An error in even one of the arguments can cause the call to fail. 

The Mark-20 library is probably a decade old -- the current version is Mark-25. NAG also sells a C library, see https://www.nag.com/numeric/cl/nagdoc_cl25/html/e04/e04ncc.html .

As Arjen said (he knows, he wrote a book on such topics!), it would be best to provide working code that exhibits the problem. The problem that you ran seems to involve a rather small set of variables and constraints.

0 Kudos
Highlighted
Beginner
28 Views

I agree that it's not an Intel problem. I was hoping that the guys on the firum might have gad some insight. 

I've been trying to produce a cut down version but that will be tough as the core set of code that provides the data is quite large. I think that I'll have to contact NAG.

0 Kudos