I do not have experience of interfacing Fortran with C.. I mean exchanging and sharing data between C routines and Fortran routines linked together. I would appreciate some guidelines how to do that. Basically, assume the following common block is defined in a fortran routine called "m1505.f": COMMON/LEXP/DLEXP,TO,AINT That is the Fortran routine defined the common block named "LEXP" containing the three valiables DLEXP, TO, AINT Now assume that such a Fortran routine is linked to some C routines and some Tcl/Tk procedures through a GNUmakefile. How can I, from inside a C routine, access the content of the variable AINT in the common block LEXP ? Thank you in advance for any suggestion. Maura
On Tuesday 06 June 2006 4:04 pm, Maura Edeweiss Monville wrote:
http://h21007.www2.hp.com/dspp/files/unprotected/Fortran/docs/vf-html/pg/pgw... However, be very careful. While floating point and integer variables have the same format, strings, structures, and arrays are quite different. -- Jerry Feldman <gaf@blu.org> Boston Linux and Unix user group http://www.blu.org PGP key id:C5061EA9 PGP Key fingerprint:053C 73EC 3AC1 5C44 3E14 9245 FB00 3ED5 C506 1EA9
Thak you. Worked examples are always welcome to understand the rules. It's not clear if the C external struct must be embedded in that "pack" declaration. In some other similar websites it is stated that a particular include file must be included in the C module ... This is confusing ... Maura On Tue, 6 Jun 2006, Jerry Feldman wrote:
On Tuesday 06 June 2006 5:06 pm, Maura Edeweiss Monville wrote:
Remember that floats (32-bits) and doubles(64-bits) are defined by the IEEE 754 standard (on a Linux and Unix platform). Integers in FORTRAN and C will be the same on the same platform as long as you understand the difference in sizes in C and FORTRAN. Structures are another matter as they are defined by the C standards and the alignments are "implementation defined". I don't recall if the C standards require variables to be naturally aligned or not. It does require that a structure start on a natural boundary. And, as I mentioned, C arrays are row-major and FORTRAN arrays are column major. Strings in FORTRAN as I remember have a leading length attribute and no trailing nul. (I'm going home :-). -- Jerry Feldman <gaf@blu.org> Boston Linux and Unix user group http://www.blu.org PGP key id:C5061EA9 PGP Key fingerprint:053C 73EC 3AC1 5C44 3E14 9245 FB00 3ED5 C506 1EA9
On Wednesday 07 June 2006 07:43, Jerry Feldman wrote:
The first BYTE of a FORTRAN character string is its DEFINED length (not the number of characters stored), and the old standard for calling routines was to pass the number of characters as an extra parameter in a CALL statement (i.e. the length was pushed onto the stack, but not seen in the source code) also, C and FORTRAN parameters were pushed onto the stack in opposite sequence, and clearing the stack can be the responsibility of the caller or of the routine. New FORTRAN compilers are now the same as C. FORTRAN always passes by address. Recent FORTRAN compilers have changed things. So you need to know your compilers :-) Besides COMMON blocks are obsolete now. Use MODULE Good luck. Colin
On Tuesday 06 June 2006 4:04 pm, Maura Edeweiss Monville wrote:
http://h21007.www2.hp.com/dspp/files/unprotected/Fortran/docs/vf-html/pg/pgw... However, be very careful. While floating point and integer variables have the same format, strings, structures, and arrays are quite different. -- Jerry Feldman <gaf@blu.org> Boston Linux and Unix user group http://www.blu.org PGP key id:C5061EA9 PGP Key fingerprint:053C 73EC 3AC1 5C44 3E14 9245 FB00 3ED5 C506 1EA9
Thak you. Worked examples are always welcome to understand the rules. It's not clear if the C external struct must be embedded in that "pack" declaration. In some other similar websites it is stated that a particular include file must be included in the C module ... This is confusing ... Maura On Tue, 6 Jun 2006, Jerry Feldman wrote:
On Tuesday 06 June 2006 5:06 pm, Maura Edeweiss Monville wrote:
Remember that floats (32-bits) and doubles(64-bits) are defined by the IEEE 754 standard (on a Linux and Unix platform). Integers in FORTRAN and C will be the same on the same platform as long as you understand the difference in sizes in C and FORTRAN. Structures are another matter as they are defined by the C standards and the alignments are "implementation defined". I don't recall if the C standards require variables to be naturally aligned or not. It does require that a structure start on a natural boundary. And, as I mentioned, C arrays are row-major and FORTRAN arrays are column major. Strings in FORTRAN as I remember have a leading length attribute and no trailing nul. (I'm going home :-). -- Jerry Feldman <gaf@blu.org> Boston Linux and Unix user group http://www.blu.org PGP key id:C5061EA9 PGP Key fingerprint:053C 73EC 3AC1 5C44 3E14 9245 FB00 3ED5 C506 1EA9
On Wednesday 07 June 2006 07:43, Jerry Feldman wrote:
The first BYTE of a FORTRAN character string is its DEFINED length (not the number of characters stored), and the old standard for calling routines was to pass the number of characters as an extra parameter in a CALL statement (i.e. the length was pushed onto the stack, but not seen in the source code) also, C and FORTRAN parameters were pushed onto the stack in opposite sequence, and clearing the stack can be the responsibility of the caller or of the routine. New FORTRAN compilers are now the same as C. FORTRAN always passes by address. Recent FORTRAN compilers have changed things. So you need to know your compilers :-) Besides COMMON blocks are obsolete now. Use MODULE Good luck. Colin
participants (3)
-
Colin Carter
-
Jerry Feldman
-
Maura Edeweiss Monville