Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
29285 Discussions

Transition from Compaq Fortran to Intel

dytac
Beginner
601 Views

Hi,

I wrote a DLL using Compaq VF that I was able to call from an Excel VBA, and it worked fine (using windows XP, Excel 2003). However, when I transitioned to Vista / Excel 2007, I had to switch to Intel VF; now it doesn't work

I traced the problem to the DLL, which allit does is call a subroutine with a somewhat complex argument list: 1 char string, 2 integers, 1 array of real values, and2 arrays of strings. I had it all wokring previously, so I think that the compiler directives are correct. Below is the actual subroutine, which worked fine with CVF:

SUBROUTINE XLS2MYSUB(ifil,charinput,nlines,ncols,dc_dpou,dc_chou)
!
!-----------------------------------------------------------------------
! Compiler directives to export DLL
!DEC$ ATTRIBUTES DLLEXPORT,STDCALL :: XLS2MYSUB
!DEC$ATTRIBUTES ALIAS: 'XLS2MYSUB'::XLS2MYSUB
!DEC$ ATTRIBUTES REFERENCE :: ifil,charinput,nlines,ncols,dc_dpou,
& dc_chou
!
!-----------------------------------------------------------------------
! Parameter Definition
CHARACTER*200 ifil
INTEGER nlines,ncols,i
CHARACTER (LEN=200) charinput(nlines)
CHARACTER (LEN=15) dc_chou(20)
DOUBLE PRECISION dc_dpou(20,2)
!-----------------------------------------------------------------------
! Begin Code
! Set the maximum number of data items per line
ncols = 50
dc_dpou(1,1) = 999.999
!-----------------------------------------------------------------------
! Call MYSUB
!CALL MYSUB_SUB(ifil,charinput,nlines,ncols,dc_dpou,dc_chou)
!
!-----------------------------------------------------------------------
! Finished
END SUBROUTINE
!

So this returns the value of 999.999 to the Excel VBA without a problem.The actual call to the subroutine MYSUB_SUB was commented to isolate the problem, if I uncomment it, it stops working. So,I wanted to debug the arguments passed from the excel by writing them outto a file, but it seems I can't do something as simple as openinga file from the DLL, Iusedthe following lines:

open(unit=10,form='formatted',file='C:\temp\junk.dat')
write(10,*) ifil
close(10)

Iknow the above lines work becase I used them sucessfullyback onthe XP side.Is there something fundamentally different in the compiler directives between CFV and IVF? Why does the DLL stop working when I try to open a file? (it works with XP)

David

0 Kudos
2 Replies
Les_Neilson
Valued Contributor II
601 Views
Probably in your Fortran DLL project you need to specify the calling convention as CVF
compiler optiion /iface:cvf or
Project->Properties->Fortran->External Procedures : Calling Convention
Les
0 Kudos
dytac
Beginner
601 Views
Thanks for the reply, but this didn't work
However, in case you're intereseted I found the problem.
Under "Properties/Fortran/Libraries/ " the "Runtime Library" was set to "Debug Multithread DLL". I had to set it "Debug Multithread", and everything is working now.

0 Kudos
Reply