- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm calling a function located in a fortran .dll file. This
function does nothing more than:
o input a matrix (3 by 7)
o print the elements of each row
o multiply the elements by 2, storing this to an output array
o prints the result to the screen
o return.
The C driver program:
o allocates and initializes an input and an output array
o prints the input array
o calls the fortran function, providing both arrays and their
dimensions.
o prints the result.
I find that when the fortran function returns, all values in the output
array are correctly set but the printout of the output array (done within fortran) hasn't happened. The input array printout appeared on the screen. but it's as if the write statements after multiply by 2 were
never executed. Very strange! Within C now, I then enter a do loop which prints out the values of the output matrix. The first time printf is called, the value of my do loop index is overwritten. It is fine before I step over printf, but is slammed during that function call. This exact code runs perfectly fine on a unix box. I've purified it and am certain neither the fortran nor the C code violates any memory boundaries.
Is there some issue related to VC++ and Visual fortran when it comes
to mixed language programming? Has this happened to anyone else? My
feeling is that the problem is happening in the fortran because the
printout fails to appear on the screen after the multiply by 2.
Thanks for any help,
function does nothing more than:
o input a matrix (3 by 7)
o print the elements of each row
o multiply the elements by 2, storing this to an output array
o prints the result to the screen
o return.
The C driver program:
o allocates and initializes an input and an output array
o prints the input array
o calls the fortran function, providing both arrays and their
dimensions.
o prints the result.
I find that when the fortran function returns, all values in the output
array are correctly set but the printout of the output array (done within fortran) hasn't happened. The input array printout appeared on the screen. but it's as if the write statements after multiply by 2 were
never executed. Very strange! Within C now, I then enter a do loop which prints out the values of the output matrix. The first time printf is called, the value of my do loop index is overwritten. It is fine before I step over printf, but is slammed during that function call. This exact code runs perfectly fine on a unix box. I've purified it and am certain neither the fortran nor the C code violates any memory boundaries.
Is there some issue related to VC++ and Visual fortran when it comes
to mixed language programming? Has this happened to anyone else? My
feeling is that the problem is happening in the fortran because the
printout fails to appear on the screen after the multiply by 2.
Thanks for any help,
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
First of all, how does the DLL routine "print" the data? Unless the calling program has allocated a console window, it's likely that any I/O to the "screen" will fail.
You also need to be aware that Visual Fortran, by default, uses the STDCALL calling mechanism. If you don't accomodate this in declarations either in the C or Fortran code, you'll corrupt the stack.
Please read the chapter on mixed-language programming in the Visual Fortran Programmer's Guide - you'll find it very helpful.
Steve
You also need to be aware that Visual Fortran, by default, uses the STDCALL calling mechanism. If you don't accomodate this in declarations either in the C or Fortran code, you'll corrupt the stack.
Please read the chapter on mixed-language programming in the Visual Fortran Programmer's Guide - you'll find it very helpful.
Steve
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page