LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Fortran array in Labview

Solved!
Go to solution

 

Hello!!
I´m having problems to link a fortran code in labview. 
When i use a simple integer or real number, the program works. But when i use a array the labview crashes.
 Actually i´m using the "library function node" to call the fortran dll and the GFORTRAN compiler for windows. I don´t know where´s the problem. I read some discussions about it but nobody offers a solution.
Please Help!!!

Hello!!I´m having problems to link a fortran code in labview. When i use a simple integer or real number, the program works. But when i use a array the labview crashes. Actually i´m using the "library function node" to call the fortran dll and the GFORTRAN compiler for windows. I don´t know where´s the problem. I read some discussions about it but nobody offers a solution.
Please Help!!!

 

0 Kudos
Message 1 of 11
(1,509 Views)

Is the array an input or output?

How is the terminal in the call library node configured?

 

Feel free to attach your LabVIEW code and dll.


LabVIEW Champion. It all comes together in GCentral GCentral
0 Kudos
Message 2 of 11
(1,504 Views)

ok, i wrote a simple code

simple code.jpg

And i tested a lot of diferents trivials programs to test. But the problem arrive when i try to manage the array inside the fortran compiler

simple code.jpg

 

My library functions node is configured like this:

 

simple code.jpg

 

Any help?

 

Thanks

 

0 Kudos
Message 3 of 11
(1,498 Views)
What is the size of the input array? What LabVIEW version is this? (Currently posting via phone, I'll look at it later in detail. Can you attach the dll?)

LabVIEW Champion. It all comes together in GCentral GCentral
0 Kudos
Message 4 of 11
(1,493 Views)

I´m using a labview 7.1 . The size of array defined on fortran is 100. the dll is attached along all other files.

Thanks

0 Kudos
Message 5 of 11
(1,488 Views)
Solution
Accepted by topic author Rjuliano

Try:

  • pre-allocate the array in LabVIEW (use Initialize Array)
  • change parameter A to "Array Data Pointer".
Message 6 of 11
(1,472 Views)

In addition to Saverio's advice, you seem to actually deal with SGL in the fortran DLL because of coding mistakes.

 

So: Change the representation in the call library setup to "4byte single" and wire a SGL array of the correct size to the input and you actually get a 10 as first element. (with DBL you get something ~1e300+)

 

(To retain DBL precision, you need to change compile options or write "A(1) = 10.D0" in the fortran code.)

 


LabVIEW Champion. It all comes together in GCentral GCentral
0 Kudos
Message 7 of 11
(1,454 Views)

Ok, thanks. It´s works for me. But the array that I enter is already done. How can i modify the elements of the array to do a operation?

0 Kudos
Message 8 of 11
(1,443 Views)

You would wire it to the input, but you need to make sure it has the correct size. For safety, you could insert a "reshape array" with the correct size. This will pad or trim to what the dll expects. You could also wire the size as an additional variable.

 

 

About the single precision fallback: it really depends on the compiler and the compile options. For example in Intel fortran, compiling with IA32 will use DBL but compiling with SSE3 options would cause a fallback to SGL unless we use an addtional compile option ("/real_size:64") .

 

I have investigated these issues in detail a while ago, have a look at some of the answers from the experts.

 

(LabVIEW is much nicer, because if always coerces to the richer representation with mixed operations). 😄


LabVIEW Champion. It all comes together in GCentral GCentral
Message 9 of 11
(1,437 Views)
Highlighted

Ok, Thank you so much. You made my life as much easier. Smiley Happy

0 Kudos
Message 10 of 11
(1,429 Views)