I'm adding some functionality on to an open-source scientific code. I work with a lot of allocatables, but I'm having some trouble printing them properly. For example, I declare and allocate, and then use:
real(dp), allocatable :: psi_n_phi(:)
! some other stuff here
allocate(psi_n_phi(1:fock_info%nocc(isp)))
! nocc(isp) is simply equal to 1 in this context
! some other stuff here
do n = 1, fock_info%nocc(isp)
psi_n_phi(n) = dot_product(fock_info%psi(:, n, isp), p)
enddo
I later get an array mismatch and I am using gdb to figure out why. If I print:
(gdb) p psi_n_phi
$23 = (0)
But this clearly is not the case, as evidenced by:
(gdb) p psi_n_phi@1
$25 = (( 0) )
(gdb) p psi_n_phi@2
$26 = (( 0) ( 0) )
(gdb) p psi_n_phi@10
$28 = (( 0) ( 0) ( 0) ( 2.0162819006781271e-320) ( 2.2600760244771319e-316) ( 2.3792209431030402e-316) ( 6.9179818424594845e-310) ( 2.2598704931684619e-316) ( 6.9179818424672413e-310) ( 0) )
I got the information about using the @
notation from http://numericalnoob.blogspot.co.il/2012/08/fortran-allocatable-arrays-and-pointers.html. This is just about the only source I can find on the issue, although I have seen some other questions where people run into similar issues (but none of them were able to fix it).
Any ideas here? I would like to understand why printing it just comes out as ((0))
, and how I can get it to print like a normal array.