- Marcar como nuevo
- Favorito
- Suscribir
- Silenciar
- Suscribirse a un feed RSS
- Resaltar
- Imprimir
- Informe de contenido inapropiado
If a parent module has an IMPLICIT NONE statement and this module is accessed through a USE statement in a descendant module without an IMPLICIT NONE statement, does the IMPLICIT NONE apply to descendant module? In my recent experience, the implicit none does not. As a result, some of my legacy code generates compilation errors or worse still, continues executing with unrealistic numbers. This seems to be irrespective of compiler settings. An example is included below. Any help would be greatly appreciated.
module parent
implicit none
integer(kind = 4) :: a, b
contains
subroutine psub()
a = 1
b = 2
! c = 3 ! generates compilation error since c is not declared
print *, 'a = ', a
print *, 'b = ', b
! print *, 'c = ', c ! generates compilation error since c is not declared
end subroutine psub
end module parent
module descendant
use parent
contains
subroutine dsub()
d = 4 ! does not generate compilation error even though d is not declared
call psub()
call tsub(i)
print *, 'd = ', d ! prints d as a single precision number 4.000000
read *
end subroutine dsub
subroutine tsub(i)
integer(kind = 4) :: i
print *, 'In tsub: i = ', i ! prints i = -858993460 since expected argument is mismatched in type
end subroutine tsub
end module descendant
program main
use descendant
call dsub()
end program main
- Etiquetas:
- Intel® Fortran Compiler
Enlace copiado
- Marcar como nuevo
- Favorito
- Suscribir
- Silenciar
- Suscribirse a un feed RSS
- Resaltar
- Imprimir
- Informe de contenido inapropiado
It does not carry into the scope of the contained routine or other module. This was discussed in part (your variable c) in an earlier thread, https://software.intel.com/en-us/forums/intel-visual-fortran-compiler-for-windows/topic/287958.
Specifically regarding inheritance through USE, Advice from others is, it does not. USE makes declared entities accessible, but it doesn’t carry along other aspects of the module such as IMPLICIT.
- Marcar como nuevo
- Favorito
- Suscribir
- Silenciar
- Suscribirse a un feed RSS
- Resaltar
- Imprimir
- Informe de contenido inapropiado
Thanks, @Kevin D. So to be clear, with reference to my example above
1. the implicit none declared in module parent will apply to any subroutines or functions contained in the parent module.
2. the implicit none declared in module parent will not apply to any module such as module descendant that invokes parent through a use statement.
- Marcar como nuevo
- Favorito
- Suscribir
- Silenciar
- Suscribirse a un feed RSS
- Resaltar
- Imprimir
- Informe de contenido inapropiado
Yes, that is correct. My apologies, I "mis-spoke" in my reply as to your item 1.
- Marcar como nuevo
- Favorito
- Suscribir
- Silenciar
- Suscribirse a un feed RSS
- Resaltar
- Imprimir
- Informe de contenido inapropiado
Thanks, @Kevin D - that's what I thought. Now clear and confirmed by running the code.

- Suscribirse a un feed RSS
- Marcar tema como nuevo
- Marcar tema como leído
- Flotar este Tema para el usuario actual
- Favorito
- Suscribir
- Página de impresión sencilla