PotsyYZhou 发表于 2021-12-10 22:57:29

程序运行后undefined reference to `al_'出错

程序运行后出错:
/usr/bin/ld: /tmp/ccz6HngJ.o: in function `MAIN__':
main.f95:(.text+0x244): undefined reference to `al_'
collect2: error: ld returned 1 exit status

         如何排出?!盼复! 谢谢

phost 发表于 2021-12-10 23:15:44

贴程序。不然谁知道啥问题。

PotsyYZhou 发表于 2021-12-11 07:50:19

收到,谢谢!回复如下:
附部分程序,足够了解问题所在吗?
Dimension a(100), a1(101), c(101), d(2), q(98)
Write (*, 3)
Read (*, *) n
np1 = n + 1
Write (*, 5)
Do i = 1, np1
    Read (*, *) a1(i)
End Do
Do i = 1, n
    a(i) = a1(i+1)/al(1)
End Do
。。。。。。。
3 Format (1X, 'Enter the order of the polynomial')
5 Format (1X, 'Enter the coefficients of the polynomial starting',&
' from the highest order'/5X, ' and press Enter key after ', &
'entering each number.')
10 Format (1X, 'Enter the initial guesses of d(l) and d(2)', &
'and Epsilon, e.g.,.005,.005,.00001:')
11 Format (1X, 'The Roots are :'//'REAL PART   IMAGINARY', &
'PART    ITERATIONS')
170 Format (F17.5, F18.5, 7X, I7)
298 Format (/5X, 'Denominator is zero.!')
352 Format (/5X, 'The process is not converging!')
368 Format (/5X, 'The process is slow in converging!')
382 Format (/5X, 'Iteration is terminated after 200 trials.')
390 End Program
**********************上面是程序的开始和结束部分,
输入:Standard Input:
3
1
2
3
4
***********
输出:
Compilation failed due to following error(s)./usr/bin/ld: /tmp/ccHVF472.o: in function `MAIN__':
main.f95:(.text+0x244): undefined reference to `al_'
collect2: error: ld returned 1 exit status
      :-@   
   

PotsyYZhou 发表于 2021-12-11 09:52:04

啊, 我自己也认真地看了一下, 确实纠错问题1: Al=A1,(要看清楚 l 和 1 的差别, 容易混淆)。问题2: 程序要求输入, 一定按程序编制的要求, 这里:Input:
5
1
2
3
4
6
9
0.005,0.005,0.00001
输出结果为,Output:
$gfortran -std=f95 *.f95 -o main
$main
Enter the order of the polynomial
Enter the coefficients of the polynomial starting from the highest order
      and press Enter key after entering each number.
Enter the initial guesses of d(l) and d(2)and Epsilon, e.g.,.005,.005,.00001:
The Roots are :
REAL PART   IMAGINARYPART    ITERATIONS
          0.68234         1.29869            18
          0.68234          -1.29869            18
         -0.88316         1.35512             7
         -0.88316          -1.35512             7
         -1.59836         0.00000             1
****************
该程序为算法, Bairstow方法求多项式的所有根(包括实数和复数)
   问题解决
谢谢

fcode 发表于 2021-12-13 08:29:11

implicit none 是如此重要
页: [1]
查看完整版本: 程序运行后undefined reference to `al_'出错