Compiling a Fortran 77 Code on Ubuntu

In summary, the code was compiled successfully on cygwin but when tried on Ubuntu it gave a runtime error. The problem seems to be with the input data, which is UTF-8 encoded differently on the two systems.
  • #1
mathia
15
0
Hi,
I have a fortran 77 code, I compiled it on cygwin in windows 7 by using f77 and gfortran, and it has been working correctly.
I should use this code on Ubuntu, so I installed f77, gfortran and gcc compiler. I tried to comile that code by using f77 but it gave me the following error:
> f77 software.f -o software
> pickup_blockiirm:
> /usr/bin/f77: aborting compilation

The code was compiled successfully when I tried gfortran and f95, but whenever I want to run the program, it gives me the following error:
> At line 172 of file software.f
> Fortran runtime error: Bad value during integer read

I should mention that I'm sure that my input data is integer, and this code and input file works on cygwin smoothly!

Can anyone help me?
Regards,
Mathia
 
Technology news on Phys.org
  • #2
mathia said:
Hi,
I have a fortran 77 code, I compiled it on cygwin in windows 7 by using f77 and gfortran, and it has been working correctly.
I should use this code on Ubuntu, so I installed f77, gfortran and gcc compiler. I tried to comile that code by using f77 but it gave me the following error:
> f77 software.f -o software
> pickup_blockiirm:
> /usr/bin/f77: aborting compilation

The code was compiled successfully when I tried gfortran and f95, but whenever I want to run the program, it gives me the following error:
> At line 172 of file software.f
> Fortran runtime error: Bad value during integer read

I should mention that I'm sure that my input data is integer, and this code and input file works on cygwin smoothly!

Can anyone help me?
Regards,
Mathia

Hey mathia and welcome to the forums.

This is just a suggestion, but since your problem is not so much with the language or even the compiler in general (but a specific version), you might get better luck posting to the dev boards for that particular port.

The only alternative to this that I think is feasible is if you had the compiler code in the raw source and then stepped through it yourself.

This sounds like a real pain to be in given that you have run it on a different platform with no problem... argh!
 
  • #3
Hhhh...could it have something to do with the format or, rather encoding of the input file? So, I am not talking about the numbers in it, but, rather about UTF-8 versus something else? How did you bring your input file from Windows over to Ubuntu?

Other than that...for debugging purposes, I would shorten the program to just read one number and see if you can do that much...and start incrementing the scope of the program.
 
  • #4
You probably have not got the right runtime libraries between the two systems.

Install the fortran system using the Ubuntu package management system and recompile your code on the Ubuntu installation. It should run correctly after that.
 
  • #5


Thank you for reaching out for assistance with compiling your Fortran 77 code on Ubuntu. It seems like you have already taken the necessary steps to install the required compilers on your system. However, it is important to note that different compilers may have slight variations in their syntax and requirements, which could result in errors during compilation or runtime.

In this case, it seems like the issue might be with the f77 compiler on Ubuntu. It is possible that the version you have installed is not fully compatible with your code, leading to the compilation error. I would recommend trying to compile your code using gfortran or f95, as these have been successful for you in the past. If you encounter any issues with these compilers, it would be helpful to provide more information about the specific errors you are getting, as well as the code and input file that you are using.

Additionally, it is important to make sure that your input data is indeed in the correct format and matches the requirements of your code. Even though it worked on cygwin, there could be slight differences in the way the two systems handle input data, so it is always a good idea to double-check.

I hope this helps and you are able to successfully compile and run your code on Ubuntu. If you continue to encounter issues, it might be helpful to seek assistance from a more experienced Fortran programmer or consult online resources for troubleshooting. Good luck!
 

1. How do I install a Fortran 77 compiler on Ubuntu?

To install a Fortran 77 compiler on Ubuntu, you can use the command sudo apt-get install gfortran. This will install the GNU Fortran 77 compiler, which is the most commonly used compiler for Fortran on Ubuntu.

2. Can I compile a Fortran 77 code using a text editor on Ubuntu?

Yes, you can use any text editor of your choice on Ubuntu to write and compile Fortran 77 code. However, it is recommended to use an integrated development environment (IDE) such as Code::Blocks or Eclipse, as they provide additional features for debugging and managing your code.

3. How do I compile a Fortran 77 code from the command line on Ubuntu?

To compile a Fortran 77 code from the command line on Ubuntu, you can use the command gfortran -o output_file input_file.f. This will compile the code and generate an executable file with the name specified in the -o option.

4. What are some common errors that I may encounter while compiling a Fortran 77 code on Ubuntu?

Some common errors that you may encounter while compiling a Fortran 77 code on Ubuntu include syntax errors, undefined variables or functions, and incompatible data types. It is important to carefully check your code and make sure it follows the correct syntax and logic before attempting to compile it.

5. How do I link external libraries to my Fortran 77 code on Ubuntu?

To link external libraries to your Fortran 77 code on Ubuntu, you can use the -l option with the gfortran command. For example, gfortran -o output_file input_file.f -lmylib will link the library libmylib.so to your code. You may also need to specify the location of the library using the -L option if it is not in the default search path.

Similar threads

  • Programming and Computer Science
Replies
3
Views
1K
  • Programming and Computer Science
Replies
2
Views
2K
  • Programming and Computer Science
Replies
8
Views
3K
  • Programming and Computer Science
Replies
2
Views
1K
  • Programming and Computer Science
Replies
4
Views
619
  • Nuclear Engineering
Replies
6
Views
1K
  • Programming and Computer Science
Replies
14
Views
2K
  • Programming and Computer Science
Replies
2
Views
7K
  • Programming and Computer Science
Replies
3
Views
1K
  • Programming and Computer Science
Replies
17
Views
4K
Back
Top