Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Internal read in DLL

Robert_S_6
Beginner
840 Views
I am creating a Fortran DLL to be used by Access. I have gotten the dll to work with access without a problem. Now, I am trying to read from a string inside the dll and the program causes access to shut down. Here is the code for a test subroutine that i have been working with.

SUBROUTINE

TESTDATA ()

!dec$ attributes alias : "TESTDATA" :: TESTDATA

!dec$ attributes dllexport :: TESTDATA

!dec$ attributes stdcall :: TESTDATA

CHARACTER TESTSTRING*2000

CHARACTER TESTRWYKEY*15,TESTICAO*4,TESTIATA*3

TESTSTRING = "KPIT10R KPITPIT"

READ(UNIT=TESTSTRING,FMT=4000)TESTRWYKEY,TESTICAO,TESTIATA

4000 FORMAT(A15,A4,A3)

END SUBROUTINE

TESTDATA

When I use this same code in an executable, it works without a problem. Also, if i write the data to a file, and then read the file, there is not a problem. Has anyone encountered this before?

0 Kudos
18 Replies
Steven_L_Intel1
Employee
840 Views
What Fortran compiler and version of same are you using?
0 Kudos
Robert_S_6
Beginner
840 Views
IVF 8.0
0 Kudos
Steven_L_Intel1
Employee
840 Views
I can't think of a reason why this should be. Is the routine you posted exactly the one you're using? I ask because it has no outputs, so it seems unlikely that you'd call it from Access.
0 Kudos
Robert_S_6
Beginner
840 Views
The code that I posted is just test code, i started with passing string arrays back and forth from access, but then when my problem started, i tried to isolate the problem. that's when i created the sample dll that i posted. i have been using write statements to write to a text file and the text file is blank when the program finishes. I also use statements such as "program is here" when writing to the text file to further isolate the problem.
0 Kudos
Steven_L_Intel1
Employee
840 Views
Are you sure that the access violation happens in the routine, or is it perhaps after it returns to Access? You can debug a DLL - see here for instructions.
0 Kudos
Robert_S_6
Beginner
840 Views
I am sure that it is in the dll. When I remove the read statement, or read from a text file, the dll works fine. The program is compiled in Visual Studio.net. I don't know if that makes a difference or not. I have tried to use the debugger, but when i use msaccess.exe, i get a message that says, msaccess.exe does not contain debugging information (no symbols loaded).
0 Kudos
Robert_S_6
Beginner
840 Views
i found that the debugging issue is a confirmed bug in vs.net from the microsfot kb
0 Kudos
Jugoslav_Dujic
Valued Contributor II
840 Views
Hmmm... as I understand it, "xxx.exe does not contain debugging information" message is not a limiting factor -- anyway, you don't want to debug msaccess.exe but your dll, which you should be able to debug. So, you can ignore the message, place a breakpoint into your code, and perform actions in Access to trigger your routine -- the debugger will stop at the breakpoint.
Jugoslav
0 Kudos
Steven_L_Intel1
Employee
840 Views
I agree with Jugoslav. After setting the executable file name to that of Access, just set a breakpoint in your DLL routine and click GO. Access will start, and the debugger will gain control when your routine is called.
0 Kudos
Robert_S_6
Beginner
840 Views
Thanks for the help so far. I have the debugger working and this is what happened.
Unhandled exception at 0x098ab8b5 in MSACCESS.EXE: 0xC0000005: Access violation reading location 0x00000000.
Any clues?
Bob
0 Kudos
Jugoslav_Dujic
Valued Contributor II
840 Views
Well... not really. When does the AV occur? Before, during,or after your breakpoint is hit? How does the calling code in MSAccess look?
Jugoslav
0 Kudos
Robert_S_6
Beginner
840 Views

I use a simple form and button to call the dll

Private Declare Sub TESTDATA Lib "C:TEMPDll1.DLL" ()

Private Sub Command0_Click()
On Error GoTo Err_Command0_Click


Call TESTDATA


MsgBox "PROGRAM DONE"

Exit_Command0_Click:
Exit Sub

Err_Command0_Click:
MsgBox Err.Description
Resume Exit_Command0_Click

End Sub

The error seems to occur when the breakpoint is hit.

Bob

0 Kudos
Robert_S_6
Beginner
840 Views

I set my breakpoint on the following line

TESTSTRING = "KPIT10R KPITPIT"

and the when i continue to the next line is where the error occurs.

0 Kudos
Jugoslav_Dujic
Valued Contributor II
840 Views
Does it still crash if you add IOSTAT=iErr argument into READ statement? If not, what's the value of iErr?
Jugoslav
0 Kudos
Robert_S_6
Beginner
840 Views

I placed the IOSTAT line in my code, and the program still crashed at the read statement.

Bob

0 Kudos
Steven_L_Intel1
Employee
840 Views
At this point I suggest you submit the problem to Intel Premier Support - be sure to attach the necessary sources (including Access form and instructions for using) to reproduce the problem.
0 Kudos
g_f_thomas
Beginner
840 Views

Pardon the interjection but in the posted Fortran

CHARACTER TESTSTRING*2000

CHARACTER TESTRWYKEY*15,TESTICAO*4,TESTIATA*3

TESTSTRING = "KPIT10R KPITPIT"

READ(UNIT=TESTSTRING,FMT=4000)TESTRWYKEY,TESTICAO,TESTIATA

4000 FORMAT(A15,A4,A3)

can UNIT in a READ be a character string? I've long believed that it had to be an integer, eg, 5.

Maybe the storm has gottento me, :-).

Ciao

Gerry T.

0 Kudos
g_f_thomas
Beginner
840 Views
Duh, too much snow on the brain!
Missed the operative 'internal' read part. So the sole record of the file is of length 2000 or is it?.
Ciao,
Gerry T.
0 Kudos
Reply