<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Problems with interface and function in Intel® Fortran Compiler</title>
    <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Problems-with-interface-and-function/m-p/748727#M5834</link>
    <description>I have edited all code of both files in my first post - have a look now. To recap: the interface of the first file, CUBATR, is not implemented correctly in the second file, MATH - possibly the function INTEGRAND in the second file gives problems.</description>
    <pubDate>Tue, 03 Aug 2010 08:51:40 GMT</pubDate>
    <dc:creator>aryangor</dc:creator>
    <dc:date>2010-08-03T08:51:40Z</dc:date>
    <item>
      <title>Problems with interface and function</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Problems-with-interface-and-function/m-p/748725#M5832</link>
      <description>This is part of the module with the interface in it:&lt;BR /&gt;&lt;BR /&gt;&lt;PRE&gt;[fortran]&lt;PRE name="code" class="fortran"&gt;           !------------------------!
           ! Cubpack User Interface !
           !------------------------!
Module CUI

USE Precision_Model
USE internal_types

Implicit NONE

PRIVATE

PUBLIC :: CUBATR, CUBPACK_INFO
&lt;BR /&gt;PRIVATE :: CUBATR_X, CUBATR_1, CUBATR_CLEAR

!
! Module variables
!
INTEGER, SAVE, PRIVATE :: PreJob=0
INTEGER, PRIVATE                :: BOTTIH,BOTTRH
INTEGER,         DIMENSION(:), PRIVATE, ALLOCATABLE  :: IWork
REAL(kind=stnd), DIMENSION(:), PRIVATE, ALLOCATABLE  :: RWork
TYPE(EPSALG_MEM), PRIVATE              :: M

INTERFACE CUBATR
   MODULE PROCEDURE CUBATR_X, CUBATR_1, CUBATR_CLEAR
END INTERFACE

CONTAINS

SUBROUTINE CUBATR_X     &amp;amp;
     (DIMENS,NumFun,Integrand,NumRgn,Vertices,RgType,Value,AbsErr,    &amp;amp;
!   and optional parameters
IFAIL,Neval,EpsAbs,EpsRel,Restart,MinPts,MaxPts,Key,Job,Tune)
!-----------------------------------------------------------------------
!   Input parameters
!   ----------------
!
!   DIMENS Integer.
!          The dimension of the region of integration.
!
!   NumFun Integer.
!          Number of components of the integrand.
!
!   Integrand
!          Externally declared function for computing all components
!          of the integrand at the given evaluation point.
!          It must have input parameter X:
!              X(1)   The x-coordinate of the evaluation point.
!              X(2)   The y-coordinate of the evaluation point.
!              ...
!              X(DIMENS) The z-coordinate of the evaluation point.
!         and NumFun, the number of components of the integrand.
!         It must be compatible with the following interface:
!           INTERFACE 
!              FUNCTION Integrand(NUMFUN,X) RESULT(Value)
!                USE Precision_Model
!                INTEGER, INTENT(IN) :: NUMFUN
!                REAL(kind=stnd), DIMENSION(:), INTENT(IN) :: X
!                REAL(kind=stnd), DIMENSION(NUMFUN) :: Value
!              END FUNCTION Integrand
!           END INTERFACE
!
!   NumRgn Integer.
!          The number of given regions.
!
!   Vertices
!          Real array of dimension (DIMENS,DIMENS+1,NumRgn).
!          Vertices(1:DIMENS,K,L) are the x, y, ... coordinates
!          respectively of vertex K of region L, where
!          K = 1,...,DIMENS+1 and L = 1,...,NumRgn.
!
!   RgType Integer array of dimension (NumRgn).
!          RgType(L) describes the type of region L.
!
!   Value  Real array of dimension NumFun.
!          Approximations to all components of the integral if
!          the procedure is restarted.
!
!   AbsErr Real array of dimension NumFun.
!          Estimates of absolute errors if the procedure is restarted.
!
!   IFAIL  Optional integer argument.
!          This follows the NAG convention:
!          IFAIL = 1 : soft silent error
!                      Control returned to calling program.
!          IFAIL = -1: soft noisy error
!                      Error message is printed.
!                      Control returned to calling program.
!          IFAIL = 0 : hard noisy error
!                      Error message is printed and program is stopped.
!          Default IFAIL = -1.
!
!   EpsAbs Optional real argument.
!          Requested absolute error.
!          Default  EpsAbs = 0.
!
!   EpsRel Optional real argument.
!          Requested relative error.
!          Default EpsRel = sqrt(machine precision).
!
!   Restart Optional boolean argument.
!          If Restart = FALSE, this is the first attempt to compute
!                              the integral.
!          If Restart = TRUE, then we restart a previous attempt.
!          In this case the only parameters for CUBATR that may
!          be changed (with respect to the previous call of CUBATR)
!          are MinPts, MaxPts, EpsAbs, EpsRel, Key and Restart.
!          Default Restart = FALSE.
!
!   MinPts Optional integer argument.
!          The minimum allowed number of integrand evaluations.
!          Default MinPts = 0.
!
!   MaxPts Optional integer argument.
!          The maximum allowed number of integrand evaluations.
!          Default MaxPts = enough to do 500 subdivisions.
!
!   Key    Optional integer argument.
!          Can be used by Rule_General to choose between several
!          local integration rules.
!          Default Key = 2 if Dimension=1 and extrapolation is used 
!                                        (This corresponds to QAGS)
!          Default Key = 0 otherwise
!
!   Job    Optional integer argument.
!          If |Job| = 0, then nothing will be done except freeing all
!                        allocated memory.
!                        This is usefull after a call of CUBATR if no
!                        Restart will be done later and memory usage
!                        might become an issue later.
!                        Equivalently, one can call CUBATR()
!                        without any arguments.
!                   = 1, the global adaptive algorithm is called
!                   = 2, extrapolation using the epsilon algorithm is used.
!                   = 11, a region will be divided in 2**DIMENS subregions
!                        and the global adaptive algorithm is called.
!                        In combination with Key=0, this resembles DUCTRI and DCUTET.
!                   = 12, a region will be divided in 2 subregions
!                        and the global adaptive algorithm is called.
!                        In combination with Key=3 or 4, this resembles DCUHRE.
!          If Job &amp;lt; 0, then an overview of the Region Collection is dumped.
!          This will create the files tmp_integerstore and tmp_realstore.
!          Default Job = 1.
!
!   Tune   Optional real argument.
!          Can be used by Global_Adapt or the local error estimators
!          to influence the reliability. 0 &amp;lt;= Tune &amp;lt;= 1.
!          Tune = 1 is the most reliable available.
!          Default Tune = 1.
!          Note that this is an experimental and controversial parameter.
!          In this version, only Tune = 1 is supported for all regions.
!
!   Output parameters
!   -----------------
!
!   Value  Real array of dimension NumFun.
!          Approximations to all components of the integral
!
!   AbsErr Real array of dimension NumFun.
!          Estimates of absolute errors.
!
!   NEval  Optional Integer.
!          Number of integrand evaluations used by CUBATR for this call.
!
!   IFAIL  Optional Integer.
!          IFAIL = 0 for normal exit.
!
!            AbsErr(K) &amp;lt;=  EpsAbs or
!            AbsErr(K) &amp;lt;=  ABS(Value(K))*EpsRel with MaxPts or less
!            function evaluations for all values of K,
!            1 &amp;lt;= K &amp;lt;= NumFun .
!
!          IFAIL = 1 if MaxPts was too small to obtain the required
!            accuracy. In this case Global_Adapt returns values of
!            Value with estimated absolute errors AbsErr.
!
!          IFAIL &amp;gt; 1 in more serious case of trouble.
!-----------------------------------------------------------------------
! MODULES USED
USE Check_Input
USE Error_Handling
USE DS_ROUTINES, ONLY: DSCOPY, DSINIT, DSUSED, DSSTAT, DSSUM, DSPINT
USE CubatureRule_General, ONLY: Rule_Cost
USE Global_Adaptive_Algorithm
!***END PROLOGUE CUBATR
!-----------------------------------------------------------------------
!
! Global variables
!
INTERFACE 
   FUNCTION Integrand(NUMFUN,X) RESULT(Value)
     USE Precision_Model
     INTEGER, INTENT(IN) :: NUMFUN
     REAL(kind=stnd), DIMENSION(:), INTENT(IN) :: X
     REAL(kind=stnd), DIMENSION(NUMFUN) :: Value
   END FUNCTION Integrand
END INTERFACE
INTEGER, INTENT(IN)               :: DIMENS,NumFun,NumRgn
INTEGER, DIMENSION(:), INTENT(IN) :: RgType
LOGICAL, INTENT(IN),    OPTIONAL  :: Restart
INTEGER, INTENT(OUT),   OPTIONAL  :: NEval
INTEGER, INTENT(IN),    OPTIONAL  :: Job,Key,MaxPts,MinPts
INTEGER, INTENT(IN OUT), OPTIONAL  :: IFAIL
REAL(kind=stnd), INTENT(IN), OPTIONAL :: Tune,EpsAbs,EpsRel
REAL(kind=stnd), INTENT(IN), DIMENSION(:,:,:) :: Vertices
REAL(kind=stnd), INTENT(IN OUT), DIMENSION(:)  :: AbsErr, Value
!
! Named constants
!
INTEGER, PARAMETER ::  NRINFO=1, NIINFO=5
!
!  Local variables
!
INTEGER :: BLOCK,i,Inform,Leval,LJob,LMaxPts,LMinPts,MinCost, &amp;amp;
           NRVERT,NrSub,NRVACA,MAXRGN,RULCLS,STATUS,Tmp
LOGICAL                                     :: EpsAlg,LRestart
REAL(kind=stnd)                             :: LEpsAbs, LEpsRel
REAL(kind=stnd), DIMENSION(:), ALLOCATABLE  :: TmpRWork
INTEGER,    DIMENSION(:), ALLOCATABLE       :: TmpIWork
TYPE(INTEGRATOR_INFO)                       :: CINFO
TYPE(USER_INFO)                             :: UINFO
!-----------------------------------------------------------------------
!
! Check array sizes
!      Array size mismatch results in hard error.
   Inform = 0
   IF (size(rgtype) &amp;lt; numrgn) THEN
       write(unit=*,fmt=*) "Error: size(rgtype) &amp;lt; numrgn"
       Inform = Inform + 1
   END IF
   IF (size(abserr) &amp;lt; numfun) THEN
       write(unit=*,fmt=*) "Error: size(abserr) &amp;lt; numfun"
       Inform = Inform + 1
   END IF
   IF (size(Value) &amp;lt; numfun) THEN
       write(unit=*,fmt=*) "Error: size(Value) &amp;lt; numfun"
       Inform = Inform + 1
   END IF
   IF ((size(vertices,1) /= dimens) .or. (size(vertices,2) /= dimens+1) &amp;amp;
          .or. (size(vertices,3) &amp;lt; numrgn)) THEN
       Inform = Inform + 1
       write(unit=*,fmt=*)"Error: size(vertices) /= (/dimens,dimens+1,numrgn/)"
   END IF
   IF (Inform /= 0) THEN
      WRITE(unit=*,fmt=*)  "Array size mismatch results in hard error."
      STOP   ! "Array size mismatch results in hard error."
   END IF

!-----------------------------------------------------------------------
IF (PRESENT(NEval)) THEN
    NEval = 0
END IF
!-----------------------------------------------------------------------
IF (PRESENT(Job)) THEN
    LJob = Job
    IF (Job == 0) THEN
       CALL CUBATR_CLEAR()
       RETURN
    END IF
 ELSE
    LJob = 1 
END IF
!-----------------------------------------------------------------------
!
! Set optional arguments
!
IF ( PRESENT(Restart)) THEN 
                              LRestart = Restart
                       ELSE 
                              LRestart = .FALSE.
