12.07.2015 Views

LF95 Linux User's Guide - Lahey Computer Systems

LF95 Linux User's Guide - Lahey Computer Systems

LF95 Linux User's Guide - Lahey Computer Systems

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Returning Function Values to CTable 7: Corresponding Data Types in Fortran and CData Type Fortran C Commentseight-byte integerINTEGER(8) I8long long intI8;8 bytesreal REAL(4) R4 float R4; 4 bytesdouble-precisionrealREAL(8) R8 double R8; 8 bytesquadruple-precisionrealREAL(16) R16long doubleR16;16 bytescomplexCOMPLEX(4) C8struct{float r, i;}C8;8 bytesdouble-precisioncomplexCOMPLEX(8) C16struct{double r, i;}C16;16 bytesquad-precisioncomplexCOMPLEX(16)C32struct{long doubler, i;} C32;32 bytescharacter (fixedlength)CHARACTER*10 Schar S[10]See examples forassumed-lengthderived typeTYPE TAGSEQUENCEINTEGER I4REAL(8) R8END TYPETYPE(TAG) Dstruct tag{int I4;double R8;} D;Size (in bytes) =sum of all componentsarray of pointersnot allowed*myarray[10]**hisarrayReturning Function Values to CFortran functions are called from C as functions returning a value, with all arguments passedby reference. Values are passed on the stack, with the exception of COMPLEX and CHARAC-TER data, in which case the values are passed via the argument list. The following table liststhe data types that may be returned to C from a Fortran function. In the third column of thetable (“examples” column), the variable result represents the value returned by the Fortranfunction myfunc(). In the last example, the variable strlen represents the length of thecharacter value returned by myfunc().<strong>Lahey</strong>/Fujitsu <strong>Linux</strong>64 Fortran User’s <strong>Guide</strong> 55

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

Saved successfully!

Ooh no, something went wrong!