- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm trying to add !DEC$ ATTRIBUTES STDCALL, REFERENCE to about a dozen external calls and it is causing a memory leak type behavior (your program has encountered an error, do you want to send Microsoft...).
The program links to a third party, fortran static library that expects STDCALL, REFERENCE. I've used this library successfully for years with the calling convention of my program set to STDCALL, REFERENCE. However, for future changes, I want to change the calling convention to "default" and write interface statements for the dozen or so calls that I make to the static library. When I tried this, the debug version [appeared] to run correctly but the release version would crash. I changed the calling convention back to STDCALL, REFERENCE, commented out all of the interface blocks (everything worked) and then starting adding the interface blocks back in one at a time. Some appeared to work and some did not. For instance:
SUBROUTINE HEC_DATJUL (DATE, J, IERR)
INTERFACE
SUBROUTINE DATJUL_ (DATE, J, IERR)
!DEC$ ATTRIBUTES STDCALL, REFERENCE ::DATJUL_
INTEGER J, IERR
CHARACTER(*) DATE
END SUBROUTINE DATJUL_
END INTERFACE
INTEGER J, IERR
CHARACTER(*) DATE
CALL DATJUL_ (DATE, J, IERR)
RETURN
END
The release version crashes with the above code, but it will run if I comment out the interface/end interface block. DATJUL_ is the call to the library routine.
Curiously, when I added in some write statements around the call:
write (123,*) 'HEC_DATJUL 1'
CALL DATJUL_ (DATE, J, IERR)
write (123,*) 'HEC_DATJUL 2'
it suddenly started running in release mode. Even more curious, when I comment this interface block out and try a different, problamatic call, it also would work in release mode, but only with the write statements".
FUNCTION HEC_XREAL (STRING, I, L, IERR)
INTERFACE
FUNCTION XREAL_ (STRING, I, L, IERR)
!DEC$ ATTRIBUTES STDCALL, REFERENCE ::XREAL_
REAL XREAL_
INTEGER I, L, IERR
CHARACTER(*) STRING
END FUNCTION XREAL_
END INTERFACE
REAL HEC_XREAL
INTEGER I, L, IERR
CHARACTER(*) STRING
write (123,*) 'HEC_XREAL 1'
HEC_XREAL = XREAL_ (STRING, I, L, IERR)
write (123,*) 'HEC_XREAL 2'
RETURN
END
The above will run but will crash if the write statements are commented out.
Am I missing something about Interface blocks or the !DEC$ attributes? This program has a wide distribution. If there is a memory leak on my end, it is very well hidden when I don't use the interface blocks, but happening all of the time when I add them in. Also, I believe the third party library is a fortran wrapper around c++ code, but I've never had a problem with it before. My program and the library are using Intel 9.1.
Thanks for any help.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
![](/skins/images/06022F5BB6D2F28C8F102671A0F06E85/responsive_peak/images/icon_anonymous_message.png)
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page