commit a53e4fca30b0b2b73e3fb175383f6d263a0081ce
parent 80d4207d8e37130b02fa8c772b6d4c9e567f72c9
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Sat, 29 Mar 2025 16:39:04 +0100
Merge remote-tracking branch 'origin/feature_master_storage' into develop
Diffstat:
13 files changed, 1028 insertions(+), 822 deletions(-)
diff --git a/Makefile b/Makefile
@@ -26,626 +26,50 @@
include config.mk
-ATMOSPHERE_LIBNAME = libhtrdr-atmosphere.a
-COMBUSTION_LIBNAME = libhtrdr-combustion.a
-PLANETS_LIBNAME = libhtrdr-planets.a
-
-PKG_CONFIG_LOCAL = PKG_CONFIG_PATH="./:$${PKG_CONFIG_PATH}" $(PKG_CONFIG)
-
-# Define macros when ATMOSPHERE is set to ENABLE
-ATMOSPHERE_CFLAGS_ENABLE = $$($(PKG_CONFIG_LOCAL) --static --cflags htrdr-atmosphere)
-ATMOSPHERE_LIBS_ENABLE = $$($(PKG_CONFIG_LOCAL) --static --libs htrdr-atmosphere)
-ATMOSPHERE_BUILD_LIB_ENABLE = build_atmosphere
-ATMOSPHERE_BUILD_CMD_ENABLE = build_htrdr_atmosphere
-ATMOSPHERE_LIBNAME_ENABLE = $(ATMOSPHERE_LIBNAME)
-
-# Define macros when COMBUSTION is set to ENABLE
-COMBUSTION_CFLAGS_ENABLE = $$($(PKG_CONFIG_LOCAL) --static --cflags htrdr-combustion)
-COMBUSTION_LIBS_ENABLE = $$($(PKG_CONFIG_LOCAL) --static --libs htrdr-combustion)
-COMBUSTION_BUILD_LIB_ENABLE = build_combustion
-COMBUSTION_BUILD_CMD_ENABLE = build_htrdr_combustion
-COMBUSTION_LIBNAME_ENABLE = $(COMBUSTION_LIBNAME)
-
-# Define macros when PLANETS is set to ENABLE
-PLANETS_CFLAGS_ENABLE = $$($(PKG_CONFIG_LOCAL) --static --cflags htrdr-planets)
-PLANETS_LIBS_ENABLE = $$($(PKG_CONFIG_LOCAL) --static --libs htrdr-planets)
-PLANETS_BUILD_LIB_ENABLE = build_planets
-PLANETS_BUILD_CMD_ENABLE = build_htrdr_planets
-PLANETS_LIBNAME_ENABLE = $(PLANETS_LIBNAME)
-
-# Default target
-all:\
- build_htrdr\
- build_htrdr_atmosphere\
- build_htrdr_combustion\
- build_htrdr_planets\
- man
-
-# Check commands dependencies
-.config_commands: config.mk
- $(PKG_CONFIG) --atleast-version $(RSYS_VERSION) rsys
- echo 'config done' > $@
-
-# Inference rules for command build
-.SUFFIXES: .c .d .o
-.c.d:
- @$(CC) $(CFLAGS_EXE) $(HTRDR_DPDC_CFLAGS) -MM -MT "$(@:.d=.o) $@" \
- $< -MF $@
-
-.c.o:
- $(CC) $(CFLAGS_EXE) $(HTRDR_DPDC_CFLAGS) -c $< -o $@
-
-################################################################################
-# Build the htrdr command
-################################################################################
-HTRDR_SRC = src/commands/htrdr_cmd.c
-HTRDR_OBJ = $(HTRDR_SRC:.c=.o)
-HTRDR_DEP = $(HTRDR_SRC:.c=.d)
-
-HTRDR_DPDC_CFLAGS =\
- $$($(PKG_CONFIG_LOCAL) $(PCFLAGS) --cflags htrdr-core)\
- $(ATMOSPHERE_CFLAGS_$(ATMOSPHERE))\
- $(COMBUSTION_CFLAGS_$(COMBUSTION))\
- $(PLANETS_CFLAGS_$(PLANETS))\
- $(RSYS_CFLAGS)
-
-HTRDR_DPDC_LIBS =\
- $$($(PKG_CONFIG_LOCAL) $(PCFLAGS) --libs htrdr-core)\
- $(ATMOSPHERE_LIBS_$(ATMOSPHERE))\
- $(COMBUSTION_LIBS_$(COMBUSTION))\
- $(PLANETS_LIBS_$(PLANETS))\
- $(RSYS_LIBS)
-
-HTRDR_DPDC_BUILD =\
- build_core\
- $(ATMOSPHERE_BUILD_LIB_$(ATMOSPHERE))\
- $(COMBUSTION_BUILD_LIB_$(COMBUSTION))\
- $(PLANETS_BUILD_LIB_$(PLANETS))
-
-HTRDR_DPDC_PREREQ =\
- $(CORE_LIBNAME)\
- $(ATMOSPHERE_LIBNAME_$(ATMOSPHERE))\
- $(COMBUSTION_LIBNAME_$(COMBUSTION))\
- $(PLANETS_LIBNAME_$(PLANETS))
-
-build_htrdr: .config_commands $(HTRDR_DPDC_BUILD) $(HTRDR_DEP)
- @$(MAKE) -fMakefile -f $(HTRDR_DEP) htrdr
-
-htrdr: config.mk $(HTRDR_OBJ) $(HTRDR_DPDC_PREREQ)
- $(CC) $(CFLAGS_EXE) $(HTRDR_DPDC_CFLAGS) -o $@ \
- $(HTRDR_OBJ) $(LDFLAGS_EXE) $(HTRDR_DPDC_LIBS)
-
-$(HTRDR_OBJ) $(HTRDR_DEP): config.mk
-
-clean_htrdr:
- rm -f htrdr $(HTRDR_OBJ) $(HTRDR_DEP)
- rm -f .config_commands
-
-################################################################################
-# Build the htrdr-atmosphere command
-################################################################################
-HTRDR_ATMOSPHERE_SRC = src/commands/htrdr_atmosphere_cmd.c
-HTRDR_ATMOSPHERE_OBJ = $(HTRDR_ATMOSPHERE_SRC:.c=.o)
-HTRDR_ATMOSPHERE_DEP = $(HTRDR_ATMOSPHERE_SRC:.c=.d)
-
-HTRDR_ATMOSPHERE_DPDC_LIBS = $(ATMOSPHERE_LIBS_$(ATMOSPHERE))
-HTRDR_ATMOSPHERE_DPDC_BUILD = build_core $(ATMOSPHERE_BUILD_LIB_$(ATMOSPHERE))
-HTRDR_ATMOSPHERE_DPDC_PREREQ = $(CORE_LIBNAME) $(ATMOSPHERE_LIBNAME_$(ATMOSPHERE))
-
-build_htrdr_atmosphere:\
- .config_commands\
- $(HTRDR_ATMOSPHERE_DPDC_BUILD)\
- $(HTRDR_ATMOSPHERE_DEP)
- @$(MAKE) -fMakefile -f $(HTRDR_ATMOSPHERE_DEP) htrdr-atmosphere
-
-htrdr-atmosphere: config.mk $(HTRDR_ATMOSPHERE_OBJ) $(HTRDR_ATMOSPHERE_DPDC_PREREQ)
- $(CC) $(CFLAGS_EXE) $(HTRDR_DPDC_CFLAGS) -o $@ \
- $(HTRDR_ATMOSPHERE_OBJ) $(LDFLAGS_EXE) $(HTRDR_ATMOSPHERE_DPDC_LIBS)
-
-$(HTRDR_ATMOSPHERE_OBJ) $(HTRDR_ATMOSPHERE_DEP): config.mk
-
-clean_htrdr-atmosphere:
- rm -f htrdr-atmosphere $(HTRDR_ATMOSPHERE_OBJ) $(HTRDR_ATMOSPHERE_DEP)
- rm -f .config_commands
-
-################################################################################
-# Build the htrdr-combustion command
-################################################################################
-HTRDR_COMBUSTION_SRC = src/commands/htrdr_combustion_cmd.c
-HTRDR_COMBUSTION_OBJ = $(HTRDR_COMBUSTION_SRC:.c=.o)
-HTRDR_COMBUSTION_DEP = $(HTRDR_COMBUSTION_SRC:.c=.d)
-
-HTRDR_COMBUSTION_DPDC_LIBS = $(COMBUSTION_LIBS_$(COMBUSTION))
-HTRDR_COMBUSTION_DPDC_BUILD = build_core $(COMBUSTION_BUILD_LIB_$(COMBUSTION))
-HTRDR_COMBUSTION_DPDC_PREREQ = $(CORE_LIBNAME) $(COMBUSTION_LIBNAME_$(COMBUSTION))
-
-build_htrdr_combustion:\
- .config_commands\
- $(HTRDR_COMBUSTION_DPDC_BUILD)\
- $(HTRDR_COMBUSTION_DEP)
- @$(MAKE) -fMakefile -f $(HTRDR_COMBUSTION_DEP) htrdr-combustion
-
-htrdr-combustion: config.mk $(HTRDR_COMBUSTION_OBJ) $(HTRDR_COMBUSTION_DPDC_PREREQ)
- $(CC) $(CFLAGS_EXE) $(HTRDR_DPDC_CFLAGS) -o $@ \
- $(HTRDR_COMBUSTION_OBJ) $(LDFLAGS_EXE) $(HTRDR_COMBUSTION_DPDC_LIBS)
-
-$(HTRDR_COMBUSTION_OBJ) $(HTRDR_COMBUSTION_DEP): config.mk
-
-clean_htrdr-combustion:
- rm -f htrdr-combustion $(HTRDR_COMBUSTION_OBJ) $(HTRDR_COMBUSTION_DEP)
- rm -f .config_commands
-
-################################################################################
-# Build the htrdr-planets command
-################################################################################
-HTRDR_PLANETS_SRC = src/commands/htrdr_planets_cmd.c
-HTRDR_PLANETS_OBJ = $(HTRDR_PLANETS_SRC:.c=.o)
-HTRDR_PLANETS_DEP = $(HTRDR_PLANETS_SRC:.c=.d)
-
-HTRDR_PLANETS_DPDC_LIBS = $(PLANETS_LIBS_$(PLANETS))
-HTRDR_PLANETS_DPDC_BUILD = build_core $(PLANETS_BUILD_LIB_$(PLANETS))
-HTRDR_PLANETS_DPDC_PREREQ = $(CORE_LIBNAME) $(PLANETS_LIBNAME_$(PLANETS))
-
-build_htrdr_planets:\
- .config_commands\
- $(HTRDR_PLANETS_DPDC_BUILD)\
- $(HTRDR_PLANETS_DEP)
- @$(MAKE) -fMakefile -f $(HTRDR_PLANETS_DEP) htrdr-planets
-
-htrdr-planets: config.mk $(HTRDR_PLANETS_OBJ) $(HTRDR_PLANETS_DPDC_PREREQ)
- $(CC) $(CFLAGS_EXE) $(HTRDR_DPDC_CFLAGS) -o $@ \
- $(HTRDR_PLANETS_OBJ) $(LDFLAGS_EXE) $(HTRDR_PLANETS_DPDC_LIBS)
-
-$(HTRDR_PLANETS_OBJ) $(HTRDR_PLANETS_DEP): config.mk
-
-clean_htrdr-planets:
- rm -f htrdr-planets $(HTRDR_PLANETS_OBJ) $(HTRDR_PLANETS_DEP)
- rm -f .config_commands
-
-################################################################################
-# Building the core
-################################################################################
-CORE_LIBNAME_STATIC = libhtrdr-core.a
-CORE_LIBNAME_SHARED = libhtrdr-core.so
-CORE_LIBNAME = $(CORE_LIBNAME_$(LIB_TYPE))
-
-CORE_SRC =\
- src/core/htrdr.c\
- src/core/htrdr_args.c\
- src/core/htrdr_buffer.c\
- src/core/htrdr_draw_map.c\
- src/core/htrdr_geometry.c\
- src/core/htrdr_log.c\
- src/core/htrdr_materials.c\
- src/core/htrdr_proc_work.c\
- src/core/htrdr_ran_wlen_cie_xyz.c\
- src/core/htrdr_ran_wlen_discrete.c\
- src/core/htrdr_ran_wlen_planck.c\
- src/core/htrdr_rectangle.c\
- src/core/htrdr_slab.c\
- src/core/htrdr_solve_buffer.c\
- src/core/htrdr_spectral.c
-CORE_OBJ = $(CORE_SRC:.c=.o)
-CORE_DEP = $(CORE_SRC:.c=.d)
-
-build_core: .config_core htrdr-core.pc $(CORE_DEP)
- @$(MAKE) -fMakefile $$(for i in $(CORE_DEP); do echo -f $${i}; done) \
- $$(if [ -n "$(CORE_LIBNAME)" ]; then \
- echo "$(CORE_LIBNAME)"; \
- else \
- echo "$(CORE_LIBNAME_SHARED)"; \
- fi)
-
-$(CORE_DEP) $(CORE_OBJ): config.mk src/core/htrdr_args.h src/core/htrdr_version.h
-
-$(CORE_LIBNAME_SHARED): $(CORE_OBJ)
- $(CC) $(CFLAGS_SO) $(CORE_DPDC_CFLAGS) -o $@ $(CORE_OBJ) $(LDFLAGS_SO) $(CORE_DPDC_LIBS)
-
-$(CORE_LIBNAME_STATIC): libhtrdr-core.o
- $(AR) -rc $@ $?
- $(RANLIB) $@
-
-libhtrdr-core.o: $(CORE_OBJ)
- $(LD) -r $(CORE_OBJ) -o $@
- $(OBJCOPY) $(OCPFLAGS) $@
-
-.config_core: config.mk
- $(PKG_CONFIG) --atleast-version $(AW_VERSION) aw
- $(PKG_CONFIG) --atleast-version $(MPI_VERSION) $(MPI_PC)
- $(PKG_CONFIG) --atleast-version $(MRUMTL_VERSION) mrumtl
- $(PKG_CONFIG) --atleast-version $(RSYS_VERSION) rsys
- $(PKG_CONFIG) --atleast-version $(S3D_VERSION) s3d
- $(PKG_CONFIG) --atleast-version $(SCAM_VERSION) scam
- $(PKG_CONFIG) --atleast-version $(SSF_VERSION) ssf
- $(PKG_CONFIG) --atleast-version $(SSP_VERSION) star-sp
- echo 'config done' > $@
-
-src/core/htrdr_args.h: config.mk src/core/htrdr_args.h.in
- sed -e 's/@HTRDR_ARGS_CAMERA_PERSPECTIVE_FOV_EXCLUSIVE_MIN@/$(HTRDR_ARGS_CAMERA_PERSPECTIVE_FOV_EXCLUSIVE_MIN)/g' \
- -e 's/@HTRDR_ARGS_CAMERA_PERSPECTIVE_FOV_EXCLUSIVE_MAX@/$(HTRDR_ARGS_CAMERA_PERSPECTIVE_FOV_EXCLUSIVE_MAX)/g' \
- -e 's/@HTRDR_ARGS_DEFAULT_CAMERA_POS@/$(HTRDR_ARGS_DEFAULT_CAMERA_POS)/g' \
- -e 's/@HTRDR_ARGS_DEFAULT_CAMERA_TGT@/$(HTRDR_ARGS_DEFAULT_CAMERA_TGT)/g' \
- -e 's/@HTRDR_ARGS_DEFAULT_CAMERA_UP@/$(HTRDR_ARGS_DEFAULT_CAMERA_UP)/g' \
- -e 's/@HTRDR_ARGS_DEFAULT_CAMERA_ORTHOGRAPHIC_HEIGHT@/$(HTRDR_ARGS_DEFAULT_CAMERA_ORTHOGRAPHIC_HEIGHT)/g' \
- -e 's/@HTRDR_ARGS_DEFAULT_CAMERA_PERSPECTIVE_FOV@/$(HTRDR_ARGS_DEFAULT_CAMERA_PERSPECTIVE_FOV)/g' \
- -e 's/@HTRDR_ARGS_DEFAULT_CAMERA_PERSPECTIVE_LENS_RADIUS@/$(HTRDR_ARGS_DEFAULT_CAMERA_PERSPECTIVE_LENS_RADIUS)/g' \
- -e 's/@HTRDR_ARGS_DEFAULT_CAMERA_PERSPECTIVE_FOCAL_DST@/$(HTRDR_ARGS_DEFAULT_CAMERA_PERSPECTIVE_FOCAL_DST)/g' \
- -e 's/@HTRDR_ARGS_DEFAULT_RECTANGLE_POS@/$(HTRDR_ARGS_DEFAULT_RECTANGLE_POS)/g' \
- -e 's/@HTRDR_ARGS_DEFAULT_RECTANGLE_TGT@/$(HTRDR_ARGS_DEFAULT_RECTANGLE_TGT)/g' \
- -e 's/@HTRDR_ARGS_DEFAULT_RECTANGLE_UP@/$(HTRDR_ARGS_DEFAULT_RECTANGLE_UP)/g' \
- -e 's/@HTRDR_ARGS_DEFAULT_RECTANGLE_SZ@/$(HTRDR_ARGS_DEFAULT_RECTANGLE_SZ)/g' \
- -e 's/@HTRDR_ARGS_DEFAULT_IMG_WIDTH@/$(HTRDR_ARGS_DEFAULT_IMG_WIDTH)/g' \
- -e 's/@HTRDR_ARGS_DEFAULT_IMG_HEIGHT@/$(HTRDR_ARGS_DEFAULT_IMG_HEIGHT)/g' \
- -e 's/@HTRDR_ARGS_DEFAULT_IMG_SPP@/$(HTRDR_ARGS_DEFAULT_IMG_SPP)/g' \
- $@.in > $@
-
-src/core/htrdr_version.h: config.mk src/core/htrdr_version.h.in
- sed -e 's/@VERSION_MAJOR@/$(VERSION_MAJOR)/g' \
- -e 's/@VERSION_MINOR@/$(VERSION_MINOR)/g' \
- -e 's/@VERSION_PATCH@/$(VERSION_PATCH)/g' \
- $@.in > $@
-
-$(CORE_DEP):
- @$(CC) $(CFLAGS_SO) $(CORE_DPDC_CFLAGS) -Isrc -MM -MT "$(@:.d=.o) $@" $(@:.d=.c) -MF $@
-
-$(CORE_OBJ):
- $(CC) $(CFLAGS_SO) $(CORE_DPDC_CFLAGS) -Isrc -DHTRDR_SHARED_BUILD -c $(@:.o=.c) -o $@
-
-htrdr-core.pc: config.mk htrdr-core.pc.in
- sed -e 's/@VERSION@/$(VERSION)/g' \
- -e 's/@AW_VERSION@/$(AW_VERSION)/g' \
- -e 's/@MPI_PC@/$(MPI_PC)/g' \
- -e 's/@MPI_VERSION@/$(MPI_VERSION)/g' \
- -e 's/@MRUMTL_VERSION@/$(MRUMTL_VERSION)/g' \
- -e 's/@RSYS_VERSION@/$(RSYS_VERSION)/g' \
- -e 's/@S3D_VERSION@/$(S3D_VERSION)/g' \
- -e 's/@SCAM_VERSION@/$(SCAM_VERSION)/g' \
- -e 's/@SSF_VERSION@/$(SSF_VERSION)/g' \
- -e 's/@SSP_VERSION@/$(SSP_VERSION)/g' \
- $@.in > $@
-
-clean_core:
- rm -f $(CORE_LIBNAME) $(CORE_OBJ) $(CORE_DEP)
- rm -f libhtrdr-core.o .config_core htrdr-core.pc
- rm -f src/core/htrdr_args.h src/core/htrdr_version.h
-
-################################################################################
-# Building the atmosphere library
-################################################################################
-ATMOSPHERE_SRC =\
- src/atmosphere/htrdr_atmosphere_args.c\
- src/atmosphere/htrdr_atmosphere.c\
- src/atmosphere/htrdr_atmosphere_compute_radiance_lw.c\
- src/atmosphere/htrdr_atmosphere_compute_radiance_sw.c\
- src/atmosphere/htrdr_atmosphere_draw_map.c\
- src/atmosphere/htrdr_atmosphere_ground.c\
- src/atmosphere/htrdr_atmosphere_main.c\
- src/atmosphere/htrdr_atmosphere_sun.c
-ATMOSPHERE_OBJ = $(ATMOSPHERE_SRC:.c=.o)
-ATMOSPHERE_DEP = $(ATMOSPHERE_SRC:.c=.d)
-
-build_atmosphere: build_core .config_atmosphere htrdr-atmosphere.pc $(ATMOSPHERE_DEP)
- @$(MAKE) -fMakefile $$(for i in $(ATMOSPHERE_DEP); do echo -f $${i}; done) \
- $(ATMOSPHERE_LIBNAME)
-
-$(ATMOSPHERE_DEP) $(ATMOSPHERE_OBJ): config.mk src/atmosphere/htrdr_atmosphere_args.h
-
-$(ATMOSPHERE_LIBNAME): libhtrdr-atmosphere.o
- $(AR) -rc $@ $?
- $(RANLIB) $@
-
-libhtrdr-atmosphere.o: $(ATMOSPHERE_OBJ)
- $(LD) -r $(ATMOSPHERE_OBJ) -o $@
- $(OBJCOPY) $(OCPFLAGS) $@
-
-.config_atmosphere: config.mk
- $(PKG_CONFIG) --atleast-version $(HTSKY_VERSION) htsky
- $(PKG_CONFIG) --atleast-version $(RSYS_VERSION) rsys
- $(PKG_CONFIG) --atleast-version $(S3D_VERSION) s3d
- $(PKG_CONFIG) --atleast-version $(SCAM_VERSION) scam
- $(PKG_CONFIG) --atleast-version $(SSF_VERSION) ssf
- $(PKG_CONFIG) --atleast-version $(SSP_VERSION) star-sp
- $(PKG_CONFIG) --atleast-version $(SVX_VERSION) svx
- echo 'config done' > $@
-
-src/atmosphere/htrdr_atmosphere_args.h: config.mk src/atmosphere/htrdr_atmosphere_args.h.in
- sed -e 's/@HTRDR_ATMOSPHERE_ARGS_DEFAULT_OPTICAL_THICKNESS_THRESHOLD@/$(HTRDR_ATMOSPHERE_ARGS_DEFAULT_OPTICAL_THICKNESS_THRESHOLD)/g' \
- -e 's/@HTRDR_ATMOSPHERE_ARGS_DEFAULT_SKY_MTL_NAME@/$(HTRDR_ATMOSPHERE_ARGS_DEFAULT_SKY_MTL_NAME)/g' \
- $@.in > $@
-
-$(ATMOSPHERE_DEP):
- @$(CC) $(CFLAGS_SO) $(ATMOSPHERE_DPDC_CFLAGS) -Isrc -MM -MT "$(@:.d=.o) $@" $(@:.d=.c) -MF $@
-
-$(ATMOSPHERE_OBJ):
- $(CC) $(CFLAGS_SO) $(ATMOSPHERE_DPDC_CFLAGS) -Isrc -DHTRDR_SHARED_BUILD -c $(@:.o=.c) -o $@
-
-htrdr-atmosphere.pc: config.mk htrdr-atmosphere.pc.in
- sed -e 's/@VERSION@/$(VERSION)/g' \
- -e 's/@HTSKY_VERSION@/$(HTSKY_VERSION)/g' \
- -e 's/@RSYS_VERSION@/$(RSYS_VERSION)/g' \
- -e 's/@S3D_VERSION@/$(S3D_VERSION)/g' \
- -e 's/@SCAM_VERSION@/$(SCAM_VERSION)/g' \
- -e 's/@SSF_VERSION@/$(SSF_VERSION)/g' \
- -e 's/@SSP_VERSION@/$(SSP_VERSION)/g' \
- -e 's/@SVX_VERSION@/$(SVX_VERSION)/g' \
- $@.in > $@
-
-clean_atmosphere:
- rm -f $(ATMOSPHERE_LIBNAME) $(ATMOSPHERE_OBJ) $(ATMOSPHERE_DEP)
- rm -f .config_atmosphere libhtrdr-atmosphere.o htrdr-atmosphere.pc
- rm -f src/atmosphere/htrdr_atmosphere_args.h
-
-################################################################################
-# Building the combustion library
-################################################################################
-COMBUSTION_SRC =\
- src/combustion/htrdr_combustion.c\
- src/combustion/htrdr_combustion_args.c\
- src/combustion/htrdr_combustion_draw_map.c\
- src/combustion/htrdr_combustion_compute_radiance_sw.c\
- src/combustion/htrdr_combustion_geometry_ray_filter.c\
- src/combustion/htrdr_combustion_laser.c\
- src/combustion/htrdr_combustion_main.c\
- src/combustion/htrdr_combustion_phase_func.c
-COMBUSTION_OBJ = $(COMBUSTION_SRC:.c=.o)
-COMBUSTION_DEP = $(COMBUSTION_SRC:.c=.d)
-
-build_combustion: build_core .config_combustion htrdr-combustion.pc $(COMBUSTION_DEP)
- @$(MAKE) -fMakefile $$(for i in $(COMBUSTION_DEP); do echo -f $${i}; done) \
- $(COMBUSTION_LIBNAME)
-
-$(COMBUSTION_DEP) $(COMBUSTION_OBJ): config.mk src/combustion/htrdr_combustion_args.h
-
-$(COMBUSTION_LIBNAME): libhtrdr-combustion.o
- $(AR) -rc $@ $?
- $(RANLIB) $@
-
-libhtrdr-combustion.o: $(COMBUSTION_OBJ)
- $(LD) -r $(COMBUSTION_OBJ) -o $@
- $(OBJCOPY) $(OCPFLAGS) $@
-
-.config_combustion: config.mk
- $(PKG_CONFIG) --atleast-version $(ATRSTM_VERSION) atrstm
- $(PKG_CONFIG) --atleast-version $(RSYS_VERSION) rsys
- $(PKG_CONFIG) --atleast-version $(S3D_VERSION) s3d
- $(PKG_CONFIG) --atleast-version $(SCAM_VERSION) scam
- $(PKG_CONFIG) --atleast-version $(SSF_VERSION) ssf
- $(PKG_CONFIG) --atleast-version $(SSP_VERSION) star-sp
- $(PKG_CONFIG) --atleast-version $(SVX_VERSION) svx
- echo 'config done' > $@
-
-src/combustion/htrdr_combustion_args.h: config.mk src/combustion/htrdr_combustion_args.h.in
- sed -e 's/@HTRDR_COMBUSTION_ARGS_DEFAULT_LASER_FLUX_DENSITY@/$(HTRDR_COMBUSTION_ARGS_DEFAULT_LASER_FLUX_DENSITY)/g' \
- -e 's/@HTRDR_COMBUSTION_ARGS_DEFAULT_FRACTAL_DIMENSION@/$(HTRDR_COMBUSTION_ARGS_DEFAULT_FRACTAL_DIMENSION)/g' \
- -e 's/@HTRDR_COMBUSTION_ARGS_DEFAULT_FRACTAL_PREFACTOR@/$(HTRDR_COMBUSTION_ARGS_DEFAULT_FRACTAL_PREFACTOR)/g' \
- -e 's/@HTRDR_COMBUSTION_ARGS_DEFAULT_OPTICAL_THICKNESS_THRESHOLD@/$(HTRDR_COMBUSTION_ARGS_DEFAULT_OPTICAL_THICKNESS_THRESHOLD)/g' \
- -e 's/@HTRDR_COMBUSTION_ARGS_DEFAULT_GRID_DEFINITION_HINT@/$(HTRDR_COMBUSTION_ARGS_DEFAULT_GRID_DEFINITION_HINT)/g' \
- -e 's/@HTRDR_COMBUSTION_ARGS_DEFAULT_WAVELENGTH@/$(HTRDR_COMBUSTION_ARGS_DEFAULT_WAVELENGTH)/g' \
- $@.in > $@
-
-$(COMBUSTION_DEP):
- @$(CC) $(CFLAGS_SO) $(COMBUSTION_DPDC_CFLAGS) -Isrc -MM -MT "$(@:.d=.o) $@" $(@:.d=.c) -MF $@
-
-$(COMBUSTION_OBJ):
- $(CC) $(CFLAGS_SO) $(COMBUSTION_DPDC_CFLAGS) -Isrc -DHTRDR_SHARED_BUILD -c $(@:.o=.c) -o $@
-
-htrdr-combustion.pc: config.mk htrdr-combustion.pc.in
- sed -e 's/@VERSION@/$(VERSION)/g' \
- -e 's/@ATRSTM_VERSION@/$(ATRSTM_VERSION)/g' \
- -e 's/@RSYS_VERSION@/$(RSYS_VERSION)/g' \
- -e 's/@S3D_VERSION@/$(S3D_VERSION)/g' \
- -e 's/@SCAM_VERSION@/$(SCAM_VERSION)/g' \
- -e 's/@SSF_VERSION@/$(SSF_VERSION)/g' \
- -e 's/@SSP_VERSION@/$(SSP_VERSION)/g' \
- -e 's/@SVX_VERSION@/$(SVX_VERSION)/g' \
- $@.in > $@
-
-clean_combustion:
- rm -f $(COMBUSTION_LIBNAME) $(COMBUSTION_OBJ) $(COMBUSTION_DEP)
- rm -f .config_combustion libhtrdr-combustion.o htrdr-combustion.pc
- rm -f src/combustion/htrdr_combustion_args.h
-
-################################################################################
-# Building the planets library
-################################################################################
-PLANETS_LIBNAME = libhtrdr-planets.a
-
-PLANETS_SRC =\
- src/planets/htrdr_planets.c\
- src/planets/htrdr_planets_args.c\
- src/planets/htrdr_planets_compute_radiance.c\
- src/planets/htrdr_planets_draw_map.c\
- src/planets/htrdr_planets_main.c\
- src/planets/htrdr_planets_solve_volrad_budget.c\
- src/planets/htrdr_planets_source.c
-PLANETS_OBJ = $(PLANETS_SRC:.c=.o)
-PLANETS_DEP = $(PLANETS_SRC:.c=.d)
-
-build_planets: build_core .config_planets htrdr-planets.pc $(PLANETS_DEP)
- @$(MAKE) -fMakefile $$(for i in $(PLANETS_DEP); do echo -f $${i}; done) \
- $(PLANETS_LIBNAME)
-
-$(PLANETS_DEP) $(PLANETS_OBJ): config.mk src/planets/htrdr_planets_args.h
-
-$(PLANETS_LIBNAME): libhtrdr-planets.o
- $(AR) -rc $@ $?
- $(RANLIB) $@
-
-libhtrdr-planets.o: $(PLANETS_OBJ)
- $(LD) -r $(PLANETS_OBJ) -o $@
- $(OBJCOPY) $(OCPFLAGS) $@
-
-.config_planets: config.mk
- $(PKG_CONFIG) --atleast-version $(RNATM_VERSION) rnatm
- $(PKG_CONFIG) --atleast-version $(RNGRD_VERSION) rngrd
- $(PKG_CONFIG) --atleast-version $(RSYS_VERSION) rsys
- $(PKG_CONFIG) --atleast-version $(S3D_VERSION) s3d
- $(PKG_CONFIG) --atleast-version $(SBUF_VERSION) sbuf
- $(PKG_CONFIG) --atleast-version $(SCAM_VERSION) scam
- $(PKG_CONFIG) --atleast-version $(SSF_VERSION) ssf
- $(PKG_CONFIG) --atleast-version $(SSP_VERSION) star-sp
- $(PKG_CONFIG) --atleast-version $(SVX_VERSION) svx
- echo 'config done' > $@
-
-src/planets/htrdr_planets_args.h: config.mk src/planets/htrdr_planets_args.h.in
- sed -e 's/@HTRDR_PLANETS_ARGS_DEFAULT_OPTICAL_THICKNESS_THRESHOLD@/$(HTRDR_PLANETS_ARGS_DEFAULT_OPTICAL_THICKNESS_THRESHOLD)/g' \
- -e 's/@HTRDR_PLANETS_ARGS_DEFAULT_GRID_DEFINITION_HINT@/$(HTRDR_PLANETS_ARGS_DEFAULT_GRID_DEFINITION_HINT)/g' \
- -e 's/@HTRDR_PLANETS_ARGS_DEFAULT_VOLRAD_BUDGET_SPT@/$(HTRDR_PLANETS_ARGS_DEFAULT_VOLRAD_BUDGET_SPT)/g' \
- $@.in > $@
-
-$(PLANETS_DEP):
- @$(CC) $(CFLAGS_SO) $(PLANETS_DPDC_CFLAGS) -Isrc -MM -MT "$(@:.d=.o) $@" $(@:.d=.c) -MF $@
-
-$(PLANETS_OBJ):
- $(CC) $(CFLAGS_SO) $(PLANETS_DPDC_CFLAGS) -Isrc -DHTRDR_SHARED_BUILD -c $(@:.o=.c) -o $@
-
-htrdr-planets.pc: config.mk htrdr-planets.pc.in
- sed -e 's/@VERSION@/$(VERSION)/g' \
- -e 's/@RNATM_VERSION@/$(RNATM_VERSION)/g' \
- -e 's/@RNGRD_VERSION@/$(RNGRD_VERSION)/g' \
- -e 's/@RSYS_VERSION@/$(RSYS_VERSION)/g' \
- -e 's/@S3D_VERSION@/$(S3D_VERSION)/g' \
- -e 's/@SBUF_VERSION@/$(SBUF_VERSION)/g' \
- -e 's/@SCAM_VERSION@/$(SCAM_VERSION)/g' \
- -e 's/@SSF_VERSION@/$(SSF_VERSION)/g' \
- -e 's/@SSP_VERSION@/$(SSP_VERSION)/g' \
- -e 's/@SVX_VERSION@/$(SVX_VERSION)/g' \
- $@.in > $@
-
-clean_planets:
- rm -f $(PLANETS_LIBNAME) $(PLANETS_OBJ) $(PLANETS_DEP)
- rm -f .config_planets libhtrdr-planets.o htrdr-planets.pc
- rm -f src/planets/htrdr_planets_args.h
-
-################################################################################
-# Man pages
-################################################################################
-man: doc/htrdr-atmosphere.1 doc/htrdr-combustion.1 doc/htrdr-planets.1
-
-doc/htrdr-atmosphere.1: doc/htrdr-atmosphere.1.in
- sed -e 's/@HTRDR_ATMOSPHERE_ARGS_DEFAULT_OPTICAL_THICKNESS_THRESHOLD@/$(HTRDR_ATMOSPHERE_ARGS_DEFAULT_OPTICAL_THICKNESS_THRESHOLD)/g' \
- -e 's/@HTRDR_ATMOSPHERE_ARGS_DEFAULT_SKY_MTL_NAME@/$(HTRDR_ATMOSPHERE_ARGS_DEFAULT_SKY_MTL_NAME)/g' \
- -e 's/@HTRDR_ARGS_CAMERA_PERSPECTIVE_FOV_EXCLUSIVE_MIN@/$(HTRDR_ARGS_CAMERA_PERSPECTIVE_FOV_EXCLUSIVE_MIN)/g' \
- -e 's/@HTRDR_ARGS_CAMERA_PERSPECTIVE_FOV_EXCLUSIVE_MAX@/$(HTRDR_ARGS_CAMERA_PERSPECTIVE_FOV_EXCLUSIVE_MAX)/g' \
- -e 's/@HTRDR_ARGS_DEFAULT_CAMERA_PERSPECTIVE_FOCAL_DST@/$(HTRDR_ARGS_DEFAULT_CAMERA_PERSPECTIVE_FOCAL_DST)/g' \
- -e 's/@HTRDR_ARGS_DEFAULT_CAMERA_PERSPECTIVE_FOV@/$(HTRDR_ARGS_DEFAULT_CAMERA_PERSPECTIVE_FOV)/g' \
- -e 's/@HTRDR_ARGS_DEFAULT_CAMERA_PERSPECTIVE_LENS_RADIUS@/$(HTRDR_ARGS_DEFAULT_CAMERA_PERSPECTIVE_LENS_RADIUS)/g' \
- -e 's/@HTRDR_ARGS_DEFAULT_CAMERA_POS@/$(HTRDR_ARGS_DEFAULT_CAMERA_POS)/g' \
- -e 's/@HTRDR_ARGS_DEFAULT_CAMERA_TGT@/$(HTRDR_ARGS_DEFAULT_CAMERA_TGT)/g' \
- -e 's/@HTRDR_ARGS_DEFAULT_CAMERA_UP@/$(HTRDR_ARGS_DEFAULT_CAMERA_UP)/g' \
- -e 's/@HTRDR_ARGS_DEFAULT_IMG_WIDTH@/$(HTRDR_ARGS_DEFAULT_IMG_WIDTH)/g' \
- -e 's/@HTRDR_ARGS_DEFAULT_IMG_HEIGHT@/$(HTRDR_ARGS_DEFAULT_IMG_HEIGHT)/g' \
- -e 's/@HTRDR_ARGS_DEFAULT_IMG_SPP@/$(HTRDR_ARGS_DEFAULT_IMG_SPP)/g' \
- -e 's/@HTRDR_ARGS_DEFAULT_RECTANGLE_POS@/$(HTRDR_ARGS_DEFAULT_RECTANGLE_POS)/g' \
- -e 's/@HTRDR_ARGS_DEFAULT_RECTANGLE_TGT@/$(HTRDR_ARGS_DEFAULT_RECTANGLE_TGT)/g' \
- -e 's/@HTRDR_ARGS_DEFAULT_RECTANGLE_UP@/$(HTRDR_ARGS_DEFAULT_RECTANGLE_UP)/g' \
- -e 's/@HTRDR_ARGS_DEFAULT_RECTANGLE_SZ@/$(HTRDR_ARGS_DEFAULT_RECTANGLE_SZ)/g'\
- $@.in > $@
-
-doc/htrdr-combustion.1: doc/htrdr-combustion.1.in
- sed -e 's/@HTRDR_COMBUSTION_ARGS_DEFAULT_LASER_FLUX_DENSITY@/$(HTRDR_COMBUSTION_ARGS_DEFAULT_LASER_FLUX_DENSITY)/g' \
- -e 's/@HTRDR_COMBUSTION_ARGS_DEFAULT_FRACTAL_DIMENSION@/$(HTRDR_COMBUSTION_ARGS_DEFAULT_FRACTAL_DIMENSION)/g' \
- -e 's/@HTRDR_COMBUSTION_ARGS_DEFAULT_FRACTAL_PREFACTOR@/$(HTRDR_COMBUSTION_ARGS_DEFAULT_FRACTAL_PREFACTOR)/g' \
- -e 's/@HTRDR_COMBUSTION_ARGS_DEFAULT_OPTICAL_THICKNESS_THRESHOLD@/$(HTRDR_COMBUSTION_ARGS_DEFAULT_OPTICAL_THICKNESS_THRESHOLD)/g' \
- -e 's/@HTRDR_COMBUSTION_ARGS_DEFAULT_GRID_DEFINITION_HINT@/$(HTRDR_COMBUSTION_ARGS_DEFAULT_GRID_DEFINITION_HINT)/g' \
- -e 's/@HTRDR_COMBUSTION_ARGS_DEFAULT_WAVELENGTH@/$(HTRDR_COMBUSTION_ARGS_DEFAULT_WAVELENGTH)/g' \
- -e 's/@HTRDR_ARGS_CAMERA_PERSPECTIVE_FOV_EXCLUSIVE_MIN@/$(HTRDR_ARGS_CAMERA_PERSPECTIVE_FOV_EXCLUSIVE_MIN)/g' \
- -e 's/@HTRDR_ARGS_CAMERA_PERSPECTIVE_FOV_EXCLUSIVE_MAX@/$(HTRDR_ARGS_CAMERA_PERSPECTIVE_FOV_EXCLUSIVE_MAX)/g' \
- -e 's/@HTRDR_ARGS_DEFAULT_CAMERA_PERSPECTIVE_FOCAL_DST@/$(HTRDR_ARGS_DEFAULT_CAMERA_PERSPECTIVE_FOCAL_DST)/g' \
- -e 's/@HTRDR_ARGS_DEFAULT_CAMERA_PERSPECTIVE_FOV@/$(HTRDR_ARGS_DEFAULT_CAMERA_PERSPECTIVE_FOV)/g' \
- -e 's/@HTRDR_ARGS_DEFAULT_CAMERA_PERSPECTIVE_LENS_RADIUS@/$(HTRDR_ARGS_DEFAULT_CAMERA_PERSPECTIVE_LENS_RADIUS)/g' \
- -e 's/@HTRDR_ARGS_DEFAULT_CAMERA_POS@/$(HTRDR_ARGS_DEFAULT_CAMERA_POS)/g' \
- -e 's/@HTRDR_ARGS_DEFAULT_CAMERA_TGT@/$(HTRDR_ARGS_DEFAULT_CAMERA_TGT)/g' \
- -e 's/@HTRDR_ARGS_DEFAULT_CAMERA_UP@/$(HTRDR_ARGS_DEFAULT_CAMERA_UP)/g' \
- -e 's/@HTRDR_ARGS_DEFAULT_IMG_WIDTH@/$(HTRDR_ARGS_DEFAULT_IMG_WIDTH)/g' \
- -e 's/@HTRDR_ARGS_DEFAULT_IMG_HEIGHT@/$(HTRDR_ARGS_DEFAULT_IMG_HEIGHT)/g' \
- -e 's/@HTRDR_ARGS_DEFAULT_IMG_SPP@/$(HTRDR_ARGS_DEFAULT_IMG_SPP)/g' \
- -e 's/@HTRDR_ARGS_DEFAULT_RECTANGLE_POS@/$(HTRDR_ARGS_DEFAULT_RECTANGLE_POS)/g' \
- -e 's/@HTRDR_ARGS_DEFAULT_RECTANGLE_TGT@/$(HTRDR_ARGS_DEFAULT_RECTANGLE_TGT)/g' \
- -e 's/@HTRDR_ARGS_DEFAULT_RECTANGLE_UP@/$(HTRDR_ARGS_DEFAULT_RECTANGLE_UP)/g' \
- -e 's/@HTRDR_ARGS_DEFAULT_RECTANGLE_SZ@/$(HTRDR_ARGS_DEFAULT_RECTANGLE_SZ)/g'\
- $@.in > $@
-
-doc/htrdr-planets.1: doc/htrdr-planets.1.in
- sed -e 's/@HTRDR_ARGS_CAMERA_PERSPECTIVE_FOV_EXCLUSIVE_MIN@/$(HTRDR_ARGS_CAMERA_PERSPECTIVE_FOV_EXCLUSIVE_MIN)/g' \
- -e 's/@HTRDR_ARGS_CAMERA_PERSPECTIVE_FOV_EXCLUSIVE_MAX@/$(HTRDR_ARGS_CAMERA_PERSPECTIVE_FOV_EXCLUSIVE_MAX)/g' \
- -e 's/@HTRDR_ARGS_DEFAULT_CAMERA_PERSPECTIVE_FOCAL_DST@/$(HTRDR_ARGS_DEFAULT_CAMERA_PERSPECTIVE_FOCAL_DST)/g' \
- -e 's/@HTRDR_ARGS_DEFAULT_CAMERA_PERSPECTIVE_FOV@/$(HTRDR_ARGS_DEFAULT_CAMERA_PERSPECTIVE_FOV)/g' \
- -e 's/@HTRDR_ARGS_DEFAULT_CAMERA_PERSPECTIVE_LENS_RADIUS@/$(HTRDR_ARGS_DEFAULT_CAMERA_PERSPECTIVE_LENS_RADIUS)/g' \
- -e 's/@HTRDR_ARGS_DEFAULT_CAMERA_POS@/$(HTRDR_ARGS_DEFAULT_CAMERA_POS)/g' \
- -e 's/@HTRDR_ARGS_DEFAULT_CAMERA_TGT@/$(HTRDR_ARGS_DEFAULT_CAMERA_TGT)/g' \
- -e 's/@HTRDR_ARGS_DEFAULT_CAMERA_UP@/$(HTRDR_ARGS_DEFAULT_CAMERA_UP)/g' \
- -e 's/@HTRDR_ARGS_DEFAULT_IMG_WIDTH@/$(HTRDR_ARGS_DEFAULT_IMG_WIDTH)/g' \
- -e 's/@HTRDR_ARGS_DEFAULT_IMG_HEIGHT@/$(HTRDR_ARGS_DEFAULT_IMG_HEIGHT)/g' \
- -e 's/@HTRDR_ARGS_DEFAULT_IMG_SPP@/$(HTRDR_ARGS_DEFAULT_IMG_SPP)/g' \
- -e 's/@HTRDR_PLANETS_ARGS_DEFAULT_OPTICAL_THICKNESS_THRESHOLD@/$(HTRDR_PLANETS_ARGS_DEFAULT_OPTICAL_THICKNESS_THRESHOLD)/g' \
- -e 's/@HTRDR_PLANETS_ARGS_DEFAULT_GRID_DEFINITION_HINT@/$(HTRDR_PLANETS_ARGS_DEFAULT_GRID_DEFINITION_HINT)/g' \
- -e 's/@HTRDR_PLANETS_ARGS_DEFAULT_VOLRAD_BUDGET_SPT@/$(HTRDR_PLANETS_ARGS_DEFAULT_VOLRAD_BUDGET_SPT)/g' \
- $@.in > $@
-
-clean_man:
- rm -f doc/htrdr-atmosphere.1 doc/htrdr-combustion.1 doc/htrdr-planets.1
-
-################################################################################
-# Installation
-################################################################################
-install: all
+default install uninstall lint clean:
+ @if [ "$(ATMOSPHERE)" == "ENABLE" ]; then $(MAKE) -fMakefile.atmosphere $@; fi
+ @if [ "$(COMBUSTION)" == "ENABLE" ]; then $(MAKE) -fMakefile.combustion $@; fi
+ @if [ "$(PLANETS)" == ENABLE ]; then $(MAKE) -fMakefile.planets $@; fi
+
+default: htrdr
+install: install_common
+uninstall: uninstall_common
+lint: lint_common
+clean: clean_common
+
+htrdr: src/htrdr.in
+ sed -e "s/@MAJOR@/$(VERSION_MAJOR)/" \
+ -e "s/@MINOR@/$(VERSION_MINOR)/" \
+ -e "s/@PATCH@/$(VERSION_PATCH)/" \
+ src/htrdr.in > $@
+
+install_common: htrdr
@$(SHELL) install.sh 755 "$(DESTDIR)$(BINPREFIX)" htrdr
- @$(SHELL) install.sh 755 "$(DESTDIR)$(BINPREFIX)" htrdr-atmosphere
- @$(SHELL) install.sh 755 "$(DESTDIR)$(BINPREFIX)" htrdr-combustion
- @$(SHELL) install.sh 755 "$(DESTDIR)$(BINPREFIX)" htrdr-planets
- @if [ "$(LIB_TYPE)" = "SHARED" ]; then \
- $(SHELL) install.sh 755 "$(DESTDIR)$(LIBPREFIX)" $(CORE_LIBNAME_SHARED); fi
@$(SHELL) install.sh 644 "$(DESTDIR)$(DOCPREFIX)/htrdr" COPYING README.md
@$(SHELL) install.sh 644 "$(DESTDIR)$(MANPREFIX)/man1" doc/htrdr.1
- @if [ "$(ATMOSPHERE)" = "ENABLE" ]; then \
- $(SHELL) install.sh 644 "$(DESTDIR)$(MANPREFIX)/man1" doc/htrdr-atmosphere.1; fi
- @if [ "$(COMBUSTION)" = "ENABLE" ]; then \
- $(SHELL) install.sh 644 "$(DESTDIR)$(MANPREFIX)/man1" doc/htrdr-combustion.1; fi
- @if [ "$(PLANETS)" = "ENABLE" ]; then \
- $(SHELL) install.sh 644 "$(DESTDIR)$(MANPREFIX)/man1" doc/htrdr-planets.1; fi
@$(SHELL) install.sh 644 "$(DESTDIR)$(MANPREFIX)/man5" doc/htrdr-image.5
@$(SHELL) install.sh 644 "$(DESTDIR)$(MANPREFIX)/man5" doc/htrdr-materials.5
@$(SHELL) install.sh 644 "$(DESTDIR)$(MANPREFIX)/man5" doc/htrdr-obj.5
@$(SHELL) install.sh 644 "$(DESTDIR)$(MANPREFIX)/man5" doc/rnrl.5
+ @$(MAKE) -fMakefile.core install
-uninstall:
+uninstall_common:
rm -f "$(DESTDIR)$(BINPREFIX)/htrdr"
- rm -f "$(DESTDIR)$(BINPREFIX)/htrdr-atmosphere"
- rm -f "$(DESTDIR)$(BINPREFIX)/htrdr-combustion"
- rm -f "$(DESTDIR)$(BINPREFIX)/htrdr-planets"
- rm -f "$(DESTDIR)$(LIBPREFIX)/$(CORE_LIBNAME_SHARED)"
rm -f "$(DESTDIR)$(DOCPREFIX)/htrdr/COPYING"
rm -f "$(DESTDIR)$(DOCPREFIX)/htrdr/README.md"
rm -f "$(DESTDIR)$(MANPREFIX)/man1/htrdr.1"
- rm -f "$(DESTDIR)$(MANPREFIX)/man1/htrdr-atmosphere.1"
- rm -f "$(DESTDIR)$(MANPREFIX)/man1/htrdr-combustion.1"
- rm -f "$(DESTDIR)$(MANPREFIX)/man1/htrdr-planets.1"
rm -f "$(DESTDIR)$(MANPREFIX)/man5/htrdr-image.5"
rm -f "$(DESTDIR)$(MANPREFIX)/man5/htrdr-materials.5"
rm -f "$(DESTDIR)$(MANPREFIX)/man5/htrdr-obj.5"
rm -f "$(DESTDIR)$(MANPREFIX)/man5/rnrl.5"
-################################################################################
-# Miscellaneous targets
-################################################################################
-clean:\
- clean_htrdr\
- clean_htrdr-atmosphere\
- clean_htrdr-combustion\
- clean_htrdr-planets\
- clean_atmosphere\
- clean_combustion\
- clean_planets\
- clean_core\
- clean_man
+clean_common:
+ rm -f htrdr
-lint: doc/htrdr-atmosphere.1 doc/htrdr-combustion.1 doc/htrdr-planets.1
+lint_common: htrdr
shellcheck -o all install.sh
+ shellcheck -o all htrdr
mandoc -Tlint -Wall doc/htrdr.1 || [ $$? -le 1 ]
- mandoc -Tlint -Wall doc/htrdr-atmosphere.1 || [ $$? -le 1 ]
- mandoc -Tlint -Wall doc/htrdr-combustion.1 || [ $$? -le 1 ]
- mandoc -Tlint -Wall doc/htrdr-planets.1 || [ $$? -le 1 ]
mandoc -Tlint -Wall doc/htrdr-image.5 || [ $$? -le 1 ]
mandoc -Tlint -Wall doc/htrdr-materials.5 || [ $$? -le 1 ]
mandoc -Tlint -Wall doc/htrdr-obj.5 || [ $$? -le 1 ]
diff --git a/Makefile.atmosphere b/Makefile.atmosphere
@@ -0,0 +1,166 @@
+# Copyright (C) 2018-2019, 2022-2025 Centre National de la Recherche Scientifique
+# Copyright (C) 2020-2022 Institut Mines Télécom Albi-Carmaux
+# Copyright (C) 2022-2025 Institut Pierre-Simon Laplace
+# Copyright (C) 2022-2025 Institut de Physique du Globe de Paris
+# Copyright (C) 2018-2025 |Méso|Star> (contact@meso-star.com)
+# Copyright (C) 2022-2025 Observatoire de Paris
+# Copyright (C) 2022-2025 Université de Reims Champagne-Ardenne
+# Copyright (C) 2022-2025 Université de Versaille Saint-Quentin
+# Copyright (C) 2018-2019, 2022-2025 Université Paul Sabatier
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+.POSIX:
+.SUFFIXES: # Clean up default inference rules
+
+include config.mk
+
+LIBNAME = libhtrdr-atmosphere.a
+
+default: command
+
+################################################################################
+# Build the library
+################################################################################
+SRC =\
+ src/atmosphere/htrdr_atmosphere_args.c\
+ src/atmosphere/htrdr_atmosphere.c\
+ src/atmosphere/htrdr_atmosphere_compute_radiance_lw.c\
+ src/atmosphere/htrdr_atmosphere_compute_radiance_sw.c\
+ src/atmosphere/htrdr_atmosphere_draw_map.c\
+ src/atmosphere/htrdr_atmosphere_ground.c\
+ src/atmosphere/htrdr_atmosphere_main.c\
+ src/atmosphere/htrdr_atmosphere_sun.c
+OBJ = $(SRC:.c=.o)
+DEP = $(SRC:.c=.d)
+
+CFLAGS_LIB = $(CFLAGS_SO) $(ATMOSPHERE_INCS) -Isrc -DHTRDR_SHARED_BUILD
+
+library: core .config_atmosphere htrdr-atmosphere.pc $(DEP)
+ @$(MAKE) -fMakefile.atmosphere \
+ $$(for i in $(DEP); do echo -f $${i}; done) $(LIBNAME)
+
+core:
+ @$(MAKE) -fMakefile.core
+
+.config_atmosphere: config.mk
+ $(PKG_CONFIG) --atleast-version $(HTSKY_VERSION) htsky
+ $(PKG_CONFIG) --atleast-version $(RSYS_VERSION) rsys
+ $(PKG_CONFIG) --atleast-version $(S3D_VERSION) s3d
+ $(PKG_CONFIG) --atleast-version $(SCAM_VERSION) scam
+ $(PKG_CONFIG) --atleast-version $(SSF_VERSION) ssf
+ $(PKG_CONFIG) --atleast-version $(SSP_VERSION) star-sp
+ $(PKG_CONFIG) --atleast-version $(SVX_VERSION) svx
+ echo 'config done' > $@
+
+$(LIBNAME): libhtrdr-atmosphere.o
+ $(AR) -rc $@ $?
+ $(RANLIB) $@
+
+libhtrdr-atmosphere.o: $(OBJ)
+ $(LD) -r $(OBJ) -o $@
+ $(OBJCOPY) $(OCPFLAGS) $@
+
+$(DEP) $(OBJ): config.mk src/atmosphere/htrdr_atmosphere_args.h
+
+# Inference rules
+.SUFFIXES: .c .d .o
+.c.d:
+ @$(CC) $(CFLAGS_LIB) -MM -MT "$(@:.d=.o) $@" $< -MF $@
+
+.c.o:
+ $(CC) $(CFLAGS_LIB) -c $< -o $@
+
+################################################################################
+# Build the command
+################################################################################
+CMD_SRC = src/commands/htrdr_atmosphere_cmd.c
+CMD_OBJ = $(CMD_SRC:.c=.o)
+CMD_DEP = $(CMD_SRC:.c=.d)
+
+CFLAGS_CMD = $(CFLAGS_EXE) $$($(PKG_CONFIG_LOCAL) --static --cflags htrdr-core htrdr-atmosphere rsys)
+LDFLAGS_CMD = $(LDFLAGS_EXE) $$($(PKG_CONFIG_LOCAL) --static --libs htrdr-core htrdr-atmosphere rsys)
+
+command: library $(CMD_DEP)
+ @$(MAKE) -fMakefile.atmosphere -f$(CMD_DEP) htrdr-atmosphere
+
+htrdr-atmosphere: $(CMD_OBJ) $(LIBNAME)
+ $(CC) $(CFLAGS_CMD) -o $@ $(CMD_OBJ) $(LDFLAGS_CMD)
+
+$(CMD_DEP) $(CMD_OBJ): config.mk htrdr-atmosphere.pc
+
+$(CMD_DEP):
+ @$(CC) $(CFLAGS_CMD) -MM -MT "$(@:.d=.o) $@" $(@:.d=.c) -MF $@
+
+$(CMD_OBJ):
+ $(CC) $(CFLAGS_CMD) -c $(@:.o=.c) -o $@
+
+################################################################################
+# Generate files from template
+################################################################################
+src/atmosphere/htrdr_atmosphere_args.h: config.mk src/atmosphere/htrdr_atmosphere_args.h.in
+ sed -e 's/@HTRDR_ATMOSPHERE_ARGS_DEFAULT_OPTICAL_THICKNESS_THRESHOLD@/$(HTRDR_ATMOSPHERE_ARGS_DEFAULT_OPTICAL_THICKNESS_THRESHOLD)/g' \
+ -e 's/@HTRDR_ATMOSPHERE_ARGS_DEFAULT_SKY_MTL_NAME@/$(HTRDR_ATMOSPHERE_ARGS_DEFAULT_SKY_MTL_NAME)/g' \
+ $@.in > $@
+
+htrdr-atmosphere.pc: config.mk htrdr-atmosphere.pc.in
+ sed -e 's/@VERSION@/$(VERSION)/g' \
+ -e 's/@HTSKY_VERSION@/$(HTSKY_VERSION)/g' \
+ -e 's/@RSYS_VERSION@/$(RSYS_VERSION)/g' \
+ -e 's/@S3D_VERSION@/$(S3D_VERSION)/g' \
+ -e 's/@SCAM_VERSION@/$(SCAM_VERSION)/g' \
+ -e 's/@SSF_VERSION@/$(SSF_VERSION)/g' \
+ -e 's/@SSP_VERSION@/$(SSP_VERSION)/g' \
+ -e 's/@SVX_VERSION@/$(SVX_VERSION)/g' \
+ $@.in > $@
+
+doc/htrdr-atmosphere.1: doc/htrdr-atmosphere.1.in
+ sed -e 's/@HTRDR_ATMOSPHERE_ARGS_DEFAULT_OPTICAL_THICKNESS_THRESHOLD@/$(HTRDR_ATMOSPHERE_ARGS_DEFAULT_OPTICAL_THICKNESS_THRESHOLD)/g' \
+ -e 's/@HTRDR_ATMOSPHERE_ARGS_DEFAULT_SKY_MTL_NAME@/$(HTRDR_ATMOSPHERE_ARGS_DEFAULT_SKY_MTL_NAME)/g' \
+ -e 's/@HTRDR_ARGS_CAMERA_PERSPECTIVE_FOV_EXCLUSIVE_MIN@/$(HTRDR_ARGS_CAMERA_PERSPECTIVE_FOV_EXCLUSIVE_MIN)/g' \
+ -e 's/@HTRDR_ARGS_CAMERA_PERSPECTIVE_FOV_EXCLUSIVE_MAX@/$(HTRDR_ARGS_CAMERA_PERSPECTIVE_FOV_EXCLUSIVE_MAX)/g' \
+ -e 's/@HTRDR_ARGS_DEFAULT_CAMERA_PERSPECTIVE_FOCAL_DST@/$(HTRDR_ARGS_DEFAULT_CAMERA_PERSPECTIVE_FOCAL_DST)/g' \
+ -e 's/@HTRDR_ARGS_DEFAULT_CAMERA_PERSPECTIVE_FOV@/$(HTRDR_ARGS_DEFAULT_CAMERA_PERSPECTIVE_FOV)/g' \
+ -e 's/@HTRDR_ARGS_DEFAULT_CAMERA_PERSPECTIVE_LENS_RADIUS@/$(HTRDR_ARGS_DEFAULT_CAMERA_PERSPECTIVE_LENS_RADIUS)/g' \
+ -e 's/@HTRDR_ARGS_DEFAULT_CAMERA_POS@/$(HTRDR_ARGS_DEFAULT_CAMERA_POS)/g' \
+ -e 's/@HTRDR_ARGS_DEFAULT_CAMERA_TGT@/$(HTRDR_ARGS_DEFAULT_CAMERA_TGT)/g' \
+ -e 's/@HTRDR_ARGS_DEFAULT_CAMERA_UP@/$(HTRDR_ARGS_DEFAULT_CAMERA_UP)/g' \
+ -e 's/@HTRDR_ARGS_DEFAULT_IMG_WIDTH@/$(HTRDR_ARGS_DEFAULT_IMG_WIDTH)/g' \
+ -e 's/@HTRDR_ARGS_DEFAULT_IMG_HEIGHT@/$(HTRDR_ARGS_DEFAULT_IMG_HEIGHT)/g' \
+ -e 's/@HTRDR_ARGS_DEFAULT_IMG_SPP@/$(HTRDR_ARGS_DEFAULT_IMG_SPP)/g' \
+ -e 's/@HTRDR_ARGS_DEFAULT_RECTANGLE_POS@/$(HTRDR_ARGS_DEFAULT_RECTANGLE_POS)/g' \
+ -e 's/@HTRDR_ARGS_DEFAULT_RECTANGLE_TGT@/$(HTRDR_ARGS_DEFAULT_RECTANGLE_TGT)/g' \
+ -e 's/@HTRDR_ARGS_DEFAULT_RECTANGLE_UP@/$(HTRDR_ARGS_DEFAULT_RECTANGLE_UP)/g' \
+ -e 's/@HTRDR_ARGS_DEFAULT_RECTANGLE_SZ@/$(HTRDR_ARGS_DEFAULT_RECTANGLE_SZ)/g'\
+ $@.in > $@
+
+################################################################################
+# Miscellaneous
+################################################################################
+install: command doc/htrdr-atmosphere.1
+ @$(SHELL) install.sh 755 "$(DESTDIR)$(BINPREFIX)" htrdr-atmosphere
+ @$(SHELL) install.sh 644 "$(DESTDIR)$(MANPREFIX)/man1" doc/htrdr-atmosphere.1
+
+uninstall:
+ rm -f "$(DESTDIR)$(BINPREFIX)/htrdr-atmosphere"
+ rm -f "$(DESTDIR)$(MANPREFIX)/man1/htrdr-atmosphere.1"
+
+clean:
+ rm -f $(OBJ) $(DEP) $(LIBNAME)
+ rm -f $(CMD_OBJ) $(CMD_DEP) htrdr-atmosphere
+ rm -f .config_atmosphere libhtrdr-atmosphere.o htrdr-atmosphere.pc
+ rm -f doc/htrdr-atmosphere.1 src/atmosphere/htrdr_atmosphere_args.h
+
+lint: doc/htrdr-atmosphere.1
+ mandoc -Tlint -Wall doc/htrdr-atmosphere.1 || [ $$? -le 1 ]
diff --git a/Makefile.combustion b/Makefile.combustion
@@ -0,0 +1,172 @@
+# Copyright (C) 2018-2019, 2022-2025 Centre National de la Recherche Scientifique
+# Copyright (C) 2020-2022 Institut Mines Télécom Albi-Carmaux
+# Copyright (C) 2022-2025 Institut Pierre-Simon Laplace
+# Copyright (C) 2022-2025 Institut de Physique du Globe de Paris
+# Copyright (C) 2018-2025 |Méso|Star> (contact@meso-star.com)
+# Copyright (C) 2022-2025 Observatoire de Paris
+# Copyright (C) 2022-2025 Université de Reims Champagne-Ardenne
+# Copyright (C) 2022-2025 Université de Versaille Saint-Quentin
+# Copyright (C) 2018-2019, 2022-2025 Université Paul Sabatier
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+.POSIX:
+.SUFFIXES: # Clean up default inference rules
+
+include config.mk
+
+LIBNAME = libhtrdr-combustion.a
+
+default: command
+
+################################################################################
+# Build the library
+################################################################################
+SRC =\
+ src/combustion/htrdr_combustion.c\
+ src/combustion/htrdr_combustion_args.c\
+ src/combustion/htrdr_combustion_draw_map.c\
+ src/combustion/htrdr_combustion_compute_radiance_sw.c\
+ src/combustion/htrdr_combustion_geometry_ray_filter.c\
+ src/combustion/htrdr_combustion_laser.c\
+ src/combustion/htrdr_combustion_main.c\
+ src/combustion/htrdr_combustion_phase_func.c
+OBJ = $(SRC:.c=.o)
+DEP = $(SRC:.c=.d)
+
+CFLAGS_LIB = $(CFLAGS_SO) $(COMBUSTION_INCS) -Isrc -DHTRDR_SHARED_BUILD
+
+library: core .config_combustion htrdr-combustion.pc $(DEP)
+ @$(MAKE) -fMakefile.combustion \
+ $$(for i in $(DEP); do echo -f $${i}; done) $(LIBNAME)
+
+core:
+ @$(MAKE) -fMakefile.core
+
+.config_combustion: config.mk
+ $(PKG_CONFIG) --atleast-version $(ATRSTM_VERSION) atrstm
+ $(PKG_CONFIG) --atleast-version $(RSYS_VERSION) rsys
+ $(PKG_CONFIG) --atleast-version $(S3D_VERSION) s3d
+ $(PKG_CONFIG) --atleast-version $(SCAM_VERSION) scam
+ $(PKG_CONFIG) --atleast-version $(SSF_VERSION) ssf
+ $(PKG_CONFIG) --atleast-version $(SSP_VERSION) star-sp
+ $(PKG_CONFIG) --atleast-version $(SVX_VERSION) svx
+ echo 'config done' > $@
+
+$(LIBNAME): libhtrdr-combustion.o
+ $(AR) -rc $@ $?
+ $(RANLIB) $@
+
+libhtrdr-combustion.o: $(OBJ)
+ $(LD) -r $(OBJ) -o $@
+ $(OBJCOPY) $(OCPFLAGS) $@
+
+$(DEP) $(OBJ): config.mk src/combustion/htrdr_combustion_args.h
+
+# Inference rules
+.SUFFIXES: .c .d .o
+.c.d:
+ @$(CC) $(CFLAGS_LIB) -MM -MT "$(@:.d=.o) $@" $< -MF $@
+
+.c.o:
+ $(CC) $(CFLAGS_LIB) -c $< -o $@
+
+################################################################################
+# Build the command
+################################################################################
+CMD_SRC = src/commands/htrdr_combustion_cmd.c
+CMD_OBJ = $(CMD_SRC:.c=.o)
+CMD_DEP = $(CMD_SRC:.c=.d)
+
+CFLAGS_CMD = $(CFLAGS_EXE) $$($(PKG_CONFIG_LOCAL) --static --cflags htrdr-core htrdr-combustion rsys)
+LDFLAGS_CMD = $(LDFLAGS_EXE) $$($(PKG_CONFIG_LOCAL) --static --libs htrdr-core htrdr-combustion rsys)
+
+command: library $(CMD_DEP)
+ @$(MAKE) -fMakefile.combustion -f$(CMD_DEP) htrdr-combustion
+
+htrdr-combustion: $(CMD_OBJ) $(LIBNAME)
+ $(CC) $(CFLAGS_CMD) -o $@ $(CMD_OBJ) $(LDFLAGS_CMD)
+
+$(CMD_DEP):
+ @$(CC) $(CFLAGS_CMD) -MM -MT "$(@:.d=.o) $@" $(@:.d=.c) -MF $@
+
+$(CMD_OBJ):
+ $(CC) $(CFLAGS_CMD) -c $(@:.o=.c) -o $@
+
+################################################################################
+# Generate files from template
+################################################################################
+src/combustion/htrdr_combustion_args.h: config.mk src/combustion/htrdr_combustion_args.h.in
+ sed -e 's/@HTRDR_COMBUSTION_ARGS_DEFAULT_LASER_FLUX_DENSITY@/$(HTRDR_COMBUSTION_ARGS_DEFAULT_LASER_FLUX_DENSITY)/g' \
+ -e 's/@HTRDR_COMBUSTION_ARGS_DEFAULT_FRACTAL_DIMENSION@/$(HTRDR_COMBUSTION_ARGS_DEFAULT_FRACTAL_DIMENSION)/g' \
+ -e 's/@HTRDR_COMBUSTION_ARGS_DEFAULT_FRACTAL_PREFACTOR@/$(HTRDR_COMBUSTION_ARGS_DEFAULT_FRACTAL_PREFACTOR)/g' \
+ -e 's/@HTRDR_COMBUSTION_ARGS_DEFAULT_OPTICAL_THICKNESS_THRESHOLD@/$(HTRDR_COMBUSTION_ARGS_DEFAULT_OPTICAL_THICKNESS_THRESHOLD)/g' \
+ -e 's/@HTRDR_COMBUSTION_ARGS_DEFAULT_GRID_DEFINITION_HINT@/$(HTRDR_COMBUSTION_ARGS_DEFAULT_GRID_DEFINITION_HINT)/g' \
+ -e 's/@HTRDR_COMBUSTION_ARGS_DEFAULT_WAVELENGTH@/$(HTRDR_COMBUSTION_ARGS_DEFAULT_WAVELENGTH)/g' \
+ $@.in > $@
+
+htrdr-combustion.pc: config.mk htrdr-combustion.pc.in
+ sed -e 's/@VERSION@/$(VERSION)/g' \
+ -e 's/@ATRSTM_VERSION@/$(ATRSTM_VERSION)/g' \
+ -e 's/@RSYS_VERSION@/$(RSYS_VERSION)/g' \
+ -e 's/@S3D_VERSION@/$(S3D_VERSION)/g' \
+ -e 's/@SCAM_VERSION@/$(SCAM_VERSION)/g' \
+ -e 's/@SSF_VERSION@/$(SSF_VERSION)/g' \
+ -e 's/@SSP_VERSION@/$(SSP_VERSION)/g' \
+ -e 's/@SVX_VERSION@/$(SVX_VERSION)/g' \
+ $@.in > $@
+
+doc/htrdr-combustion.1: doc/htrdr-combustion.1.in
+ sed -e 's/@HTRDR_COMBUSTION_ARGS_DEFAULT_LASER_FLUX_DENSITY@/$(HTRDR_COMBUSTION_ARGS_DEFAULT_LASER_FLUX_DENSITY)/g' \
+ -e 's/@HTRDR_COMBUSTION_ARGS_DEFAULT_FRACTAL_DIMENSION@/$(HTRDR_COMBUSTION_ARGS_DEFAULT_FRACTAL_DIMENSION)/g' \
+ -e 's/@HTRDR_COMBUSTION_ARGS_DEFAULT_FRACTAL_PREFACTOR@/$(HTRDR_COMBUSTION_ARGS_DEFAULT_FRACTAL_PREFACTOR)/g' \
+ -e 's/@HTRDR_COMBUSTION_ARGS_DEFAULT_OPTICAL_THICKNESS_THRESHOLD@/$(HTRDR_COMBUSTION_ARGS_DEFAULT_OPTICAL_THICKNESS_THRESHOLD)/g' \
+ -e 's/@HTRDR_COMBUSTION_ARGS_DEFAULT_GRID_DEFINITION_HINT@/$(HTRDR_COMBUSTION_ARGS_DEFAULT_GRID_DEFINITION_HINT)/g' \
+ -e 's/@HTRDR_COMBUSTION_ARGS_DEFAULT_WAVELENGTH@/$(HTRDR_COMBUSTION_ARGS_DEFAULT_WAVELENGTH)/g' \
+ -e 's/@HTRDR_ARGS_CAMERA_PERSPECTIVE_FOV_EXCLUSIVE_MIN@/$(HTRDR_ARGS_CAMERA_PERSPECTIVE_FOV_EXCLUSIVE_MIN)/g' \
+ -e 's/@HTRDR_ARGS_CAMERA_PERSPECTIVE_FOV_EXCLUSIVE_MAX@/$(HTRDR_ARGS_CAMERA_PERSPECTIVE_FOV_EXCLUSIVE_MAX)/g' \
+ -e 's/@HTRDR_ARGS_DEFAULT_CAMERA_PERSPECTIVE_FOCAL_DST@/$(HTRDR_ARGS_DEFAULT_CAMERA_PERSPECTIVE_FOCAL_DST)/g' \
+ -e 's/@HTRDR_ARGS_DEFAULT_CAMERA_PERSPECTIVE_FOV@/$(HTRDR_ARGS_DEFAULT_CAMERA_PERSPECTIVE_FOV)/g' \
+ -e 's/@HTRDR_ARGS_DEFAULT_CAMERA_PERSPECTIVE_LENS_RADIUS@/$(HTRDR_ARGS_DEFAULT_CAMERA_PERSPECTIVE_LENS_RADIUS)/g' \
+ -e 's/@HTRDR_ARGS_DEFAULT_CAMERA_POS@/$(HTRDR_ARGS_DEFAULT_CAMERA_POS)/g' \
+ -e 's/@HTRDR_ARGS_DEFAULT_CAMERA_TGT@/$(HTRDR_ARGS_DEFAULT_CAMERA_TGT)/g' \
+ -e 's/@HTRDR_ARGS_DEFAULT_CAMERA_UP@/$(HTRDR_ARGS_DEFAULT_CAMERA_UP)/g' \
+ -e 's/@HTRDR_ARGS_DEFAULT_IMG_WIDTH@/$(HTRDR_ARGS_DEFAULT_IMG_WIDTH)/g' \
+ -e 's/@HTRDR_ARGS_DEFAULT_IMG_HEIGHT@/$(HTRDR_ARGS_DEFAULT_IMG_HEIGHT)/g' \
+ -e 's/@HTRDR_ARGS_DEFAULT_IMG_SPP@/$(HTRDR_ARGS_DEFAULT_IMG_SPP)/g' \
+ -e 's/@HTRDR_ARGS_DEFAULT_RECTANGLE_POS@/$(HTRDR_ARGS_DEFAULT_RECTANGLE_POS)/g' \
+ -e 's/@HTRDR_ARGS_DEFAULT_RECTANGLE_TGT@/$(HTRDR_ARGS_DEFAULT_RECTANGLE_TGT)/g' \
+ -e 's/@HTRDR_ARGS_DEFAULT_RECTANGLE_UP@/$(HTRDR_ARGS_DEFAULT_RECTANGLE_UP)/g' \
+ -e 's/@HTRDR_ARGS_DEFAULT_RECTANGLE_SZ@/$(HTRDR_ARGS_DEFAULT_RECTANGLE_SZ)/g'\
+ $@.in > $@
+
+################################################################################
+# Miscellaneous
+################################################################################
+install: command doc/htrdr-combustion.1
+ @$(SHELL) install.sh 755 "$(DESTDIR)$(BINPREFIX)" htrdr-combustion
+ @$(SHELL) install.sh 644 "$(DESTDIR)$(MANPREFIX)/man1" doc/htrdr-combustion.1
+
+uninstall:
+ rm -f "$(DESTDIR)$(BINPREFIX)/htrdr-combustion"
+ rm -f "$(DESTDIR)$(MANPREFIX)/man1/htrdr-combustion.1"
+
+clean:
+ rm -f $(OBJ) $(DEP) $(LIBNAME)
+ rm -f htrdr-combustion $(CMD_OBJ) $(CMD_DEP)
+ rm -f .config_combustion libhtrdr-combustion.o htrdr-combustion.pc
+ rm -f doc/htrdr-combustion.1 src/combustion/htrdr_combustion_args.h
+
+lint: doc/htrdr-combustion.1
+ mandoc -Tlint -Wall doc/htrdr-combustion.1 || [ $$? -le 1 ]
diff --git a/Makefile.core b/Makefile.core
@@ -0,0 +1,155 @@
+# Copyright (C) 2018-2019, 2022-2025 Centre National de la Recherche Scientifique
+# Copyright (C) 2020-2022 Institut Mines Télécom Albi-Carmaux
+# Copyright (C) 2022-2025 Institut Pierre-Simon Laplace
+# Copyright (C) 2022-2025 Institut de Physique du Globe de Paris
+# Copyright (C) 2018-2025 |Méso|Star> (contact@meso-star.com)
+# Copyright (C) 2022-2025 Observatoire de Paris
+# Copyright (C) 2022-2025 Université de Reims Champagne-Ardenne
+# Copyright (C) 2022-2025 Université de Versaille Saint-Quentin
+# Copyright (C) 2018-2019, 2022-2025 Université Paul Sabatier
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+.POSIX:
+.SUFFIXES: # Clean up default inference rules
+
+include config.mk
+
+LIBNAME_STATIC = libhtrdr-core.a
+LIBNAME_SHARED = libhtrdr-core.so
+LIBNAME = $(LIBNAME_$(LIB_TYPE))
+
+default: core
+
+################################################################################
+# Build library
+################################################################################
+SRC =\
+ src/core/htrdr.c\
+ src/core/htrdr_args.c\
+ src/core/htrdr_buffer.c\
+ src/core/htrdr_draw_map.c\
+ src/core/htrdr_geometry.c\
+ src/core/htrdr_log.c\
+ src/core/htrdr_materials.c\
+ src/core/htrdr_proc_work.c\
+ src/core/htrdr_ran_wlen_cie_xyz.c\
+ src/core/htrdr_ran_wlen_discrete.c\
+ src/core/htrdr_ran_wlen_planck.c\
+ src/core/htrdr_rectangle.c\
+ src/core/htrdr_slab.c\
+ src/core/htrdr_solve_buffer.c\
+ src/core/htrdr_spectral.c
+OBJ = $(SRC:.c=.o)
+DEP = $(SRC:.c=.d)
+
+CFLAGS_CORE = $(CFLAGS_SO) -Isrc -DHTRDR_SHARED_BUILD $(CORE_INCS)
+LDFLAGS_CORE = $(LDFLAGS_SO) $(CORE_LIBS)
+
+core: .config_core htrdr-core.pc $(DEP)
+ @$(MAKE) -fMakefile.core $$(for i in $(DEP); do echo -f $${i}; done) \
+ $$(if [ -n "$(LIBNAME)" ]; then \
+ echo "$(LIBNAME)"; \
+ else \
+ echo "$(LIBNAME_SHARED)"; \
+ fi)
+
+$(LIBNAME_SHARED): $(OBJ)
+ $(CC) $(CFLAGS_CORE) -o $@ $(OBJ) $(LDFLAGS_CORE)
+
+$(LIBNAME_STATIC): libhtrdr-core.o
+ $(AR) -rc $@ $?
+ $(RANLIB) $@
+
+libhtrdr-core.o: $(OBJ)
+ $(LD) -r $(OBJ) -o $@
+ $(OBJCOPY) $(OCPFLAGS) $@
+
+$(DEP) $(OBJ): config.mk src/core/htrdr_args.h src/core/htrdr_version.h
+
+.config_core: config.mk
+ $(PKG_CONFIG) --atleast-version $(AW_VERSION) aw
+ $(PKG_CONFIG) --atleast-version $(MPI_VERSION) $(MPI_PC)
+ $(PKG_CONFIG) --atleast-version $(MRUMTL_VERSION) mrumtl
+ $(PKG_CONFIG) --atleast-version $(RSYS_VERSION) rsys
+ $(PKG_CONFIG) --atleast-version $(S3D_VERSION) s3d
+ $(PKG_CONFIG) --atleast-version $(SCAM_VERSION) scam
+ $(PKG_CONFIG) --atleast-version $(SSF_VERSION) ssf
+ $(PKG_CONFIG) --atleast-version $(SSP_VERSION) star-sp
+ echo 'config done' > $@
+
+# Inference rules
+.SUFFIXES: .c .d .o
+.c.d:
+ @$(CC) $(CFLAGS_CORE) -MM -MT "$(@:.d=.o) $@" $< -MF $@
+
+.c.o:
+ $(CC) $(CFLAGS_CORE) -c $< -o $@
+
+################################################################################
+# Generate files
+################################################################################
+src/core/htrdr_args.h: config.mk src/core/htrdr_args.h.in
+ sed -e 's/@HTRDR_ARGS_CAMERA_PERSPECTIVE_FOV_EXCLUSIVE_MIN@/$(HTRDR_ARGS_CAMERA_PERSPECTIVE_FOV_EXCLUSIVE_MIN)/g' \
+ -e 's/@HTRDR_ARGS_CAMERA_PERSPECTIVE_FOV_EXCLUSIVE_MAX@/$(HTRDR_ARGS_CAMERA_PERSPECTIVE_FOV_EXCLUSIVE_MAX)/g' \
+ -e 's/@HTRDR_ARGS_DEFAULT_CAMERA_POS@/$(HTRDR_ARGS_DEFAULT_CAMERA_POS)/g' \
+ -e 's/@HTRDR_ARGS_DEFAULT_CAMERA_TGT@/$(HTRDR_ARGS_DEFAULT_CAMERA_TGT)/g' \
+ -e 's/@HTRDR_ARGS_DEFAULT_CAMERA_UP@/$(HTRDR_ARGS_DEFAULT_CAMERA_UP)/g' \
+ -e 's/@HTRDR_ARGS_DEFAULT_CAMERA_ORTHOGRAPHIC_HEIGHT@/$(HTRDR_ARGS_DEFAULT_CAMERA_ORTHOGRAPHIC_HEIGHT)/g' \
+ -e 's/@HTRDR_ARGS_DEFAULT_CAMERA_PERSPECTIVE_FOV@/$(HTRDR_ARGS_DEFAULT_CAMERA_PERSPECTIVE_FOV)/g' \
+ -e 's/@HTRDR_ARGS_DEFAULT_CAMERA_PERSPECTIVE_LENS_RADIUS@/$(HTRDR_ARGS_DEFAULT_CAMERA_PERSPECTIVE_LENS_RADIUS)/g' \
+ -e 's/@HTRDR_ARGS_DEFAULT_CAMERA_PERSPECTIVE_FOCAL_DST@/$(HTRDR_ARGS_DEFAULT_CAMERA_PERSPECTIVE_FOCAL_DST)/g' \
+ -e 's/@HTRDR_ARGS_DEFAULT_RECTANGLE_POS@/$(HTRDR_ARGS_DEFAULT_RECTANGLE_POS)/g' \
+ -e 's/@HTRDR_ARGS_DEFAULT_RECTANGLE_TGT@/$(HTRDR_ARGS_DEFAULT_RECTANGLE_TGT)/g' \
+ -e 's/@HTRDR_ARGS_DEFAULT_RECTANGLE_UP@/$(HTRDR_ARGS_DEFAULT_RECTANGLE_UP)/g' \
+ -e 's/@HTRDR_ARGS_DEFAULT_RECTANGLE_SZ@/$(HTRDR_ARGS_DEFAULT_RECTANGLE_SZ)/g' \
+ -e 's/@HTRDR_ARGS_DEFAULT_IMG_WIDTH@/$(HTRDR_ARGS_DEFAULT_IMG_WIDTH)/g' \
+ -e 's/@HTRDR_ARGS_DEFAULT_IMG_HEIGHT@/$(HTRDR_ARGS_DEFAULT_IMG_HEIGHT)/g' \
+ -e 's/@HTRDR_ARGS_DEFAULT_IMG_SPP@/$(HTRDR_ARGS_DEFAULT_IMG_SPP)/g' \
+ $@.in > $@
+
+src/core/htrdr_version.h: config.mk src/core/htrdr_version.h.in
+ sed -e 's/@VERSION_MAJOR@/$(VERSION_MAJOR)/g' \
+ -e 's/@VERSION_MINOR@/$(VERSION_MINOR)/g' \
+ -e 's/@VERSION_PATCH@/$(VERSION_PATCH)/g' \
+ $@.in > $@
+
+htrdr-core.pc: config.mk htrdr-core.pc.in
+ sed -e 's/@VERSION@/$(VERSION)/g' \
+ -e 's/@AW_VERSION@/$(AW_VERSION)/g' \
+ -e 's/@MPI_PC@/$(MPI_PC)/g' \
+ -e 's/@MPI_VERSION@/$(MPI_VERSION)/g' \
+ -e 's/@MRUMTL_VERSION@/$(MRUMTL_VERSION)/g' \
+ -e 's/@RSYS_VERSION@/$(RSYS_VERSION)/g' \
+ -e 's/@S3D_VERSION@/$(S3D_VERSION)/g' \
+ -e 's/@SCAM_VERSION@/$(SCAM_VERSION)/g' \
+ -e 's/@SSF_VERSION@/$(SSF_VERSION)/g' \
+ -e 's/@SSP_VERSION@/$(SSP_VERSION)/g' \
+ $@.in > $@
+
+################################################################################
+# Miscellaneous
+################################################################################
+install:
+ @if [ "$(LIB_TYPE)" == "SHARED" ]; then \
+ $(SHELL) install.sh 755 "$(DESTDIR)$(LIBPREFIX)" $(LIBNAME); \
+ fi
+
+uninstall:
+ rm -f "$(DESTDIR)$(LIBPREFIX)/$(LIBNAME)
+
+clean:
+ rm -f $(LIBNAME) $(OBJ) $(DEP)
+ rm -f libhtrdr-core.o .config_core htrdr-core.pc
+ rm -f src/core/htrdr_args.h src/core/htrdr_version.h
diff --git a/Makefile.planets b/Makefile.planets
@@ -0,0 +1,166 @@
+# Copyright (C) 2018-2019, 2022-2025 Centre National de la Recherche Scientifique
+# Copyright (C) 2020-2022 Institut Mines Télécom Albi-Carmaux
+# Copyright (C) 2022-2025 Institut Pierre-Simon Laplace
+# Copyright (C) 2022-2025 Institut de Physique du Globe de Paris
+# Copyright (C) 2018-2025 |Méso|Star> (contact@meso-star.com)
+# Copyright (C) 2022-2025 Observatoire de Paris
+# Copyright (C) 2022-2025 Université de Reims Champagne-Ardenne
+# Copyright (C) 2022-2025 Université de Versaille Saint-Quentin
+# Copyright (C) 2018-2019, 2022-2025 Université Paul Sabatier
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+.POSIX:
+.SUFFIXES: # Clean up default inference rules
+
+include config.mk
+
+LIBNAME = libhtrdr-planets.a
+
+default: command
+
+################################################################################
+# Build the library
+################################################################################
+SRC =\
+ src/planets/htrdr_planets.c\
+ src/planets/htrdr_planets_args.c\
+ src/planets/htrdr_planets_compute_radiance.c\
+ src/planets/htrdr_planets_draw_map.c\
+ src/planets/htrdr_planets_main.c\
+ src/planets/htrdr_planets_solve_volrad_budget.c\
+ src/planets/htrdr_planets_source.c
+OBJ = $(SRC:.c=.o)
+DEP = $(SRC:.c=.d)
+
+CFLAGS_LIB = $(CFLAGS_SO) $(PLANETS_INCS) -Isrc -DHTRDR_SHARED_BUILD
+
+library: core .config_planets htrdr-planets.pc $(DEP)
+ @$(MAKE) -fMakefile.planets \
+ $$(for i in $(DEP); do echo -f $${i}; done) $(LIBNAME)
+
+core:
+ @$(MAKE) -fMakefile.core
+
+.config_planets: config.mk
+ $(PKG_CONFIG) --atleast-version $(MPI_VERSION) $(MPI_PC)
+ $(PKG_CONFIG) --atleast-version $(RNATM_VERSION) rnatm
+ $(PKG_CONFIG) --atleast-version $(RNGRD_VERSION) rngrd
+ $(PKG_CONFIG) --atleast-version $(RSYS_VERSION) rsys
+ $(PKG_CONFIG) --atleast-version $(S3D_VERSION) s3d
+ $(PKG_CONFIG) --atleast-version $(SBUF_VERSION) sbuf
+ $(PKG_CONFIG) --atleast-version $(SCAM_VERSION) scam
+ $(PKG_CONFIG) --atleast-version $(SSF_VERSION) ssf
+ $(PKG_CONFIG) --atleast-version $(SSP_VERSION) star-sp
+ $(PKG_CONFIG) --atleast-version $(SVX_VERSION) svx
+ echo 'config done' > $@
+
+$(LIBNAME): libhtrdr-planets.o
+ $(AR) -rc $@ $?
+ $(RANLIB) $@
+
+libhtrdr-planets.o: $(OBJ)
+ $(LD) -r $(OBJ) -o $@
+ $(OBJCOPY) $(OCPFLAGS) $@
+
+$(DEP) $(OBJ): config.mk src/planets/htrdr_planets_args.h
+
+# Inference rules
+.SUFFIXES: .c .d .o
+.c.d:
+ @$(CC) $(CFLAGS_LIB) -MM -MT "$(@:.d=.o) $@" $< -MF $@
+
+.c.o:
+ $(CC) $(CFLAGS_LIB) -c $< -o $@
+
+################################################################################
+# Build the command
+################################################################################
+CMD_SRC = src/commands/htrdr_planets_cmd.c
+CMD_OBJ = $(CMD_SRC:.c=.o)
+CMD_DEP = $(CMD_SRC:.c=.d)
+
+CFLAGS_CMD = $(CFLAGS_EXE) $$($(PKG_CONFIG_LOCAL) --static --cflags htrdr-core htrdr-planets rsys)
+LDFLAGS_CMD = $(LDFLAGS_EXE) $$($(PKG_CONFIG_LOCAL) --static --libs htrdr-core htrdr-planets rsys)
+
+command: library $(CMD_DEP)
+ @$(MAKE) -fMakefile.planets -f$(CMD_DEP) htrdr-planets
+
+htrdr-planets: $(CMD_OBJ) $(LIBNAME)
+ $(CC) $(CFLAGS_CMD) -o $@ $(CMD_OBJ) $(LDFLAGS_CMD)
+
+$(CMD_DEP):
+ @$(CC) $(CFLAGS_CMD) -MM -MT "$(@:.d=.o) $@" $(@:.d=.c) -MF $@
+
+$(CMD_OBJ):
+ $(CC) $(CFLAGS_CMD) -c $(@:.o=.c) -o $@
+
+################################################################################
+# Generate files from template
+################################################################################
+src/planets/htrdr_planets_args.h: config.mk src/planets/htrdr_planets_args.h.in
+ sed -e 's/@HTRDR_PLANETS_ARGS_DEFAULT_OPTICAL_THICKNESS_THRESHOLD@/$(HTRDR_PLANETS_ARGS_DEFAULT_OPTICAL_THICKNESS_THRESHOLD)/g' \
+ -e 's/@HTRDR_PLANETS_ARGS_DEFAULT_GRID_DEFINITION_HINT@/$(HTRDR_PLANETS_ARGS_DEFAULT_GRID_DEFINITION_HINT)/g' \
+ -e 's/@HTRDR_PLANETS_ARGS_DEFAULT_VOLRAD_BUDGET_SPT@/$(HTRDR_PLANETS_ARGS_DEFAULT_VOLRAD_BUDGET_SPT)/g' \
+ $@.in > $@
+
+htrdr-planets.pc: config.mk htrdr-planets.pc.in
+ sed -e 's/@VERSION@/$(VERSION)/g' \
+ -e 's/@RNATM_VERSION@/$(RNATM_VERSION)/g' \
+ -e 's/@RNGRD_VERSION@/$(RNGRD_VERSION)/g' \
+ -e 's/@RSYS_VERSION@/$(RSYS_VERSION)/g' \
+ -e 's/@S3D_VERSION@/$(S3D_VERSION)/g' \
+ -e 's/@SBUF_VERSION@/$(SBUF_VERSION)/g' \
+ -e 's/@SCAM_VERSION@/$(SCAM_VERSION)/g' \
+ -e 's/@SSF_VERSION@/$(SSF_VERSION)/g' \
+ -e 's/@SSP_VERSION@/$(SSP_VERSION)/g' \
+ -e 's/@SVX_VERSION@/$(SVX_VERSION)/g' \
+ $@.in > $@
+
+doc/htrdr-planets.1: doc/htrdr-planets.1.in
+ sed -e 's/@HTRDR_ARGS_CAMERA_PERSPECTIVE_FOV_EXCLUSIVE_MIN@/$(HTRDR_ARGS_CAMERA_PERSPECTIVE_FOV_EXCLUSIVE_MIN)/g' \
+ -e 's/@HTRDR_ARGS_CAMERA_PERSPECTIVE_FOV_EXCLUSIVE_MAX@/$(HTRDR_ARGS_CAMERA_PERSPECTIVE_FOV_EXCLUSIVE_MAX)/g' \
+ -e 's/@HTRDR_ARGS_DEFAULT_CAMERA_PERSPECTIVE_FOCAL_DST@/$(HTRDR_ARGS_DEFAULT_CAMERA_PERSPECTIVE_FOCAL_DST)/g' \
+ -e 's/@HTRDR_ARGS_DEFAULT_CAMERA_PERSPECTIVE_FOV@/$(HTRDR_ARGS_DEFAULT_CAMERA_PERSPECTIVE_FOV)/g' \
+ -e 's/@HTRDR_ARGS_DEFAULT_CAMERA_PERSPECTIVE_LENS_RADIUS@/$(HTRDR_ARGS_DEFAULT_CAMERA_PERSPECTIVE_LENS_RADIUS)/g' \
+ -e 's/@HTRDR_ARGS_DEFAULT_CAMERA_POS@/$(HTRDR_ARGS_DEFAULT_CAMERA_POS)/g' \
+ -e 's/@HTRDR_ARGS_DEFAULT_CAMERA_TGT@/$(HTRDR_ARGS_DEFAULT_CAMERA_TGT)/g' \
+ -e 's/@HTRDR_ARGS_DEFAULT_CAMERA_UP@/$(HTRDR_ARGS_DEFAULT_CAMERA_UP)/g' \
+ -e 's/@HTRDR_ARGS_DEFAULT_IMG_WIDTH@/$(HTRDR_ARGS_DEFAULT_IMG_WIDTH)/g' \
+ -e 's/@HTRDR_ARGS_DEFAULT_IMG_HEIGHT@/$(HTRDR_ARGS_DEFAULT_IMG_HEIGHT)/g' \
+ -e 's/@HTRDR_ARGS_DEFAULT_IMG_SPP@/$(HTRDR_ARGS_DEFAULT_IMG_SPP)/g' \
+ -e 's/@HTRDR_PLANETS_ARGS_DEFAULT_OPTICAL_THICKNESS_THRESHOLD@/$(HTRDR_PLANETS_ARGS_DEFAULT_OPTICAL_THICKNESS_THRESHOLD)/g' \
+ -e 's/@HTRDR_PLANETS_ARGS_DEFAULT_GRID_DEFINITION_HINT@/$(HTRDR_PLANETS_ARGS_DEFAULT_GRID_DEFINITION_HINT)/g' \
+ -e 's/@HTRDR_PLANETS_ARGS_DEFAULT_VOLRAD_BUDGET_SPT@/$(HTRDR_PLANETS_ARGS_DEFAULT_VOLRAD_BUDGET_SPT)/g' \
+ $@.in > $@
+
+################################################################################
+# Miscellaneous
+################################################################################
+install: command doc/htrdr-planets.1
+ @$(SHELL) install.sh 755 "$(DESTDIR)$(BINPREFIX)" htrdr-planets
+ @$(SHELL) install.sh 644 "$(DESTDIR)$(MANPREFIX)/man1" doc/htrdr-planets.1
+
+uninstall:
+ rm -f "$(DESTDIR)$(BINPREFIX)/htrdr-planets"
+ rm -f "$(DESTDIR)$(MANPREFIX)/man1/htrdr-planets.1"
+
+clean:
+ rm -f $(OBJ) $(DEP) $(LIBNAME)
+ rm -f $(CMD_OBJ) $(CMD_DEP) htrdr-planets
+ rm -f .config_planets libhtrdr-planets.o htrdr-planets.pc
+ rm -f doc/htrdr-planets.1 src/planets/htrdr_planets_args.h
+
+lint: doc/htrdr-planets.1
+ mandoc -Tlint -Wall doc/htrdr-planets.1 || [ $$? -le 1 ]
diff --git a/config.mk b/config.mk
@@ -73,6 +73,7 @@ CC = cc
LD = ld
OBJCOPY = objcopy
PKG_CONFIG = pkg-config
+PKG_CONFIG_LOCAL = PKG_CONFIG_PATH="./:$${PKG_CONFIG_PATH}" $(PKG_CONFIG)
RANLIB = ranlib
################################################################################
@@ -98,30 +99,30 @@ SSP_VERSION = 0.14
SVX_VERSION = 0.3
# Atmosphere
-ATMOSPHERE_DPDC_CFLAGS =\
+ATMOSPHERE_INCS =\
$$($(PKG_CONFIG) $(PCFLAGS) --cflags htsky rsys s3d scam ssf star-sp svx)
-ATMOSPHERE_DPDC_LIBS =\
+ATMOSPHERE_LIBS =\
$$($(PKG_CONFIG) $(PCFLAGS) --libs htsky rsys s3d scam ssf star-sp svx) -lm
# Combustion
-COMBUSTION_DPDC_CFLAGS =\
+COMBUSTION_INCS =\
$$($(PKG_CONFIG) $(PCFLAGS) --cflags atrstm rsys s3d scam ssf star-sp svx)
-COMBUSTION_DPDC_LIBS =\
+COMBUSTION_LIBS =\
$$($(PKG_CONFIG) $(PCFLAGS) --libs atrstm rsys s3d scam ssf star-sp svx) -lm
# Core
-CORE_DPDC_CFLAGS =\
+CORE_INCS =\
$$($(PKG_CONFIG) $(PCFLAGS) --cflags aw $(MPI_PC) mrumtl rsys s3d scam ssf star-sp)\
-fopenmp
-CORE_DPDC_LIBS =\
+CORE_LIBS =\
$$($(PKG_CONFIG) $(PCFLAGS) --libs aw $(MPI_PC) mrumtl rsys s3d scam ssf star-sp)\
-fopenmp -lm
# Planets
-PLANETS_DPDC_CFLAGS=\
- $$($(PKG_CONFIG) $(PCFLAGS) --cflags rnatm rngrd rsys s3d sbuf scam ssf star-sp svx)
-PLANETS_DPDC_LIBS=\
- $$($(PKG_CONFIG) $(PCFLAGS) --libs rnatm rngrd rsys s3d sbuf scam ssf star-sp svx) -lm
+PLANETS_INCS = $$($(PKG_CONFIG) $(PCFLAGS) --cflags $(MPI_PC) \
+ rnatm rngrd rsys s3d sbuf scam ssf star-sp svx)
+PLANETS_LIBS = $$($(PKG_CONFIG) $(PCFLAGS) --libs $(MPI_PC) \
+ rnatm rngrd rsys s3d sbuf scam ssf star-sp svx) -lm
################################################################################
# Compilation options
diff --git a/doc/htrdr-planets.1.in b/doc/htrdr-planets.1.in
@@ -20,7 +20,7 @@
.\"
.\" You should have received a copy of the GNU General Public License
.\" along with this program. If not, see <http://www.gnu.org/licenses/>.
-.Dd February 14, 2025
+.Dd March 17, 2025
.Dt HTRDR-PLANETS 1
.Os
.\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
@@ -36,17 +36,15 @@
.Nm
.Op Fl dfhNv
.Op Fl a Ar aerosol_opt Ns Op : Ns Ar aerosol_opt No ...
+.Op Fl b Ar accel_struct_build_opt Ns Op : Ns Ar accel_struct_build_opt No ...
.Op Fl C Ar persp_camera_opt Ns Op : Ns Ar persp_camera_opt No ...
.Op Fl G Ar ground_opt Ns Op : Ns Ar ground_opt No ...
.Op Fl i Ar image_opt Ns Op : Ns Ar image_opt No ...
-.Op Fl O Ar accel_struct_storage
.Op Fl o Ar output
.Op Fl r Ar volrad_budget_opt Ns Op : Ns Ar volrad_budget_opt No ...
.Op Fl S Ar source_opt Ns Op : Ns Ar source_opt No ...
.Op Fl s Ar spectral_opt Ns Op : Ns Ar spectral_opt No ...
-.Op Fl T Ar optical_thickness
.Op Fl t Ar threads_count
-.Op Fl V Ar accel_struct_definition
.Fl g Ar gas_opt Ns Op : Ns Ar gas_opt No ...
.\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
.\" Detailed description
@@ -172,6 +170,82 @@ Note that this file and the tetrahedral mesh
must be consistent with each other, i.e. the nodes must be
listed in the same order.
.El
+.It Fl b Ar accel_struct_build_opt Ns Op : Ns Ar accel_struct_build_opt No ...
+Configure the building of the acceleration structures.
+.Pp
+The acceleration structures building options are as follows:
+.Bl -tag -width Ds
+.It Cm def= Ns Ar definition
+Advice on the definition of the atmospheric acceleration structures.
+Default is @HTRDR_PLANETS_ARGS_DEFAULT_GRID_DEFINITION_HINT@.
+.It Cm nthreads= Ns Ar threads_count
+Advice on the number of threads to use.
+This number is different from that defined by the
+.Fl t
+option, as the construction of acceleration structures is not based on
+the same parallelization model as Monte Carlo integration.
+This construction may not benefit from too many threads, on the
+contrary.
+.Pp
+The default value is 8, i.e. a maximum of 8 threads are used to build
+acceleration structures.
+.It Cm proc= Ns Ar processes
+This option is only used when
+.Nm
+is run with multiple processes
+.Pq see Xr mpirun 1 .
+It defines the processes that must build the acceleration structures.
+.Pp
+The value
+.Cm all
+means that all processes build their own set of acceleration structures.
+This is the de facto configuration when no storage is used
+.Po
+i.e. the
+.Cm storage
+parameter is not set
+.Pc .
+.Pp
+If acceleration structure storage is defined
+.Pq Cm storage No parameter ,
+a value of
+.Cm all
+should only be used if each process has its own disk space on which its
+own set of acceleration structures is stored.
+If processes share a common disk space, the value should be
+.Cm master .
+This means that only the main process builds the acceleration
+structures, which are in fine shared with the other processes by
+storing the saved acceleration structures on a common disk space.
+.Pp
+The default value is
+.Cm master .
+.It Cm storage= Ns Ar accel_struct_file
+File where atmospheric acceleration structures are stored/loaded.
+.Pp
+If
+.Ar accel_struct_file
+does not exist, it is created and is used to store the built
+acceleration structures.
+.Pp
+If
+.Ar accel_struct_file
+exists, acceleration structures are loaded from it rather than built
+from scratch, resulting in significant acceleration of the preprocessing
+step.
+Note that if the data structures stored in
+.Ar accel_struct_file
+are not as expected (that is, the input atmospheric data or construction
+parameters are different), an error is notified and execution is
+stopped, thus avoiding the use of incorrect acceleration structures.
+.Pp
+By default, no storage file is used, i.e. acceleration structures are
+built from scratch and stored in memory.
+.It Cm tau= Ns Ar optical_thickness
+Optical thickness used as threshold criterion for building the
+acceleration structures.
+Default is @HTRDR_PLANETS_ARGS_DEFAULT_OPTICAL_THICKNESS_THRESHOLD@.
+.El
.It Fl C Ar persp_camera_opt Ns Op : Ns Ar persp_camera_opt No ...
Set up a pinhole or thin-lens perspective camera.
.Pp
@@ -308,24 +382,6 @@ all rather than re-evaluating them every time a tetrahedron is queried
at a given position.
In return, the memory space used to store normals increases the memory
footprint.
-.It Fl O Ar accel_struct_storage
-File where atmospheric acceleration structures are stored/loaded.
-.Pp
-If
-.Ar accel_struct_storage
-does not exist, it is created and is used to store the built
-acceleration structures.
-.Pp
-If
-.Ar accel_struct_storage
-exists, acceleration structures are loaded from it rather than built
-from scratch, resulting in significant acceleration of the preprocessing
-step.
-Note that if the data structures stored in
-.Ar accel_struct_storage
-are not as expected (that is, the input atmospheric data or construction
-parameters are different), an error is notified and execution is
-stopped, thus avoiding the use of incorrect acceleration structures.
.It Fl o Ar output
Output file.
If not defined, data is written to standard output.
@@ -424,18 +480,11 @@ and
.Ar wlen_max
are equal, the calculation is monochromatic.
.El
-.It Fl T Ar optical_thickness
-Optical thickness used as threshold criterion for building the acceleration
-structures.
-Default is @HTRDR_PLANETS_ARGS_DEFAULT_OPTICAL_THICKNESS_THRESHOLD@.
.It Fl t
Advice on the number of threads to use.
By default,
.Nm
uses many threads as processor cores.
-.It Fl V Ar accel_struct_definition
-Advice on the definition of the atmospheric acceleration structures.
-Default is @HTRDR_PLANETS_ARGS_DEFAULT_GRID_DEFINITION_HINT@.
.It Fl v
Make
.Nm
@@ -651,7 +700,7 @@ htrdr-planets -v -N \\
:mesh=ground_triangles.smsh\\
:prop=ground_properties.rnsp\\
:brdf=ground_brdfs.rnsl \\
- -V 512 -T 10 -O storage_cie.bin \\
+ -b def=512:tau=10:storage=storage_cie.bin \\
-fo image_CIE_XYZ.ht
.Ed
.Pp
@@ -671,8 +720,7 @@ while one wants to store/reload the acceleration structures for a
spectral range between 10 and 20 microns.
In any case, if the previous storage had been submitted, the command
would have stopped with an error message, thus avoiding the use of the
-wrong acceleration structures
-.Pq see Fl O No option .
+wrong acceleration structures:
.Bd -literal -offset Ds
htrdr-planets -v -N \\
-i def=800x600:spp=64 \\
@@ -693,7 +741,7 @@ htrdr-planets -v -N \\
:mesh=ground_triangles.smsh\\
:prop=ground_properties.rnsp\\
:brdf=ground_brdfs.rnsl \\
- -V 512 -T 10 -O storage_lw.bin \\
+ -b def=512:tau=10:storage=storage_lw.bin \\
-fo image_infrared.ht
.Ed
.\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
diff --git a/src/commands/htrdr_cmd.c b/src/commands/htrdr_cmd.c
@@ -1,126 +0,0 @@
-/* Copyright (C) 2018-2019, 2022-2025 Centre National de la Recherche Scientifique
- * Copyright (C) 2020-2022 Institut Mines Télécom Albi-Carmaux
- * Copyright (C) 2022-2025 Institut Pierre-Simon Laplace
- * Copyright (C) 2022-2025 Institut de Physique du Globe de Paris
- * Copyright (C) 2018-2025 |Méso|Star> (contact@meso-star.com)
- * Copyright (C) 2022-2025 Observatoire de Paris
- * Copyright (C) 2022-2025 Université de Reims Champagne-Ardenne
- * Copyright (C) 2022-2025 Université de Versaille Saint-Quentin
- * Copyright (C) 2018-2019, 2022-2025 Université Paul Sabatier
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>. */
-
-#ifdef HTRDR_BUILD_ATMOSPHERE
- #include "atmosphere/htrdr_atmosphere.h"
-#endif
-#ifdef HTRDR_BUILD_COMBUSTION
- #include "combustion/htrdr_combustion.h"
-#endif
-#ifdef HTRDR_BUILD_PLANETS
- #include "planets/htrdr_planets.h"
-#endif
-
-#include "core/htrdr_log.h"
-#include "core/htrdr_version.h"
-
-#include <rsys/rsys.h>
-#include <string.h>
-
-/*******************************************************************************
- * Helper functions
- ******************************************************************************/
-static void
-usage(void)
-{
- printf("usage: htrdr [-vh] [mode [options ...]]\n");
-}
-
-/*******************************************************************************
- * Program
- ******************************************************************************/
-int
-main(int argc, char** argv)
-{
- int err = 0;
-
- if(argc < 2) {
- usage();
- err = -1;
- goto error;
- }
-
- /* Atmosphere mode */
- if(!strcmp(argv[1], "atmosphere")) {
-#ifdef HTRDR_BUILD_ATMOSPHERE
- err = htrdr_atmosphere_main(argc-1, argv+1);
- if(err) goto error;
-#else
- fprintf(stderr,
- "The atmosphere mode is not available in this htrdr build.\n");
- err = 1;
- goto error;
-#endif
-
- /* Combustion mode */
- } else if(!strcmp(argv[1], "combustion")) {
-#ifdef HTRDR_BUILD_COMBUSTION
- err = htrdr_combustion_main(argc-1, argv+1);
- if(err) goto error;
-#else
- fprintf(stderr,
- "The combustion mode is not available in this htrdr build.\n");
- err = 1;
- goto error;
-#endif
-
- /* Planeto mode */
- } else if(!strcmp(argv[1], "planets")) {
-#ifdef HTRDR_BUILD_PLANETS
- err = htrdr_planets_main(argc-1, argv+1);
- if(err) goto error;
-#else
- fprintf(stderr,
- "The planets mode is not available in this htrdr build.\n");
- err = 1;
- goto error;
-#endif
-
- /* Version */
- } else if(!strcmp(argv[1], "-v")) {
- printf("%s version %d.%d.%d\n",
- argv[0],
- HTRDR_VERSION_MAJOR,
- HTRDR_VERSION_MINOR,
- HTRDR_VERSION_PATCH);
- goto exit;
-
- /* Help */
- } else if(!strcmp(argv[1], "-h")) {
- usage();
- goto exit;
-
- /* Fallback */
- } else {
- fprintf(stderr, "Unknown option: %s\n", argv[1]);
- usage();
- err = -1;
- goto error;
- }
-
-exit:
- return err;
-error:
- goto exit;
-}
-
diff --git a/src/htrdr.in b/src/htrdr.in
@@ -0,0 +1,48 @@
+#!/bin/sh
+
+# Copyright (C) 2018-2019, 2022-2025 Centre National de la Recherche Scientifique
+# Copyright (C) 2020-2022 Institut Mines Télécom Albi-Carmaux
+# Copyright (C) 2022-2025 Institut Pierre-Simon Laplace
+# Copyright (C) 2022-2025 Institut de Physique du Globe de Paris
+# Copyright (C) 2018-2025 |Méso|Star> (contact@meso-star.com)
+# Copyright (C) 2022-2025 Observatoire de Paris
+# Copyright (C) 2022-2025 Université de Reims Champagne-Ardenne
+# Copyright (C) 2022-2025 Université de Versaille Saint-Quentin
+# Copyright (C) 2018-2019, 2022-2025 Université Paul Sabatier
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+set -e
+
+usage()
+{
+ printf 'usage: %s [-hv] [mode [options ...]]\n' "${0##*/}"
+}
+
+if [ $# -lt 1 ]; then
+ >&2 usage
+ exit 1
+fi
+
+opt="$1"
+shift 1
+
+case "${opt}" in
+ "atmosphere") htrdr-atmosphere "$@" ;;
+ "combustion") htrdr-combustion "$@" ;;
+ "planets") htrdr-planets "$@" ;;
+ "-h") usage ;;
+ "-v") printf '%s version @MAJOR@.@MINOR@.@PATCH@\n' "${0##*/}" ;;
+ *) >&2 usage ;;
+esac
diff --git a/src/planets/htrdr_planets.c b/src/planets/htrdr_planets.c
@@ -21,7 +21,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
-#define _POSIX_C_SOURCE 200112L /* fdopen, nextafter, rint */
+#define _POSIX_C_SOURCE 200112L /* fdopen, nanosleep, nextafter, rint */
#include "core/htrdr.h"
#include "core/htrdr_ran_wlen_cie_xyz.h"
@@ -49,6 +49,9 @@
#include <unistd.h> /* close */
#include <sys/stat.h>
+#include <mpi.h>
+#include <time.h>
+
/*******************************************************************************
* Helper function
******************************************************************************/
@@ -86,9 +89,9 @@ setup_octree_storage
rnatm_args->octrees_storage = NULL;
rnatm_args->load_octrees_from_storage = 0;
- if(!args->octrees_storage) goto exit;
+ if(!args->accel_struct.storage) goto exit;
- fd = open(args->octrees_storage, O_CREAT|O_RDWR, S_IRUSR|S_IWUSR);
+ fd = open(args->accel_struct.storage, O_CREAT|O_RDWR, S_IRUSR|S_IWUSR);
if(fd < 0) { res = RES_IO_ERR; goto error; }
rnatm_args->octrees_storage = fdopen(fd, "w+");
@@ -98,7 +101,7 @@ setup_octree_storage
* descriptor */
fd = -1;
- err = stat(args->octrees_storage, &file_stat);
+ err = stat(args->accel_struct.storage, &file_stat);
if(err < 0) { res = RES_IO_ERR; goto error; }
if(file_stat.st_size != 0) {
@@ -111,7 +114,7 @@ exit:
return res;
error:
htrdr_log_err(cmd->htrdr, "error opening the octree storage `%s' -- %s\n",
- args->octrees_storage, res_to_cstr(res));
+ args->accel_struct.storage, res_to_cstr(res));
if(fd >= 0) CHK(close(fd) == 0);
if(rnatm_args->octrees_storage) CHK(fclose(rnatm_args->octrees_storage) == 0);
@@ -120,34 +123,83 @@ error:
goto exit;
}
+static void
+mpi_barrier(void)
+{
+ struct timespec t;
+ int complete = 0;
+ MPI_Request req;
+
+ t.tv_sec = 0;
+ t.tv_nsec = 10000000; /* 10ms */
+
+ /* Use an asynchronous barrier to avoid active waiting,
+ * and therefore wasted resources */
+ MPI_Ibarrier(MPI_COMM_WORLD, &req);
+
+ do {
+ nanosleep(&t, NULL);
+ MPI_Test(&req, &complete, MPI_STATUS_IGNORE);
+ } while(!complete);
+}
+
static res_T
setup_atmosphere
(struct htrdr_planets* cmd,
const struct htrdr_planets_args* args)
{
- struct rnatm_create_args rnatm_args = RNATM_CREATE_ARGS_DEFAULT;
+ struct rnatm_create_args rnatm = RNATM_CREATE_ARGS_DEFAULT;
res_T res = RES_OK;
ASSERT(cmd && args);
- rnatm_args.gas = args->gas;
- rnatm_args.aerosols = args->aerosols;
- rnatm_args.naerosols = args->naerosols;
- rnatm_args.name = "atmosphere";
- rnatm_args.spectral_range[0] = args->spectral_domain.wlen_range[0];
- rnatm_args.spectral_range[1] = args->spectral_domain.wlen_range[1];
- rnatm_args.optical_thickness = args->optical_thickness;
- rnatm_args.grid_definition_hint = args->octree_definition_hint;
- rnatm_args.precompute_normals = args->precompute_normals;
- rnatm_args.logger = htrdr_get_logger(cmd->htrdr);
- rnatm_args.allocator = htrdr_get_allocator(cmd->htrdr);
- rnatm_args.nthreads = args->nthreads;
- rnatm_args.verbose = args->verbose;
-
- res = setup_octree_storage(cmd, args, &rnatm_args);
- if(res != RES_OK) goto error;
+ rnatm.gas = args->gas;
+ rnatm.aerosols = args->aerosols;
+ rnatm.naerosols = args->naerosols;
+ rnatm.name = "atmosphere";
+ rnatm.spectral_range[0] = args->spectral_domain.wlen_range[0];
+ rnatm.spectral_range[1] = args->spectral_domain.wlen_range[1];
+ rnatm.optical_thickness = args->accel_struct.optical_thickness;
+ rnatm.grid_definition_hint = args->accel_struct.definition_hint;
+ rnatm.precompute_normals = args->precompute_normals;
+ rnatm.logger = htrdr_get_logger(cmd->htrdr);
+ rnatm.allocator = htrdr_get_allocator(cmd->htrdr);
+ rnatm.nthreads = args->accel_struct.nthreads;
+ rnatm.verbose = args->verbose;
+
+ if(!args->accel_struct.storage || !args->accel_struct.master_only) {
+ /* From now on, either the octrees have to be built in memory, or all the
+ * processes have to build them. In all cases, all processes must create
+ * the atmopshere data structures. */
+ if((res = setup_octree_storage(cmd, args, &rnatm)) != RES_OK) goto error;
+ if((res = rnatm_create(&rnatm, &cmd->atmosphere)) != RES_OK) goto error;
- res = rnatm_create(&rnatm_args, &cmd->atmosphere);
- if(res != RES_OK) goto error;
+ } else {
+
+ const int is_master_process = htrdr_get_mpi_rank(cmd->htrdr) == 0;
+ /* A storage space is used and only the master process must fill it with the
+ * octrees it builds */
+
+ if(is_master_process) {
+ /* Octrees are built only by the master process and stored on disk.
+ * Note that in reality, octrees may already be constructed and stored in
+ * the storage provided. In any case, we can treat this special case as
+ * the general case, and therefore simply consider that in such situation,
+ * "construction" by the master process is only faster */
+ if((res = setup_octree_storage(cmd, args, &rnatm)) != RES_OK) goto error;
+ if((res = rnatm_create(&rnatm, &cmd->atmosphere)) != RES_OK) goto error;
+ }
+
+ /* Wait for octrees to be built by the master process */
+ mpi_barrier();
+
+ if(!is_master_process) {
+ /* Octrees have been built by the master process.
+ * Non master processes simply load them. */
+ if((res = setup_octree_storage(cmd, args, &rnatm)) != RES_OK) goto error;
+ ASSERT(rnatm.load_octrees_from_storage == 1);
+ if((res = rnatm_create(&rnatm, &cmd->atmosphere)) != RES_OK) goto error;
+ }
+ }
exit:
return res;
diff --git a/src/planets/htrdr_planets_args.c b/src/planets/htrdr_planets_args.c
@@ -117,17 +117,32 @@ check_volrad_budget_args(const struct htrdr_planets_volrad_budget_args* args)
return RES_OK;
}
+static INLINE res_T
+check_accel_struct_build_args
+ (const struct htrdr_planets_accel_struct_build_args* args)
+{
+ if(!args) return RES_BAD_ARG;
+
+ /* Definition and number of threads cannot be null */
+ if(!args->definition_hint || !args->nthreads) return RES_BAD_ARG;
+
+ /* Invalid threshold */
+ if(args->optical_thickness < 0) return RES_BAD_ARG;
+
+ return RES_OK;
+}
+
static void
usage(void)
{
printf("usage: htrdr-planets [-dfhNv] [-a aerosol_opt[:aerosol_opt ...]]\n");
+ printf(" [-b accel_struct_build_opt[:accel_struct_build_opt ...]]\n");
printf(" [-C persp_camera_opt[:persp_camera_opt ...]]\n");
printf(" [-G ground_opt[:ground_opt ...]]\n");
- printf(" [-i image_opt[:image_opt ...]] [-O accel_struct_storage]\n");
- printf(" [-o output] [-r volrad_budget_opt[:volrad_budget_opt ...]]\n");
+ printf(" [-i image_opt[:image_opt ...]] [-o output]\n");
+ printf(" [-r volrad_budget_opt[:volrad_budget_opt ...]]\n");
printf(" [-S source_opt[:source_opt ...]]\n");
- printf(" [-s spectral_opt[:spectral_opt ...]] [-T optical_thickness]\n");
- printf(" [-t threads_count] [-V accel_struct_definition]\n");
+ printf(" [-s spectral_opt[:spectral_opt ...]] [-t threads_count]\n");
printf(" -g gas_opt[:gas_opt ...]\n");
}
@@ -590,6 +605,85 @@ error:
goto exit;
}
+static res_T
+parse_accel_struct_build_parameters(const char* str, void* ptr)
+{
+ enum { DEF, NTHREADS, PROC, STORAGE, OPTIC_THICKNESS} iparam;
+ char buf[BUFSIZ];
+ struct htrdr_planets_args* args = ptr;
+ char* key;
+ char* val;
+ char* tk_ctx;
+ res_T res = RES_OK;
+
+ ASSERT(str && ptr);
+
+ if(strlen(str) >= sizeof(buf) -1/*NULL char*/) {
+ fprintf(stderr,
+ "Could not duplicate the parameters of the acceleration structures `%s'",
+ str);
+ res = RES_MEM_ERR;
+ goto error;
+ }
+ strncpy(buf, str, sizeof(buf));
+
+ key = strtok_r(buf, "=", &tk_ctx);
+ val = strtok_r(NULL, "", &tk_ctx);
+
+ if(!strcmp(key, "def")) iparam = DEF;
+ else if(!strcmp(key, "nthreads")) iparam = NTHREADS;
+ else if(!strcmp(key, "proc")) iparam = PROC;
+ else if(!strcmp(key, "storage")) iparam = STORAGE;
+ else if(!strcmp(key, "tau")) iparam = OPTIC_THICKNESS;
+ else {
+ fprintf(stderr, "Invalid acceleration structure parameter `%s'\n", key);
+ res = RES_BAD_ARG;
+ goto error;
+ }
+
+ switch(iparam) {
+ case DEF:
+ res = cstr_to_uint(val, &args->accel_struct.definition_hint);
+ if(res == RES_OK && args->accel_struct.definition_hint == 0)
+ res = RES_BAD_ARG;
+ break;
+ case NTHREADS:
+ res = cstr_to_uint(val, &args->accel_struct.nthreads);
+ if(res == RES_OK && args->accel_struct.nthreads == 0) res = RES_BAD_ARG;
+ break;
+ case PROC:
+ if(!strcmp(val, "all")) {
+ args->accel_struct.master_only = 0;
+ } else if(!strcmp(val, "master")) {
+ args->accel_struct.master_only = 1;
+ } else {
+ res = RES_BAD_ARG;
+ }
+ break;
+ case STORAGE:
+ if(args->accel_struct.storage) mem_rm(args->accel_struct.storage);
+ if(!(args->accel_struct.storage = str_dup(val))) res = RES_MEM_ERR;
+ break;
+ case OPTIC_THICKNESS:
+ res = cstr_to_double(val, &args->accel_struct.optical_thickness);
+ if(res == RES_OK && args->accel_struct.optical_thickness < 0)
+ res = RES_BAD_ARG;
+ break;
+ default: FATAL("Unreachable code\n"); break;
+ }
+ if(res != RES_OK) {
+ fprintf(stderr,
+ "Unable to parse the acceleration structure parameter `%s' -- %s\n",
+ str, res_to_cstr(res));
+ goto error;
+ }
+
+exit:
+ return res;
+error:
+ goto exit;
+}
+
/*******************************************************************************
* Local functions
******************************************************************************/
@@ -602,7 +696,7 @@ htrdr_planets_args_init(struct htrdr_planets_args* args, int argc, char** argv)
*args = HTRDR_PLANETS_ARGS_DEFAULT;
- while((opt = getopt(argc, argv, "a:C:dfG:g:hi:NO:o:r:S:s:T:t:V:v")) != -1) {
+ while((opt = getopt(argc, argv, "a:b:C:dfG:g:hi:No:r:S:s:t:v")) != -1) {
switch(opt) {
case 'a':
(void)sa_add(args->aerosols, 1);
@@ -613,6 +707,9 @@ htrdr_planets_args_init(struct htrdr_planets_args* args, int argc, char** argv)
res = check_aerosol_args(args->aerosols+args->naerosols-1);
}
break;
+ case 'b':
+ res = cstr_parse_list(optarg, ':', parse_accel_struct_build_parameters, args);
+ break;
case 'C':
res = htrdr_args_camera_perspective_parse(&args->cam_persp, optarg);
args->output_type = HTRDR_PLANETS_ARGS_OUTPUT_IMAGE;
@@ -644,7 +741,6 @@ htrdr_planets_args_init(struct htrdr_planets_args* args, int argc, char** argv)
res = htrdr_args_image_parse(&args->image, optarg);
break;
case 'N': args->precompute_normals = 1; break;
- case 'O': args->octrees_storage = optarg; break;
case 'o': args->output = optarg; break;
case 'r':
res = cstr_parse_list(optarg, ':', parse_volrad_budget_parameters, args);
@@ -656,18 +752,10 @@ htrdr_planets_args_init(struct htrdr_planets_args* args, int argc, char** argv)
case 's':
res = cstr_parse_list(optarg, ':', parse_spectral_parameters, args);
break;
- case 'T':
- res = cstr_to_double(optarg, &args->optical_thickness);
- if(res == RES_OK && args->optical_thickness < 0) res = RES_BAD_ARG;
- break;
case 't':
res = cstr_to_uint(optarg, &args->nthreads);
if(res == RES_OK && !args->nthreads) res = RES_BAD_ARG;
break;
- case 'V':
- res = cstr_to_uint(optarg, &args->octree_definition_hint);
- if(res == RES_OK && !args->octree_definition_hint) res = RES_BAD_ARG;
- break;
case 'v': args->verbose = 1; break;
default: res = RES_BAD_ARG; break;
}
@@ -737,6 +825,7 @@ htrdr_planets_args_release(struct htrdr_planets_args* args)
if(args->ground.name) mem_rm(args->ground.name);
if(args->source.rnrl_filename) mem_rm(args->source.rnrl_filename);
if(args->volrad_budget.smsh_filename) mem_rm(args->volrad_budget.smsh_filename);
+ if(args->accel_struct.storage) mem_rm(args->accel_struct.storage);
FOR_EACH(i, 0, args->naerosols) {
struct rnatm_aerosol_args* aerosol = args->aerosols + i;
@@ -770,9 +859,8 @@ htrdr_planets_args_check(const struct htrdr_planets_args* args)
}
/* Check the octree parameters */
- if(args->octree_definition_hint == 0
- || args->optical_thickness < 0)
- return RES_BAD_ARG;
+ res = check_accel_struct_build_args(&args->accel_struct);
+ if(res != RES_OK) return res;
/* Check the spectral domain */
res = check_spectral_args(&args->spectral_domain);
diff --git a/src/planets/htrdr_planets_args.h.in b/src/planets/htrdr_planets_args.h.in
@@ -82,6 +82,25 @@ static const struct htrdr_planets_volrad_budget_args
HTRDR_PLANETS_VOLRAD_BUDGET_ARGS_NULL =
HTRDR_PLANETS_VOLRAD_BUDGET_ARGS_NULL__;
+/* Configure the building of the acceleration structure */
+struct htrdr_planets_accel_struct_build_args {
+ unsigned definition_hint; /* Hint on octree definition */
+ unsigned nthreads; /* Hint on the number of threads to use */
+ double optical_thickness; /* Threshold used during octree building */
+
+ /* Read/Write file where octrees are stored. May be NULL => octres are built
+ * at runtime and kept in memory */
+ char* storage;
+
+ /* Indicator defining whether the structure is built solely on the
+ * master process */
+ int master_only;
+};
+#define HTRDR_PLANETS_ACCEL_STRUCT_BUILD_ARGS_NULL__ { 512, 8, 1, NULL, 1 }
+static const struct htrdr_planets_accel_struct_build_args
+HTRDR_PLANETS_ACCEL_STRUCT_BUILD_ARGS_NULL =
+ HTRDR_PLANETS_ACCEL_STRUCT_BUILD_ARGS_NULL__;
+
struct htrdr_planets_args {
/* System data */
struct rnatm_gas_args gas;
@@ -89,12 +108,8 @@ struct htrdr_planets_args {
size_t naerosols;
struct htrdr_planets_ground_args ground;
- /* Read/Write file where octrees are stored. May be NULL => octres are built
- * at runtime and kept in memory */
- char* octrees_storage;
-
- unsigned octree_definition_hint; /* Hint on octree definition */
- double optical_thickness; /* Threshold used during octree building */
+ /* Configure the building of the acceleration structure */
+ struct htrdr_planets_accel_struct_build_args accel_struct;
char* output; /* File where the result is written */
struct htrdr_planets_spectral_args spectral_domain; /* Integration spectral domain */
@@ -107,7 +122,7 @@ struct htrdr_planets_args {
struct htrdr_planets_volrad_budget_args volrad_budget;
/* Miscellaneous arguments */
- unsigned nthreads; /* Hint on the nimber of threads to use */
+ unsigned nthreads; /* Hint on the number of threads to use */
enum htrdr_planets_args_output_type output_type;
int precompute_normals; /* Pre-compute tetrahedron normals */
int force_output_overwrite; /* Replace output if it exists */
@@ -120,10 +135,7 @@ struct htrdr_planets_args {
0, /* Number of aerosols */ \
HTRDR_PLANETS_GROUND_ARGS_NULL__, /* Ground */ \
\
- NULL, /* File where to dump octrees */ \
- \
- @HTRDR_PLANETS_ARGS_DEFAULT_GRID_DEFINITION_HINT@, /* octree definition */ \
- @HTRDR_PLANETS_ARGS_DEFAULT_OPTICAL_THICKNESS_THRESHOLD@, \
+ HTRDR_PLANETS_ACCEL_STRUCT_BUILD_ARGS_NULL__, \
\
NULL, /* Ouput file */ \
HTRDR_PLANETS_SPECTRAL_ARGS_DEFAULT__, /* Spectral domain */ \
diff --git a/src/planets/htrdr_planets_source.c b/src/planets/htrdr_planets_source.c
@@ -433,7 +433,7 @@ htrdr_planets_source_get_spectrum
if(low == upp) {
/* The range is fully included in a band */
- ASSERT(low->radiance > range[0] && upp->radiance >= range[1]);
+ ASSERT(low->wavelength > range[0] && upp->wavelength >= range[1]);
source_spectrum->size = 2;
source_spectrum->buffer = NULL;