Identify version of Fortran of this code for the LF compiler

試著忘記壹切 提交于 2020-01-13 20:49:00

问题


I'm new to Fortran. I was given a file that is supposed to be in Fortran 90, but written to be compiled with the Lahey Fujitsu compiler (the sparse documentation states that it should be compiled with lf95 filename.f -out compiled_name @imsllf95.cmd). However, some lines are commented with c, which as I understand was the way to comment in Fortran 77. Also, matrices are declared like REAL*8, DIMENSION(23,8) :: xxx19, which again I think is from Fortran 77.

For the most part, I can compile the file with gfortran or ifort except for a section that requires the computation of a matrix inverse. Apparently, in the LF95 compiler (using a propietary module IMSLF90), a matrix inverse was computed with .i.. If I delete those inversions, the file compiles and runs with no problem (apart from the fact that it gives the wrong result).

I'm trying to find the version of Fortran this code is written in, so that I can then search for some code written in that same version so that I can invert the matrices in the code.

EDIT: The file has extension .f, even though the compiling instructions seem to imply that it is Fortran 95.

Here I have some sections of the code:

    PROGRAM estimate_group
    implicit none

    INTEGER :: i,j,k,full,group1
    REAL*8, DIMENSION(500) :: theta_start,theta_input



    OPEN(68, STATUS="REPLACE",file='fit_measures.txt')
c   OPEN(68, file='fit_measures.txt')
    REWIND(68)

    DO full=1,1

        PRINT *, "=================================="
        PRINT *, "FULL LOOP #: ", full
        PRINT *, "=================================="
        WRITE(68, *) "=================================="
        WRITE(68, *) "FULL LOOP #: ", full
        WRITE(68, *) "=================================="   

    DO group1=2,28

c   Additional If statement to focus on top level and scale
c       IF ( ((group1>=22) .AND. (group1<=28)) .OR. (group1==2)) THEN
        IF ( group1==2) THEN

c   READING IN THETA VECTOR FROM PREVIOUS ITERATIONS
c   (starting values taken from prior runs theta output)
c   ====================================================

        IF ((group1==2) .AND. (full==1)) THEN
            theta_input=0.0*theta_input
            OPEN(67, file='theta_input1.txt')
            REWIND(67)
            DO i=1,500
            READ(67,*) theta_input(i)
            END DO
        ELSE
            theta_input=0.0*theta_input
            OPEN(66,file='theta_input.txt')
            REWIND(66)
            DO i=1,500
            READ(66,*) theta_input(i)
            END DO
        END IF


    SUBROUTINE estimate(group1, theta_start)

        INTEGER, INTENT(IN) :: group1
        REAL*8, INTENT(IN), DIMENSION(500) :: theta_start


c   Variable Declarations:\ 

        INTEGER :: i,j,k,m,l,t0,i0,improve,max_m



        REAL*8, DIMENSION(23,8) :: xxx19
    xxx19(1:23,1) = (/554.0,541.1,583.3,593.2,615.8,582.0,582.5,546.5,
     &          538.4,494.1,503.3,494.1,486.9,478.6,432.6,439.6,
     &          380.4,355.4,305.9,271.8,254.6,208.8,202.8/)

回答1:


Real*8 is not part of Fortran, and has never been part of Fortran. So the strict answer to your question is it is not Fortran of any vintage.

However going on what you have shown apart from Real*8 it is Fortran 90 or later. Fixed source form is still part of the language (though I would fail any students I have for using it) so it not an indicator of the vintage of the code. However after a quick look at the above I can see the following features which came into the standard language in Fortran 90:

  • Mixed case (outside character variables and constants)
  • Underscore in symbol name
  • Implicit None
  • :: in variable declarations and comma separated attribute lists
  • Variable names longer than 6 characters
  • Double inverted commas (") to delimit character strings
  • Do ... End Do (I assume you have missed out the End Do for some reason as otherwise the fragments above make no sense whatsoever)
  • == to test equality
  • Intent for dummy arguments
  • Array sections
  • Array constructors

There may be others.



来源:https://stackoverflow.com/questions/57472015/identify-version-of-fortran-of-this-code-for-the-lf-compiler

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!