使用其他模块的模块如何影响编译? (gfortran)

时间:2017-09-29 18:12:40

标签: compilation fortran gfortran

我在这里询问了一个关于Fortran编译器的一些奇怪行为的问题:

gfortran compiler cannot find misspelled full directory

基本上,编译器偶尔**抱怨文件丢失,但问题是文件的打印名称(实际上是完整路径)拼写错误,所以难怪它“丢失”。我认为我通过使用相对路径来解决问题,但事实证明问题只是休眠。以下是一个这样的投诉的例子:

C:\Users\charl\Documents\GitHub\MOONS>gfortran -fopenmp -g -fimplicit-none -cpp
C:/Users/charl/Documents/GitHub/MOONS/code/globals/current_precision.f90 
...
C:/Users/charl/Documents/GitHub/MOONS/code/solvers/induction/init_Bfield.f90 
C:/Users/charl/Documents/GitHub
gfortran: error: 
C:/Users/charl/Documents/GitHubMOONS/code/solvers/induction/init_Sigma.f90: No such file or directory

请注意,GitHub和MOONS之间缺少正斜杠('/'),而是读取“GitHubMOONS”。此路径已在makefile中正确写入。

**我偶尔会说,因为更改代码中的行有时会导致错误消失。同样,从我的编译列表中删除一些未使用的模块(编译得很好)会导致错误消失。

我正在使用的编译器是:

 GNU Fortran (x86_64-posix-seh-rev0, Built by MinGW-W64 project) 4.9.2 Copyright (C) 2014 Free Software Foundation, Inc.

但是我在最近的编译器中遇到了同样的问题,例如:

 x86_64-7.1.0-release-posix-seh-rt_v5-rev2

我认为我看到这种错误发生时的趋势,并且当模块将公共接口传递给其他模块时,它似乎更频繁地发生。

问题

所以,我的问题是,给出以下两个模块:

   module add_int_mod
   implicit none
   private
   public :: add
   interface add; module procedure add_int; end interface
   contains
   subroutine add_int(a,b)
     implicit none
     integer,intent(inout) :: a
     integer,intent(in) :: b
     a = a + b
   end subroutine
   end module

   module add_all_mod
   use add_int_mod
   implicit none
   private
   public :: add
   end module

这两个程序有什么区别,如果有的话?

计划1

   program main
   use add_all_mod                         ! only difference
   implicit none
   integer :: a,b
   a = 0
   b = 1
   call add(a,b)
   write(*,*) 'a = ',a
   write(*,*) 'b = ',b
   end program

计划2

   program main
   use add_int_mod                         ! only difference
   implicit none
   integer :: a,b
   a = 0
   b = 1
   call add(a,b)
   write(*,*) 'a = ',a
   write(*,*) 'b = ',b
   end program

我感谢任何帮助/建议。

0 个答案:

没有答案