02.07.2013 Views

HP Fortran Programmer's Reference

HP Fortran Programmer's Reference

HP Fortran Programmer's Reference

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

INCLUDE line<br />

Language elements<br />

INCLUDE line<br />

The INCLUDE line is a directive to the compiler, not a <strong>Fortran</strong> 90 statement. It causes the<br />

compiler to insert text into a program before compilation. The inserted text is substituted for<br />

the INCLUDE line and becomes part of the compilable source text. The format of an INCLUDE<br />

line is:<br />

INCLUDE char-literal-const<br />

where char-literal-const is the name of a file containing the text to be included. The<br />

character literal constant must not have a kind parameter that is a named constant.<br />

If char-literal-const is only a filename (in other words, no pathname is specified), the<br />

compiler searches a user-specified path. You can use the -Idir option to tell the compiler<br />

wheretosearchforfilestobeincluded.<br />

The INCLUDE line must appear on one line with no other text except possibly a trailing<br />

comment. There must be no statement label. This means, for example, that it is not possible to<br />

branch to it, and it cannot be the action statement that is part of an IF statement. Putting a<br />

second INCLUDE or another <strong>Fortran</strong> 90 statement on the same line using a semicolon as a<br />

separator is not permitted. Continuing an INCLUDE line using an ampersand is also not<br />

permitted.<br />

The text of the included file must consist of complete <strong>Fortran</strong> 90 statements.<br />

INCLUDE lines may also be nested. That is, a second INCLUDE line may appear within the text<br />

to be included, and the text that it includes may also have an INCLUDE line,andsoon.<strong>HP</strong><br />

<strong>Fortran</strong> has a maximum INCLUDE line nesting level of 10. However, the text inclusion must<br />

not be recursive at any level; for example, included text A must not include text B if B<br />

includes text A.<br />

The following are example INCLUDE lines:<br />

INCLUDE ”MY_COMMON_BLOCKS”<br />

INCLUDE ”/usr/include/machine_parameters.h”<br />

In the next example, the INCLUDE line occurs in the executable part of a program and supplies<br />

the code that uses the input value from the preceding READ statement:<br />

READ *, theta<br />

INCLUDE ”FUNCTION_CALCULATION”<br />

Chapter 2 21

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!