Unable to open MODULE file

Hi there

I am new to working with PVF. I have an existing project with IVF and want to migrate it to PVF. My project contains four source files (.f90) and a static library (.lib). As instructed in the PVF Users’ Guide, I created a new project in PVF and moved and added all the source files to the new project. I tried two ways for adding the .lib file, once simply by adding it to the project (something which works with IVF in MVS2010), and another time by creating a new project in the PVF project and including the .lib file there (as suggested by the User’s guide). But, unfortunately, both times I get similar errors as listed below:


Input.f90
PGF90/x86-64 Windows 13.3-0: compilation aborted
Module not found while generating build dependencies; will retry Input.f90

Output.f90
PGF90/x86-64 Windows 13.3-0: compilation aborted
Module not found while generating build dependencies; will retry Output.f90

SOCP-CUDAFOR.f90
PGF90/x86-64 Windows 13.3-0: compilation aborted
Module not found while generating build dependencies; will retry SOCP-CUDAFOR.f90

Solve.f90
PGF90/x86-64 Windows 13.3-0: compilation aborted
Module not found while generating build dependencies; will retry Solve.f90

Input.f90
C:\Omid’s project\My SOCP Codes\SOCP-CUDAFOR\SOCP-CUDAFOR\Input.f90(3) : error F0004 : Unable to open MODULE file ut_input.mod
PGF90/x86-64 Windows 13.3-0: compilation aborted

Output.f90
C:\Omid’s project\My SOCP Codes\SOCP-CUDAFOR\SOCP-CUDAFOR\Output.f90(3) : error F0004 : Unable to open MODULE file nlp_structures.mod
PGF90/x86-64 Windows 13.3-0: compilation aborted

SOCP-CUDAFOR.f90
C:\Omid’s project\My SOCP Codes\SOCP-CUDAFOR\SOCP-CUDAFOR\SOCP-CUDAFOR.f90(20) : error F0004 : Unable to open MODULE file input.mod
PGF90/x86-64 Windows 13.3-0: compilation aborted

Solve.f90
C:\Omid’s project\My SOCP Codes\SOCP-CUDAFOR\SOCP-CUDAFOR\Solve.f90(8) : error F0004 : Unable to open MODULE file ut_solve.mod
PGF90/x86-64 Windows 13.3-0: compilation aborted
SOCP-CUDAFOR build failed.


My four .f90 files are named : “input.f90”,“output.f90”,“SOCP-CUDAFOR.f90” and “solve.f90”. The main program is contained in SOCP-CUDAFOR.f90, and other three source files contain only modules with the same name of the corresponding files.

The mentioned modules in the errors, i.e. “ut_solve.mod”, “nlp_structures.mod” and “ut_input.mod” are included in the “.lib” file. These modules are used inside the three modules contained in three “.f90” files. The input.mod is, on the other hand, is a module itself contained in “input.f90” file.

my suspicion is that the compiler does not recognize the .lib file.
How exactly should I add an existing “.lib” file to the PVF project?
Also, do I need to export any other things form my existing project to the PVF project?
Or any other suggestions?

Many thanks,

Omid

Hi Omid,

The mentioned modules in the errors, i.e. “ut_solve.mod”, “nlp_structures.mod” and “ut_input.mod” are included in the “.lib” file. These modules are used inside the three modules contained in three “.f90” files. The input.mod is, on the other hand, is a module itself contained in “input.f90” file.

Module files can’t be including a library. Perhaps you meant that the object files are part of this library?

In any event, you will need the source for these modules included in your project. The format of Module files are not standard across compilers, so even if you had the old mod file from IVF, you would still need to recompile them with PGI. Also, several F90 features are not compatible across Fortran compilers, so all F90 source would need to be recompiled with PGI. (F77 is fine across compilers).

You can build the library as a separate PVF project. However, you would add the directory containing the mod files via the new project’s Project Property Page “Fortran->Module Path”.

Note, you can link against external libraries by adding them to your project’s property pages “Linker->Input->Additional Dependencies” list and the path to the libraries can be added in “Linker->General->Additional Library Directories”

Hope this helps,
Mat

Hi Mat,

Thank you very much for your reply.

