- #1
pilipili2021
- 5
- 0
- Homework Statement
- Coding by ifort
Try to call a uncertain name subroutine
- Relevant Equations
- NONE
Here is the code for example:
Then I compile it.
ifort main.F90
It seems no error. Then run it.
./a.outIt show that
fk
1
fk
2
forrtl: severe (174): SIGSEGV, segmentation fault occurred
Image PC Routine Line Source
a.out 000000000040492A Unknown Unknown Unknown
libpthread-2.31.s 00007F15A65153C0 Unknown Unknown Unknown
Unknown 00007FFFC18B82C0 Unknown Unknown Unknown
Surely there is something wrong when I call the subroutine fcn, which it should be named as B.
So, what should I do? what's wrong? Please let me know if any of you have any ideas or any comments.
thank you
Fortran:
PROGRAM main
CALL B()
CALL CaoB(B)
contains
subroutine B()
IMPLICIT NONE
write (*,*) 'fk'
end subroutine B
subroutine CaoB(fcn)
implicit none
INTERFACE
SUBROUTINE fcn()
IMPLICIT NONE
END SUBROUTINE fcn
END INTERFACE
write (*,*) '1'
call B()
write (*,*) '2'
call fcn()
write (*,*) '3'
end subroutine CaoB
END
ifort main.F90
It seems no error. Then run it.
./a.outIt show that
fk
1
fk
2
forrtl: severe (174): SIGSEGV, segmentation fault occurred
Image PC Routine Line Source
a.out 000000000040492A Unknown Unknown Unknown
libpthread-2.31.s 00007F15A65153C0 Unknown Unknown Unknown
Unknown 00007FFFC18B82C0 Unknown Unknown Unknown
Surely there is something wrong when I call the subroutine fcn, which it should be named as B.
So, what should I do? what's wrong? Please let me know if any of you have any ideas or any comments.
thank you