Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Help with using fortls (in vscode) #173

Open
mathomp4 opened this issue Sep 9, 2020 · 4 comments
Open

Help with using fortls (in vscode) #173

mathomp4 opened this issue Sep 9, 2020 · 4 comments
Labels

Comments

@mathomp4
Copy link

mathomp4 commented Sep 9, 2020

All,

I decided to try out VSCode with fortls today and when I tried it on my code, I got this from the VSCode...uh...bottom terminal/problems/debug thing? Not sure what it's called, but this was in the Output tab:

[Error - 7:14:34 PM] Server initialization failed.
  Message: Error sending result: '(<fortls.parse_fortran.fortran_file object at 0x1088bd4c0>, None)'. Reason: 'RecursionError('maximum recursion depth exceeded while pickling an object')'
  Code: -32603 
[object Object]

I did see #100 which seems to be like what this is, but #100 is closed so I'm not sure. Any ideas on what I might be doing wrong? I'm new to even VSCode so any help is nice (perhaps this is in the wrong repo?).

@JHenneberg
Copy link
Contributor

Hey,

Can you give a minimal example?

@mathomp4
Copy link
Author

mathomp4 commented Sep 12, 2020

@JHenneberg Well, if I clone one of the projects I work on:

git clone https://github.com/GEOS-ESM/MAPL.git

and then open that folder in Code and then open, say, base/MAPL_Base.F90, I get:

[Error - 2:48:14 PM] Server initialization failed.
  Message: Error sending result: '(<fortls.parse_fortran.fortran_file object at 0x10a08c940>, None)'. Reason: 'RecursionError('maximum recursion depth exceeded while pickling an object')'
  Code: -32603 
[object Object]

@JHenneberg
Copy link
Contributor

JHenneberg commented Sep 13, 2020

for now I can confirm I am getting the same error so it is not your specific machine. I would guess it is a problem with the precompiler includes which are causing a circular structure.

Edit:

When you add a .fortls for example like this to your main folder it works

{
  "source_dirs": ["base", "include", "tests", "shared"],
  "pp_suffixes": [".H", ".h"],
  "debug_log": false
}

@hansec
Copy link
Owner

hansec commented Oct 14, 2020

Hi @mathomp4, thanks for the report. I have been able to track down the issue, which appears to be related to handling the macros in base/MAPL_EsmfRegridder.F90. In particular, there is a problem with the handling of semi-colons in the inline if statements. For the _VERIFY macro for example, which is defined as

#define _VERIFY(A)   if(  A/=0) then; if(present(rc)) rc=A; PRINT *, Iam, __LINE__; return; endif

we can expand it on multiple lines as

if(  A/=0) then
  if(present(rc)) rc=A; PRINT *, Iam, __LINE__; return
endif

and that middle inline if statement is tripping things up since currently the parser crudely treats semi-colons by inserting line breaks. I will try work on better handling of semi-colons, which should fix this. If you want a quick fix in the meantime you can replace these macros with all "then" and "endif" closed if statements. For example the _VERIFY macro would become

#define _VERIFY(A)   if(  A/=0) then; if(present(rc)) then rc=A; PRINT *, Iam, __LINE__; return; endif; endif

Obviously, the solution to "change your code" isn't great when it is working fine but figured I'd let you know as a quick workaround. You can also exclude the file base/MAPL_EsmfRegridder.F90 from parsing, but of course that has disadvantages as well.

@hansec hansec added the bug label Oct 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants