数値 n を読み取り、n 倍精度数値を格納するベクトルを作成し、この数値を読み取り、サブルーチン printminmax() を呼び出して最小値と最大値を見つけるコードを実装しようとしています。私のコードは通常の数値 (整数、実数など) に対しては完璧に機能しますが、科学表記法 (0.3412E+01) スタックがある場合はなぜですか? 私はすべてのフォーマットを読むと思った。ありがとう
implicit none
integer, dimension(:), allocatable :: x
integer :: n
open (unit=77, file='input2.dat', action='read', status='old')
read(77,*), n
allocate(x(n))
call printminmax(n)
deallocate(x)
end
subroutine printminmax(y)
implicit none
integer, dimension(:), allocatable :: x
integer :: y,max,min,i
allocate(x(y))
read(77,*) x
!print *,'Maximun=', maxval(x)
!print *,'Minimun=', minval(x
!initialize the value max & min
max=x(1)
min=x(1)
do i=2,y
if (x(i)>max) max=x(i)
if (x(i)<min) min=x(i)
end do
write(*,*) 'Maximum=',max
write(*,*) 'Minimum=',min
end subroutine printminmax
スタック入力の一例は
1000
5.39524398466520e-01
9.85099770130787e-01
7.38946122872518e-01
6.47771620257608e-01
8.80871051119695e-01
2.99375585725816e-02
私が科学的表記法のために取るエラーは
At line 13 of file io.f90 (unit = 77, file = 'input3.dat')
Fortran runtime error: Bad integer for item 1 in list input