为 LF 编译器识别此代码的 Fortran 版本 [英] Identify version of Fortran of this code for the LF compiler

查看:25
本文介绍了为 LF 编译器识别此代码的 Fortran 版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 Fortran 新手.我得到了一个应该在 Fortran 90 中的文件,但编写为使用 Lahey Fujitsu 编译器进行编译(稀疏文档指出它应该使用 lf95 filename.f -out compiled_name @imsllf95.cmd).但是,有些行用 c 注释,据我了解,这是在 Fortran 77 中注释的方式.此外,矩阵声明为 REAL*8, DIMENSION(23,8) ::xxx19,我认为它来自 Fortran 77.

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.

在大多数情况下,我可以使用 gfortranifort 编译文件,但需要计算矩阵逆的部分除外.显然,在 LF95 编译器中(使用专有模块 IMSLF90),使用 .i. 计算矩阵逆.如果我删除这些反转,文件编译并运行没有问题(除了它给出错误结果的事实).

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).

我正在尝试查找编写此代码的 Fortran 版本,以便我可以搜索以相同版本编写的一些代码,以便我可以反转代码中的矩阵.

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.

该文件具有扩展名 .f,尽管编译说明似乎暗示它是 Fortran 95.

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

这里有部分代码:

    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/)

推荐答案

Real*8 不是 Fortran 的一部分,也从未成为 Fortran 的一部分.所以对你的问题的严格回答是它不是任何年份的 Fortran.

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.

但是,除了 Real*8 之外,您所展示的内容是 Fortran 90 或更高版本.固定源代码形式仍然是该语言的一部分(尽管我会让任何使用它的学生失败),因此它不是代码年代的指标.然而,在快速浏览以上内容后,我可以看到 Fortran 90 标准语言中的以下功能:

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:

  • 混合大小写(字符变量和常量之外)
  • 符号名称中的下划线
  • 隐式无
  • :: 在变量声明和逗号分隔的属性列表中
  • 超过 6 个字符的变量名称
  • 用双引号 (") 分隔字符串
  • Do ... End Do(我假设您出于某种原因错过了 End Do,否则上面的片段毫无意义)
  • == 测试相等性
  • Intent 用于虚拟参数
  • 数组部分
  • 数组构造函数

可能还有其他人.

这篇关于为 LF 编译器识别此代码的 Fortran 版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