5 USE v3_utilities,
ONLY:
assert
8 USE descriptor_mod,
ONLY: inhessian, nprocs, iam, siesta_comm
10 USE hessian,
ONLY: apply_precond, l_compute_hessian, apply_colscale
11 USE timer_mod,
ONLY: time_init_state, time_funci
12 USE nscalingtools,
ONLY: startglobrow, endglobrow, mpi_err, &
15 USE gmres_lib,
ONLY: truncate
19 INTEGER,
PRIVATE :: nsmin, nsmax
25 SUBROUTINE funct_island
33 USE siesta_displacement,
ONLY: update_upperv
40 REAL(dp) :: ton, toff, skston, skstoff
44 nsmin = max(1, startglobrow)
45 nsmax = min(endglobrow, ns)
58 time_init_state = time_init_state + (skstoff - skston)
62 IF (any(
xc .ne. 0) .or.
ALLOCATED(
buv_res))
THEN
67 CALL clear_field_perts
71 CALL assert(
gamma.NE.one,
'SIESTA REQUIRES gamma != 1')
84 'l_getfsq must be set to FALSE in Hessian')
110 time_funci = time_funci+(toff-ton)
112 END SUBROUTINE funct_island
115 SUBROUTINE getfsq(fsqout)
116 USE quantities,
ONLY: fsubsmncf, fsubumnsf, fsubvmnsf, &
118 fsubsmnsf, fsubumncf, fsubvmncf, &
124 REAL(dp),
INTENT(OUT) :: fsqout
131 temp(1) = sum(fsubsmncf(:,:,nsmin:nsmax)**2)
132 temp(2) = sum(fsubumnsf(:,:,nsmin:nsmax)**2)
133 temp(3) = sum(fsubvmnsf(:,:,nsmin:nsmax)**2)
135 temp(1) = temp(1) + sum(fsubsmnsf(:,:,nsmin:nsmax)**2)
136 temp(2) = temp(2) + sum(fsubumncf(:,:,nsmin:nsmax)**2)
137 temp(3) = temp(3) + sum(fsubvmncf(:,:,nsmin:nsmax)**2)
141 CALL mpi_allreduce(mpi_in_place,temp,3,mpi_real8,mpi_sum, &
168 CALL mpi_allreduce(mpi_in_place,temp,1,mpi_real8,mpi_sum, &
173 fsqout = temp(1)/sum(
vp_f)
175 END SUBROUTINE getfsq
184 REAL(dp),
INTENT(in) :: p(
neqs)
208 SUBROUTINE linesearch(xcmin, fsq_min)
213 REAL(dp),
INTENT(INOUT) :: xcmin(neqs)
214 REAL(dp),
INTENT(INOUT) :: fsq_min
224 lwrite = (iam .EQ. 0 .and.
lverbose)
226 90
FORMAT(/,1x,
'LINE SEARCH - SCAN ||X|| FOR MIN FSQ_NL',/,1x,15(
'-'), &
227 /,1x,
'ITER',7x,
'FSQ_NL',10x,
'||X||',9x,
'MAX|X|',10x,
'FAC')
231 fsq_min = huge(fsq_min)
245 ELSE IF (j .gt. 4)
THEN
251 facmin = facmin/sqrt2
257 1000
FORMAT(i5,4(3x,1pe12.3))
259 END SUBROUTINE linesearch
262 SUBROUTINE init_ptrs (xtarget, ptr1, ptr2, ptr3, ptr4, ptr5, ptr6)
266 REAL(dp),
TARGET,
INTENT(IN) :: xtarget(0:mpol,-ntor:ntor,ndims,ns)
267 REAL(dp),
POINTER,
DIMENSION(:,:,:) :: ptr1, ptr4
268 REAL(dp),
POINTER,
DIMENSION(:,:,:) :: ptr2, ptr5
269 REAL(dp),
POINTER,
DIMENSION(:,:,:) :: ptr3, ptr6
272 ptr1 => xtarget(:,:,1,:)
273 ptr2 => xtarget(:,:,2,:)
274 ptr3 => xtarget(:,:,3,:)
275 IF (ndims .EQ. 6)
THEN
276 ptr4 => xtarget(:,:,4,:)
277 ptr5 => xtarget(:,:,5,:)
278 ptr6 => xtarget(:,:,6,:)
281 END SUBROUTINE init_ptrs