Minimum Reproducible Example
test_subroutine.f90
SUBROUTINE test_subroutine
PRINT *, "Call Result: SUCCESS"
END SUBROUTINE test_subroutine
test_program.f90
PROGRAM test_program
CALL test_subroutine
END PROGRAM test_program
Output
GFortran
We compile and execute this with GFortran using the below commands:
gfortran -c ./examples/test_subroutine.f90 -o ./examples/test_subroutine.o # compile subroutine to binary
gfortran -c ./examples/test_program.f90 -o ./examples/test_program.o # compile program to binary
gfortran -o ./examples/my_program ./examples/test_program.o ./examples/test_subroutine.o # link binaries
./examples/my_program # execute the program
The output is as expected:
(base) saurabh-kumar@Awadh:~/Projects/System/lfortran$ ./examples/my_program
Call Result: SUCCESS
LFortran
LFortran compiles the subroutine file successfully, but fails to compile the program file.
(base) saurabh-kumar@Awadh:~/Projects/System/lfortran$ lfortran -c ./examples/test_subroutine.f90 -o ./examples/test_subroutine.o # compile subroutine to binary
(base) saurabh-kumar@Awadh:~/Projects/System/lfortran$ lfortran -c ./examples/test_program.f90 -o ./examples/test_program.o # compile program to binary
semantic error: Function 'test_subroutine' not found or not implemented yet (if it is intrinsic)
--> ./examples/test_program.f90:2:4
|
2 | CALL test_subroutine
| ^^^^^^^^^^^^^^^^^^^^
Note: Please report unclear, confusing or incorrect messages as bugs at
https://github.com/lfortran/lfortran/issues.
This bug was caught when trying to compile the file snap_main.f90 which has a call to a subroutine translv contained in a file of it's own - translv.f90. I feel this is an important issue because separating subroutines into their own files is commonly observed in legacy code-bases.
Minimum Reproducible Example
Output
GFortran
We compile and execute this with GFortran using the below commands:
The output is as expected:
LFortran
LFortran compiles the subroutine file successfully, but fails to compile the program file.
This bug was caught when trying to compile the file
snap_main.f90which has a call to a subroutinetranslvcontained in a file of it's own -translv.f90. I feel this is an important issue because separating subroutines into their own files is commonly observed in legacy code-bases.