hi all, i'm trying to write a very simple program, which prompts me for matrix dimensions (m,n) and then outputs a m x n matrix of ones (1's) on the display. the thing obviously doesn't work - if you can help me, i'd be very grateful!
my CODE:__________________________________________________
subroutine matrix(row,column,array)
implicit none
integer, intent(in) :: row,column
integer, dimension(row,column), intent(out) :: array
integer :: i,j
do i = 1,row
do j = 1,column
array(i,j) = 1
end do
end do
end subroutine matrix
!***
program mxn
implicit none
integer :: m,n
integer, dimension(m,n) :: matr
print *,"m,n:"
read *,m,n
call matrix(m,n,matr)
print *, matr
end program mxn
MY ERROR msg's:_______________________________________
Compiling Fortran...
C:\Documents and Settings\mlicer\My Documents\fortran\mxn_matrix.f90
C:\Documents and Settings\mlicer\My Documents\fortran\mxn_matrix.f90(23) : Error: A specification expression object must be a dummy argument, a COMMON block object, or an object accessible through host or use association [M]
integer :: m,n
-----------^
C:\Documents and Settings\mlicer\My Documents\fortran\mxn_matrix.f90(23) : Error: A specification expression object must be a dummy argument, a COMMON block object, or an object accessible through host or use association [N]
integer :: m,n
-------------^
C:\Documents and Settings\mlicer\My Documents\fortran\mxn_matrix.f90(24) : Error: An automatic object is invalid in a main program. [MATR]
integer, dimension(m,n) :: matr
___________________________________________________
does anyone know what i'm doing wrong? i can't figure it out...thanks a lot!
my CODE:__________________________________________________
subroutine matrix(row,column,array)
implicit none
integer, intent(in) :: row,column
integer, dimension(row,column), intent(out) :: array
integer :: i,j
do i = 1,row
do j = 1,column
array(i,j) = 1
end do
end do
end subroutine matrix
!***
program mxn
implicit none
integer :: m,n
integer, dimension(m,n) :: matr
print *,"m,n:"
read *,m,n
call matrix(m,n,matr)
print *, matr
end program mxn
MY ERROR msg's:_______________________________________
Compiling Fortran...
C:\Documents and Settings\mlicer\My Documents\fortran\mxn_matrix.f90
C:\Documents and Settings\mlicer\My Documents\fortran\mxn_matrix.f90(23) : Error: A specification expression object must be a dummy argument, a COMMON block object, or an object accessible through host or use association [M]
integer :: m,n
-----------^
C:\Documents and Settings\mlicer\My Documents\fortran\mxn_matrix.f90(23) : Error: A specification expression object must be a dummy argument, a COMMON block object, or an object accessible through host or use association [N]
integer :: m,n
-------------^
C:\Documents and Settings\mlicer\My Documents\fortran\mxn_matrix.f90(24) : Error: An automatic object is invalid in a main program. [MATR]
integer, dimension(m,n) :: matr
___________________________________________________
does anyone know what i'm doing wrong? i can't figure it out...thanks a lot!