Dear Paul
Yes. I have used it in a single solution with two projects. One for DLL and another one for EXE. So, as you said, VS automatically sorted the DLL and compiled. Thank you very much for your suggestions.
But I am not able to get what I intended to develop. Please excuse for the detailed illustration of the problem here. I am not sure whether the same subject was discussed in our forum earlier.
Objective:
What I am trying to build is nothing but the Reusable DLL Libraries with some Values to be supplied to the DLL library function and the results should be stored in the common area, where the Main Program can get it for further use.
Problem - 1:
The Problem here is that I am not able to pass a value through our global MODULE into DLL.
I am showing the DLL code, Main EXE code and the output while running as given below.
To demonstrate I have used the following Codes.
The DLL Library routine code MyDll.f95:
! --------------------------------------------------
! Silverfrost FTN95 for Microsoft Visual Studio
! Free Format FTN95 Source File
! --------------------------------------------------
module xyz
integer :: ii
end module xyz
program calldll
use xyz
integer:: val=1
print*, 'Dll Program calldll Started..'
print*,'common value ii received at calldll=',ii
print*, 'initialise val=',val
val=ii
print*,'Val assigned in calldll prog.. =',val
call printsub(val)
print*, 'control returned back to main'
print*, 'Ending dll program calldll'
end program calldll
subroutine printsub(rval)
use xyz
integer,optional:: rval
print*, 'Gotinside to subroutine'
print*,'Received value =',rval
print*,'module ii =',ii
rval=rval*5
print*, 'Printing the result=',rval
print*, 'returning back to program calldll'
end subroutine
The Main Executable Program Code SaiMainDll.f95:
module xyz
integer :: ii
end module xyz
program SaiMainDll
use xyz
!!include MyDll
implicit none
!!integer iy
print*, 'This is Main Program...'
print*, 'Calling the Dll subroutine library'
print*, 'Assigning value here in MasterProgram as 12'
print*, 'The idea is ii value will be received in DLL'
ii=12
call calldll()
!call printsub(ii)
print*, 'Control received back to Main...'
print*, 'Printing at Main'
end program SaiMainDll
While executing the Main EXE file SaiMainDll.exe, following are the output obtained:
D:\A02\C03\Proj01\DllRef\dll-01\OverallSoln\MainExe\Debug\Win32>MainExe.exe
This is Main Program...
Calling the Dll subroutine library
Assigning value here in MasterProgram as 12
The idea is ii value will be received in DLL
Dll Program calldll Started..
common value ii received at calldll= 0
initialise val= 1
Val assigned in calldll prog.. = 0
Gotinside to subroutine
Received value = 0
module ii = 0
Printing the result= 0
returning back to program calldll
control returned back to main
Ending dll program calldll
The results are not correct. Ideally the value for ii = 12 should be passed into the DLL (MyDll.f95) calldll() and it will inturn pass into the subroutine printsub(rval) which should display result as 12x5=60.
Where is the problem here? Why I am not able to get the value ii=12 into the MyDll.f95 in DLL library
Problem: 2
My intention of using MODULE in MyDll.f95 is to get the access to the COMMON storage data from the main Program. At the same time, I have to use that MOD file in Module path of SaiMainDll.f95, so that i can pass the value to ii as 12. As per our FTN95 standards, the MODULE should be used at one place. So, If I remove the MODULE definition in SaiMainDll.f95, I get the following Access Violation Error as given below: