+--------------------------------------------------------------------+
 |                                                                    |
 |               USER-DEFINED RESERVED FUNCTION EXAMPLE               |
 |                                                                    |
 +--------------------------------------------------------------------+

 If  you  wish  to  define  your own function, and have the information
 about its proper use of arguments be conveyed upon its  execution,  so
 the compiler may detect errors, then one method is to package the def-
 inition of the function in a USE module.  The function must be  listed
 in an include file whose name starts with the characters
 nonmem_reserved

 Caution:  NMTRAN  will  permit the use of such a function but will not
 compute eta deriatives with respect to the arguments.  Do not use such
 functions to compute any variable that affects the objective function!

 Here is an example.

 Myfuncmodule.f90 defines the functions mymin and mymax:

        MODULE MYFUNCS
        contains
        function mymin(a,b,c,d,e)
        integer mymin
        integer a,b,c,d,e
        mymin=min(a,b,c,d,e)
        end function
        function mymax(a,b,c,d,e)
        integer mymax
        integer a,b,c,d,e
        mymax=max(a,b,c,d,e)
        end function
        END MODULE MYFUNCS

 Nonmem_reserved_myfunc is the include file that declares its use:

 " USE myfuncs, only: mymin,mymax

 The following control stream file uses the function:

      $PROB  THEOPHYLLINE   POPULATION DATA
      $INPUT      ID DOSE=AMT TIME CP=DV WT
      $DATA       THEOPP

      $SUBROUTINES  ADVAN2 OTHER=myfuncmodule

      $PK
      ;THETA(1)=MEAN ABSORPTION RATE CONSTANT (1/HR)
      ;THETA(2)=MEAN ELIMINATION RATE CONSTANT (1/HR)
      ;THETA(3)=SLOPE OF CLEARANCE VS WEIGHT RELATIONSHIP (LITERS/HR/KG)
      ;SCALING PARAMETER=VOLUME/WT SINCE DOSE IS WEIGHT-ADJUSTED
      include "nonmem_reserved_myfunc"
         CALLFL=1
         KA=THETA(1)+ETA(1)
         K=THETA(2)+ETA(2)
         CL=THETA(3)*WT+ETA(3)
         SC=CL/K/WT
      I=mymin(1,2,3,4,5.0)
      print *,'I ',I

      $THETA  (.1,3,5) (.008,.08,.5) (.004,.04,.9)
      $OMEGA BLOCK(3)  6 .005 .0002 .3 .006 .4

      $ERROR
         Y=F+EPS(1)

      $SIGMA  .4

 If  you use the wrong argument type (real instead of integer), or per-
 haps use the wrong number of arguments, the compiler will readily flag
 this.

REFERENCES: Guide Introduction_7

  
Go to main index.
  
Created by nmhelp2html v. 1.0 written by Niclas Jonsson (Modified by AJB 5/2006,11/2007,10/2012)