- Marcar como novo
- Marcador
- Subscrever
- Silenciar
- Subscrever fonte RSS
- Destacar
- Imprimir
- Denunciar conteúdo inapropriado
module mymod
implicit none
integer, protected :: n
interface
module subroutine set_n(i)
integer, intent(in) :: i
end subroutine set_n
end interface
end module mymod
submodule(mymod) mymod_i
contains
module subroutine set_n(i)
integer, intent(in) :: i
n = i
end subroutine set_n
end submodule mymod_i
program test
use mymod
implicit none
integer :: i
i = 5
call set_n(i)
print *,n
end program test
The above code fails to compile with the error
ifort tc.f90
Intel(R) Visual Fortran Intel(R) 64 Compiler for applications running on Intel(R) 64, Version 16.0.2.180 Build 20160204
Copyright (C) 1985-2016 Intel Corporation. All rights reserved.
tc.f90(17): error #7986: A use associated object that has the PROTECTED attribute shall not appear in a variable definition context.
n = i
----------------^
compilation aborted for tc.f90 (code 1)
Is it possible to protect module data and still use the sub-module structure? If I had written this in just a single module there would not have been a problem. Shouldn't a sub-module's procedures have the same access rights to module data as if they were part of the module?
Thanks.
- Marcas:
- Intel® Fortran Compiler
Link copiado
- Marcar como novo
- Marcador
- Subscrever
- Silenciar
- Subscrever fonte RSS
- Destacar
- Imprimir
- Denunciar conteúdo inapropriado
I think this is a compiler bug. A submodule does not "use associate" from its parent (and in fact is not allowed to). I will report it to the developers.
- Marcar como novo
- Marcador
- Subscrever
- Silenciar
- Subscrever fonte RSS
- Destacar
- Imprimir
- Denunciar conteúdo inapropriado
Thanks for your prompt response. I'll just have to drop the 'protected' qualification for now.
- Marcar como novo
- Marcador
- Subscrever
- Silenciar
- Subscrever fonte RSS
- Destacar
- Imprimir
- Denunciar conteúdo inapropriado
This bug has been fixed for a future release.
- Marcar como novo
- Marcador
- Subscrever
- Silenciar
- Subscrever fonte RSS
- Destacar
- Imprimir
- Denunciar conteúdo inapropriado
Great - thanks. By future do you mean 16.x or 17.x ?
- Marcar como novo
- Marcador
- Subscrever
- Silenciar
- Subscrever fonte RSS
- Destacar
- Imprimir
- Denunciar conteúdo inapropriado
17.0 - it may or may not get fixed in a 16.0 update.
- Marcar como novo
- Marcador
- Subscrever
- Silenciar
- Subscrever fonte RSS
- Destacar
- Imprimir
- Denunciar conteúdo inapropriado
Looks as if it will be fixed in 16.0 Update 3, scheduled for May.
- Subscrever fonte RSS
- Marcar tópico como novo
- Marcar tópico como lido
- Flutuar este Tópico para o utilizador atual
- Marcador
- Subscrever
- Página amigável para impressora