- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The code below compiles in ifort. Accoring to at least one interpretation on the Stackoverflow question it is invalid, but ifort does not produce F2008/F2003 compliance warnings. Is intel's opion that this is correct, that it is an extension, or is it a bug? (if it is deliberate it is useful, but would also be nice to be able to get a warning as it doesn't work in gfortran, and know what the exact rule being applied is).
module classes
Type AData
end Type
Type A
contains
procedure :: Work
end type
Type, extends(AData) :: BData
end Type
Type, extends(A) :: B
contains
procedure :: Work => Work2
end type
contains
subroutine Work(this, D)
class(A) :: this
class(*) :: D
end subroutine
subroutine Work2(this, D)
class(B) :: this
class(BData) :: D
end subroutine
end module classes
Link Copied
- « Previous
-
- 1
- 2
- Next »
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Also the reverse of the first case is rejected by gfortran, eg
module classes implicit none Type AData end Type Type, extends(AData) :: BData end Type Type A contains procedure :: Work end type Type, extends(A) :: B contains procedure :: Work => Work2 end type contains subroutine Work(this, D) class(A) :: this Type(AData), intent(in) :: D end subroutine subroutine Work2(this, D) class(B) :: this Type(AData) :: D end subroutine end module classes
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
antony wrote:
The code below compiles in ifort.
... would also be nice to be able to get a warning as it doesn't work in gfortran, ..
[fortran]
module classes Type AData end Type Type A contains procedure :: Work end type Type, extends(AData) :: BData end Type Type, extends(A) :: B contains procedure :: Work => Work2 end type contains subroutine Work(this, D) class(A) :: this class(*) :: D end subroutine subroutine Work2(this, D) class(B) :: this class(BData) :: D end subroutine end module classes[/fortran]
I am curious about recent developments with gfortran, so finally got around to downloading and setting it up for Windows. The latest, convenient version I could find was MinGW 4.8.1 build.
NOTE: the above code builds without any errors/warnings in gfortran, MinGW 4.8.1 build:
[plain]
mingw32-gfortran.exe -JDebug\\GNU\\ -Wall -g -std=f2008 -Wrealloc-lhs-all -Wrealloc-lhs
-Wimplicit-interface -Wconversion -Warray-temporaries -Wall
-c C:\\dev\\Fortran\\TypeExtension\\sor\\ProcOverride.f90
-o Debug\\GNU\\sor\\ProcOverride.o
Process terminated with status 0 (0 minute(s), 0 second(s))
0 error(s), 0 warning(s) (0 minute(s), 0 second(s))
[/plain]
So perhaps a newer gfortran version (4.9+) has been improved on this procedure overriding aspect, but I can't find the newer version for Windows. 4.8.1 version also doesn't complain if the dummy argument in the overriding procedure uses an extended type. However 4.8.1 version does catch mismatches in the dummy argument INTENT.
My (obvious) take-away:
- Fortran 2008 (and some 2003) implementations are still "in the works" in most compilers,
- Coders need to think through and use new features with appropriate caution,
- Cross-checking using different compilers can help, especially with the newer features,
- Test, test, test.. report issues so everyone can benefit
Thanks to Antony for this bringing this up,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
We have fixed the issues discussed in this thread - I expect the fixes to appear in the 15.0 release later this year.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- « Previous
-
- 1
- 2
- Next »