Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

module dependency problem

Xiong__Jun
Beginner
390 Views

Hi,

I've encountered a strange problem of module dependency. It seems that the compiler integrated in microsoft visual studio can not correctly parse the module dependency under specific conditions. I tries to isolate the problem and simplifies it as the below sample:

The Visual Studio solution contains two projects.

One is named "foo" for a Fortran static library, which contains three modules in seperated source files: a, b, and c. Module b uses module c, which uses module a. Below are the simplified source files:

MODULE a
END MODULE a
MODULE b
  USE c
END MODULE b
! -*- coding: utf-8 -*-
! 兵
MODULE c
  USE a
END MODULE c

I should mention that file "c.f90" is utf-8 encoded and the last character of the second comment line is a Chinese character.

The other project in the solution is named "hello" for a C++ console executable. It is not related to project "foo". It can even be empty as the sample attached.

I open the solution with Visual Studio Professional 2015 + Intel Parallel Studio XE 2018 with Update 1, and build the project "foo". The output is as below:

1>------ 已启动生成: 项目: foo, 配置: Debug Win32 ------
1>Compiling with Intel(R) Visual Fortran Compiler 18.0.1.156 [IA-32]...
1>a.f90
1>b.f90
1>D:\mix\src\b.f90(2): error #7002: Error in opening the compiled module file.  Check INCLUDE paths.  
1>compilation aborted for D:\mix\src\b.f90 (code 1)
1>c.f90
1>
1>Build log written to  "file://D:\mix\Debug\BuildLog.htm"
1>foo - 2 error(s), 0 warning(s)

Below is the BuildLog.htm:

Build Log
           Build started: Project: foo, Configuration: Debug|Win32
Output
          Compiling with Intel(R) Visual Fortran Compiler 18.0.1.156 [IA-32]...
ifort /nologo /debug:full /Od /warn:interfaces /module:&quotDebug\\" /object:&quotDebug\\" /Fd&quotDebug\vc140.pdb" /traceback /check:bounds /check:stack /libs:dll /threads /dbglibs /c /Qlocation,link,&quotC:\MSVS14\VC\\bin" /Qm32 &quotD:\mix\src\a.f90"
ifort /nologo /debug:full /Od /warn:interfaces /module:&quotDebug\\" /object:&quotDebug\\" /Fd&quotDebug\vc140.pdb" /traceback /check:bounds /check:stack /libs:dll /threads /dbglibs /c /Qlocation,link,&quotC:\MSVS14\VC\\bin" /Qm32 &quotD:\mix\src\b.f90"
D:\mix\src\b.f90(2): error #7002: Error in opening the compiled module file.  Check INCLUDE paths.  
  USE c
------^
compilation aborted for D:\mix\src\b.f90 (code 1)

ifort /nologo /debug:full /Od /warn:interfaces /module:&quotDebug\\" /object:&quotDebug\\" /Fd&quotDebug\vc140.pdb" /traceback /check:bounds /check:stack /libs:dll /threads /dbglibs /c /Qlocation,link,&quotC:\MSVS14\VC\\bin" /Qm32 &quotD:\mix\src\c.f90"

foo - 2 error(s), 0 warning(s)

Obviously the source files should be compiled in the order a.f90, c.f90, b.f90. But b.f90 is compiled before c.f90, which is the cause of the error. I've found two workarounds:

  1. In the source file c.f90, insert another ordinary comment just before the MODULE statement:
    ! -*- coding: utf-8 -*-
    ! 兵
    !
    MODULE c
      USE a
    END MODULE c
    

     

  2.  Remove project "hello" from the solution.

 In both ways, the project "foo" is successfully built. The output is as below:

1>------ 已启动生成: 项目: foo, 配置: Debug Win32 ------
1>Compiling with Intel(R) Visual Fortran Compiler 18.0.1.156 [IA-32]...
1>a.f90
1>c.f90
1>b.f90
1>Creating library...
1>
1>Build log written to  "file://D:\mix\Debug\BuildLog.htm"
1>foo - 0 error(s), 0 warning(s)
========== 生成: 成功 1 个,失败 0 个,最新 0 个,跳过 0 个 ==========

 However, what's wrong with the original solution? Can anyone please shed some light? Thanks in advance.

Below is my detailed build environment:

Microsoft Visual Studio Professional 2015
版本 14.0.25420.01 Update 3
Microsoft .NET Framework
版本 4.6.01055

已安装的版本: Professional

LightSwitch for Visual Studio 2015   00322-50050-03552-AA218
Microsoft LightSwitch for Visual Studio 2015

Visual Basic 2015   00322-50050-03552-AA218
Microsoft Visual Basic 2015

Visual C# 2015   00322-50050-03552-AA218
Microsoft Visual C# 2015

Visual C++ 2015   00322-50050-03552-AA218
Microsoft Visual C++ 2015

Application Insights Tools for Visual Studio 包   1.0
Application Insights Tools for Visual Studio

Intel® Inspector 2018 Update 1   
Intel® Inspector 2018 Update 1, (build 535335), Copyright © 2009-2017 Intel Corporation. All rights reserved.

Intel® Parallel Studio XE 2018 Update 1 Composer Edition for C++ Windows*   Package ID: w_comp_lib_2018.1.156
Intel® Parallel Studio XE 2018 Update 1 Composer Edition for C++ Windows* Integration for Microsoft* Visual Studio* 2015, Version 18.0.27.14, Copyright © 2002-2017 Intel Corporation. All rights reserved.
* Other names and brands may be claimed as the property of others.

Intel® Parallel Studio XE 2018 Update 1 Composer Edition for Fortran Windows*   Package ID: w_comp_lib_2018.1.156
Intel® Parallel Studio XE 2018 Update 1 Composer Edition for Fortran Windows* Integration for Microsoft Visual Studio* 2015, Version 18.0.0037.14, Copyright © 2002-2017 Intel Corporation. All rights reserved.
* Other names and brands may be claimed as the property of others.

 BTW, I use not Intel C++ compiler but MSVC. And the attachment contains the source files and the Visual Studio solution file.

0 Kudos
1 Reply
FortranFan
Honored Contributor II
390 Views

@Xiong, Jun:

It looks like a bug in the Intel Fortran integration with Visual Studio.  You may want to submit a support request at the Intel Online Service Center to direct the attention of the Intel Fortran team to this issue:

https://supporttickets.intel.com/?lang=en-US

0 Kudos
Reply