mohamedmoussa
mohamedmoussa

Reputation: 559

Fortran subroutine overloading with submodules

I'm learning Fortran and using the Intel compiler.

Here is some code that I wrote. I want to define the print_array interface in the arraytools module, and all the specific implementations (e.g. print_array_rp) should go into a seperate sub-module. The following works, but if I split the implementation into a submodule, I get a huge amount of compiler errors (I suppose it cant find the implementation anymore).

module arraytools
use precision

implicit none

    interface print_array
        module procedure print_array_rp
    end interface

contains

    subroutine print_array_rp(arr, fmt_in)
       ! ... Implementation not important
    end subroutine

end module

How do I split print_array_rp off into a sub-module? I don't want to use #include instead.

Upvotes: 1

Views: 913

Answers (1)

casey
casey

Reputation: 6915

Submodules are not implemented in current Fortran compilers (unless you happen to be using the Cray compiler).

Only the Cray Fortran compiler implements the entire Fortran 2008 standard (thanks to VladimirF for pointing this out). Among the most poorly supported features among the other compilers are submodules.

The Fortran 2008 status wiki page (last modified Nov 2014 at the time of this post) lists Cray Fortran 8.1.1 as supporting submodules and Absoft 14, gfortran 4.8, HP, ifort 14.1, NAG 5.3.1, Oracle, Pathscale 4 and pgi 14.1 as not supporting submodules. As far as I am aware, none of these compilers has added support for submodules since then.

As noted in the comments below by Steve "Dr. Fortran" Lionel, Intel Fortran will gain submodule support in version 16 to be released later this year.

Upvotes: 2

Related Questions