LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Calling compaq visual fortran dll from labview

All,
I would like to call a subroutine written in fortran from labview. I can make a fortran dynamic link library of the subroutine in CVF, for example

SUBROUTINE TEST (INT_ARG_IN, INT_ARG_OUT)
IMPLICIT NONE

!DEC$ ATTRIBUTES DLLEXPORT :: TEST
!DEC$ ATTRIBUTES ALIAS:'TEST' :: TEST

INTEGER INT_ARG_IN, INT_ARG_OUT

INT_ARG_OUT = INT_ARG_IN + 2

RETURN
END

How do I set up the call to this from labview
Function name is no problem, but what about the other settings??
I guess it should be winapi, return type??

I keep getting an exception error. Any help is much appreciated

TY, Martyn
Message 1 of 12
(4,978 Views)
Martyn,

Long ago I've made a simple example (see attached, LabVIEW 7.0), the Fortran code is listed on the diagram. If you built an application, don't forget to inlude the DLL you just made and also DFORRT.DLL unless the target system has fortran installed.

Let me know if you have any questions. Good luck!

LabVIEW Champion. It all comes together in GCentral GCentral
What does "Engineering Redefined" mean??
Message 2 of 12
(4,978 Views)
Thank you very much for your example it works just fine. You have implemented a function call

double precision function TESTF(a, b)

! Expose subroutine TESTF to users of this DLL
!
!DEC$ ATTRIBUTES DLLEXPORT::TESTF

double precision a, b, c
a=a*a
testf=a+b
end

Do you know if it is possible to implement a call to a subroutine also?

TY, Martyn
0 Kudos
Message 3 of 12
(4,978 Views)
(Sorry, the above example has some sloppy syntax errors, still it works fine).

Yes, subroutines are done exactly the same way.

LabVIEW Champion. It all comes together in GCentral GCentral
What does "Engineering Redefined" mean??
0 Kudos
Message 4 of 12
(4,978 Views)
How do I declare the return type in that case?
For example if my subroutine is declared as:

subroutine test(a,b)
real a,b
b = a*a
return
end

is the return type void in this case as there is no implicit return type???

Thanks again for your help,
Martyn
0 Kudos
Message 5 of 12
(4,978 Views)
martyn_wheeler wrote:

> How do I declare the return type in that case?
> For example if my subroutine is declared as:
>
> subroutine test(a,b)
> real a,b
> b = a*a
> return
> end
>
> is the return type void in this case as there is no implicit return
> type???

Not understanding Fortran at all I would however suppose that yes here
the retun type is void.

Rolf Kalbermatter
Rolf Kalbermatter
Averna BV
0 Kudos
Message 6 of 12
(4,978 Views)
Yes, for a subroutine, the correct return type is Void.
(Sorry, I only have a very fancy dll, but the attached image shows how it looks like in the diagram.)

LabVIEW Champion. It all comes together in GCentral GCentral
What does "Engineering Redefined" mean??
0 Kudos
Message 7 of 12
(4,978 Views)

I would like to connect LabVIEW with a CVF dll library. The examples from this thread just give me a Apache/Tomcat error. It appears that the forums website is broken!

0 Kudos
Message 8 of 12
(2,630 Views)

@dou.man wrote:

 It appears that the forums website is broken!


Yes.


LabVIEW Champion. It all comes together in GCentral GCentral
What does "Engineering Redefined" mean??
0 Kudos
Message 9 of 12
(2,626 Views)

Altenbach,

 

I am trying to do the similar thing here, to call a CVF .dll from LabView, and having issues need your help!

 

I tried first a very simple case of a^2+b, which my colleague wrote in CVF and compiled to .dll. I can call it correctly from LabView and it working ok.  Now we are working on a more complicated/real case, which , and it doesn't seem to work.

 

When I configure the Call Library Function Node, it gives me an error showing "This appliation has failed to start because DFORRT.DLL was not found. Re-installing the application may fix this problem". I can still configure it but it has broken arrow all the time and saying "Call Library Function Node 'xxx': Library not found or failed to load".

 

Can you give some advice? I attached both this two dll and the scripts of Forturn code that created them.

 

Thanks so much for your help!

 

Rgds,

 

Harry

Download All
0 Kudos
Message 10 of 12
(2,568 Views)