Is there any difference between elseif and else if in Fortran? Same goes for endif and end if or enddo and end do.
I found both options in a code I am working on and wondered if it makes any difference in Fortran; furthermore if one option is preferable over the other.
In the Fortran language there is no difference in meaning/syntax. else and if are keywords and in fixed-form source blanks are between keywords are insignificant; in free-form source blanks are significant in general and should be used to separate keywords except in a given list of adjoining keywords.
else if, end if, and end do are pairs where blanks are optional. The entire list is given in Table 6.2 of the current Fortran standard. end features in most but also notable are double precision, else where, go to, in out, and select case.
Local style guides may state a preference.
source: Fortran 2018 Standard

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With