- #1
Taff
- 1
- 0
hello, I'm trying to write a program with a subroutine that can handle array valued functions of different dimensions, I'm new to fortran 90 so i have some troubles.
Here's what i tried:
program passing
use functions
use sub_mod
implicit none
integer, dimension(2,2):: a2
integer, dimension(3,3):: a3
call prova(a2,g2)
!print*,a2
call prova(a3,g3)
!print*,a3
end program passing
module functions
implicit none
contains
function g2(x)
implicit none
!result
integer,dimension(2,2) :: g2
!dummy
integer x
g2(1,1)=x+2
g2(1,2)=x+2
g2(2,1)=x+2
g2(2,2)=x+2
end function g2
function g3(x)
implicit none
!result
integer,dimension(3,3) :: g3
!dummy
integer x
g3(1,1)=x+3
g3(1,2)=x+3
g3(2,1)=x+3
g3(2,2)=x+3
end function g3
end module functions
module sub_mod
implicit none
contains
subroutine prova(a,f)
!dummy
integer,dimension(:,:) :: a
integer,dimension(size(a,1),size(a,2)) :: f
external f
a=f(0)
end subroutine prova
end module sub_modi got 1 compiler error "can't open module file sub_mod.mod..."
Here's what i tried:
program passing
use functions
use sub_mod
implicit none
integer, dimension(2,2):: a2
integer, dimension(3,3):: a3
call prova(a2,g2)
!print*,a2
call prova(a3,g3)
!print*,a3
end program passing
module functions
implicit none
contains
function g2(x)
implicit none
!result
integer,dimension(2,2) :: g2
!dummy
integer x
g2(1,1)=x+2
g2(1,2)=x+2
g2(2,1)=x+2
g2(2,2)=x+2
end function g2
function g3(x)
implicit none
!result
integer,dimension(3,3) :: g3
!dummy
integer x
g3(1,1)=x+3
g3(1,2)=x+3
g3(2,1)=x+3
g3(2,2)=x+3
end function g3
end module functions
module sub_mod
implicit none
contains
subroutine prova(a,f)
!dummy
integer,dimension(:,:) :: a
integer,dimension(size(a,1),size(a,2)) :: f
external f
a=f(0)
end subroutine prova
end module sub_modi got 1 compiler error "can't open module file sub_mod.mod..."