- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I am gettingan error in Intel Visual Studio: error #8000: There is a conflict between local interface block and external interface block [fnc]. It points at the line where I first call the function fnc. Surprisingly, the code runs perfectly on the older Compaq Visual Fortran without that mistake.
PROGRAM nwSpGr_demo
!INCLUDE 'link_fnl_shared.h'
!%*****************************************************************************
!% nwSpGr_demo: test & demo for nwspgr
!%*****************************************************************************
! USE nwspgr_mod
IMPLICIT NONE
INTEGER(4) :: DD,kmax,simnum
CHARACTER(3) :: tpe
REAL(8),ALLOCATABLE :: xx(:,:),ww(:)
REAL(8),ALLOCATABLE :: x(:,:),w(:,:),g(:,:),sim(:)
REAL(8) :: trueval,SGappr(1,1),SGerror(1,1),Simerror
INTEGER(4) :: kk,nn,r
INTERFACE
FUNCTION fnc(x1)
IMPLICIT NONE
! INTEGER(4) :: n1,d
REAL(8),INTENT(IN):: x1(:,:)
REAL(8) :: fnc(size(x1(:,1)))
END FUNCTION fnc
END INTERFACE
WRITE(*,*) 'Max k:'
READ(*,*) kmax
WRITE(*,*) 'Dimension D:'
READ(*,*) DD
WRITE(*,*) 'String :'
READ(*,*) tpe
ALLOCATE(xx(kmax**DD,DD),ww(kmax**DD))
WRITE(*,*) 'Number of simulation repetitions:'
READ(*,*) simnum
ALLOCATE(sim(simnum))
CALL RANDOM_SEED(PUT=(/ 123456789,412648571 /))
CALL RANDOM_NUMBER(xx)
trueval=sum(fnc(xx))/dble(kmax**DD)
DO kk=1,kmax
! CALL nwspgr(tpe,DD,kk,nn,xx,ww)
CALL RANDOM_NUMBER(xx)
CALL RANDOM_NUMBER(ww)
WRITE(*,*) 'number of nodes:'
READ(*,*) nn
ALLOCATE(x(nn,DD),w(nn,1),g(nn,1))
x=xx(1:nn,1:DD)
w(1:nn,1)=ww(1:nn)
g(1:nn,1)=fnc(x)
SGappr = matmul(transpose(g),w)
SGerror = sqrt((SGappr - trueval)**2)/trueval
sim = 0.0d0
DO r=1,simnum
CALL RANDOM_NUMBER(x)
g(:,1)=fnc(x)
sim = sum(g(:,1))/(max(1,size(g(:,1))))
END DO
Simerror = sqrt(sum((sim(:)-trueval)**2)/(max(1,size(SIM(:)))))/trueval
WRITE(*,*) 'Number of nodes:'
WRITE(*,*) nn
WRITE(*,*) 'SG error='
WRITE(*,*) SGerror
WRITE(*,*) 'Sim. error='
WRITE(*,*) Simerror
DEALLOCATE(x,w,g)
END DO
END PROGRAM nwSpGr_demo
!=====================================================================================
! integrand: some function that evaluates g(x): (R times D)->(R times 1)
FUNCTION fnc(x1)
IMPLICIT NONE
! INTEGER(4) :: n1,d
REAL(8),INTENT(IN):: x1(:,:)
REAL(8) :: fnc(size(x1(:,1)))
REAL(8),PARAMETER :: pi=3.14159265359d0
INTEGER(4) :: i
DO i=1,size(x1(:,1))
fnc(i) = product( exp(-(x1(i,:)/2.0d0)**2 / 2.0d0)/2.0d0/sqrt(2.0d0*pi))
END DO
END FUNCTION fnc
I would appreciate any suggestions.
I am gettingan error in Intel Visual Studio: error #8000: There is a conflict between local interface block and external interface block [fnc]. It points at the line where I first call the function fnc. Surprisingly, the code runs perfectly on the older Compaq Visual Fortran without that mistake.
PROGRAM nwSpGr_demo
!INCLUDE 'link_fnl_shared.h'
!%*****************************************************************************
!% nwSpGr_demo: test & demo for nwspgr
!%*****************************************************************************
! USE nwspgr_mod
IMPLICIT NONE
INTEGER(4) :: DD,kmax,simnum
CHARACTER(3) :: tpe
REAL(8),ALLOCATABLE :: xx(:,:),ww(:)
REAL(8),ALLOCATABLE :: x(:,:),w(:,:),g(:,:),sim(:)
REAL(8) :: trueval,SGappr(1,1),SGerror(1,1),Simerror
INTEGER(4) :: kk,nn,r
INTERFACE
FUNCTION fnc(x1)
IMPLICIT NONE
! INTEGER(4) :: n1,d
REAL(8),INTENT(IN):: x1(:,:)
REAL(8) :: fnc(size(x1(:,1)))
END FUNCTION fnc
END INTERFACE
WRITE(*,*) 'Max k:'
READ(*,*) kmax
WRITE(*,*) 'Dimension D:'
READ(*,*) DD
WRITE(*,*) 'String :'
READ(*,*) tpe
ALLOCATE(xx(kmax**DD,DD),ww(kmax**DD))
WRITE(*,*) 'Number of simulation repetitions:'
READ(*,*) simnum
ALLOCATE(sim(simnum))
CALL RANDOM_SEED(PUT=(/ 123456789,412648571 /))
CALL RANDOM_NUMBER(xx)
trueval=sum(fnc(xx))/dble(kmax**DD)
DO kk=1,kmax
! CALL nwspgr(tpe,DD,kk,nn,xx,ww)
CALL RANDOM_NUMBER(xx)
CALL RANDOM_NUMBER(ww)
WRITE(*,*) 'number of nodes:'
READ(*,*) nn
ALLOCATE(x(nn,DD),w(nn,1),g(nn,1))
x=xx(1:nn,1:DD)
w(1:nn,1)=ww(1:nn)
g(1:nn,1)=fnc(x)
SGappr = matmul(transpose(g),w)
SGerror = sqrt((SGappr - trueval)**2)/trueval
sim = 0.0d0
DO r=1,simnum
CALL RANDOM_NUMBER(x)
g(:,1)=fnc(x)
sim = sum(g(:,1))/(max(1,size(g(:,1))))
END DO
Simerror = sqrt(sum((sim(:)-trueval)**2)/(max(1,size(SIM(:)))))/trueval
WRITE(*,*) 'Number of nodes:'
WRITE(*,*) nn
WRITE(*,*) 'SG error='
WRITE(*,*) SGerror
WRITE(*,*) 'Sim. error='
WRITE(*,*) Simerror
DEALLOCATE(x,w,g)
END DO
END PROGRAM nwSpGr_demo
!=====================================================================================
! integrand: some function that evaluates g(x): (R times D)->(R times 1)
FUNCTION fnc(x1)
IMPLICIT NONE
! INTEGER(4) :: n1,d
REAL(8),INTENT(IN):: x1(:,:)
REAL(8) :: fnc(size(x1(:,1)))
REAL(8),PARAMETER :: pi=3.14159265359d0
INTEGER(4) :: i
DO i=1,size(x1(:,1))
fnc(i) = product( exp(-(x1(i,:)/2.0d0)**2 / 2.0d0)/2.0d0/sqrt(2.0d0*pi))
END DO
END FUNCTION fnc
I would appreciate any suggestions.
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The error message is coming from an interface consistency checker that CVF didn't have. However, in this case, it is not correctly handling the case of the function returning the array result with an expression bound.
There are two obvious alternatives:
1. Remove the INTERFACE block and move FNC to be a CONTAINed routine, so that the end of the code would look like this:
I prefer the first alternative, as I consider writing INTERFACE blocks for Fortran code to be poor style.
I will report this problem to the developers. The issue ID is DPD200148870. Thanks for bringing it to our attention.
There are two obvious alternatives:
1. Remove the INTERFACE block and move FNC to be a CONTAINed routine, so that the end of the code would look like this:
[plain]DEALLOCATE(x,w,g)2. Right click on the Fortran project. Select Properties > Fortran > Diagnostics. Change "Generate Interface Blocks" and "Check Routine Interfaces" to "No".
END DO
contains
!=====================================================================================
! integrand: some function that evaluates g(x): (R times D)->(R times 1)
FUNCTION fnc(x1)
IMPLICIT NONE
! INTEGER(4) :: n1,d
REAL(8),INTENT(IN):: x1(:,:)
REAL(8) :: fnc(size(x1(:,1)))
REAL(8),PARAMETER :: pi=3.14159265359d0
INTEGER(4) :: i
DO i=1,size(x1(:,1))
fnc(i) = product( exp(-(x1(i,:)/2.0d0)**2 / 2.0d0)/2.0d0/sqrt(2.0d0*pi))
END DO
END FUNCTION fnc
END PROGRAM nwSpGr_demo[/plain]
I prefer the first alternative, as I consider writing INTERFACE blocks for Fortran code to be poor style.
I will report this problem to the developers. The issue ID is DPD200148870. Thanks for bringing it to our attention.

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