A line is a horizontal arrangement of characters. By contrast, a column is a vertical arrangement of characters, where each character, or each byte of a multibyte character, in a given column shares the same line position.
+-------------------------------IBM Extension--------------------------------+
Because XL Fortran measures lines in bytes, these definitions apply only to lines containing single-byte characters. Each byte of a multibyte character occupies one column.
+----------------------------End of IBM Extension----------------------------+
Initial Line | Is the first line of a statement. |
Continuation Line | Continues a statement beyond its initial line. |
Comment Line | Does not affect the executable program and can be used for
documentation. The comment text continues to the end of a line.
Although comment lines can follow one another, a comment line cannot be
continued. A line of all white space or a zero-length line is a comment
line without any text. Comment text can contain any characters allowed
in a character context.
If an initial line or continuation line is not continued, or if it is continued but not in a character context, an inline comment can be placed on the same line, to the right of any statement label, statement text, and continuation character that may be present. An exclamation mark (!) begins an inline comment. |
* Conditional Compilation Line | Indicates that the line should only be compiled if recognition of conditional compilation lines is enabled. A conditional compilation sentinel should appear on a conditional compilation line. (See Conditional Compilation) * |
* Debug Line | Indicates that the line is for debugging code (for fixed source form only). In XL Fortran the letter D or X must be specified in column 1. (See Debug Lines) * |
* Directive Line | Provides instructions or information to the compiler in XL Fortran (see Chapter 11, Directives). * |
+-------------------------------IBM Extension--------------------------------+
In XL Fortran, source lines can be in fixed source form or free source form format. Use the SOURCEFORM directive to mix source formats within the same program unit. Fixed source form is the default when using the f77, fort77, xlf, xlf_r or xlf_r7 invocation commands. Fortran 90 free source form is the default when using the xlf90, xlf90_r, xlf90_r7, xlf95, xlf95_r or xlf95_r7 invocation commands.
See "Compiling an XL Fortran Program" in the User's Guide for details on invocation commands.
+----------------------------End of IBM Extension----------------------------+
+-------------------------------IBM Extension--------------------------------+
A fixed source form line is a sequence of 1 to 132 characters. The default line size (as stipulated in Fortran 95) is 72 characters, but can be changed in XL Fortran by using the -qfixed=right_margin compiler option (see the User's Guide).
+----------------------------End of IBM Extension----------------------------+
Columns beyond the right margin are not part of the line and can be used for identification, sequencing, or any other purpose.
Except within a character context, white space is insignificant; that is, you can imbed white space between and within lexical tokens, without affecting the way the compiler will treat them.
+-------------------------------IBM Extension--------------------------------+
Tab formatting means there is a tab character in columns 1 through 6 of an initial line in XL Fortran, which directs the compiler to interpret the next character as being in column 7.
+----------------------------End of IBM Extension----------------------------+
Requirements for lines and for items on those lines are:
+-------------------------------IBM Extension--------------------------------+
+----------------------------End of IBM Extension----------------------------+
+-------------------------------IBM Extension--------------------------------+
Column 1 can contain a D (signifying a debug line) in XL Fortran. Otherwise, these columns can contain any characters allowed in a character context; these characters are ignored.
+----------------------------End of IBM Extension----------------------------+
+-------------------------------IBM Extension--------------------------------+
+----------------------------End of IBM Extension----------------------------+
The Fortran standards limit the number of continuation lines to 19.
A semicolon (;) separates statements on a single source line, except when it appears in a character context, in a comment, or in columns 1 through 6. Two or more semicolon separators that are on the same line and are themselves separated by only white space or other semicolons are considered to be a single separator. A separator that is the last character on a line or before an inline comment is ignored. Statements following a semicolon on the same line cannot be labeled. Additional statements cannot follow a program unit END statement on the same line.
+-------------------------------IBM Extension--------------------------------+
A debug line, allowed only for fixed source form, contains source code used for debugging and is specified in XL Fortran by the letter D, or the letter X in column 1. The handling of debug lines depends on the -qdlines or the -qxlines compiler options:
If you continue a debugging statement on more than one line, every continuation line must have a D in column 1 and a continuation character. If the initial line is not a debugging line, you can designate any continuation lines as debug lines provided that the statement is syntactically correct, whether or not you specify the -qdlines or -qxlines compiler option.
+----------------------------End of IBM Extension----------------------------+
C Column Numbers: C 1 2 3 4 5 6 7 C23456789012345678901234567890123456789012345678901234567890123456789012 !IBM* SOURCEFORM (FIXED) CHARACTER ABC ; LOGICAL X ! 2 statements on 1 line DO 10 I=1,10 PRINT *,'this is the index',I ! with an inline comment 10 CONTINUE C CHARSTR="THIS IS A CONTINUED X CHARACTER STRING" ! There will be 38 blanks in the string between "CONTINUED" ! and "CHARACTER". You cannot have an inline comment on ! the initial line because it would be interpreted as part ! of CHARSTR (character context). 100 PRINT *, IERROR ! The following debug lines are compiled as source lines if ! you use -qdlines D IF (I.EQ.IDEBUG.AND. D + J.EQ.IDEBUG) WRITE(6,*) IERROR D IF (I.EQ. D + IDEBUG ) D + WRITE(6,*) INFO END
+-------------------------------IBM Extension--------------------------------+
XL Fortran allows any line length and number of continuation lines, so long as the number of characters does not exceed 6700.
+----------------------------End of IBM Extension----------------------------+
A free source form line can specify up to 132 characters on each line, with a maximum of 39 continuation lines for a statement.
Items can begin in any column of a line, subject to the following requirements for lines and items on those lines:
A semicolon separates statements on a single source line, except when it appears in a character context or in a comment. Two or more separators that are on the same line and are themselves separated by only white space or other semicolons are considered to be a single separator. A separator that is the last character on a line or before an inline comment is ignored. Additional statements cannot follow a program unit END statement on the same line.
White space must not appear within lexical tokens, except in a character context or in a format specification. White space can be inserted freely between tokens to improve readability, although it must separate names, constants, and labels from adjacent keywords, names, constants, and labels.
Certain adjacent keywords may require white space. The following
table lists keywords that require white space, and keywords for which white
space is optional.
Table 1. Keywords Where White Space is Optional
BLOCK DATA | END FUNCTION | END SUBROUTINE |
DOUBLE COMPLEX | END IF | END TYPE |
DOUBLE PRECISION | END INTERFACE | END UNION |
ELSE IF | END MAP | END WHERE |
END BLOCK DATA | END MODULE | GO TO |
END DO | END PROGRAM | IN OUT |
END FILE | END SELECT | SELECT CASE |
END FORALL | END STRUCTURE |
|
See Type Declaration for details about type_spec.
!IBM* SOURCEFORM (FREE(F90)) ! ! Column Numbers: ! 1 2 3 4 5 6 7 !23456789012345678901234567890123456789012345678901234567890123456789012 DO I=1,20 PRINT *,'this statement& & is continued' ; IF (I.LT.5) PRINT *, I ENDDO EN& &D ! A lexical token can be continued
+-------------------------------IBM Extension--------------------------------+
An IBM free source form line or statement is a sequence of up to 6700 characters. Items can begin in any column of a line, subject to the following requirements for lines and items on those lines:
If statement text on an initial line or continuation line is to be continued, a minus sign indicates continuation of the statement text on the next line. In a character context, if the rightmost character of the statement text to be continued is a minus sign, a second minus sign must be entered as a continuation character.
Except within a character context, white space is insignificant; that is, you can imbed white space between and within lexical tokens, without affecting the way the compiler will treat them.
!IBM* SOURCEFORM (FREE(IBM)) " " Column Numbers: " 1 2 3 4 5 6 7 "23456789012345678901234567890123456789012345678901234567890123456789012 DO I=1,10 PRINT *,'this is - the index',I ! There will be 14 blanks in the string ! between "is" and "the" END DO END
+----------------------------End of IBM Extension----------------------------+
+-------------------------------IBM Extension--------------------------------+
You can use sentinels to mark specific lines of an XL Fortran program for conditional compilation. This support allows you to port code that contains statements that are only valid or needed in an SMP environment to a non-SMP environment. You can do this by using conditional compilation lines or by using the _OPENMP C preprocessor macro.
The syntax for conditional compilation lines is as follows:
>>-cond_comp_sentinel--fortran_source_line--------------------->< |
The syntax rules for conditional compilation lines are very similar to the syntax rules for fixed source form and free source form lines. The rules are as follows:
A valid XL Fortran source line must follow the conditional compilation sentinel.
A conditional compilation line may contain the INCLUDE or EJECT noncomment directives.
A conditional compilation sentinel must not contain embedded white space.
A conditional compilation sentinel must not follow a source statement or directive on the same line.
If you are continuing a conditional compilation line, the conditional compilation sentinel must appear on at least one of the continuation lines or on the initial line.
You must specify the -qcclines compiler option for conditional compilation lines to be recognized. To disable recognition of conditional compilation lines, specify the -qnocclines compiler option. Specifying the -qsmp=omp compiler option enables the -qcclines option.
Trigger directives take precedence over conditional compilation sentinels. For example, if you specify the -qdirective='$' option, then lines that start with the trigger, such as !$, will be treated as comment directives, rather than conditional compilation lines.
Conditional compilation sentinels must start in column 1.
All of the rules for fixed source form line length, case sensitivity, white space, continuation, tab formatting, and columns apply. See Fixed Source Form for information. Note that when recognition of conditional compilation lines is enabled, the conditional compilation sentinel is replaced by two white spaces.
Conditional compilation sentinels may start in any column.
All of the rules for free source form line length, case sensitivity, white space, and continuation apply. See Free Source Form for information. Note that when recognition of conditional compilation lines is enabled, the conditional compilation sentinel is replaced by two white spaces.
Another way to conditionally include code, other than using conditional compilation lines, is to use the C preprocessor macro _OPENMP. This macro is defined when the C preprocessor is invoked and you specify the -qsmp=omp compiler option. See the section on passing Fortran files through the C preprocessor in the "Editing, Compiling, Linking, and Running XL Fortran Programs" chapter of the User's Guide for an example of using this macro.
In the following example, conditional compilation lines are used to hide OpenMP run-time routines. Code that calls OpenMP run-time routines cannot easily be compiled in a non-OpenMP environment without using conditional compilation. Since calls to the run-time routines are not directives, they cannot be hidden by the !$OMP trigger. If the code below is not compiled with the -qsmp=omp compiler option, the variable used to store the number of threads will be assigned the value of 8.
PROGRAM PAR_MAT_MUL IMPLICIT NONE INTEGER(KIND=8) ::I,J,NTHREADS INTEGER(KIND=8),PARAMETER ::N=60 INTEGER(KIND=8),DIMENSION(N,N) ::AI,BI,CI INTEGER(KIND=8) ::SUMI !$ INTEGER OMP_GET_NUM_THREADS COMMON/DATA/ AI,BI,CI !$OMP THREADPRIVATE (/DATA/) !$OMP PARALLEL FORALL(I=1:N,J=1:N) AI(I,J) = (I-N/2)**2+(J+N/2) FORALL(I=1:N,J=1:N) BI(I,J) = 3-((I/2)+(J-N/2)**2) !$OMP MASTER NTHREADS=8 !$ NTHREADS=OMP_GET_NUM_THREADS() !$OMP END MASTER !$OMP END PARALLEL !$OMP PARALLEL DEFAULT(PRIVATE),COPYIN(AI,BI),SHARED(NTHREADS) !$OMP DO DO I=1,NTHREADS CALL IMAT_MUL(SUMI) ENDDO !$OMP END DO !$OMP END PARALLEL END
+----------------------------End of IBM Extension----------------------------+