Skip to content

Commit

Permalink
minor updates to readme
Browse files Browse the repository at this point in the history
  • Loading branch information
scarlehoff committed Nov 30, 2023
1 parent 48ff7f9 commit 9f3cc62
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 10 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -134,3 +134,5 @@ benchmarks/*.png
# cffi stuff
*.pc
cpdfflow.c
# example executables
example
15 changes: 10 additions & 5 deletions capi/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@ This repository contains a C library to access PDFFlow from programming language

Make sure you have installed the `pdfflow` module in Python, then in order to install proceed with the usual cmake steps:
```bash
mkdir build
cd build
cmake .. -DCMAKE_INSTALL_PREFIX=<your install prefix>
make
make install
cmake -S . -B build -DCMAKE_INSTALL_PREFIX=<your install prefix>
cmake --build build
cmake --install build
```

## Usage
Expand All @@ -23,4 +21,11 @@ pkg-config pdfflow --cflags
pkg-config pdfflow --libs
```

If you installed to a non-standard location, you need to set up the `PKG_CONFIG_PATH` and `LD_LIBRARY_PATH`, e.g.:
```bash
export PKG_CONFIG_PATH=${VIRTUAL_ENV}/lib/pkgconfig/:${PKG_CONFIG_PATH}:
export LD_LIBRARY_PATH=${VIRTUAL_ENV}/lib/:${LD_LIBRARY_PATH}:
```


Sample programs using this library are provided in the `capi/examples/` directory.
2 changes: 1 addition & 1 deletion capi/examples/example.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

int main() {
// load pdf
mkpdf("NNPDF31_nlo_as_0118/0", "/usr/share/lhapdf/LHAPDF/");
mkpdf("NNPDF40_nnlo_as_01180/0", "/usr/share/lhapdf/LHAPDF/");

// test xfxq2 and alphasq2
int pid[] = {-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5};
Expand Down
2 changes: 1 addition & 1 deletion capi/examples/fortran/example.f90
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ program example
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=23) :: ss = "NNPDF40_nnlo_as_01180/0"
character(kind=c_char, len=24) :: pp = "/usr/share/lhapdf/LHAPDF/"

call mkPDF(ss, pp)
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ install_requires =
where = src

[options.extras_require]
capi = ciffi
capi = cffi
docs =
sphinx_rtd_theme
recommonmark
Expand Down
9 changes: 7 additions & 2 deletions src/pdfflow/pflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ def mkPDF(fname, dirname=None):
----------
fname: str
PDF name and member in the format '<set_name>/<set member number>'
If the set number is not given, assume member 0
dirname: str
LHAPDF datadir, if None will try to guess from LHAPDF
Expand All @@ -116,8 +117,12 @@ def mkPDF(fname, dirname=None):
PDF: pdfflow.PDF
instantiated member of the PDF class
"""
fname_sp, member = fname.split("/")
member = int(member)
try:
fname_sp, member = fname.split("/")
member = int(member)
except ValueError:
fname_sp = fname
member = 0
return mkPDFs(fname_sp, [member], dirname=dirname)


Expand Down

0 comments on commit 9f3cc62

Please sign in to comment.