I am new to Fortran and I had made a program where everything did fit into one single file, which worked. However when i tried to take out parts and put them into modules and subroutines I quickly ran into problems. Even after removing everything and having only the bare minimum left, it still gives an error regarding the subroutine.
Currently the heavily reduced main program looks like this. It only uses the module and calls the subroutine.
program test
use mod1
call sub1(var)
end program test
and the module looks like:
Module mod1
implicit none
type A
real :: type1
end type A
contains
subroutine sub1(var)
type(A) :: var
var%type1 = 1+1
end subroutine sub1
However I seem to do something wrong here and unfortunately I can not figure out what. I get the error
||Error: Type mismatch in argument 'var' ; passed REAL(4) to TYPE(a)|
end module mod1
Can someone please explain which fundamental mistake I am making in order to prevent the most basic subroutine from working?
varin the main program... could this be the problem? - darthbithvaris (implicitly) defined to be aREAL, whereasAonly contains aREAL. I think you need something like...type (A) varbefore you callsub1(). Fortran is very picky about data types. If you copy the definition ofAinto the main program, that will fail with an even more cryptic error. - John C