Using gfortran to build user functions

Altair Forum User
Altair Forum User
Altair Employee
edited October 2020 in Community Q&A

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

Tagged:

Answers

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited August 2016

    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.

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited August 2016

    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