this is the code
module Util
use, intrinsic :: iso_c_binding, only : c_int
interface
function Util_Rand() bind(c, name = "rand")
import c_int
integer(c_int) :: Util_Rand
end function Util_Rand
end interface
function Util_RandomRange(minimum, maximum)
integer :: Util_RandomRange
integer :: minimum, maximum
Util_RandomRange = mod(c_rand() + minimum, maximum)
end function Util_RandomRange
end module Util
and error
src/util.f90:9:5:
9 | function Util_RandomRange(minimum, maximum)
| 1
Error: Unclassifiable statement at (1)
wrong function call name…
im so stupid
now its this and im confused
function Util_RandomRange(minimum, maximum)
integer :: Util_RandomRange
integer :: minimum, maximum
integer :: randReturn
randReturn = Util_Rand()
Util_RandomRange = mod(randReturn + minimum, maximum)
end function Util_RandomRange
You are missing a contains
statement.
1 Like
I have forgotten the contains
statement many times. Since beginners may also do this, a clear message would be good. For
module m
implicit none
subroutine hello()
print*,"hi"
end subroutine hello
end module m
I think the error message would ideally be something like
module procedure hello defined before contains statement
since that clarifies what needs to be done. For the code shown,
lfortran -c
says
syntax error: Token 'subroutine' is unexpected here
--> contains.f90:3:1
|
3 | subroutine hello()
| ^^^^^^^^^^
gfortran -c
says
contains.f90:3:1:
3 | subroutine hello()
| 1
Error: Unclassifiable statement at (1)
contains.f90:4:11:
4 | print*,"hi"
| 1
Error: Unexpected WRITE statement in MODULE at (1)
contains.f90:5:3:
5 | end subroutine hello
| 1
Error: Expecting END MODULE statement at (1)
ifort -c
says
contains.f90(3): error #6218: This statement is positioned incorrectly and/or has syntax errors.
subroutine hello()
^
contains.f90(4): error #6274: This statement must not appear in the specification part of a module.
print*,"hi"
^
contains.f90(5): error #6786: This is an invalid statement; an END [MODULE] statement is required.
end subroutine hello
^
contains.f90(5): error #6785: This name does not match the unit name. [HELLO]
end subroutine hello
---------------^
contains.f90(6): error #6790: This is an invalid statement; an END [PROGRAM] statement is required.
end module m
^
contains.f90(6): error #6785: This name does not match the unit name. [M]
end module m
-----------^
compilation aborted for contains.f90 (code 1)
1 Like