-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fortran 2008 submodule #4704
Comments
log output for the above example. Changing the order of the .f90 files in the
|
Here is the verbose output of CMake building this executable correctly:
|
Here is how one can build the executable manually. The compiler commands must be issued in this order--the module must be compiled before the submodules.
For simplicity, here is a table of the module and submodule files generated by several popular Fortran compilers:
|
How do modules and submodules behave with respect to each other? Can there be multiple modules and/or submodules in a single file? Also your post above the table says the output file name is |
it's Yes there can be multiple modules and submodules in a single file, though more often for clarity they are put in separate files. This gives an excellent description of Fortran submodule hierarchy The times when you need to use I put some example code with |
I don't think this issue is resolved yet. submodule (mother) mother
contains
module elemental real function pi2tau
pi2tau = 2*pi
end function pi2tau
end submodule mother
module mother
real, parameter :: pi = 4.*atan(1.)
real :: tau
interface
module elemental real function pi2tau(pi)
real, intent(in) :: pi
end function pi2tau
end interface
contains
end module mother
program hier1
use mother
tau = pi2tau(pi)
print *,'pi=',pi, 'tau=', tau
end program
project('submodule single level', 'fortran')
hier2 = executable('main', 'main.f90','child.f90','parent.f90')
|
Are you testing |
@QuLogic yes, I am testing master.
|
fixed by #5039 |
meson(built from scivision) failed to build dependencies between source files in this example. SUBMODULE(parent) child
IMPLICIT NONE
CONTAINS
MODULE PURE SUBROUTINE mince( a, b )
REAL, INTENT(IN) :: a
REAL, INTENT(OUT) :: b
b = -a
END SUBROUTINE mince
END SUBMODULE child
MODULE parent
IMPLICIT NONE
INTERFACE
MODULE PURE SUBROUTINE mince( a, b )
REAL, INTENT(IN) :: a
REAL, INTENT(OUT) :: b
END SUBROUTINE mince
END INTERFACE
END MODULE parent
PROGRAM main
USE parent
IMPLICIT NONE
REAL :: b
CALL mince(1.,b)
PRINT*, b
END PROGRAM main
project('submod', 'fortran')
test = executable('main', 'main.f90', 'parent.f90', 'child.f90')
I have looked into |
The syntax of the example is incorrect. There should be a space between I have updated the Meson Fortran submodule regex to allow for this non-standard but unambiguous syntax. You might be aware that it is not necessary to specify the interface of a submodule procedure in the module and submodule. It could be simplified to: child1.f90: SUBMODULE (parent) child
IMPLICIT NONE
CONTAINS
MODULE procedure mince
b = -a
END procedure mince
END SUBMODULE child |
Non-standard! I always enable standard checking flags (-std=f2018, -stand f18 ...) and no compiler complains about my syntax. |
Have you tried to build my example?. Because on my side nothing has changed with your last commits, I still get the same problem with dependencies. |
06ad37c Now I made sure that both functions use the same submodule-finding pattern, so it works now and as seen by inspection of the build.ninja file. Thanks |
Fortran 2008 added
submodule
, which is quite useful for good structure and fast builds of Fortran programs. The present lack ofsubmodule
support in Meson is a key blocker for Fortran use.Meson does not appear to understand the
submodule
statement. A self-contained single.f90
file will of course compile correctly, but almost all use cases forsubmodule
are where the submodule is in a different.f90
file from themodule
containing thesubmodule
.Here is a simple example consisting of two files.
file
basic.f90
file
basic_sub.f90
file
meson.build
The text was updated successfully, but these errors were encountered: