@@ -249,7 +249,7 @@ subroutine prg_kernel_multirank_latte(KRes,KK0_bml,Res,FelTol,L,LMAX,NUMRANK,HO_
249
249
250
250
if (modulo (mdstep,update) .eq. 0 ) then
251
251
call prg_update_preconditioner(KK0_bml,vi(:,1 ),fi(:,1 ),Nr_atoms,threshold)
252
- endif
252
+ endif
253
253
254
254
deallocate (row1);deallocate (row2);deallocate (row_NA)
255
255
call bml_deallocate(KK0T_bml)
@@ -261,73 +261,73 @@ subroutine prg_kernel_multirank_latte(KRes,KK0_bml,Res,FelTol,L,LMAX,NUMRANK,HO_
261
261
call prg_timer_shutdown()
262
262
263
263
end subroutine prg_kernel_multirank_latte
264
-
264
+
265
265
subroutine prg_update_preconditioner (K0 ,v ,fv ,Nr_atoms ,threshold )
266
266
267
- implicit none
268
- type (bml_matrix_t), intent (inout ) :: K0
269
- real (dp), intent (in ) :: v(Nr_atoms),fv(Nr_atoms),threshold
270
- integer , intent (in ) :: Nr_atoms
271
- type (bml_matrix_t) :: v_bml,fv_bml,vt_bml,tmp1_bml,tmp2_bml
272
- type (bml_matrix_t) :: ones_bml,onest_bml,K0_update,K0_T
273
- real (dp) :: const,kthresh
274
- real (dp) :: ones(Nr_atoms)
275
- real (dp),allocatable :: row(:),norm(:)
276
- integer :: I
277
- character (20 ) :: bml_type
278
-
279
- bml_type = bml_get_type(K0)
280
- kthresh = 1.0_dp * 1e-5
281
- allocate (row(Nr_atoms))
282
- allocate (norm(Nr_atoms))
283
-
284
- call bml_zero_matrix(bml_type,bml_element_real,dp,Nr_atoms,Nr_atoms,v_bml)
285
- call bml_zero_matrix(bml_type,bml_element_real,dp,Nr_atoms,Nr_atoms,vt_bml)
286
- call bml_zero_matrix(bml_type,bml_element_real,dp,Nr_atoms,Nr_atoms,fv_bml)
287
- call bml_zero_matrix(bml_type,bml_element_real,dp,Nr_atoms,Nr_atoms,tmp1_bml)
288
- call bml_zero_matrix(bml_type,bml_element_real,dp,Nr_atoms,Nr_atoms,tmp2_bml)
289
- call bml_zero_matrix(bml_type,bml_element_real,dp,Nr_atoms,Nr_atoms,ones_bml)
290
- call bml_zero_matrix(bml_type,bml_element_real,dp,Nr_atoms,Nr_atoms,onest_bml)
291
- call bml_zero_matrix(bml_type,bml_element_real,dp,Nr_atoms,Nr_atoms,K0_update)
292
- call bml_zero_matrix(bml_type,bml_element_real,dp,Nr_atoms,Nr_atoms,K0_T)
293
-
294
- ones = 1.0_dp
295
- call bml_set_row(onest_bml,1 ,ones,0.0_dp )
296
- call bml_multiply(K0,ones_bml,tmp1_bml,1.0_dp ,0.0_dp ,threshold)
297
- const = 1.0_dp / (bml_trace_mult(onest_bml,tmp1_bml) + 1 )
298
-
299
- call bml_set_row(vt_bml,1 ,v,1.0_dp * 1e-10 )
300
- call bml_set_row(fv_bml,1 ,fv,1.0_dp * 1e-10 )
301
- call bml_transpose(vt_bml,v_bml)
302
-
303
- call bml_multiply(K0,v_bml,tmp1_bml,1.0_dp ,0.0_dp ,threshold)
304
- call bml_copy(vt_bml,tmp2_bml)
305
- call bml_multiply(fv_bml,K0,tmp2_bml,1.0_dp ,- 1.0_dp ,threshold)
306
- call bml_multiply(tmp1_bml,tmp2_bml,K0_update,const,0.0_dp ,kthresh)
307
- call bml_add(K0,K0_update,1.0_dp ,- 1.0_dp ,kthresh)
308
-
309
- call bml_multiply(onest_bml,K0,tmp1_bml,1.0_dp ,0.0_dp ,0.0_dp )
310
- call bml_get_row(tmp1_bml,1 ,norm)
311
- call bml_transpose(K0,K0_T)
312
- do I = 1 ,Nr_atoms
313
- call bml_get_row(K0_T,1 ,row)
314
- call bml_set_row(K0_T,1 ,row/ norm(I),1.0_dp * 1e-10 )
315
- enddo
316
- call bml_transpose(K0_T,K0)
317
-
318
- deallocate (row)
319
- deallocate (norm)
320
- call bml_deallocate(v_bml)
321
- call bml_deallocate(vt_bml)
322
- call bml_deallocate(fv_bml)
323
- call bml_deallocate(tmp1_bml)
324
- call bml_deallocate(tmp2_bml)
325
- call bml_deallocate(onest_bml)
326
- call bml_deallocate(ones_bml)
327
- call bml_deallocate(K0_update)
328
- call bml_deallocate(K0_T)
329
-
330
- end subroutine prg_update_preconditioner
267
+ implicit none
268
+ type (bml_matrix_t), intent (inout ) :: K0
269
+ real (dp), intent (in ) :: v(Nr_atoms),fv(Nr_atoms),threshold
270
+ integer , intent (in ) :: Nr_atoms
271
+ type (bml_matrix_t) :: v_bml,fv_bml,vt_bml,tmp1_bml,tmp2_bml
272
+ type (bml_matrix_t) :: ones_bml,onest_bml,K0_update,K0_T
273
+ real (dp) :: const,kthresh
274
+ real (dp) :: ones(Nr_atoms)
275
+ real (dp),allocatable :: row(:),norm(:)
276
+ integer :: I
277
+ character (20 ) :: bml_type
278
+
279
+ bml_type = bml_get_type(K0)
280
+ kthresh = 1.0_dp * 1e-5
281
+ allocate (row(Nr_atoms))
282
+ allocate (norm(Nr_atoms))
283
+
284
+ call bml_zero_matrix(bml_type,bml_element_real,dp,Nr_atoms,Nr_atoms,v_bml)
285
+ call bml_zero_matrix(bml_type,bml_element_real,dp,Nr_atoms,Nr_atoms,vt_bml)
286
+ call bml_zero_matrix(bml_type,bml_element_real,dp,Nr_atoms,Nr_atoms,fv_bml)
287
+ call bml_zero_matrix(bml_type,bml_element_real,dp,Nr_atoms,Nr_atoms,tmp1_bml)
288
+ call bml_zero_matrix(bml_type,bml_element_real,dp,Nr_atoms,Nr_atoms,tmp2_bml)
289
+ call bml_zero_matrix(bml_type,bml_element_real,dp,Nr_atoms,Nr_atoms,ones_bml)
290
+ call bml_zero_matrix(bml_type,bml_element_real,dp,Nr_atoms,Nr_atoms,onest_bml)
291
+ call bml_zero_matrix(bml_type,bml_element_real,dp,Nr_atoms,Nr_atoms,K0_update)
292
+ call bml_zero_matrix(bml_type,bml_element_real,dp,Nr_atoms,Nr_atoms,K0_T)
293
+
294
+ ones = 1.0_dp
295
+ call bml_set_row(onest_bml,1 ,ones,0.0_dp )
296
+ call bml_multiply(K0,ones_bml,tmp1_bml,1.0_dp ,0.0_dp ,threshold)
297
+ const = 1.0_dp / (bml_trace_mult(onest_bml,tmp1_bml) + 1 )
298
+
299
+ call bml_set_row(vt_bml,1 ,v,1.0_dp * 1e-10 )
300
+ call bml_set_row(fv_bml,1 ,fv,1.0_dp * 1e-10 )
301
+ call bml_transpose(vt_bml,v_bml)
302
+
303
+ call bml_multiply(K0,v_bml,tmp1_bml,1.0_dp ,0.0_dp ,threshold)
304
+ call bml_copy(vt_bml,tmp2_bml)
305
+ call bml_multiply(fv_bml,K0,tmp2_bml,1.0_dp ,- 1.0_dp ,threshold)
306
+ call bml_multiply(tmp1_bml,tmp2_bml,K0_update,const,0.0_dp ,kthresh)
307
+ call bml_add(K0,K0_update,1.0_dp ,- 1.0_dp ,kthresh)
308
+
309
+ call bml_multiply(onest_bml,K0,tmp1_bml,1.0_dp ,0.0_dp ,0.0_dp )
310
+ call bml_get_row(tmp1_bml,1 ,norm)
311
+ call bml_transpose(K0,K0_T)
312
+ do I = 1 ,Nr_atoms
313
+ call bml_get_row(K0_T,1 ,row)
314
+ call bml_set_row(K0_T,1 ,row/ norm(I),1.0_dp * 1e-10 )
315
+ enddo
316
+ call bml_transpose(K0_T,K0)
317
+
318
+ deallocate (row)
319
+ deallocate (norm)
320
+ call bml_deallocate(v_bml)
321
+ call bml_deallocate(vt_bml)
322
+ call bml_deallocate(fv_bml)
323
+ call bml_deallocate(tmp1_bml)
324
+ call bml_deallocate(tmp2_bml)
325
+ call bml_deallocate(onest_bml)
326
+ call bml_deallocate(ones_bml)
327
+ call bml_deallocate(K0_update)
328
+ call bml_deallocate(K0_T)
329
+
330
+ end subroutine prg_update_preconditioner
331
331
332
332
333
333
! Above routine but for development code
0 commit comments