diff --git a/examples/fortran/lhapdf_example_v1.f90 b/examples/fortran/lhapdf_example_v1.f90 index f9acf3c5..677ab5e3 100644 --- a/examples/fortran/lhapdf_example_v1.f90 +++ b/examples/fortran/lhapdf_example_v1.f90 @@ -11,8 +11,8 @@ program lhapdf_example type(pineappl_kinematics) :: kinematics(3) type(pineappl_interp_tuples) :: interpolations(3) - type (pineappl_xfx) :: xfx(2) - type (pineappl_alphas) :: alphas + type(pineappl_xfx) :: xfx(2) + type(pineappl_alphas) :: alphas integer(kind(pineappl_reweight_meth)) :: q2_reweight integer(kind(pineappl_reweight_meth)) :: x_reweight @@ -22,8 +22,8 @@ program lhapdf_example integer, target :: flags(2) - channels = pineappl_channel_new() - call pineappl_channel_add(channels, 3, 2, [0, 0, 1, -1, 2, -2], [1.0_dp, 1.0_dp, 1.0_dp]) + channels = pineappl_channels_new() + call pineappl_channels_add(channels, 3, 2, [0, 0, 1, -1, 2, -2], [1.0_dp, 1.0_dp, 1.0_dp]) kinematics = [& pineappl_kinematics(pineappl_scale, 0), & @@ -42,7 +42,7 @@ program lhapdf_example pineappl_interp_tuples(2e-7, 1.0, 50, 3, x_reweight, x_mapping, interpolation_meth) & ] - grid = pineappl_grid_new2(pineappl_pdg, channels, 1, [2_1, 0_1, 0_1, 0_1], 2, & + grid = pineappl_grid_new2(pineappl_pdg, channels, 1, [2_1, 0_1, 0_1, 0_1, 0_1], 2, & [0.0_dp, 1.0_dp, 2.0_dp], 2, [pineappl_unpol_pdf, pineappl_unpol_pdf], [2212, 2212], kinematics, interpolations, [1, 1, 0]) call pineappl_grid_fill_all2(grid, 0, 0.5_dp, [100.0_dp, 0.5_dp, 0.5_dp], [0.5_dp, 0.5_dp, 0.5_dp]) diff --git a/examples/fortran/pineappl.f90 b/examples/fortran/pineappl.f90 index a6856bd6..da2cc716 100644 --- a/examples/fortran/pineappl.f90 +++ b/examples/fortran/pineappl.f90 @@ -121,8 +121,8 @@ function strlen(s) bind(c, name="strlen") integer (c_size_t) :: strlen end function strlen - subroutine channel_add(lumi, combinations, nb_combinations, pdg_id_combinations, factors) & - bind(c, name = 'pineappl_channel_add') + subroutine channels_add(lumi, combinations, nb_combinations, pdg_id_combinations, factors) & + bind(c, name = 'pineappl_channels_add') use iso_c_binding type (c_ptr), value :: lumi @@ -131,7 +131,7 @@ subroutine channel_add(lumi, combinations, nb_combinations, pdg_id_combinations, real (c_double) :: factors(*) end subroutine - type (c_ptr) function channel_new() bind(c, name = 'pineappl_channel_new') + type (c_ptr) function channels_new() bind(c, name = 'pineappl_channels_new') use iso_c_binding end function @@ -481,7 +481,7 @@ subroutine lumi_entry(lumi, entry, pdg_ids, factors) bind(c, name = 'pineappl_lu real (c_double) :: factors(*) end subroutine - subroutine channel_entry(lumi, entry, pdg_ids, factors) bind(c, name = 'pineappl_channel_entry') + subroutine channels_entry(lumi, entry, pdg_ids, factors) bind(c, name = 'pineappl_channels_entry') use iso_c_binding type (c_ptr), value :: lumi integer (c_size_t), value :: entry @@ -524,10 +524,10 @@ function c_f_string(c_str) result(f_str) end do end function - type (pineappl_lumi) function pineappl_channel_new() + type (pineappl_lumi) function pineappl_channels_new() implicit none - pineappl_channel_new = pineappl_lumi(channel_new()) + pineappl_channels_new = pineappl_lumi(channels_new()) end function integer function pineappl_grid_bin_count(grid) @@ -1135,7 +1135,7 @@ subroutine pineappl_lumi_add(lumi, combinations, pdg_id_pairs, factors) call lumi_add(lumi%ptr, int(combinations, c_size_t), pdg_id_pairs, factors) end subroutine - subroutine pineappl_channel_add(channels, combinations, nb_combinations, pdg_id_combinations, factors) + subroutine pineappl_channels_add(channels, combinations, nb_combinations, pdg_id_combinations, factors) use iso_c_binding implicit none @@ -1145,7 +1145,7 @@ subroutine pineappl_channel_add(channels, combinations, nb_combinations, pdg_id_ integer, dimension(2 * combinations), intent(in) :: pdg_id_combinations real (dp), dimension(combinations), intent(in) :: factors - call channel_add(channels%ptr, int(combinations, c_size_t), int(nb_combinations, c_size_t), pdg_id_combinations, factors) + call channels_add(channels%ptr, int(combinations, c_size_t), int(nb_combinations, c_size_t), pdg_id_combinations, factors) end subroutine integer function pineappl_lumi_combinations(lumi, entry) @@ -1190,7 +1190,7 @@ subroutine pineappl_lumi_entry(lumi, entry, pdg_ids, factors) call lumi_entry(lumi%ptr, int(entry, c_size_t), pdg_ids, factors) end subroutine - subroutine pineappl_channel_entry(lumi, entry, pdg_ids, factors) + subroutine pineappl_channels_entry(lumi, entry, pdg_ids, factors) use iso_c_binding implicit none @@ -1200,7 +1200,7 @@ subroutine pineappl_channel_entry(lumi, entry, pdg_ids, factors) integer, intent(out) :: pdg_ids(*) real (dp), intent(out) :: factors(*) - call channel_entry(lumi%ptr, int(entry, c_size_t), pdg_ids, factors) + call channels_entry(lumi%ptr, int(entry, c_size_t), pdg_ids, factors) end subroutine type (pineappl_lumi) function pineappl_lumi_new() diff --git a/examples/fortran/test_v1.f90 b/examples/fortran/test_v1.f90 index b7961173..85c4544a 100644 --- a/examples/fortran/test_v1.f90 +++ b/examples/fortran/test_v1.f90 @@ -22,8 +22,8 @@ program test_pineappl type (pineappl_xfx) :: xfx1, xfx2 type (pineappl_alphas) :: alphas - channels = pineappl_channel_new() - call pineappl_channel_add(channels, 3, 2, [0, 0, 1, -1, 2, -2], [1.0_dp, 1.0_dp, 1.0_dp]) + channels = pineappl_channels_new() + call pineappl_channels_add(channels, 3, 2, [0, 0, 1, -1, 2, -2], [1.0_dp, 1.0_dp, 1.0_dp]) if (pineappl_lumi_count(channels) /= 1) then write(*, *) "pineappl_lumi_count(): ", pineappl_lumi_count(channels) diff --git a/pineappl_capi/src/lib.rs b/pineappl_capi/src/lib.rs index dc423a7c..7ee339ab 100644 --- a/pineappl_capi/src/lib.rs +++ b/pineappl_capi/src/lib.rs @@ -1396,19 +1396,21 @@ pub extern "C" fn pineappl_channels_new() -> Box { /// # Safety /// /// The parameter `lumi` must point to a valid `Lumi` object created by `pineappl_lumi_new`. -/// `pdg_id_combinations` must be an array with length `n_combinations * combinations`, and -/// `factors` with length of `combinations`. +/// `pdg_id_combinations` must be an array with length `nb_combinations * combinations`, and +/// `factors` with length of `combinations`. The `nb_convolutions` describe the number of +/// parton distributions involved, while `combinations` represent the number of different +/// channel combinations. #[no_mangle] pub unsafe extern "C" fn pineappl_channels_add( channels: *mut Lumi, combinations: usize, - nb_combinations: usize, + nb_convolutions: usize, pdg_id_combinations: *const i32, factors: *const f64, ) { let channels = unsafe { &mut *channels }; let pdg_id_pairs = - unsafe { slice::from_raw_parts(pdg_id_combinations, nb_combinations * combinations) }; + unsafe { slice::from_raw_parts(pdg_id_combinations, nb_convolutions * combinations) }; let factors = if factors.is_null() { vec![1.0; combinations] } else { @@ -1417,9 +1419,9 @@ pub unsafe extern "C" fn pineappl_channels_add( channels.0.push(Channel::new( pdg_id_pairs - .chunks(nb_combinations) + .chunks(nb_convolutions) .zip(factors) - .map(|x| ((0..nb_combinations).map(|i| x.0[i]).collect(), x.1)) + .map(|x| ((0..nb_convolutions).map(|i| x.0[i]).collect(), x.1)) .collect(), )); }