CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Main CFD Forum (https://www.cfd-online.com/Forums/main/)
-   -   CFD Code Conversion from Intel Fortran to GNU Fortran (https://www.cfd-online.com/Forums/main/175253-cfd-code-conversion-intel-fortran-gnu-fortran.html)

pitto July 26, 2016 15:36

CFD Code Conversion from Intel Fortran to GNU Fortran
 
I am working on a custom CFD Solver written in FORTRAN 90 and MPI.
The code contain 15+ Modules and was initially designed to work with the Intel Fortran compiler. Now since i do not have access to the Intel compiler I need to make it work using the GNU Fortran Compiler.

I made changes in the Makefile that initially had flags suitable for the ifort.
I am using it on Ubuntu with GNU Fortran and Openmpi


**I am sorry I am unable to put in anything from the code structure or terminal output due to IP restrictions of my university. Nevertheless,I will try to best describe the issues**

So now when I compile the code I am having some strange issues.

1) The GNU Fortran is not able to read lines that are too long and I get errors during compilation. As a result I have to break it into multiple lines using the '&' symbol

2) A module D.f90 contains all the Global variables declared. However, now I during compilation i get error is in module B.F90.
The error I get is 'Unclassified Statement Error', I was able to fix it in some subroutines and functions by locally declaring the variables again.

I am not the most experienced person in Fortran, but I thought that the change in Compiler should not be a reason for new found syntax errors.

The errors described above so far could be remedied but considering the expanse of the code it is impractical.

I was hoping if anyone could share views on this matter and provide guidance on how to tackle it.

Any help is much appreciated. Many thanks

kaya July 26, 2016 15:52

in my department there is a fortran code that was written with sun compiler, they wanted to make it compatiable with GNU, after a while I think they gave up on trying to make it work for GNU and Intel. though not sure how much they wanted it...

I also know people write in fortran and check their compatiblity in diff. compilers just to make sure that their code is 'universal'

I bet its more than braking some lines and adjusting the makefile but I'd push a bit more. at the end its still fortran90 not like translating from another language. with full attention it shouldn't take more than a week.


for 2), make sure that makefile does the things in the correct order.

wangmianzhi July 26, 2016 16:18

Quote:

Originally Posted by pitto (Post 611494)
I am working on a custom CFD Solver written in FORTRAN 90 and MPI.
The code contain 15+ Modules and was initially designed to work with the Intel Fortran compiler. Now since i do not have access to the Intel compiler I need to make it work using the GNU Fortran Compiler.

I made changes in the Makefile that initially had flags suitable for the ifort.
I am using it on Ubuntu with GNU Fortran and Openmpi


**I am sorry I am unable to put in anything from the code structure or terminal output due to IP restrictions of my university. Nevertheless,I will try to best describe the issues**

So now when I compile the code I am having some strange issues.

1) The GNU Fortran is not able to read lines that are too long and I get errors during compilation. As a result I have to break it into multiple lines using the '&' symbol

2) A module D.f90 contains all the Global variables declared. However, now I during compilation i get error is in module B.F90.
The error I get is 'Unclassified Statement Error', I was able to fix it in some subroutines and functions by locally declaring the variables again.

I am not the most experienced person in Fortran, but I thought that the change in Compiler should not be a reason for new found syntax errors.

The errors described above so far could be remedied but considering the expanse of the code it is impractical.

I was hoping if anyone could share views on this matter and provide guidance on how to tackle it.

Any help is much appreciated. Many thanks


You may let your dog sit on the keyboard for a while and ifort can still compile the outcome and produce something.
Porting a code from ifort to gfortran would expose many hidden issues and mistakes in the code. And the process is a good opportunity to improve the robustness and quality of the code.
Sure it needs some patience. But at the end of the process, you would get a much better code.
Have a good luck.

BTW: remember to check the -Wall option of gfortran.

flotus1 July 26, 2016 19:16

Quote:

Originally Posted by pitto (Post 611494)
1) The GNU Fortran is not able to read lines that are too long and I get errors during compilation. As a result I have to break it into multiple lines using the '&' symbol

1. No you don't have to break lines. Compile with "-ffree-line-length-none" instead

Edit: in addition to checking the -Wall flag, I would recommend using more debugging flags to track down the errors you describe. http://stackoverflow.com/questions/3...ch-faulty-code

pitto August 4, 2016 15:51

Thank you for all the responses and help.


@kaya: Even i thought that the code should be more or less universal as long as the script is same. But i noticed that with the some features changing in Intel and GNU compiler , it can have some issues in the code. How much of it is an issue would depend on the code itself

@wangmianzhi: thanks for the suggestion. In my case -Wall did not prove to be of much help as it calls all the flags in the -W so some flags got overridden by others.

@flotus1: thanks for the suggestion. It worked for me.

Below I will mention some of the flags I used to make the code work
-ffree-line-length-none for line break
-Wno-tabs to avoid the non conforming tab warning
-O3 optimisation
-fcray-pointer - was prompted for this flag by the compiler

According to some reading I used the flag -fopenmp
as it is supposed to invoked openmp but strangely enough , i get an error at the end of compilation relating to the OMP commands in some of the objects.
Compiling without this command works alright.

So now my code compiles and runs. But i still have to evaluate if it is working as expected.
One main difference i found is that it is not producing as many output files as it is supposed to based on the input file.
This needs some more verification into the code.

Also at the end of simulation I get the final output file and an error in the terminal
"Note: The following floating-point exceptions are signalling: IEEE_INVALID_FLAG IEEE_OVERFLOW_FLAG IEEE_UNDERFLOW_FLAG IEEE_DENORMAL"


All times are GMT -4. The time now is 22:00.