What I mentioned was that the modules are included in (not including) the library, that is they are part of the library embedded in the “.lib” file.

I tried your second and third recommendations and none of them solved the problem. still getting the same error.

It seems that I need to follow the first one, i.e. moving all the source files included in the library to the PVF project and compile them with PVF. However, this seems a bit odd to me as a static library needs to be fully compatible in different compilers.
The “.lib” file I have got includes some standard modules, such as “Numerical Recipes”, some routines out of HSL library and etc. in order not to have to move so many source files between different projects in hand, I made a “.lib” file to be kept as a tool.
What if I need to use other libraries from other sources, for example, available online?! Would I need to do the same thing with them? I do not have access to their source codes then!

Thank you for your help.

Omid

Library files contain a number of object files and, sometimes, a directory table to the object files. These object files correspond to IBM mainframe “object modules”, and are not to be confused with Fortran module files (*.mod).

You are mistaken. Such compatibility may be encountered if the Fortran sources from which they were compiled perform no I/O and all the compilers involved address the same machine architecture and operating system, and follow the same register level calling conventions. It would be folly to count on such compatibility. If, in addition, the use of subprograms in the library requires providing interfaces or USE {modulename} statements, the .mod files need to be available, and these are almost invariably compiler-specific.

What I mentioned was that the modules are included in (not including) the library, that is they are part of the library embedded in the “.lib” file.

While I don’t know IVF, I would find it odd if they embedded the module files (.mod) in with the library. I can see the benefit since you’d only need to carry around the “.lib” file but then the compiler would need access to the library at compile time instead of just link.

What if I need to use other libraries from other sources, for example, available online?! Would I need to do the same thing with them? I do not have access to their source codes then!

In general, libraries should be written in C or F77. There are far fewer portability issues, and none compiler related, with these languages than F90/F2003 or C++.

The “.lib” file I have got includes some standard modules, such as “Numerical Recipes”, some routines out of HSL library and etc. in order not to have to move so many source files between different projects in hand, I made a “.lib” file to be kept as a tool.

HSL has a C interface which can be called from any compiler’s F90. Depending on which implementation of Numerical Recipes you’re using, these are typically F77, which is also compiler agnostic.

Please see Chapter 13, “Inter-Language Calling”, of the PGI Compiler User’s Guide (http://www.pgroup.com/doc/pgiug.pdf) for more details.

Hope this helps,
Mat

Mat,

Thank you for your reply.

As you suggested in your first reply, I Included all the source files for the modules I use in my project. If I include all of them (.f90 files) in one project, it works fine. But, if I create two separate projects, one of type console application in which I place the main program, and one of type static library and include the source files for modules in that, and set the order of building correctly, I get the same error “Unable to open something.mod file”. However, this time “.obj” files, “.lib” file and “.mod” files are created in the project of type static library.

In fact, I guess you can create a simple example for yourself to see what I mean.

First create an IVF project of type console application and place your main program there. Your main program will use a module. Then add a new project of type static library to your solution and place the source file for your module in there. choose the correct building order for the two projects and you will see it works fine.

But do the same thing in PVF and it won’t work and give you the mentioned error.

Why is that so? I am so confused!

Many thanks for your help,

Omid

I get the same error “Unable to open something.mod file”

I assume you mean that you get this when building the “main” program. In this case, you need to set the module path option in your Project Property “Fortran->Module Path” to the directories where the library mod files are located. One caveat is that the first directory listed is also added to the directories to be “cleaned”. Hence, if you do not want the mod files to be deleted when you clean “main”, be sure to add a dummy directory as the first directory.

Hope this helps,
Mat

Hi Mat,

I Tried what you suggested. I add the directories where the library mod files are located to the module path. This time when I build the main program, I get another set of errors.
“Unresolved external symbol module1_add_referenced in function MAIN_”
“Unresolved external symbol MODULE1”

in which “module1” is a single module which is used in the main program, and “add” is a subroutine which is located in module1 and is called from the main program.

Any idea what might be the problem?

Thanks a lot,

Omid

Hi Omid,

The object or library which contains this symbol needs to be added to your link options.

  • Mat

Mat,

Thanks a lot.
That final trick made the project work.

Many thanks for your valuable advice.

Cheers,

Omid