Porting fortran program-problem with padding in common

  • Context: Fortran 
  • Thread starter Thread starter saleemhasan
  • Start date Start date
  • Tags Tags
    Fortran
Click For Summary

Discussion Overview

The discussion revolves around the challenges of porting a Fortran program from an IRIX environment to Linux, specifically addressing issues related to padding warnings in common blocks. Participants explore potential solutions, including compiler options and code reordering, while also considering the implications of these warnings on program performance and functionality.

Discussion Character

  • Technical explanation
  • Debate/contested
  • Experimental/applied

Main Points Raised

  • Saleem describes encountering padding warnings when compiling a Fortran program on Linux, noting that the program runs without issues on IRIX.
  • Some participants suggest consulting compiler documentation for guidance on handling padding issues.
  • One participant proposes reordering variables in common blocks to avoid padding warnings, suggesting that it is a feasible solution despite the program's size.
  • Saleem expresses concern about the complexity of reordering due to multiple variable types present in the program.
  • There is a discussion about whether padding warnings can be ignored temporarily, with some participants indicating that warnings do not prevent compilation, while errors must be addressed first.
  • Another participant raises the possibility that alignment issues could lead to more serious memory problems beyond just performance concerns.
  • Saleem indicates a shift in focus to resolving an ambiguity error related to double variables, suggesting that this error takes precedence over the padding warnings.

Areas of Agreement / Disagreement

Participants generally agree that warnings related to padding can be addressed later, while errors must be resolved first. However, there is no consensus on the long-term implications of ignoring padding warnings, with differing views on whether they could lead to more significant issues.

Contextual Notes

Participants acknowledge that the program's complexity, including various data types, complicates the reordering of variables in common blocks. The discussion also highlights the distinction between warnings and errors in the context of compilation.

saleemhasan
Messages
9
Reaction score
0
Hello,

I must start by stating that I know almost nothing about fortran. I am trying to help port a fortran program to linux. It compiles and runs fine on irix (64 bit sgi origin 2000). There are two make files and both of them give padding warnings.
---------
Padding of 4 bytes required before `eln' in common block `option' at (^) -- consider reordering members, largest-type-size first
---------

I searched the Internet and found that in order to improve performance and to minimize the number of cpu fetches, padding is needed if variables are not stored from the largest type-size to the smallest. Since the program is very large, it is not possible to re-arrange the order of the variables from large to small in the COMMON blocks. I found a couple of options (for different compilers) that align (pad) the storage however, none of these options worked on my compilers. I tried these options on a Centos 5.9 linux and a Redhat EL 5 machine.

I entered the align option in the make file.

maindpx.exe: maindpx.o exerfc.o saxbi.o tred2.o cavxcor.o diagovlp.o
f77 -o32 -falign-commons -o maindpx.exe maindpx.o exerfc.o saxbi.o tred2.o cavxcor.o diagovlp.o

maindpx.o: maindpx.f
f77 -o32 -c maindpx.f
exerfc.o: exerfc.f
f77 -o32 -c exerfc.f
.....
....

I tried -falign-commons from a gnu fortran compiler site
I also tried -fno-align-commons to prevent the compiler from padding but there was no change. I got the same warnings. I tried a couple of other versions of the same option such as -aligncommon[=4 or 8] but that did not help.

Is it that I am entering the option on the wrong line?

Thank you very much in advance for your help.

Saleem
 
Technology news on Phys.org
When all else fails, read the instructions. Your system must have some documentation for running the compiler.
 
I will try that option next SteamKing.
Thank you.
 
I had to do something like that last time I had to port from Solaris to Linux...I thought re-ordering was cleaner than needing a compilation flag, so I did...it is not impossible ;-)

There are only 2 variable lengths, integers and reals...all you got to do is move the integers to the back of the common block or, better yet, split the common block into two by type...o.k., there may be more lengths if you have character variables or various lengths within a type (REAL*4, REAL*8, etc)...but it is very do-able and it is called programming :-)
 
gsal,

Thank you for the encouragement to take the "re-ordering" path. I think it will be a slow and painful one but I will try that also. In the programs that I am trying to port, I think there are more than just two variable lengths. There are doubles and chars also.

Is it correct to say that aligning messages are all warnings and could be ignored temporarily. It would only result in some loss in performance?

The reason I want to set aside the aligning (if they are only warnings) is that, there is an Error, in addition to the align messages. It is about ambiguity in Real (double) variable. However, I will start another thread for that and provide more details. As I had mentioned in my original post, the program works on sgi irix and so all these warnings and the error are porting issues.

I think I will change my username to porter :).
Although, this is my first attempt, people who do porting should have a separate designation and not be lumped in with programmers :)
 
Errors will keep you from building and running your application. These must be fixed. Warnings are not as serious, and will not prevent you from building and testing the application.
 
Thank you. That is what I thought. I will postpone the align (padding) issues that seem to be warnings only. I will first try to correct the error.
 
http://www.delorie.com/gnu/docs/gcc/g77_567.html

http://cepa.fnal.gov/psm/simulation/mcfast/version_doc/v5_2/simulator/alignment_notes.html

By the way, I am not 100% sure that a problem with alignment is always just a warning...I wonder if it could become more than a performance problem and become a real memory problem as things get misplaced...but I don't know that much.

Sometimes, when not knowing the answer, is just as valuable to know how to stay away from trouble.

gsal
 
Last edited by a moderator:
gsal,
Thank you for the warning. The reason I am switching to solving the other problem of ambiguity of real is because this one appears to be an error. I cannot compile until I get rid of it. As you stated, it is quite possible that after correcting the error the many warnings on padding (align) may still prevent the program from running.
 

Similar threads

  • · Replies 3 ·
Replies
3
Views
5K
  • · Replies 3 ·
Replies
3
Views
5K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 4 ·
Replies
4
Views
5K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 5 ·
Replies
5
Views
4K
  • · Replies 1 ·
Replies
1
Views
17K
  • · Replies 9 ·
Replies
9
Views
9K