gfxgfx
 
Please login or register.

Login with username, password and session length
 
gfx gfx
gfx
1508 Posts in 498 Topics by 729 Members - Latest Member: shinkat August 05, 2020, 05:46:38 PM
*
gfx* Home | Help | Search | Login | Register | gfx
gfx
Absoft User Forum  |  Support  |  Windows  |  Compiler thrusts use association on Fortran 77 code
gfx
gfxgfx
 

Author Topic: Compiler thrusts use association on Fortran 77 code  (Read 36 times)

mecej4

  • Jr. Member
  • **
  • Posts: 66
Compiler thrusts use association on Fortran 77 code
« on: July 30, 2020, 11:33:15 PM »
The code below is a shortened version of a much longer subroutine, with enough content to demonstrate an issue with the current version of Absoft F77.


Code: [Select]
! Compile with f77 -N32
      subroutine expint(x,y,c)
      DATA Q, GAMMA / 3.1415927, 0.57721566 /
      c = q*exp(gamma*(x+y))
      return
      end


If the compiler (20.0.2) is run on this code, with one of these commands


Code: [Select]
f77 -c xgamma.f
f77 -N32 -c xgamma.f
f95 -c xgamma.f


it refuses to produce an OBJ file, aborting the compilation with the error message


Code: [Select]
f77 -N32 -c xgamma.f
Absoft ERROR 922: EXPINT: xgamma.f: 3, 15
  "GAMMA" has been use associated, therefore it must not be redeclared with the DATA initialized attribute.


Absoft Pro Fortran 20.0: 1 Errors, 0 Warnings, 0 Other messages, 0 ANSI
f90fe reported errors.


I should remark that Gamma is an intrinsic function only in F2008 and later versions of the Fortran Standard. Even if a compiler were to provide Gamma() as an extension, since intrinsic function names have never been reserved names in Fortran, only a warning message would be justified, not an aborting of the compilation.

If a REAL type declaration for GAMMA is added, the error goes away.


Attachments and other options
I note that Gamma() is an intrinsic function in F2008 and later; it is not present as such in F2003 or Fortran 95 and earlier versions of Fortran. Secondly, since intrinsic function names are not reserved names, even if we apply Fortran 2008 rules the use of Gamma may at best trigger a warning, not an error.
« Last Edit: July 30, 2020, 11:37:44 PM by mecej4 »

forumadmin

  • Administrator
  • Sr. Member
  • *****
  • Posts: 302
Re: Compiler thrusts use association on Fortran 77 code
« Reply #1 on: July 31, 2020, 07:33:49 AM »
This is a defect in the current compiler implementation. There are two work-arounds. As you discovered, bringing GAMMA into the local scope by adding a type declaration fixes the defect without changing the meaning of the code. If the code is strictly FORTRAN77, you can avoid this source code modification by compiling with the -noautoload-module option:
af77 -noautoload-module -c xgamma.f





mecej4

  • Jr. Member
  • **
  • Posts: 66
Re: Compiler thrusts use association on Fortran 77 code
« Reply #2 on: August 01, 2020, 04:29:46 AM »
Thanks, that compiler option works with the f77 command, as well.


It appears to be undocumented, though, since I could not find it in the 2020 ProFortran User Guide for Windows.

Absoft User Forum  |  Support  |  Windows  |  Compiler thrusts use association on Fortran 77 code
 

gfxgfx
gfx gfx
Powered by MySQL Powered by PHP Valid XHTML 1.0! Valid CSS!