1module m_pivot_array 2 3 implicit none 4 5 public 6 7 ! Current size of the pivoting arrays 8 integer, save :: Npiv = 0 9 ! The pivoting array 10 integer, save, allocatable :: ipiv(:) 11 12 ! Counts of initializations 13 integer, save :: N_init = 0 14 15contains 16 17 ! We initialize the pivoting array for rotating the inversion 18 subroutine init_pivot(n) 19 integer, intent(in) :: n 20 21 N_init = N_init + 1 22 23 if ( n > Npiv ) then 24 Npiv = n 25 if ( allocated(ipiv) ) deallocate(ipiv) 26 allocate(ipiv(Npiv)) 27 end if 28 29 end subroutine init_pivot 30 31 subroutine clear_pivot() 32 33 N_init = N_init - 1 34 if ( N_init > 0 ) return 35 36 ! Force it to be zero 37 N_init = 0 38 39 ! Deallocate the pivoting array 40 deallocate(ipiv) 41 Npiv = 0 42 43 end subroutine clear_pivot 44 45end module m_pivot_array 46