blauwra1
03-11-2004, 02:22 AM
Has anyone had success spreading the definition of a generic interface across multiple files and modules? I have the situation (simplifying tremendously):
***file1:
module mod1
type type1
real(8) :: data1
real(8) :: data2
end type type1
interface init
module procedure type1_init
end interface init
contains
subroutine type1_init(obj,data1,data2)
type(type1) :: obj
real(8) :: data1
real(8) :: data2
obj%data1 = data1
obj%data2 = data2
end subroutine type1_init
end module mod1
***file2:
module mod2
use mod1
type type2
type(type1) :: obj1
type(type1) :: obj2
end type type2
interface init
module procedure type2_init
end interface init
contains
subroutine type2_init(obj,data1,data2)
type(type2) :: obj
real(8) :: data1
real(8) :: data2
call init(obj%obj1,data1,data2)
call init(obj%obj2,data2,data1)
end subroutine type2_init
end module mod2
--------------------------------------------
When I tried something like this on LF95 v6.1 on Linux I got an error about needing procedures specified in a generic interface to be all functions or all subroutines. I was porting this code from CVF 6.6C on Windows, where it compiled. No warnings were given there about this when I turned on F95 standard checking.
Thanks in advance for any suggestions,
Ross Blauwkamp
r.blauwkamp@ieee.org
***file1:
module mod1
type type1
real(8) :: data1
real(8) :: data2
end type type1
interface init
module procedure type1_init
end interface init
contains
subroutine type1_init(obj,data1,data2)
type(type1) :: obj
real(8) :: data1
real(8) :: data2
obj%data1 = data1
obj%data2 = data2
end subroutine type1_init
end module mod1
***file2:
module mod2
use mod1
type type2
type(type1) :: obj1
type(type1) :: obj2
end type type2
interface init
module procedure type2_init
end interface init
contains
subroutine type2_init(obj,data1,data2)
type(type2) :: obj
real(8) :: data1
real(8) :: data2
call init(obj%obj1,data1,data2)
call init(obj%obj2,data2,data1)
end subroutine type2_init
end module mod2
--------------------------------------------
When I tried something like this on LF95 v6.1 on Linux I got an error about needing procedures specified in a generic interface to be all functions or all subroutines. I was porting this code from CVF 6.6C on Windows, where it compiled. No warnings were given there about this when I turned on F95 standard checking.
Thanks in advance for any suggestions,
Ross Blauwkamp
r.blauwkamp@ieee.org