62
67
c Needs to be extended to store the sub-space vectors out-of-core
63
68
c at least while the product() routine is being executed.
65
integer iter, n, n2, nvec, nsub, isub, type, maxsub, ipm,
70
integer iter, n, n2, nvec, nsub, isub, type, maxsub,
68
73
c ... jochen: for convenience, now most arrays have two components.
69
74
c that might be changed later if memory becomes an issue
70
integer g_y, g_Ay, g_Ax(2), g_r(2), g_r2, g_a, g_bb,
71
& g_c, g_xold(2), g_Axold(2), g_Ax_im(2)
72
double precision rmax, rmax1, rmax2, acc
76
& g_Ax(2), g_r(2), g_r2,
78
& g_xold(2), g_Axold(2), g_Ax_im(2)
79
double precision rmax, rmax1, rmax2, acc,rmx(2)
74
81
logical odebug, debug, converge_precond
83
double precision omg(2)
76
86
c =================================================================
78
88
debug = (.false. .and. ga_nodeid().eq.0) ! for code development
80
92
c check input key if we should check for convergence
81
93
c after the preconditioner has been applied to the residual
82
94
if (.not. rtdb_get(rtdb, 'aoresponse:precond', mt_log, 1,
201
call ga_add(1.0d0, g_x(ipm), -1.0d0,
202
& g_xold(ipm), g_x(ipm))
238
call ga_add(1.0d0,g_x(ipm),
239
& -1.0d0,g_xold(ipm),
242
enddo ! end-loop-ncomp
207
245
c ... jochen: call product routine with initial or intermediate
208
246
c solution vector: g_x and g_Ax MUST have two components here
210
248
if (debug) write (6,*) 'calling product from ga_lkain_2cpl'
211
call product(acc, g_x, g_Ax, g_x_im, g_Ax_im, omega, limag,
212
& lifetime, gamwidth, ncomp)
250
if (ga_nodeid().eq.0) then
252
10 format('------ g_x-BEF-product(',i3,')---START')
255
if (ga_nodeid().eq.0)
256
& write(*,31) iter,ipm
257
31 format('-------g_x-re(',i3,',',i3,')--------- START')
258
call ga_print(g_x(ipm))
259
if (ga_nodeid().eq.0)
260
& write(*,32) iter,ipm
261
32 format('-------g_x-re(',i3,',',i3,')--------- END')
262
if (ga_nodeid().eq.0)
263
& write(*,33) iter,ipm
264
33 format('-------g_Ax-re(',i3,',',i3,')--------- START')
265
call ga_print(g_Ax(ipm))
266
if (ga_nodeid().eq.0)
267
& write(*,34) iter,ipm
268
34 format('-------g_Ax-re(',i3,',',i3,')--------- END')
270
if (ga_nodeid().eq.0)
271
& write(*,35) iter,ipm
272
35 format('-------g_x-im(',i3,',',i3,')--------- START')
273
call ga_print(g_x_im(ipm))
274
if (ga_nodeid().eq.0)
275
& write(*,36) iter,ipm
276
36 format('-------g_x-im(',i3,',',i3,')--------- END')
277
if (ga_nodeid().eq.0)
278
& write(*,37) iter,ipm
279
37 format('-------g_Ax-im(',i3,',',i3,')--------- START')
280
call ga_print(g_Ax_im(ipm))
281
if (ga_nodeid().eq.0)
282
& write(*,38) iter,ipm
283
38 format('-------g_Ax-im(',i3,',',i3,')--------- END')
286
if (ga_nodeid().eq.0) then
288
11 format('------ g_x-BEF-product(',i3,')---END')
296
& lifetime, gamwidth, ncomp)
298
if (ga_nodeid().eq.0) then
300
12 format('------ g_x-AFT-product(',i3,')---START')
303
if (ga_nodeid().eq.0)
304
& write(*,41) iter,ipm
305
41 format('-------g_x-re(',i3,',',i3,')--------- START')
306
call ga_print(g_x(ipm))
307
if (ga_nodeid().eq.0)
308
& write(*,42) iter,ipm
309
42 format('-------g_x-re(',i3,',',i3,')--------- END')
310
if (ga_nodeid().eq.0)
311
& write(*,43) iter,ipm
312
43 format('-------g_Ax-re(',i3,',',i3,')--------- START')
313
call ga_print(g_Ax(ipm))
314
if (ga_nodeid().eq.0)
315
& write(*,44) iter,ipm
316
44 format('-------g_Ax-re(',i3,',',i3,')--------- END')
318
if (ga_nodeid().eq.0)
319
& write(*,45) iter,ipm
320
45 format('-------g_x-im(',i3,',',i3,')--------- START')
321
call ga_print(g_x_im(ipm))
322
if (ga_nodeid().eq.0)
323
& write(*,46) iter,ipm
324
46 format('-------g_x-im(',i3,',',i3,')--------- END')
325
if (ga_nodeid().eq.0)
326
& write(*,47) iter,ipm
327
47 format('-------g_Ax-im(',i3,',',i3,')--------- START')
328
call ga_print(g_Ax_im(ipm))
329
if (ga_nodeid().eq.0)
330
& write(*,48) iter,ipm
331
48 format('-------g_Ax-im(',i3,',',i3,')--------- END')
334
if (ga_nodeid().eq.0) then
336
13 format('------ g_x-AFT-product(',i3,')---END')
214
341
if (debug) write (6,*) 'returning product from ga_lkain_2cpl'
234
363
c g_Ax = g_b if the system is solved. During the first cycle,
235
364
c g_Ax is calculated from the initial guess
236
365
call ga_add(1.0d0, g_b(ipm),
237
& -1.0d0, g_Ax(ipm), g_r(ipm)) ! The residual
367
& g_r(ipm)) ! The residual
240
369
enddo ! ipm = 1,ncomp
373
if (ga_nodeid().eq.0) then
375
49 format('----g_Ax(',i3,',',i3,')-----START')
377
call ga_print(g_Ax(ipm))
378
if (ga_nodeid().eq.0) then
380
50 format('----g_Ax(',i3,',',i3,')-----END')
382
if (ga_nodeid().eq.0) then
383
write(*,2779) ipm,iter
384
2779 format('----g_b(',i3,',',i3,')-----START')
386
call ga_print(g_b(ipm))
387
if (ga_nodeid().eq.0) then
388
write(*,2880) ipm,iter
389
2880 format('----g_b(',i3,',',i3,')-----END')
391
if (ga_nodeid().eq.0) then
392
write(*,2782) iter,ipm
393
2782 format('----g_r(',i3,',',i3,')-----START')
395
call ga_print(g_r(ipm))
396
if (ga_nodeid().eq.0) then
397
write(*,2783) iter,ipm
398
2783 format('----g_r(',i3,',',i3,')-----END')
243
402
c convergence checking:
244
403
c find the largest element of the residual either
245
404
c before or after the call to the preconditioner
247
if (converge_precond) then
248
call precond(g_r(1), -omega)
250
call precond(g_r(2), omega)
254
call ga_maxelt(g_r(1), rmax1)
256
call ga_maxelt(g_r(2), rmax2)
260
rmax = max(rmax1, rmax2)
408
if (converge_precond) then
410
call precond(g_r(ipm),omg(ipm))
412
endif ! end-if-converge_precond
416
call ga_maxelt(g_r(ipm),rmx(ipm))
422
rmax = max(rmax1, rmax2)
262
424
if (oprint .and. ga_nodeid().eq.0) then
263
425
write(6,3) iter, nsub+nvec, rmax, util_wallsec()
275
437
c (there were only two in ga_lkain, one with g_aX, one with g_r)
276
438
c for array g_r the preconditioner call is only necessary
277
439
c in case converge_precond is .false.
279
call precond(g_Ax(1), -omega)
280
if (.not.converge_precond) call precond(g_r(1), -omega)
282
call precond(g_Ax(2), omega)
283
if (.not.converge_precond) call precond(g_r(2), omega)
443
call precond(g_Ax(ipm),omg(ipm))
444
if (.not.converge_precond)
445
& call precond(g_r(ipm) ,omg(ipm))
287
c Copy the vectors to the subspace work area
289
call ga_copy_patch('n',
290
$ g_Ax(1), 1, n, 1, nvec,
291
$ g_Ay, 1, n, nsub+1, nsub+nvec)
294
call ga_copy_patch('n',
295
$ g_Ax(2), 1, n, 1, nvec,
296
$ g_Ay, n+1, n2, nsub+1, nsub+nvec)
298
call ga_copy_patch('n',
299
$ g_x(1), 1, n, 1, nvec,
300
$ g_y, 1, n, nsub+1, nsub+nvec)
303
call ga_copy_patch('n',
304
$ g_x(2), 1, n, 1, nvec,
305
$ g_y, n+1, n2, nsub+1, nsub+nvec)
308
c g_r2 is needed below for multiplication
309
call ga_copy_patch('n',
310
$ g_r(1), 1, n, 1, nvec,
311
$ g_r2, 1, n, 1, nvec)
313
call ga_copy_patch('n',
314
$ g_r(2), 1, n, 1, nvec,
315
$ g_r2, n+1, n2, 1, nvec)
450
c Copy the vectors to the subspace work area
453
call ga_copy_patch('n',
454
$ g_Ax(ipm),1 ,n ,1 ,nvec,
455
$ g_Ay ,1+dsp,n+dsp,nsub+1,nsub+nvec)
456
call ga_copy_patch('n',
457
$ g_x(ipm),1 ,n ,1 ,nvec,
458
$ g_y ,1+dsp,n+dsp,nsub+1,nsub+nvec)
459
call ga_copy_patch('n',
460
$ g_r(ipm),1 ,n ,1,nvec,
461
$ g_r2 ,1+dsp,n+dsp,1,nvec)
318
464
nsub = nsub + nvec
359
505
call ga_dgemm('n','n',n2,nvec,nsub,-1.0d0,
360
& g_Ay,g_c,1.0d0,g_r2)
506
& g_Ay,g_c,1.0d0,g_r2)
362
508
write(6,*) ' The update in the complement '
363
509
call ga_print(g_r2)
366
512
c copy components of g_r2 into g_r before adding g_r to g_x
369
call ga_copy_patch('n',
370
$ g_r2, 1, n, 1, nvec,
371
$ g_r(1), 1, n, 1,nvec)
373
call ga_copy_patch('n',
374
$ g_r2, n+1, n2, 1, nvec,
375
$ g_r(2), 1, n, 1,nvec)
515
call ga_copy_patch('n',
516
$ g_r2 ,1+dsp,n+dsp,1,nvec,
517
$ g_r(ipm),1 ,n ,1,nvec)
380
call ga_add(1.0d0, g_r(ipm), 1.0d0, g_x(ipm), g_x(ipm))
521
call ga_add(1.0d0, g_r(ipm),
384
527
call ga_dgemm('n','n',n2,nvec,nsub,1.0d0,
385
& g_y,g_c,0.0d0,g_r2)
528
& g_y,g_c,0.0d0,g_r2)
388
532
write(6,*) ' The update in the subspace '
389
533
call ga_print(g_r2)
392
c copy components of g_r2 into g_r before adding g_r to g_x
394
call ga_copy_patch('n',
395
$ g_r2, 1, n, 1, nvec,
396
$ g_r(1), 1, n, 1,nvec)
398
call ga_copy_patch('n',
399
$ g_r2, n+1, n2, 1, nvec,
400
$ g_r(2), 1, n, 1,nvec)
536
c copy components of g_r2 into g_r before adding g_r to g_x
539
call ga_copy_patch('n',
540
$ g_r2 ,1+dsp,n+dsp,1,nvec,
541
$ g_r(ipm),1 ,n ,1,nvec)
404
call ga_add(1.0d0, g_r(ipm), 1.0d0, g_x(ipm), g_x(ipm))
545
call ga_add(1.0d0, g_r(ipm),
408
551
if (.not. ga_destroy(g_a)) call errquit
758
935
c ... jochen: call product routine with initial or intermediate
759
936
c solution vector: g_x and g_Ax MUST have dimension two here
760
937
c even if only one of them is used
940
if (ga_nodeid().eq.0) then
941
write(*,112) iter,ipm
942
112 format('------ prod-g_x-1(',i3,',',i3,')------ START')
944
call ga_print(g_x(ipm))
945
if (ga_nodeid().eq.0) then
946
write(*,113) iter,ipm
947
113 format('------ prod-g_x-1(',i3,',',i3,')------ END')
949
if (ga_nodeid().eq.0) then
950
write(*,114) iter,ipm
951
114 format('------ prod-g_Ax-1(',i3,',',i3,')------ START')
953
call ga_print(g_Ax(ipm))
954
if (ga_nodeid().eq.0) then
955
write(*,115) iter,ipm
956
115 format('------ prod-g_Ax-1(',i3,',',i3,')------ END')
959
call ga_print(g_x_im(ipm))
960
call ga_print(g_Ax_im(ipm))
762
965
if (debug) write (6,*)
763
966
& 'calling product from ga_lkain_2cpl_damp'
764
967
call product(acc, g_x, g_Ax, g_x_im, g_Ax_im, omega, limag,
765
968
& lifetime, gamwidth, ncomp)
971
if (ga_nodeid().eq.0) then
972
write(*,116) iter,ipm
973
116 format('------ prod-g_x-2(',i3,',',i3,')------ START')
975
call ga_print(g_x(ipm))
976
if (ga_nodeid().eq.0) then
977
write(*,117) iter,ipm
978
117 format('------ prod-g_x-2(',i3,',',i3,')------ END')
980
if (ga_nodeid().eq.0) then
981
write(*,118) iter,ipm
982
118 format('------ prod-g_Ax-2(',i3,',',i3,')------ START')
984
call ga_print(g_Ax(ipm))
985
if (ga_nodeid().eq.0) then
986
write(*,119) iter,ipm
987
119 format('------ prod-g_Ax-2(',i3,',',i3,')------ END')
991
c if (iter.eq.3) then
992
c if (ga_nodeid().eq.0)
993
c & write(*,*) 'FA-STOP-convergence at 3rd iter'
766
997
if (debug) write (6,*)
767
998
& 'returning product from ga_lkain_2cpl_damp'
798
1031
c and assigned real and imaginary parts accordingly)
801
call ga_add(1.0d0, g_b(ipm),
802
& -1.0d0, g_Ax(ipm), g_r(ipm)) ! The residual, Real part
1035
call ga_add( 1.0d0,g_b(ipm),
1037
& g_r(ipm)) ! The residual, Real part
1040
if (ga_nodeid().eq.0) then
1041
write(*,120) iter,ipm
1042
120 format('------ prod-g_b(',i3,',',i3,')------ START')
1044
call ga_print(g_b(ipm))
1045
if (ga_nodeid().eq.0) then
1046
write(*,121) iter,ipm
1047
121 format('------ prod-g_b(',i3,',',i3,')------ END')
1049
if (ga_nodeid().eq.0) then
1050
write(*,122) iter,ipm
1051
122 format('------ prod-g_r(',i3,',',i3,')------ START')
1053
call ga_print(g_r(ipm))
1054
if (ga_nodeid().eq.0) then
1055
write(*,123) iter,ipm
1056
123 format('------ prod-g_r(',i3,',',i3,')------ END')
1058
endif ! end-if-debug
804
1060
if (lifetime) then
805
call ga_add(1.0d0, g_b_im(ipm),
806
& -1.0d0, g_Ax_im(ipm), g_r_im(ipm)) ! The residual, Im part
1061
call ga_add( 1.0d0,g_b_im(ipm),
1062
& -1.0d0,g_Ax_im(ipm),
1063
& g_r_im(ipm)) ! The residual, Im part
809
1066
enddo ! ipm = 1,ncomp
812
1068
c convergence checking:
813
1069
c find the largest element of the residual either
814
1070
c before or after the call to the preconditioner
816
1072
if (converge_precond) then
817
call precond(g_r(1), g_r_im(1), -omega, gamwidth)
819
call precond(g_r(2), g_r_im(2), omega, gamwidth)
1074
call precond(g_r(ipm),g_r_im(ipm),-omega,gamwidth)
1075
enddo ! end-loop-ipm
824
1078
call ga_maxelt(g_r(1), rmax1)
825
1079
if (ncomp.gt.1) then
826
1080
call ga_maxelt(g_r(2), rmax2)
863
1117
if (.not.converge_precond)
864
1118
& call precond(g_r(2), g_r_im(2), omega, gamwidth)
867
1121
if (debug) write (6,*) 'lkain3_damp: back from precond'
869
1123
c Copy the vectors to the subspace work area
871
call ga_copy_patch('n',
872
$ g_Ax(1), 1, n, 1, nvec,
873
$ g_Ay, 1, n, nsub+1, nsub+nvec)
874
if (ncomp.gt.1) call ga_copy_patch('n',
875
$ g_Ax(2), 1, n, 1, nvec,
876
$ g_Ay, n+1, n2, nsub+1, nsub+nvec)
878
call ga_copy_patch('n',
879
$ g_Ax_im(1), 1, n, 1, nvec,
880
$ g_Ay, n2+1, n3, nsub+1, nsub+nvec)
881
if (ncomp.gt.1) call ga_copy_patch('n',
882
$ g_Ax_im(2), 1, n, 1, nvec,
883
$ g_Ay, n3+1, n4, nsub+1, nsub+nvec)
885
call ga_copy_patch('n',
886
$ g_x(1), 1, n, 1, nvec,
887
$ g_y, 1, n, nsub+1, nsub+nvec)
888
if (ncomp.gt.1) call ga_copy_patch('n',
889
$ g_x(2), 1, n, 1, nvec,
890
$ g_y, n+1, n2, nsub+1, nsub+nvec)
892
call ga_copy_patch('n',
893
$ g_x_im(1), 1, n, 1, nvec,
894
$ g_y, n2+1, n3, nsub+1, nsub+nvec)
895
if (ncomp.gt.1) call ga_copy_patch('n',
896
$ g_x_im(2), 1, n, 1, nvec,
897
$ g_y, n3+1, n4, nsub+1, nsub+nvec)
900
if (debug) write (6,*) 'lkain3_damp: vec to sub complete'
902
c g_r2 is needed below for multiplication
903
call ga_copy_patch('n',
904
$ g_r(1), 1, n, 1, nvec,
905
$ g_r2, 1, n, 1, nvec)
906
if (ncomp.gt.1) call ga_copy_patch('n',
907
$ g_r(2), 1, n, 1, nvec,
908
$ g_r2, n+1, n2, 1, nvec)
910
call ga_copy_patch('n',
911
$ g_r_im(1), 1, n, 1, nvec,
912
$ g_r2, n2+1, n3, 1, nvec)
913
if (ncomp.gt.1) call ga_copy_patch('n',
914
$ g_r_im(2), 1, n, 1, nvec,
915
$ g_r2, n3+1, n4, 1, nvec)
918
if (debug) write (6,*) 'lkain3_damp: r2 complete'
1125
c ---- FA-copy ((Ax,Ax_im),(x,x_im)) -> (Ay,y) ------ START
1128
if (ga_nodeid().eq.0)
1129
& write(*,*) '---------g_x-0(',iter,')-----START'
1130
call ga_print(g_x(1))
1131
if (ga_nodeid().eq.0)
1132
& write(*,*) '---------g_x-0(',iter,')-----END'
1133
if (ga_nodeid().eq.0)
1134
& write(*,*) '---------g_x_im-0(',iter,')-----START'
1135
call ga_print(g_x_im(1))
1136
if (ga_nodeid().eq.0)
1137
& write(*,*) '---------g_x_im-0(',iter,')-----END'
1138
if (ga_nodeid().eq.0)
1139
& write(*,*) '---------g_Ax-0(',iter,')-----START'
1140
call ga_print(g_Ax(1))
1141
if (ga_nodeid().eq.0)
1142
& write(*,*) '---------g_Ax-0(',iter,')-----END'
1143
if (ga_nodeid().eq.0)
1144
& write(*,*) '---------g_r-0(',iter,')-----START'
1145
call ga_print(g_r(1))
1146
if (ga_nodeid().eq.0)
1147
& write(*,*) '---------g_r-0(',iter,')-----END'
1148
endif ! end-if-debug1
1150
call copy_AxxtoAyy(g_Ax,g_Ax_im,
1159
c ---- FA-copy ((Ax,Ax_im),(x,x_im)) -> (Ay,y) ------ END
1160
c ----- FA--- (g_r,g_r_im) -> g_r2 ---------- START
1162
call copy_rtor2(g_r2,
1169
c ----- FA--- (g_r,g_r_im) -> g_r2 ---------- END
1171
if (ga_nodeid().eq.0)
1172
& write(*,*) '---------g_y-0(',iter,')-----START'
1174
if (ga_nodeid().eq.0)
1175
& write(*,*) '---------g_y-0(',iter,')-----END'
1176
if (ga_nodeid().eq.0)
1177
& write(*,*) '---------g_Ay-0(',iter,')-----START'
1179
if (ga_nodeid().eq.0)
1180
& write(*,*) '---------g_Ay-0(',iter,')-----END'
1181
if (ga_nodeid().eq.0)
1182
& write(*,*) '---------g_r2-0(',iter,')-----START'
1184
if (ga_nodeid().eq.0)
1185
& write(*,*) '---------g_r2-0(',iter,')-----END'
1186
endif ! end-if-debug1
920
1188
nsub = nsub + nvec
922
1190
c Form and solve the subspace equations using SVD in order
952
1218
c realistic examples (maxsub << n) there is only a little
953
1219
c advantage and in the precence of real noise in the products
954
1220
c screening with a realistic threshold is important.
1222
if (ga_nodeid().eq.0)
1223
& write(*,*) '---------g_a(',iter,')-----START'
1225
if (ga_nodeid().eq.0)
1226
& write(*,*) '---------g_a(',iter,')-----END'
1227
if (ga_nodeid().eq.0)
1228
& write(*,*) '---------g_bb(',iter,')-----START'
1230
if (ga_nodeid().eq.0)
1231
& write(*,*) '---------g_bb(',iter,')-----END'
1232
endif ! end-if-debug1
1233
c ++++++++++++++++++++++++++++++++++++++++++++++++++++
1234
c ++++++++++++++ real linear solver ++++++++++++++++++
956
1235
call ga_svd_solve_seq(g_a,g_bb,g_c,1d-14)
1237
c if (ga_nodeid().eq.0)
1238
c & write(*,*) 'FA-test ga_lu_solve ...'
1239
c call ga_lu_solve('n',g_a,g_bb)
1241
c stat_solve=ga_solve(g_a,g_bb)
1242
c if (ga_nodeid().eq.0) then
1243
c write(*,14) stat_solve
1244
c 14 format('FA-test ga_lu_solve(Choleski->LU) stat=',i3)
1246
c call ga_copy(g_bb,g_c)
1247
c ++++++++++++++++++++++++++++++++++++++++++++++++++++
1248
c ++++++++++++++++++++++++++++++++++++++++++++++++++++
1250
if (ga_nodeid().eq.0)
1251
& write(*,*) '---------g_c(',iter,')-----START'
1253
if (ga_nodeid().eq.0)
1254
& write(*,*) '---------g_c(',iter,')-----END'
1255
endif ! end-if-debug1
957
1257
if (odebug) call ga_print(g_c)
959
c Form and add the correction, in parts, onto the solution
1259
c Form and add the correction, in parts, onto the solution
1262
if (ga_nodeid().eq.0)
1263
& write(*,*) '---------g_r2-BEF(',iter,')-----START'
1265
if (ga_nodeid().eq.0)
1266
& write(*,*) '---------g_r2-BEF(',iter,')-----END'
1267
endif ! end-if-debug1
962
1269
call ga_dgemm('n','n',n4,nvec,nsub,-1.0d0,
963
& g_Ay,g_c,1.0d0,g_r2)
966
write(6,*) ' The update in the complement '
969
if (debug) write (6,*) 'lkain3_damp: after dgemm'
1270
& g_Ay,g_c,1.0d0,g_r2)
1273
if (ga_nodeid().eq.0)
1274
& write(*,*) '---------g_r2-AFT(',iter,')-----START'
1276
if (ga_nodeid().eq.0)
1277
& write(*,*) '---------g_r2-AFT(',iter,')-----END'
1278
if (ga_nodeid().eq.0)
1279
& write(*,*) '---------g_x-BEF-1(',iter,')-----START'
1281
if (ga_nodeid().eq.0)
1282
& write(*,*) '---------g_x-BEF-1(',iter,')-----END'
1283
endif ! end-if-debug1
971
1285
c copy components of g_r2 into g_r before adding g_r to g_x
972
call ga_copy_patch('n',
973
$ g_r2, 1, n, 1, nvec,
974
$ g_r(1), 1, n, 1,nvec)
975
if (ncomp.gt.1) call ga_copy_patch('n',
976
$ g_r2, n+1, n2, 1, nvec,
977
$ g_r(2), 1, n, 1,nvec)
979
call ga_copy_patch('n',
980
$ g_r2, n2+1, n3, 1, nvec,
981
$ g_r_im(1), 1, n, 1,nvec)
982
if (ncomp.gt.1) call ga_copy_patch('n',
983
$ g_r2, n3+1, n4, 1, nvec,
984
$ g_r_im(2), 1, n, 1,nvec)
987
if (debug) write (6,*) 'lkain3_damp: r2 copied'
990
call ga_add(1.0d0, g_r(ipm), 1.0d0, g_x(ipm), g_x(ipm))
992
& call ga_add(1.0d0, g_r_im(ipm),
993
& 1.0d0, g_x_im(ipm), g_x_im(ipm))
1286
call update_g_x1(g_r2, ! in :
1287
& g_x, ! in/ou: updated
1288
& g_x_im, ! in/ou: updated
1289
& ncomp, ! in : nr. components
1290
& nvec, ! in : (x,y,z) = 3
1291
& n, ! in : size of block (e.g. RE1,RE2,IM1 or IM2)
1292
& lifetime)! in : = .true. if complex
1294
if (ga_nodeid().eq.0)
1295
& write(*,*) '---------g_x-AFT-1(',iter,')-----START'
1297
if (ga_nodeid().eq.0)
1298
& write(*,*) '---------g_x-AFT-1(',iter,')-----END'
1299
endif ! end-if-debug1
997
1301
call ga_dgemm('n','n',n4,nvec,nsub,1.0d0,
998
& g_y,g_c,0.0d0,g_r2)
1001
write(6,*) ' The update in the subspace '
1004
if (debug) write (6,*) 'lkain3_damp: subspace updated'
1302
& g_y,g_c,0.0d0,g_r2)
1304
if (ga_nodeid().eq.0)
1305
& write(*,*) '---------g_y c(',iter,')-----START'
1307
if (ga_nodeid().eq.0)
1308
& write(*,*) '---------g_y c(',iter,')-----END'
1309
endif ! end-if-debug1
1007
1310
c copy components of g_r2 into g_r before adding g_r to g_x
1008
call ga_copy_patch('n',
1009
$ g_r2, 1, n, 1, nvec,
1010
$ g_r(1), 1, n, 1,nvec)
1011
if (ncomp.gt.1) call ga_copy_patch('n',
1012
$ g_r2, n+1, n2, 1, nvec,
1013
$ g_r(2), 1, n, 1,nvec)
1015
call ga_copy_patch('n',
1016
$ g_r2, n2+1, n3, 1, nvec,
1017
$ g_r_im(1), 1, n, 1,nvec)
1018
if (ncomp.gt.1) call ga_copy_patch('n',
1019
$ g_r2, n3+1, n4, 1, nvec,
1020
$ g_r_im(2), 1, n, 1,nvec)
1024
call ga_add(1.0d0, g_r(ipm), 1.0d0, g_x(ipm), g_x(ipm))
1026
& call ga_add(1.0d0, g_r_im(ipm),
1027
& 1.0d0, g_x_im(ipm), g_x_im(ipm))
1030
if (debug) write (6,*) 'lkain3_damp: gr to gx complete'
1311
call update_g_x1(g_r2, ! in :
1312
& g_x, ! in/ou: updated
1313
& g_x_im, ! in/ou: updated
1314
& ncomp, ! in : nr. components
1315
& nvec, ! in : (x,y,z) = 3
1316
& n, ! in : size of block (e.g. RE1,RE2,IM1 or IM2)
1317
& lifetime)! in : = .true. if complex
1320
if (ga_nodeid().eq.0)
1321
& write(*,*) '---------g_x-AFT-2(',iter,')-----START'
1323
if (ga_nodeid().eq.0)
1324
& write(*,*) '---------g_x-AFT-2(',iter,')-----END'
1325
endif ! end-if-debug1
1032
1327
if (.not. ga_destroy(g_a)) call errquit
1033
1328
& ('lkain_2cpl: a',0, GA_ERR)
1034
1329
if (.not. ga_destroy(g_bb)) call errquit
1039
1334
c Reduce the subspace as necessary
1336
if (ga_nodeid().eq.0) then
1337
write(*,17) iter,nsub,maxsub,nvec,n4
1338
17 format('(iter,nsub,maxsub,nvec,n4)=(',
1339
& i3,',',i4,',',i4,',',i3,',',i4,')')
1343
write(*,*) 'STOP-test-linsolver'
1346
endif ! end-if-debug1
1041
1348
if (nsub .eq. maxsub) then
1042
do isub = nvec+1, maxsub, nvec
1045
call ga_copy_patch('n',
1046
$ g_Ay, 1, n, isub, isub+nvec-1,
1047
$ g_Ax(1), 1, n, 1, nvec)
1049
call ga_copy_patch('n',
1050
$ g_Ax(1), 1, n, 1, nvec,
1051
$ g_Ay, 1, n, isub-nvec, isub-1)
1053
if (ncomp.gt.1) then
1054
call ga_copy_patch('n',
1055
$ g_Ay, n+1, n2, isub, isub+nvec-1,
1056
$ g_Ax(2), 1, n, 1, nvec)
1058
call ga_copy_patch('n',
1059
$ g_Ax(2), 1, n, 1, nvec,
1060
$ g_Ay, n+1, n2, isub-nvec, isub-1)
1065
call ga_copy_patch('n',
1066
$ g_Ay, n2+1, n3, isub, isub+nvec-1,
1067
$ g_Ax_im(1), 1, n, 1, nvec)
1069
call ga_copy_patch('n',
1070
$ g_Ax_im(1), 1, n, 1, nvec,
1071
$ g_Ay, n2+1, n3, isub-nvec, isub-1)
1073
if (ncomp.gt.1) then
1074
call ga_copy_patch('n',
1075
$ g_Ay, n3+1, n4, isub, isub+nvec-1,
1076
$ g_Ax_im(2), 1, n, 1, nvec)
1078
call ga_copy_patch('n',
1079
$ g_Ax_im(2), 1, n, 1, nvec,
1080
$ g_Ay, n3+1, n4, isub-nvec, isub-1)
1087
call ga_copy_patch('n',
1088
$ g_y, 1, n, isub, isub+nvec-1,
1089
$ g_Ax(1), 1, n, 1, nvec)
1091
call ga_copy_patch('n',
1092
$ g_Ax(1), 1, n, 1, nvec,
1093
$ g_y, 1, n, isub-nvec, isub-1)
1095
if (ncomp.gt.1) then
1096
call ga_copy_patch('n',
1097
$ g_y, n+1, n2, isub, isub+nvec-1,
1098
$ g_Ax(2), 1, n, 1, nvec)
1100
call ga_copy_patch('n',
1101
$ g_Ax(2), 1, n, 1, nvec,
1102
$ g_y, n+1, n2, isub-nvec, isub-1)
1108
call ga_copy_patch('n',
1109
$ g_y, n2+1, n3, isub, isub+nvec-1,
1110
$ g_Ax_im(1), 1, n, 1, nvec)
1112
call ga_copy_patch('n',
1113
$ g_Ax_im(1), 1, n, 1, nvec,
1114
$ g_y, n2+1, n3, isub-nvec, isub-1)
1116
if (ncomp.gt.1) then
1117
call ga_copy_patch('n',
1118
$ g_y, n3+1, n4, isub, isub+nvec-1,
1119
$ g_Ax_im(2), 1, n, 1, nvec)
1121
call ga_copy_patch('n',
1122
$ g_Ax_im(2), 1, n, 1, nvec,
1123
$ g_y, n3+1, n4, isub-nvec, isub-1)
1127
end do ! isub = nvec+1, maxsub, nvec
1349
c ====== FA: left-shifting patch ==== START
1350
c Note.- matrices Ay,y shift to left nvec positions
1351
c removing leftmost patch of dimension: n4 x nvec
1352
if (ga_nodeid().eq.0)
1353
& write(*,*) 'FA-matrix-nvec-left-shifting:'
1354
do isub = nvec+1, maxsub, nvec
1355
call ga_copy_patch('n',g_Ay,1,n4,isub,isub+nvec-1,
1356
$ g_Ay,1,n4,isub-nvec,isub-1)
1357
call ga_copy_patch('n',g_y ,1,n4,isub,isub+nvec-1,
1358
$ g_y ,1,n4,isub-nvec,isub-1)
1359
c ====== FA: left-shifting patch ==== END
1360
enddo ! end-loop-isub
1129
1362
end if ! (nsub .eq. maxsub)
1130
if (debug) write (6,*) 'lkain3_damp: sub reduction comp.'
1132
1363
enddo ! iter = 1,maxiter
1133
1364
100 continue ! jump here if converged