Skip to content

Commit

Permalink
add more overflow precautions when initialising excit gens
Browse files Browse the repository at this point in the history
  • Loading branch information
verena-neufeld committed Mar 21, 2019
1 parent ac34819 commit 175d0cf
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/excit_gens.f90
Original file line number Diff line number Diff line change
Expand Up @@ -386,8 +386,9 @@ subroutine alloc_alias_table_data_three_ind_t(alias_data, len_three, len_two, le
type(alias_table_data_three_ind_t), intent(inout) :: alias_data
integer, intent(in) :: len_one, len_two, len_three
integer :: ierr
integer(int_64) :: len_tot
integer(int_64) :: len_tot, len_tot_2
len_tot=(int(len_one,int_64)*len_two)*len_three
len_tot_2=int(len_one,int_64)*len_two

allocate(alias_data%weights(len_three, len_two, len_one), stat=ierr)
call check_allocate('alias_data%weights', len_tot, ierr)
Expand All @@ -396,7 +397,7 @@ subroutine alloc_alias_table_data_three_ind_t(alias_data, len_three, len_two, le
allocate(alias_data%aliasK(len_three, len_two, len_one), stat=ierr)
call check_allocate('alias_data%aliasK', len_tot, ierr)
allocate(alias_data%weights_tot(len_two, len_one), stat=ierr)
call check_allocate('alias_data%weights_tot', (len_one*len_two), ierr)
call check_allocate('alias_data%weights_tot', len_tot_2, ierr)

end subroutine alloc_alias_table_data_three_ind_t

Expand All @@ -407,10 +408,11 @@ subroutine alloc_alias_table_data_2indarray_three_ind_t(alias_data, len_three, a
type(alias_table_data_three_ind_t), intent(inout) :: alias_data
integer, intent(in) :: len_one, array_two(2), len_three
integer :: ierr, len_two
integer(int_64) :: len_tot
integer(int_64) :: len_tot, len_tot_2

len_two = array_two(2) - array_two(1) + 1
len_tot=(int(len_one,int_64)*len_two)*len_three
len_tot_2=int(len_one,int_64)*len_two

allocate(alias_data%weights(len_three, array_two(1):array_two(2), len_one), stat=ierr)
call check_allocate('alias_data%weights', len_tot, ierr)
Expand All @@ -419,7 +421,7 @@ subroutine alloc_alias_table_data_2indarray_three_ind_t(alias_data, len_three, a
allocate(alias_data%aliasK(len_three, array_two(1):array_two(2), len_one), stat=ierr)
call check_allocate('alias_data%aliasK', len_tot, ierr)
allocate(alias_data%weights_tot(array_two(1):array_two(2), len_one), stat=ierr)
call check_allocate('alias_data%weights_tot', (len_one*len_two), ierr)
call check_allocate('alias_data%weights_tot', len_tot_2, ierr)

end subroutine alloc_alias_table_data_2indarray_three_ind_t

Expand All @@ -430,9 +432,10 @@ subroutine alloc_alias_table_data_four_ind_t(alias_data, len_four, len_three, le
type(alias_table_data_four_ind_t), intent(inout) :: alias_data
integer, intent(in) :: len_one, len_two, len_three, len_four
integer :: ierr
integer(int_64) :: len_tot
integer(int_64) :: len_tot, len_tot_2

len_tot=((int(len_one,int_64)*len_two)*len_three)*len_four
len_tot_2=(int(len_one,int_64)*len_two)*len_three

allocate(alias_data%weights(len_four, len_three, len_two, len_one), stat=ierr)
call check_allocate('alias_data%weights', len_tot, ierr)
Expand All @@ -441,7 +444,7 @@ subroutine alloc_alias_table_data_four_ind_t(alias_data, len_four, len_three, le
allocate(alias_data%aliasK(len_four, len_three, len_two, len_one), stat=ierr)
call check_allocate('alias_data%aliasK', len_tot, ierr)
allocate(alias_data%weights_tot(len_three, len_two, len_one), stat=ierr)
call check_allocate('alias_data%weights_tot', (len_one*len_two*len_three), ierr)
call check_allocate('alias_data%weights_tot', len_tot_2, ierr)

end subroutine alloc_alias_table_data_four_ind_t
!--------------------------------------------------------------------------------!
Expand Down

0 comments on commit 175d0cf

Please sign in to comment.