END IF
IF ( PRESENT(Key)) THEN 
                        CINFO%Key = Key
                   ELSE 
                       IF ((ABS(LJob) == 2) .AND. (DIMENS == 1)) THEN
                           CINFO%Key = 2   ! simulate QAGS
                       ELSE
                           CINFO%Key = 0
                       END IF
END IF
!-----------------------------------------------------------------------
!
!  Check input parameters
!
IF ( .NOT. LRestart) THEN
         CALL CHECK(DIMENS,NumFun,NumRgn,RgType,Inform, &amp;amp;
                    LJob,IFAIL,EpsAbs,EpsRel,MinPts,MaxPts,Tune)
ELSE IF ( ALLOCATED(IWork) ) THEN
         CALL CHECK(DIMENS,NumFun,BOTTRH,BOTTIH,IWork,  &amp;amp;
                    Inform,LJob,IFAIL,EpsAbs,EpsRel,MinPts,MaxPts,Tune)
ELSE
   Inform = 4096  ! There is nothing to restart from
END IF
IF (Inform /= 0) THEN 
    CALL Handle_Error(Inform,IFAIL)
    RETURN
END IF
!-----------------------------------------------------------------------
RULCLS = Rule_Cost( DIMENS, RgType(1), CINFO%Key )
MinCost = RULCLS
DO i = 2,NumRgn
   Tmp = Rule_Cost( DIMENS, RgType(i), CINFO%Key)
   RULCLS = max(RULCLS,Tmp)
   MinCost = MinCost + Tmp
END DO
!-----------------------------------------------------------------------
!
! Set optional arguments
!
   
IF ( PRESENT(MinPts)) THEN 
                              LMinPts = MinPts
                      ELSE 
                              LMinPts = 0
END IF
IF ( PRESENT(MaxPts)) THEN 
                              LMaxPts = MaxPts
                      ELSE 
                              LMaxPts = 500*RULCLS
END IF
IF ( PRESENT(Tune)) THEN 
                              CINFO%Tune = Tune
                    ELSE 
                              CINFO%Tune = 1
END IF
IF ( PRESENT(EpsAbs)) THEN 
                              LEpsAbs = EpsAbs
                      ELSE 
                              LEpsAbs = 0
END IF
IF ( PRESENT(EpsRel)) THEN 
                              LEpsRel = EpsRel
                      ELSE 
                              LEpsRel = SQRT(EPSILON(LEpsRel))
END IF
!-----------------------------------------------------------------------
!
! Set other parameters of the Global Adaptive algorithm
!      
!
!  NrSub is an upper limit for the number of subregions after subdivision.
!  This influence memory managment, so don't exagerate here.
IF (DIMENS &amp;lt;= 3) THEN 
                              NrSub = 2**DIMENS
                 ELSE 
                              NrSub = 4
END IF
!
EpsAlg = ( ABS(LJob) == 2 )
CINFO%UNIFORM_SUBDIV = EpsAlg
CINFO%NrSub = NrSub

IF (( ABS(LJob) == 11) .AND. (DIMENS &amp;lt;= 3)) THEN
   ! simulate dcutri and dcutet ; NrSub = 2**DIMENS ; EpsAlg = .FALSE.
   CINFO%UNIFORM_SUBDIV = .TRUE.
END IF

IF ( ABS(LJob) == 12 ) THEN
   ! simulate dcuhre; NrSub = 2 ; EpsAlg = .FALSE.
   CINFO%NrSub = 2
END IF

NRVERT = DIMENS + 1   ! Only cubes and simplices are implemented here.

UINFO%NumFun = NumFun  
UINFO%NumRgn = NumRgn
UINFO%MinPts = LMinPts 
UINFO%MaxPts = LMaxPts
UINFO%EpsAbs = LEpsAbs 
UINFO%EpsRel = LEpsRel
!-----------------------------------------------------------------------
IF (LRestart) THEN
  ! This requires allocating larger arrays and copying
  ! the region collection.
  ALLOCATE(TmpRWork(SIZE(RWork)),STAT=status)
  IF (status /=  0) THEN
     WRITE(unit=*,fmt=*)  "Problem allocating real workspace."
     STOP  !  "Problem allocating real workspace."
  END IF
  ALLOCATE(TmpIWork(SIZE(IWork)),STAT=status)
  IF (status /=  0) THEN
     WRITE(unit=*,fmt=*) "Problem allocating integer workspace."
     STOP  ! "Problem allocating integer workspace."
  END IF
  MAXRGN = DSUSED(IWork)
  CALL DSCOPY(IWork,RWork,TmpIWork,TmpRWork)
ELSE
  MAXRGN = NumRgn
END IF
!-----------------------------------------------------------------------
! NRVACA is the number of regions the global adaptive algorithm
!        removes from the data structure for further processing.
!        In some routines for shared memory parallel machines
!        this is the variable MDIV
NRVACA = 1
! MAXRGN depends on the number of function evalutions
MAXRGN = MAXRGN + 1 + (NrSub-1)*(LMaxPts - RULCLS*NumRgn)/(RULCLS*NrSub)
!
! Compute length of workspace needed.
!
BOTTIH = MAXRGN*(1+NIINFO) + 15 + NRVACA
BLOCK = NRINFO+NRVERT*DIMENS+2*NumFun
IF (NumFun &amp;gt; 1) THEN
    BLOCK = BLOCK + 1
END IF
BOTTRH = MAXRGN*BLOCK
!
! Allocate space for the region collection
!
IF (ALLOCATED(RWork)) THEN
    DEALLOCATE(RWork)
END IF
ALLOCATE(RWork(BOTTRH),STAT=status)
IF (status /=  0) THEN
   WRITE(unit=*,fmt=*) "Problem allocating real workspace."
   STOP  ! "Problem allocating real workspace."
END IF
IF (ALLOCATED(IWork)) THEN
   DEALLOCATE(IWork)
END IF
ALLOCATE(IWork(BOTTIH),STAT=status)
IF (status  /=  0) THEN
   WRITE(unit=*,fmt=*) "Problem allocating integer workspace."
   STOP  ! "Problem allocating integer workspace."
END IF
!
! Initialise region collection
!
IF ( LRestart) THEN
    CALL DSCOPY(TmpIWork,TmpRWork,IWork,RWork)
    DEALLOCATE(TmpIWork,TmpRWork)
ELSE
   IF ( MinCost &amp;gt; LMaxPts ) THEN
       Inform = 128    ! Dit nummer werd al gebruikt !
   ELSE
       CALL DSINIT(DIMENS,NRVERT,NIINFO,NRINFO,NumFun,NRVACA,   &amp;amp;
                   BOTTIH,BOTTRH,IWork,Inform)
   END IF
   IF (Inform /= 0) THEN 
       CALL Handle_Error(Inform,IFAIL)
       RETURN
   END IF
END IF
!-----------------------------------------------------------------------
!
!  Call integration routine
!
If (EpsAlg) THEN
   IF ( LRestart .AND. (PreJob /= ABS(LJob))) THEN
      Inform = 3
   ELSE
      ! Observe that only relevant array sections are passed !
      CALL Global_Adapt_Extrap(DIMENS,CINFO,UINFO,NRVERT,NIINFO,    &amp;amp;
                     NRINFO, Vertices(1:DIMENS,1:NRVERT,1:NUMRGN),  &amp;amp;
                     RgType(1:NUMRGN),Integrand,LRestart,           &amp;amp;
                     Value(1:NUMFUN),AbsErr(1:NUMFUN),LEval,Inform, &amp;amp;
                     RWork,IWork,M)
   END IF
ELSE
   IF ( LRestart .AND. (PreJob /= LJob)) THEN
       IF ( ASSOCIATED(M%RESLA)) THEN
           DEALLOCATE(M%RESLA,M%ERLARG,M%RESULT1,M%ABSERR1,M%RCOPY)
       END IF
       CALL DSPINT(IWork,RWork)
       CALL DSSUM(Value,Abserr,IWork,RWork,Inform)
   END IF
   ! Observe that only relevant array sections are passed !
   CALL Global_Adapt(DIMENS,CINFO,UINFO,NRVERT,NIINFO,NRINFO,    &amp;amp;
                  Vertices(1:DIMENS,1:NRVERT,1:NUMRGN),          &amp;amp;
                  RgType(1:NUMRGN),Integrand,LRestart,           &amp;amp;
                  Value(1:NUMFUN),AbsErr(1:NUMFUN),LEval,Inform, &amp;amp;
                  RWork,IWork)
END IF
IF (PRESENT(NEval)) THEN
   NEval = LEval
END IF
!-----------------------------------------------------------------------
 IF (LJob &amp;lt; 0) THEN
    WRITE(unit=*,fmt=*) "Debug mode: dumping region collection overview."
    CALL DSSTAT(IWork(:),RWork(:))          ! For debugging.
 END IF
!-----------------------------------------------------------------------
! IF ((Inform &amp;gt;= 8) .or. (Inform == 3)) THEN
!    Something went wrong but the data structure remains untouched
!    and so this call can be ignored.
IF ((Inform &amp;lt; 8) .AND. (Inform /= 3)) THEN
   PreJob = ABS(LJob)
END IF
CALL Handle_Error(Inform,IFAIL)
RETURN
END SUBROUTINE CUBATR_X


SUBROUTINE CUBATR_1                                              &amp;amp;
     (DIMENS,Integrand,SVertices,SRgType,SValue,SAbsErr,         &amp;amp;
!   and optional parameters                                      &amp;amp; 
      IFAIL,Neval,EpsAbs,EpsRel,Restart,MaxPts,Key,Job)
