vscode-fortran-ls
vscode-fortran-ls copied to clipboard
How do I define compiler options
I'm using this extension with visual studio code in windows 10. It works well for some of my projects. But most of my projects uses mpi
and this extension throws error here,
use mpi
complaining ablut not finding the mpi.mod
file. Now I can link the location of that particular .mod
file with the compiler flag
-I path
But, how do I specify that fort this extension to use for my project.
I'm having similar issues with some of my projects on Mac OSX. where I have a complex directory structure with a main src/ directory and subdirectories where source files use modules defined in other directories, and VS Code doesn't recognize them because they are in a different directory. In emacs, using flycheck
and f90-mode
I have to put in flycheck-gfortran-include-path
entries to properly parse all the module files, and I assume there must be something similar for this.
I've tried putting entries into "source_dirs", "include_dirs", and "mod_dirs" in the .fortls file at the root of the project, but it doesn't seem to work.
@Koushikphy Thanks for the report and sorry for the delay. Unfortunately, the Fortran language server that is used to drive this extension does not parse *.mod
files and must have the actual source files to provide autocomplete and other features for a given library. Sorry for the inconvenience.
I have plans to add support for "external library" index files in the future that would function similar to the intrinsic functions in the current extension. I am not sure when I will have time to complete this but I would plan to create indices for common HPC libraries (eg. MPI, BLAS/LAPACK) when I do.
In the meantime it would be a good idea to add a known_modules
setting though that can eliminate diagnostic warnings/errors for known library modules/use statements. I will work on that.
@dvincentwest If you have access to all of the source files you should be able to include them using the ext_source_dirs
setting in .fortls
. Note that you can only use source_dirs
if the directories are in the directory tree for the current project. Also, keep in mind that in both cases directories are not traversed recursively so you will need to add all sub-directories manually.
FYI in vscode I'm currently using "fortran.linterExtraArgs": ["-I",<mpi.mod location>]
. And it just throws a info "Module "mpi" not found in project".
@hansec when you have a moment, I wonder if you can take a peak at this simple project setup:
https://github.com/dvincentwest/fortls_test
there are two png files in the root directory showing screenshots of the VSCode linting of the src/main.f90 file.
Perhaps you can take a look at the .fortls file and tell me what I'm doing wrong, but although VSCode is able to view the function sub1_add, and pop up a handy signature for me to see, it tells me that it cannot find sub1.mod.
I am using a fresh install of the latest VSCode on MacOSX catalina. Python 3.8 with a pip install of fortran-language-server just today.