🎉Community Raffle - Win $25

An exclusive raffle opportunity for active members like you! Complete your profile, answer questions and get your first accepted badge to enter the raffle.
Join and Win

Using gfortran to build user functions

User: "Altair Forum User"
Altair Employee
Updated by Altair Forum User

Submitted by Rachel Elsey on Tue, 08/02/2016 - 03:18

 

 

Hi,

I've been gfortran to build simple user functions in a dll's (actually simple user functions which call complex functions in legacy fortran code)

At the moment I have created just the main step function such as a simple example below.

I have some complex things working really well and I have got a long way just using this.


subroutine test1(param, insig, outsig)<br> !GCC$ ATTRIBUTES STDCALL, DLLEXPORT::test1<br> !==========================================================<br> !*<br> !* input(s): insig(1) = Input 1<br> !* insig(2) = Input 2<br> !* output(s): outsig(1) = Result<br> !* parameters: param(1) = Not Used<br> !*<br> !==========================================================<br> real*8 :: param(1), insig(2), outsig(2)<br> integer :: i<br> outsig(1) = (insig(1) + insig(2))/2.0<br> end subroutine

and built it with ...

gfortran -shared -fno-underscoring test1.f90 -o test1.dll

... and it works well.

However, when I add the further subroutines to the library e.g. test1SS to do some initialisation on the first step (at the moment I am passing in the step count as a parameter and using this to trigger initialisation) or try to create some parameters for the block I get stuck. It seems that although the functions are in the dll, VISSIM does not recognise them.

Does anyone have a working example in gfortran they can show me were they have done such things?

Best Regards

Rachel

Find more posts tagged with

Sort by:
1 - 2 of 21
    User: "Altair Forum User"
    Altair Employee
    OP
    Updated by Altair Forum User

    Submitted by pete on Wed, 08/03/2016 - 21:09.

    Hi Rachel,
    Please post the testSS function that is causing problems. It should work OK.

    User: "Altair Forum User"
    Altair Employee
    OP
    Updated by Altair Forum User

    Submitted by Rachel Elsey on Sun, 08/07/2016 - 12:08.

    Hi Pete,

    Thanks very much for your reply.

    After messing around with it a bit more gave up and switched to writing the user functions in C and then calling the FORTRAN from these. It proved easier than I though it would as I could use the TANK32 as an example. So I have a working example now.

    Rachel