pass user defined type to Fortran com dll

pass user defined type to Fortran com dll

We have a Fortran DLL that currently is being used by a VB DotNet project.

The VB side has user defined structures that correspond to User Defined Kinds in fortran.

Currently, we are passing in arrays of user defined structures to the Fortran DLL using un-managed code.

The Fortran Dll writes out its results to text files and is working fine in that regard.

The Fortran function being called is a long-running procedure generating results for a simulation. It may take many minutes to complete.

We need to change the DLL to a COM Compliant dll so that we may interact with a COM object from the VB dotNet code in a

more sophisticated manor. We need to be able to monitor the status of the simulation and get the results as arrays of structures that we pass in ByRef when we make the call to the DLL.

We have created a test project using the Intel Compiler version 10.1.011

In that project we have defined the following structure

Module modTypeDefinitions

Public Structure ProbParamKind

Dim Na As Int32

Dim Nc As Int32

Dim Nstep As Int32

Dim MaxCycles As Int32

Dim AxialPts As Int32

End Structure

End Module

We have not been able to pass in this structure as an argument to a call named UseCustomType

Using the hie file we defined a method called UseCustomType. We added an argument named SingleProbParam

we have tried all c
ombinations we can think of in the argument's properties

Currently we have

Assumed-Shape = false

By Reference = true

Dimensions = 0

Fortran Type = TYPE(VARIANT)


Intent = [in/out]

Is Optional = false

When we call the function, we get the following exception:

System.ArgumentException was unhandled

Message="Value does not fall within the expected range."


We have tried every data type as the Fortran Type and IDL Type

and get different errors depending upon which type is selected.

Also, each time we change the hie file, we have to go into the system generated helper files and add use ifcore to the function in order to get the project to compile

function IDelsComServer_UseCustomType( ObjectData ,&

SingleProbParam) result (hresult)

use DelsComServer_Types

use ifcore 'added by hand

type(DelsComServer_InstanceData) ObjectData

!dec$ attributes reference :: ObjectData

TYPE(VARIANT), intent(in) :: SingleProbParam

; integer(long) hresult

end function

Since we cannot pass in even a single instance of this sturcture, we cannot pass in an array of these structures.

We have contacted Premire support and they sent us to this forum since they had no answer for us.

Our question then is this:

How do we configure the hie file to accept a user defined structure as an argument?

My guess is that the Fortran Type and IDL types need to be something different.

Do we need to be defining the structure as a pointer to a memory address?

Would this be INT_PTR_KIND?

Can we enter an option in the argument property's that are not in the pick list such as INT_PTR_KIND?

Any suggestions are welcomed.



2 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Please change my question. I was able to pass in a single member of the structure by specifying the argument as

Assumed-Shape = false

By Reference = true

Dimensions = 0

Fortran Type = INTEGER(INT_PTR_KIND())

IDL Type = IUnknown*

Intent = [in/out]

Is Optional = false

But now when trying to pass an array of these structures using this configuration

Assumed Shape = true

By Reference = True

Dimension[1] = 1:2

Dimensions = 1

Fortran Type = INTEGER(INT_PTR_KIND())

IDL Type = IUnknown*

Intent = [in,out]

Optional = false

we get a warning at compile time:

Warning1 warning MIDL2456 : SAFEARRAY(interface pointer) doesn't work using midl generated proxy : [ Parameter 'ArrayOfProbParam' of Procedure 'UseCustomTypeArray' ( Interface 'IDelsComServer' ) ]C:ArrayTesterArrayTesterDelsComServerGeneratedserver.idl23

And when we try to pass in the argument we get the exception:

Specified array was not of the expected type

Any clues as to where to look would be appreciated

Leave a Comment

Please sign in to add a comment. Not a member? Join today