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

Bigger project (SNAP) fails #35

Closed
certik opened this issue Dec 19, 2024 · 11 comments
Closed

Bigger project (SNAP) fails #35

certik opened this issue Dec 19, 2024 · 11 comments
Labels
bug Something isn't working

Comments

@certik
Copy link
Contributor

certik commented Dec 19, 2024

I did:

            git clone https://github.com/certik/SNAP.git
            cd SNAP          
                  
            git checkout lf11
            git checkout 169a9216f2c922e94065a519efbb0a6c8b55149e
            cd ./src              
            make -j8 FORTRAN=lfortran FFLAGS= MPI=no OPENMP=no
            ./gsnap ../qasnap/sample/inp out

This works.

Then I opened src/snap_main.f90 in VSCode and it would not show any symbols. No error is shown (#34, #33).

LFortran clearly knows how to parse it, even fully compile this project. But the LSP somehow doesn't work, we need to debug it, it's either a bug in LFortran or in lfortran-lsp or both.

@certik certik added the bug Something isn't working label Dec 19, 2024
@Pranavchiku
Copy link
Member

Pranavchiku commented Dec 19, 2024

It fails because LFortran is unable to locate *.mod files in the directory you are present i.e. root of project. If you do % cp src/*.mod ./ then it will work. Let me check on extension. Even on extension, it just works the moment we copy mod files to root directory.

image
(lf) pranavchiku@pranavchikus-MacBook-Air:~/repos/SNAP((HEAD detached at 169a921)) % lfortran src/snap_main.f90 --continue-compilation
semantic error: Module 'global_module' not declared in the current source and the modfile was not found
  --> src/snap_main.f90:81:3
   |
81 |   USE global_module, ONLY: i_knd, r_knd, ifile, ofile, iunit, ounit, one
   |   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 

semantic error: Module 'utils_module' not declared in the current source and the modfile was not found
  --> src/snap_main.f90:83:3
   |
83 |   USE utils_module
   |   ^^^^^^^^^^^^^^^^ 

semantic error: Module 'version_module' not declared in the current source and the modfile was not found
  --> src/snap_main.f90:85:3
   |
85 |   USE version_module, ONLY: version_print
   |   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 

semantic error: Module 'input_module' not declared in the current source and the modfile was not found
  --> src/snap_main.f90:87:3
   |
87 |   USE input_module, ONLY: input_read
   |   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 

semantic error: Module 'setup_module' not declared in the current source and the modfile was not found
  --> src/snap_main.f90:89:3
   |
89 |   USE setup_module, ONLY: setup
   |   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 

semantic error: Module 'output_module' not declared in the current source and the modfile was not found
  --> src/snap_main.f90:91:3
   |
91 |   USE output_module, ONLY: output
   |   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 

semantic error: Module 'time_module' not declared in the current source and the modfile was not found
  --> src/snap_main.f90:93:3
   |
93 |   USE time_module, ONLY: tsnap, wtime, tparset, time_summ, tgrind
   |   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 

semantic error: Module 'dealloc_module' not declared in the current source and the modfile was not found
  --> src/snap_main.f90:95:3
   |
95 |   USE dealloc_module
   |   ^^^^^^^^^^^^^^^^^^ 

semantic error: Module 'plib_module' not declared in the current source and the modfile was not found
  --> src/snap_main.f90:97:3 - 98:24
   |
97 |      USE plib_module, ONLY: pinit, iproc, root, comm_snap, bcast,         &
   |      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^...
...
   |
98 |        pcomm_set, pinit_omp
   | ...^^^^^^^^^^^^^^^^^^^^^^^^ 

semantic error: Module 'control_module' not declared in the current source and the modfile was not found
   --> src/snap_main.f90:100:3
    |
100 |   USE control_module, ONLY: otrdone, swp_typ
    |   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 

semantic error: Module 'translv_module' not declared in the current source and the modfile was not found
   --> src/snap_main.f90:102:3
    |
102 |   USE translv_module, ONLY: translv
    |   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 

semantic error: Variable 'i_knd' is not declared
   --> src/snap_main.f90:114:11
    |
114 |   INTEGER(i_knd) :: ierr, i, ndpwds
    |           ^^^^^ 'i_knd' is undeclared

semantic error: Variable 'r_knd' is not declared
   --> src/snap_main.f90:116:8
    |
116 |   REAL(r_knd) :: t1, t2, t3, t4, t5
    |        ^^^^^ 'r_knd' is undeclared

semantic error: Variable 'ierr' is not declared
   --> src/snap_main.f90:123:3
    |
123 |   ierr = 0
    |   ^^^^ 'ierr' is undeclared

semantic error: Variable 'ndpwds' is not declared
   --> src/snap_main.f90:124:3
    |
124 |   ndpwds = 0
    |   ^^^^^^ 'ndpwds' is undeclared

semantic error: Function 'pinit' not found (not user defined nor intrinsic)
   --> src/snap_main.f90:127:3
    |
127 |   CALL pinit ( t1 )
    |   ^^^^^^^^^^^^^^^^^ 

semantic error: Function 'wtime' not found (not user defined nor intrinsic)
   --> src/snap_main.f90:129:3
    |
129 |   CALL wtime ( t2 )
    |   ^^^^^^^^^^^^^^^^^ 

semantic error: Variable 'tparset' is not declared
   --> src/snap_main.f90:130:3
    |
130 |   tparset = tparset + t2 - t1
    |   ^^^^^^^ 'tparset' is undeclared

semantic error: Function 'cmdarg' not found (not user defined nor intrinsic)
   --> src/snap_main.f90:137:3
    |
137 |   CALL cmdarg ( ierr, error )
    |   ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 

semantic error: Function 'bcast' not found (not user defined nor intrinsic)
   --> src/snap_main.f90:138:3
    |
138 |   CALL bcast ( ierr, comm_snap, root )
    |   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 

semantic error: Variable 'ierr' is not declared
   --> src/snap_main.f90:139:8
    |
139 |   IF ( ierr /= 0 ) THEN
    |        ^^^^ 'ierr' is undeclared

semantic error: Function 'open_file' not found (not user defined nor intrinsic)
   --> src/snap_main.f90:144:3
    |
144 |   CALL open_file ( iunit, ifile, 'OLD', 'READ', ierr, error )
    |   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 

semantic error: Function 'bcast' not found (not user defined nor intrinsic)
   --> src/snap_main.f90:145:3
    |
145 |   CALL bcast ( ierr, comm_snap, root )
    |   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 

semantic error: Variable 'ierr' is not declared
   --> src/snap_main.f90:146:8
    |
146 |   IF ( ierr /= 0 ) THEN
    |        ^^^^ 'ierr' is undeclared

semantic error: Function 'open_file' not found (not user defined nor intrinsic)
   --> src/snap_main.f90:151:3
    |
151 |   CALL open_file ( ounit, ofile, 'REPLACE', 'WRITE', ierr, error )
    |   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 

semantic error: Function 'bcast' not found (not user defined nor intrinsic)
   --> src/snap_main.f90:152:3
    |
152 |   CALL bcast ( ierr, comm_snap, root )
    |   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 

semantic error: Variable 'ierr' is not declared
   --> src/snap_main.f90:153:8
    |
153 |   IF ( ierr /= 0 ) THEN
    |        ^^^^ 'ierr' is undeclared

semantic error: Variable 'iproc' is not declared
   --> src/snap_main.f90:162:8
    |
162 |   IF ( iproc == root ) CALL version_print
    |        ^^^^^ 'iproc' is undeclared

semantic error: Function 'input_read' not found (not user defined nor intrinsic)
   --> src/snap_main.f90:168:3
    |
168 |   CALL input_read
    |   ^^^^^^^^^^^^^^^ 

semantic error: Function 'close_file' not found (not user defined nor intrinsic)
   --> src/snap_main.f90:170:3
    |
170 |   CALL close_file ( iunit, ierr, error )
    |   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 

semantic error: Function 'bcast' not found (not user defined nor intrinsic)
   --> src/snap_main.f90:171:3
    |
171 |   CALL bcast ( ierr, comm_snap, root )
    |   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 

semantic error: Variable 'ierr' is not declared
   --> src/snap_main.f90:172:8
    |
172 |   IF ( ierr /= 0 ) THEN
    |        ^^^^ 'ierr' is undeclared

semantic error: Function 'wtime' not found (not user defined nor intrinsic)
   --> src/snap_main.f90:182:3
    |
182 |   CALL wtime ( t3 )
    |   ^^^^^^^^^^^^^^^^^ 

semantic error: Function 'pinit_omp' not found (not user defined nor intrinsic)
   --> src/snap_main.f90:184:3
    |
184 |   CALL pinit_omp ( ierr, error )
    |   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 

semantic error: Variable 'ierr' is not declared
   --> src/snap_main.f90:185:8
    |
185 |   IF ( ierr /= 0 ) CALL print_error ( 0, error )
    |        ^^^^ 'ierr' is undeclared

semantic error: Function 'pcomm_set' not found (not user defined nor intrinsic)
   --> src/snap_main.f90:187:3
    |
187 |   CALL pcomm_set
    |   ^^^^^^^^^^^^^^ 

semantic error: Function 'wtime' not found (not user defined nor intrinsic)
   --> src/snap_main.f90:189:3
    |
189 |   CALL wtime ( t4 )
    |   ^^^^^^^^^^^^^^^^^ 

semantic error: Variable 'tparset' is not declared
   --> src/snap_main.f90:190:3
    |
190 |   tparset = tparset + t4 - t3
    |   ^^^^^^^ 'tparset' is undeclared

semantic error: Function 'setup' not found (not user defined nor intrinsic)
   --> src/snap_main.f90:196:3
    |
196 |   CALL setup ( ndpwds )
    |   ^^^^^^^^^^^^^^^^^^^^^ 

semantic error: Function 'translv' not found (not user defined nor intrinsic)
   --> src/snap_main.f90:202:3
    |
202 |   CALL translv ( ndpwds )
    |   ^^^^^^^^^^^^^^^^^^^^^^^ 

semantic error: Function 'output' not found (not user defined nor intrinsic)
   --> src/snap_main.f90:208:3
    |
208 |   CALL output
    |   ^^^^^^^^^^^ 

semantic error: Variable 'iproc' is not declared
   --> src/snap_main.f90:209:8
    |
209 |   IF ( iproc == root ) CALL time_summ
    |        ^^^^^ 'iproc' is undeclared

semantic error: Function 'dealloc_input' not found (not user defined nor intrinsic)
   --> src/snap_main.f90:215:3
    |
215 |   CALL dealloc_input ( 4 )
    |   ^^^^^^^^^^^^^^^^^^^^^^^^ 

semantic error: Function 'dealloc_solve' not found (not user defined nor intrinsic)
   --> src/snap_main.f90:216:3
    |
216 |   CALL dealloc_solve ( swp_typ, 2 )
    |   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 

semantic error: Function 'wtime' not found (not user defined nor intrinsic)
   --> src/snap_main.f90:218:3
    |
218 |   CALL wtime ( t5 )
    |   ^^^^^^^^^^^^^^^^^ 

semantic error: Variable 'tsnap' is not declared
   --> src/snap_main.f90:219:3
    |
219 |   tsnap = t5 - t1
    |   ^^^^^ 'tsnap' is undeclared

semantic error: Variable 'iproc' is not declared
   --> src/snap_main.f90:221:8
    |
221 |   IF ( iproc == root ) THEN
    |        ^^^^^ 'iproc' is undeclared

semantic error: Function 'close_file' not found (not user defined nor intrinsic)
   --> src/snap_main.f90:229:3
    |
229 |   CALL close_file ( ounit, ierr, error )
    |   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 

semantic error: Function 'bcast' not found (not user defined nor intrinsic)
   --> src/snap_main.f90:230:3
    |
230 |   CALL bcast ( ierr, comm_snap, root )
    |   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 

semantic error: Variable 'ierr' is not declared
   --> src/snap_main.f90:231:8
    |
231 |   IF ( ierr /= 0 ) THEN
    |        ^^^^ 'ierr' is undeclared

semantic error: Variable 'otrdone' is not declared
   --> src/snap_main.f90:236:8
    |
236 |   IF ( otrdone ) THEN
    |        ^^^^^^^ 'otrdone' is undeclared


Note: Please report unclear, confusing or incorrect messages as bugs at
https://github.com/lfortran/lfortran/issues.

@certik
Copy link
Contributor Author

certik commented Dec 23, 2024

The extension gets stuck on the main program in SNAP:

image

It's stuck on "loading". It's not clear from the log what it is doing. Update: I created an MRE for this here: #50.

This works: lfortran --show-document-symbols --continue-compilation snap_main.f90.

@certik
Copy link
Contributor Author

certik commented Dec 23, 2024

If I open up a different file sn.f90, and ensure the main program is not loaded, then the outline loads. But symbols cannot be looked up:

image

It looks like the location information is incorrect.

@certik
Copy link
Contributor Author

certik commented Dec 23, 2024

Clicking on a module and "go to definition" should open up the module source file.

@certik
Copy link
Contributor Author

certik commented Dec 23, 2024

P.S. I found that if I open VSCode in the src directory, then it will automatically find the .mod files, so don't need any special options.

@Pranavchiku
Copy link
Member

Clicking on a module and "go to definition" should open up the module source file.

Yes, this is yet to be done. @dylon you'll be doing this?

@certik
Copy link
Contributor Author

certik commented Dec 24, 2024

Let's get all the above issues fixed in this small MRE first: #50, once that fully works, we'll test SNAP again and see.

Also we need to fix #52, which will make SNAP "working" even if we can't find the .mod files.

@certik certik changed the title Bigger project fails Bigger project (SNAP) fails Dec 26, 2024
@certik
Copy link
Contributor Author

certik commented Dec 26, 2024

Current status:

image

You have to start code in the src directory, then things work, it shows a list of symbols, and you can click on the symbols and they seem correct. However, I randomly clicked on a variable and it can't find a definition, as seen on the above screenshot.

@Pranavchiku
Copy link
Member

MRE: lfortran/lfortran#5829

MODULE sn_module

REAL, ALLOCATABLE, DIMENSION(:,:,:) :: ec

CONTAINS

SUBROUTINE sn_expcoeff ( ndimen )
  INTEGER, INTENT(IN) :: ndimen
  ec(:,1,5) = 1.0
END SUBROUTINE sn_expcoeff


END MODULE sn_module

@Pranavchiku
Copy link
Member

Pranavchiku commented Dec 26, 2024

lfortran/lfortran#5833

module time_module_xx
  IMPLICIT NONE
  PUBLIC
  REAL :: tparset_ = 0.0
  REAL :: wtime_ = 0.0
END module time_module_xx


module plib_module_xx
use time_module_xx, only: wtime_
PUBLIC
INTEGER :: iproc = 0
INTEGER :: root = 0
INTEGER :: pinit = 0
INTEGER :: pcomm_set = 0
end module

PROGRAM snap_main
  USE time_module_xx, ONLY: tparset_

  USE plib_module_xx, ONLY: pinit,         &
    pcomm_set
  tparset_ = tparset_ + 1.0
END PROGRAM snap_main
% lfortran a.f90 --line=23 --column=17 --lookup-name
[]

If I use the following diff it works:

diff --git a/a.f90 b/a.f90
index a8a3493a2..0e060bda8 100644
--- a/a.f90
+++ b/a.f90
@@ -18,7 +18,6 @@ end module
 PROGRAM snap_main
   USE time_module_xx, ONLY: tparset_
 
-  USE plib_module_xx, ONLY: pinit,         &
-pcomm_set
+  USE plib_module_xx, ONLY: pinit, pcomm_set
   tparset_ = tparset_ + 1.0
 END PROGRAM snap_main

@certik
Copy link
Contributor Author

certik commented Dec 28, 2024

It now mostly works! You can lookup definitions and they are often correct. Not always, I discovered a few bugs: #61, #62. But I think the main issue is now fixed and it mostly works, now it's just fixing individual bugs.

@certik certik closed this as completed Dec 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants