12-18-2009 12:11 PM
Hi, I don't think this is covered in the forums and am sorry if it is.
I have a FORTRAN dll with a parameter of type CHARACTER(99) which I'd like to assign from Labview. When I set up the parameter in the configure menu, the closest option I find is string, but this hasn't been acceptable and I get an error when I try it.
Thanks very much!
12-18-2009 11:37 PM
12-22-2009 08:45 AM
12-22-2009 09:12 AM
12-22-2009 09:17 AM
12-22-2009 10:17 AM
If I'm not mistaken is a fortran string the same as a LabVIEW string, preceded by an INT containing the number of characters.
A c-string is null-terminated.
Ton
12-22-2009 12:47 PM - edited 12-22-2009 12:47 PM
I'm not aware of such a Fortran convention. Generally in Fortran strings seem to be always fixed size allocated, like C fixed size character arrays and while they are indeed 0 terminated those 0 termination characters are considered part of the string when the string contents is used in a comparison. Same about the len() operator which seems to return the length of the allocated fixed size buffer, not the number of characters until the 0 character. All in all without using explicit string functions, string operations are quite a pain in Fortran.
Pascal has the notion of a prepended character to note the length of the string, but that is again not the same as LabVIEW which uses a 32 bit integer but also stores the strings inside a handle too, not a pointer.
12-22-2009 07:22 PM
Hi Paul. You might want to start here: http://www.math.utah.edu/software/c-with-fortran.html, although it may be tricky:
For mixed-language programming in C/C++ and Fortran, only the minimal intersection of their many data types can be relied on:
No other data types can be expected to be exchanged without serious compromise of portability.
Also, with respect to other comments Fortran CHARACTER variables are 8-bit per character and not preceded by an integer relating to length and counting, like MATLAB, starts at 1 for amusing confusion with LabVIEW and C users.
01-14-2010 09:13 AM
Hi Everyone,
Thanks for your responses. In the end I was able to make the solution work in which I:
1) Converted a labview string to an array of U8
2) Passed the array and the length of the string to my FORTRAN DLL
3) In the FORTRAN code, copied the passed in array, to a local one which is mapped to an array of CHARACTERS using the EQUIVALENCE statement
I'm not sure it's the most elegant, but it works. Thanks again everyone,
Paul
04-16-2012 09:49 PM
Can everyone tell me how to write the fortran code?
Thanks!