I am learning how to distribute the code across modules in Fortran 95.
I have the following code which intends to use two derived types:
file_parser_2.f95
program file_parser_2
use data_model_2
implicit none
! -------------------
! VARIABLE DEFINITION
! -------------------
integer :: i, io_result
integer :: lines_read
type(type1_record) :: line_read
type(timestamp_record) :: timestamp_read
! -------------------
! READ RECORDS
! -------------------
lines_read = 0
do
! READ LINE TO line_read IF AVAILABLE
read(*,*,iostat=io_result) line_read
if (io_result /= 0) exit
! PARSE TIMESTAMP
timestamp_read%year = line_read%year
timestamp_read%month = line_read%month
timestamp_read%day = line_read%day
timestamp_read%hour = line_read%hour
timestamp_read%minute = line_read%minute
timestamp_read%second = line_read%second
! DO OTHER STUFF
! TBC
end do
end program
The program does nothing, just reads input and process it according to those fields. It is intentionally stripped down to cover the specific question.
As those derived types will be used in different modules and potentially in different programs, I have put them in a separate module named data_model.
data_model_2.f95
module data_model_2
! -------------------
! TYPE DEFINITION
! -------------------
type :: type1_record
integer :: month
integer :: day
integer :: year
integer :: hour
integer :: minute
integer :: second
integer :: value1
integer :: value2
end type
type :: timestamp_record
integer :: year
integer :: month
integer :: day
integer :: hour
integer :: minute
integer :: second
end type
end module
I try to compile them but I get Corrupted module error:
$ flang file_parser_2.f95
F90-F-0004-Corrupt or Old Module file ./data_model_2.mod (file_parser_2.f95: 5)
F90/x86-64 FreeBSD Flang - 1.5 2017-05-01: compilation aborted
$
Why am I getting this error?