!-----------------------------------------------------------------------
!   Input parameters
!   ----------------
!
!   DIMENS Integer.
!          The dimension of the region of integration.
!
!   Integrand
!          Externally declared function for computing all components
!          of the integrand at the given evaluation point.
!          It must have input parameter X:
!              X(1)   The x-coordinate of the evaluation point.
!              X(2)   The y-coordinate of the evaluation point.
!              ...
!              X(DIMENS) The z-coordinate of the evaluation point.
!         and NumFun, the number of components of the integrand.
!         It must be compatible with the following interface:
!           INTERFACE 
!              FUNCTION Integrand(NUMFUN,X) RESULT(Value)
!                USE Precision_Model
!                INTEGER, INTENT(IN) :: NUMFUN
!                REAL(kind=stnd), DIMENSION(:), INTENT(IN) :: X
!                REAL(kind=stnd), DIMENSION(NUMFUN) :: Value
!              END FUNCTION Integrand
!           END INTERFACE
!
!   SVertices
!          Real array of dimension (DIMENS,DIMENS+1).
!          Vertices(1:DIMENS,K) are the x, y, ... coordinates
!          respectively of vertex K of the region, where
!          K = 1,...,DIMENS+1.
!
!   SRgType Integer.
!          RgType describes the type of region L.
!
!   SValue Real.
!          Approximation to the integral if the procedure is restarted.
!
!   SAbsErr Real.
!          Estimate of the absolute error if the procedure is restarted.
!
!   IFAIL  Optional integer argument.
!          This follows the NAG convention:
!          IFAIL = 1 : soft silent error
!                      Control returned to calling program.
!          IFAIL = -1: soft noisy error
!                      Error message is printed.
!                      Control returned to calling program.
!          IFAIL = 0 : hard noisy error
!                      Error message is printed and program is stopped.
!          Default IFAIL = -1.
!
!   EpsAbs Optional real argument.
!          Requested absolute error.
!          Default  EpsAbs = 0.
!
!   EpsRel Optional real argument.
!          Requested relative error.
!          Default EpsRel = sqrt(machine precision).
!
!   Restart Optional boolean argument.
!          If Restart = FALSE, this is the first attempt to compute
!                              the integral.
!          If Restart = TRUE, then we restart a previous attempt.
!          In this case the only parameters for CUBATR that may
!          be changed (with respect to the previous call of CUBATR)
!          are MinPts, MaxPts, EpsAbs, EpsRel, Key and Restart.
!          Default Restart = FALSE.
!
!   MaxPts Optional integer argument.
!          The maximum allowed number of integrand evaluations.
!          Default MaxPts = enough to do 500 subdivisions.
!
!   Key    Optional integer argument.
!          Can be used by Rule_General to choose between several
!          local integration rules.
!          Default Key = 2 if Dimension=1 and extrapolation is used 
!                                        (This corresponds to QAGS)
!          Default Key = 0 otherwise
!
!   Job    Optional integer argument.
!          If |Job| = 0, then nothing will be done except freeing all
!                        allocated memory.
!                        This is usefull after a call of CUBATR if no
!                        Restart will be done later and memory usage
!                        might become an issue later.
!                        Equivalently, one can call CUBATR()
!                        without any arguments.
!                   = 1, the global adaptive algorithm is called
!                   = 2, extrapolation using the epsilon algorithm is used.
!                   = 11, a region will be divided in 2**DIMENS subregions
!                        and the global adaptive algorithm is called.
!                        In combination with Key=0, this resembles DUCTRI and DCUTET.
!                   = 12, a region will be divided in 2 subregions
!                        and the global adaptive algorithm is called.
!                        In combination with Key=3 or 4, this resembles DCUHRE.
!          If Job &amp;lt; 0, then an overview of the Region Collection is dumped.
!          This will create the files tmp_integerstore and tmp_realstore.
!          Default Job = 1.
!
!   Output parameters
!   -----------------
!
!   SValue Real.
!          Approximation to the integral
!
!   AbsErr Real.
!          Estimate of the absolute error.
!
!   NEval  Optional Integer.
!          Number of integrand evaluations used by CUBATR for this call.
!
!   IFAIL  Optional Integer.
!          IFAIL = 0 for normal exit.
!
!            AbsErr(K) &amp;lt;=  EpsAbs or
!            AbsErr(K) &amp;lt;=  ABS(Value(K))*EpsRel with MaxPts or less
!            function evaluations for all values of K,
!            1 &amp;lt;= K &amp;lt;= NumFun .
!
!          IFAIL = 1 if MaxPts was too small to obtain the required
!            accuracy. In this case Global_Adapt returns values of
!            Value with estimated absolute errors AbsErr.
!
!          IFAIL &amp;gt; 1 in more serious case of trouble.
!-----------------------------------------------------------------------
!
! Global variables
!
INTERFACE 
   FUNCTION Integrand(NUMFUN,X) RESULT(Value)
      USE Precision_Model
      INTEGER, INTENT(IN) :: NUMFUN
      REAL(kind=stnd), DIMENSION(:), INTENT(IN) :: X
      REAL(kind=stnd), DIMENSION(NUMFUN) :: Value
   END FUNCTION Integrand
END INTERFACE
LOGICAL, OPTIONAL, INTENT(IN)                 :: Restart
INTEGER, INTENT(IN)                           :: DIMENS,SRgType
INTEGER, INTENT(OUT), OPTIONAL                :: NEval
INTEGER, INTENT(IN), OPTIONAL                 :: Key,MaxPts,Job
INTEGER, INTENT(IN OUT), OPTIONAL             :: IFAIL
REAL(kind=stnd), INTENT(IN), OPTIONAL         :: EpsAbs,EpsRel
REAL(kind=stnd), DIMENSION(:,:), INTENT(IN)   :: SVertices
REAL(kind=stnd), INTENT(IN OUT)               :: SValue,SAbsErr
!
! Local variables
!
INTEGER, DIMENSION(1)                         :: RgType
REAL(kind=stnd), DIMENSION(1)                 :: Value, AbsErr
REAL(kind=stnd), DIMENSION(DIMENS,DIMENS+1,1) :: Vertices
!-------------------
RgType(1) = SRgType
Vertices(:,:,1) = SVertices
IF (PRESENT(Restart)) THEN
    IF ( Restart ) THEN
       Value(1) = SValue
       AbsErr(1) = SAbsErr
    END IF
END IF
CALL CUBATR             &amp;amp;
  (DIMENS,1,Integrand,1,Vertices,RgType,Value,AbsErr,        &amp;amp;
   !   and optional parameters                               &amp;amp;
   ifail=IFAIL,neval=Neval,epsabs=EpsAbs,epsrel=EpsRel,      &amp;amp;
   restart=Restart,maxpts=MaxPts,key=key,job=Job)
SValue = Value(1)
SAbsErr = AbsErr(1)
RETURN
END SUBROUTINE CUBATR_1

SUBROUTINE CUBATR_CLEAR()
  IF ( ALLOCATED(Iwork) ) THEN
     DEALLOCATE(RWork,IWork)
  END IF
  IF ( ASSOCIATED(M%RESLA)) THEN
     DEALLOCATE(M%RESLA,M%ERLARG,M%RESULT1,M%ABSERR1,M%RCOPY)
  END IF
  PreJob = 0
  RETURN
END SUBROUTINE CUBATR_CLEAR

SUBROUTINE CUBPACK_INFO()

REAL(kind=stnd) :: x=1.0e-30  ! lowest accuracy of cubature formula constants

print *," ---------------------------------------------------------------"
print *,"              CUBPACK information"
print *,"              -------------------"
print *," The model for real numbers in the current installed version,"
print *," obtained with the declaration REAL(KIND=stnd), has the"
print *," following characteristics:"
print *,"                base =  ",radix(x)
print *," digits in this base = ", digits(x)
! print *," highest exponent = ", maxexponent(x)
! print *," lowest exponent = "minexponent(x), "(normalized numbers)
print *," This implies:"
print *,"            machine epsilon = ",epsilon(x)
print *,"        largest real number = ", huge(x)
print *," smallest normalized number = ", tiny(x)
print *
print *," The lowest relative error that may be obtained with this"
print "(""  version is about "",G8.2)",max(50*epsilon(x),x)
print *," Asking for lower error will push the routine to use the"
print *," maximal number of function evaluations it is allowed."
print *
print *
print *," This version accepts a collection of hyper-rectangles"
print *,"   (and parallelepipeds) and simplices as integration regions."
print *," Extrapolation using the epsilon-algorithm is available"
print *,"      for dimensions 1, 2 and 3."
print *," The following values of KEY give different integration rules:"
print *," - finite interval: KEY = 1, 2, 3, 4, 5."
print *,"      KEY &amp;lt; 1 defaults to 1; KEY &amp;gt; 5 defaults to 5."
print *," - n-cube:          KEY = 3, 4       uses rule of degree 2*KEY+1"
print *,"           otherwise, uses for a square a rule of degree 13"
print *,"                                 3-cube a rule of degree 11"
print *,"                                        a rule of degree  7"
print *," - n-simplex:       KEY = 1, 2, 3, 4 uses rule of degree 2*KEY+1" 
print *,"         otherwise, uses for a triangle a rule of degree 13"
print *,"                            tetrahedron a rule of degree  8"
print *,"                                        a rule of degree  7"
print *," KEY = 0 corresponds to our preferred choice."
print *," ---------------------------------------------------------------"

RETURN
END SUBROUTINE CUBPACK_INFO

END Module CUI[/fortran]&lt;/PRE&gt; &lt;BR /&gt;&lt;/PRE&gt; ------------------------&lt;BR /&gt;Here is the part of the actual program that calls the interface:&lt;BR /&gt;&lt;BR /&gt;&lt;PRE&gt;[fortran]&lt;PRE name="code" class="fortran"&gt;MODULE math
  USE cui
!***************************************************[ CONSTANTS ]*****************************************************!
  REAL, PUBLIC, PARAMETER :: PI = 3.14159265358979
  REAL, PUBLIC, PARAMETER :: TWOPI = 6.28318530717958
  REAL, PUBLIC, PARAMETER :: SQRTPI = 1.77245385090552
!***************************************************[ VARIABLES ]*****************************************************!
  REAL, PRIVATE           :: gammafnarg      ! Argument of the gamma function
!***************************************************[ FUNCTIONS ]*****************************************************!
  PRIVATE :: Integrand
  
  PUBLIC  :: gammafn
  PUBLIC  :: betafn
  PUBLIC  :: factorial
  PUBLIC  :: linint
  PUBLIC  :: polint
  PUBLIC  :: polin2
  PUBLIC  :: spline, splint
  PUBLIC  :: deriv
  PUBLIC  :: zbrac
  PUBLIC  :: rtbis
!  PUBLIC  :: broydn
!  PUBLIC  :: lnsrch
  PUBLIC  :: logvec, linvec
  PUBLIC  :: addsubdev, productdev, quotientdev, powerdev, constdev
  PUBLIC  :: heavyside
!*********************************************************************************************************************!
  CONTAINS
!*************************************************[ GAMMA FUNCTION ]**************************************************!
  FUNCTION gammafn( x )
  
    REAL, INTENT( IN ) :: x                     ! Argument of the gamma function
    REAL               :: gammafn
    
    ! Local variables
    INTEGER, PARAMETER          :: n=1          ! Dimension of integration
    INTEGER, PARAMETER          :: rgtype=1     ! Region type
    REAL                        :: result      ! Result of integration
    REAL                        :: abserr       ! Absolute error on integration
    REAL, DIMENSION( 1:n, 0:n ) :: vertices
    REAL                        :: prod
    
    vertices( 1, : ) = (/ 0.0 , 1.0 /)          ! Boundaries of integration
    gammafnarg = x
    prod = 1.0
    
    ! Do some recursion if the argument is less than unity
    DO WHILE ( gammafnarg &amp;lt; 1.0 )
      prod = prod * gammafnarg
      gammafnarg = gammafnarg + 1.0
    END DO
    
    ! Do the integration...
    CALL CUBATR(n,Integrand,vertices,rgtype,result,abserr)
            
    gammafn = result / prod
    
    RETURN
  END FUNCTION gammafn
!*********************************************************************************************************************!
   FUNCTION Integrand(NUMFUN,X) RESULT(Value)
     USE Precision_Model
     INTEGER, INTENT(IN) :: NUMFUN
     REAL(kind=stnd), DIMENSION(:), INTENT(IN) :: X
     REAL(kind=stnd), DIMENSION(NUMFUN) :: Value
     Value( 1 ) = ( -LOG( x( 1 ) ) )**( gammafnarg - 1.0 )
   END FUNCTION Integrand

