- #1
davidfur
- 18
- 2
Hi guys,
On with my Fortran adventures...I'm trying to accomplish a simple task: assign a 2D array with some reals. Here's an excerpt from the code:
This just won't assign the 1.0-9.0 reals into gradmat and throws out the following:
I'm obviously doing something really stupid, but I just can't figure out what's wrong... need help!
Dave
On with my Fortran adventures...I'm trying to accomplish a simple task: assign a 2D array with some reals. Here's an excerpt from the code:
Fortran:
subroutine get_energy_and_grad(natoms_,coords,ereal,gradmat)
include 'cbka.blk'
include 'opt.blk'
integer, intent(in) :: natoms_
double precision, intent(in) :: coords(3*natoms_)
real*8, intent(out) :: ereal ! total energy
real*8, dimension(3,3), intent(out) :: gradmat
call vlist
call srtbon1
call encalc
ereal = estrc ! total energy
! write (*,*) 'natoms_ is: ', natoms_
write (*,*) 'size of gradmat is:', size(gradmat)
write (*,*) 'size of d is:', size(d)
write (*,*) 'shape of gradmat is:', shape(gradmat)
write (*,*) 'shape of d is:', shape(d)
gradmat = reshape((/ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0 /),(/3, 3/))
write(*,*) 'gradmat is: ', gradmat(2,3)
end subroutine get_energy_and_grad
This just won't assign the 1.0-9.0 reals into gradmat and throws out the following:
Code:
size of gradmat is: 9
size of d is: 7500
shape of gradmat is: 3 3
shape of d is: 3 2500
Program received signal SIGSEGV: Segmentation fault - invalid memory reference.
Backtrace for this error:
#0 0x7F3B8F78EE08
#1 0x7F3B8F78DF90
#2 0x7F3B8F0D54AF
#3 0x40151C in __reaxff_interface_MOD_get_energy_and_grad
#4 0x402C5E in MAIN__ at main.f90:?
Segmentation fault (core dumped)
I'm obviously doing something really stupid, but I just can't figure out what's wrong... need help!
Dave
Last edited: