Transcript
Page 1: Chasm Reference Manualchasm-interop.sourceforge.net/F90ArrayDesc_API.pdf · (for modifying an array pointer on return from a Fortran call to C). Note, it is the callers responsibility

Chasm Reference Manual

Generated by Doxygen 1.3.4

Mon Sep 29 17:57:06 2003

Page 2: Chasm Reference Manualchasm-interop.sourceforge.net/F90ArrayDesc_API.pdf · (for modifying an array pointer on return from a Fortran call to C). Note, it is the callers responsibility
Page 3: Chasm Reference Manualchasm-interop.sourceforge.net/F90ArrayDesc_API.pdf · (for modifying an array pointer on return from a Fortran call to C). Note, it is the callers responsibility

Contents

1 Array Descriptor Library 1

2 Chasm Module Index 3

2.1 Chasm Modules. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

3 Chasm Data Structure Index 5

3.1 Chasm Data Structures. . . . . . . . . . . . . . . . . . . . . . . . . 5

4 Chasm File Index 7

4.1 Chasm File List. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

5 Chasm Module Documentation 9

5.1 Create and Initialize. . . . . . . . . . . . . . . . . . . . . . . . . . . 9

5.2 Procedure Calls. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

5.3 Accessors. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

5.4 Miscellaneous. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19

6 Chasm Data Structure Documentation 23

6.1 F90_CompilerCharacteristics Struct Reference. . . . . . . . . . . . 23

7 Chasm File Documentation 27

7.1 CompilerCharacteristics.h File Reference. . . . . . . . . . . . . . . 27

7.2 F90Vendor.h File Reference. . . . . . . . . . . . . . . . . . . . . . 30

Page 4: Chasm Reference Manualchasm-interop.sourceforge.net/F90ArrayDesc_API.pdf · (for modifying an array pointer on return from a Fortran call to C). Note, it is the callers responsibility
Page 5: Chasm Reference Manualchasm-interop.sourceforge.net/F90ArrayDesc_API.pdf · (for modifying an array pointer on return from a Fortran call to C). Note, it is the callers responsibility

Chapter 1

Array Descriptor Library

Fortran 90 (and later) compilers pass array-valued parameters via an array descriptor(sometimes called a dope vector). The Chasm library provides C functions to accesselements in an array descriptor.

The API for the array descriptor library is divided into several groups:

• Creation and initialization of an array descriptor:

1. createArrayDesc_F90Vendor()

2. setArrayDesc_F90Vendor()

3. resetArrayDesc_F90Vendor()

• Creation and initialization of a temporary, array and hidden descriptor pair, usedin a procedure call:

1. copyToArrayDescAndHidden_F90Vendor()

2. createArrayDescAndHidden_F90Vendor()

3. freeArrayDescAndHidden_F90Vendor()

• Access functions:

1. getArrayBaseAddress_F90Vendor()

2. getArraySize_F90Vendor()

3. getArrayLowerBound_F90Vendor()

4. getArrayExtent_F90Vendor()

5. getArrayStrideMult_F90Vendor()

• Miscellaneous helper functions:

1. getArrayDescSize_F90Vendor()

Page 6: Chasm Reference Manualchasm-interop.sourceforge.net/F90ArrayDesc_API.pdf · (for modifying an array pointer on return from a Fortran call to C). Note, it is the callers responsibility

2 Array Descriptor Library

2. hiddenArrayDescType_F90Vendor()

3. verifyArrayDesc_F90Vendor()

4. nullifyArrayDesc_F90Vendor()

5. printArrayDesc_F90Vendor()

6. equalsArrayDesc_F90Vendor()

7. getMangledName_F90Vendor()

8. F90_SetCCFunctions_F90Vendor()

Generated on Mon Sep 29 17:57:07 2003 for Chasm by Doxygen

Page 7: Chasm Reference Manualchasm-interop.sourceforge.net/F90ArrayDesc_API.pdf · (for modifying an array pointer on return from a Fortran call to C). Note, it is the callers responsibility

Chapter 2

Chasm Module Index

2.1 Chasm Modules

Here is a list of all modules:

Create and Initialize . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .9Procedure Calls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .13Accessors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .16Miscellaneous . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .19

Page 8: Chasm Reference Manualchasm-interop.sourceforge.net/F90ArrayDesc_API.pdf · (for modifying an array pointer on return from a Fortran call to C). Note, it is the callers responsibility

4 Chasm Module Index

Generated on Mon Sep 29 17:57:07 2003 for Chasm by Doxygen

Page 9: Chasm Reference Manualchasm-interop.sourceforge.net/F90ArrayDesc_API.pdf · (for modifying an array pointer on return from a Fortran call to C). Note, it is the callers responsibility

Chapter 3

Chasm Data Structure Index

3.1 Chasm Data Structures

Here are the data structures with brief descriptions:

