Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
7 Views

EXCEL - FORTRAN DLL

Possibly someone out there has experienced something similar?

Finally got beyond the "bad entry point" issue signified by error 453.

Excel is "talking" to the fortran DLL.

Issue is now the following:

1 - when the fortran is compiled without debugging, the DLL is able to be executed one time and it will work fine.  The second attempt to use the DLL returns 65535 values and obviously does NOT run correctly.

2 - when the fortran is compiled with debug and there is an effort to debug the DLL through connection through the spreadsheet, at the end of the run and just before leaving the fortran subroutine, the following error is thrown....."cannot find the VBE7.PDB".

3 - finally, when the code is compiled with debug and NOT stepped through and, instead, just executed, it throws an error 11, division by zero.

Incidentally, there are no "hits nor runs nor errors" evident with the same EXACT code when compiled through the console.

Runs every time.

Any help appreciated.

Thanks.

0 Kudos
9 Replies
Highlighted
Black Belt
7 Views

Reads very much to me as a

Reads very much to me as a calling convention mismatch. Did you specify ATTRIBUTES STDCALL, REFERENCE on your Fortran procedure?

There is a complete worked Excel example in the Parallel Studio XE for WIndows sample bundle.

Steve (aka "Doctor Fortran") - https://stevelionel.com/drfortran
0 Kudos
Highlighted
7 Views

Steve, the following is at

Steve, the following is at the start of the subroutine.

 

    SUBROUTINE NGCDT ( OUTPUT )
    
    !DEC$ ATTRIBUTES DLLEXPORT, STDCALL, REFERENCE, ALIAS: "NGCDT" :: NGCDT

 

0 Kudos
Highlighted
Black Belt
7 Views

How is OUTPUT declared, and

How is OUTPUT declared, and what is your declaration of the routine in Excel?

Steve (aka "Doctor Fortran") - https://stevelionel.com/drfortran
0 Kudos
Highlighted
7 Views

In excel:

In excel:

Public Declare PtrSafe Sub NGCDT Lib "C:\WINDOWS\System\MyDLL.dll" (ByRef MyIOArray As Double)
'Function that returns windows temp directory
Declare Function WinTempPath Lib "kernel32" Alias "GetTempPathA" (ByVal nBufferLength As Long, ByVal lpBuffer As String) As Long

Other statement in fortran is the following:

!DEC$ ATTRIBUTES REFERENCE :: OUTPUT

 

0 Kudos
Highlighted
Black Belt
7 Views

If, as suggested by the name,

If, as suggested by the name, MyIOArray is an array, then the function call needs to pass the first element MyIOArray(0) or MyIOArray(1), depending on whether you are using Option Base 1 in Excel.

In addition, you need to pass the number of elements in the array.

0 Kudos
Highlighted
7 Views

with Option Base 1

with Option Base 1

Call NGCDT(dIOData(1, 1))

did i understand you correctly?

0 Kudos
Highlighted
Valued Contributor III
7 Views

Quote:Guaglardi, Paul wrote:

Guaglardi, Paul wrote:

In excel:

Public Declare PtrSafe Sub NGCDT Lib "C:\WINDOWS\System\MyDLL.dll" (ByRef MyIOArray As Double)
'Function that returns windows temp directory
Declare Function WinTempPath Lib "kernel32" Alias "GetTempPathA" (ByVal nBufferLength As Long, ByVal lpBuffer As String) As Long

Other statement in fortran is the following:

!DEC$ ATTRIBUTES REFERENCE :: OUTPUT

 

What this not solved in this thread?  It seems the exact same procedures are involved, especially considering Quote #7 by OP:

https://software.intel.com/en-us/forums/intel-visual-fortran-compiler-for-windows/topic/758963

0 Kudos
Highlighted
Beginner
7 Views

Hi Dear Steve or Dear Dr.

Hi Dear Steve or Dear Dr. Fortran: I have been experiencing a similar problem, can please advise? My excel (32-bit) "can not fine the Dll file" when run the VBA code. However, once a while after I re-compile (or rebuilding) the Fortran program, I can debug inside the FORTRAN coding to link to excel to read inputs, and then outputs to excel. I tried both x86 and x64 compiling in Fortran (two available options for me) and got the same error information. My computer is a x64 system. I don't know what is the cause and how to debug it as everything else looks correct. Thank you very much! Best, and happy holiday season.

0 Kudos
Highlighted
Black Belt
7 Views

That error from VBA usually

That error from VBA usually means that a DLL that your DLL depends on cannot be found by searching the PATH environment variable. This is usually because you built a debug configuration and are running Excel from outside Visual Studio. Try building a Release configuration. An alternative is to set the project property Fortran > Libraries > Use Runtime Library to "Multithreaded (/MT):".

Steve (aka "Doctor Fortran") - https://stevelionel.com/drfortran
0 Kudos