Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: FSPS Regression Tests

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
test-matrix:
runs-on: ubuntu-latest

env:
SPS_HOME: ${{ github.workspace }}
FSPS_TEST_RTOL: 1.0E-5 # Set global relative tolerance here

strategy:
fail-fast: false
matrix:
include:
# Define the configurations to test.
# 'opts': The library options passed to test_runner.
# 'ref_suffix': The suffix of the reference file in tests/data/

# 1. Standard (Default)
- name: MILES + MIST (default)
opts: "--isoc mist --spec miles"
ref_suffix: "MILES-1_MIST-1"

# 2. BaSeL+Padova
- name: BaSEL + Padova
opts: "--isoc pdva --spec basel"
ref_suffix: "MILES-0_MIST-0_BASEL-1_PADOVA-1"

# 3. Dust Model (THEMIS)
- name: THEMIS (dust)
opts: "--isoc mist --spec miles --dust themis"
ref_suffix: "MILES-1_MIST-1_THEMIS-1_DL07-0"

# 4. C3K
- name: C3K + MIST
opts: "--isoc mist --spec c3k_afe+0.0"
ref_suffix: "MILES-0_C3K-1_MIST-1"

# 5. BPASS (Different logic path)
- name: BPASS
opts: "--isoc bpss"
ref_suffix: "MIST-0_BPASS-1"

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Install GFortran
run: |
sudo apt-get update
sudo apt-get install -y gfortran

- name: Compile FSPS and Test Runner
# We force FFLAGS to include the matrix flags + standard flags + silence underflows
run: |
make clean
make test FFLAGS="-cpp -O3 -fPIC -ffpe-summary=invalid,zero,overflow"

