Skip to content

Commit 1f3c4b7

Browse files
committed
Finx handling of unallocated atom index
1 parent cc29e99 commit 1f3c4b7

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/fortran/lib/mod_geom_rw.f90

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1451,6 +1451,8 @@ subroutine add_atom(this, species, position, is_cartesian)
14511451
!! Optional. Boolean whether the position is in cartesian coordinates.
14521452

14531453
! Local variables
1454+
integer :: j
1455+
!! Loop index.
14541456
integer :: idx
14551457
!! The index of the species in the basis.
14561458
integer :: length
@@ -1487,7 +1489,11 @@ subroutine add_atom(this, species, position, is_cartesian)
14871489
deallocate(species_list)
14881490
else
14891491
allocate(atom_idx(this%spec(idx)%num+1))
1490-
atom_idx(1:this%spec(idx)%num) = this%spec(idx)%atom_idx
1492+
if(allocated(this%spec(idx)%atom_idx))then
1493+
atom_idx(1:this%spec(idx)%num) = this%spec(idx)%atom_idx
1494+
else
1495+
atom_idx(1:this%spec(idx)%num) = [ ( j, j = 1, this%spec(idx)%num ) ]
1496+
end if
14911497
atom_idx(this%spec(idx)%num+1) = this%natom
14921498
allocate(positions(this%spec(idx)%num+1,length))
14931499
positions = 0._real32

0 commit comments

Comments
 (0)