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

Create successful ePaper yourself

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

Chapter 3 Mixed Language Programmingvoid test(float real_array[10][9][8][7][6][5][4])int i,j,k,l,m,n,o;/*** this is what the subscripts would look like on the C side*/for(o = 0; o < 11; o++)for(n = 0; n < 10; n++)for(m = 0; m < 9; m++)for(l = 0; l < 8; l++)for(k = 0; k < 7; k++)for(j = 0; j < 6; j++)for(i = 0; i < 5; i++)real_array[o][n][m][l][k][j][i] = 12.000;return;}On the Fortran side of the call, the array argument must not be dimensioned as an assumedshapearray. You should use explicit shape, assumed size, or adjustable arrays.Passing Character DataCharacter arguments are passed as pointers to strings. When a Fortran program unit containscharacter dummy arguments, then any routine calling that program unit must append to theend of the argument list the length of each of the corresponding character actual arguments.The length must be passed by value, as a four-byte integer (long int), to Fortran.For example, the Fortran subroutine:subroutine example3 (int1, char1, int2, char2)integer int1, int2character (len=*) :: char1character (len=25) :: char2endcorresponds to this prototype in C:void example3 (long int *int1, \char *char1, \long int *int2, \char *char2, \long int char1_len);When passing a character string from Fortran to C, Fortran will by default append a “hidden”integer value, representing the length of the string, to the end of the argument list. This integeris passed by value. If more than one character string is passed, the length values appearin the same order as the strings, at the end of the argument list. To prevent the length valuefrom being added, apply the CARG() intrinsic or combine the VAL(OFFSET()) intrinsics, sothat only the pointer to the string is passed.60 <strong>Lahey</strong>/Fujitsu <strong>Linux</strong>64 Fortran User’s <strong>Guide</strong>

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

Saved successfully!

Ooh no, something went wrong!