END MODULE math[/fortran]&lt;/PRE&gt; &lt;BR /&gt;&lt;/PRE&gt; ------------------------------&lt;BR /&gt;When I compile the first module, there is no problem. When I compile the module(s) that depend on implementing the interface CUBATR, I get the following error:&lt;BR /&gt;&lt;BR /&gt;&lt;PRE&gt;[plain]math.f90(74): error #6285: There is no matching specific subroutine for this generic subroutine call.   [CUBATR]&lt;BR /&gt;    CALL CUBATR(n,Integrand,vertices,rgtype,result,abserr)&lt;BR /&gt;---------^&lt;BR /&gt;compilation aborted for math.f90 (code 1)&lt;BR /&gt;make: *** [math.o] Error 1&lt;BR /&gt;[/plain]&lt;/PRE&gt; ---------------------------&lt;BR /&gt;I suspect that the problem arises because the interface receives a parameter of varying size. What can you advese me about it? Do you need to see more code? Thanks!!&lt;DIV style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow: hidden;" id="_mcePaste"&gt; !------------------------!&lt;BR /&gt; ! Cubpack User Interface !&lt;BR /&gt; !------------------------!&lt;BR /&gt;Module CUI&lt;BR /&gt;&lt;BR /&gt;USE Precision_Model&lt;BR /&gt;USE internal_types&lt;BR /&gt;&lt;BR /&gt;Implicit NONE&lt;BR /&gt;&lt;BR /&gt;PRIVATE&lt;BR /&gt;&lt;BR /&gt;PUBLIC :: CUBATR, CUBPACK_INFO&lt;BR /&gt;!-----------------------------------------------------------------------&lt;BR /&gt;!***BEGIN PROLOGUE CUBATR&lt;BR /&gt;!***DATE WRITTEN 901114 (YYMMDD)&lt;BR /&gt;!***REVISION DATE 970620 (YYMMDD)&lt;BR /&gt;!***REVISION DATE 980406 (YYMMDD) (MDIV removed)&lt;BR /&gt;!***REVISION DATE 000809 (YYMMDD)&lt;BR /&gt;!***REVISION DATE 010719 (YYMMDD)&lt;BR /&gt;!***REVISION DATE 020715 (YYMMDD) (CUBPACK_INFO added)&lt;BR /&gt;!***AUTHOR&lt;BR /&gt;! Ronald Cools, Dept. of Computer Science,&lt;BR /&gt;! Katholieke Universiteit Leuven, Celestijnenlaan 200A,&lt;BR /&gt;! B-3001 Heverlee, Belgium&lt;BR /&gt;! Email: Ronald.Cools@cs.kuleuven.ac.be&lt;BR /&gt;!&lt;BR /&gt;!***PURPOSE Computation of integrals over a collection of regions.&lt;BR /&gt;!&lt;BR /&gt;!***DESCRIPTION&lt;BR /&gt;! CUBATR is the driver routine for CUBPACK and the only&lt;BR /&gt;! routine that a user has to deal with (at the moment).&lt;BR /&gt;!&lt;BR /&gt;!-----------------------------------------------------------------------&lt;BR /&gt;PRIVATE :: CUBATR_X, CUBATR_1, CUBATR_CLEAR&lt;BR /&gt;&lt;BR /&gt;!&lt;BR /&gt;! Module variables&lt;BR /&gt;!&lt;BR /&gt;INTEGER, SAVE, PRIVATE :: PreJob=0&lt;BR /&gt;INTEGER, PRIVATE :: BOTTIH,BOTTRH&lt;BR /&gt;INTEGER, DIMENSION(:), PRIVATE, ALLOCATABLE :: IWork&lt;BR /&gt;REAL(kind=stnd), DIMENSION(:), PRIVATE, ALLOCATABLE :: RWork&lt;BR /&gt;TYPE(EPSALG_MEM), PRIVATE :: M&lt;BR /&gt;&lt;BR /&gt;INTERFACE CUBATR&lt;BR /&gt; MODULE PROCEDURE CUBATR_X, CUBATR_1, CUBATR_CLEAR&lt;BR /&gt;END INTERFACE&lt;BR /&gt;&lt;BR /&gt;CONTAINS&lt;BR /&gt;&lt;BR /&gt;SUBROUTINE CUBATR_X &amp;amp;&lt;BR /&gt; (DIMENS,NumFun,Integrand,NumRgn,Vertices,RgType,Value,AbsErr, &amp;amp;&lt;BR /&gt;! and optional parameters&lt;BR /&gt;IFAIL,Neval,EpsAbs,EpsRel,Restart,MinPts,MaxPts,Key,Job,Tune)&lt;BR /&gt;!-----------------------------------------------------------------------&lt;BR /&gt;! Input parameters&lt;BR /&gt;! ----------------&lt;BR /&gt;!&lt;BR /&gt;! DIMENS Integer.&lt;BR /&gt;! The dimension of the region of integration.&lt;BR /&gt;!&lt;BR /&gt;! NumFun Integer.&lt;BR /&gt;! Number of components of the integrand.&lt;BR /&gt;!&lt;BR /&gt;! Integrand&lt;BR /&gt;! Externally declared function for computing all components&lt;BR /&gt;! of the integrand at the given evaluation point.&lt;BR /&gt;! It must have input parameter X:&lt;BR /&gt;! X(1) The x-coordinate of the evaluation point.&lt;BR /&gt;! X(2) The y-coordinate of the evaluation point.&lt;BR /&gt;! ...&lt;BR /&gt;! X(DIMENS) The z-coordinate of the evaluation point.&lt;BR /&gt;! and NumFun, the number of components of the integrand.&lt;BR /&gt;! It must be compatible with the following interface:&lt;BR /&gt;! INTERFACE &lt;BR /&gt;! FUNCTION Integrand(NUMFUN,X) RESULT(Value)&lt;BR /&gt;! USE Precision_Model&lt;BR /&gt;! INTEGER, INTENT(IN) :: NUMFUN&lt;BR /&gt;! REAL(kind=stnd), DIMENSION(:), INTENT(IN) :: X&lt;BR /&gt;! REAL(kind=stnd), DIMENSION(NUMFUN) :: Value&lt;BR /&gt;! END FUNCTION Integrand&lt;BR /&gt;! END INTERFACE&lt;BR /&gt;!&lt;BR /&gt;! NumRgn Integer.&lt;BR /&gt;! The number of given regions.&lt;BR /&gt;!&lt;BR /&gt;! Vertices&lt;BR /&gt;! Real array of dimension (DIMENS,DIMENS+1,NumRgn).&lt;BR /&gt;! Vertices(1:DIMENS,K,L) are the x, y, ... coordinates&lt;BR /&gt;! respectively of vertex K of region L, where&lt;BR /&gt;! K = 1,...,DIMENS+1 and L = 1,...,NumRgn.&lt;BR /&gt;!&lt;BR /&gt;! RgType Integer array of dimension (NumRgn).&lt;BR /&gt;! RgType(L) describes the type of region L.&lt;BR /&gt;!&lt;BR /&gt;! Value Real array of dimension NumFun.&lt;BR /&gt;! Approximations to all components of the integral if&lt;BR /&gt;! the procedure is restarted.&lt;BR /&gt;!&lt;BR /&gt;! AbsErr Real array of dimension NumFun.&lt;BR /&gt;! Estimates of absolute errors if the procedure is restarted.&lt;BR /&gt;!&lt;BR /&gt;! IFAIL Optional integer argument.&lt;BR /&gt;! This follows the NAG convention:&lt;BR /&gt;! IFAIL = 1 : soft silent error&lt;BR /&gt;! Control returned to calling program.&lt;BR /&gt;! IFAIL = -1: soft noisy error&lt;BR /&gt;! Error message is printed.&lt;BR /&gt;! Control returned to calling program.&lt;BR /&gt;! IFAIL = 0 : hard noisy error&lt;BR /&gt;! Error message is printed and program is stopped.&lt;BR /&gt;! Default IFAIL = -1.&lt;BR /&gt;!&lt;BR /&gt;! EpsAbs Optional real argument.&lt;BR /&gt;! Requested absolute error.&lt;BR /&gt;! Default EpsAbs = 0.&lt;BR /&gt;!&lt;BR /&gt;! EpsRel Optional real argument.&lt;BR /&gt;! Requested relative error.&lt;BR /&gt;! Default EpsRel = sqrt(machine precision).&lt;BR /&gt;!&lt;BR /&gt;! Restart Optional boolean argument.&lt;BR /&gt;! If Restart = FALSE, this is the first attempt to compute&lt;BR /&gt;! the integral.&lt;BR /&gt;! If Restart = TRUE, then we restart a previous attempt.&lt;BR /&gt;! In this case the only parameters for CUBATR that may&lt;BR /&gt;! be changed (with respect to the previous call of CUBATR)&lt;BR /&gt;! are MinPts, MaxPts, EpsAbs, EpsRel, Key and Restart.&lt;BR /&gt;! Default Restart = FALSE.&lt;BR /&gt;!&lt;BR /&gt;! MinPts Optional integer argument.&lt;BR /&gt;! The minimum allowed number of integrand evaluations.&lt;BR /&gt;! Default MinPts = 0.&lt;BR /&gt;!&lt;BR /&gt;! MaxPts Optional integer argument.&lt;BR /&gt;! The maximum allowed number of integrand evaluations.&lt;BR /&gt;! Default MaxPts = enough to do 500 subdivisions.&lt;BR /&gt;!&lt;BR /&gt;! Key Optional integer argument.&lt;BR /&gt;! Can be used by Rule_General to choose between several&lt;BR /&gt;! local integration rules.&lt;BR /&gt;! Default Key = 2 if Dimension=1 and extrapolation is used &lt;BR /&gt;! (This corresponds to QAGS)&lt;BR /&gt;! Default Key = 0 otherwise&lt;BR /&gt;!&lt;BR /&gt;! Job Optional integer argument.&lt;BR /&gt;! If |Job| = 0, then nothing will be done except freeing all&lt;BR /&gt;! allocated memory.&lt;BR /&gt;! This is usefull after a call of CUBATR if no&lt;BR /&gt;! Restart will be done later and memory usage&lt;BR /&gt;! might become an issue later.&lt;BR /&gt;! Equivalently, one can call CUBATR()&lt;BR /&gt;! without any arguments.&lt;BR /&gt;! = 1, the global adaptive algorithm is called&lt;BR /&gt;! = 2, extrapolation using the epsilon algorithm is used.&lt;BR /&gt;! = 11, a region will be divided in 2**DIMENS subregions&lt;BR /&gt;! and the global adaptive algorithm is called.&lt;BR /&gt;! In combination with Key=0, this resembles DUCTRI and DCUTET.&lt;BR /&gt;! = 12, a region will be divided in 2 subregions&lt;BR /&gt;! and the global adaptive algorithm is called.&lt;BR /&gt;! In combination with Key=3 or 4, this resembles DCUHRE.&lt;BR /&gt;! If Job &amp;lt; 0, then an overview of the Region Collection is dumped.&lt;BR /&gt;! This will create the files tmp_integerstore and tmp_realstore.&lt;BR /&gt;! Default Job = 1.&lt;BR /&gt;!&lt;BR /&gt;! Tune Optional real argument.&lt;BR /&gt;! Can be used by Global_Adapt or the local error estimators&lt;BR /&gt;! to influence the reliability. 0 &amp;lt;= Tune &amp;lt;= 1.&lt;BR /&gt;! Tune = 1 is the most reliable available.&lt;BR /&gt;! Default Tune = 1.&lt;BR /&gt;! Note that this is an experimental and controversial parameter.&lt;BR /&gt;! In this version, only Tune = 1 is supported for all regions.&lt;BR /&gt;!&lt;BR /&gt;! Output parameters&lt;BR /&gt;! -----------------&lt;BR /&gt;!&lt;BR /&gt;! Value Real array of dimension NumFun.&lt;BR /&gt;! Approximations to all components of the integral&lt;BR /&gt;!&lt;BR /&gt;! AbsErr Real array of dimension NumFun.&lt;BR /&gt;! Estimates of absolute errors.&lt;BR /&gt;!&lt;BR /&gt;! NEval Optional Integer.&lt;BR /&gt;! Number of integrand evaluations used by CUBATR for this call.&lt;BR /&gt;!&lt;BR /&gt;! IFAIL Optional Integer.&lt;BR /&gt;! IFAIL = 0 for normal exit.&lt;BR /&gt;!&lt;BR /&gt;! AbsErr(K) &amp;lt;= EpsAbs or&lt;BR /&gt;! AbsErr(K) &amp;lt;= ABS(Value(K))*EpsRel with MaxPts or less&lt;BR /&gt;! function evaluations for all values of K,&lt;BR /&gt;! 1 &amp;lt;= K &amp;lt;= NumFun .&lt;BR /&gt;!&lt;BR /&gt;! IFAIL = 1 if MaxPts was too small to obtain the required&lt;BR /&gt;! accuracy. In this case Global_Adapt returns values of&lt;BR /&gt;! Value with estimated absolute errors AbsErr.&lt;BR /&gt;!&lt;BR /&gt;! IFAIL &amp;gt; 1 in more serious case of trouble.&lt;BR /&gt;!-----------------------------------------------------------------------&lt;BR /&gt;! MODULES USED&lt;BR /&gt;USE Check_Input&lt;BR /&gt;USE Error_Handling&lt;BR /&gt;USE DS_ROUTINES, ONLY: DSCOPY, DSINIT, DSUSED, DSSTAT, DSSUM, DSPINT&lt;BR /&gt;USE CubatureRule_General, ONLY: Rule_Cost&lt;BR /&gt;USE Global_Adaptive_Algorithm&lt;BR /&gt;!***END PROLOGUE CUBATR&lt;BR /&gt;!-----------------------------------------------------------------------&lt;BR /&gt;!&lt;BR /&gt;! Global variables&lt;BR /&gt;!&lt;BR /&gt;INTERFACE &lt;BR /&gt; FUNCTION Integrand(NUMFUN,X) RESULT(Value)&lt;BR /&gt; USE Precision_Model&lt;BR /&gt; INTEGER, INTENT(IN) :: NUMFUN&lt;BR /&gt; REAL(kind=stnd), DIMENSION(:), INTENT(IN) :: X&lt;BR /&gt; REAL(kind=stnd), DIMENSION(NUMFUN) :: Value&lt;BR /&gt; END FUNCTION Integrand&lt;BR /&gt;END INTERFACE&lt;BR /&gt;INTEGER, INTENT(IN) :: DIMENS,NumFun,NumRgn&lt;BR /&gt;INTEGER, DIMENSION(:), INTENT(IN) :: RgType&lt;BR /&gt;LOGICAL, INTENT(IN), OPTIONAL :: Restart&lt;BR /&gt;INTEGER, INTENT(OUT), OPTIONAL :: NEval&lt;BR /&gt;INTEGER, INTENT(IN), OPTIONAL :: Job,Key,MaxPts,MinPts&lt;BR /&gt;INTEGER, INTENT(IN OUT), OPTIONAL :: IFAIL&lt;BR /&gt;REAL(kind=stnd), INTENT(IN), OPTIONAL :: Tune,EpsAbs,EpsRel&lt;BR /&gt;REAL(kind=stnd), INTENT(IN), DIMENSION(:,:,:) :: Vertices&lt;BR /&gt;REAL(kind=stnd), INTENT(IN OUT), DIMENSION(:) :: AbsErr, Value&lt;BR /&gt;!&lt;BR /&gt;! Named constants&lt;BR /&gt;!&lt;BR /&gt;INTEGER, PARAMETER :: NRINFO=1, NIINFO=5&lt;BR /&gt;!&lt;BR /&gt;! Local variables&lt;BR /&gt;!&lt;BR /&gt;INTEGER :: BLOCK,i,Inform,Leval,LJob,LMaxPts,LMinPts,MinCost, &amp;amp;&lt;BR /&gt; NRVERT,NrSub,NRVACA,MAXRGN,RULCLS,STATUS,Tmp&lt;BR /&gt;LOGICAL :: EpsAlg,LRestart&lt;BR /&gt;REAL(kind=stnd) :: LEpsAbs, LEpsRel&lt;BR /&gt;REAL(kind=stnd), DIMENSION(:), ALLOCATABLE :: TmpRWork&lt;BR /&gt;INTEGER, DIMENSION(:), ALLOCATABLE :: TmpIWork&lt;BR /&gt;TYPE(INTEGRATOR_INFO) :: CINFO&lt;BR /&gt;TYPE(USER_INFO) :: UINFO&lt;BR /&gt;!-----------------------------------------------------------------------&lt;BR /&gt;!&lt;BR /&gt;! Check array sizes&lt;BR /&gt;! Array size mismatch results in hard error.&lt;BR /&gt; Inform = 0&lt;BR /&gt; IF (size(rgtype) &amp;lt; numrgn) THEN&lt;BR /&gt; write(unit=*,fmt=*) "Error: size(rgtype) &amp;lt; numrgn"&lt;BR /&gt; Inform = Inform + 1&lt;BR /&gt; END IF&lt;BR /&gt; IF (size(abserr) &amp;lt; numfun) THEN&lt;BR /&gt; write(unit=*,fmt=*) "Error: size(abserr) &amp;lt; numfun"&lt;BR /&gt; Inform = Inform + 1&lt;BR /&gt; END IF&lt;BR /&gt; IF (size(Value) &amp;lt; numfun) THEN&lt;BR /&gt; write(unit=*,fmt=*) "Error: size(Value) &amp;lt; numfun"&lt;BR /&gt; Inform = Inform + 1&lt;BR /&gt; END IF&lt;BR /&gt; IF ((size(vertices,1) /= dimens) .or. (size(vertices,2) /= dimens+1) &amp;amp;&lt;BR /&gt; .or. (size(vertices,3) &amp;lt; numrgn)) THEN&lt;BR /&gt; Inform = Inform + 1&lt;BR /&gt; write(unit=*,fmt=*)"Error: size(vertices) /= (/dimens,dimens+1,numrgn/)"&lt;BR /&gt; END IF&lt;BR /&gt; IF (Inform /= 0) THEN&lt;BR /&gt; WRITE(unit=*,fmt=*) "Array size mismatch results in hard error."&lt;BR /&gt; STOP ! "Array size mismatch results in hard error."&lt;BR /&gt; END IF&lt;BR /&gt;&lt;BR /&gt;!-----------------------------------------------------------------------&lt;BR /&gt;IF (PRESENT(NEval)) THEN&lt;BR /&gt; NEval = 0&lt;BR /&gt;END IF&lt;BR /&gt;!-----------------------------------------------------------------------&lt;BR /&gt;IF (PRESENT(Job)) THEN&lt;BR /&gt; LJob = Job&lt;BR /&gt; IF (Job == 0) THEN&lt;BR /&gt; CALL CUBATR_CLEAR()&lt;BR /&gt; RETURN&lt;BR /&gt; END IF&lt;BR /&gt;ELSE&lt;BR /&gt; LJob = 1 &lt;BR /&gt;END IF&lt;BR /&gt;!-----------------------------------------------------------------------&lt;BR /&gt;!&lt;BR /&gt;! Set optional arguments&lt;BR /&gt;!&lt;BR /&gt;IF ( PRESENT(Restart)) THEN &lt;BR /&gt; LRestart = Restart&lt;BR /&gt; ELSE &lt;BR /&gt; LRestart = .FALSE.&lt;BR /&gt;END IF&lt;BR /&gt;IF ( PRESENT(Key)) THEN &lt;BR /&gt; CINFO%Key = Key&lt;BR /&gt; ELSE &lt;BR /&gt; IF ((ABS(LJob) == 2) .AND. (DIMENS == 1)) THEN&lt;BR /&gt; CINFO%Key = 2 ! simulate QAGS&lt;BR /&gt; ELSE&lt;BR /&gt; CINFO%Key = 0&lt;BR /&gt; END IF&lt;BR /&gt;END IF&lt;BR /&gt;!-----------------------------------------------------------------------&lt;BR /&gt;!&lt;BR /&gt;! Check input parameters&lt;BR /&gt;!&lt;BR /&gt;IF ( .NOT. LRestart) THEN&lt;BR /&gt; CALL CHECK(DIMENS,NumFun,NumRgn,RgType,Inform, &amp;amp;&lt;BR /&gt; LJob,IFAIL,EpsAbs,EpsRel,MinPts,MaxPts,Tune)&lt;BR /&gt;ELSE IF ( ALLOCATED(IWork) ) THEN&lt;BR /&gt; CALL CHECK(DIMENS,NumFun,BOTTRH,BOTTIH,IWork, &amp;amp;&lt;BR /&gt; Inform,LJob,IFAIL,EpsAbs,EpsRel,MinPts,MaxPts,Tune)&lt;BR /&gt;ELSE&lt;BR /&gt; Inform = 4096 ! There is nothing to restart from&lt;BR /&gt;END IF&lt;BR /&gt;IF (Inform /= 0) THEN &lt;BR /&gt; CALL Handle_Error(Inform,IFAIL)&lt;BR /&gt; RETURN&lt;BR /&gt;END IF&lt;BR /&gt;!-----------------------------------------------------------------------&lt;BR /&gt;RULCLS = Rule_Cost( DIMENS, RgType(1), CINFO%Key )&lt;BR /&gt;MinCost = RULCLS&lt;BR /&gt;DO i = 2,NumRgn&lt;BR /&gt; Tmp = Rule_Cost( DIMENS, RgType(i), CINFO%Key)&lt;BR /&gt; RULCLS = max(RULCLS,Tmp)&lt;BR /&gt; MinCost = MinCost + Tmp&lt;BR /&gt;END DO&lt;BR /&gt;!-----------------------------------------------------------------------&lt;BR /&gt;!&lt;BR /&gt;! Set optional arguments&lt;BR /&gt;!&lt;BR /&gt; &lt;BR /&gt;IF ( PRESENT(MinPts)) THEN &lt;BR /&gt; LMinPts = MinPts&lt;BR /&gt; ELSE &lt;BR /&gt; LMinPts = 0&lt;BR /&gt;END IF&lt;BR /&gt;IF ( PRESENT(MaxPts)) THEN &lt;BR /&gt; LMaxPts = MaxPts&lt;BR /&gt; ELSE &lt;BR /&gt; LMaxPts = 500*RULCLS&lt;BR /&gt;END IF&lt;BR /&gt;IF ( PRESENT(Tune)) THEN &lt;BR /&gt; CINFO%Tune = Tune&lt;BR /&gt; ELSE &lt;BR /&gt; CINFO%Tune = 1&lt;BR /&gt;END IF&lt;BR /&gt;IF ( PRESENT(EpsAbs)) THEN &lt;BR /&gt; LEpsAbs = EpsAbs&lt;BR /&gt; ELSE &lt;BR /&gt; LEpsAbs = 0&lt;BR /&gt;END IF&lt;BR /&gt;IF ( PRESENT(EpsRel)) THEN &lt;BR /&gt; LEpsRel = EpsRel&lt;BR /&gt; ELSE &lt;BR /&gt; LEpsRel = SQRT(EPSILON(LEpsRel))&lt;BR /&gt;END IF&lt;BR /&gt;!-----------------------------------------------------------------------&lt;BR /&gt;!&lt;BR /&gt;! Set other parameters of the Global Adaptive algorithm&lt;BR /&gt;! &lt;BR /&gt;!&lt;BR /&gt;! NrSub is an upper limit for the number of subregions after subdivision.&lt;BR /&gt;! This influence memory managment, so don't exagerate here.&lt;BR /&gt;IF (DIMENS &amp;lt;= 3) THEN &lt;BR /&gt; NrSub = 2**DIMENS&lt;BR /&gt; ELSE &lt;BR /&gt; NrSub = 4&lt;BR /&gt;END IF&lt;BR /&gt;!&lt;BR /&gt;EpsAlg = ( ABS(LJob) == 2 )&lt;BR /&gt;CINFO%UNIFORM_SUBDIV = EpsAlg&lt;BR /&gt;CINFO%NrSub = NrSub&lt;BR /&gt;&lt;BR /&gt;IF (( ABS(LJob) == 11) .AND. (DIMENS &amp;lt;= 3)) THEN&lt;BR /&gt; ! simulate dcutri and dcutet ; NrSub = 2**DIMENS ; EpsAlg = .FALSE.&lt;BR /&gt; CINFO%UNIFORM_SUBDIV = .TRUE.&lt;BR /&gt;END IF&lt;BR /&gt;&lt;BR /&gt;IF ( ABS(LJob) == 12 ) THEN&lt;BR /&gt; ! simulate dcuhre; NrSub = 2 ; EpsAlg = .FALSE.&lt;BR /&gt; CINFO%NrSub = 2&lt;BR /&gt;END IF&lt;BR /&gt;&lt;BR /&gt;NRVERT = DIMENS + 1 ! Only cubes and simplices are implemented here.&lt;BR /&gt;&lt;BR /&gt;UINFO%NumFun = NumFun &lt;BR /&gt;UINFO%NumRgn = NumRgn&lt;BR /&gt;UINFO%MinPts = LMinPts &lt;BR /&gt;UINFO%MaxPts = LMaxPts&lt;BR /&gt;UINFO%EpsAbs = LEpsAbs &lt;BR /&gt;UINFO%EpsRel = LEpsRel&lt;BR /&gt;!-----------------------------------------------------------------------&lt;BR /&gt;IF (LRestart) THEN&lt;BR /&gt; ! This requires allocating larger arrays and copying&lt;BR /&gt; ! the region collection.&lt;BR /&gt; ALLOCATE(TmpRWork(SIZE(RWork)),STAT=status)&lt;BR /&gt; IF (status /= 0) THEN&lt;BR /&gt; WRITE(unit=*,fmt=*) "Problem allocating real workspace."&lt;BR /&gt; STOP ! "Problem allocating real workspace."&lt;BR /&gt; END IF&lt;BR /&gt; ALLOCATE(TmpIWork(SIZE(IWork)),STAT=status)&lt;BR /&gt; IF (status /= 0) THEN&lt;BR /&gt; WRITE(unit=*,fmt=*) "Problem allocating integer workspace."&lt;BR /&gt; STOP ! "Problem allocating integer workspace."&lt;BR /&gt; END IF&lt;BR /&gt; MAXRGN = DSUSED(IWork)&lt;BR /&gt; CALL DSCOPY(IWork,RWork,TmpIWork,TmpRWork)&lt;BR /&gt;ELSE&lt;BR /&gt; MAXRGN = NumRgn&lt;BR /&gt;END IF&lt;BR /&gt;!-----------------------------------------------------------------------&lt;BR /&gt;! NRVACA is the number of regions the global adaptive algorithm&lt;BR /&gt;! removes from the data structure for further processing.&lt;BR /&gt;! In some routines for shared memory parallel machines&lt;BR /&gt;! this is the variable MDIV&lt;BR /&gt;NRVACA = 1&lt;BR /&gt;! MAXRGN depends on the number of function evalutions&lt;BR /&gt;MAXRGN = MAXRGN + 1 + (NrSub-1)*(LMaxPts - RULCLS*NumRgn)/(RULCLS*NrSub)&lt;BR /&gt;!&lt;BR /&gt;! Compute length of workspace needed.&lt;BR /&gt;!&lt;BR /&gt;BOTTIH = MAXRGN*(1+NIINFO) + 15 + NRVACA&lt;BR /&gt;BLOCK = NRINFO+NRVERT*DIMENS+2*NumFun&lt;BR /&gt;IF (NumFun &amp;gt; 1) THEN&lt;BR /&gt; BLOCK = BLOCK + 1&lt;BR /&gt;END IF&lt;BR /&gt;BOTTRH = MAXRGN*BLOCK&lt;BR /&gt;!&lt;BR /&gt;! Allocate space for the region collection&lt;BR /&gt;!&lt;BR /&gt;IF (ALLOCATED(RWork)) THEN&lt;BR /&gt; DEALLOCATE(RWork)&lt;BR /&gt;END IF&lt;BR /&gt;ALLOCATE(RWork(BOTTRH),STAT=status)&lt;BR /&gt;IF (status /= 0) THEN&lt;BR /&gt; WRITE(unit=*,fmt=*) "Problem allocating real workspace."&lt;BR /&gt; STOP ! "Problem allocating real workspace."&lt;BR /&gt;END IF&lt;BR /&gt;IF (ALLOCATED(IWork)) THEN&lt;BR /&gt; DEALLOCATE(IWork)&lt;BR /&gt;END IF&lt;BR /&gt;ALLOCATE(IWork(BOTTIH),STAT=status)&lt;BR /&gt;IF (status /= 0) THEN&lt;BR /&gt; WRITE(unit=*,fmt=*) "Problem allocating integer workspace."&lt;BR /&gt; STOP ! "Problem allocating integer workspace."&lt;BR /&gt;END IF&lt;BR /&gt;!&lt;BR /&gt;! Initialise region collection&lt;BR /&gt;!&lt;BR /&gt;IF ( LRestart) THEN&lt;BR /&gt; CALL DSCOPY(TmpIWork,TmpRWork,IWork,RWork)&lt;BR /&gt; DEALLOCATE(TmpIWork,TmpRWork)&lt;BR /&gt;ELSE&lt;BR /&gt; IF ( MinCost &amp;gt; LMaxPts ) THEN&lt;BR /&gt; Inform = 128 ! Dit nummer werd al gebruikt !&lt;BR /&gt; ELSE&lt;BR /&gt; CALL DSINIT(DIMENS,NRVERT,NIINFO,NRINFO,NumFun,NRVACA, &amp;amp;&lt;BR /&gt; BOTTIH,BOTTRH,IWork,Inform)&lt;BR /&gt; END IF&lt;BR /&gt; IF (Inform /= 0) THEN &lt;BR /&gt; CALL Handle_Error(Inform,IFAIL)&lt;BR /&gt; RETURN&lt;BR /&gt; END IF&lt;BR /&gt;END IF&lt;BR /&gt;!-----------------------------------------------------------------------&lt;BR /&gt;!&lt;BR /&gt;! Call integration routine&lt;BR /&gt;!&lt;BR /&gt;If (EpsAlg) THEN&lt;BR /&gt; IF ( LRestart .AND. (PreJob /= ABS(LJob))) THEN&lt;BR /&gt; Inform = 3&lt;BR /&gt; ELSE&lt;BR /&gt; ! Observe that only relevant array sections are passed !&lt;BR /&gt; CALL Global_Adapt_Extrap(DIMENS,CINFO,UINFO,NRVERT,NIINFO, &amp;amp;&lt;BR /&gt; NRINFO, Vertices(1:DIMENS,1:NRVERT,1:NUMRGN), &amp;amp;&lt;BR /&gt; RgType(1:NUMRGN),Integrand,LRestart, &amp;amp;&lt;BR /&gt; Value(1:NUMFUN),AbsErr(1:NUMFUN),LEval,Inform, &amp;amp;&lt;BR /&gt; RWork,IWork,M)&lt;BR /&gt; END IF&lt;BR /&gt;ELSE&lt;BR /&gt; IF ( LRestart .AND. (PreJob /= LJob)) THEN&lt;BR /&gt; IF ( ASSOCIATED(M%RESLA)) THEN&lt;BR /&gt; DEALLOCATE(M%RESLA,M%ERLARG,M%RESULT1,M%ABSERR1,M%RCOPY)&lt;BR /&gt; END IF&lt;BR /&gt; CALL DSPINT(IWork,RWork)&lt;BR /&gt; CALL DSSUM(Value,Abserr,IWork,RWork,Inform)&lt;BR /&gt; END IF&lt;BR /&gt; ! Observe that only relevant array sections are passed !&lt;BR /&gt; CALL Global_Adapt(DIMENS,CINFO,UINFO,NRVERT,NIINFO,NRINFO, &amp;amp;&lt;BR /&gt; Vertices(1:DIMENS,1:NRVERT,1:NUMRGN), &amp;amp;&lt;BR /&gt; RgType(1:NUMRGN),Integrand,LRestart, &amp;amp;&lt;BR /&gt; Value(1:NUMFUN),AbsErr(1:NUMFUN),LEval,Inform, &amp;amp;&lt;BR /&gt; RWork,IWork)&lt;BR /&gt;END IF&lt;BR /&gt;IF (PRESENT(NEval)) THEN&lt;BR /&gt; NEval = LEval&lt;BR /&gt;END IF&lt;BR /&gt;!-----------------------------------------------------------------------&lt;BR /&gt;IF (LJob &amp;lt; 0) THEN&lt;BR /&gt; WRITE(unit=*,fmt=*) "Debug mode: dumping region collection overview."&lt;BR /&gt; CALL DSSTAT(IWork(:),RWork(:)) ! For debugging.&lt;BR /&gt;END IF&lt;BR /&gt;!-----------------------------------------------------------------------&lt;BR /&gt;! IF ((Inform &amp;gt;= 8) .or. (Inform == 3)) THEN&lt;BR /&gt;! Something went wrong but the data structure remains untouched&lt;BR /&gt;! and so this call can be ignored.&lt;BR /&gt;IF ((Inform &amp;lt; 8) .AND. (Inform /= 3)) THEN&lt;BR /&gt; PreJob = ABS(LJob)&lt;BR /&gt;END IF&lt;BR /&gt;CALL Handle_Error(Inform,IFAIL)&lt;BR /&gt;RETURN&lt;BR /&gt;END SUBROUTINE CUBATR_X&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;SUBROUTINE CUBATR_1 &amp;amp;&lt;BR /&gt; (DIMENS,Integrand,SVertices,SRgType,SValue,SAbsErr, &amp;amp;&lt;BR /&gt;! and optional parameters &amp;amp; &lt;BR /&gt; IFAIL,Neval,EpsAbs,EpsRel,Restart,MaxPts,Key,Job)&lt;BR /&gt;!-----------------------------------------------------------------------&lt;BR /&gt;! Input parameters&lt;BR /&gt;! ----------------&lt;BR /&gt;!&lt;BR /&gt;! DIMENS Integer.&lt;BR /&gt;! The dimension of the region of integration.&lt;BR /&gt;!&lt;BR /&gt;! Integrand&lt;BR /&gt;! Externally declared function for computing all components&lt;BR /&gt;! of the integrand at the given evaluation point.&lt;BR /&gt;! It must have input parameter X:&lt;BR /&gt;! X(1) The x-coordinate of the evaluation point.&lt;BR /&gt;! X(2) The y-coordinate of the evaluation point.&lt;BR /&gt;! ...&lt;BR /&gt;! X(DIMENS) The z-coordinate of the evaluation point.&lt;BR /&gt;! and NumFun, the number of components of the integrand.&lt;BR /&gt;! It must be compatible with the following interface:&lt;BR /&gt;! INTERFACE &lt;BR /&gt;! FUNCTION Integrand(NUMFUN,X) RESULT(Value)&lt;BR /&gt;! USE Precision_Model&lt;BR /&gt;! INTEGER, INTENT(IN) :: NUMFUN&lt;BR /&gt;! REAL(kind=stnd), DIMENSION(:), INTENT(IN) :: X&lt;BR /&gt;! REAL(kind=stnd), DIMENSION(NUMFUN) :: Value&lt;BR /&gt;! END FUNCTION Integrand&lt;BR /&gt;! END INTERFACE&lt;BR /&gt;!&lt;BR /&gt;! SVertices&lt;BR /&gt;! Real array of dimension (DIMENS,DIMENS+1).&lt;BR /&gt;! Vertices(1:DIMENS,K) are the x, y, ... coordinates&lt;BR /&gt;! respectively of vertex K of the region, where&lt;BR /&gt;! K = 1,...,DIMENS+1.&lt;BR /&gt;!&lt;BR /&gt;! SRgType Integer.&lt;BR /&gt;! RgType describes the type of region L.&lt;BR /&gt;!&lt;BR /&gt;! SValue Real.&lt;BR /&gt;! Approximation to the integral if the procedure is restarted.&lt;BR /&gt;!&lt;BR /&gt;! SAbsErr Real.&lt;BR /&gt;! Estimate of the absolute error if the procedure is restarted.&lt;BR /&gt;!&lt;BR /&gt;! IFAIL Optional integer argument.&lt;BR /&gt;! This follows the NAG convention:&lt;BR /&gt;! IFAIL = 1 : soft silent error&lt;BR /&gt;! Control returned to calling program.&lt;BR /&gt;! IFAIL = -1: soft noisy error&lt;BR /&gt;! Error message is printed.&lt;BR /&gt;! Control returned to calling program.&lt;BR /&gt;! IFAIL = 0 : hard noisy error&lt;BR /&gt;! Error message is printed and program is stopped.&lt;BR /&gt;! Default IFAIL = -1.&lt;BR /&gt;!&lt;BR /&gt;! EpsAbs Optional real argument.&lt;BR /&gt;! Requested absolute error.&lt;BR /&gt;! Default EpsAbs = 0.&lt;BR /&gt;!&lt;BR /&gt;! EpsRel Optional real argument.&lt;BR /&gt;! Requested relative error.&lt;BR /&gt;! Default EpsRel = sqrt(machine precision).&lt;BR /&gt;!&lt;BR /&gt;! Restart Optional boolean argument.&lt;BR /&gt;! If Restart = FALSE, this is the first attempt to compute&lt;BR /&gt;! the integral.&lt;BR /&gt;! If Restart = TRUE, then we restart a previous attempt.&lt;BR /&gt;! In this case the only parameters for CUBATR that may&lt;BR /&gt;! be changed (with respect to the previous call of CUBATR)&lt;BR /&gt;! are MinPts, MaxPts, EpsAbs, EpsRel, Key and Restart.&lt;BR /&gt;! Default Restart = FALSE.&lt;BR /&gt;!&lt;BR /&gt;! MaxPts Optional integer argument.&lt;BR /&gt;! The maximum allowed number of integrand evaluations.&lt;BR /&gt;! Default MaxPts = enough to do 500 subdivisions.&lt;BR /&gt;!&lt;BR /&gt;! Key Optional integer argument.&lt;BR /&gt;! Can be used by Rule_General to choose between several&lt;BR /&gt;! local integration rules.&lt;BR /&gt;! Default Key = 2 if Dimension=1 and extrapolation is used &lt;BR /&gt;! (This corresponds to QAGS)&lt;BR /&gt;! Default Key = 0 otherwise&lt;BR /&gt;!&lt;BR /&gt;! Job Optional integer argument.&lt;BR /&gt;! If |Job| = 0, then nothing will be done except freeing all&lt;BR /&gt;! allocated memory.&lt;BR /&gt;! This is usefull after a call of CUBATR if no&lt;BR /&gt;! Restart will be done later and memory usage&lt;BR /&gt;! might become an issue later.&lt;BR /&gt;! Equivalently, one can call CUBATR()&lt;BR /&gt;! without any arguments.&lt;BR /&gt;! = 1, the global adaptive algorithm is called&lt;BR /&gt;! = 2, extrapolation using the epsilon algorithm is used.&lt;BR /&gt;! = 11, a region will be divided in 2**DIMENS subregions&lt;BR /&gt;! and the global adaptive algorithm is called.&lt;BR /&gt;! In combination with Key=0, this resembles DUCTRI and DCUTET.&lt;BR /&gt;! = 12, a region will be divided in 2 subregions&lt;BR /&gt;! and the global adaptive algorithm is called.&lt;BR /&gt;! In combination with Key=3 or 4, this resembles DCUHRE.&lt;BR /&gt;! If Job &amp;lt; 0, then an overview of the Region Collection is dumped.&lt;BR /&gt;! This will create the files tmp_integerstore and tmp_realstore.&lt;BR /&gt;! Default Job = 1.&lt;BR /&gt;!&lt;BR /&gt;! Output parameters&lt;BR /&gt;! -----------------&lt;BR /&gt;!&lt;BR /&gt;! SValue Real.&lt;BR /&gt;! Approximation to the integral&lt;BR /&gt;!&lt;BR /&gt;! AbsErr Real.&lt;BR /&gt;! Estimate of the absolute error.&lt;BR /&gt;!&lt;BR /&gt;! NEval Optional Integer.&lt;BR /&gt;! Number of integrand evaluations used by CUBATR for this call.&lt;BR /&gt;!&lt;BR /&gt;! IFAIL Optional Integer.&lt;BR /&gt;! IFAIL = 0 for normal exit.&lt;BR /&gt;!&lt;BR /&gt;! AbsErr(K) &amp;lt;= EpsAbs or&lt;BR /&gt;! AbsErr(K) &amp;lt;= ABS(Value(K))*EpsRel with MaxPts or less&lt;BR /&gt;! function evaluations for all values of K,&lt;BR /&gt;! 1 &amp;lt;= K &amp;lt;= NumFun .&lt;BR /&gt;!&lt;BR /&gt;! IFAIL = 1 if MaxPts was too small to obtain the required&lt;BR /&gt;! accuracy. In this case Global_Adapt returns values of&lt;BR /&gt;! Value with estimated absolute errors AbsErr.&lt;BR /&gt;!&lt;BR /&gt;! IFAIL &amp;gt; 1 in more serious case of trouble.&lt;BR /&gt;!-----------------------------------------------------------------------&lt;BR /&gt;!&lt;BR /&gt;! Global variables&lt;BR /&gt;!&lt;BR /&gt;INTERFACE &lt;BR /&gt; FUNCTION Integrand(NUMFUN,X) RESULT(Value)&lt;BR /&gt; USE Precision_Model&lt;BR /&gt; INTEGER, INTENT(IN) :: NUMFUN&lt;BR /&gt; REAL(kind=stnd), DIMENSION(:), INTENT(IN) :: X&lt;BR /&gt; REAL(kind=stnd), DIMENSION(NUMFUN) :: Value&lt;BR /&gt; END FUNCTION Integrand&lt;BR /&gt;END INTERFACE&lt;BR /&gt;LOGICAL, OPTIONAL, INTENT(IN) :: Restart&lt;BR /&gt;INTEGER, INTENT(IN) :: DIMENS,SRgType&lt;BR /&gt;INTEGER, INTENT(OUT), OPTIONAL :: NEval&lt;BR /&gt;INTEGER, INTENT(IN), OPTIONAL :: Key,MaxPts,Job&lt;BR /&gt;INTEGER, INTENT(IN OUT), OPTIONAL :: IFAIL&lt;BR /&gt;REAL(kind=stnd), INTENT(IN), OPTIONAL :: EpsAbs,EpsRel&lt;BR /&gt;REAL(kind=stnd), DIMENSION(:,:), INTENT(IN) :: SVertices&lt;BR /&gt;REAL(kind=stnd), INTENT(IN OUT) :: SValue,SAbsErr&lt;BR /&gt;!&lt;BR /&gt;! Local variables&lt;BR /&gt;!&lt;BR /&gt;INTEGER, DIMENSION(1) :: RgType&lt;BR /&gt;REAL(kind=stnd), DIMENSION(1) :: Value, AbsErr&lt;BR /&gt;REAL(kind=stnd), DIMENSION(DIMENS,DIMENS+1,1) :: Vertices&lt;BR /&gt;!-------------------&lt;BR /&gt;RgType(1) = SRgType&lt;BR /&gt;Vertices(:,:,1) = SVertices&lt;BR /&gt;IF (PRESENT(Restart)) THEN&lt;BR /&gt; IF ( Restart ) THEN&lt;BR /&gt; Value(1) = SValue&lt;BR /&gt; AbsErr(1) = SAbsErr&lt;BR /&gt; END IF&lt;BR /&gt;END IF&lt;BR /&gt;CALL CUBATR &amp;amp;&lt;BR /&gt; (DIMENS,1,Integrand,1,Vertices,RgType,Value,AbsErr, &amp;amp;&lt;BR /&gt; ! and optional parameters &amp;amp;&lt;BR /&gt; ifail=IFAIL,neval=Neval,epsabs=EpsAbs,epsrel=EpsRel, &amp;amp;&lt;BR /&gt; restart=Restart,maxpts=MaxPts,key=key,job=Job)&lt;BR /&gt;SValue = Value(1)&lt;BR /&gt;SAbsErr = AbsErr(1)&lt;BR /&gt;RETURN&lt;BR /&gt;END SUBROUTINE CUBATR_1&lt;BR /&gt;&lt;BR /&gt;SUBROUTINE CUBATR_CLEAR()&lt;BR /&gt; IF ( ALLOCATED(Iwork) ) THEN&lt;BR /&gt; DEALLOCATE(RWork,IWork)&lt;BR /&gt; END IF&lt;BR /&gt; IF ( ASSOCIATED(M%RESLA)) THEN&lt;BR /&gt; DEALLOCATE(M%RESLA,M%ERLARG,M%RESULT1,M%ABSERR1,M%RCOPY)&lt;BR /&gt; END IF&lt;BR /&gt; PreJob = 0&lt;BR /&gt; RETURN&lt;BR /&gt;END SUBROUTINE CUBATR_CLEAR&lt;BR /&gt;&lt;BR /&gt;SUBROUTINE CUBPACK_INFO()&lt;BR /&gt;&lt;BR /&gt;REAL(kind=stnd) :: x=1.0e-30 ! lowest accuracy of cubature formula constants&lt;BR /&gt;&lt;BR /&gt;print *," -------------------------------------------------------&lt;/DIV&gt;</description>
      <pubDate>Fri, 30 Jul 2010 10:25:05 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Problems-with-interface-and-function/m-p/748725#M5832</guid>
      <dc:creator>aryangor</dc:creator>
      <dc:date>2010-07-30T10:25:05Z</dc:date>
    </item>
    <item>
      <title>Problems with interface and function</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Problems-with-interface-and-function/m-p/748726#M5833</link>
      <description>You have removed some crucial lines of code that would have shown the context -- in particular, the USE CUBATR_MOD and the MODULE ... END MODULE ... statements in the second part. &lt;BR /&gt;&lt;BR /&gt;That leaves insufficient information for me to give you a specific answer.&lt;BR /&gt;&lt;BR /&gt;If, however, INTEGRAND and GAMMAFN are separate procedures rather than member procedures of a module, with GAMMAFNARG declared with module scope, INTEGRAND is seen as an ordinary integer variable within function GAMMAFN, and does not match with the interface for CUBATR, whose second argument should be: function returning real. That would explain the compiler error #6285.&lt;BR /&gt;</description>
      <pubDate>Fri, 30 Jul 2010 12:39:29 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Problems-with-interface-and-function/m-p/748726#M5833</guid>
      <dc:creator>mecej4</dc:creator>
      <dc:date>2010-07-30T12:39:29Z</dc:date>
    </item>
    <item>
      <title>Problems with interface and function</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Problems-with-interface-and-function/m-p/748727#M5834</link>
      <description>I have edited all code of both files in my first post - have a look now. To recap: the interface of the first file, CUBATR, is not implemented correctly in the second file, MATH - possibly the function INTEGRAND in the second file gives problems.</description>
      <pubDate>Tue, 03 Aug 2010 08:51:40 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Problems-with-interface-and-function/m-p/748727#M5834</guid>
      <dc:creator>aryangor</dc:creator>
      <dc:date>2010-08-03T08:51:40Z</dc:date>
    </item>
    <item>
      <title>Problems with interface and function</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Problems-with-interface-and-function/m-p/748728#M5835</link>
      <description>Well, the code is now too big to analyse manually (without a compiler) but here is one thing to check:&lt;BR /&gt;&lt;BR /&gt;You did not show what &lt;I&gt;real(stnd)&lt;/I&gt; is; if it is double precision, then the array &lt;I&gt;result&lt;/I&gt; in your math module, which is default (single) precision, will not match the interface for &lt;I&gt;integrate&lt;/I&gt;. Make all the corresponding variables in the calls to &lt;I&gt;integrate&lt;/I&gt; match in type -- either REAL or REAL(stnd), but not a mismatched mix.&lt;BR /&gt;</description>
      <pubDate>Wed, 04 Aug 2010 02:06:15 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Problems-with-interface-and-function/m-p/748728#M5835</guid>
      <dc:creator>mecej4</dc:creator>
      <dc:date>2010-08-04T02:06:15Z</dc:date>
    </item>
    <item>
      <title>Problems with interface and function</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Problems-with-interface-and-function/m-p/748729#M5836</link>
      <description>I modified the code as following (see lines 04-05 and 31-34):&lt;BR /&gt;&lt;BR /&gt;&lt;PRE&gt;[fortran]    ! Local variables
    INTEGER, PARAMETER          :: n=1          ! Dimension of integration
    INTEGER, PARAMETER          :: rgtype=1     ! Region type
