Within some legacy Fortran 77
subroutines I was using the continuation mark &
in position 6 and few cpp
directives to adjust I/O
at compile time - depending on very few parameters - to avoid redundancy. Look at a simpler example, here below:
open(unit=1,file=opfile,status="unknown",form="unformatted")
!
read(1) a, b, c
!
#ifdef _READMORE
& ,d, e
#endif
!
close(1)
Now, after some f90
refactoring (basically, putting almost everything within modules
), I am struggling to reproduce the above mentioned behaviour, i.e. reading d
and e
if and only if _READMORE
is defined, since the first solution I tried - the one here below - does not work as expected, because of the unexpected &
at the end of the first line, if _READMORE
is not defined:
open(unit=1,file=opfile,status="unknown",form="unformatted")
!
read(1) a, b, c &
!
#ifdef _READMORE
,d, e
#endif
!
close(1)
Could anyone suggest me what would be the best way to accomplish this task?
It would be appreciable if the proposed solution still relies on this continuation line trick and preserves backward compatibility.