【问题标题】:which Fortran standard of these codes?这些代码的哪个 Fortran 标准?
【发布时间】:2020-10-26 19:59:16
【问题描述】:

我很困惑fortran代码子程序中的语法如下:

subroutine X(lr_orth_response)(mesh, st, lr, omega)
  type(mesh_t),   intent(in)    :: mesh
  type(states_t), intent(in)    :: st
  type(lr_t),     intent(inout) :: lr
  R_TYPE,         intent(in)    :: omega
  
  integer :: ist, ik
  PUSH_SUB(X(lr_orth_response))
  
  do ik = st%d%kpt%start, st%d%kpt%end
    do ist = 1, st%nst
      call X(lr_orth_vector) (mesh, st, lr%X(dl_psi)(:,:, ist, ik), ist, ik, omega)
    end do
  end do
  
  POP_SUB(X(lr_orth_response))
end subroutine X(lr_orth_response)

我检查了所有 Fortran 标准,但找不到任何有用的信息!有谁知道lr_orth_response 的标签是什么?另外,通过指针访问数据在lr%X(dl_psi)(:,:, ist, ik), ist, ik, omega)这一行也有点混乱,其中lr是用户定义的新类型lr_t,但没有名为X(dl_psi)的成员函数或变量。

【问题讨论】:

标签: syntax fortran subroutine


【解决方案1】:

这不是纯 Fortran。它看起来像是一个必须由某个预处理器预处理的源代码,可能是 C 预处理器cpp 或其变体fpp。预处理器将使用一些宏扩展R_TYPEPUSH_SUBPOP_SUBX。一些宏显然依赖于一些名为lr_orth_response 的参数。如果没有实际看到定义,我们无法说出该参数在这些宏中的作用,但我们需要您提供更多代码。它可能用于一些通用编程,但很难猜测到底是什么。

【讨论】:

  • 嗨弗拉基米尔,谢谢!您的猜测是合理的,这些代码来自计算量子化学包 Octopus 9.2。更具体的,它们来自文件 states/linear_response_inc.F90,参见gitlab.com/octopus-code/octopus/-/blob/9.2/src/states/…
  • @YingxingCheng 扩展中的大写F使其自动被cppfpp预处理。但是,代码不完整。最有可能的是,该文件使用#include 指令包含在其他位置。然后在包含#include 的文件中定义相关的宏。软管包括可以嵌套。文件名中的 _inc 明确表明它是要包含的文件。
  • 你是对的。该文件包含在linear_response.F90 中,其中包含一些 C++ 宏以区分此子例程中使用的实数和复数。再次感谢!
猜你喜欢
  • 2011-08-04
  • 1970-01-01
  • 1970-01-01
  • 2010-12-19
  • 2014-09-11
  • 2019-10-21
  • 1970-01-01
  • 1970-01-01
  • 2023-03-20
相关资源
最近更新 更多