If your conditions really are all equality with some integer, then select case will be a slightly better construct.
The reality is that this selection will have to occur somewhere, it’s a matter of in what form and where you want to put it. If you really will always call do_something, I’d lean towards having that call outside the conditional construct. So something like
procedure(sub_interface), pointer :: selected_sub
select case (option)
case (1)
selected_sub => mysub1
case (2)
selected_sub => mysub2
...
end select
call do_something(...,selected_sub,...)
In fact, I would probably put the select case block in its own procedure, so you can do selected_sub => select_sub(option)
Thanks for these solutions. To provide some context, this is related to a problem in simulating beam dynamics in particle accelerators. When I wrote “call do_something” I was referring to calling a subroutine that does numerical integration of particle trajectories. The details of the equations can vary significantly depending on a particle’s location in the accelerator. Basically, I want to pass as an argument the appropriate subroutine depending on a particle’s location. I could of course just make a huge subroutine, containing a select case, for evaluating the right hand side of the equations of motion. But that would be a huge mess. If I associate an integer with each type beamline element (i.e., each magnet), then the choice of what subroutine to pass can be made depending on that integer.