Skip to content

Commit

Permalink
Updated Makefile to fix MAC issues with sed, and to propagate library…
Browse files Browse the repository at this point in the history
… definition to XSPEC wrappers.
  • Loading branch information
garciafederico committed Oct 25, 2022
1 parent a64d21a commit de87a61
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 26 deletions.
38 changes: 29 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ FCFLAGS := $(FCFLAGS) -O5 -Wall -fPIC
LDFLAGS = -L/usr/local/include
LDLIBS = -lopenblas

OS := $(shell uname -s)

DEPSDIR := ./dependencies

DEPSSRC := $(shell find $(DEPSDIR)/ -name \*.f)
Expand Down Expand Up @@ -42,22 +44,40 @@ $(DEPSDIR)/%.o: $(DEPSDIR)/%.f
# $(FC) $(FCFLAGS) -c $<


all: loader version vkompth_lin vkompth_log vkompth_bb vkompth_dk vkompthbb vkompthdk vkdualbb vkdualdk vkddka pyvkompth
all: loader version vkompth_lin vkompth_log vkompth_bb vkompth_dk makefile_libs vkompthbb vkompthdk vkdualbb vkdualdk vkddka pyvkompth

model: vkompth_lin vkompth_log vkompth_bb vkompth_dk

wrappers: loader version vkompthbb vkompthdk vkdualbb vkdualdk vkddka pyvkompth
wrappers: loader version makefile_libs vkompthbb vkompthdk vkdualbb vkdualdk vkddka pyvkompth

loader:
@echo "\nApply PATHTO to load_vkompth.xcm...\n"
sed -i "s|/PATHTO|$$(pwd)|g" load_vkompth.xcm
#For MAC, use: sed -i '' "s|/PATHTO|$$(pwd)|g" load_vkompth.xcm
sed "s|/PATHTO|$$(pwd)|g" load_vkompth.xcm > load_vkompth.tmp; mv load_vkompth.tmp load_vkompth.xcm
@echo "\n ... Done.\n\n"

