The question relates to a common variable defined by means of a module and alocatable variables.
In oder to save time we have several 2D data arrays defined in a module. This means we assign the data once and perform the desired operations. In short we experience the following: In some subroutines arrays are constructed from the module (or global) data, i.e. one column of a matrix.When using the debugger the assigned matrix display no valid data (but a print to the screen is correct). I prepared a small sample code which shows this: module pmsyn_mod implicit none save real, allocatable,dimension(:,:) :: TF end module pmsyn_mod
subroutine assign_TF(m,n)
use pmsyn_mod
implicit none
integer,intent(in) :: m,n
integer :: i,j
real :: random
allocate(TF(m,n))
do i=1,n
do j=1,m
TF(j,i) = random()*1000.0d0
enddo
enddo
return
end subroutine assign_TF
subroutine T_new(m,n)
use pmsyn_mod
real,dimension(m) :: T1
real,pointer,dimension(:) :: T2
T1 = TF(:,1)
write(*,'(5F8.2)') T1 !---------------------T1 has only invalid values in the debugger
T2 => TF(:,1)
write(*,'(5F8.2)') T2 !---------------------T2 has valid values in the debugger
return
end subroutine T_new
program alloc
use pmsyn_mod
implicit none
integer :: m=5,n=2
! Assign a 5x2 matrix
call assign_TF(m,n)
! Use
call T_new(m,n)
end program alloc
My question: In the subroutine [color=green:f6bc8639ea]T_new[/color:f6bc8639ea] the arrays T1 and T2 are defined as real,dimension(m)real,pointer,dimension( : )respectively. Are both these definitions correct or is there something wrong in the debugger?