+--------------------------------------------------------------------+
 |                                                                    |
 |                   ABBREVIATED FUNCTION EXAMPLES                    |
 |                                                                    |
 +--------------------------------------------------------------------+

 Here  is  an example of the use and construction of a function of both
 time and the first-order elimination rate constant of a simple PK one-
 compartment  model,  to  compute  the  amount in the system at a given
 time.
 (See abbreviated_function).

 $PRED
    ...
    VECTRA(1)=THETA(1)*EXP(ETA(1))
    VECTRA(2)=TIME
    ...
    A=DOSE*FUNCA(VECTRA)
    ...

 With the $ABBREVIATED  REPLACE  feature,  the  function  name  can  be |
 changed to one that is perhaps easier to understand.                   |

 $ABBR REPLACE ONE_COMPARTMENT_LINEAR=FUNCA                             |
    ...                                                                 |
 $PRED                                                                  |
    ...                                                                 |
    VECTRA(1)=THETA(1)*EXP(ETA(1))                                      |
    VECTRA(2)=TIME                                                      |
    ...                                                                 |
    A=DOSE*ONE_COMPARTMENT_LINEAR(VECTRA)                               |
    ...                                                                 |

 Either way, one needs to supply the function.

       FUNCTION FUNCA(X,X1,X2)
 ! Implements the One Compartment Linear model
       USE SIZES, ONLY: DPSIZE
       REAL(KIND=DPSIZE), INTENT(IN)     :: X
       REAL(KIND=DPSIZE), INTENT(IN OUT) :: X1,X2
       REAL(KIND=DPSIZE) :: FUNCA
       DIMENSION :: X(9),X1(9),X2(9,9)
       REAL(KIND=DPSIZE) :: EXPT
 ! THE FUNCTION ITSELF
       EXPT=EXP(-X(1)*X(2))
       FUNCA=EXPT
 ! 1ST. PARTIALS
       X1(1)=-EXPT*X(2)
       X1(2)=-EXPT*X(1)
 ! 2ND. PARTIALS
       X2(1,1)=EXPT*X(2)*X(2)
       X2(1,2)=EXPT*X(1)*X(2)
       X2(2,1)=EXPT*X(1)*X(2)
       X2(2,2)=EXPT*X(1)*X(1)
       RETURN
       END

 Suppose the above code is in file ONE_COMPARTMENT_LINEAR.f90.          |
 Then the control stream should also include                            |
 $SUBROUTINES OTHER=ONE_COMPARTMENT_LINEAR.f90                          |

 Multiple  functions can be used with the $ABBREVIATED REPLACE feature. |
 Suppose two functions are needed, called (for example) RED and  GREEN. |
 The control stream might contain the following fragment:               |

 $SUBR OTHER=red.f90 OTHER=green.f90                                    |
  ...                                                                   |
 $ABBR REPLACE RED=FUNCA                                                |
 $ABBR REPLACE GREEN=FUNCB                                              |
  ...                                                                   |
 $PRED                                                                  |
  ...                                                                   |
    VECTRA(1)=THETA(1)*EXP(ETA(1))                                      |
    VECTRA(2)=TIME                                                      |
    A=DOSE*RED(VECTRA)                                                  |
    B=DOSE*GREEN(VECTRA)                                                |
  ...                                                                   |

 The  file red.f90 contains code for FUNCA, and the file green.f90 con-
 tains code for FUNCB.

 The $ABBREVIATED REPLACE feature could also be used  to  provide  more |
 meaningful  names for reserved vectors. For example, suppose the argu- |
 ments of the functions are different vectors.                          |

 $ABBR REPLACE RED=FUNCA, REDARG=VECTRA                                 |
 $ABBR REPLACE GREEN=FUNCB, GREENARG=VECTRB                             |
  ...                                                                   |
 $PRED                                                                  |
  ...                                                                   |
    REDARG(1)=...                                                       |
    REDARG(2)=...                                                       |
    GREENARG(1)=...                                                     |
    GREENARG(2)=...                                                     |
    A=DOSE*RED(REDARG)                                                  |
    B=DOSE*GREEN(GREENARG)                                              |
  ...                                                                   |

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)