dimanche 17 mai 2020

How to avoid repeated checking of an if-statement when the condition to be checked is deallocated within the if-block?

I have a fortran code using a derived type as follows:

if(type%value(1).LT.0D0 OR type%value(1).GT.1D0) then
  if(type%value(1).LT.0D0) then 
    do something
  end if
  deallocate(type%value)
end if

In this scenario the statement type%value(1).LT.0D0 is checked twice. Is there a way to avoid this? More generally, is there a better approach to validate this?

Aucun commentaire:

Enregistrer un commentaire