The following program creates a window with a menu item and a button, both of which call the same callback function, f, which is defined in module m. The call-back function allocates memory to two arrays, x and y, that are defined as pointers. It then tries to call a subroutine, s, which declares the arrays as Intent(Out) rather than as pointers (I think that is legal, but I am not certain), but only one of the arrays is actually assigned any values.
If you click on the menu item the program runs, but it hangs if you click on the button. FTN95 does not typically seem to complain if an Intent(Out) argument is left unassigned, and this problem only seems to occur if the callback function is activated from a window.
Any suggestions? I suppose the place to start is to confirm whether or not the coding is valid Fortran. Change the arguments in the subroutine to pointers and the problem disappears. However, if I make an equivalent change to my original 70,000 line program the problem is not resolved. And since it took me 3 working days to isolate the problem below, I'm hoping that diagnosing what might be happening with this small program will help fix my larger program!
Module m
!
Real, Dimension(:), Pointer :: x => Null()
Real, Dimension(:), Pointer :: y => Null()
!
Contains
!
Function f()
Integer :: f
!
Allocate (x(2))
Allocate (y(2))
Print *, 'Call s2'
Call s (x, y)
Print *, 'Called S2'
f = 2
Return
End Function f
!
!
Subroutine s (x, y)
Real, Dimension(:), Intent(Out) :: x, y
!
Print *, 'Start'
x(:) = 1.0
Print *, 'End'
Return
End Subroutine s
End Module m
!
!
Winapp
Program cpt
!
Use clrwin, Only: winio@
Use m, Only: f
!
Integer :: ic_par ! - parent window control variable -
Integer :: iw ! - window argument -
Integer :: ih_con ! - ClearWin+ window handle -
!
! Open test window
iw = winio@('%ca@&', 'TEST')
iw = winio@('%mn[test]&', f)
iw = winio@('%cn%^5tt@%ff&', 'test', f)
iw = winio@('%ff %`50.10cw&', 0, ih_con)
iw = winio@('%lw', ic_par)
!
End Program cpt