F90_CompilerCharacteristics(CompilerCharacteristics contains functionpointers that provide a generic interface to the array descriptor li-brary ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .23

Page 10: Chasm Reference Manualchasm-interop.sourceforge.net/F90ArrayDesc_API.pdf · (for modifying an array pointer on return from a Fortran call to C). Note, it is the callers responsibility

6 Chasm Data Structure Index

Generated on Mon Sep 29 17:57:07 2003 for Chasm by Doxygen

Page 11: Chasm Reference Manualchasm-interop.sourceforge.net/F90ArrayDesc_API.pdf · (for modifying an array pointer on return from a Fortran call to C). Note, it is the callers responsibility

Chapter 4

Chasm File Index

4.1 Chasm File List

Here is a list of all files with brief descriptions:

CompilerCharacteristics.h. . . . . . . . . . . . . . . . . . . . . . . . . . .27F90Vendor.h(Function declarations for the Chasm array-descriptor library ) .30

Page 12: Chasm Reference Manualchasm-interop.sourceforge.net/F90ArrayDesc_API.pdf · (for modifying an array pointer on return from a Fortran call to C). Note, it is the callers responsibility

8 Chasm File Index

Generated on Mon Sep 29 17:57:07 2003 for Chasm by Doxygen

Page 13: Chasm Reference Manualchasm-interop.sourceforge.net/F90ArrayDesc_API.pdf · (for modifying an array pointer on return from a Fortran call to C). Note, it is the callers responsibility

Chapter 5

Chasm Module Documentation

5.1 Create and Initialize

Functions in this group are used to create and initialize an array descriptor.

Functions

• void ∗ createArrayDesc_F90Vendor(void ∗desc, void∗hidden, int rank,F90_-DescTypedesc_type)

Creates an array descriptor by copying an existing array and hidden descriptor pair.

• int setArrayDesc_F90Vendor(void ∗desc, void∗base_addr, int rank,F90_Desc-Type desc_type, F90_ArrayDataType data_type, unsigned long element_size,const long∗lowerBound, const unsigned long∗extent, const long∗strideMult)

Sets the elements of a preallocated array descriptor.

• int resetArrayDesc_F90Vendor(void ∗desc, void∗base_addr, int rank, constlong∗lowerBound, const unsigned long∗extent, const long∗strideMult)

Resets the elements of a preallocated array descriptor.

5.1.1 Detailed Description

Functions in this group are used to create and initialize an array descriptor.

Descriptors created by these functions may be permanently stored in C (as long as thearray associated with the descriptor has not freed; it is an error to use a descriptor if theassociated array has been freed). However, these descriptors cannot be directly used

Page 14: Chasm Reference Manualchasm-interop.sourceforge.net/F90ArrayDesc_API.pdf · (for modifying an array pointer on return from a Fortran call to C). Note, it is the callers responsibility

10 Chasm Module Documentation

in a procedure call to Fortran as the call may require a hidden descriptor parameter(depending on the Fortran compiler). Descriptors created by these functions must firstbe converted to a descriptor and hidden descriptor pair by a function in the"ProcedureCall" group.

5.1.2 Function Documentation

5.1.2.1 void∗ createArrayDesc_F90Vendor (void∗ desc, void ∗ hidden, int rank,F90_DescTypedesc_type)

Creates an array descriptor by copying an existing array and hidden descriptor pair.

This function is used when passing an array from Fortran to C. The array and hiddendescriptor input parameters are obtained from the Fortran calling procedure; they mustnot be otherwise stored or saved.

The returned descriptor cannot be directly used in calls to Fortran because a hidden de-scriptor may be required by some compilers. The created descriptor may be copiedto a descriptor and hidden descriptor pair by eithercreateArrayDescAndHidden_-F90Vendor()(for a C call to Fortran) or bycopyToArrayDescAndHidden_F90Vendor()(for modifying an array pointer on return from a Fortran call to C).Note, it is the callersresponsibility to free the returned descriptor.

See also:setArrayDesc_F90Vendor()resetArrayDesc_F90Vendor()

Parameters:desc the array descriptor (from Fortran call stack) to copy (in parameter).

hidden hidden descriptor (from Fortran call stack; in parameter).

rank the rank of the array (in parameter).

desc_typetype of the source descriptor (in parameter).

Returns:a newly allocated array descriptor.

5.1.2.2 int resetArrayDesc_F90Vendor (void∗ desc, void ∗ base_addr, int rank,const long∗ lowerBound, const unsigned long∗ extent, const long∗strideMult)

Resets the elements of a preallocated array descriptor.

The descriptor must have been previously initialized by eithersetArrayDesc_-F90Vendor()or createArrayDesc_F90Vendor(). The rank, data type and element size

Generated on Mon Sep 29 17:57:07 2003 for Chasm by Doxygen

Page 15: Chasm Reference Manualchasm-interop.sourceforge.net/F90ArrayDesc_API.pdf · (for modifying an array pointer on return from a Fortran call to C). Note, it is the callers responsibility

5.1 Create and Initialize 11

of the array MUST NOT change.Note, at least,getArrayDescSize_F90Vendor()bytesmust have been allocated for the descriptor.

Parameters:desc a previously initialized array descriptor (memory created and freed by caller;

inout parameter).

base_addrthe base address of the array (in parameter).

rank the rank of the array (in parameter).

lowerBound array[rank] of lower bounds for the array (in parameter).

extent array[rank] of extents for the array (in elements; in parameter).

strideMult array[rank] of distances between successive elements (in bytes; in pa-rameter).

Returns:0 if successful (nonzero on error).

5.1.2.3 int setArrayDesc_F90Vendor (void∗ desc, void ∗ base_addr, int rank,F90_DescTypedesc_type, F90_ArrayDataType data_type, unsigned longelement_size, const long∗ lowerBound, const unsigned long∗ extent,const long∗ strideMult)

Sets the elements of a preallocated array descriptor.

This function is used when memory for an array has been created in C and the C arrayis to be subsequently passed to a Fortran procedure.

The initialized descriptor cannot be directly used in calls to Fortran because a hid-den descriptor parameter may be required by some compilers. The initialized descrip-tor may be copied to a descriptor and hidden descriptor pair by eithercreateArray-DescAndHidden_F90Vendor()(for a C call to Fortran) or bycopyToArrayDescAnd-Hidden_F90Vendor()(for modifying an array pointer on return from a Fortran call toC).

Memory for the descriptor is allocated and freed by the caller. The size of descriptormust be at leastgetArrayDescSize_F90Vendor()bytes.

See also:createArrayDesc_F90Vendor()resetArrayDesc_F90Vendor()

Parameters:desc an uninitialized array descriptor (memory created and freed by caller; out

parameter).

base_addrthe base address of the array (in paramemter).

Generated on Mon Sep 29 17:57:07 2003 for Chasm by Doxygen

Page 16: Chasm Reference Manualchasm-interop.sourceforge.net/F90ArrayDesc_API.pdf · (for modifying an array pointer on return from a Fortran call to C). Note, it is the callers responsibility

12 Chasm Module Documentation

rank the rank of the array (in parameter).

desc_typetype of the descriptor (in parameter).

data_typedata type of an array element (in parameter).

element_sizesize of an array element (in parameter).

lowerBound array[rank] of lower bounds for the array (in parameter).

extent array[rank] of extents for the array (in elements; in parameter).

strideMult array[rank] of distances between successive elements (in bytes; in pa-rameter).

Returns:0 if successful (nonzero on error).

Generated on Mon Sep 29 17:57:07 2003 for Chasm by Doxygen

Page 17: Chasm Reference Manualchasm-interop.sourceforge.net/F90ArrayDesc_API.pdf · (for modifying an array pointer on return from a Fortran call to C). Note, it is the callers responsibility

5.2 Procedure Calls 13

5.2 Procedure Calls

Functions in this group are used to create (or copy to) a temporary array and hiddendescriptor pair used in a procedure call.

Functions

• int copyToArrayDescAndHidden_F90Vendor(void ∗src, int rank,F90_Desc-Typedesc_type, void∗desc, void∗hidden)

Copies an array descriptor to an array and hidden descriptor pair.

• int createArrayDescAndHidden_F90Vendor(void ∗src, int rank,F90_DescTypedesc_type, void∗∗desc, void∗∗hidden)

Creates an array and hidden descriptor pair from an existing descriptor.

• int freeArrayDescAndHidden_F90Vendor(F90_DescTypedesc_type, void∗desc, void∗hidden)

Frees an array and hidden descriptor pair created by a call tocreateArrayDescAnd-Hidden_F90Vendor().

5.2.1 Detailed Description

Functions in this group are used to create (or copy to) a temporary array and hiddendescriptor pair used in a procedure call.

Note that descriptors created or intialized by functions in the"Create and Initialize"group cannot be used directly in a procedure call, but must first be copied by one of thefunctions in this group.

5.2.2 Function Documentation

5.2.2.1 int copyToArrayDescAndHidden_F90Vendor (void∗ src, int rank,F90_DescTypedesc_type, void ∗ desc, void ∗ hidden)

Copies an array descriptor to an array and hidden descriptor pair.

This function may be used to modify an array pointer on the return of a Fortran call toC. The source descriptor must have been created by a call to eithercreateArrayDesc_-F90Vendor()or setArrayDesc_F90Vendor().

See also:createArrayDescAndHidden_F90Vendor()

Generated on Mon Sep 29 17:57:07 2003 for Chasm by Doxygen

Page 18: Chasm Reference Manualchasm-interop.sourceforge.net/F90ArrayDesc_API.pdf · (for modifying an array pointer on return from a Fortran call to C). Note, it is the callers responsibility

14 Chasm Module Documentation

Parameters:src the source descriptor (in parameter).

rank the rank of the source and destination arrays (in parameter).

desc_typetype of the source and destination descriptors (in parameter).

desc the destination array descriptor (from Fortran call stack; out parameter).

hidden the destination hidden descriptor (from Fortran call stack; out parameter).

Returns:0 if successful (nonzero on error).

5.2.2.2 int createArrayDescAndHidden_F90Vendor (void∗ src, int rank,F90_DescTypedesc_type, void ∗∗ desc, void ∗∗ hidden)

Creates an array and hidden descriptor pair from an existing descriptor.

This function may used in calling a Fortran procedure from C (with an array-valuedparameter). The source descriptor must have been created by a call to eithercreate-ArrayDesc_F90Vendor()or setArrayDesc_F90Vendor().

Note, the companion function freeArrayDescWithHidden_F90Vendor() must be calledto free the parameters desc and hidden after use (lifetime must not exceed that of thesource descriptor).

See also:copyToArrayDescAndHidden_F90Vendor()

Parameters:src the source descriptor (in parameter).

rank the rank of the source and destination arrays (in parameter).

desc_typetype of the source and destination descriptors (in parameter).

desc on return, contains address of created array descriptor (to be passed to For-tran; out parameter).

hidden on return, contains address of hidden form of the array descriptor (to bepassed to Fortran; out parameter).

Returns:0 if successful (nonzero on error).

Generated on Mon Sep 29 17:57:07 2003 for Chasm by Doxygen

Page 19: Chasm Reference Manualchasm-interop.sourceforge.net/F90ArrayDesc_API.pdf · (for modifying an array pointer on return from a Fortran call to C). Note, it is the callers responsibility

5.2 Procedure Calls 15

5.2.2.3 int freeArrayDescAndHidden_F90Vendor (F90_DescTypedesc_type,void ∗ desc, void ∗ hidden)

Frees an array and hidden descriptor pair created by a call tocreateArrayDescAnd-Hidden_F90Vendor().

Parameters:desc_typetype of the descriptor (in parameter).

desc address of descriptor to be freed (inout parameter).

hidden address of hidden form of the descriptor to be freed (inout parameter).

Returns:0 if successful (nonzero on error).

Generated on Mon Sep 29 17:57:07 2003 for Chasm by Doxygen

Page 20: Chasm Reference Manualchasm-interop.sourceforge.net/F90ArrayDesc_API.pdf · (for modifying an array pointer on return from a Fortran call to C). Note, it is the callers responsibility

16 Chasm Module Documentation

5.3 Accessors

Functions in this group provide access to information contained in an array de-scriptor obtained by a call to eithercreateArrayDesc_F90Vendor()or setArrayDesc_-F90Vendor().

Functions

• void ∗ getArrayBaseAddress_F90Vendor(const void∗desc, int rank)

Returns a pointer to the base address of the array.

• unsigned longgetArraySize_F90Vendor(const void∗desc, int rank)

Returns the array size (in elements).

• longgetArrayLowerBound_F90Vendor(const void∗desc, int rank, int dim)

Returns the lower bound for the given dimension.

• unsigned longgetArrayExtent_F90Vendor(const void∗desc, int rank, int dim)

Returns the extent of the array for the given dimension (in elements).

• longgetArrayStrideMult_F90Vendor(const void∗desc, int rank, int dim)

Returns the distance between successive elements (in bytes).

5.3.1 Detailed Description

Functions in this group provide access to information contained in an array de-scriptor obtained by a call to eithercreateArrayDesc_F90Vendor()or setArrayDesc_-F90Vendor().

5.3.2 Function Documentation

5.3.2.1 void∗ getArrayBaseAddress_F90Vendor (const void∗ desc, int rank)

Returns a pointer to the base address of the array.

Parameters:desc array descriptor (in parameter).

rank the rank of the array (in parameter).

Returns:the base address of the array.

Generated on Mon Sep 29 17:57:07 2003 for Chasm by Doxygen

Page 21: Chasm Reference Manualchasm-interop.sourceforge.net/F90ArrayDesc_API.pdf · (for modifying an array pointer on return from a Fortran call to C). Note, it is the callers responsibility

5.3 Accessors 17

5.3.2.2 unsigned long getArrayExtent_F90Vendor (const void∗ desc, int rank,int dim)

Returns the extent of the array for the given dimension (in elements).

Parameters:desc array descriptor (in parameter).

rank the rank of the array (in parameter).

dim the dimension (in parameter).

Returns:the array extent for the given dimension (in elements).

5.3.2.3 long getArrayLowerBound_F90Vendor (const void∗ desc, int rank, intdim)

Returns the lower bound for the given dimension.

Parameters:desc array descriptor (in parameter).

rank the rank of the array (in parameter).

dim the dimension (in parameter).

Returns:the lower bound of the array for the given dimension.

5.3.2.4 unsigned long getArraySize_F90Vendor (const void∗ desc, int rank)

Returns the array size (in elements).

Parameters:desc array descriptor (in parameter).

rank the rank of the array (in parameter).

Returns:the array size.

Generated on Mon Sep 29 17:57:07 2003 for Chasm by Doxygen

Page 22: Chasm Reference Manualchasm-interop.sourceforge.net/F90ArrayDesc_API.pdf · (for modifying an array pointer on return from a Fortran call to C). Note, it is the callers responsibility

18 Chasm Module Documentation

5.3.2.5 long getArrayStrideMult_F90Vendor (const void∗ desc, int rank, intdim)

Returns the distance between successive elements (in bytes).

Parameters:desc array descriptor (in parameter).

rank the rank of the array (in parameter).

dim the dimension (in parameter).

Returns:the array stride for the given dimension (in bytes).

Generated on Mon Sep 29 17:57:07 2003 for Chasm by Doxygen

Page 23: Chasm Reference Manualchasm-interop.sourceforge.net/F90ArrayDesc_API.pdf · (for modifying an array pointer on return from a Fortran call to C). Note, it is the callers responsibility

5.4 Miscellaneous 19

5.4 Miscellaneous

This group of functions contains various miscellaneous helper functions.

Functions

• unsigned longgetArrayDescSize_F90Vendor(int rank)

Returns the size of an array descriptor (in bytes).

• F90_HiddenDescType hiddenArrayDescType_F90Vendor(F90_DescTypedesc_type)

Returns the type of hidden descriptor used by the compiler for the given descriptortype.

• int verifyArrayDesc_F90Vendor(const void∗desc, int rank)

Verify an array descriptor.

• int nullifyArrayDesc_F90Vendor(void ∗desc, int rank)

Nullify an array descriptor.

• int printArrayDesc_F90Vendor(const void∗desc, int rank)

Prints all fields in the array descriptor.

• int equalsArrayDesc_F90Vendor(const void∗desc1, const void∗desc2, intrank)

Determines if two descriptors are equal (equivalent).

• char∗ getMangledName_F90Vendor(const char∗fun_name, const char∗mod_-name)

Returns the symbol name of a module procedure, if the module name is not null,otherwise returns the name of the procedure.

• void F90_SetCCFunctions_F90Vendor(F90_CompilerCharacteristics∗cc)

Set CompilerCharacteristics function pointers for a particular compiler.

5.4.1 Detailed Description

This group of functions contains various miscellaneous helper functions.

Note that all descriptor parameters in this function group must have been obtained bya call to eithercreateArrayDesc_F90Vendor()or setArrayDesc_F90Vendor().

Generated on Mon Sep 29 17:57:07 2003 for Chasm by Doxygen

Page 24: Chasm Reference Manualchasm-interop.sourceforge.net/F90ArrayDesc_API.pdf · (for modifying an array pointer on return from a Fortran call to C). Note, it is the callers responsibility

20 Chasm Module Documentation

5.4.2 Function Documentation

5.4.2.1 int equalsArrayDesc_F90Vendor (const void∗ desc1, const void∗ desc2,int rank)

Determines if two descriptors are equal (equivalent).

Parameters:desc1first descriptor (in parameter).

desc2second descriptor (in parameter).

rank the rank of the array (in parameter).

Returns:1 if equal, 0 otherwise.

5.4.2.2 void F90_SetCCFunctions_F90Vendor (F90_CompilerCharacteristics∗cc)

Set CompilerCharacteristics function pointers for a particular compiler.

This function is called by the generic (and global)F90_SetCompilerCharacteristics()function to provide a generic interface to the Chasm array-descriptor library.

Parameters:cc theF90_CompilerCharacteristicsstruct (out parameter).

5.4.2.3 unsigned long getArrayDescSize_F90Vendor (intrank)

Returns the size of an array descriptor (in bytes).

Parameters:rank the rank of the array (in parameter).

Returns:the descriptor size (in bytes).

5.4.2.4 char∗ getMangledName_F90Vendor (const char∗ fun_name, const char∗ mod_name)

Returns the symbol name of a module procedure, if the module name is not null, oth-erwise returns the name of the procedure.

Note that static memory is used for the return value so it must be copied if retainedbecause the memory is overwritten at each call.

Generated on Mon Sep 29 17:57:07 2003 for Chasm by Doxygen

Page 25: Chasm Reference Manualchasm-interop.sourceforge.net/F90ArrayDesc_API.pdf · (for modifying an array pointer on return from a Fortran call to C). Note, it is the callers responsibility

5.4 Miscellaneous 21

Parameters:fun_name the name of the procedure (in parameter).

mod_namethe module name (in parameter). Should be NULL if a global proce-dure rather than a module procedure.

Returns:the symbol name.

5.4.2.5 F90_HiddenDescTypehiddenArrayDescType_F90Vendor(F90_DescTypedesc_type)

Returns the type of hidden descriptor used by the compiler for the given descriptortype.

Parameters:desc_typetype of the descriptor (in parameter).

Returns:the hidden descriptor type.

5.4.2.6 int nullifyArrayDesc_F90Vendor (void∗ desc, int rank)

Nullify an array descriptor.

This sets elements of the array descriptor so that the Fortran nullify intrinsic will returnfalse, given the associated array.

Parameters:desc array descriptor (inout parameter).

rank the rank of the array (in parameter).

Returns:0 if successful (nonzero on error).

5.4.2.7 int printArrayDesc_F90Vendor (const void∗ desc, int rank)

Prints all fields in the array descriptor.

Parameters:desc array descriptor (in parameter).

rank the rank of the array (in parameter).

Returns:0 if successful (nonzero on error).

Generated on Mon Sep 29 17:57:07 2003 for Chasm by Doxygen

Page 26: Chasm Reference Manualchasm-interop.sourceforge.net/F90ArrayDesc_API.pdf · (for modifying an array pointer on return from a Fortran call to C). Note, it is the callers responsibility

22 Chasm Module Documentation

5.4.2.8 int verifyArrayDesc_F90Vendor (const void∗ desc, int rank)

Verify an array descriptor.

This function does what it can (given only the limited information in the descriptor) toverify that the elements of the array descriptor are correct (i.e., self consistent).

Parameters:desc array descriptor (in parameter).

rank the rank of the array (in parameter).

Returns:0 if the descriptor is valid, nonzero otherwise.

Generated on Mon Sep 29 17:57:07 2003 for Chasm by Doxygen

Page 27: Chasm Reference Manualchasm-interop.sourceforge.net/F90ArrayDesc_API.pdf · (for modifying an array pointer on return from a Fortran call to C). Note, it is the callers responsibility

Chapter 6

Chasm Data StructureDocumentation

6.1 F90_CompilerCharacteristics Struct Reference

CompilerCharacteristics contains function pointers that provide a generic interface tothe array descriptor library.

#include <CompilerCharacteristics.h >

Data Fields

• int(∗ setArrayDesc)(void ∗desc, void∗base_addr, int rank,F90_DescTypekind,F90_ArrayDataType data_type, unsigned long element_size, const long∗lower-Bound, const unsigned long∗extent, const long∗strideMult)

• int(∗ resetArrayDesc)(void ∗desc, void∗base_addr, int rank, const long∗lower-Bound, const unsigned long∗extent, const long∗strideMult)

• void ∗(∗ createArrayDesc)(void ∗desc, void∗hidden, int rank,F90_DescTypekind)

• int(∗ createArrayDescAndHidden)(void ∗src, int rank,F90_DescTypekind,void ∗∗desc, void∗∗hidden)

• int(∗ freeArrayDescAndHidden)(F90_DescTypekind, void ∗desc, void∗hidden)

• int(∗ copyToArrayDescAndHidden)(void ∗src, int rank,F90_DescTypekind,void ∗dest, void∗hidden)

• void ∗(∗ getArrayBaseAddress)(const void∗desc, int rank)• unsigned long(∗ getArraySize)(const void∗desc, int rank)• long(∗ getArrayLowerBound)(const void∗desc, int rank, int dim)

Page 28: Chasm Reference Manualchasm-interop.sourceforge.net/F90ArrayDesc_API.pdf · (for modifying an array pointer on return from a Fortran call to C). Note, it is the callers responsibility

24 Chasm Data Structure Documentation

• unsigned long(∗ getArrayExtent)(const void∗desc, int rank, int dim)

• long(∗ getArrayStrideMult)(const void∗desc, int rank, int dim)

• unsigned long(∗ getArrayDescSize)(int rank)

• int(∗ nullifyArrayDesc)(void ∗desc, int rank)

• int(∗ verifyArrayDesc)(const void∗desc, int rank)

• F90_HiddenDescType(∗ hiddenArrayDescType)(F90_DescTypekind)

• char∗(∗ getMangledName)(const char∗fun_name, const char∗mod_name)

• int(∗ printArrayDesc)(const void∗desc, int rank)

• int(∗ equalsArrayDesc)(const void∗desc2, const void∗desc1, int rank)

6.1.1 Detailed Description

CompilerCharacteristics contains function pointers that provide a generic interface tothe array descriptor library.

This struct contains a pointer for each function that is needed for manipulating fortranarray descriptors. TheF90_SetCompilerCharacteristics()function is used to initializethe function pointers to the correct vendor-specific function.

See also:F90_SetCompilerCharacteristics()

Generated on Mon Sep 29 17:57:07 2003 for Chasm by Doxygen

Page 29: Chasm Reference Manualchasm-interop.sourceforge.net/F90ArrayDesc_API.pdf · (for modifying an array pointer on return from a Fortran call to C). Note, it is the callers responsibility

6.1 F90_CompilerCharacteristics Struct Reference 25

Generated on Mon Sep 29 17:57:07 2003 for Chasm by Doxygen

Page 30: Chasm Reference Manualchasm-interop.sourceforge.net/F90ArrayDesc_API.pdf · (for modifying an array pointer on return from a Fortran call to C). Note, it is the callers responsibility

26 Chasm Data Structure Documentation

6.1.2 Field Documentation

6.1.2.1 int(∗ copyToArrayDescAndHidden)(void∗ src, int rank, F90_DescTypekind, void∗ dest, void∗ hidden )

6.1.2.2 void∗(∗ createArrayDesc)(void∗ desc, void∗ hidden, int rank,F90_DescTypekind )

6.1.2.3 int(∗ createArrayDescAndHidden)(void∗ src, int rank, F90_DescTypekind, void∗∗ desc, void∗∗ hidden )

6.1.2.4 int(∗ equalsArrayDesc)(const void∗ desc2, const void∗ desc1, int rank)

6.1.2.5 int(∗ freeArrayDescAndHidden)(F90_DescTypekind, void∗ desc, void∗hidden)

6.1.2.6 void∗(∗ getArrayBaseAddress)(const void∗ desc, int rank)

6.1.2.7 unsigned long(∗ getArrayDescSize)(int rank)

6.1.2.8 unsigned long(∗ getArrayExtent)(const void∗ desc, int rank, int dim)

6.1.2.9 long(∗ getArrayLowerBound)(const void∗ desc, int rank, int dim)

6.1.2.10 unsigned long(∗ getArraySize)(const void∗ desc, int rank)

6.1.2.11 long(∗ getArrayStrideMult )(const void∗ desc, int rank, int dim)

6.1.2.12 char∗(∗ getMangledName)(const char∗ fun_name, const char∗mod_name)

6.1.2.13 F90_HiddenDescType(∗ hiddenArrayDescType)(F90_DescTypekind)

6.1.2.14 int(∗ nullifyArrayDesc )(void∗ desc, int rank)

6.1.2.15 int(∗ printArrayDesc )(const void∗ desc, int rank)

6.1.2.16 int(∗ resetArrayDesc)(void∗ desc, void∗ base_addr, int rank, constlong∗ lowerBound, const unsigned long∗ extent, const long∗ strideMult)

6.1.2.17 int(∗ setArrayDesc)(void∗ desc, void∗ base_addr, int rank,F90_DescTypekind, F90_ArrayDataType data_type, unsigned longelement_size, const long∗ lowerBound, const unsigned long∗ extent,const long∗ strideMult )

6.1.2.18 int(∗ verifyArrayDesc)(const void∗ desc, int rank)Generated on Mon Sep 29 17:57:07 2003 for Chasm by Doxygen

Page 31: Chasm Reference Manualchasm-interop.sourceforge.net/F90ArrayDesc_API.pdf · (for modifying an array pointer on return from a Fortran call to C). Note, it is the callers responsibility

Chapter 7

Chasm File Documentation

7.1 CompilerCharacteristics.h File Reference

#include "F90ArrayDataType.h"

Data Structures

• structF90_CompilerCharacteristics

CompilerCharacteristics contains function pointers that provide a generic interfaceto the array descriptor library.

Enumerations

• enumF90_DescType{

F90_Array, F90_Pointer, F90_ArrayPointer, F90_ArrayPointerInDerived,

F90_DerivedPointer, F90_NonArray}

F90_DescType describes the type of the array descriptor.

• enumF90_HiddenDescType{ F90_Hidden, F90_NoHidden, F90_PointerWith-HiddenDesc}

F90_HiddenDescType describes the types of hidden descriptor arguments used by acompiler.

Page 32: Chasm Reference Manualchasm-interop.sourceforge.net/F90ArrayDesc_API.pdf · (for modifying an array pointer on return from a Fortran call to C). Note, it is the callers responsibility

28 Chasm File Documentation

Functions

• int F90_SetCompilerCharacteristics(F90_CompilerCharacteristics∗cc, constchar∗compiler)

Sets the CompilerCharacteristics function pointers for the given compiler.

7.1.1 Enumeration Type Documentation

7.1.1.1 enumF90_DescType

F90_DescType describes the type of the array descriptor.

The descriptor layout can depend on how the array-valued paramater is declared.

Enumeration values:F90_Array an array (e.g., integer :: a(:))

F90_Pointer a pointer (e.g., integer, pointer :: p)

F90_ArrayPointer an array pointer (e.g., integer, pointer :: pa(:) )

F90_ArrayPointerInDerived an array pointer within a derived type

F90_DerivedPointer pointer to a derived type

F90_NonArray not an array or pointer type

7.1.1.2 enumF90_HiddenDescType

F90_HiddenDescType describes the types of hidden descriptor arguments used by acompiler.

Hidden descriptors arguments may be passed at the end of the formal parameter list bysome compilers. Most compilers pass explicitly-defined array parameters via a descrip-tor (F90_NoHidden). However, in some instances, a compiler may place a pointer tothe base of the array in the formal parameter slot and pass a hidden descriptor argumentafter the formal parameters (F90_PointerWithHiddenDesc).

Enumeration values:F90_Hidden has a hidden param

F90_NoHidden has no hidden parameter

F90_PointerWithHiddenDescarray pointer passed with a hidden descriptor ar-gument

Generated on Mon Sep 29 17:57:07 2003 for Chasm by Doxygen

Page 33: Chasm Reference Manualchasm-interop.sourceforge.net/F90ArrayDesc_API.pdf · (for modifying an array pointer on return from a Fortran call to C). Note, it is the callers responsibility

7.1 CompilerCharacteristics.h File Reference 29

7.1.2 Function Documentation

7.1.2.1 int F90_SetCompilerCharacteristics (F90_CompilerCharacteristics∗cc, const char∗ compiler)

Sets the CompilerCharacteristics function pointers for the given compiler.

Delegates the actual setting of function pointers to the vendor-specific functionF90_-SetCCFunctions_F90Vendor(). The current set of supported compilers is {"Absoft","Alpha", "IBMXL", "Intel", "Lahey", "MIPSpro", "NAG", "SUNWspro"}.

Parameters:cc the CompilerCharacteristics struct

compiler the name of the compiler

Returns:0 if successful (nonzero on error)

Generated on Mon Sep 29 17:57:07 2003 for Chasm by Doxygen

Page 34: Chasm Reference Manualchasm-interop.sourceforge.net/F90ArrayDesc_API.pdf · (for modifying an array pointer on return from a Fortran call to C). Note, it is the callers responsibility

30 Chasm File Documentation

7.2 F90Vendor.h File Reference

Function declarations for the Chasm array-descriptor library.

#include <stdio.h >

#include <CompilerCharacteristics.h >

Functions

• void ∗ createArrayDesc_F90Vendor(void ∗desc, void∗hidden, int rank,F90_-DescTypedesc_type)

Creates an array descriptor by copying an existing array and hidden descriptor pair.

• int setArrayDesc_F90Vendor(void ∗desc, void∗base_addr, int rank,F90_Desc-Type desc_type, F90_ArrayDataType data_type, unsigned long element_size,const long∗lowerBound, const unsigned long∗extent, const long∗strideMult)

Sets the elements of a preallocated array descriptor.

• int resetArrayDesc_F90Vendor(void ∗desc, void∗base_addr, int rank, constlong∗lowerBound, const unsigned long∗extent, const long∗strideMult)

Resets the elements of a preallocated array descriptor.

• int copyToArrayDescAndHidden_F90Vendor(void ∗src, int rank,F90_Desc-Typedesc_type, void∗desc, void∗hidden)

Copies an array descriptor to an array and hidden descriptor pair.

• int createArrayDescAndHidden_F90Vendor(void ∗src, int rank,F90_DescTypedesc_type, void∗∗desc, void∗∗hidden)

Creates an array and hidden descriptor pair from an existing descriptor.

• int freeArrayDescAndHidden_F90Vendor(F90_DescTypedesc_type, void∗desc, void∗hidden)

Frees an array and hidden descriptor pair created by a call tocreateArrayDescAnd-Hidden_F90Vendor().

• void ∗ getArrayBaseAddress_F90Vendor(const void∗desc, int rank)

Returns a pointer to the base address of the array.

• unsigned longgetArraySize_F90Vendor(const void∗desc, int rank)

Returns the array size (in elements).

• longgetArrayLowerBound_F90Vendor(const void∗desc, int rank, int dim)

Returns the lower bound for the given dimension.

Generated on Mon Sep 29 17:57:07 2003 for Chasm by Doxygen

Page 35: Chasm Reference Manualchasm-interop.sourceforge.net/F90ArrayDesc_API.pdf · (for modifying an array pointer on return from a Fortran call to C). Note, it is the callers responsibility

7.2 F90Vendor.h File Reference 31

• unsigned longgetArrayExtent_F90Vendor(const void∗desc, int rank, int dim)

Returns the extent of the array for the given dimension (in elements).

• longgetArrayStrideMult_F90Vendor(const void∗desc, int rank, int dim)

Returns the distance between successive elements (in bytes).

• unsigned longgetArrayDescSize_F90Vendor(int rank)

Returns the size of an array descriptor (in bytes).

• F90_HiddenDescType hiddenArrayDescType_F90Vendor(F90_DescTypedesc_type)

Returns the type of hidden descriptor used by the compiler for the given descriptortype.

• int verifyArrayDesc_F90Vendor(const void∗desc, int rank)

Verify an array descriptor.

• int nullifyArrayDesc_F90Vendor(void ∗desc, int rank)

Nullify an array descriptor.

• int printArrayDesc_F90Vendor(const void∗desc, int rank)

Prints all fields in the array descriptor.

• int equalsArrayDesc_F90Vendor(const void∗desc1, const void∗desc2, intrank)

Determines if two descriptors are equal (equivalent).

• char∗ getMangledName_F90Vendor(const char∗fun_name, const char∗mod_-name)

Returns the symbol name of a module procedure, if the module name is not null,otherwise returns the name of the procedure.

• void F90_SetCCFunctions_F90Vendor(F90_CompilerCharacteristics∗cc)

Set CompilerCharacteristics function pointers for a particular compiler.

7.2.1 Detailed Description

Function declarations for the Chasm array-descriptor library.

Fortran 90 (and later) compilers pass array-valued parameters via an array descriptor(sometimes called a dope vector). The Chasm library provides C functions to get andset array-descriptor elements. This file declares the API for the array-descriptor library.

Generated on Mon Sep 29 17:57:07 2003 for Chasm by Doxygen

Page 36: Chasm Reference Manualchasm-interop.sourceforge.net/F90ArrayDesc_API.pdf · (for modifying an array pointer on return from a Fortran call to C). Note, it is the callers responsibility

32 Chasm File Documentation

Note that separate global functions are provided for each Fortran compiler with vendorname appended to the generic function name. In this file, F90Vendor is used in placeof a specific compiler vendor. A generic interface is available via function pointersin the F90_CompilerCharacteristicsstruct. These function pointers are set with theF90_SetCompilerCharacteristics()function.

Generated on Mon Sep 29 17:57:07 2003 for Chasm by Doxygen

Page 37: Chasm Reference Manualchasm-interop.sourceforge.net/F90ArrayDesc_API.pdf · (for modifying an array pointer on return from a Fortran call to C). Note, it is the callers responsibility

Index

Accessors,16

CompilerCharacteristics.h,27F90_Array,28F90_ArrayPointer,28F90_ArrayPointerInDerived,28F90_DerivedPointer,28F90_Hidden,28F90_NoHidden,28F90_NonArray,28F90_Pointer,28F90_PointerWithHiddenDesc,28

CompilerCharacteristics.hF90_DescType,28F90_HiddenDescType,28F90_SetCompilerCharacteristics,

29copyToArrayDescAndHidden

F90_CompilerCharacteristics,26copyToArrayDescAndHidden_-

F90Vendorgroup2,13

Create and Initialize,9createArrayDesc

F90_CompilerCharacteristics,26createArrayDesc_F90Vendor

group1,10createArrayDescAndHidden

F90_CompilerCharacteristics,26createArrayDescAndHidden_-

F90Vendorgroup2,14

equalsArrayDescF90_CompilerCharacteristics,26

equalsArrayDesc_F90Vendorgroup4,20

F90_ArrayCompilerCharacteristics.h,28

F90_ArrayPointerCompilerCharacteristics.h,28

F90_ArrayPointerInDerivedCompilerCharacteristics.h,28

F90_CompilerCharacteristics,23F90_CompilerCharacteristics

copyToArrayDescAndHidden,26createArrayDesc,26createArrayDescAndHidden,26equalsArrayDesc,26freeArrayDescAndHidden,26getArrayBaseAddress,26getArrayDescSize,26getArrayExtent,26getArrayLowerBound,26getArraySize,26getArrayStrideMult,26getMangledName,26hiddenArrayDescType,26nullifyArrayDesc,26printArrayDesc,26resetArrayDesc,26setArrayDesc,26verifyArrayDesc,26

F90_DerivedPointerCompilerCharacteristics.h,28

F90_DescTypeCompilerCharacteristics.h,28

F90_HiddenCompilerCharacteristics.h,28

F90_HiddenDescTypeCompilerCharacteristics.h,28

F90_NoHiddenCompilerCharacteristics.h,28

F90_NonArray

Page 38: Chasm Reference Manualchasm-interop.sourceforge.net/F90ArrayDesc_API.pdf · (for modifying an array pointer on return from a Fortran call to C). Note, it is the callers responsibility

34 INDEX

CompilerCharacteristics.h,28F90_Pointer

CompilerCharacteristics.h,28F90_PointerWithHiddenDesc

CompilerCharacteristics.h,28F90_SetCCFunctions_F90Vendor

group4,20F90_SetCompilerCharacteristics

CompilerCharacteristics.h,29F90Vendor.h,30freeArrayDescAndHidden

F90_CompilerCharacteristics,26freeArrayDescAndHidden_F90Vendor

group2,14

getArrayBaseAddressF90_CompilerCharacteristics,26

getArrayBaseAddress_F90Vendorgroup3,16

getArrayDescSizeF90_CompilerCharacteristics,26

getArrayDescSize_F90Vendorgroup4,20

getArrayExtentF90_CompilerCharacteristics,26

getArrayExtent_F90Vendorgroup3,16

getArrayLowerBoundF90_CompilerCharacteristics,26

getArrayLowerBound_F90Vendorgroup3,17

getArraySizeF90_CompilerCharacteristics,26

getArraySize_F90Vendorgroup3,17

getArrayStrideMultF90_CompilerCharacteristics,26

getArrayStrideMult_F90Vendorgroup3,17

getMangledNameF90_CompilerCharacteristics,26

getMangledName_F90Vendorgroup4,20

group1createArrayDesc_F90Vendor,10resetArrayDesc_F90Vendor,10

setArrayDesc_F90Vendor,11group2

copyToArrayDescAndHidden_-F90Vendor,13

createArrayDescAndHidden_-F90Vendor,14

freeArrayDescAndHidden_-F90Vendor,14

group3getArrayBaseAddress_-

F90Vendor,16getArrayExtent_F90Vendor,16getArrayLowerBound_-

F90Vendor,17getArraySize_F90Vendor,17getArrayStrideMult_F90Vendor,

17group4

equalsArrayDesc_F90Vendor,20F90_SetCCFunctions_-

F90Vendor,20getArrayDescSize_F90Vendor,

20getMangledName_F90Vendor,

20hiddenArrayDescType_-

F90Vendor,21nullifyArrayDesc_F90Vendor,21printArrayDesc_F90Vendor,21verifyArrayDesc_F90Vendor,21

hiddenArrayDescTypeF90_CompilerCharacteristics,26

hiddenArrayDescType_F90Vendorgroup4,21

Miscellaneous,19

nullifyArrayDescF90_CompilerCharacteristics,26

nullifyArrayDesc_F90Vendorgroup4,21

printArrayDescF90_CompilerCharacteristics,26

printArrayDesc_F90Vendor

Generated on Mon Sep 29 17:57:07 2003 for Chasm by Doxygen

Page 39: Chasm Reference Manualchasm-interop.sourceforge.net/F90ArrayDesc_API.pdf · (for modifying an array pointer on return from a Fortran call to C). Note, it is the callers responsibility

INDEX 35

group4,21Procedure Calls,13

resetArrayDescF90_CompilerCharacteristics,26

resetArrayDesc_F90Vendorgroup1,10

setArrayDescF90_CompilerCharacteristics,26

setArrayDesc_F90Vendorgroup1,11

verifyArrayDescF90_CompilerCharacteristics,26

verifyArrayDesc_F90Vendorgroup4,21

Generated on Mon Sep 29 17:57:07 2003 for Chasm by Doxygen


Top Related