In fortran, in a single line, I want to execute two commands after an if, like shown below.
if (.true.) err = 'my error message' AND return
Is this possible? Using an if (.true.) then ... takes 4 whole lines!
In fortran, in a single line, I want to execute two commands after an if, like shown below.
if (.true.) err = 'my error message' AND return
Is this possible? Using an if (.true.) then ... takes 4 whole lines!
An IF statement is designed and specified specifically to conditionally execute a single (action) statement.
IF statements are not unique in rejected "joined statements"; nowhere in Fortran, unlike some other languages, is it possible to perform multiple statements as though they are one. (Some statements can be rewritten so that their combined effects can be accomplished in a single statement.)
An IF construct is precisely for the case of an executable block of one or more statements. And a wider variety of activities can be performed in an IF construct which isn't restricted to executing action statements.
To reflect what has been commented so far by others: