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

Nonstandard forward reference to 'lk' is not allowed in the same specification part causes compilation errors #810

Closed
sscalpone opened this issue May 10, 2024 · 4 comments · Fixed by #812
Labels
bug Something isn't working

Comments

@sscalpone
Copy link

Description

There's some non-standard non-portable Fortran code at line 55569 of stdlib_linalg_lapack_s.fypp.

55569            logical(lk) :: lquery, upper
55570            integer(ilp) :: i, j, iinfo, lwmin, pn, pk, lk, ldt, ldw, lds2, lds1, ls2, ls1, lw, lt,&
55571                       tpos, wpos, s2pos, s1pos

Forward reference to 'lk' is not allowed in the same specification part. Some compilers will allow the use of 'lk' at line 55569 to reference the outer 'lk' and then from line 55570 onward use the 'lk' that is defined on line 55570.

Expected Behaviour

The code would compile. We see an error with XLF, NAG, and LLVM flang.

Version of stdlib

33559f5

Platform and Architecture

Linux

Additional Information

In the following subroutines, I changed the local declaration and all uses of 'lk' to 'llk' and things compiled fine.

stdlib_linalg_lapack_c.fypp:36510:           integer(ilp) :: i, j, iinfo, lwmin, pn, pk, lk, ldt, ldw, lds2, lds1, ls2, ls1, lw, lt,&
stdlib_linalg_lapack_d.fypp:57095:           integer(ilp) :: i, j, iinfo, lwmin, pn, pk, lk, ldt, ldw, lds2, lds1, ls2, ls1, lw, lt,&
stdlib_linalg_lapack_q.fypp:72920:           integer(ilp) :: i, j, iinfo, lwmin, pn, pk, lk, ldt, ldw, lds2, lds1, ls2, ls1, lw, lt,&
stdlib_linalg_lapack_s.fypp:55570:           integer(ilp) :: i, j, iinfo, lwmin, pn, pk, lk, ldt, ldw, lds2, lds1, ls2, ls1, lw, lt,&
stdlib_linalg_lapack_w.fypp:28871:           integer(ilp) :: i, j, iinfo, lwmin, pn, pk, lk, ldt, ldw, lds2, lds1, ls2, ls1, lw, lt,&
stdlib_linalg_lapack_z.fypp:36925:           integer(ilp) :: i, j, iinfo, lwmin, pn, pk, lk, ldt, ldw, lds2, lds1, ls2, ls1, lw, lt,&
@sscalpone sscalpone added the bug Something isn't working label May 10, 2024
@jvdp1
Copy link
Member

jvdp1 commented May 11, 2024

@perazz Any idea what could be the problem? (I never use these compilers)

@perazz
Copy link
Contributor

perazz commented May 11, 2024

Sorry, I had not seen this issue. There is a variable in LAPACK that's named lk which is the same name as the library's logical kind:

integer, parameter :: lk = kind(.true.)

One solution is to rename either variable. Probably the integer variables in LAPACK, as I guess the logical kind is used elsewhere in stdlib

@sscalpone
Copy link
Author

One solution is to rename either variable. Probably the integer variables in LAPACK, as I guess the logical kind is used elsewhere in stdlib

I renamed the local variable in six different files. This change allowed the files to compile.

@jvdp1
Copy link
Member

jvdp1 commented May 11, 2024

One solution is to rename either variable. Probably the integer variables in LAPACK, as I guess the logical kind is used elsewhere in stdlib

You could also "rename" inside the LAPACK module when importing it:

 use stdlib_kinds, only: stdlib_lk => lk, ...

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

Successfully merging a pull request may close this issue.

3 participants