Package g77 is not available in any currently supported version of Ubuntu, 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. The fort77 utility is the interface to the Fortran compilation system. It will accept the full Fortran 77 language defined by the ANSI X3.9-1978 standard. fort77 can be installed in all currently supported versions of Ubuntu by running the following commands:
sudo apt update
sudo apt install fort77
To test fort77 save this Hello world Fortran 77 code as hello-world.f:
text = 'Hello World!'
write (*,*) text
To compile the code run the following command:
fort77 hello-world.f -o hello-world
This creates an executable file named hello-world. Run the program by typing
./hello-world and then press Enter.
GNU Fortran 95 compiler can also be installed in all currently supported versions of Ubuntu by running the following command:
sudo apt install gfortran
This is the GNU Fortran 95 compiler, which compiles Fortran 95 on platforms supported by the gcc compiler. It uses the gcc backend to generate optimized code. gfortran is backwards compatible with the same Hello world code example shown above, and the executable file that it generates will run. gfortran is not backwards compatible with all Fortran 77 code, so sometimes it's necessary to install fort77 for full Fortran 77 compatibility.