FrankMonkey
Systems Engineer
Hello all,
I need to do the following in Fortran 90.
I have two subroutines that perform similar tasks, lets call them subroutine ALPHA and subroutine BRAVO. Lets say they have SAME dummy argument list, same sequence ranks, same kinds to all args.
So.. SUBROUTINE ALPHA(dummy_arg1,dummy_arg2,...)
SUBROUTINE BRAVO(dummy_arg1,dummy_arg2,...)
They are called from a MAIN program like so.
CALL ALPHA(arg_1,arg2,...) etc...
What I need to do is to make ONE call from the main and to make the switch between calling ALPHA or BRAVO depending on some logic in the main.
What I DO NOT WANT TO DO is the following
SELECT CASE(TEST)
CASE(1)
CALL ALPHA(arg1,arg2,...)
CASE(2)
CALL BRAVO(arg1,arg2,...)
END SELECT
or similar with an IF-ELSE-ENDIF
I want a single (ONE) subroutine call from the MAIN which will access either ALPHA or BRAVO depending on the logic in main, but again with a SINGLE call.
I understand this CAN be done with polymorphism / dynamic dispatch. Fortran 95 and beyond can do it relatively easily but it's much more complicated with earlier versions and I MUST basically use Fortran 90.
I've racked my brain and coded and just can't get this to work.
Anyone know how to do this???
Regards,
Frank
I need to do the following in Fortran 90.
I have two subroutines that perform similar tasks, lets call them subroutine ALPHA and subroutine BRAVO. Lets say they have SAME dummy argument list, same sequence ranks, same kinds to all args.
So.. SUBROUTINE ALPHA(dummy_arg1,dummy_arg2,...)
SUBROUTINE BRAVO(dummy_arg1,dummy_arg2,...)
They are called from a MAIN program like so.
CALL ALPHA(arg_1,arg2,...) etc...
What I need to do is to make ONE call from the main and to make the switch between calling ALPHA or BRAVO depending on some logic in the main.
What I DO NOT WANT TO DO is the following
SELECT CASE(TEST)
CASE(1)
CALL ALPHA(arg1,arg2,...)
CASE(2)
CALL BRAVO(arg1,arg2,...)
END SELECT
or similar with an IF-ELSE-ENDIF
I want a single (ONE) subroutine call from the MAIN which will access either ALPHA or BRAVO depending on the logic in main, but again with a SINGLE call.
I understand this CAN be done with polymorphism / dynamic dispatch. Fortran 95 and beyond can do it relatively easily but it's much more complicated with earlier versions and I MUST basically use Fortran 90.
I've racked my brain and coded and just can't get this to work.
Anyone know how to do this???
Regards,
Frank