在 fortran 中排列数组
Arranged array in gfortran
Program allo
Implicit none
integer :: A,ok,i,B,k
Real, Dimension (:,:), Allocatable :: note
Print*, "enter line A"
Read*, A
Print*, "enter range B"
Read* ,B
Allocate (note(A,B), STAT=ok)
If (ok/=0) then
print*, "failed"
STOP
end if
Do i=1,A
Do k=1,B
Read*, note(i,k)
End do
End do
print*,shape(note, /A,B/)
Deallocate (note)
End Program allo
当我在没有 "shape" 选项的情况下正常编译它时,它在 1 行上给我一个数组,我想要 (A,B) 数组。我试图塑造它以获得完美的 table 但它给了我错误。
Program allo
Implicit none
integer :: A,ok,i,B,k
Real, Dimension (:,:), Allocatable :: note
Print*, "enter line A"
Read*, A
Print*, "enter range B"
Read* ,B
Allocate (note(A,B), STAT=ok)
If (ok/=0) then
print*, "failed"
STOP
end if
Do i=1,A
Do k=1,B
Read*, note(i,k)
End do
End do
print*,shape(note, /A,B/)
Deallocate (note)
End Program allo
当我在没有 "shape" 选项的情况下正常编译它时,它在 1 行上给我一个数组,我想要 (A,B) 数组。我试图塑造它以获得完美的 table 但它给了我错误。