hansec / fortran-language-server

Fortran Language Server for the Language Server Protocol
MIT License
294 stars 57 forks source link

Need some help,Coarrays disabled at (1), use '-fcoarray=' to enable #214

Closed syf1913 closed 2 years ago

syf1913 commented 2 years ago

Hello, hope you're good.

I just started using fls, which is very awesome! Here is my problem. I have a main402.f file such as:

     subroutine nonstad_main(irank)

      character*40 filena,str40
c
         include 'commons.std'
c
         parameter (ippp=101)
         real*8   prop_D(ippp,10)
         integer   nmprop [allocatable] (:) ! here's error
         integer     nloc [allocatable] (:)
c

It gives me Coarrays disabled at (1), use '-fcoarray=' to enable. Although I get the above error when I use fls , I can successfully compile the code. I'm not experienced enough to understand what the problem is, could someone kindly help me?

gnikit commented 2 years ago

how are you using fortls as in through VS Code, Atom, vim...? I don't use coarrays so you might have to provide a MWE if you want us to replicate the error

syf1913 commented 2 years ago

Thank you for your reply! In VS code, but I don't think it's coarrays, it's just arrays defined in old FORTRAN 77-style.

gnikit commented 2 years ago

This is not related to fortls but with the input options of the VSCode extension. What is probably happening is your linter is complaining that it does not know how to mock-compile your code. If you are using the Modern Fortran extension then you need to input the relevant coarray arguments that you use during compilation as part of your linter extra arguments. For more help please close this issue and migrate it to https://github.com/krvajal/vscode-fortran-support/issues

gnikit commented 2 years ago

FYI the only errors fortls is capable of displaying in VSCode (or anywhere I think) are:

Multiple definitions with the same variable name Variable definition masks definition from parent scope Missing subroutine/function arguments Unknown user-defined type used in "TYPE"/"CLASS" definition (only if visible in project) Unclosed blocks/scopes Invalid scope nesting Unknown modules in "USE" statement Unimplemented deferred type-bound procedures Use of unimported variables/objects in interface blocks Statement placement errors ("CONTAINS", "IMPLICIT", "IMPORT")

The rest is done by the VSCode extension through a -fsyntax-only call to gfortran

gnikit commented 2 years ago

@syf1913 sorry I completely missed the

I don't think it's coarrays

part of your answer. If you are still having problems please move the issue to the extension repo.

syf1913 commented 2 years ago

ok, I see, thank you very much for your patience to answer my questions. I will figure it out .

Thanks again!

jaksoner commented 2 years ago

have you solved this problem?

gnikit commented 2 years ago

This is a linter error i.e. from VS Code's Modern Fortran (or whatever editor and linter you are using) not fortls. Either way, the problem is unrelated to this repo (fortran-language-server)

jaksoner commented 2 years ago

Thank you for your reply! but I used gfortran in Ubuntu and found the same problem. I can't solve this problem o(╥﹏╥)o. show

syf1913 commented 2 years ago

I think you are going in the wrong direction on this issue. From your picture, I think it's your code that has a problem, not fortran-language-server

gnikit commented 2 years ago

Thank you for your reply! but I used gfortran in Ubuntu and found the same problem. I can't solve this problem o(╥﹏╥)o. show

First search result will land you on this SO post: https://stackoverflow.com/questions/67545509/coarrays-disabled-use-fcoarrays which tells you that you need to pass a flag to your compiler.

You then you need to read the instructions of the VS Code extension, specifically: https://github.com/fortran-lang/vscode-fortran-support#additional-linting-options and pass something like -fcoarray=single.

Again, this is completely unrelated to this repository.

jaksoner commented 2 years ago

Thank you for your patient reply!