I have defined a new type called KhonShamOrbitals
as it appears below
type KhonShamOrbitals
integer :: NumUpOrbitals
integer :: NumDownOrbitals
real(dp), allocatable,dimension(:,:) :: PhiUp, PhiDown
real(dp),allocatable,dimension(:) :: EigenEnergiesUp,EigenEnergiesDown
real(dp),allocatable, dimension(:) :: DensityUp,DensityDown
end type KhonShamOrbitals
Then I initalize it somewhere like this
type(KhonShamOrbitals) :: orbitals
orbitals%NumUpOrbitals = 1
orbitals%NumDownOrbitals = 1
allocate(orbitals%PhiUp(orbitals%NumUpOrbitals,100))
allocate(orbitals%PhiDown(orbitals%NumDownOrbitals,100))
allocate(orbitals%EigenEnergiesUp(orbitals%NumUpOrbitals))
allocate(orbitals%EigenEnergiesDown(orbitals%NumDownOrbitals))
allocate(orbitals%DensityUp(100))
allocate(orbitals%DensityDown(100))
Just after that I call a subroutine
call ComputeDensity(1, 100, orbitals%PhiUp, orbitals%DensityUp)
And then the definition of the subroutine
subroutine ComputeDensity(NumOrbitals, NumPoints, orbitals, Density)
integer,intent(in) :: NumOrbitals,NumPoints
real(dp), intent(in) :: orbitals(NumOrbitals,NumPoints)
real(dp) :: Density(NumPoints)
real(dp) :: aux(NumPoints)
integer i
Density = 0
do i = 1, NumOrbitals
aux = orbitals(i,:)
Density = Density + aux**2
enddo
end subroutine ComputeDensity
The problem is that I am getting this error
Fortran runtime error: Allocatable actual argument 'orbitals' is not allocated when running the program.
It is compiled with gfortran 6.0.0 on MacOS X 10.10. Any ideas of why this is happening?