- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dear forum users,
I'm trying to convert an EXE to a DLL. The DLL compiles ok, and I can call it without problems from Java using the JNI.
But, while the EXE runs ok, the DLL seems to get stuck in a recursive routine. So the EXE can successfully complete the processing, but the DLL goes on forever. The EXE and DLL source codes are identical, except for the few modifications required to implement a DLL.
The code runs over a 2D grid, and for each grid cell (at position col, row) calls the following recursive subroutine. The subroutine gets stuck when the conditions for calling it again are not met for the first time.
recursive
subroutine dry_upward_cell(col, row)use
fill_mdlimplicit none
integer
col, row, jinteger
max_depth! ----------------------
sh_col = (/ 0, -1, -1, -1, 0, 1, 1, 1 /)
sh_row = (/ 1, 1, 0, -1, -1, -1, 0, 1 /)
max_depth = 2000
depth = depth + 1
if
(depth.le.max_depth)then do j = 1, 8 if(gDEM(col+sh_col(j),row+sh_row(j)).ne.esterno)then if(gW(col+sh_col(j),row+sh_row(j)).eq.huge)then if(mod(j,2).eq.1.and.gDEM(col+sh_col(j),row+sh_row(j)).ge.gW(col,row)+gEps1(col,row))thengW(col+sh_col(j),row+sh_row(j)) = gDEM(col+sh_col(j),row+sh_row(j))
call dry_upward_cell(col+sh_col(j),row+sh_row(j)) elseif(mod(j,2).eq.0.and.gDEM(col+sh_col(j),row+sh_row(j)).ge.gW(col,row)+gEps2(col,row))thengW(col+sh_ col(j),row+sh_row(j)) = gDEM(col+sh_col(j),row+sh_row(j))
call dry_upward_cell(col+sh_col(j),row+sh_row(j)) endif endif endif enddoendif
depth = depth - 1
return
end subroutine
Any idea why the EXE and the DLL do not behave in the same way, and the DLL gets stuck?
Thanks a lot
Alberto
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
Hi Steve,
thank you for your reply.
DEPTH is declared as integer in the module fill_mdl.
To debug the DLL, I open a dummy text file, and put some write statements around the code, to try see where the problem is. The last thing the code does is exiting the if(depth.le.max_depth)then, endif construct. After that, nothing: the recursive subroutine is not called again, nor the execution returns to the calling subroutine.
Could it be a problem related to the number of times the recursive subroutine is called? Is there some limit to that?
The interesting thing is that, as I mentioned, the executable version of this code runs flawlessy.
Alberto
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Steve,
please ignore my last post, I didn't look with enough attention. I now narrowed down the problem to another part of the code calling the recursive subroutine. The problem is not related to the recursive subroutine then, but toa do construct and some logical variables controlling it.
I will investigated the problem further and get back to you if I work out why the executable works and the DLL doesn't.
Sorry about wasting your time.
Alberto

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page