diff --git a/c/gridsys.c b/c/gridsys.c index 1d266fd5..1261e387 100644 --- a/c/gridsys.c +++ b/c/gridsys.c @@ -192,7 +192,7 @@ long gridsys_get_triplets_at_q(long *map_triplets, long *map_q, rec_rotations, swappable); } -long gridsys_get_BZ_triplets_at_q(long (*triplets)[3], const long grid_point, +long gridsys_get_bz_triplets_at_q(long (*triplets)[3], const long grid_point, const long (*bz_grid_addresses)[3], const long *bz_map, const long *map_triplets, const long num_map_triplets, diff --git a/c/gridsys.h b/c/gridsys.h index 5946a991..90a2e8a1 100644 --- a/c/gridsys.h +++ b/c/gridsys.h @@ -274,7 +274,7 @@ long gridsys_get_triplets_at_q(long *map_triplets, long *map_q, * dense, recommended) of bz_map * @return long */ -long gridsys_get_BZ_triplets_at_q(long (*triplets)[3], const long grid_point, +long gridsys_get_bz_triplets_at_q(long (*triplets)[3], const long grid_point, const long (*bz_grid_addresses)[3], const long *bz_map, const long *map_triplets, const long num_map_triplets, diff --git a/ctest/CMakeLists.txt b/ctest/CMakeLists.txt index 78de2a61..a3658f4b 100644 --- a/ctest/CMakeLists.txt +++ b/ctest/CMakeLists.txt @@ -20,8 +20,8 @@ if(NOT GTest_FOUND) # cmake-lint: disable=C0301 FetchContent_Declare( googletest - URL https://github.com/google/googletest/archive/refs/tags/release-1.12.1.tar.gz - URL_HASH MD5=e82199374acdfda3f425331028eb4e2a) + GIT_REPOSITORY https://github.com/google/googletest.git + GIT_TAG 4fb7039fda3f6588c7ca9664176f8c9e0a023b4a) FetchContent_MakeAvailable(googletest) endif() diff --git a/ctest/fortran/gridsysf/test_gridsysf.f90 b/ctest/fortran/gridsysf/test_gridsysf.f90 index e2dc3a3c..086d1cd6 100644 --- a/ctest/fortran/gridsysf/test_gridsysf.f90 +++ b/ctest/fortran/gridsysf/test_gridsysf.f90 @@ -1,96 +1,198 @@ program test_gridsysf - use, intrinsic :: iso_c_binding - use gridsysf, only: gridsys_get_bz_grid_addresses - implicit none + use, intrinsic :: iso_c_binding + use gridsysf, only: & + gridsys_get_bz_grid_addresses, & + gridsys_get_triplets_at_q + implicit none - write (*, '("[test_gridsys_get_bz_grid_addresses]")') - call test_gridsys_get_bz_grid_addresses() + integer(c_long) :: wurtzite_rec_rotations_without_time_reversal(3, 3, 12) + + wurtzite_rec_rotations_without_time_reversal(:, :, :) = & + reshape([1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, -1, 0, 0, 0, 0, 1, & + 0, 1, 0, -1, -1, 0, 0, 0, 1, -1, 0, 0, 0, -1, 0, 0, 0, 1, & + -1, -1, 0, 1, 0, 0, 0, 0, 1, 0, -1, 0, 1, 1, 0, 0, 0, 1, & + 0, 1, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, -1, 0, 0, 0, 1, & + 1, 0, 0, -1, -1, 0, 0, 0, 1, 0, -1, 0, -1, 0, 0, 0, 0, 1, & + -1, -1, 0, 0, 1, 0, 0, 0, 1, -1, 0, 0, 1, 1, 0, 0, 0, 1], [3, 3, 12]) + + write (*, '("[test_gridsys_get_bz_grid_addresses]")') + call test_gridsys_get_bz_grid_addresses() + write (*, '("[test_gridsys_get_triplets_at_q]")') + call test_gridsys_get_triplets_at_q() contains - subroutine test_gridsys_get_bz_grid_addresses() bind(C) - integer(c_long) :: bz_size - integer(c_long) :: PS(3), D_diag(3), Q(3, 3), bz_grid_addresses(3, 144) - integer(c_long) :: bz_map(76), bzg2grg(144) - real(c_double) :: rec_lattice(3, 3) - integer :: i, j + subroutine test_gridsys_get_bz_grid_addresses() bind(C) + integer(c_long) :: bz_size + integer(c_long) :: PS(3), D_diag(3), Q(3, 3), bz_grid_addresses(3, 144) + integer(c_long) :: bz_map(76), bzg2grg(144) + real(c_double) :: rec_lattice(3, 3) + integer :: i, j - integer :: ref_bz_addresses(3, 93) - integer :: ref_bz_map(76) - integer :: ref_bzg2grg(93) + integer(c_long) :: ref_bz_grid_addresses(3, 93) + integer(c_long) :: ref_bz_map(76) + integer(c_long) :: ref_bzg2grg(93) - ref_bz_addresses(:, :) = reshape([ & - 0, 0, 0, 1, 0, 0, 2, 0, 0, -2, 0, 0, -1, 0, 0, & - 0, 1, 0, 1, 1, 0, 2, 1, 0, -3, 1, 0, -2, 1, 0, & - -1, 1, 0, 0, 2, 0, 1, 2, 0, 1, -3, 0, 2, -3, 0, & - -3, 2, 0, -2, 2, 0, -1, 2, 0, 0, -2, 0, 1, -2, 0, & - 2, -2, 0, -2, 3, 0, 3, -2, 0, -1, -2, 0, -1, 3, 0, & - 0, -1, 0, 1, -1, 0, 2, -1, 0, -2, -1, 0, 3, -1, 0, & - -1, -1, 0, 0, 0, 1, 1, 0, 1, 2, 0, 1, -2, 0, 1, & - -1, 0, 1, 0, 1, 1, 1, 1, 1, 2, 1, 1, -3, 1, 1, & - -2, 1, 1, -1, 1, 1, 0, 2, 1, 1, 2, 1, 1, -3, 1, & - 2, -3, 1, -3, 2, 1, -2, 2, 1, -1, 2, 1, 0, -2, 1, & - 1, -2, 1, 2, -2, 1, -2, 3, 1, 3, -2, 1, -1, -2, 1, & - -1, 3, 1, 0, -1, 1, 1, -1, 1, 2, -1, 1, -2, -1, 1, & - 3, -1, 1, -1, -1, 1, 0, 0, -1, 1, 0, -1, 2, 0, -1, & - -2, 0, -1, -1, 0, -1, 0, 1, -1, 1, 1, -1, 2, 1, -1, & - -3, 1, -1, -2, 1, -1, -1, 1, -1, 0, 2, -1, 1, 2, -1, & - 1, -3, -1, 2, -3, -1, -3, 2, -1, -2, 2, -1, -1, 2, -1, & - 0, -2, -1, 1, -2, -1, 2, -2, -1, -2, 3, -1, 3, -2, -1, & - -1, -2, -1, -1, 3, -1, 0, -1, -1, 1, -1, -1, 2, -1, -1, & - -2, -1, -1, 3, -1, -1, -1, -1, -1], [3, 93]) - ref_bz_map(:) = [0, 1, 2, 3, 4, 5, 6, 7, 9, 10, 11, 12, 14, 16, & - 17, 18, 19, 20, 21, 23, 25, 26, 27, 28, 30, 31, 32, 33, & - 34, 35, 36, 37, 38, 40, 41, 42, 43, 45, 47, 48, 49, 50, & - 51, 52, 54, 56, 57, 58, 59, 61, 62, 63, 64, 65, 66, 67, & - 68, 69, 71, 72, 73, 74, 76, 78, 79, 80, 81, 82, 83, 85, 87, 88, 89, 90, 92, 93] - ref_bzg2grg(:) = [ & - 0, 1, 2, 3, 4, 5, 6, 7, 7, 8, 9, 10, 11, 11, 12, 12, & - 13, 14, 15, 16, 17, 18, 18, 19, 19, 20, 21, 22, 23, 23, 24, 25, & - 26, 27, 28, 29, 30, 31, 32, 32, 33, 34, 35, 36, 36, 37, 37, 38, & - 39, 40, 41, 42, 43, 43, 44, 44, 45, 46, 47, 48, 48, 49, 50, 51, & - 52, 53, 54, 55, 56, 57, 57, 58, 59, 60, 61, 61, 62, 62, 63, 64, & - 65, 66, 67, 68, 68, 69, 69, 70, 71, 72, 73, 73, 74] + ref_bz_grid_addresses(:, :) = & + reshape([0, 0, 0, 1, 0, 0, 2, 0, 0, -2, 0, 0, -1, 0, 0, & + 0, 1, 0, 1, 1, 0, 2, 1, 0, -3, 1, 0, -2, 1, 0, & + -1, 1, 0, 0, 2, 0, 1, 2, 0, 1, -3, 0, 2, -3, 0, & + -3, 2, 0, -2, 2, 0, -1, 2, 0, 0, -2, 0, 1, -2, 0, & + 2, -2, 0, -2, 3, 0, 3, -2, 0, -1, -2, 0, -1, 3, 0, & + 0, -1, 0, 1, -1, 0, 2, -1, 0, -2, -1, 0, 3, -1, 0, & + -1, -1, 0, 0, 0, 1, 1, 0, 1, 2, 0, 1, -2, 0, 1, & + -1, 0, 1, 0, 1, 1, 1, 1, 1, 2, 1, 1, -3, 1, 1, & + -2, 1, 1, -1, 1, 1, 0, 2, 1, 1, 2, 1, 1, -3, 1, & + 2, -3, 1, -3, 2, 1, -2, 2, 1, -1, 2, 1, 0, -2, 1, & + 1, -2, 1, 2, -2, 1, -2, 3, 1, 3, -2, 1, -1, -2, 1, & + -1, 3, 1, 0, -1, 1, 1, -1, 1, 2, -1, 1, -2, -1, 1, & + 3, -1, 1, -1, -1, 1, 0, 0, -1, 1, 0, -1, 2, 0, -1, & + -2, 0, -1, -1, 0, -1, 0, 1, -1, 1, 1, -1, 2, 1, -1, & + -3, 1, -1, -2, 1, -1, -1, 1, -1, 0, 2, -1, 1, 2, -1, & + 1, -3, -1, 2, -3, -1, -3, 2, -1, -2, 2, -1, -1, 2, -1, & + 0, -2, -1, 1, -2, -1, 2, -2, -1, -2, 3, -1, 3, -2, -1, & + -1, -2, -1, -1, 3, -1, 0, -1, -1, 1, -1, -1, 2, -1, -1, & + -2, -1, -1, 3, -1, -1, -1, -1, -1], [3, 93]) + ref_bz_map(:) = [0, 1, 2, 3, 4, 5, 6, 7, 9, 10, 11, 12, 14, 16, & + 17, 18, 19, 20, 21, 23, 25, 26, 27, 28, 30, 31, 32, 33, & + 34, 35, 36, 37, 38, 40, 41, 42, 43, 45, 47, 48, 49, 50, & + 51, 52, 54, 56, 57, 58, 59, 61, 62, 63, 64, 65, 66, 67, & + 68, 69, 71, 72, 73, 74, 76, 78, 79, 80, 81, 82, 83, 85, & + 87, 88, 89, 90, 92, 93] + ref_bzg2grg(:) = [ & + 0, 1, 2, 3, 4, 5, 6, 7, 7, 8, 9, 10, 11, 11, 12, 12, & + 13, 14, 15, 16, 17, 18, 18, 19, 19, 20, 21, 22, 23, 23, 24, 25, & + 26, 27, 28, 29, 30, 31, 32, 32, 33, 34, 35, 36, 36, 37, 37, 38, & + 39, 40, 41, 42, 43, 43, 44, 44, 45, 46, 47, 48, 48, 49, 50, 51, & + 52, 53, 54, 55, 56, 57, 57, 58, 59, 60, 61, 61, 62, 62, 63, 64, & + 65, 66, 67, 68, 68, 69, 69, 70, 71, 72, 73, 73, 74] - PS(:) = [0, 0, 0] - D_diag(:) = [5, 5, 3] - Q(:, :) = reshape([1, 0, 0, 0, 1, 0, 0, 0, 1], [3, 3]) - rec_lattice(:, :) = reshape([0.3214400514304082, 0.0, 0.0, & - 0.1855835002216734, 0.3711670004433468, 0.0, & - 0.0, 0.0, 0.20088388911209323], [3, 3]) + PS(:) = [0, 0, 0] + D_diag(:) = [5, 5, 3] + Q(:, :) = reshape([1, 0, 0, 0, 1, 0, 0, 0, 1], [3, 3]) + rec_lattice(:, :) = reshape([0.3214400514304082, 0.0, 0.0, & + 0.1855835002216734, 0.3711670004433468, 0.0, & + 0.0, 0.0, 0.20088388911209323], [3, 3]) - bz_size = gridsys_get_bz_grid_addresses(bz_grid_addresses, bz_map, bzg2grg, & - D_diag, Q, PS, rec_lattice, int(2, c_long)) + bz_size = gridsys_get_bz_grid_addresses(bz_grid_addresses, bz_map, bzg2grg, & + D_diag, Q, PS, rec_lattice, int(2, c_long)) - ! check bz_grid_addresses - write (*, '("check bz_grid_addresses")', advance='no') - do i = 1, 93 - do j = 1, 3 - if (bz_grid_addresses(j, i) /= ref_bz_addresses(j, i)) then - print '("(", i0, ",", i0, "):", i0, " ", i0)', i, j, bz_grid_addresses(j, i), ref_bz_addresses(j, i) - error stop - end if - end do - end do - write (*, '(" OK")') + write (*, '("check bz_grid_addresses")', advance='no') + call assert_2D_array_c_long(bz_grid_addresses, ref_bz_grid_addresses, & + shape(ref_bz_grid_addresses)) + write (*, '(" OK")') - ! check bz_map - write (*, '("check bz_map")', advance='no') - do i = 1, 76 - if (bz_map(i) /= ref_bz_map(i)) then - print '(i0, ":", i0, " ", i0)', i, bz_map(i), ref_bz_map(i) - error stop - end if - end do - write (*, '(" OK")') + write (*, '("check bz_map")', advance='no') + call assert_1D_array_c_long(bz_map, ref_bz_map, 76) + write (*, '(" OK")') - ! check bz_map - write (*, '("check bzg2grg")', advance='no') - do i = 1, 93 - if (bzg2grg(i) /= ref_bzg2grg(i)) then - print '(i0, ":", i0, " ", i0)', i, bzg2grg(i), ref_bzg2grg(i) - error stop - end if - end do - write (*, '(" OK")') + write (*, '("check bzg2grg")', advance='no') + call assert_1D_array_c_long(bzg2grg, ref_bzg2grg, 93) + write (*, '(" OK")') end subroutine test_gridsys_get_bz_grid_addresses + + subroutine test_gridsys_get_triplets_at_q() bind(C) + integer(c_long) :: D_diag(3) + integer(c_long) :: map_triplets(36), map_q(36) + integer(c_long) :: rec_rotations(3, 3, 12) + integer(c_long) :: grid_point, is_time_reversal, num_rot, swappable + integer :: i, j, k, n_ir_triplets + + integer :: ref_num_triplets(4) + integer(c_long) :: ref_map_triplets(36, 4), ref_map_q(36, 4) + + grid_point = 1 + D_diag(:) = [3, 3, 4] + num_rot = 12 + ref_num_triplets(:) = [12, 18, 14, 24] + ref_map_triplets(:, :) = & + reshape([ & + 0, 1, 0, 3, 3, 5, 5, 3, 3, 9, 10, 9, 12, 12, 14, 14, 12, 12, & + 18, 19, 18, 21, 21, 23, 23, 21, 21, 9, 10, 9, 12, 12, 14, 14, 12, 12, & + 0, 1, 2, 3, 4, 5, 5, 3, 4, 9, 10, 11, 12, 13, 14, 14, 12, 13, & + 18, 19, 20, 21, 22, 23, 23, 21, 22, 9, 10, 11, 12, 13, 14, 14, 12, 13, & + 0, 1, 0, 3, 3, 5, 5, 3, 3, 9, 10, 11, & + 12, 13, 14, 14, 12, 13, 18, 19, 18, 21, 21, 23, & + 23, 21, 21, 11, 10, 9, 13, 12, 14, 14, 13, 12, & + 0, 1, 2, 3, 4, 5, 5, 3, 4, 9, 10, 11, & + 12, 13, 14, 14, 12, 13, 18, 19, 20, 21, 22, 23, & + 23, 21, 22, 27, 28, 29, 30, 31, 32, 32, 30, 31 & + ], [36, 4]) + ref_map_q(:, :) = & + reshape([ & + 0, 1, 2, 3, 4, 5, 5, 3, 4, 9, 10, 11, 12, 13, 14, 14, 12, 13, & + 18, 19, 20, 21, 22, 23, 23, 21, 22, 9, 10, 11, 12, 13, 14, 14, 12, 13, & + 0, 1, 2, 3, 4, 5, 5, 3, 4, 9, 10, 11, 12, 13, 14, 14, 12, 13, & + 18, 19, 20, 21, 22, 23, 23, 21, 22, 9, 10, 11, 12, 13, 14, 14, 12, 13, & + 0, 1, 2, 3, 4, 5, 5, 3, 4, 9, 10, 11, & + 12, 13, 14, 14, 12, 13, 18, 19, 20, 21, 22, 23, & + 23, 21, 22, 27, 28, 29, 30, 31, 32, 32, 30, 31, & + 0, 1, 2, 3, 4, 5, 5, 3, 4, 9, 10, 11, & + 12, 13, 14, 14, 12, 13, 18, 19, 20, 21, 22, 23, & + 23, 21, 22, 27, 28, 29, 30, 31, 32, 32, 30, 31], & + [36, 4]) + + k = 1 + do i = 0, 1 + do j = 0, 1 + is_time_reversal = 1 - i + swappable = 1 - j + n_ir_triplets = gridsys_get_triplets_at_q( & + map_triplets, map_q, grid_point, & + D_diag, is_time_reversal, num_rot, & + wurtzite_rec_rotations_without_time_reversal, & + swappable) + + call assert_int(n_ir_triplets, ref_num_triplets(k)) + write (*, '("check map_triplets")', advance='no') + call assert_1D_array_c_long(map_triplets, ref_map_triplets(:, k), 36) + write (*, '(" OK")') + write (*, '("check map_q")', advance='no') + call assert_1D_array_c_long(map_q, ref_map_q(:, k), 36) + write (*, '(" OK")') + k = k + 1 + end do + end do + end subroutine test_gridsys_get_triplets_at_q + + subroutine assert_int(val, ref_val) + integer, intent(in) :: val, ref_val + if (val /= ref_val) then + print '()' + print '(i0, "/=", i0)', val, ref_val + error stop + end if + end subroutine assert_int + + subroutine assert_1D_array_c_long(vals, ref_vals, size_of_array) + integer(c_long), intent(in) :: vals(:) + integer(c_long), intent(in) :: ref_vals(:) + integer, intent(in) :: size_of_array + integer :: i + + do i = 1, size_of_array + if (vals(i) /= ref_vals(i)) then + print '()' + print '(i0, ":", i0, " ", i0)', i, vals(i), ref_vals(i) + error stop + end if + end do + end subroutine assert_1D_array_c_long + + subroutine assert_2D_array_c_long(vals, ref_vals, shape_of_array) + integer(c_long), intent(in) :: vals(:, :) + integer(c_long), intent(in) :: ref_vals(:, :) + integer, intent(in) :: shape_of_array(:) + integer :: i, j + + do i = 1, shape_of_array(1) + do j = 1, shape_of_array(2) + if (vals(j, i) /= ref_vals(j, i)) then + print '()' + print '("(", i0, ",", i0, "):", i0, " ", i0)', i, j, vals(j, i), ref_vals(j, i) + error stop + end if + end do + end do + end subroutine assert_2D_array_c_long + end program test_gridsysf diff --git a/ctest/test_gridsys.cpp b/ctest/test_gridsys.cpp index 2cca856d..7eec77ea 100644 --- a/ctest/test_gridsys.cpp +++ b/ctest/test_gridsys.cpp @@ -983,7 +983,7 @@ TEST(test_gridsys, test_gridsys_get_triplets_at_q_wurtzite_force_SNF) { * The lattices generated with and without force_SNF are the same. * Therefore numbers of unique triplets should agree, which is this test. */ -TEST(test_gridsys, test_gridsys_get_BZ_triplets_at_q_wurtzite_force_SNF) { +TEST(test_gridsys, test_gridsys_get_bz_triplets_at_q_wurtzite_force_SNF) { long D_diag[2][3] = {{1, 5, 15}, {5, 5, 3}}; long PS[3] = {0, 0, 0}; long Q[2][3][3] = {{{-1, 0, -6}, {0, -1, 0}, {-1, 0, -5}}, @@ -1030,7 +1030,7 @@ TEST(test_gridsys, test_gridsys_get_BZ_triplets_at_q_wurtzite_force_SNF) { num_triplets_1 = gridsys_get_triplets_at_q( map_triplets, map_q, grid_point, D_diag[i], is_time_reversal[k], 12, rec_rotations[i], swappable[j]); - num_triplets_2 = gridsys_get_BZ_triplets_at_q( + num_triplets_2 = gridsys_get_bz_triplets_at_q( triplets, grid_point, bz_grid_addresses, bz_map, map_triplets, 75, D_diag[i], Q[i], 2); ASSERT_EQ(num_triplets_1, num_triplets_2); diff --git a/fortran/gridsysf.f90 b/fortran/gridsysf.f90 index 839b50f4..0b30c32e 100644 --- a/fortran/gridsysf.f90 +++ b/fortran/gridsysf.f90 @@ -34,165 +34,168 @@ module gridsysf - use iso_c_binding, only: c_char, c_long, c_double + use iso_c_binding, only: c_char, c_long, c_double - implicit none + implicit none - private + private - interface + interface - subroutine gridsys_get_all_grid_addresses(gr_grid_addresses, D_diag) bind(c) - import c_long - integer(c_long), intent(in) :: D_diag(3) - integer(c_long), intent(inout) :: gr_grid_addresses(3, *) - end subroutine gridsys_get_all_grid_addresses + subroutine gridsys_get_all_grid_addresses(gr_grid_addresses, D_diag) bind(c) + import c_long + integer(c_long), intent(in) :: D_diag(3) + integer(c_long), intent(inout) :: gr_grid_addresses(3, *) + end subroutine gridsys_get_all_grid_addresses + subroutine gridsys_get_double_grid_address(address_double, address, & + PS) bind(c) + import c_long + integer(c_long), intent(inout) :: address_double(3) + integer(c_long), intent(in) :: address(3) + integer(c_long), intent(in) :: PS(3) + end subroutine gridsys_get_double_grid_address - subroutine gridsys_get_double_grid_address(address_double, address, & - PS) bind(c) - import c_long - integer(c_long), intent(inout) :: address_double(3) - integer(c_long), intent(in) :: address(3) - integer(c_long), intent(in) :: PS(3) - end subroutine gridsys_get_double_grid_address + subroutine gridsys_get_grid_address_from_index(address, grid_index, D_diag) & + bind(c) + import c_long + integer(c_long), intent(inout) :: address(3) + integer(c_long), intent(in), value :: grid_index + integer(c_long), intent(in) :: D_diag(3) + end subroutine gridsys_get_grid_address_from_index + function gridsys_rotate_grid_index(grid_index, rotation, D_diag, PS) & + bind(c) + import c_long + integer(c_long), intent(in), value :: grid_index + integer(c_long), intent(in) :: rotation(3, 3) + integer(c_long), intent(in) :: D_diag(3) + integer(c_long), intent(in) :: PS(3) + integer(c_long) :: gridsys_rotate_grid_index + end function gridsys_rotate_grid_index - subroutine gridsys_get_grid_address_from_index(address, grid_index, D_diag) & - bind(c) - import c_long - integer(c_long), intent(inout) :: address(3) - integer(c_long), intent(in), value :: grid_index - integer(c_long), intent(in) :: D_diag(3) - end subroutine gridsys_get_grid_address_from_index + function gridsys_get_double_grid_index(address_double, D_diag, PS) bind(c) + import c_long + integer(c_long), intent(in) :: address_double(3) + integer(c_long), intent(in) :: D_diag(3) + integer(c_long), intent(in) :: PS(3) + integer(c_long) :: gridsys_get_double_grid_index + end function gridsys_get_double_grid_index + function gridsys_get_reciprocal_point_group(rec_rotations, rotations, & + num_rot, is_time_reversal) bind(c) + import c_long + integer(c_long), intent(inout) :: rec_rotations(3, 3, 48) + integer(c_long), intent(in) :: rotations(3, 3, *) + integer(c_long), intent(in), value :: num_rot + integer(c_long), intent(in), value :: is_time_reversal + integer(c_long) :: gridsys_get_reciprocal_point_group + end function gridsys_get_reciprocal_point_group - function gridsys_rotate_grid_index(grid_index, rotation, D_diag, PS) & - bind(c) - import c_long - integer(c_long), intent(in), value :: grid_index - integer(c_long), intent(in) :: rotation(3, 3) - integer(c_long), intent(in) :: D_diag(3) - integer(c_long), intent(in) :: PS(3) - integer(c_long) :: gridsys_rotate_grid_index - end function gridsys_rotate_grid_index + function gridsys_get_snf3x3(D_diag, P, Q, A) bind(c) + import c_long + integer(c_long), intent(inout) :: D_diag(3) + integer(c_long), intent(inout) :: P(3, 3) + integer(c_long), intent(inout) :: Q(3, 3) + integer(c_long), intent(in) :: A(3, 3) + integer(c_long) :: gridsys_get_snf3x3 + end function gridsys_get_snf3x3 + function gridsys_transform_rotations(transformed_rots, & + rotations, num_rot, D_diag, Q) bind(c) + import c_long + integer(c_long), intent(inout) :: transformed_rots(3, 3, *) + integer(c_long), intent(in) :: rotations(3, 3, *) + integer(c_long), intent(in), value :: num_rot + integer(c_long), intent(in) :: D_diag(3) + integer(c_long), intent(in) :: Q(3, 3) + integer(c_long) :: gridsys_transform_rotations + end function gridsys_transform_rotations - function gridsys_get_double_grid_index(address_double, D_diag, PS) bind(c) - import c_long - integer(c_long), intent(in) :: address_double(3) - integer(c_long), intent(in) :: D_diag(3) - integer(c_long), intent(in) :: PS(3) - integer(c_long) :: gridsys_get_double_grid_index - end function gridsys_get_double_grid_index + function gridsys_get_thm_integration_weight(omega, & + tetrahedra_omegas, function_char) bind(c) + import c_char, c_double + real(c_double), intent(in), value :: omega + real(c_double), intent(in) :: tetrahedra_omegas(4, 24) + character(kind=c_char), intent(in), value :: function_char + real(c_double) :: gridsys_get_thm_integration_weight + end function gridsys_get_thm_integration_weight + subroutine gridsys_get_thm_relative_grid_address(relative_grid_addresses, & + rec_lattice) bind(c) + import c_long, c_double + integer(c_long), intent(inout) :: relative_grid_addresses(3, 4, 24) + real(c_double), intent(in) :: rec_lattice(3, 3) + end subroutine gridsys_get_thm_relative_grid_address - function gridsys_get_reciprocal_point_group(rec_rotations, rotations, & - num_rot, is_time_reversal) bind(c) - import c_long - integer(c_long), intent(inout) :: rec_rotations(3, 3, 48) - integer(c_long), intent(in) :: rotations(3, 3, *) - integer(c_long), intent(in), value :: num_rot - integer(c_long), intent(in), value :: is_time_reversal - integer(c_long) :: gridsys_get_reciprocal_point_group - end function gridsys_get_reciprocal_point_group + subroutine gridsys_get_ir_grid_map(ir_grid_map, rotations, num_rot, & + D_diag, PS) bind(c) + import c_long + integer(c_long), intent(inout) :: ir_grid_map(*) + integer(c_long), intent(in) :: rotations(3, 3, *) + integer(c_long), intent(in), value :: num_rot + integer(c_long), intent(in) :: D_diag(3) + integer(c_long), intent(in) :: PS(3) + end subroutine gridsys_get_ir_grid_map + function gridsys_get_bz_grid_addresses(bz_grid_addresses, bz_map, & + bzg2grg, D_diag, Q, PS, rec_lattice, type) bind(c) + import c_long, c_double + integer(c_long), intent(inout) :: bz_grid_addresses(3, *) + integer(c_long), intent(inout) :: bz_map(*) + integer(c_long), intent(inout) :: bzg2grg(*) + integer(c_long), intent(in) :: D_diag(3) + integer(c_long), intent(in) :: Q(3, 3) + integer(c_long), intent(in) :: PS(3) + real(c_double), intent(in) :: rec_lattice(3, 3) + integer(c_long), intent(in), value :: type + integer(c_long) :: gridsys_get_bz_grid_addresses + end function gridsys_get_bz_grid_addresses - function gridsys_get_snf3x3(D_diag, P, Q, A) bind(c) - import c_long - integer(c_long), intent(inout) :: D_diag(3) - integer(c_long), intent(inout) :: P(3, 3) - integer(c_long), intent(inout) :: Q(3, 3) - integer(c_long), intent(in) :: A(3, 3) - integer(c_long) :: gridsys_get_snf3x3 - end function gridsys_get_snf3x3 + function gridsys_get_triplets_at_q(map_triplets, map_q, grid_point, & + D_diag, is_time_reversal, num_rot, rec_rotations, swappable) bind(c) + import c_long + integer(c_long), intent(inout) :: map_triplets(*) + integer(c_long), intent(inout) :: map_q(*) + integer(c_long), intent(in), value :: grid_point + integer(c_long), intent(in) :: D_diag(3) + integer(c_long), intent(in), value :: is_time_reversal + integer(c_long), intent(in), value :: num_rot + integer(c_long), intent(in) :: rec_rotations(3, 3, *) + integer(c_long), intent(in), value :: swappable + integer(c_long) :: gridsys_get_triplets_at_q + end function gridsys_get_triplets_at_q + function gridsys_get_bz_triplets_at_q(triplets, grid_point, bz_grid_addresses, & + bz_map, map_triplets, num_map_triplets, D_diag, Q, bz_grid_type) bind(c) + import c_long + integer(c_long), intent(inout) :: triplets(3, *) + integer(c_long), intent(in), value :: grid_point + integer(c_long), intent(in) :: bz_grid_addresses(3, *) + integer(c_long), intent(in) :: bz_map(*) + integer(c_long), intent(in) :: map_triplets(*) + integer(c_long), intent(in), value :: num_map_triplets + integer(c_long), intent(in) :: D_diag(3) + integer(c_long), intent(in) :: Q(3, 3) + integer(c_long), intent(in), value :: bz_grid_type + integer(c_long) :: gridsys_get_bz_triplets_at_q + end function gridsys_get_bz_triplets_at_q - function gridsys_transform_rotations(transformed_rots, & - rotations, num_rot, D_diag, Q) bind(c) - import c_long - integer(c_long), intent(inout) :: transformed_rots(3, 3, *) - integer(c_long), intent(in) :: rotations(3, 3, *) - integer(c_long), intent(in), value :: num_rot - integer(c_long), intent(in) :: D_diag(3) - integer(c_long), intent(in) :: Q(3, 3) - integer(c_long) :: gridsys_transform_rotations - end function gridsys_transform_rotations + end interface - - function gridsys_get_thm_integration_weight(omega, & - tetrahedra_omegas, function_char) bind(c) - import c_char, c_double - real(c_double), intent(in), value :: omega - real(c_double), intent(in) :: tetrahedra_omegas(4, 24) - character(kind=c_char), intent(in), value :: function_char - real(c_double) :: gridsys_get_thm_integration_weight - end function gridsys_get_thm_integration_weight - - - subroutine gridsys_get_thm_relative_grid_address(relative_grid_addresses, & - rec_lattice) bind(c) - import c_long, c_double - integer(c_long), intent(inout) :: relative_grid_addresses(3, 4, 24) - real(c_double), intent(in) :: rec_lattice(3, 3) - end subroutine gridsys_get_thm_relative_grid_address - - - subroutine gridsys_get_ir_grid_map(ir_grid_map, rotations, num_rot, & - D_diag, PS) bind(c) - import c_long - integer(c_long), intent(inout) :: ir_grid_map(*) - integer(c_long), intent(in) :: rotations(3, 3, *) - integer(c_long), intent(in), value :: num_rot - integer(c_long), intent(in) :: D_diag(3) - integer(c_long), intent(in) :: PS(3) - end subroutine gridsys_get_ir_grid_map - - - function gridsys_get_bz_grid_addresses(bz_grid_addresses, bz_map, & - bzg2grg, D_diag, Q, PS, rec_lattice, type) bind(c) - import c_long, c_double - integer(c_long), intent(inout) :: bz_grid_addresses(3, *) - integer(c_long), intent(inout) :: bz_map(*) - integer(c_long), intent(inout) :: bzg2grg(*) - integer(c_long), intent(in) :: D_diag(3) - integer(c_long), intent(in) :: Q(3, 3) - integer(c_long), intent(in) :: PS(3) - real(c_double), intent(in) :: rec_lattice(3, 3) - integer(c_long), intent(in), value :: type - integer(c_long) :: gridsys_get_bz_grid_addresses - end function gridsys_get_bz_grid_addresses - - - function gridsys_get_triplets_at_q(map_triplets, map_q, grid_point, & - D_diag, is_time_reversal, num_rot, rec_rotations, swappable) bind(c) - import c_long - integer(c_long), intent(inout) :: map_triplets(*) - integer(c_long), intent(inout) :: map_q(*) - integer(c_long), intent(in), value :: grid_point - integer(c_long), intent(in) :: D_diag(3) - integer(c_long), intent(in), value :: is_time_reversal - integer(c_long), intent(in), value :: num_rot - integer(c_long), intent(in) :: rec_rotations(3, 3, *) - integer(c_long), intent(in), value :: swappable - integer(c_long) :: gridsys_get_triplets_at_q - end function gridsys_get_triplets_at_q - - end interface - - - public :: gridsys_get_all_grid_addresses, & - gridsys_get_double_grid_address, & - gridsys_get_grid_address_from_index, & - gridsys_rotate_grid_index, & - gridsys_get_thm_relative_grid_address, & - gridsys_get_double_grid_index, & - gridsys_get_reciprocal_point_group, & - gridsys_get_snf3x3, & - gridsys_transform_rotations, & - gridsys_get_thm_integration_weight, & - gridsys_get_ir_grid_map, & - gridsys_get_bz_grid_addresses, & - gridsys_get_triplets_at_q + public :: gridsys_get_all_grid_addresses, & + gridsys_get_double_grid_address, & + gridsys_get_grid_address_from_index, & + gridsys_rotate_grid_index, & + gridsys_get_thm_relative_grid_address, & + gridsys_get_double_grid_index, & + gridsys_get_reciprocal_point_group, & + gridsys_get_snf3x3, & + gridsys_transform_rotations, & + gridsys_get_thm_integration_weight, & + gridsys_get_ir_grid_map, & + gridsys_get_bz_grid_addresses, & + gridsys_get_triplets_at_q, & + gridsys_get_bz_triplets_at_q end module gridsysf