In the Fortran 2003 module, I define a type called t_savepoint , and later I want to define an interface for a routine called fs_initializesavepoint that takes an object of type t_savepoint as an argument.
Here is the code for the whole module:
module m_serialization implicit none type :: t_savepoint integer :: savepoint_index real :: savepoint_value end type t_savepoint interface subroutine fs_initializesavepoint(savepoint) type(t_savepoint) :: savepoint end subroutine fs_initializesavepoint end interface end module m_serialization
The reason I need such an interface is because later on I will make this fortran module interact with C.
If I try to compile it (gfortran-4.7.0), I get the following error message:
type(t_savepoint) :: savepoint 1 Error: The type of 'savepoint' at (1) has not been declared within the interface
The error disappears if I go on to type definition inside a routine; but if then I want to use the same type in many routines, should I repeat the definition in all of them?
Thanks in advance.
EDIT : The solution would be to move the type definition to another module, and then to use in each subroutine. However, I do not really like this solution, because the t_savepoint type and routines are part of the same conceptual theme.
source share