如何在 Eclipse Phortran 中创建支持模块依赖关系的托管构建?

发布于 2024-12-20 03:20:46 字数 1023 浏览 3 评论 0原文

我已经安装了新的 Phortran 7 作为 PTP 的一部分。

我想使用 OOP 方法开发我的代码,这需要我有许多模块 我发现托管构建系统无法理解 .f90 文件中的依赖关系。

我现在正在研究这个问题一天。我将使用“假”项目解释我的问题

我的项目有 2 个文件

main.f90、module1.f90

main.f90 :

program main
    use module1
    implicit none
    .....
    code...
    .....
end program main

module1.f90:

module module1
    implicit none
    contains
     .....
    code...
    .....
end module module1

当我在 IDE 中使用托管 make 和 build 命令编译此代码时,我得到以下内容错误:

Fatal Error: Can't open module file 'module1.mod' for reading at (1): No such file or directory
make: *** [main.o] Error 1

makefile 似乎按照

从子目录文件中获取的字母顺序排列:

F90_SRCS += \
../main.f90 \
../module1.f90

OBJS += \
./main.o \
./module1.o

我确实检查了这一点,如果我在 main.f90 之前按照 modul1.f90 的顺序编译项目,一切都会很好。

但我的印象是IDE可以自动解决这个问题,Fortran中的USE关键字需要告诉IDE以什么顺序链接文件。

有人可以帮我解决这个问题吗?我在其他线程中读到托管 make 应该理解依赖关系。

非常感谢。

I have installed the new Phortran 7 as part of the PTP.

I want to develop my code using an OOP approach which requires me to have many modules
I have found that the managed build system doesn't understand dependencies in my .f90 files.

I was working on this problem for a day now. I will explain my problem using a "fake" project

My project have 2 files

main.f90, module1.f90

main.f90 :

program main
    use module1
    implicit none
    .....
    code...
    .....
end program main

module1.f90:

module module1
    implicit none
    contains
     .....
    code...
    .....
end module module1

When I compile this code using the managed make and build command in the IDE I get the following error:

Fatal Error: Can't open module file 'module1.mod' for reading at (1): No such file or directory
make: *** [main.o] Error 1

It seems like that makefile goes in the alphabet order

taken from the subdir file:

F90_SRCS += \
../main.f90 \
../module1.f90

OBJS += \
./main.o \
./module1.o

I did checked this and if the I compile the project in the order of modul1.f90 before main.f90 everything works great.

But I was under the impression that the IDE can automatically take care of this problem, the USE keyword in Fortran needs to tell the IDE what order to link the files.

Can someone help me with this, I have read in other threads that the managed make should understand dependencies.

Thank you very much.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

巷子口的你 2024-12-27 03:20:46

我做了一些解决方法,试图告诉 makefile 处理器找到依赖项。
(针对并行应用程序开发人员在 Eclipse 上进行了测试。版本:Juno Release。内部版本 ID:20120614-1722

  1. ) noreferrer">设置模块和包含路径(引用此数字)

如果您的源代码包含 INCLUDE 行或 USE 行引用
其他文件中的模块,Photran 需要知道按顺序查看哪里
找到这些。它不会自动解决这个问题。对于每个
您计划在其中使用重构支持的项目,

  1. 在 Fortran 项目视图中右键单击项目文件夹
  2. 点击“属性”
  3. 展开左侧列表中的 Fortran General,然后单击 Analysis/Refactoring
  4. 列出 Photran 所在的文件夹
    重构时应该搜索 INCLUDE 文件和模块。将从列出的第一个文件夹到最后一个文件夹按顺序搜索它们。子文件夹不会自动搜索;您必须明确包含它们。
  5. 点击“确定”

。 2.在 Eclipse IDE 中,右键单击项目文件夹,然后 -> 重构 -> 子程序 -> 引入调用树。它应该向您显示模块中的所有依赖项。

您应该小心模块的顺序:

模块