!    REAL      	                    :: result       ! Result of integration
    REAL(stnd)	                    :: result       ! Result of integration
    REAL                        :: abserr       ! Absolute error on integration
    REAL, DIMENSION( 1:n, 0:n ) :: vertices
    REAL                        :: prod
    
    vertices( 1, : ) = (/ 0.0 , 1.0 /)          ! Boundaries of integration
    gammafnarg = x
    prod = 1.0
    
    ! Do some recursion if the argument is less than unity
    DO WHILE ( gammafnarg &amp;lt; 1.0 )
      prod = prod * gammafnarg
      gammafnarg = gammafnarg + 1.0
    END DO
    
    ! Do the integration...
    CALL CUBATR(n,Integrand,vertices,rgtype,result,abserr)
            
    gammafn = result / prod
    
    RETURN
  END FUNCTION gammafn
!*********************************************************************************************************************!
   FUNCTION Integrand(NUMFUN,X) RESULT(Value)
     USE Precision_Model
     INTEGER, INTENT(IN) :: NUMFUN
!     REAL, DIMENSION(:), INTENT(IN) :: X
!     REAL, DIMENSION(NUMFUN) :: Value
      REAL(kind=stnd), DIMENSION(NUMFUN) :: Value
      REAL(kind=stnd), DIMENSION(:), INTENT(IN) :: X
      Value( 1 ) = ( -LOG( x( 1 ) ) )**( gammafnarg - 1.0 )
   END FUNCTION Integrand[/fortran]&lt;/PRE&gt; &lt;BR /&gt;Still, the same error persists, and even more - I get this one now:&lt;BR /&gt;&lt;PRE&gt;[bash]math.f90(58): error #6683: A kind type parameter must be a compile-time constant.   [STND]
    REAL(kind=stnd)             :: result       ! Result of integration
