02.07.2014 Views

Intel(R) Fortran Compiler for Linux* Systems User's Guide Volume I ...

Intel(R) Fortran Compiler for Linux* Systems User's Guide Volume I ...

Intel(R) Fortran Compiler for Linux* Systems User's Guide Volume I ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

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

<strong>Intel</strong>® <strong>Fortran</strong> <strong>Compiler</strong> <strong>for</strong> <strong>Linux*</strong> <strong>Systems</strong> <strong>User's</strong> <strong>Guide</strong>, <strong>Volume</strong> I: Building<br />

Applications<br />

DOUBLE PRECISION X, Y<br />

CHARS = MAKECHARS( X, Y )<br />

Corresponding C Routine<br />

void makechars ( result, length, x, y );<br />

char *result;<br />

int length;<br />

double *x, *y;<br />

{<br />

...program text, producing returnvalue...<br />

<strong>for</strong> (i = 0; i < length; i++ ) {<br />

result[i] = returnvalue[i];<br />

}<br />

}<br />

In the above example, the following restrictions and behaviors apply:<br />

• The function's length and result do not appear in the call statement; they<br />

are added by the compiler.<br />

• The called routine must copy the result string into the location specified by<br />

result; it must not copy more than length characters.<br />

• If fewer than length characters are returned, the return location should be<br />

padded on the right with blanks; <strong>Fortran</strong> does not use zeros to terminate<br />

strings.<br />

• The called procedure is type void.<br />

• You must use lowercase names <strong>for</strong> C routines and INTERFACE blocks to<br />

make the calls using lower case.<br />

Handling User-Defined Types<br />

<strong>Fortran</strong> 95/90 supports user-defined types (data structures similar to C<br />

structures). User-defined types can be passed in modules and common blocks<br />

just as other data types, but the other language must know the type's structure.<br />

For example:<br />

<strong>Fortran</strong> Code:<br />

TYPE LOTTA_DATA<br />

SEQUENCE<br />

REAL A<br />

INTEGER B<br />

CHARACTER(30) INFO<br />

COMPLEX CX<br />

CHARACTER(80) MOREINFO<br />

END TYPE LOTTA_DATA<br />

TYPE (LOTTA_DATA) D1, D2<br />

COMMON /T_BLOCK/ D1, D2<br />

211

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

Saved successfully!

Ooh no, something went wrong!