0

I have a Fortran subroutine Sample. I call it inside another program. I am looking for a way to call it with a character variable, not like call sample() but like the following

Program calculate
  character(97) :: ii='Sample'
  call ii() ! So it call Sample subroutine
End program

Subroutine Sample
  print 'something'
End Subroutine Sample
francescalus
  • 30,576
  • 16
  • 61
  • 96
  • Possible duplicate of [How to alias a function name in Fortran](https://stackoverflow.com/questions/8612466/how-to-alias-a-function-name-in-fortran) – francescalus Jul 25 '17 at 16:29
  • Procedure pointers or just `select case()`. Not sure if exact duplicate. (I had to reopen some recently so I am more careful.) – Vladimir F Героям слава Jul 25 '17 at 19:26
  • thanks dear. I found a solution after your guide. `module test contains subroutine test1(argi,hello) integer :: argi external :: shabi arg=5 call hello(argi) end subroutine test1 subroutine test2(argg) integer :: argg print*,'value through test1 to test2:', argg end subroutine test2 end module test program test_func_ptrs use test implicit none
    call test1(5,test2) end program test_func_ptrs`
    – Shahbaz Ahmed Jul 25 '17 at 21:10
  • you should post your solution as an answer – agentp Jul 26 '17 at 12:13

0 Answers0