--------------^
math.f90(74): error #6285: There is no matching specific subroutine for this generic subroutine call.   [CUBATR]
    CALL CUBATR(n,Integrand,vertices,rgtype,result,abserr)
---------^
[/bash]&lt;/PRE&gt;I believe there is nothing to change in the first file. Did I understand you correctly?</description>
      <pubDate>Wed, 04 Aug 2010 07:55:57 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Problems-with-interface-and-function/m-p/748729#M5836</guid>
      <dc:creator>aryangor</dc:creator>
      <dc:date>2010-08-04T07:55:57Z</dc:date>
    </item>
    <item>
      <title>Problems with interface and function</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Problems-with-interface-and-function/m-p/748730#M5837</link>
      <description>Ok I found something else.&lt;BR /&gt;&lt;BR /&gt;&lt;PRE&gt;[fortran]! This file is F-compatible, except for upper/lower case conventions.&lt;BR /&gt;!--------------------------------------------------------------------&lt;BR /&gt;MODULE  Extended  ! precision specification for real computations&lt;BR /&gt;&lt;BR /&gt;    ! This requests the processor to use a real implementation 'stnd'&lt;BR /&gt;    ! which provides at least 20 decimal digits of precision and an&lt;BR /&gt;    ! exponent range of at least 10 ^ +- 80.  It is expected that this&lt;BR /&gt;    ! precision may not be available on all machines.&lt;BR /&gt;    ! In July 2002, we found this available on&lt;BR /&gt;    !     SUN (Solaris) with f95&lt;BR /&gt;    !     IBM (AIX)     with xlf90&lt;BR /&gt;    !     DEC alpha     with f90&lt;BR /&gt;&lt;BR /&gt;    IMPLICIT NONE&lt;BR /&gt;    Integer, PUBLIC, PARAMETER :: stnd = Selected_Real_Kind ( 20, 80 )&lt;BR /&gt;    !-------------------------&lt;BR /&gt;&lt;BR /&gt;    ! A few computations are preferably done in higher precision 'extd'. The&lt;BR /&gt;    ! numbers chosen here should be such that the underlying hardware will&lt;BR /&gt;    ! select a higher precision for kind 'extd' than for kind 'stnd', if&lt;BR /&gt;    ! this is feasible.  If a higher precision is not readily available,&lt;BR /&gt;    ! the same values may be used as are given above for 'stnd'. It is&lt;BR /&gt;    ! anticipated that on many machines, such an even higher precision may&lt;BR /&gt;    ! not be available.&lt;BR /&gt;&lt;BR /&gt;    Integer, PUBLIC, PARAMETER :: extd = Selected_Real_Kind ( 30, 80 )&lt;BR /&gt;    !-------------------------&lt;BR /&gt;&lt;BR /&gt;end Module Extended[/fortran]&lt;/PRE&gt;

