Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29362 Discussions

[ Intel Fortran IMSL library]: Pass more variables to FCN when using NNLPF/NNLPG

Abac1
Beginner
832 Views
When using NNLPF/NNLPG in FORTRAN IMSL library, subroutine FCN is usually called to evaluate the objective function and associated constraints.

Besides the IMSL documentation, where can we find more information about NNLPF/NNLPG, especially the definition of FCN?
It seems that the the number of variables for FCN is fixed. For example, they are "CALL FCN(X,IACT,RESULT,IEER)", is it possible to pass more variables through FCN subroutine? Say,CALL NNLPF(FCN,M,ME,IBTYPE,XLB,XUB,X) while FCN takes the form "FCN(X,IACT,RESULT,IEER,AA,BB,CC...)"
0 Kudos
2 Replies
mecej4
Honored Contributor III
832 Views
The interface to the user-supplied subroutine argument FCN is fixed by VNI/Roguewave. You cannot change it.

To pass additional variables to the function (in mathematics they would be called "function parameters"), you may use COMMON blocks (deprecated) or MODULEs.

You have to assign values to AA, BB and CC before calling NNLPF/NNLPG. Once you call NNLPF/NNLPG, you should not change the values of AA, BB and CC until those subroutines return control to the caller. After NNLPF/NNLPG return control, however, you may change AA, BB or CC and call the IMSL routines again.

[fortran]MODULE VCOM DOUBLE PRECISION :: AA,BB,CC END MODULE VCOM ... PROGRAM CALLER ... USE VCOM AA = ... BB = ... CC = ... ... CONTAINS SUBROUTINE FCN(X,IACT,RESULT,IEER) ... statements that define RESULT using AA,BB,CC ... END SUBROUTINE FCN END PROGRAM CALLER[/fortran]
0 Kudos
Abac1
Beginner
832 Views
Thank you mecej4. This way is cool. It can even pass allocatable arrays.
0 Kudos
Reply