Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'elseif' or 'else if' in Fortran

Tags:

syntax

fortran

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.

like image 860
hveng Avatar asked Aug 17 '20 12:08

hveng


1 Answers

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

Copy of Table 6.2

like image 184
francescalus Avatar answered Sep 30 '22 00:09

francescalus