- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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...)"
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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]
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]
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you mecej4. This way is cool. It can even pass allocatable arrays.

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page