使用 Fortran 在 Eclipse 上没有控制台输出

No console output on Eclipse with Fortran

全部。我正在编写一个相对简单的程序,它遍历数据列表和 returns 学校项目的峰值。

目前的代码如下:

    program Fortran_Project_1
    implicit none
    integer::cnt,cnt1, i
    integer:: peaks=5
    real, dimension(360):: time,impulse
    real, allocatable :: impulselist(:)
    integer, dimension(360)::interval
    character(len=150)::clean,header
    clean='C:\Users\User\Desktop\Fortran_Project_1\ir_clean.txt'
    print *, clean

    open (unit=1,file=clean)

    do cnt1=1,4
        read (1,*) header
    end do

    do cnt=1,443
        read(1,*) interval(cnt),time(cnt),impulse(cnt)
    end do
   print *, 'Choose amount of peaks to find'
   read *, peaks
   deallocate (impulselist)
   allocate (impulselist(peaks))
    do i = 1, cnt
        if (impulse(i)>impulse(i+1) .and. impulse(i)>impulse(i-1)) then
                peaks = peaks - 1
                impulselist(peaks) = impulse(i)
        end if
        if (peaks < 1) then
            exit
        end if
    end do
    close (1)
    print *, impulselist
end program Fortran_Project_1

无论如何,当 运行 这并输入用户想要查找的峰值数量时,控制台完全空白。它打印干净的变量和查询,仅此而已。我该怎么办?

谢谢

编辑:控制台输出:

C:\Users\User\Desktop\Fortran_Project_1\ir_clean.txt
选择要查找的峰数量

[输入]

奇怪,你说什么都没发生。您应该会收到一条错误消息。

数组 impulselist 未分配,您正在调用 deallocate(impulselist)。这是不允许的,应该由编译器诊断,当代码为 运行.

时它应该抱怨

我明白了。列表维度存在问题。这是完美运行的更新代码。

计划Fortran_Project_1 隐式 none integer::cnt、cnt1、i、count1、峰 real, dimension(1000):: 时间,脉冲 真实的,可分配的 :: impulselist(:),timelist(:) 整数,维度(1000)::间隔 字符(len=150)::干净,header 干净='C:\Users\Buraaq Alrawi\Desktop\Fortran_Project_1\ir_clean.txt' 打印*,清洁 打印 *, 'Choose amount of peaks to find' 读取 *,峰值 分配(脉冲列表(峰值)) 分配(时间列表(峰值))

open (unit=1,file=clean,action='read')

do cnt1=1,4
    read (1,*) header
end do

do cnt=1,501
    read(1,*) interval(cnt),time(cnt),impulse(cnt)
end do

count1=1
do i = 1, cnt
    if (impulse(i)>impulse(i+1) .and. impulse(i)>impulse(i-1)) then
            impulselist(count1) = impulse(i)
            timelist(count1) = time(i)
            count1 = count1 + 1
    end if
    if (count1 > peaks) then
        exit
    end if
end do
close (1)
100 format(A28,X,1000F10.2)
200 format(A28,X,1000F10.4)
300 format(A23,F10.2,F10.4)
write (*,100) 'The peak times are(seconds):', timelist
write (*,200) 'The peak impulse values are:', impulselist
write (*,300) 'The settled values are:',time(501),impulse(501)

结束节目Fortran_Project_1

谢谢大家