module constants
  implicit none
  real, parameter :: PI=3.14
  real, parameter :: E=2.71828183
  integer, parameter :: answer=42
  real, parameter :: earthRadiusInMeters=6.38e6
end module constants
module constants2
  implicit none
  real, parameter :: PI2=3.14
  real, parameter :: E2=2.71828183
  integer, parameter :: answer2=42
  real, parameter :: earthRadiusInMeters2=6.38e6
end module constants2

使用它将运行的 (代码修改自 此处),

program test
! Option #1:  blanket "use constants"
!  use constants
! Option #2:  Specify EACH variable you wish to use.
  use constants, only : PI,E,answer,earthRadiusInMeters
  use constants2, only : PI2,E2,answer2,earthRadiusInMeters2
  implicit none

  write(6,*) "Hello world.  Here are some constants:"
  write(6,*) PI, E, answer, earthRadiusInMeters
    write(6,*) PI2, E2, answer2, earthRadiusInMeters2
end program test

但如果您

  use constants, only : PI,E,answer,earthRadiusInMeters
  use constants2, only : PI2,E2,answer2,earthRadiusInMeters2
  implicit none

对此

  use constants2, only : PI2,E2,answer2,earthRadiusInMeters2
  use constants, only : PI,E,answer,earthRadiusInMeters
  implicit none

进行更改,您将得到相同的错误。

对于更大的程序,我使用了 手动 makefile 选项 。但为了调试,我使用了 Intel 调试器 idb,因为使用相同的 makefile Photran 的调试器没有设置断点。

祝你好运,朋友。

I've made a little workaround trying to tell the makefile processor to find the dependences.
(Tested on Eclipse for Parallel Application Developers. Version: Juno Release. Build id: 20120614-1722)

  1. Set Module and Include Paths (This numeral is cited)

If your source code contains INCLUDE lines or USE lines referencing
modules in other files, Photran needs to know where to look in order
to find these. It will not figure this out automatically. For each
project in which you plan to use refactoring support,

  1. Right-click on your project's folder in the Fortran Projects view
  2. Click on Properties
  3. Expand Fortran General in the list on the left, and click on Analysis/Refactoring
  4. List the folders in which Photran
    should search for INCLUDE files and modules when refactoring. They will be searched in order from the first folder listed to the last.Subfolders are not searched automatically; you must include them explicitly.
  5. Click OK

. 2.In the eclipse IDE make right click in your project folder then ->refactor->subprogram->introduce call tree. It should show you all the dependences in your modules.

You should be careful with the order of your modules:

with the module

module constants
  implicit none
  real, parameter :: PI=3.14
  real, parameter :: E=2.71828183
  integer, parameter :: answer=42
  real, parameter :: earthRadiusInMeters=6.38e6
end module constants
module constants2
  implicit none
  real, parameter :: PI2=3.14
  real, parameter :: E2=2.71828183
  integer, parameter :: answer2=42
  real, parameter :: earthRadiusInMeters2=6.38e6
end module constants2

it will run with (Code modified from here)

program test
! Option #1:  blanket "use constants"
!  use constants
! Option #2:  Specify EACH variable you wish to use.
  use constants, only : PI,E,answer,earthRadiusInMeters
  use constants2, only : PI2,E2,answer2,earthRadiusInMeters2
  implicit none

  write(6,*) "Hello world.  Here are some constants:"
  write(6,*) PI, E, answer, earthRadiusInMeters
    write(6,*) PI2, E2, answer2, earthRadiusInMeters2
end program test

but if you change

  use constants, only : PI,E,answer,earthRadiusInMeters
  use constants2, only : PI2,E2,answer2,earthRadiusInMeters2
  implicit none

for this

  use constants2, only : PI2,E2,answer2,earthRadiusInMeters2
  use constants, only : PI,E,answer,earthRadiusInMeters
  implicit none

You'll get the same error.

For a bigger program i've used the manual makefile option. But for debugging i've used Intel debugger idb because with the same makefile Photran's debugger did't put the breakpoints.

Best luck pal.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文