CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > General Forums > Main CFD Forum

CFD Code Conversion from Intel Fortran to GNU Fortran

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes
  • 2 Post By wangmianzhi

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 26, 2016, 14:36
Default CFD Code Conversion from Intel Fortran to GNU Fortran
  #1
New Member
 
Join Date: Jun 2016
Posts: 3
Rep Power: 9
pitto is on a distinguished road
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
pitto is offline   Reply With Quote

Old   July 26, 2016, 14:52
Default
  #2
Member
 
Kaya Onur Dag
Join Date: Apr 2013
Posts: 94
Rep Power: 13
kaya is on a distinguished road
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.
kaya is offline   Reply With Quote

Old   July 26, 2016, 15:18
Default
  #3
Member
 
Mianzhi Wang
Join Date: Jan 2015
Location: Columbus, IN
Posts: 34
Rep Power: 11
wangmianzhi is on a distinguished road
Quote:
Originally Posted by pitto View Post
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.
lcarasik and pitto like this.
wangmianzhi is offline   Reply With Quote

Old   July 26, 2016, 18:16
Default
  #4
Super Moderator
 
flotus1's Avatar
 
Alex
Join Date: Jun 2012
Location: Germany
Posts: 3,399
Rep Power: 46
flotus1 has a spectacular aura aboutflotus1 has a spectacular aura about
Quote:
Originally Posted by pitto View Post
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
flotus1 is offline   Reply With Quote

Old   August 4, 2016, 14:51
Default
  #5
New Member
 
Join Date: Jun 2016
Posts: 3
Rep Power: 9
pitto is on a distinguished road
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"
pitto is offline   Reply With Quote

Reply

Tags
fortran, gnu, intel, makefile, openmpi


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
intel visual fortran and GNU compiler Rawnak Main CFD Forum 1 October 30, 2013 21:59
Books about writing a cfd code in Fortran olsson Main CFD Forum 7 October 17, 2012 16:26
CFD Code with Fortran murat Main CFD Forum 0 October 11, 2009 17:05
CFD code for Mac Xserve Intel cluster node? Chris Cameron Main CFD Forum 0 October 17, 2006 14:14
OOP for CFD code Jongtae Kim Main CFD Forum 26 October 20, 2000 06:11


All times are GMT -4. The time now is 01:20.