24.05.2014 Views

XL Fortran Enterprise Edition for AIX : User's Guide - IBM

XL Fortran Enterprise Edition for AIX : User's Guide - IBM

XL Fortran Enterprise Edition for AIX : User's Guide - IBM

SHOW MORE
SHOW LESS

Create successful ePaper yourself

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

See “Passing Arguments By Reference or By Value” on page 353 and %VAL and<br />

%REF in the <strong>XL</strong> <strong>Fortran</strong> <strong>Enterprise</strong> <strong>Edition</strong> <strong>for</strong> <strong>AIX</strong> Language Reference <strong>for</strong> more<br />

details.<br />

Passing Data From One Language to Another<br />

The following table shows the data types available in the <strong>XL</strong> <strong>Fortran</strong>, Pascal, and C<br />

languages. This section shows how <strong>Fortran</strong> arguments can be passed by reference<br />

to C programs. To use the <strong>Fortran</strong> 2003 Draft Standard interoperability features,<br />

such as the BIND(C) attribute and ISO_C_BINDING module support, see the <strong>XL</strong><br />

<strong>Fortran</strong> <strong>Enterprise</strong> <strong>Edition</strong> <strong>for</strong> <strong>AIX</strong> Language Reference.<br />

Passing Arguments between Languages<br />

Table 24. Corresponding Data Types in <strong>Fortran</strong>, C, and Pascal. When calling <strong>Fortran</strong>, the C<br />

and Pascal routines must pass arguments as pointers to the types listed in this table.<br />

<strong>XL</strong> <strong>Fortran</strong> Data Types <strong>IBM</strong> C Data Types <strong>XL</strong> Pascal Data Types<br />

INTEGER(1), BYTE signed char PACKED -128..127<br />

INTEGER(2) signed short PACKED -32768..32767<br />

INTEGER(4) signed int INTEGER<br />

INTEGER(8) signed long long (see note 1) —<br />

REAL, REAL(4) float SHORTREAL<br />

REAL(8), DOUBLE<br />

PRECISION<br />

double<br />

REAL(16) long double (see note 2) —<br />

REAL<br />

COMPLEX, COMPLEX(4) structure of two floats record of two SHORTREALs<br />

COMPLEX(8), DOUBLE<br />

COMPLEX<br />

structure of two doubles<br />

COMPLEX(16) structure of two long doubles —<br />

record of two REALs<br />

LOGICAL(1) unsigned char PACKED 0..255<br />

LOGICAL(2) unsigned short PACKED 0..65535<br />

LOGICAL(4) unsigned int —<br />

LOGICAL(8)<br />

unsigned long long (see note<br />

1)<br />

CHARACTER char CHAR<br />

CHARACTER(n) char[n] PACKED ARRAY[1..n] OF<br />

CHAR<br />

Integer POINTER void * POINTER, or typed pointer<br />

such as @INTEGER (see note<br />

3)<br />

Array array ARRAY<br />

Sequence-derived type<br />

structure (with C<br />

-qalign=packed option)<br />

—<br />

PACKED RECORD<br />

Notes:<br />

1. Requires the option -qlanglvl=extended in <strong>XL</strong> C or -qlonglong in C <strong>for</strong> <strong>AIX</strong> and C Set<br />

++ <strong>for</strong> <strong>AIX</strong>. These are default options <strong>for</strong> some compilation commands but not <strong>for</strong><br />

others.<br />

2. Requires C compiler -qlongdbl option.<br />

3. Requires <strong>XL</strong> Pascal -qptr4 option.<br />

Interlanguage Calls 349

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

Saved successfully!

Ooh no, something went wrong!