我在这个程序中的子程序有问题,它位于程序的末尾。我在子例程中对数组进行划分时遇到错误,它显示“不可分类语句”。希望有人能帮忙!
PROGRAM subroutine1
IMPLICIT NONE
INTEGER:: err, ierr, counter, y ,i ,j
!INTEGER, ALLOCATABLE:: gamenum(:)
CHARACTER(30):: fname
REAL, ALLOCATABLE:: AB(:), H(:), TB(:), BA (:), SP(:)
100 Format (A)
200 Format (I2)
300 Format (F9.3)
! 1.Open file
WRITE(*,100)"Please enter a filename:"
READ(*,*) fname
OPEN (UNIT=10, FILE=fname, STATUS="OLD", ACTION="READ", IOSTAT=err)
IF(err.NE.0) STOP "An error occured when opening the file."
! 2.Count Lines
READ(10,*)
counter=0
DO
READ(10,*,IOSTAT=ierr)
IF(ierr .NE. 0) EXIT
counter=counter+1
END DO
!WRITE(*,200) counter
! 3. allocate array
ALLOCATE(AB(counter))
ALLOCATE(H(counter))
ALLOCATE(TB(counter))
ALLOCATE(BA (counter))
ALLOCATE(SP(counter))
! 4. read in data
REWIND(10)
READ(10,*)
DO i=1,counter
READ(10,*) AB(i), H(i), TB(i)
END DO
REWIND(10)
! 5. Call subroutine
CALL arraycalc(counter,AB,H,TB,BA,SP)
! 6. Write out
WRITE(*,100)"Game AB H TB BA SP"
DO i=1,counter
WRITE(*,200,ADVANCE="NO") i
WRITE(*,'(5F9.3)') AB(i), H(i), TB(i), BA(i), SP(i)
END DO
END PROGRAM subroutine1
!HERE IS THE PART WHERE I'M HAVING TROUBLE
SUBROUTINE arraycalc(counter,AB,H,TB,BA,SP)
IMPLICIT NONE
INTEGER, INTENT(IN)::counter
INTEGER::i
REAL,INTENT(INOUT)::AB,H,TB
REAL,INTENT(INOUT):: BA,SP
DO i=1,counter
BA(i)=H(i)/AB(i)
END DO
DO i=1,counter
SP(i)=TB(i)/AB(i)
END DO
END SUBROUTINE