fortran-lang/vscode-fortran-support

bug: gfortran linter cannot open module files

marcelmbn opened this issue · 2 comments

Is there an existing issue for this?

  • I have searched the existing issues

Description

In some repositories (see below for an example), a linter error Cannot open module file 'mctc_env_accuracy.mod' for reading at (1): No such file or directory is produced, even though the project can be built without any problems.
However, the linter produces the <module>.mod file as it pops up in the file manager in the same position as the original .f90 file containing the module source, but apparently, it can't be read.
This is particularly peculiar because this applies not to every module but only to some specific ones.

One example for this behavior is the above-mentioned module error popping up when opening the following repository in VS code:
https://github.com/grimme-lab/mctc-lib

If opening an issue in the specific repository is more appropriate, I apologize for the mismatch.

Screenshots

Screenshot from 2023-08-01 09-09-04

Expected Behaviour

In my understanding, the linter should also produce no errors if the project can be built without errors using the same compiler as for the linting (here: gfortran).

Version of Modern Fortran

v3.2.0

Version of Visual Studio Code

v1.80.2

Platform and Architecture

Ubuntu 22.04

Additional Information

Commit of mctc-lib used for the above test: grimme-lab/mctc-lib@305eb7a

When using a global output directory with ${workspaceFolder}/modoutput/, these errors seem to be solved. However, I believe that this should also work with the default setting of having the module files locally (i.e., in the same path).

A few things to note here:

  • The building the project and providing linting diagnostics are somewhat isolated. You can build a project in any number of ways but since Modern Fortran does not know anything about the building step of your project, that information cannot be relayed to its linter.
  • The linter will try (not very hard, by default) to find the *.mod files. Similarly to having valid files to compile your project, it is up to the user to configure the linter options properly. The 2 tend to be quite similar since the linting is done after all by the compiler. You can have a look at the README.md for more details.
  • I would strongly advise using the pre-release version of the extension.