Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with calling Fortran Dll from Compaq Visual Fortran

Status
Not open for further replies.

zeft

Programmer
Mar 12, 2008
2
GB
I'm using CVF and I'm trying to create Fortran dll and call some functions from it from another Fortran program. Here is my code for the program inside the DLL:
subroutine abc(a,b,c)
!DEC$ ATTRIBUTES DLLEXPORT :: abc
implicit none
integer, intent(in) :: a,b
integer, intent(out) :: c
real*8 pi
complex*16 ci
pi=3.1415D0
ci=dcmplx(0.D0,1.D0)
c=a+b-10*int(cdabs(cdexp(pi*ci))
return
end subroutine abc

And the code for the EXE is:

program main
!DEC$ attributes dllimport :: abc
implicit none
integer a,b,c

write(*,*) 'Enter a'
read(*,*) a
write(*,*) 'Enter b'
read(*,*) b
call abc(a,b,c)
write(*,*) a,'+',b,'- 10*int(cdabs(cdexp(pi*ci))','=',c
read(*,*)
stop
end program main

I've added lib-file of the dll in the project settings. The problem occurs when dll subroutine perform some operations with complex*16 numbers and EXE program throws critical message that it unabled to locate DFORRTD.dll. In simple variant, without any complex-number operations everything works very well. I've tried just about everything I can think of I can do with it.

There is probably something incredibly stupid that I'm missing, but I cannot figure out what it is. Each program was coded in it's own little project folder. When I tried importing the projects into the same workspace, the DLL would compile properly but the EXE would not. Any help would be greatly appreciated.
 
I've solved this problem. My mistake was that I compiled dll in the DEBUG mode, but the right thing is to compile in RELEASE.
 
Nice to know - I couldn't see anything wrong with what you were doing.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top