This is part of
&lt;PRE&gt;[fortran]USE Precision_Model[/fortran]&lt;/PRE&gt;
call.</description>
      <pubDate>Wed, 04 Aug 2010 08:00:09 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Problems-with-interface-and-function/m-p/748730#M5837</guid>
      <dc:creator>aryangor</dc:creator>
      <dc:date>2010-08-04T08:00:09Z</dc:date>
    </item>
    <item>
      <title>Problems with interface and function</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Problems-with-interface-and-function/m-p/748731#M5838</link>
      <description>I think that what you have posted has reached the limits of workability in a forum such as this. The code posted is rather large already, and incomplete in the sense that the pieces posted cannot be run through a compiler because many USED modules are missing.&lt;BR /&gt;&lt;BR /&gt;Here are some bugs that I spotted:&lt;BR /&gt;&lt;BR /&gt; (i) There are several instances where REAL variables are used in place of REAL(kind=stnd) variables and vice versa. There are several instances where scalar variables are used as equivalent to array variables with DIMENSION (1) or (1,1), in assignment statements and as actual arguments. These lax practices might have made it through Fortran 77 but with the stricter requirements in Fortran 9X, they need to be fixed.&lt;BR /&gt;&lt;BR /&gt; (ii) The internal subprogram INTEGRAND has been used as an actual argument in a call to CUBATR. Section 12.1.2.2 of the Fortran Standard says "...the internal procedure name shall not be argument associated with a dummy procedure (12.4.1.3)".&lt;BR /&gt;&lt;BR /&gt; (iii) CUBATR_1, which is a specific name for the generic name CUBATR, calls CUBATR (indirect recursion) without the specification RECURSIVE present for any procedure.&lt;BR /&gt;&lt;BR /&gt;There are two ways to go forward. You can whittle down your code to a much smaller size and repost a complete example. Or you can take the files that I have attached, which compile without syntax errors and run, but have much code removed and have numerous cases of uninitialized variables. I have NOT addressed Bug (ii) above. You could add code to these to fill in the missing functionality, retaining the working variable types and subprogram interfaces.</description>
      <pubDate>Wed, 04 Aug 2010 14:46:59 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Problems-with-interface-and-function/m-p/748731#M5838</guid>
      <dc:creator>mecej4</dc:creator>
      <dc:date>2010-08-04T14:46:59Z</dc:date>
    </item>
    <item>
      <title>Problems with interface and function</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Problems-with-interface-and-function/m-p/748732#M5839</link>
      <description>&lt;DIV id="tiny_quote"&gt;
                &lt;DIV style="margin-left: 2px; margin-right: 2px;"&gt;Quoting &lt;A rel="/en-us/services/profile/quick_profile.php?is_paid=&amp;amp;user_id=9662" class="basic" href="https://community.intel.com/en-us/profile/9662/"&gt;mecej4&lt;/A&gt;&lt;/DIV&gt;
                &lt;DIV style="background-color: #e5e5e5; padding: 5px; border: 1px inset; margin-left: 2px; margin-right: 2px;"&gt;&lt;I&gt;&lt;BR /&gt; (ii) The internal subprogram INTEGRAND has been used as an actual argument in a call to CUBATR. Section 12.1.2.2 of the Fortran Standard says "...the internal procedure name shall not be argument associated with a dummy procedure (12.4.1.3)".&lt;BR /&gt;&lt;BR /&gt;&lt;/I&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;ifort supported this common extension to f90 even before it was included in 2003 standard.&lt;/P&gt;</description>
      <pubDate>Wed, 04 Aug 2010 15:37:25 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Problems-with-interface-and-function/m-p/748732#M5839</guid>
      <dc:creator>TimP</dc:creator>
      <dc:date>2010-08-04T15:37:25Z</dc:date>
    </item>
    <item>
      <title>Problems with interface and function</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Problems-with-interface-and-function/m-p/748733#M5840</link>
      <description>Tim, I am puzzled. I actually took the quote from the J4-007 draft of the F2003 Standard, from the link posted at the top of this forum. Was the restriction listed in the draft removed in the final standard (which I haven't bought so far)?</description>
      <pubDate>Wed, 04 Aug 2010 18:39:18 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Problems-with-interface-and-function/m-p/748733#M5840</guid>
      <dc:creator>mecej4</dc:creator>
      <dc:date>2010-08-04T18:39:18Z</dc:date>
    </item>
    <item>
      <title>Problems with interface and function</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Problems-with-interface-and-function/m-p/748734#M5841</link>
      <description>&lt;DIV id="tiny_quote"&gt;
                &lt;DIV style="margin-left: 2px; margin-right: 2px;"&gt;Quoting &lt;A rel="/en-us/services/profile/quick_profile.php?is_paid=&amp;amp;user_id=9662" class="basic" href="https://community.intel.com/en-us/profile/9662/"&gt;mecej4&lt;/A&gt;&lt;/DIV&gt;
                &lt;DIV style="background-color: #e5e5e5; padding: 5px; border: 1px inset; margin-left: 2px; margin-right: 2px;"&gt;&lt;I&gt;Tim, I am puzzled. I actually took the quote from the J4-007 draft of the F2003 Standard, from the link posted at the top of this forum. Was the restriction listed in the draft removed in the final standard (which I haven't bought so far)?&lt;/I&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;I believe allowing internal procedures as actual arguments is a feature of the F2008 standard (which, despite its name, is still in the process of being formally approved). Tim may have either mistyped or misremembered.&lt;/P&gt;&lt;P&gt;-Kurt&lt;/P&gt;</description>
      <pubDate>Wed, 04 Aug 2010 23:26:21 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Problems-with-interface-and-function/m-p/748734#M5841</guid>
      <dc:creator>Hirchert__Kurt_W</dc:creator>
      <dc:date>2010-08-04T23:26:21Z</dc:date>
    </item>
    <item>
      <title>Problems with interface and function</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Problems-with-interface-and-function/m-p/748735#M5842</link>
      <description>Thanks a lot, mecej4! I will have a good look into this - will let you know. Good day!</description>
      <pubDate>Tue, 10 Aug 2010 06:02:43 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Problems-with-interface-and-function/m-p/748735#M5842</guid>
      <dc:creator>aryangor</dc:creator>
      <dc:date>2010-08-10T06:02:43Z</dc:date>
    </item>
  </channel>
</rss>

