Calling 32-bit FORTRAN dlls from 32-bit VB 
Author Message
 Calling 32-bit FORTRAN dlls from 32-bit VB

A lot of the following is Watcom-specific, so this might not be the
best place to post it.  However, the traffic on Powersoft's Watcom
fortran forum has been VERY light so I thought that I'd post this here
as well.

I'm using Watcom FORTRAN 11b to create a 32-bit dll that I'm calling from
VB4-32.  The FORTRAN application was originally an executable that read an
input file that I created in Visual Basic.  In order to convert my exe to a
dll, I changed the main routine to a subroutine which I call from VB.  
Initially, I hardcoded all of the data that I was reading from the input file,
but am now passing several key ones from VB and returning several arrays.

As I add arguments to the main subroutine in my dll, the pragma is
beginning to get very long.  Here it is, I've broken it into two lines:

*$pragma aux (__stdcall) TMMAIN "TModel" export parm(reference, reference,
reference, value, value, value,value)

Is there any way to get a line continuation on a pragma?  Is there any
limitation on it length?  I'm compiling my code with the /xl option.  Does
the pragma have the same line limits as the rest of my code? (132 characters,
from what I recall)

Also, I can't seem to pass an array of input data by value, only by reference.
What are the advantages and disadvantages of reference and value.  I figured
that since passing variables by value meant that the dll couldn't modify
the value that was in the VB calling program, that this would be desirable
for inputs.  My understanding is that passing variable by reference gives the
called program access to the chunk of memory that the caller program uses,
this would seem to reduce the ammount of memory required compared to passing
by value.

--
To respond via e-mail, please remove what's between Eric and Goforth in
my address in order to get my real e-mail address.



Wed, 18 Jun 1902 08:00:00 GMT  
 Calling 32-bit FORTRAN dlls from 32-bit VB

Quote:
>A lot of the following is Watcom-specific, so this might not be the
>best place to post it.  However, the traffic on Powersoft's Watcom
>FORTRAN forum has been VERY light so I thought that I'd post this here
>as well.

...
>Also, I can't seem to pass an array of input data by value, only by reference.
>What are the advantages and disadvantages of reference and value.  I figured
>that since passing variables by value meant that the dll couldn't modify
>the value that was in the VB calling program, that this would be desirable
>for inputs.  My understanding is that passing variable by reference gives the
>called program access to the chunk of memory that the caller program uses,
>this would seem to reduce the ammount of memory required compared to passing
>by value.

The immediate advantage of pass-by-reference here is that you only need
to pass the address of the first element of the array, as all the others
will immediately follow it. This is going to be much less memory (and
time?) -consuming than passing all the values in a possibly huge array.

Your understanding about how passing variables by reference may not be
guaranteed to be true by the strict semantics of the Fortran
specification, or indeed on all platforms, but it is how it works for
all Windows compilers that I've seen. I'm not sure you could call a
Fortran DLL from an arbitrary EXE at all if it didn't work this way.

Catherine.
--
Catherine Rees Lay



Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Building 32 bit DLL from 32 bit EXE

2. Division 32-Bit/32-Bit with 16-Bit Register

3. Calling 32-bit DLLs from 16-bit code

4. Loading a 32-Bit DLL into a 16-Bit DLL

5. 32 Bit ASM from 32 Bit Windows COBOL

6. 32 Bit ASM from 32 Bit Windows COBOL

7. top 32 bits of 64-bit product of two 32-bit integers

8. 32-bit ST/V outruns 32-bit ST80 on Intel

9. 32 bit ST communicating with 16 bit VB

10. Problems in calling Fortran DLLs from VB4 32-bit

11. Using 16 bit fortran libraries with 32 bit fortran

12. Wanted: 32-bit AWK DLL for VB app

 

 
Powered by phpBB® Forum Software