- Marquer comme nouveau
- Marquer
- S'abonner
- Sourdine
- S'abonner au fil RSS
- Surligner
- Imprimer
- Signaler un contenu inapproprié
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)
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
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
- Balises:
- Intel® Fortran Compiler
Lien copié
1 Répondre
- Marquer comme nouveau
- Marquer
- S'abonner
- Sourdine
- S'abonner au fil RSS
- Surligner
- Imprimer
- Signaler un contenu inapproprié
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:
This says that the specific routines are provided later in the module.
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.
Répondre
Options du sujet
- S'abonner au fil RSS
- Marquer le sujet comme nouveau
- Marquer le sujet comme lu
- Placer ce Sujet en tête de liste pour l'utilisateur actuel
- Marquer
- S'abonner
- Page imprimable