version:
@echo "\nApply VERSION number to XSPEC model wrappers...\n"
sed -i s/VERSION/$$(cat VERSION)/g */*.f90
#For MAC, use: sed -i '' s/VERSION/$$(cat VERSION)/g */*.f90
@echo "\nApply VERSION number $$(cat VERSION) to XSPEC model wrappers...\n"
for f90 in $(shell ls */*.f90); do echo $$f90; sed s/VERSION/$$(cat VERSION)/g $$f90 > $$f90.tmp; mv $$f90.tmp $$f90; done
@echo "\n ... Done.\n\n"

makefile_libs:
@echo "\nApply LDFLAGS and LDLIBS variables to wrappers Makefile_libs files...\n"
cd vkompthbb; \
sed "5s,.*,LDFLAGS=$(LDFLAGS)," Makefile_libs > Makefile_libs.tmp; mv Makefile_libs.tmp Makefile_libs; \
sed "6s,.*,LDLIBS=$(LDLIBS)," Makefile_libs > Makefile_libs.tmp; mv Makefile_libs.tmp Makefile_libs; \
cd ../vkompthdk; \
sed "5s,.*,LDFLAGS=$(LDFLAGS)," Makefile_libs > Makefile_libs.tmp; mv Makefile_libs.tmp Makefile_libs; \
sed "6s,.*,LDLIBS=$(LDLIBS)," Makefile_libs > Makefile_libs.tmp; mv Makefile_libs.tmp Makefile_libs; \
cd ../vkdualbb; \
sed "5s,.*,LDFLAGS=$(LDFLAGS)," Makefile_libs > Makefile_libs.tmp; mv Makefile_libs.tmp Makefile_libs; \
sed "6s,.*,LDLIBS=$(LDLIBS)," Makefile_libs > Makefile_libs.tmp; mv Makefile_libs.tmp Makefile_libs; \
cd ../vkdualdk; \
sed "5s,.*,LDFLAGS=$(LDFLAGS)," Makefile_libs > Makefile_libs.tmp; mv Makefile_libs.tmp Makefile_libs; \
sed "6s,.*,LDLIBS=$(LDLIBS)," Makefile_libs > Makefile_libs.tmp; mv Makefile_libs.tmp Makefile_libs; \
cd ../vkddka ; \
sed "5s,.*,LDFLAGS=$(LDFLAGS)," Makefile_libs > Makefile_libs.tmp; mv Makefile_libs.tmp Makefile_libs; \
sed "6s,.*,LDLIBS=$(LDLIBS)," Makefile_libs > Makefile_libs.tmp; mv Makefile_libs.tmp Makefile_libs; \
cd .. ;
@echo "\n ... Done.\n\n"

vkompth_lin: $(DEPSOBJ) $(SCOOBJ) $(XSOBJ)
Expand Down Expand Up @@ -89,11 +109,11 @@ vkddka:

pyvkompth:
cd pyvkompth; \
python -m numpy.f2py -lopenblas -c pyvkompthbb.pyf pyvkompthbb.f90 \
python -m numpy.f2py $(LDFLAGS) $(LDLIBS) -c pyvkompthbb.pyf pyvkompthbb.f90 \
../sco_arrays.f90 ../sco_global.f90 ../sco_band_integration.f90 \
../sco_mppinv.f90 ../sco_simpson.f90 ../sco_par.f90 \
../sco_model_LOGbb.f90 ../dependencies/*.f ../xsbbrd.f; \
python -m numpy.f2py -lopenblas -c pyvkompthdk.pyf pyvkompthdk.f90 \
python -m numpy.f2py $(LDFLAGS) $(LDLIBS) -c pyvkompthdk.pyf pyvkompthdk.f90 \
../sco_arrays.f90 ../sco_global.f90 ../sco_band_integration.f90 \
../sco_mppinv.f90 ../sco_simpson.f90 ../sco_par.f90 \
../sco_model_LOG_dskb.f90 ../dependencies/*.f ../xsdskb.f; cd ..
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ This is the Fortran version of the [vKompth](https://github.com/candebellavita/v

## Requirements

In order to invert the matrix of the linear problem, `vKompth` requires the `DGTSV`, `ZGETRF` and `ZGETRS` routines from the [Lapack](https://www.netlib.org/lapack) or [openBLAS](https://www.openblas.net/) libraries, which have to be installed in your system. Before compiling the code check the `lopenblas` choice under the `LDFLAGS` variable in the `Makefile` and change it to `lopenblas`, `lopenblasp` or `llapack`, depending the one you have installed in your system.
In order to invert the matrix of the linear problem, `vKompth` requires the `DGTSV`, `ZGETRF` and `ZGETRS` routines from the [Lapack](https://www.netlib.org/lapack) or [openBLAS](https://www.openblas.net/) libraries, which have to be installed in your system. Before compiling the code check the `lopenblas` choice under the `LDLIBS` variable in the `Makefile` and change it to `lopenblas`, `lopenblasp` or `llapack`, depending the one you have installed in your system, and `LDFLAGS` to the directory where the library is installed.

Make sure you have [HEASOFT](https://heasarc.gsfc.nasa.gov/lheasoft/) installed from the source version, and set it up before compiling the *XSPEC* models. This model has to be compiled with the same compiler version used for *HEASOFT* to ensure compatibility. Read the *HEASOFT* pages about compilers.

In order to compile the *python* wrappers, you need to have a working `python3` environment set up, including `numpy` and `matplotlib` libraries.
In order to compile the *python* wrappers, you need to have a working `python3` environment set up, including `numpy` and `matplotlib` packages.


## Compile the main code, *XSPEC* models and *python* wrapper
Expand Down
6 changes: 3 additions & 3 deletions vkddka/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Instructions for Compilation under XSPEC

1) First load HEASOFT (heainit, export, etc...).
2) Edit the Makefile_libs "lopenblas" to your preferred value
(lopenblas, lopenblasp, llapack, etc).
2) Edit the Makefile_libs LDFLAGS and LDLIBS variables
to your preferred values (lopenblas, lopenblasp, llapack, etc).
3) Then, run:

```
Expand All @@ -12,7 +12,7 @@ hmake
```

We use Makefile_libs to inject all the dependencies of our
XPEC model with the files on the top dir, and openblas
XSPEC model with the files on the top dir, and openblas
library for multithreading.

3) Before running XSPEC, please set your `OPENBLAS_NUM_THREADS`
Expand Down
6 changes: 3 additions & 3 deletions vkdualbb/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Instructions for Compilation under XSPEC

1) First load HEASOFT (heainit, export, etc...).
2) Edit the Makefile_libs "lopenblas" to your preferred value
(lopenblas, lopenblasp, llapack, etc).
2) Edit the Makefile_libs LDFLAGS and LDLIBS variables
to your preferred values (lopenblas, lopenblasp, llapack, etc).
3) Then, run:

```
Expand All @@ -12,7 +12,7 @@ hmake
```

We use Makefile_libs to inject all the dependencies of our
XPEC model with the files on the top dir, and openblas
XSPEC model with the files on the top dir, and openblas
library for multithreading.

3) Before running XSPEC, please set your `OPENBLAS_NUM_THREADS`
Expand Down
6 changes: 3 additions & 3 deletions vkdualdk/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Instructions for Compilation under XSPEC

1) First load HEASOFT (heainit, export, etc...).
2) Edit the Makefile_libs "lopenblas" to your preferred value
(lopenblas, lopenblasp, llapack, etc).
2) Edit the Makefile_libs LDFLAGS and LDLIBS variables
to your preferred values (lopenblas, lopenblasp, llapack, etc).
3) Then, run:

```
Expand All @@ -12,7 +12,7 @@ hmake
```

We use Makefile_libs to inject all the dependencies of our
XPEC model with the files on the top dir, and openblas
XSPEC model with the files on the top dir, and openblas
library for multithreading.

3) Before running XSPEC, please set your `OPENBLAS_NUM_THREADS`
Expand Down
6 changes: 3 additions & 3 deletions vkompthbb/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Instructions for Compilation under XSPEC

1) First load HEASOFT (heainit, export, etc...).
2) Edit the Makefile_libs "lopenblas" to your preferred value
(lopenblas, lopenblasp, llapack, etc).
2) Edit the Makefile_libs LDFLAGS and LDLIBS variables
to your preferred values (lopenblas, lopenblasp, llapack, etc).
3) Then, run:

```
Expand All @@ -12,7 +12,7 @@ hmake
```

We use Makefile_libs to inject all the dependencies of our
XPEC model with the files on the top dir, and openblas
XSPEC model with the files on the top dir, and openblas
library for multithreading.

3) Before running XSPEC, please set your `OPENBLAS_NUM_THREADS`
Expand Down
6 changes: 3 additions & 3 deletions vkompthdk/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Instructions for Compilation under XSPEC

1) First load HEASOFT (heainit, export, etc...).
2) Edit the Makefile_libs "lopenblas" to your preferred value
(lopenblas, lopenblasp, llapack, etc).
2) Edit the Makefile_libs LDFLAGS and LDLIBS variables
to your preferred values (lopenblas, lopenblasp, llapack, etc).
3) Then, run:

```
Expand All @@ -12,7 +12,7 @@ hmake
```

We use Makefile_libs to inject all the dependencies of our
XPEC model with the files on the top dir, and openblas
XSPEC model with the files on the top dir, and openblas
library for multithreading.

3) Before running XSPEC, please set your `OPENBLAS_NUM_THREADS`
Expand Down

0 comments on commit de87a61

Please sign in to comment.