Sorry to be bombarding everyone with questions but the responses I have had so far have been absolutely fascinating (I am STILL working through the COMMON responses; I love it when a topic becomes a discussion on other finer points).
My question this time is about the use of if
statements.
The code I have has a number of single if
statement lines:
if (Jsub .gt. 0) call sub(Jsub)
In most cases these contribute to easy-to-read code. Yet sometimes it leads to a mess (when the test itself is complex).
Equally, I have a single if
statement where it’s test is incredibly long…
if (line(1:1) .ne. 'c' .and. line(1:1) .ne. 'C' &
& .and. line .ne. oldline(linecount)) then
write (lunit, '(a)') line
end if
In the case of the single-line example, where the code gets difficult to read, I am converting these to…
if (Jsub .gt. 0) then
call sub(Jsub)
end if
(I wouldn’t - haven’t - in this particular case, since it is easy to read; but it acts as an example).
And in the case of the multi-line test, I am thinking of resorting to nested if
statements…
if (line(1:1) .ne. 'c' .and. line(1:1) .ne. 'C') then
if *line .ne. oldline(linecount))) then
write (lunit, '(a)') line
end if
end if
The thing is, would these have significant impact upon processing speed, once compiled?
I can’t see how the first one would (I am sure it would compile to the same) and I believe it is the same for the latter example, but wondered if anyone had experience of this?
Thanks in advance.