Skip to content

Commit

Permalink
further improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
scarrazza committed Nov 15, 2023
1 parent 0c5bf3f commit 48ff7f9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
12 changes: 10 additions & 2 deletions capi/examples/fortran/example.f90
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ program example
integer, parameter :: dp = kind(1.d0)

integer :: pid(0:10), i
real(dp) :: alpha_s, q2(0:1), x(0:1), xfx(0:10)
real(dp) :: alpha_s, q2(0:1), x(0:1), xfx(0:11)
real(dp) :: q2_vectorized(0:2), as_vectorized(0:2)

character(kind=c_char, len=21) :: ss = "NNPDF31_nlo_as_0118/0"
character(kind=c_char, len=24) :: pp = "/usr/share/lhapdf/LHAPDF/"
Expand All @@ -26,7 +27,14 @@ program example
write(*, fmt=200)"Flavour: ", i - 5, " value: ", xfx(i)
enddo

100 format (A, F6.2, A, F4.2)
q2_vectorized(0) = 1.65
q2_vectorized(1) = 10.65
call alphasq2(q2_vectorized, 2, as_vectorized);

write(*, fmt=100)"alphas(q2=",q2_vectorized(0),") = ", as_vectorized(0)
write(*, fmt=100)"alphas(q2=",q2_vectorized(1),") = ", as_vectorized(1)

100 format (A, F10.7, A, F10.7)
200 format (" ", A, I0, A, F10.7)

end program
10 changes: 7 additions & 3 deletions capi/examples/fortran/pdfflow_f_interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,14 @@ void mkpdf_(const char *fname, const char *dirname) {
mkpdf(fname, dirname);
}

void alphasq2_(double *q2, int *n, double *alphas) {
alphas = alphasq2(q2, *n);
void alphasq2_(double *q2, const int *n, double *alphas) {
double *as = alphasq2(q2, *n);
for (int i = 0; i < *n; i++)
alphas[i] = as[i];
}

void xfxq2_(int *pid, const int *n, double *x, const int *m, double *q2, const int *o, double *f) {
f = xfxq2(pid, *n, x, *m, q2, *o);
double *xf = xfxq2(pid, *n, x, *m, q2, *o);
for (int i = 0; i < *n * *m * *o; i++)
f[i] = xf[i];
}

0 comments on commit 48ff7f9

Please sign in to comment.