Using: Windows 8.1 © 2013 64 bit OS, x64-based processor MS Office 2013 x64
Download the example from https://myengineeringworld.net/2014/03/fortran-dll-excel-vba.html
Copy the “Calling A FORTRAN DLL From Excel & VBA.xlsm” to the folder ..\MySample\Release\x64
Open the .xlsm Click on the “Enable Content” button
In VBA window, add “PtrSafe” to both Public Declare… Save and Close
As seen in https://www.silverfrost.com/32/ftn95/ftn95_personal_edition.aspx just downloaded the compiler FTN95 Personal Edition (FTN95PE) version 8.61 from http://www.ftn95.co.uk/ftn95/ftn95-8.61/ftn95_personal.exe
Run 'C:\Program Files (x86)\Silverfrost\FTN95\plato.exe'
File > New > Project: Project Type: Fortran DLL Name: MySample
OK
In “Project Explorer”, right click on “Source Files”, click on “Add New Item”
Type: Free format Fortran file Name: MyCode
And paste the content of the downloaded MyCode.f90 in a new .f95 source file
Configuration: Release Platform: x64
Build > Build
So far so good: “Compiling file: MyCode.f95 C:\Users\BarRErA\Documents\MySample\MyCode.F95(17) : warning 197 - Variable C has been declared but not used C:\Users\BarRErA\Documents\MySample\MyCode.F95(17) : warning 197 - Variable D has been declared but not used C:\Users\BarRErA\Documents\MySample\MyCode.F95(51) : warning 197 - Variable I has been declared but not used Compilation completed with no errors. Linking... Creating dynamic link library C:\Users\BarRErA\Documents\MySample\Release\x64\MySample.dl”
When opening the .xlsm, Excel crashes or a exception is thrown.
“FATAL ERROR > Silverfrost exception handler has failed”
Commenting the FRICTIONFACTOR on the .f95 code, compiling again, then going to Excel > tab Sub > clicking RUN (i.e. running the VBA Sub CallDoubleArray()), it works. The problem is with the function call.
I have no clue about what to do. It is my first contact with FORTRAN, I’m an engineer that wants to translate some thermodynamic calculations from VBA to Fortran.