Merge lp:~garsua/siesta/trunk-elsi-dm into lp:~albertog/siesta/trunk-elsi-dm

Proposed by Alberto Garcia
Status: Needs review
Proposed branch: lp:~garsua/siesta/trunk-elsi-dm
Merge into: lp:~albertog/siesta/trunk-elsi-dm
Diff against target: 470 lines (+218/-220)
1 file modified
Src/m_elsi_interface.F90 (+218/-220)
To merge this branch: bzr merge lp:~garsua/siesta/trunk-elsi-dm
Reviewer Review Type Date Requested Status
Alberto Garcia Pending
Review via email: mp+361869@code.launchpad.net

Commit message

Cosmetic changes on m_elsi_interface.F90
- Removed "use fdf, only: fdf_get" from elsi_real_solver and elsi_complex_solver subroutines
- Unindented lines from 401 to 510 (in elsi_real_solver) and from 1351 to 1460 (in elsi_complex_solver)

Description of the change

Trying to resubmit.

To post a comment you must log in.

Unmerged revisions

696. By Victor GS

Cosmetic changes on m_elsi_interface.F90
- Removed "use fdf, only: fdf_get" from elsi_real_solver and elsi_complex_solver subroutines
- Unindented lines from 401 to 510 (in elsi_real_solver) and from 1351 to 1460 (in elsi_complex_solver)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'Src/m_elsi_interface.F90'
--- Src/m_elsi_interface.F90 2019-01-15 14:46:49 +0000
+++ Src/m_elsi_interface.F90 2019-01-17 09:06:38 +0000
@@ -271,7 +271,6 @@
271subroutine elsi_real_solver(iscf, n_basis, n_basis_l, n_spin, nnz_l, row_ptr, &271subroutine elsi_real_solver(iscf, n_basis, n_basis_l, n_spin, nnz_l, row_ptr, &
272 col_idx, qtot, temp, ham, ovlp, dm, edm, ef, ets, Get_EDM_Only)272 col_idx, qtot, temp, ham, ovlp, dm, edm, ef, ets, Get_EDM_Only)
273273
274 use fdf, only: fdf_get
275 use m_mpi_utils, only: globalize_sum274 use m_mpi_utils, only: globalize_sum
276 use parallel, only: BlockSize275 use parallel, only: BlockSize
277#ifdef MPI276#ifdef MPI
@@ -399,116 +398,116 @@
399398
400 endif ! iscf == 1399 endif ! iscf == 1
401400
402 if (n_spin == 1) then401 if (n_spin == 1) then
403402
404 ! Sparsity pattern403 ! Sparsity pattern
405 call globalize_sum(nnz_l, nnz_g, comm=elsi_global_comm)404 call globalize_sum(nnz_l, nnz_g, comm=elsi_global_comm)
406405
407 allocate(row_ptr2(n_basis_l+1))406 allocate(row_ptr2(n_basis_l+1))
408 row_ptr2(1:n_basis_l) = row_ptr(1:n_basis_l)+1407 row_ptr2(1:n_basis_l) = row_ptr(1:n_basis_l)+1
409 row_ptr2(n_basis_l+1) = nnz_l+1408 row_ptr2(n_basis_l+1) = nnz_l+1
410409
411 call elsi_set_csc(elsi_h, nnz_g, nnz_l, n_basis_l, col_idx, row_ptr2)410 call elsi_set_csc(elsi_h, nnz_g, nnz_l, n_basis_l, col_idx, row_ptr2)
412 deallocate(row_ptr2)411 deallocate(row_ptr2)
413412
414 call elsi_set_csc_blk(elsi_h, BlockSize)413 call elsi_set_csc_blk(elsi_h, BlockSize)
415 call elsi_set_mpi(elsi_h, elsi_global_comm)414 call elsi_set_mpi(elsi_h, elsi_global_comm)
416415
417 else416 else
418417
419 ! MPI logic for spin polarization418 ! MPI logic for spin polarization
420419
421 ! Re-create numh, as we use it in the transfer420 ! Re-create numh, as we use it in the transfer
422 allocate(numh(n_basis_l))421 allocate(numh(n_basis_l))
423 numh(1) = row_ptr(2)422 numh(1) = row_ptr(2)
424 do i = 2, n_basis_l-1423 do i = 2, n_basis_l-1
425 numh(i) = row_ptr(i+1)-row_ptr(i)424 numh(i) = row_ptr(i+1)-row_ptr(i)
426 enddo425 enddo
427 numh(n_basis_l) = nnz_l - row_ptr(n_basis_l)426 numh(n_basis_l) = nnz_l - row_ptr(n_basis_l)
428427
429 ! Split the communicator in spins and get distribution objects428 ! Split the communicator in spins and get distribution objects
430 ! for the data redistribution needed429 ! for the data redistribution needed
431 ! Note that dist_spin is an array430 ! Note that dist_spin is an array
432 call get_spin_comms_and_dists(elsi_global_comm,elsi_global_comm, &431 call get_spin_comms_and_dists(elsi_global_comm,elsi_global_comm, &
433 blocksize, n_spin, &432 blocksize, n_spin, &
434 dist_global,dist_spin, elsi_spatial_comm, elsi_spin_comm)433 dist_global,dist_spin, elsi_spatial_comm, elsi_spin_comm)
435434
436 ! Find out which spin team we are in, and tag the spin we work on435 ! Find out which spin team we are in, and tag the spin we work on
437 call mpi_comm_rank( elsi_Spin_Comm, spin_rank, ierr )436 call mpi_comm_rank( elsi_Spin_Comm, spin_rank, ierr )
438 my_spin = spin_rank+1 ! {1,2}437 my_spin = spin_rank+1 ! {1,2}
439438
440439
441 ! This is done serially, each time filling one spin set440 ! This is done serially, each time filling one spin set
442 ! Note that **all processes** need to have the same pkg_global441 ! Note that **all processes** need to have the same pkg_global
443442
444 do ispin = 1, n_spin443 do ispin = 1, n_spin
445444
446 ! Load pkg_global data package445 ! Load pkg_global data package
447 pkg_global%norbs = n_basis446 pkg_global%norbs = n_basis
448 pkg_global%no_l = n_basis_l447 pkg_global%no_l = n_basis_l
449 pkg_global%nnzl = nnz_l448 pkg_global%nnzl = nnz_l
450 pkg_global%numcols => numh449 pkg_global%numcols => numh
451 pkg_global%cols => col_idx450 pkg_global%cols => col_idx
452451
453 allocate(pkg_global%vals(2))452 allocate(pkg_global%vals(2))
454 ! Link the vals items to the appropriate arrays (no extra memory here)453 ! Link the vals items to the appropriate arrays (no extra memory here)
455 pkg_global%vals(1)%data => ovlp(:)454 pkg_global%vals(1)%data => ovlp(:)
456 ! Note that we *cannot* say => ham(:,my_spin)455 ! Note that we *cannot* say => ham(:,my_spin)
457 ! and avoid the sequential loop, as then half the processors will send456 ! and avoid the sequential loop, as then half the processors will send
458 ! the information for 'spin up' and the other half the information for 'spin down',457 ! the information for 'spin up' and the other half the information for 'spin down',
459 ! which is *not* what we want.458 ! which is *not* what we want.
460 pkg_global%vals(2)%data => ham(:,ispin)459 pkg_global%vals(2)%data => ham(:,ispin)
461460
462 call timer("redist_orbs_fwd", 1)461 call timer("redist_orbs_fwd", 1)
463462
464 ! We are doing the transfers sequentially. One spin team is463 ! We are doing the transfers sequentially. One spin team is
465 ! 'idle' (in the receiving side) in each pass, as the dist_spin(ispin) distribution464 ! 'idle' (in the receiving side) in each pass, as the dist_spin(ispin) distribution
466 ! does not involve them.465 ! does not involve them.
467466
468 call redistribute_spmatrix(n_basis,pkg_global,dist_global, &467 call redistribute_spmatrix(n_basis,pkg_global,dist_global, &
469 pkg_spin,dist_spin(ispin),elsi_global_Comm)468 pkg_spin,dist_spin(ispin),elsi_global_Comm)
470469
471 call timer("redist_orbs_fwd", 2)470 call timer("redist_orbs_fwd", 2)
472471
473 if (my_spin == ispin) then ! Each team gets their own data472 if (my_spin == ispin) then ! Each team gets their own data
474473
475 !nrows = pkg_spin%norbs ! or simply 'norbs'474 !nrows = pkg_spin%norbs ! or simply 'norbs'
476 my_no_l = pkg_spin%no_l475 my_no_l = pkg_spin%no_l
477 my_nnz_l = pkg_spin%nnzl476 my_nnz_l = pkg_spin%nnzl
478 call MPI_AllReduce(my_nnz_l,my_nnz,1,MPI_integer,MPI_sum,elsi_Spatial_Comm,ierr)477 call MPI_AllReduce(my_nnz_l,my_nnz,1,MPI_integer,MPI_sum,elsi_Spatial_Comm,ierr)
479 ! generate off-by-one row pointer478 ! generate off-by-one row pointer
480 call re_alloc(my_row_ptr2,1,my_no_l+1,"my_row_ptr2","elsi_solver")479 call re_alloc(my_row_ptr2,1,my_no_l+1,"my_row_ptr2","elsi_solver")
481 my_row_ptr2(1) = 1480 my_row_ptr2(1) = 1
482 do ih = 1,my_no_l481 do ih = 1,my_no_l
483 my_row_ptr2(ih+1) = my_row_ptr2(ih) + pkg_spin%numcols(ih)482 my_row_ptr2(ih+1) = my_row_ptr2(ih) + pkg_spin%numcols(ih)
484 enddo483 enddo
485484
486 my_col_idx => pkg_spin%cols485 my_col_idx => pkg_spin%cols
487 my_S => pkg_spin%vals(1)%data486 my_S => pkg_spin%vals(1)%data
488 my_H => pkg_spin%vals(2)%data487 my_H => pkg_spin%vals(2)%data
489488
490 call re_alloc(my_DM,1,my_nnz_l,"my_DM","elsi_solver")489 call re_alloc(my_DM,1,my_nnz_l,"my_DM","elsi_solver")
491 call re_alloc(my_EDM,1,my_nnz_l,"my_EDM","elsi_solver")490 call re_alloc(my_EDM,1,my_nnz_l,"my_EDM","elsi_solver")
492 endif491 endif
493492
494 ! Clean pkg_global493 ! Clean pkg_global
495 nullify(pkg_global%vals(1)%data)494 nullify(pkg_global%vals(1)%data)
496 nullify(pkg_global%vals(2)%data)495 nullify(pkg_global%vals(2)%data)
497 deallocate(pkg_global%vals)496 deallocate(pkg_global%vals)
498 nullify(pkg_global%numcols)497 nullify(pkg_global%numcols)
499 nullify(pkg_global%cols)498 nullify(pkg_global%cols)
500499
501 enddo500 enddo
502501
503 call elsi_set_csc(elsi_h, my_nnz, my_nnz_l, my_no_l, my_col_idx, my_row_ptr2)502 call elsi_set_csc(elsi_h, my_nnz, my_nnz_l, my_no_l, my_col_idx, my_row_ptr2)
504 call de_alloc(my_row_ptr2,"my_row_ptr2","elsi_solver")503 call de_alloc(my_row_ptr2,"my_row_ptr2","elsi_solver")
505504
506 call elsi_set_csc_blk(elsi_h, BlockSize)505 call elsi_set_csc_blk(elsi_h, BlockSize)
507 call elsi_set_spin(elsi_h, n_spin, my_spin)506 call elsi_set_spin(elsi_h, n_spin, my_spin)
508 call elsi_set_mpi(elsi_h, elsi_Spatial_comm)507 call elsi_set_mpi(elsi_h, elsi_Spatial_comm)
509 call elsi_set_mpi_global(elsi_h, elsi_global_comm)508 call elsi_set_mpi_global(elsi_h, elsi_global_comm)
510509
511 endif ! n_spin510 endif ! n_spin
512511
513 call timer("elsi-solver", 1)512 call timer("elsi-solver", 1)
514513
@@ -1217,7 +1216,6 @@
1217 col_idx, qtot, temp, ham, ovlp, dm, edm, ef, ets, &1216 col_idx, qtot, temp, ham, ovlp, dm, edm, ef, ets, &
1218 nkpnt, kpt_n, kpt, weight, kpt_comm, Get_EDM_Only)1217 nkpnt, kpt_n, kpt, weight, kpt_comm, Get_EDM_Only)
12191218
1220 use fdf, only: fdf_get
1221 use m_mpi_utils, only: globalize_sum1219 use m_mpi_utils, only: globalize_sum
1222 use parallel, only: BlockSize1220 use parallel, only: BlockSize
1223#ifdef MPI1221#ifdef MPI
@@ -1350,116 +1348,116 @@
13501348
1351 !print *, global_rank, "| ", " Entering elsi_complex_solver"1349 !print *, global_rank, "| ", " Entering elsi_complex_solver"
13521350
1353 if (n_spin == 1) then1351 if (n_spin == 1) then
13541352
1355 ! Sparsity pattern1353 ! Sparsity pattern
1356 call globalize_sum(nnz_l, nnz_g, comm=kpt_comm)1354 call globalize_sum(nnz_l, nnz_g, comm=kpt_comm)
13571355
1358 allocate(row_ptr2(n_basis_l+1))1356 allocate(row_ptr2(n_basis_l+1))
1359 row_ptr2(1:n_basis_l) = row_ptr(1:n_basis_l)+11357 row_ptr2(1:n_basis_l) = row_ptr(1:n_basis_l)+1
1360 row_ptr2(n_basis_l+1) = nnz_l+11358 row_ptr2(n_basis_l+1) = nnz_l+1
13611359
1362 call elsi_set_csc(elsi_h, nnz_g, nnz_l, n_basis_l, col_idx, row_ptr2)1360 call elsi_set_csc(elsi_h, nnz_g, nnz_l, n_basis_l, col_idx, row_ptr2)
1363 deallocate(row_ptr2)1361 deallocate(row_ptr2)
13641362
1365 call elsi_set_csc_blk(elsi_h, BlockSize)1363 call elsi_set_csc_blk(elsi_h, BlockSize)
1366 call elsi_set_kpoint(elsi_h, nkpnt, kpt_n, weight)1364 call elsi_set_kpoint(elsi_h, nkpnt, kpt_n, weight)
1367 call elsi_set_mpi(elsi_h, kpt_comm)1365 call elsi_set_mpi(elsi_h, kpt_comm)
1368 call elsi_set_mpi_global(elsi_h, elsi_global_comm)1366 call elsi_set_mpi_global(elsi_h, elsi_global_comm)
13691367
1370 else1368 else
13711369
1372 call mpi_comm_rank( elsi_global_Comm, global_rank, ierr )1370 call mpi_comm_rank( elsi_global_Comm, global_rank, ierr )
13731371
1374 ! MPI logic for spin polarization1372 ! MPI logic for spin polarization
13751373
1376 ! Split the communicator in spins and get distribution objects1374 ! Split the communicator in spins and get distribution objects
1377 ! for the data redistribution needed1375 ! for the data redistribution needed
1378 ! Note that dist_spin is an array1376 ! Note that dist_spin is an array
1379 call get_spin_comms_and_dists(kpt_comm,kpt_comm, & !! **** kpt_comm as global?1377 call get_spin_comms_and_dists(kpt_comm,kpt_comm, & !! **** kpt_comm as global?
1380 blocksize, n_spin, &1378 blocksize, n_spin, &
1381 dist_global,dist_spin, elsi_spatial_comm, elsi_spin_comm)1379 dist_global,dist_spin, elsi_spatial_comm, elsi_spin_comm)
13821380
1383 ! Find out which spin team we are in, and tag the spin we work on1381 ! Find out which spin team we are in, and tag the spin we work on
1384 call mpi_comm_rank( elsi_Spin_Comm, spin_rank, ierr )1382 call mpi_comm_rank( elsi_Spin_Comm, spin_rank, ierr )
1385 my_spin = spin_rank+1 ! {1,2}1383 my_spin = spin_rank+1 ! {1,2}
13861384
1387 !print *, global_rank, "| ", "spin ", my_spin, " After spin splitting"1385 !print *, global_rank, "| ", "spin ", my_spin, " After spin splitting"
13881386
1389 ! This is done serially, each time filling one spin set1387 ! This is done serially, each time filling one spin set
1390 ! Note that **all processes** need to have the same pkg_global1388 ! Note that **all processes** need to have the same pkg_global
13911389
1392 do ispin = 1, n_spin1390 do ispin = 1, n_spin
13931391
1394 ! Load pkg_global data package1392 ! Load pkg_global data package
1395 pkg_global%norbs = n_basis1393 pkg_global%norbs = n_basis
1396 pkg_global%no_l = n_basis_l1394 pkg_global%no_l = n_basis_l
1397 pkg_global%nnzl = nnz_l1395 pkg_global%nnzl = nnz_l
1398 pkg_global%numcols => numh1396 pkg_global%numcols => numh
1399 pkg_global%cols => col_idx1397 pkg_global%cols => col_idx
14001398
1401 allocate(pkg_global%complex_vals(2))1399 allocate(pkg_global%complex_vals(2))
1402 ! Link the vals items to the appropriate arrays (no extra memory here)1400 ! Link the vals items to the appropriate arrays (no extra memory here)
1403 pkg_global%complex_vals(1)%data => ovlp(:)1401 pkg_global%complex_vals(1)%data => ovlp(:)
1404 ! Note that we *cannot* say => ham(:,my_spin)1402 ! Note that we *cannot* say => ham(:,my_spin)
1405 ! and avoid the sequential loop, as then half the processors will send1403 ! and avoid the sequential loop, as then half the processors will send
1406 ! the information for 'spin up' and the other half the information for 'spin down',1404 ! the information for 'spin up' and the other half the information for 'spin down',
1407 ! which is *not* what we want.1405 ! which is *not* what we want.
1408 pkg_global%complex_vals(2)%data => ham(:,ispin)1406 pkg_global%complex_vals(2)%data => ham(:,ispin)
14091407
1410 call timer("redist_orbs_fwd", 1)1408 call timer("redist_orbs_fwd", 1)
14111409
1412 ! We are doing the transfers sequentially. One spin team is1410 ! We are doing the transfers sequentially. One spin team is
1413 ! 'idle' (in the receiving side) in each pass, as the dist_spin(ispin) distribution1411 ! 'idle' (in the receiving side) in each pass, as the dist_spin(ispin) distribution
1414 ! does not involve them.1412 ! does not involve them.
14151413
1416 call redistribute_spmatrix(n_basis,pkg_global,dist_global, &1414 call redistribute_spmatrix(n_basis,pkg_global,dist_global, &
1417 pkg_spin,dist_spin(ispin),kpt_Comm)1415 pkg_spin,dist_spin(ispin),kpt_Comm)
14181416
1419 call timer("redist_orbs_fwd", 2)1417 call timer("redist_orbs_fwd", 2)
14201418
1421 if (my_spin == ispin) then ! Each team gets their own data1419 if (my_spin == ispin) then ! Each team gets their own data
14221420
1423 !nrows = pkg_spin%norbs ! or simply 'norbs'1421 !nrows = pkg_spin%norbs ! or simply 'norbs'
1424 my_no_l = pkg_spin%no_l1422 my_no_l = pkg_spin%no_l
1425 my_nnz_l = pkg_spin%nnzl1423 my_nnz_l = pkg_spin%nnzl
1426 call MPI_AllReduce(my_nnz_l,my_nnz,1,MPI_integer,MPI_sum,elsi_Spatial_Comm,ierr)1424 call MPI_AllReduce(my_nnz_l,my_nnz,1,MPI_integer,MPI_sum,elsi_Spatial_Comm,ierr)
1427 ! generate off-by-one row pointer1425 ! generate off-by-one row pointer
1428 call re_alloc(my_row_ptr2,1,my_no_l+1,"my_row_ptr2","elsi_solver")1426 call re_alloc(my_row_ptr2,1,my_no_l+1,"my_row_ptr2","elsi_solver")
1429 my_row_ptr2(1) = 11427 my_row_ptr2(1) = 1
1430 do ih = 1,my_no_l1428 do ih = 1,my_no_l
1431 my_row_ptr2(ih+1) = my_row_ptr2(ih) + pkg_spin%numcols(ih)1429 my_row_ptr2(ih+1) = my_row_ptr2(ih) + pkg_spin%numcols(ih)
1432 enddo1430 enddo
14331431
1434 my_col_idx => pkg_spin%cols1432 my_col_idx => pkg_spin%cols
1435 my_S => pkg_spin%complex_vals(1)%data1433 my_S => pkg_spin%complex_vals(1)%data
1436 my_H => pkg_spin%complex_vals(2)%data1434 my_H => pkg_spin%complex_vals(2)%data
14371435
1438 call re_alloc(my_DM,1,my_nnz_l,"my_DM","elsi_solver")1436 call re_alloc(my_DM,1,my_nnz_l,"my_DM","elsi_solver")
1439 call re_alloc(my_EDM,1,my_nnz_l,"my_EDM","elsi_solver")1437 call re_alloc(my_EDM,1,my_nnz_l,"my_EDM","elsi_solver")
1440 endif1438 endif
14411439
1442 ! Clean pkg_global1440 ! Clean pkg_global
1443 nullify(pkg_global%complex_vals(1)%data)1441 nullify(pkg_global%complex_vals(1)%data)
1444 nullify(pkg_global%complex_vals(2)%data)1442 nullify(pkg_global%complex_vals(2)%data)
1445 deallocate(pkg_global%complex_vals)1443 deallocate(pkg_global%complex_vals)
1446 nullify(pkg_global%numcols)1444 nullify(pkg_global%numcols)
1447 nullify(pkg_global%cols)1445 nullify(pkg_global%cols)
14481446
1449 enddo1447 enddo
14501448
1451 !print *, global_rank, "| ", "spin ", my_spin, "Done spin transfers"1449 !print *, global_rank, "| ", "spin ", my_spin, "Done spin transfers"
14521450
1453 call elsi_set_csc(elsi_h, my_nnz, my_nnz_l, my_no_l, my_col_idx, my_row_ptr2)1451 call elsi_set_csc(elsi_h, my_nnz, my_nnz_l, my_no_l, my_col_idx, my_row_ptr2)
1454 call de_alloc(my_row_ptr2,"my_row_ptr2","elsi_solver")1452 call de_alloc(my_row_ptr2,"my_row_ptr2","elsi_solver")
14551453
1456 call elsi_set_csc_blk(elsi_h, BlockSize)1454 call elsi_set_csc_blk(elsi_h, BlockSize)
1457 call elsi_set_spin(elsi_h, n_spin, my_spin)1455 call elsi_set_spin(elsi_h, n_spin, my_spin)
1458 call elsi_set_kpoint(elsi_h, nkpnt, kpt_n, weight)1456 call elsi_set_kpoint(elsi_h, nkpnt, kpt_n, weight)
1459 call elsi_set_mpi(elsi_h, elsi_Spatial_comm)1457 call elsi_set_mpi(elsi_h, elsi_Spatial_comm)
1460 call elsi_set_mpi_global(elsi_h, elsi_global_comm)1458 call elsi_set_mpi_global(elsi_h, elsi_global_comm)
14611459
1462 endif ! n_spin1460 endif ! n_spin
14631461
1464 call timer("elsi-solver", 1)1462 call timer("elsi-solver", 1)
14651463

Subscribers

People subscribed via source and target branches

to all changes: