Browse Prior Art Database

FORTRAN to C Bindings - Programming Assistance (Approach B)

IP.com Disclosure Number: IPCOM000036280D
Original Publication Date: 1989-Sep-01
Included in the Prior Art Database: 2005-Jan-28
Document File: 3 page(s) / 14K

Publishing Venue

IBM

Related People

McDonald, RE: AUTHOR [+2]

Abstract

Disclosed is a tool to facilitate the use of the FORTRAN Memory Management service routines to access elements in 'C' data structures. A set of macro definitions is defined for each 'C' structure. These macros provide the offset and size of each element in the structure (for accessing data) and the size of the structure (for memory allocation).

This text was extracted from a PDF file.
This is the abbreviated version, containing approximately 58% of the total text.

Page 1 of 3

FORTRAN to C Bindings - Programming Assistance (Approach B)

Disclosed is a tool to facilitate the use of the FORTRAN Memory Management service routines to access elements in 'C' data structures. A set of macro definitions is defined for each 'C' structure. These macros provide the offset and size of each element in the structure (for accessing data) and the size of the structure (for memory allocation).

1) To allocate and free memory, a macro definition is created for each 'C' structure as follows: a) The macro name is formed by concatenating the

string "allocate_" and the 'C' structure name.

b) The macro definition for allocating memory is

formed by concatenating the string

"allocatememory(", the predetermined size of the

structure, and the string ")".

c) The macro definition for freeing memory is the

string "freememory($1)"

As an example:

The 'C' structure is:

struct simple

{

unsigned long int varl;

short int var2;

}

The macro definitions for allocating and freeing a data area for this structure are: define(allocate_simple,allocatememory(6))

define(free_simple,freememory($1))

d) A defined macro to allocate memory is invoked by:

starting address = allocate macro name

e) A defined macro to free memory is invoked by: free

macro name (starting address)

As an example:

The macro invocation which allocates memory for a

variable of type

simple is:

returnaddr = allocate_simple()

which expands to:

returnaddr = allocatememory(6)

The macro invocation which frees memory for a variable of

type

simple is:

free_simple( addr)

which expands to:

freememory( addr)

2) To store and retrieve data, a macro definition is created for both storing and retrieving data for each C' structure element as follows:

1

Page 2 of 3

a) The macro name is formed by concatenating the string "get_" or "put_" (as applicable), the 'C' data structure name and the data structure element name.

1) The macro definition for storing integer-type data is formed by concatenating the string "putvalue($1,", the predetermined offset of the structure element from the beginning of the structure, the string ",", the predetermined size of the structure element, and the string ",$2)".

2) The macro definition for retrieving integer-type data is formed by concatenating the string "getvalue($1,", the predetermined offset of the structure element from the beginning of the structure, the string ",", the predetermined size of the structure element, and the string ")".

3) The macro definition for the storing string data is formed by concatenating the string "putstring($1,", the string ",", the predetermined offset of the structure element from the beginning of the structure, and the string ",$2)".

4) The macro definition for retrieving s...