Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Neophyte Interface problem

Intel_C_Intel
Сотрудник
437Просмотр.
Neophyte Fortran question:
I get errors with "name conflicts" in the following code.
Specifically, "The name of the module procedure conflicts with a name in the encompassing scoping unit. [DIAG_SET_LEVEL]
SUBROUTINE DIAG_SET_LEVEL(LEVEL)
^ "
What I want to do is to have a subroutine called "DIAG_SET" that calls "DIAG_SET_LEVEL" if the argument is an integer, and "DIAG_SET_NAME" ifthe argument is a character string. I want the subroutines to be in a module so that they are invisible unless the module is used. What am I doing wrong here?
Richard
MODULE DIAG
C
C Diagnostic "level"
INTEGER LDIAG
C
INTERFACE DIAG_SET
SUBROUTINE DIAG_SET_LEVEL( LEVEL )
IMPLICIT NONE
INTEGER, INTENT(IN) :: LEVEL
END SUBROUTINE DIAG_SET_LEVEL
SUBROUTINE DIAG_SET_NAME( NAME )
IMPLICIT NONE
CHARACTER (LEN=*), INTENT(IN) :: NAME
END SUBROUTINE DIAG_SET_NAME
END INTERFACE
C
CONTAINS
C
SUBROUTINE DIAG_SET_LEVEL(LEVEL)
IMPLICIT NONE
INTEGER, INTENT(IN) :: LEVEL
LOGICAL LSTAT
LDIAG = LEVEL
CALL DIAG_LIST('0',LSTAT)
RETURN
END SUBROUTINE DIAG_SET_LEVEL
C
SUBROUTINE DIAG_SET_NAME(NAME)
IMPLICIT NONE
LOGICAL LSTAT
CHARACTER (LEN=*), INTENT(IN) :: NAME
CALL DIAG_LIST('+'//NAME,LSTAT)
RETURN
END SUBROUTINE DIAG_SET_NAME
C
END MODULE DIAG
0 баллов
1 Ответить
Steven_L_Intel1
Сотрудник
437Просмотр.
What you have done is specify in the generic interface that the specific routines are external, and then you supplied the same routines internal to the module. Replace the generic interface block with this:


INTERFACE DIAG_SET
MODULE PROCEDURE DIAG_SET_LEVEL
MODULE_PROCEDURE DIAG_SET_NAME
END INTERFACE

This says that the specific routines are provided later in the module.
Ответить