![g77 搭载 Ubuntu 14.04 LTS](https://linux22.com/image/868796/g77%20%E6%90%AD%E8%BD%BD%20Ubuntu%2014.04%20LTS.png)
我正在使用一个用 Fortran 77 编写的政府程序,需要 g77 来配置和编译源代码。我知道 g77 已经淘汰,并被较新的编译器取代,但我与政府的联系点和我发现,当我们尝试编译此程序时,GCC 中的较新编译器会产生大量错误。
我尝试了之前发布的 Ubuntu 12 问题中提供的说明,其中修改了 sources.list 文件以添加 Hardy Ubuntu 页面,然后它应该可用。但是,如下面的输出所示,这没有成功。我尝试搜索 g77 的其他来源,但一无所获。
我曾尝试在这台电脑和其他电脑上安装早期版本的 Linux,但发现我下载的版本缺少关键功能,无法安装。请给出详细答案,因为我对 Linux 不是很熟悉。
sudo apt-get update
Ign http:// us.archive.ubuntu.com trusty InRelease
Ign http:// security.ubuntu.com trusty-security InRelease
Ign http:// us.archive.ubuntu.com trusty-updates InRelease
Get:1 http:// security.ubuntu.com trusty-security Release.gpg [933 B]
Ign http:// extras.ubuntu.com trusty InRelease
Ign http:// us.archive.ubuntu.com trusty-backports InRelease
Get:2 http:// security.ubuntu.com trusty-security Release [62.0 kB]
Hit http:// us.archive.ubuntu.com trusty Release.gpg
Get:3 http:// extras.ubuntu.com trusty Release.gpg [72 B]
Get:4 http:// us.archive.ubuntu.com trusty-updates Release.gpg [933 B]
Ign http:// hu.archive.ubuntu.com hardy InRelease
Hit http:// extras.ubuntu.com trusty Release
Get:5 http:// us.archive.ubuntu.com trusty-backports Release.gpg [933 B]
Get:6 http:// security.ubuntu.com trusty-security/main Sources [71.5 kB]
Hit http:// us.archive.ubuntu.com trusty Release
Hit http:// extras.ubuntu.com trusty/main Sources
Ign http:// hu.archive.ubuntu.com hardy-updates InRelease
Get:7 http:// us.archive.ubuntu.com trusty-updates Release [62.0 kB]
Get:8 http:// security.ubuntu.com trusty-security/restricted Sources [2,061 B]
Hit http:// extras.ubuntu.com trusty/main amd64 Packages
Get:9 http:// security.ubuntu.com trusty-security/universe Sources [17.9 kB]
Ign http:// hu.archive.ubuntu.com hardy Release.gpg
Get:10 http:// security.ubuntu.com trusty-security/multiverse Sources [1,896 B]
Hit http:// extras.ubuntu.com trusty/main i386 Packages
Get:11 http:// security.ubuntu.com trusty-security/main amd64 Packages [220 kB]
Get:12 http:// us.archive.ubuntu.com trusty-backports Release [62.0 kB]
Ign http:// hu.archive.ubuntu.com hardy-updates Release.gpg
Ign http:// hu.archive.ubuntu.com hardy Release
Get:13 http:// security.ubuntu.com trusty-security/restricted amd64 Packages [8,875 B]
Hit http:// us.archive.ubuntu.com trusty/main Sources
Get:14 http:// security.ubuntu.com trusty-security/universe amd64 Packages [87.7 kB]
Ign http:// hu.archive.ubuntu.com hardy-updates Release
Hit http:// us.archive.ubuntu.com trusty/restricted Sources
Hit http:// us.archive.ubuntu.com trusty/universe Sources
Get:15 http:// security.ubuntu.com trusty-security/multiverse amd64 Packages [3,458 B]
Hit http:// us.archive.ubuntu.com trusty/multiverse Sources
Get:16 http:// security.ubuntu.com trusty-security/main i386 Packages [210 kB]
Hit http:// us.archive.ubuntu.com trusty/main amd64 Packages
Hit http:// us.archive.ubuntu.com trusty/restricted amd64 Packages
Hit http:// us.archive.ubuntu.com trusty/universe amd64 Packages
Hit http:// us.archive.ubuntu.com trusty/multiverse amd64 Packages
Get:17 http:// security.ubuntu.com trusty-security/restricted i386 Packages [8,846 B]
Hit http:// us.archive.ubuntu.com trusty/main i386 Packages
Get:18 http:// security.ubuntu.com trusty-security/universe i386 Packages [87.7 kB]
Hit http:// us.archive.ubuntu.com trusty/restricted i386 Packages
Ign http:// extras.ubuntu.com trusty/main Translation-en_US
Get:19 http:// security.ubuntu.com trusty-security/multiverse i386 Packages [3,624 B]
Ign http:// extras.ubuntu.com trusty/main Translation-en
Get:20 http:// security.ubuntu.com trusty-security/main Translation-en [113 kB]
Hit http:// us.archive.ubuntu.com trusty/universe i386 Packages
Hit http:// us.archive.ubuntu.com trusty/multiverse i386 Packages
Hit http:// security.ubuntu.com trusty-security/multiverse Translation-en
Hit http:// security.ubuntu.com trusty-security/restricted Translation-en
Hit http:// us.archive.ubuntu.com trusty/main Translation-en
Get:21 http:// security.ubuntu.com trusty-security/universe Translation-en [48.5 kB]
Hit http:// us.archive.ubuntu.com trusty/multiverse Translation-en
Hit http:// us.archive.ubuntu.com trusty/restricted Translation-en
Hit http:// us.archive.ubuntu.com trusty/universe Translation-en
Get:22 http:// us.archive.ubuntu.com trusty-updates/main Sources [181 kB]
Get:23 http:// us.archive.ubuntu.com trusty-updates/restricted Sources [2,061 B]
Get:24 http:// us.archive.ubuntu.com trusty-updates/universe Sources [105 kB]
Get:25 http:// us.archive.ubuntu.com trusty-updates/multiverse Sources [4,463 B]
Get:26 http:// us.archive.ubuntu.com trusty-updates/main amd64 Packages [446 kB]
Get:27 http:// us.archive.ubuntu.com trusty-updates/restricted amd64 Packages [8,875 B]
Get:28 http:// us.archive.ubuntu.com trusty-updates/universe amd64 Packages [254 kB]
Get:29 http:// us.archive.ubuntu.com trusty-updates/multiverse amd64 Packages [11.2 kB]
Get:30 http:// us.archive.ubuntu.com trusty-updates/main i386 Packages [436 kB]
Get:31 http:// us.archive.ubuntu.com trusty-updates/restricted i386 Packages [8,846 B]
Get:32 http:// us.archive.ubuntu.com trusty-updates/universe i386 Packages [255 kB]
Get:33 http:// us.archive.ubuntu.com trusty-updates/multiverse i386 Packages [11.3 kB]
Get:34 http:// us.archive.ubuntu.com trusty-updates/main Translation-en [213 kB]
Err http:// hu.archive.ubuntu.com hardy/universe Sources
404 Not Found [IP: 148.6.0.24 80]
Err http:// hu.archive.ubuntu.com hardy/universe amd64 Packages
404 Not Found [IP: 148.6.0.24 80]
Err http:// hu.archive.ubuntu.com hardy/universe i386 Packages
404 Not Found [IP: 148.6.0.24 80]
Ign http:// hu.archive.ubuntu.com hardy/universe Translation-en_US
Hit http:// us.archive.ubuntu.com trusty-updates/multiverse Translation-en
Hit http:// us.archive.ubuntu.com trusty-updates/restricted Translation-en
Get:35 http:// us.archive.ubuntu.com trusty-updates/universe Translation-en [131 kB]
Ign http:// hu.archive.ubuntu.com hardy/universe Translation-en
Get:36 http:// us.archive.ubuntu.com trusty-backports/main Sources [5,298 B]
Err http:// hu.archive.ubuntu.com hardy-updates/universe Sources
404 Not Found [IP: 148.6.0.24 80]
Get:37 http://us.archive.ubuntu.com trusty-backports/restricted Sources [28 B]
Get:38 http:// us.archive.ubuntu.com trusty-backports/universe Sources [20.7 kB]
Err http:// hu.archive.ubuntu.com hardy-updates/universe amd64 Packages
404 Not Found [IP: 148.6.0.24 80]
Get:39 http:// us.archive.ubuntu.com trusty-backports/multiverse Sources [1,898 B]
Get:40 http:// us.archive.ubuntu.com trusty-backports/main amd64 Packages [5,536 B]
Get:41 http:// us.archive.ubuntu.com trusty-backports/restricted amd64 Packages [28 B]
Err http:// hu.archive.ubuntu.com hardy-updates/universe i386 Packages
404 Not Found [IP: 148.6.0.24 80]
Get:42 http:// us.archive.ubuntu.com trusty-backports/universe amd64 Packages [24.4 kB]
Get:43 http:// us.archive.ubuntu.com trusty-backports/multiverse amd64 Packages [1,245 B]
Ign http:// hu.archive.ubuntu.com hardy-updates/universe Translation-en_US
Get:44 http:// us.archive.ubuntu.com trusty-backports/main i386 Packages [5,550 B]
Get:45 http:// us.archive.ubuntu.com trusty-backports/restricted i386 Packages [28 B]
Ign http:// hu.archive.ubuntu.com hardy-updates/universe Translation-en
Get:46 http:// us.archive.ubuntu.com trusty-backports/universe i386 Packages [24.5 kB]
Get:47 http:// us.archive.ubuntu.com trusty-backports/multiverse i386 Packages [1,249 B]
Get:48 http:// us.archive.ubuntu.com trusty-backports/main Translation-en [3,233 B]
Hit http:// us.archive.ubuntu.com trusty-backports/multiverse Translation-en
Hit http:// us.archive.ubuntu.com trusty-backports/restricted Translation-en
Get:49 http:// us.archive.ubuntu.com trusty-backports/universe Translation-en [22.7 kB]
Ign http:// us.archive.ubuntu.com trusty/main Translation-en_US
Ign http:// us.archive.ubuntu.com trusty/multiverse Translation-en_US
Ign http:// us.archive.ubuntu.com trusty/restricted Translation-en_US
Ign http:// us.archive.ubuntu.com trusty/universe Translation-en_US
Fetched 3,258 kB in 11s (275 kB/s)
W: Failed to fetch http:// hu.archive.ubuntu.com/ubuntu/dists/hardy/universe/source/Sources 404 Not Found [IP: 148.6.0.24 80]
W: Failed to fetch http:// hu.archive.ubuntu.com/ubuntu/dists/hardy/universe/binary-amd64/Packages 404 Not Found [IP: 148.6.0.24 80]
W: Failed to fetch http:// hu.archive.ubuntu.com/ubuntu/dists/hardy/universe/binary-i386/Packages 404 Not Found [IP: 148.6.0.24 80]
W: Failed to fetch http:// hu.archive.ubuntu.com/ubuntu/dists/hardy-updates/universe/source/Sources 404 Not Found [IP: 148.6.0.24 80]
W: Failed to fetch http:// hu.archive.ubuntu.com/ubuntu/dists/hardy-updates/universe/binary-amd64/Packages 404 Not Found [IP: 148.6.0.24 80]
W: Failed to fetch http:// hu.archive.ubuntu.com/ubuntu/dists/hardy-updates/universe/binary-i386/Packages 404 Not Found [IP: 148.6.0.24 80]
E: Some index files failed to download. They have been ignored, or old ones used instead.
:~$ sudo apt-get install g77
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package g77 is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
E: Package 'g77' has no installation candidate
:~$ which g77
:~$ dir
答案1
我也使用非常老的 F77 程序!gfortran 有标志,您可以设置这些标志来指定您正在使用/编译旧代码。它们很有帮助,但并不完美。您可能还想在启用调试选项的情况下进行编译。
您可以阅读 gfortran 的手册页以获取更多信息。-ff2c 生成的代码旨在与 g77 和 f2c 生成的代码兼容。-g 设置调试,以便您以后可以使用 GDB
gfortran -ff2c -g foo.f -o foo
这里有一个关于调试 fortran 的精彩教程 http://infohost.nmt.edu/tcc/help/lang/fortran/gdbcompile.html
它是为旧系统编写的,但我认为它是可以理解的。