- name: Run Test
run: |
./test_runner tests/data/sps_ref_${{ matrix.ref_suffix }}.bin ${{ matrix.opts }}
17 changes: 14 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
*.o
*.mod
*.exe
.DS_Store
nr
SPECTRA/CKC14/*
Expand All @@ -11,3 +8,17 @@ metalml.f90
colorteff.f90
bytype.f90
Makefile.prv

# Ignore compiler outputs
build/
*.o
*.mod
*.exe

# Executables produced by Makefile
autosps
simple
lesssimple
spec_bin
generate_test_data
test_runner
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2009-2021 Charlie Conroy & contributors.
Copyright (c) 2009-2026 Charlie Conroy & contributors.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
111 changes: 111 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
# ===================================
# Compiler Configuration
# ===================================

# Default to gfortran, allow for an override (e.g. make FC=ifort)
FC = gfortran

# Default flags
FFLAGS ?= -O3 -cpp -fPIC

# Directory configuration
SRC_DIR := src
TEST_DIR := tests
BUILD_DIR := build

# Module directory flags:
# Gfortran uses -J to specify where to put/find .mod files
# Intel (ifort) uses -module. We default to Gfortran syntax here.
# You can override this: make MOD_FLAG=-module
MOD_FLAG ?= -J

# Combine flags to include the build dir for .mod search
FCFLAGS := $(FFLAGS) $(MOD_FLAG)$(BUILD_DIR) -I$(BUILD_DIR)

# ===================================
# Source and Object Definitions
# ===================================

# Tell make to look for source files in these directories
VPATH = $(SRC_DIR):$(TEST_DIR)

# The list of programs to build (executables)
PROGS = simple lesssimple autosps spec_bin

# The common object files required by the programs
# We wrap them in addprefix to place them inside the build directory
COMMON_NAMES = sps_vars.o sps_utils.o compsp.o csp_gen.o ssp_gen.o \
getmags.o locate.o funcint.o sps_setup.o pz_convol.o \
get_tuniv.o intsfwght.o imf.o imf_weight.o add_dust.o \
getspec.o sbf.o add_bs.o mod_hb.o add_remnants.o getindx.o \
smoothspec.o mod_gb.o add_nebular.o add_xrb.o write_isochrone.o \
sfhstat.o linterp.o tsum.o add_agb_dust.o linterparr.o \
ztinterp.o vacairconv.o igm_absorb.o get_lumdist.o attn_curve.o \
sfh_weight.o sfhlimit.o sfhinfo.o setup_tabular_sfh.o agn_dust.o

COMMON_OBJS = $(addprefix $(BUILD_DIR)/, $(COMMON_NAMES))

# ===================================
# Rules
# ===================================

.PHONY: all clean test

all: $(PROGS)

# --- Compilation Rules ---

# Ensure build directory exists before compiling
$(BUILD_DIR):
@mkdir -p $(BUILD_DIR)

# Pattern rule: Compile any .f90 found in VPATH to .o in BUILD_DIR
$(BUILD_DIR)/%.o: %.f90 | $(BUILD_DIR)
$(FC) $(FCFLAGS) -c $< -o $@

# Specific dependencies to enforce compilation order

# sps_utils.o specifically depends on sps_vars.o
$(BUILD_DIR)/sps_utils.o: $(BUILD_DIR)/sps_vars.o

# All other common objects depend on both vars and utils.
REST_OF_COMMON = $(filter-out $(BUILD_DIR)/sps_vars.o $(BUILD_DIR)/sps_utils.o, $(COMMON_OBJS))

$(REST_OF_COMMON): $(BUILD_DIR)/sps_vars.o $(BUILD_DIR)/sps_utils.o

# Main program objects also wait for modules
$(BUILD_DIR)/simple.o $(BUILD_DIR)/lesssimple.o $(BUILD_DIR)/autosps.o $(BUILD_DIR)/spec_bin.o: $(BUILD_DIR)/sps_vars.o $(BUILD_DIR)/sps_utils.o

# Dependencies for test objects
$(BUILD_DIR)/generate_test_data.o: $(BUILD_DIR)/sps_vars.o $(BUILD_DIR)/sps_utils.o
$(BUILD_DIR)/test_runner.o: $(BUILD_DIR)/sps_vars.o $(BUILD_DIR)/sps_utils.o

# --- Linking Rules ---

autosps: $(BUILD_DIR)/autosps.o $(COMMON_OBJS)
$(FC) $(FCFLAGS) -o $@ $^

simple: $(BUILD_DIR)/simple.o $(COMMON_OBJS)
$(FC) $(FCFLAGS) -o $@ $^

lesssimple: $(BUILD_DIR)/lesssimple.o $(COMMON_OBJS)
$(FC) $(FCFLAGS) -o $@ $^

spec_bin: $(BUILD_DIR)/spec_bin.o $(BUILD_DIR)/sps_vars.o
$(FC) $(FCFLAGS) -o $@ $^

# --- Test Targets ---

generate_test_data: $(BUILD_DIR)/generate_test_data.o $(COMMON_OBJS)
$(FC) $(FCFLAGS) -o $@ $^

test_runner: $(BUILD_DIR)/test_runner.o $(COMMON_OBJS)
$(FC) $(FCFLAGS) -o $@ $^

test: test_runner

# --- Utilities ---

clean:
rm -rf $(BUILD_DIR) $(PROGS) generate_test_data test_runner

43 changes: 22 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
FSPS: Flexible Stellar Population Synthesis
=====
version 3.2
![Version Badge](https://img.shields.io/badge/version-v3.2-blue)

References
---------
When using this code please cite the following papers:
* Conroy, Gunn, & White 2009, ApJ, 699, 486
* Conroy & Gunn 2010, ApJ, 712, 833
* [Conroy, Gunn, & White 2009, ApJ, 699, 486](https://ui.adsabs.harvard.edu/abs/2009ApJ...699..486C)
* [Conroy & Gunn 2010, ApJ, 712, 833](https://ui.adsabs.harvard.edu/abs/2010ApJ...712..833C)

Installation
----------
If you have git installed, FSPS can be obtained with the following commands:
```
If you have Git installed, FSPS can be obtained with the following commands:

```sh
cd /path/to/desired/location/
git clone https://github.com/cconroy20/fsps
```
Otherwise download a gzipped tarball from [here](https://github.com/cconroy20/fsps/releases). Then follow the instructions at [doc/INSTALL](doc/INSTALL).
Otherwise download a gzipped tarball from [here](https://github.com/cconroy20/fsps/releases). Then follow the instructions at [`doc/INSTALL`](doc/INSTALL).

You should not need to update the git repository until an update is announced (which is why you need to be on the mailing list - see [doc/INSTALL](doc/INSTALL)). If you've obtained FSPS using git then when an update is announced you will need to simply type ``cd $SPS_HOME; git pull`` and then recompile. If you have made your own edits to the FSPS files, git will attempt to gracefully merge your local version with the repository version.
You should not need to update the Git repository until an update is announced (which is why you need to be on the mailing list - see [`doc/INSTALL`](doc/INSTALL)). If you've obtained FSPS using Git then when an update is announced you will need to simply type `cd $SPS_HOME; git pull` and then recompile (just type `make`). If you have made your own edits to the FSPS files, Git will attempt to gracefully merge your local version with the repository version.

Documentation
------
Expand All @@ -28,46 +29,46 @@ Contents
Below is a brief description of the contents of the directories in the
fsps root directory:

* `ISOCHRONES`: Contains the isochrone tables for the BaSTI and Padova
* [`ISOCHRONES`](ISOCHRONES): Contains the isochrone tables for the BaSTI and Padova
isochrone sets. The Geneva isochrones have been pasted onto the BaSTI
and Padova tables for high masses (M>70Msun), and the low-mass Lyon
models have been pasted on at low masses. You should not edit these
files unless you know what you're doing.

* `OUTPUTS`: Contains the outputs of a few example calls of the routines
* [`OUTPUTS`](OUTPUTS): Contains the outputs of a few example calls of the routines
autosps and simple. You may wish to use this directory for all
outputs of the fsps routines.

* `SPECTRA`: Contains the spectral libraries, the spectrum of an A0V star
* [`SPECTRA`](SPECTRA): Contains the spectral libraries, the spectrum of an A0V star
used to set the Vega magnitude zero points, and a spectrum of the Sun.
The BaSeL spectra (based on the Kurucz models) are in binary format,
primarily to make the read in time faster and to decrease the size of
the fsps download. The Hot_spectra directory contain the libraries
for O stars, WR stars, and post-AGB stars, from Smith et al. 2002 and
Rauch 2003, respectively.

* `data`: Contains files that define the set of filters and indices used
* `build`: Contains the compiled object files (`.o`) and Fortran modules (`.mod`).
This directory is automatically created when you run `make`.

* [`data`](data): Contains files that define the set of filters and indices used
in FSPS and the tabulated imfs and sfhs if those options are set. The
files in this directory are readily user editable.

* `doc`: Contains the manual, revision history, and installation
* [`doc`](doc): Contains the manual, revision history, and installation
instructions.

* `dust`: Contains the dust attenuation curves for the Witt & Gordon
* [`dust`](dust): Contains the dust attenuation curves for the Witt & Gordon
(2000) dust model and the dust emission spectra from the Draine & Li
2007 grain model. Also contains the circumstellar dust models from
Villaume et al. 2015 and the AGN dusty torus models of Nenkova et al. 2008.

* `nebular`: Contains the Cloudy lookup tables for nebular emission
* [`nebular`](nebular): Contains the Cloudy lookup tables for nebular emission
(both continuum and line emission) computed by Nell Byler.

* `pro`: Contains IDL files for reading in the .mag, .indx, and .spec
* [`pro`](pro): Contains IDL files for reading in the .mag, .indx, and .spec
output files

* `src`: Contains the source files and routines from Numerical Recipes.





* [`src`](src): Contains the source files and routines from Numerical Recipes.

* [`tests`](tests): Contains the regression test suite and scripts for generating
reference comparison data.
30 changes: 20 additions & 10 deletions doc/INSTALL
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
SETUP INSTRUCTIONS

1. edit your .cshrc (or .bashrc) file to something like:
setenv SPS_HOME /home/user/fsps/
(this should point to the directory containing the src directory)
1. Edit your .cshrc (or .bashrc/zshrc) file to set the SPS_HOME variable:
export SPS_HOME="/home/user/fsps/"
(this must point to the root directory containing the src/ directory)

2. edit the makefile in the src directory so that it is using your
fortran compiler one should then be able to compile everything by
simply typing "make"
2. Compile the code. The Makefile is located in the root directory.
By default, it uses gfortran. You can compile by simply typing:
make

If you wish to use a different compiler (e.g., ifort), you can specify it
on the command line without editing the Makefile:
make FC=ifort

3. email cconroy@cfa.harvard.edu so that I can keep you posted on updates.
-> this step is actually important! Every code has bugs. If I
don't know that you're using this code, I can't tell you
that I found a catastrophic bug that invalidates all of your
results.
don't know that you're using this code, I can't tell you
that I found a catastrophic bug that invalidates all of your
results.

4. please email me if have any problems or find any bugs.

Expand All @@ -23,4 +27,10 @@ NOTES:
1. It has been reported that the code crashes if compiled with
earlier versions of gfortran (specifically v4.2.1). The code has
been tested and compiles sucessfully with gfortran v4.4 and later.
(FYI, I currently compile FSPS with gfortran v6.4.0).
(FYI, I currently compile FSPS with gfortran v6.4.0).

2. As of 2026, the code allows for runtime selection of isochrones and
spectral libraries. You do NOT need to edit sps_vars.f90 and
recompile to switch between MIST, Padova, MILES, BaSeL, etc.
These options can now be passed directly to the setup routines or
selected interactively in the `autosps` driver.
16 changes: 15 additions & 1 deletion doc/REVISION_HISTORY
Original file line number Diff line number Diff line change
Expand Up @@ -149,4 +149,18 @@

04/2/21
- Release of v3.2
- added THEMIS dust emission model
- added THEMIS dust emission model

01/28/26
- Major modernization of the codebase and build system.
- Key Feature: Isochrone and spectral libraries can now be selected at
runtime. You no longer need to edit `sps_vars.f90` and recompile to switch
between MIST, Padova, MILES, BaSeL, etc.
- Implemented dynamic memory allocation throughout the driver programs
(`simple`, `lesssimple`, `autosps`), removing compile-time static array limits.
- `autosps` is now interactive and will prompt the user to select their desired
libraries at runtime.
- The `Makefile` has been moved to the root directory and now uses an
out-of-source build system (all artifacts are output to `build/`).
- Fixed legacy compiler warnings regarding FORMAT strings.
- Updated CI/CD infrastructure for regression testing.
Loading