Porting fortran program-problem with padding in common

  • Fortran
  • Thread starter saleemhasan
  • Start date
  • Tags
    Fortran
In summary: I will try to solve the error and come back to the align warnings if I am not successful with running the program.In summary, a user is seeking help with porting a Fortran program to Linux. They have encountered warnings about padding and have tried various options to address it, but none have worked. They are now seeking advice on whether to prioritize fixing the padding warnings or an error related to ambiguity in real variables. They are also considering re-ordering the variables in the program as a potential solution. They will try to fix the error first and then address the padding warnings if needed.
  • #1
saleemhasan
9
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
  • #2
When all else fails, read the instructions. Your system must have some documentation for running the compiler.
 
  • #3
I will try that option next SteamKing.
Thank you.
 
  • #4
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 :-)
 
  • #5
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 :)
 
  • #6
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.
 
  • #7
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.
 
  • #8
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:
  • #9
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.
 

1. What is porting and why is it necessary?

Porting is the process of adapting a computer program from one operating system or programming language to another. It is necessary when the program needs to run on a different system or environment, or when there are changes in the language or platform being used.

2. What is a fortran program and why is it commonly used?

Fortran is a high-level programming language primarily used for scientific and engineering applications. It is commonly used because of its efficiency, speed, and ability to handle complex mathematical calculations.

3. What is padding in common in fortran programs?

Padding in common refers to the extra memory space reserved for variables in a common block. This is necessary to ensure that the program runs smoothly on different systems, as some systems have stricter memory alignment requirements.

4. Why does padding in common cause problems when porting fortran programs?

Padding in common can cause problems when porting fortran programs because the amount of padding may vary on different systems, leading to inconsistencies in the program's memory usage. This can result in unexpected behavior and errors.

5. How can padding in common be addressed when porting fortran programs?

To address padding in common when porting fortran programs, the programmer can use compiler directives or preprocessor commands to control the amount of padding in common. Alternatively, the program's code can be modified to use different data structures that do not require padding. It is important to test the program thoroughly after making any changes to ensure it runs correctly on different systems.

Similar threads

  • Programming and Computer Science
Replies
4
Views
3K
  • Programming and Computer Science
Replies
4
Views
4K
  • Programming and Computer Science
Replies
4
Views
4K
  • Programming and Computer Science
Replies
1
Views
3K
  • Programming and Computer Science
Replies
1
Views
3K
  • Programming and Computer Science
Replies
1
Views
3K
  • Programming and Computer Science
Replies
1
Views
3K
  • Programming and Computer Science
Replies
5
Views
3K
  • Programming and Computer Science
Replies
4
Views
15K
Back
Top