Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Error using common block?

Joshua_W_2
Beginner
426 Views

I do not have much experience using fortran and I'm not used to having to go through so much trouble to get a compiler to work (I mostly use matlab). I have a very long fortran program (I did not write it) that i've used for the past year for some research i'm doing. Up until now, I have had access to absoft visual fortran, which made things very easy and user friendly for me. However, I no longer have access to absoft, so I have been trying to compile and run this program using intel fortran (also tried gfortran) on a mac. The program consists of a main source file (called GNSOP.f90, I changed this extension from .f95 for ifort), a common file (COMMON.inc), a format file (FORMAT.inc), and it should prompt the user for an input file when it runs. The problem seems to be with the common file as I get an error on virtually everyone line of the common file when I try to compile. I have attached a screenshot of a small portion of the long list of errors I get. This is too much for me to diagnose with my limited fortran experience and it is overwhelming me. Any help with this would be greatly appreciated.

0 Kudos
7 Replies
mecej4
Honored Contributor III
426 Views

The screenshot is not sufficient. Please zip up the source files (*.f90, *.inc) that you used, and attach the zip file to your reply, stating what compiler options were in effect.

0 Kudos
Joshua_W_2
Beginner
426 Views

Sorry, I attached the zip file containing the files. I have not invoked any of the non default compiler options. I have hardly any experience with compiling fortran code. In absoft, I dragged the three files into a project and was able to compile and run right away.

0 Kudos
mecej4
Honored Contributor III
426 Views

In the file COMMON.INC, you have a Fortran-77 style PARAMETER statement in which MNPP is declared to be the symbolic name for the integer constant MNPP, but the type of MNPP is declared much later. Add MNPP to, say, line-39 of COMMON.INC, and remove the current type declaration of MNPP.

You may also wish to use the /w option since your code has a large number of instances of misaligned common block elements.

I was able to produce an EXE and run the program, but it aborted because you have mismatched FORMAT statements corresponding to some WRITE statements that you (or someone else) modified without modifying the FORMAT statements to suit.

0 Kudos
Joshua_W_2
Beginner
426 Views

Thank you very much for your help. I don't quite understand the format problem or how to fix it. I suppose i'm just confused why absoft was able to run this no problem, but now I have to change the code to get it to run using intel (reluctant to do this since this is an established code). Does it have to do with this being written in Fortran-77? If so, is there a certain option that can be implemented that compiles as Fortran-77?

0 Kudos
mecej4
Honored Contributor III
426 Views

In file FORMAT.INC, there are two lines with "F10.4". Changing to "F11.4" should suffice.

The more serious problem is that there are several instances where items have been removed from older versions of WRITE statements (old versions now commented out but still present in the file) without checking whether the format needs to be modified as well. These are program errors that must be fixed, regardless of which compiler you use. A compiler that produces output with such format statements is not your friend -- the output results (e.g., integer printed with a F format, or a float printed with an I format) will be wrong.

0 Kudos
Joshua_W_2
Beginner
426 Views

Thank you so much! Extremely helpful! I don't need the data from output6 (where the errors were occurring) so I just commented all of those write statements out. I will take a closer look later when I have time to edit the code. For now, I'm up and running and able to output the values I currently need. Thanks again.

0 Kudos
TimP
Honored Contributor III
426 Views

These errors may be among those which Fortran 77 did not require a compiler to diagnose.  You can't expect an option to turn off all checking which wasn't mandatory under F77 (while accepting all those admittedly widely used IBM360 F66 extensions).

You may prefer a compiler which runs without checking correctness, but it may be impossible to verify whether your output is correct in such a case (or whether one compiler treats it the same as another).

0 Kudos
Reply