Topic: Problem with modules
I'm new to modern Fortran, and to Simply Fortran, which I downloaded a few days ago. Here's my problem. I built the following module:
module months
implicit none
integer, parameter, dimension(12) :: days_per_month = [31,28,31,30,31,30,31,31,30,31,30,31]
character(len = 9), parameter, dimension(12) :: month_names = [character(len=9) :: 'January','February','March','April','May',&
'June','July','August','September','October','November','December']
end module
The following program compiles and runs:
program test
use months
implicit none
write(*,*) days_per_month(1)
end program
but this program won't even compile:
program test
use months
implicit none
integer :: i
do i = 1,12
write(*,*) days_per_month(i)
end do
end program
The error message that I get is:
Generating target.exe
build\testmain.o:testmain.f90:(.rdata$.refptr.__months_MOD_days_per_month[.refptr.__months_MOD_days_per_month]+0x0): undefined reference to `__months_MOD_days_per_month'
collect2.exe: error: ld returned 1 exit status
Error: Last command making (target.exe) returned a bad status
Error: Make execution terminated
* Failed *
The file is saved as test.f90, and I did not change any compiler defaults. What am I doing wrong??