0

I trying to get dynamic memory allocation to work but i cant seem to get it right.

program test
    implicit none
    integer i,j, error,size
    real, dimension(2), allocatable :: inputMatrix 
    
    
    print *, "Input the number of equations (and variables): "
    read *, size
    allocate (inputMatrix(size,size), stat = error)
    
    print *, "enter coefficients from your equations"
    do i = 1, size
        do j = 1, size
            read *, inputMatrix(j,i)
        end do
    end do
    deallocate (inputMatrix, stat = error)
    end program

when i compile i get
Error 1 error #6646: ALLOCATABLE or POINTER attribute dictates a deferred-shape-array [INPUTMATRIX] C:\Users\Nathan\Documents\fortran\test.f90 8


any ideas why? if there are logic errors that would not effect compilation, the don't bother mentioning them i just want it to compile. I can debug it later when i write the rest of the program.

1
Contributor
1
Reply
2
Views
7 Years
Discussion Span
Last Post by shindu
0

I figured it out. If any one is having a problem like this.

real, dimension(2), allocatable :: inputMatrix

should be

real inputMatrix[allocatable](:,:)
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.