I have a subroutine which contains a simple if-statement right in the middle which I would like to get rid of. The reason being that I know in advance if that statement will be true or false based on where the call occurs and not based on the input data. This is even more attractive since it is a 1-liner if that really does not do too much.
Right now there is an extra logical input which is purely for that if statement and it is called twice - once with "false" and once with "true".
Essentially, I want to make the if-statement work out during compilation, but an #ifdef will not allow for two different usages/configurations of the same subroutine.
The dumb solution would be to copy the subroutine completely and have one instance with the "true" segment while the other with the "false" segment only.
However, besides this being far from elegant (and have 99.9% similarity), this is an opening for trouble, once the subroutine is changed in the future.
I will note that I do not mean overloading the subroutine (at least not in the "traditional" sense of it), although this is sort of the same general idea.
So my question is - is there a solution to this situation or I will have to leave it as a run-time if statement and have an additional logical true/false input?
I'm using Fortran 90/95.