Topic: Modules in SF
I am a beginner in Fortran, and maybe I am just stupid, but I have spent a huge amount of time trying to write programs that use modules that I have done myself. I need to make several numerical calculation programs, and some tasks are similar in all these programs. Therefore it would be nice to make a module that contains many functions that I need often. Can anyone tell me what goes wrong in the very simple test program below:
I have made a simple project with the name moduletest. It contains two files:
moduletest_main.f90:
program moduletest
use testmodule
implicit none
real :: x, y
x=2.0
y=testmodulefunction(x)
write(*,*) x, y
end program moduletest
testmodule.mod:
module testmodule
implicit none
real :: x, y
contains
function testmodulefunction(x) result(y)
y=x**2
end function testmodulefunction
end module testmodule
Build => Build Now! (F6) produces the following log:
==============================================================================
Open Watcom Make Version 1.9 (Built on May 17 2012)
Portions Copyright (c) 1988-2002 Sybase, Inc. All Rights Reserved.
Source code is available under the Sybase Open Watcom Public License.
See http://www.openwatcom.org/ for details.
"C:\Program Files (x86)\Simply Fortran\mingw-w64\bin\gfortran.exe" -c -o build\moduletest_main.o -g -m32 -Jmodules .\moduletest_main.f90
.\moduletest_main.f90:2.4:
use testmodule
1
Fatal Error: File 'testmodule.mod' opened at (1) is not a GFORTRAN module file
Error(E42): Last command making (build\moduletest_main.o) returned a bad status
Error(E02): Make execution terminated
* Complete *