Because I couldnât find the format of .mod
file on the net (but the page is now shown in the above comment!! thank you), I played around a bit with the following .mod
file.
module mymod
implicit none
integer, parameter :: dp = kind(0.0d0)
contains
subroutine mysub1( n, x, z )
integer :: n
real :: x
complex :: z
print *, n, x, z
end
subroutine mysub2( s, n, x, z )
character(*), intent(in) :: s
integer, intent(in) :: n
real(dp), intent(out) :: x
complex(dp), intent(inout) :: z
x = 1.0; z = z + 1.0
print *, s, n, x, z
end
subroutine mysub3( a1, a2, a3, b1, b2, c, n1, n2 )
real :: a1(:), a2(:,:), a3(:,:,:)
real :: b1( 123 ), b2( 456, 789 ), c( n1, n2 )
integer :: n1, n2
print *, a1, a2, a3, b1, b2, c, n1, n2
end
end module
Following this page (module - Is it possible to determine which Fortran compiler generated a ".mod" file? - Stack Overflow)
$ gfortran-10 -c mymod.f90
$ cp mymod.mod mymod.txt.gz
$ gzip -d mymod.txt.gz
$ cat mymod.txt
which shows (arrows by me)
GFORTRAN module version '15' created from mymod.f90
...
(2 'dp' 'mymod' '' 1 ((PARAMETER UNKNOWN-INTENT UNKNOWN-PROC UNKNOWN
IMPLICIT-SAVE 0 0) () (INTEGER 4 0 0 0 INTEGER ()) 0 0 () (CONSTANT (
INTEGER 4 0 0 0 INTEGER ()) 0 '8' ()) () 0 () () () 0 0)
3 'kind' '(intrinsic)' '' 1 ((PROCEDURE UNKNOWN-INTENT UNKNOWN-PROC
UNKNOWN UNKNOWN 0 0 FUNCTION ARRAY_OUTER_DEPENDENCY) () (UNKNOWN 0 0 0 0
UNKNOWN ()) 0 0 () () 3 () () () 0 0)
4 'mymod' 'mymod' '' 1 ((MODULE UNKNOWN-INTENT UNKNOWN-PROC UNKNOWN
UNKNOWN 0 0) () (UNKNOWN 0 0 0 0 UNKNOWN ()) 0 0 () () 0 () () () 0 0)
5 'mysub1' 'mymod' '' 1 ((PROCEDURE UNKNOWN-INTENT MODULE-PROC DECL
UNKNOWN 0 0 SUBROUTINE) () (UNKNOWN 0 0 0 0 UNKNOWN ())
6 0 (7 8 9) <-----
() 0 () () () 0 0)
10 'mysub2' 'mymod' '' 1 ((PROCEDURE UNKNOWN-INTENT MODULE-PROC DECL
UNKNOWN 0 0 SUBROUTINE) () (UNKNOWN 0 0 0 0 UNKNOWN ())
11 0 (12 13 14 15) <------
() 0 () () () 0 0)
16 'mysub3' 'mymod' '' 1 ((PROCEDURE UNKNOWN-INTENT MODULE-PROC DECL
UNKNOWN 0 0 SUBROUTINE ALWAYS_EXPLICIT) () (UNKNOWN 0 0 0 0 UNKNOWN ())
17 0 (18 19 20 21 22 23 24 25) <------
() 0 () () () 0 0)
7 'n' '' '' 6 ((VARIABLE UNKNOWN-INTENT UNKNOWN-PROC UNKNOWN UNKNOWN 0 0
DUMMY) () (INTEGER 4 0 0 0 INTEGER ()) 0 0 () () 0 () () () 0 0)
8 'x' '' '' 6 ((VARIABLE UNKNOWN-INTENT UNKNOWN-PROC UNKNOWN UNKNOWN 0 0
DUMMY) () (REAL 4 0 0 0 REAL ()) 0 0 () () 0 () () () 0 0)
9 'z' '' '' 6 ((VARIABLE UNKNOWN-INTENT UNKNOWN-PROC UNKNOWN UNKNOWN 0 0
DUMMY) () (COMPLEX 4 0 0 0 COMPLEX ()) 0 0 () () 0 () () () 0 0)
12 's' '' '' 11 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 DUMMY) ()
(CHARACTER 1 0 0 0 CHARACTER (())) 0 0 () () 0 () () () 0 0)
13 'n' '' '' 11 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 DUMMY) ()
(INTEGER 4 0 0 0 INTEGER ()) 0 0 () () 0 () () () 0 0)
14 'x' '' '' 11 ((VARIABLE OUT UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 DUMMY) ()
(REAL 8 0 0 0 REAL ()) 0 0 () () 0 () () () 0 0)
15 'z' '' '' 11 ((VARIABLE INOUT UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 DUMMY)
() (COMPLEX 8 0 0 0 COMPLEX ()) 0 0 () () 0 () () () 0 0)
18 'a1' '' '' 17 ((VARIABLE UNKNOWN-INTENT UNKNOWN-PROC UNKNOWN UNKNOWN
0 0 DIMENSION DUMMY) () (REAL 4 0 0 0 REAL ()) 0 0 () (1 0 ASSUMED_SHAPE
(CONSTANT (INTEGER 4 0 0 0 INTEGER ()) 0 '1' ()) ()) 0 () () () 0 0)
19 'a2' '' '' 17 ((VARIABLE UNKNOWN-INTENT UNKNOWN-PROC UNKNOWN UNKNOWN
0 0 DIMENSION DUMMY) () (REAL 4 0 0 0 REAL ()) 0 0 () (2 0 ASSUMED_SHAPE
(CONSTANT (INTEGER 4 0 0 0 INTEGER ()) 0 '1' ()) () (CONSTANT (INTEGER 4
0 0 0 INTEGER ()) 0 '1' ()) ()) 0 () () () 0 0)
20 'a3' '' '' 17 ((VARIABLE UNKNOWN-INTENT UNKNOWN-PROC UNKNOWN UNKNOWN
0 0 DIMENSION DUMMY) () (REAL 4 0 0 0 REAL ()) 0 0 () (3 0 ASSUMED_SHAPE
(CONSTANT (INTEGER 4 0 0 0 INTEGER ()) 0 '1' ()) () (CONSTANT (INTEGER 4
0 0 0 INTEGER ()) 0 '1' ()) () (CONSTANT (INTEGER 4 0 0 0 INTEGER ()) 0
'1' ()) ()) 0 () () () 0 0)
21 'b1' '' '' 17 ((VARIABLE UNKNOWN-INTENT UNKNOWN-PROC UNKNOWN UNKNOWN
0 0 DIMENSION DUMMY) () (REAL 4 0 0 0 REAL ()) 0 0 () (1 0 EXPLICIT (
CONSTANT (INTEGER 4 0 0 0 INTEGER ()) 0 '1' ()) (CONSTANT (INTEGER 4 0 0
0 INTEGER ()) 0 '123' ())) 0 () () () 0 0)
22 'b2' '' '' 17 ((VARIABLE UNKNOWN-INTENT UNKNOWN-PROC UNKNOWN UNKNOWN
0 0 DIMENSION DUMMY) () (REAL 4 0 0 0 REAL ()) 0 0 () (2 0 EXPLICIT (
CONSTANT (INTEGER 4 0 0 0 INTEGER ()) 0 '1' ()) (CONSTANT (INTEGER 4 0 0
0 INTEGER ()) 0 '456' ()) (CONSTANT (INTEGER 4 0 0 0 INTEGER ()) 0 '1' ())
(CONSTANT (INTEGER 4 0 0 0 INTEGER ()) 0 '789' ())) 0 () () () 0 0)
23 'c' '' '' 17 ((VARIABLE UNKNOWN-INTENT UNKNOWN-PROC UNKNOWN UNKNOWN 0
0 DIMENSION DUMMY) () (REAL 4 0 0 0 REAL ()) 0 0 () (2 0 EXPLICIT (
CONSTANT (INTEGER 4 0 0 0 INTEGER ()) 0 '1' ()) (VARIABLE (INTEGER 4 0 0
0 INTEGER ()) 0 24 () ()) (CONSTANT (INTEGER 4 0 0 0 INTEGER ()) 0 '1' ())
(VARIABLE (INTEGER 4 0 0 0 INTEGER ()) 0 25 () ())) 0 () () () 0 0)
24 'n1' '' '' 17 ((VARIABLE UNKNOWN-INTENT UNKNOWN-PROC UNKNOWN UNKNOWN
0 0 DUMMY) () (INTEGER 4 0 0 0 INTEGER ()) 0 0 () () 0 () () () 0 0)
25 'n2' '' '' 17 ((VARIABLE UNKNOWN-INTENT UNKNOWN-PROC UNKNOWN UNKNOWN
0 0 DUMMY) () (INTEGER 4 0 0 0 INTEGER ()) 0 0 () () 0 () () () 0 0)
)
('dp' 0 2 'kind' 0 3 'mymod' 0 4 'mysub1' 0 5 'mysub2' 0 10 'mysub3' 0
16)
so if .mod files are created by Gfortran, it might be possible to get some info somehow (though extremely unreadableâŚ) I hope some tools like gfort2py (?) will show such info in a more readable way