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

compile the old fortran 77 code worked with Compaq Fortran

Howard_Lee
Beginner
1,850 Views

HI

I have a set of old Fortran 77 code, they were compiled and executed with old Compaq Fortran and it worked fine. With the Intel Fortran, they either cannot be compiled, or the results of execution different form results with Compaq.

Is there any setting/flags available to make the Intel compiler bahave the same as Compaq f77? Or are there any settings required to compile 77 Fortran code?

Thanks

Howard

0 Kudos
10 Replies
mecej4
Honored Contributor III
1,850 Views
In all likelihood, there are bugs in your code (deviations from the Fortran standard) that did not show up when you used the Compaq compiler, or the code relied on nonstandard extensions provided by the compiler (for example, implicit SAVE of all local variables).

Read this note:

Migrating from CVF

and, if there are still questions left unanswered, you may ask here.
0 Kudos
Steven_L_Intel1
Employee
1,850 Views
Also, if you would like help, please post or attach the code in question along with the error messages. If you are getting argument type mismatch errors or similar, then these are coding errors not detected by the earlier compiler.

Please note that Intel Visual Fortran is directly descended from Compaq Visual Fortran (there was never any such thing as Compaq F77), so correct code should work.
0 Kudos
Howard_Lee
Beginner
1,850 Views

the code base is pretty big (about 5000 lines of code for one module)

so far i encounter 2 discrepancies: when a main program call a subroutine, the array in the sub dimension with larger value, then it will not spit error message in Intel, however, it seems accepted in Compaq.

another issome local variables (undeclared with sobroutine)which i know they behave differently from the 'old module'. In the intel environment,they weresometimes set to 0, however, under Compaq environment, seems they carry the values set in previous call.

is there any way i can make the compiled behavior the same as the 'old Compaq' does?

Thanks

Howard

0 Kudos
Steven_L_Intel1
Employee
1,850 Views
Ok, so you do indeed have bugs in your code that were not detected by the Compaq compiler.

For the first case, it is an error for an array dummy argument in the subroutine to be larger than the array you are passing to it. You should fix this, as otherwise you may get unpredictable results. If you know that the subroutine never accesses past the end of the array, declare it with (*) in the subroutine instead of the larger size.

In the second case, you make the invalid assumption that local variables retain their value across calls without the SAVE attribute. Add a SAVE statement in the subroutine that names the variables where this is needed. You can just say SAVE with no variable names listed, and all will be saved.
0 Kudos
Howard_Lee
Beginner
1,850 Views
Hi

Your suggestions do help, the first program seems working now. However, still there are other discrepancies found in the subsequent modules.

My qeustion is: are there any documentation on all the possible discrepancies between Compaq and Intel, and how to remediate them to make them compatible?

Thanks

Howard
0 Kudos
Steven_L_Intel1
Employee
1,850 Views
The article on migrating from Compaq Visual Fortran is the best resource. We have made many improvements to error detection, so sometimes programs thast CVF let by are now detected as errors.

Please describe the problems and we'll be glad to help you with them.
0 Kudos
Vinod
Beginner
1,850 Views
Steve Lionel (Intel) wrote:

Also, if you would like help, please post or attach the code in question along with the error messages. If you are getting argument type mismatch errors or similar, then these are coding errors not detected by the earlier compiler.

Please note that Intel Visual Fortran is directly descended from Compaq Visual Fortran (there was never any such thing as Compaq F77), so correct code should work.

Dear Steve, Could you please help me? I have a code (attached with the post, downloaded from netlib.org) which used to work fine with Compaq, but it does not give proper results in Intel. I am calling ranf() function which logically should return a random value between 0 - 1, but it gives me 48271.0 always. :( Looking forward for your reply. Regards, Vinod
(Virus scan in progress ...)
0 Kudos
Steven_L_Intel1
Employee
1,850 Views
Vinod, RANF is a non-standard routine and, as such, its meaning can vary by implementation. However, looking at my CVF documentation I don't see that it defined a RANF function at all. (I can't try it out until tomorrow.) We document RANF as returning a value in the range 0. to 32767. which is apparently consistent with a similar C function. I strongly recommend that you use the standard Fortran intrinsic RANDOM_NUMBER. If you want the sequence to vary each run, insert a single call to RANDOM_SEED, without arguments, at the beginning of your program. (Note that RANDOM_NUMBER is a subroutine, not a function.)
0 Kudos
mecej4
Honored Contributor III
1,850 Views
The file that was attached (snorm.f) contains a function that returns normally distributed real numbers, which it obtains from uniformly distributed random numbers using a transformation. The uniformly distributed random numbers are supposed to be obtained by calling RANF(), which https://wci.llnl.gov/codes/basis/manual/node183.html identifies as an old 48-bit RNG. This RANF was part of Mathlib on CRAY computers, and there is mention of RANF in the CXML library documentation that came with Compaq Visual Fortran, but that documentation says that the Windows version of CXML did not have the Scilib component, which would have provided RANF. Steve's advice to call the modern RANDOM_NUMBER is good. If, however, you need to reproduce the behavior of old code I suggest that you change all instances of RANF in snorm.f to ORANF, and use the following for ORANF, which implements the old function referenced above. [fortran] function oranf() integer*8 S,a,M data S/Z'0000948253fc9cd1'/,a/Z'00002875a2e7b175'/ data M/Z'0001000000000000'/ oranf=real(S)/M S=iand(a*S,Z'0000FFFFFFFFFFFF') return end [/fortran] GNU's GSL library contains the RANF as one of several selectable generators. To use it from Fortran, you will need to write a suitable wrapper function.
0 Kudos
Vinod
Beginner
1,850 Views
mecej4 wrote:

The file that was attached (snorm.f) contains a function that returns normally distributed real numbers, which it obtains from uniformly distributed random numbers using a transformation. The uniformly distributed random numbers are supposed to be obtained by calling RANF(), which https://wci.llnl.gov/codes/basis/manual/node183.html identifies as an old 48-bit RNG.

This RANF was part of Mathlib on CRAY computers, and there is mention of RANF in the CXML library documentation that came with Compaq Visual Fortran, but that documentation says that the Windows version of CXML did not have the Scilib component, which would have provided RANF.

Steve's advice to call the modern RANDOM_NUMBER is good. If, however, you need to reproduce the behavior of old code I suggest that you change all instances of RANF in snorm.f to ORANF, and use the following for ORANF, which implements the old function referenced above.


      function oranf()

      integer*8 S,a,M

      data S/Z'0000948253fc9cd1'/,a/Z'00002875a2e7b175'/

      data M/Z'0001000000000000'/

      oranf=real(S)/M

      S=iand(a*S,Z'0000FFFFFFFFFFFF')

      return

      end

Thank you Steve and mecej4 for your replies. The function, oranf() has solved my problem. :) With best regards, Vinod
0 Kudos
Reply