htrdr

Solving radiative transfer in heterogeneous media
git clone git://git.meso-star.fr/htrdr.git
Log | Files | Refs | README | LICENSE

commit fa47a43c7be2eb5b9a183b8325485e47a09e9807
parent 7f12e284a09db782df8ef36a4ffeeb11e53df8c8
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Thu,  2 Oct 2025 16:21:44 +0200

Merge branch 'release_0.12'

Diffstat:
M.gitignore | 4++++
MMakefile | 639+++++--------------------------------------------------------------------------
AMakefile.atmosphere | 167+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
AMakefile.combustion | 201+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
AMakefile.core | 162+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
AMakefile.planets | 197+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
MREADME.md | 65+++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------
Mconfig.mk | 46+++++++++++++++++++++++++++-------------------
Mdoc/htrdr-atmosphere.1.in | 46++++++++++++++++++++++++++++++++++++++--------
Mdoc/htrdr-combustion.1.in | 16++++++++--------
Mdoc/htrdr-image.5 | 16++++++++--------
Mdoc/htrdr-materials.5 | 16++++++++--------
Mdoc/htrdr-obj.5 | 16++++++++--------
Mdoc/htrdr-planets.1.in | 324++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------------
Mdoc/htrdr.1 | 16++++++++--------
Mdoc/rnrl.5 | 16++++++++--------
Mhtrdr-planets.pc.in | 1+
Minstall.sh | 16++++++++--------
Msrc/atmosphere/htrdr_atmosphere.c | 44++++++++++++++++++++++++++++++++------------
Msrc/atmosphere/htrdr_atmosphere.h | 16++++++++--------
Msrc/atmosphere/htrdr_atmosphere_args.c | 16++++++++--------
Msrc/atmosphere/htrdr_atmosphere_args.h.in | 12++++++------
Msrc/atmosphere/htrdr_atmosphere_c.h | 16++++++++--------
Msrc/atmosphere/htrdr_atmosphere_compute_radiance_lw.c | 16++++++++--------
Msrc/atmosphere/htrdr_atmosphere_compute_radiance_sw.c | 16++++++++--------
Msrc/atmosphere/htrdr_atmosphere_draw_map.c | 17++++++++---------
Msrc/atmosphere/htrdr_atmosphere_ground.c | 16++++++++--------
Msrc/atmosphere/htrdr_atmosphere_ground.h | 16++++++++--------
Msrc/atmosphere/htrdr_atmosphere_main.c | 16++++++++--------
Msrc/atmosphere/htrdr_atmosphere_sun.c | 16++++++++--------
Msrc/atmosphere/htrdr_atmosphere_sun.h | 16++++++++--------
Msrc/combustion/htrdr_combustion.c | 16++++++++--------
Msrc/combustion/htrdr_combustion.h | 16++++++++--------
Msrc/combustion/htrdr_combustion_args.c | 16++++++++--------
Msrc/combustion/htrdr_combustion_args.h.in | 12++++++------
Msrc/combustion/htrdr_combustion_c.h | 16++++++++--------
Msrc/combustion/htrdr_combustion_compute_radiance_sw.c | 16++++++++--------
Msrc/combustion/htrdr_combustion_draw_map.c | 16++++++++--------
Msrc/combustion/htrdr_combustion_geometry_ray_filter.c | 16++++++++--------
Msrc/combustion/htrdr_combustion_geometry_ray_filter.h | 16++++++++--------
Msrc/combustion/htrdr_combustion_laser.c | 16++++++++--------
Msrc/combustion/htrdr_combustion_laser.h | 16++++++++--------
Msrc/combustion/htrdr_combustion_main.c | 16++++++++--------
Msrc/combustion/htrdr_combustion_phase_func.c | 16++++++++--------
Msrc/combustion/test_htrdr_combustion_laser.c | 16++++++++--------
Msrc/commands/htrdr_atmosphere_cmd.c | 29+++++++++--------------------
Dsrc/commands/htrdr_cmd.c | 126-------------------------------------------------------------------------------
Msrc/commands/htrdr_combustion_cmd.c | 29+++++++++--------------------
Msrc/commands/htrdr_planets_cmd.c | 29+++++++++--------------------
Msrc/core/htrdr.c | 22+++++++++++++---------
Msrc/core/htrdr.h | 28++++++++++++++--------------
Msrc/core/htrdr_accum.h | 16++++++++--------
Msrc/core/htrdr_args.c | 28++++++++++++++++++++--------
Msrc/core/htrdr_args.h.in | 16++++++++++------
Msrc/core/htrdr_buffer.c | 19+++++++++----------
Msrc/core/htrdr_buffer.h | 47++++++++++++++++++++++++++++++++---------------
Msrc/core/htrdr_c.h | 22+++++++++++++---------
Msrc/core/htrdr_draw_map.c | 312++++++++++++++-----------------------------------------------------------------
Msrc/core/htrdr_draw_map.h | 16++++++++--------
Msrc/core/htrdr_geometry.c | 16++++++++--------
Msrc/core/htrdr_geometry.h | 16++++++++--------
Msrc/core/htrdr_interface.h | 16++++++++--------
Msrc/core/htrdr_log.c | 75+++++++++++++++++++++++++++++++++++++++------------------------------------
Msrc/core/htrdr_log.h | 16++++++++--------
Msrc/core/htrdr_materials.c | 16++++++++--------
Msrc/core/htrdr_materials.h | 16++++++++--------
Asrc/core/htrdr_proc_work.c | 267+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Asrc/core/htrdr_proc_work.h | 94+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/core/htrdr_ran_wlen_cie_xyz.c | 16++++++++--------
Msrc/core/htrdr_ran_wlen_cie_xyz.h | 16++++++++--------
Msrc/core/htrdr_ran_wlen_discrete.c | 99+++++++++++++++++++++++++++++++++++++++++++++----------------------------------
Msrc/core/htrdr_ran_wlen_discrete.h | 16++++++++--------
Msrc/core/htrdr_ran_wlen_planck.c | 16++++++++--------
Msrc/core/htrdr_ran_wlen_planck.h | 16++++++++--------
Msrc/core/htrdr_rectangle.c | 16++++++++--------
Msrc/core/htrdr_rectangle.h | 16++++++++--------
Msrc/core/htrdr_sensor.h | 16++++++++--------
Msrc/core/htrdr_slab.c | 16++++++++--------
Msrc/core/htrdr_slab.h | 16++++++++--------
Asrc/core/htrdr_solve_buffer.c | 593+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Asrc/core/htrdr_solve_buffer.h | 72++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/core/htrdr_spectral.c | 16++++++++--------
Msrc/core/htrdr_spectral.h | 16++++++++--------
Msrc/core/htrdr_version.h.in | 12++++++------
Asrc/htrdr.in | 48++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/planets/htrdr_planets.c | 326+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------
Msrc/planets/htrdr_planets.h | 16++++++++--------
Msrc/planets/htrdr_planets_args.c | 262++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------
Msrc/planets/htrdr_planets_args.h.in | 67++++++++++++++++++++++++++++++++++++++++++++++++++-----------------
Msrc/planets/htrdr_planets_c.h | 70++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------
Msrc/planets/htrdr_planets_compute_radiance.c | 43+++++++++++++++++++++++++++++++------------
Msrc/planets/htrdr_planets_draw_map.c | 28+++++++++++++++++-----------
Msrc/planets/htrdr_planets_main.c | 16++++++++--------
Asrc/planets/htrdr_planets_solve_volrad_budget.c | 449+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/planets/htrdr_planets_source.c | 18+++++++++---------
Msrc/planets/htrdr_planets_source.h | 16++++++++--------
Msrc/planets/test_htrdr_planets_source.c | 64+++++++++++++++++++++++++++++++++++++++++++++++++++++++---------
97 files changed, 4165 insertions(+), 1914 deletions(-)

diff --git a/.gitignore b/.gitignore @@ -1,6 +1,7 @@ *~ *.[aod] [Bb]uild* +*.bin .config* .gitignore htrdr @@ -12,7 +13,10 @@ htrdr-combustion.1 htrdr-planets htrdr-planets.1 htrdr_version.h +*.obj *.pc *.so *.sw[po] tags +test_* +!test_*.[ch] diff --git a/Makefile b/Makefile @@ -1,12 +1,12 @@ -# Copyright (C) 2018-2019, 2022-2024 Centre National de la Recherche Scientifique +# 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-2024 Institut Pierre-Simon Laplace -# Copyright (C) 2022-2024 Institut de Physique du Globe de Paris -# Copyright (C) 2018-2024 |Méso|Star> (contact@meso-star.com) -# Copyright (C) 2022-2024 Observatoire de Paris -# Copyright (C) 2022-2024 Université de Reims Champagne-Ardenne -# Copyright (C) 2022-2024 Université de Versaille Saint-Quentin -# Copyright (C) 2018-2019, 2022-2024 Université Paul Sabatier +# 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 @@ -26,621 +26,54 @@ 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_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_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_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' \ - $@.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' \ - $@.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: + @$(MAKE) -fMakefile.core $@ + @if [ "$(ATMOSPHERE)" = "ENABLE" ]; then $(MAKE) -fMakefile.atmosphere $@; fi + @if [ "$(COMBUSTION)" = "ENABLE" ]; then $(MAKE) -fMakefile.combustion $@; fi + @if [ "$(PLANETS)" = ENABLE ]; then $(MAKE) -fMakefile.planets $@; fi + +test: + @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 config.mk + 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 -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,167 @@ +# 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) + +# Use CFLAGS_EXE because the object files will be linked as executables +CFLAGS_LIB = $(CFLAGS_EXE) $(ATMOSPHERE_INCS) -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-atmosphere) +LDFLAGS_CMD = $(LDFLAGS_EXE) $$($(PKG_CONFIG_LOCAL) --static --libs htrdr-atmosphere) + +command: library $(CMD_DEP) + @$(MAKE) -fMakefile.atmosphere -f$(CMD_DEP) htrdr-atmosphere + +htrdr-atmosphere: $(CMD_OBJ) $(LIBNAME) $(CORE_NAME) + $(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,201 @@ +# 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 tests + +################################################################################ +# 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) + +# Use CFLAGS_EXE because the object files will be linked as executables +CFLAGS_LIB = $(CFLAGS_EXE) $(COMBUSTION_INCS) -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-combustion) +LDFLAGS_CMD = $(LDFLAGS_EXE) $$($(PKG_CONFIG_LOCAL) --static --libs htrdr-combustion) + +command: library $(CMD_DEP) + @$(MAKE) -fMakefile.combustion -f$(CMD_DEP) htrdr-combustion + +htrdr-combustion: $(CMD_OBJ) $(LIBNAME) $(CORE_NAME) + $(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 $@ + +################################################################################ +# Build the test +################################################################################ +TEST_SRC = src/combustion/test_htrdr_combustion_laser.c +TEST_OBJ = $(TEST_SRC:.c=.o) +TEST_DEP = $(TEST_SRC:.c=.d) + +CFLAGS_TEST = $(CFLAGS_EXE) $(COMBUSTION_INCS) +LDFLAGS_TEST = $(LDFLAGS_EXE) $(COMBUSTION_LIBS) + +test: tests + ./test_htrdr_combustion_laser > /dev/null 2>&1 + +tests: library $(TEST_DEP) + @$(MAKE) -fMakefile.combustion -f$(TEST_DEP) test_htrdr_combustion_laser + +# Link with all obj files in the combustion library since the test checks +# hidden functions +test_htrdr_combustion_laser: $(TEST_OBJ) $(CORE_NAME) + $(CC) $(CFLAGS_TEST) -o $@ $(TEST_OBJ) $(OBJ) $(LDFLAGS_TEST) + +$(TEST_DEP): + @$(CC) $(CFLAGS_TEST) -MM -MT "$(@:.d=.o) $@" $(@:.d=.c) -MF $@ + +$(TEST_OBJ): + $(CC) $(CFLAGS_TEST) -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 + rm -f test_htrdr_combustion_laser laser.obj + +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,162 @@ +# 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 = $(CORE_NAME_STATIC) +LIBNAME_SHARED = $(CORE_NAME_SHARED) +LIBNAME = $(CORE_NAME) + +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) + +# Use CFLAGS_EXE when the library is built as a static library because +# the object files will be linked as executables. +CFLAGS_STATIC = $(CFLAGS_EXE) +CFLAGS_SHARED = $(CFLAGS_SO) + +CFLAGS_CORE = $(CFLAGS_$(LIB_TYPE)) -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_SHARED) $(LIBNAME_STATIC) $(OBJ) $(DEP) + rm -f libhtrdr-core.o .config_core htrdr-core.pc + rm -f src/core/htrdr_args.h src/core/htrdr_version.h + +lint: # no lint diff --git a/Makefile.planets b/Makefile.planets @@ -0,0 +1,197 @@ +# 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 tests + +################################################################################ +# 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) + +# Use CFLAGS_EXE because the object files will be linked as executables +CFLAGS_LIB = $(CFLAGS_EXE) $(PLANETS_INCS) -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 $(SMSH_VERSION) smsh + $(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-planets) +LDFLAGS_CMD = $(LDFLAGS_EXE) $$($(PKG_CONFIG_LOCAL) --static --libs htrdr-planets) + +command: library $(CMD_DEP) + @$(MAKE) -fMakefile.planets -f$(CMD_DEP) htrdr-planets + +htrdr-planets: $(CMD_OBJ) $(LIBNAME) $(CORE_NAME) + $(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 $@ + +################################################################################ +# Tests +################################################################################ +TEST_SRC = src/planets/test_htrdr_planets_source.c +TEST_OBJ = $(TEST_SRC:.c=.o) +TEST_DEP = $(TEST_SRC:.c=.d) + +CFLAGS_TEST = $(CFLAGS_EXE) $(PLANETS_INCS) +LDFLAGS_TEST = $(LDFLAGS_EXE) $(PLANETS_LIBS) + +test: tests + ./test_htrdr_planets_source > /dev/null 2>&1 + +tests: library $(TEST_DEP) + @$(MAKE) -fMakefile.planets -f$(TEST_DEP) test_htrdr_planets_source + +# Link with all obj files in the planet library since the test checks +# hidden functions +test_htrdr_planets_source: $(TEST_OBJ) $(CORE_NAME) + $(CC) $(CFLAGS_TEST) -o $@ $(TEST_OBJ) $(OBJ) $(LDFLAGS_TEST) + +$(TEST_DEP): + @$(CC) $(CFLAGS_TEST) -MM -MT "$(@:.d=.o) $@" $(@:.d=.c) -MF $@ + +$(TEST_OBJ): + $(CC) $(CFLAGS_TEST) -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/@SMSH_VERSION@/$(SMSH_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 + rm -f test_htrdr_planets_source rnrl.bin + +lint: doc/htrdr-planets.1 + mandoc -Tlint -Wall doc/htrdr-planets.1 || [ $$? -le 1 ] diff --git a/README.md b/README.md @@ -83,6 +83,8 @@ that calculate the radiance are used for computing various quantities: - [Star Buffer](https://gitlab.com/meso-star/star-buffer) (optional; required by PLANETS) - [Star Camera](https://gitlab.com/meso-star/star-camera) +- [Star Mesh](https://gitlab.com/meso-star/star-mesh) + (optional; required by PLANETS) - [Star Scattering Functions](https://gitlab.com/meso-star/star-sf) - [Star SamPling](https://gitlab.com/meso-star/star-sp) - [Star VoXel](https://gitlab.com/meso-star/star-vx) @@ -95,6 +97,53 @@ Edit config.mk as needed, then run: ## Release notes +### Version 0.12 + +#### Volumic Radiative Budget + +Add support for volumic radiative budget calculations to +`htrdr-planets`. Its new `-r` option allows listing the tetrahedra for +which the volumic radiative budget is estimated and the number of +realizations to be used per tetrahedron. + +Note that, with the exception of the separate treatment of direct and +diffuse components, no specific sampling strategy has been developed to +manage the spectro-spatio-directional heterogeneity of the integration +to be performed. It is the same Monte Carlo algorithm as the one used +for rendering. The variance of the volumic budget can therefore be high, +and may therefore require a large number of realizations per tetrahedron +to ensure the validity of its estimation. + +#### Work distribution + +- Addition of a new distribution policy that does not distribute the + rendering of an image but a generic calculation: the workload is a 1D + set of computations partitioned into pieces distributed to the + processes. It was developed to parallelize the calculation of the + volumetric radiative budget added by this version to the + `htrdr-planets` command. +- Adjustment of the "work stealing" policy: steal more frequently and + steal more work. The additional costs are negligible and this improves + the balance of work when distributing to (very) heterogeneous + computers. +- Fix load balancing issues. Depending on the image resolution, the + workload could be poorly distributed among processes. More + importantly, a deadlock could occur. + +#### Miscellaneous + +- Use Star-Sampling 0.15 to avoid using too much temporary space, which + could lead to disk space shortages on some systems. In return, + increase memory usage per thread by approximately 4 MB. +- Compile the missing tests in planets and combustion: they do not + appear to have been compiled since version 0.10. +- Rewrite the Makefile: divide it into sub-makefiles, one for each + command, and an additional one for the base library. This makes the + build system easier to read and manage. +- Fix the bug when the number of discrete wavelengths to be taken into + account is equal to 1. +- `htrdr-planets`: make the source optional in long wave computations. + ### Version 0.11 - Renamed `planeto` sub-command to `planets`. @@ -383,15 +432,15 @@ CIE XYZ (i.e. regular image rendering), longwave or shortwave. ## Copyright notice -Copyright © 2018-2019, 2022-2024 Centre National de la Recherche Scientifique +Copyright © 2018-2019, 2022-2025 Centre National de la Recherche Scientifique Copyright © 2020-2022 Institut Mines Télécom Albi-Carmaux -Copyright © 2022-2024 Institut Pierre-Simon Laplace -Copyright © 2022-2024 Institut de Physique du Globe de Paris -Copyright © 2018-2024 [|Méso|Star>](http://www.meso-star.com) (contact@meso-star.com) -Copyright © 2022-2024 Observatoire de Paris -Copyright © 2022-2024 Université de Reims Champagne-Ardenne -Copyright © 2022-2024 Université de Versaille Saint-Quentin -Copyright © 2018-2019, 2022-2024 Université Paul Sabatier +Copyright © 2022-2025 Institut Pierre-Simon Laplace +Copyright © 2022-2025 Institut de Physique du Globe de Paris +Copyright © 2018-2025 [|Méso|Star>](http://www.meso-star.com) (contact@meso-star.com) +Copyright © 2022-2025 Observatoire de Paris +Copyright © 2022-2025 Université de Reims Champagne-Ardenne +Copyright © 2022-2025 Université de Versaille Saint-Quentin +Copyright © 2018-2019, 2022-2025 Université Paul Sabatier ## License diff --git a/config.mk b/config.mk @@ -1,5 +1,5 @@ VERSION_MAJOR = 0 -VERSION_MINOR = 11 +VERSION_MINOR = 12 VERSION_PATCH = 0 VERSION = $(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_PATCH) @@ -63,6 +63,7 @@ HTRDR_COMBUSTION_ARGS_DEFAULT_WAVELENGTH = 532 # Planets HTRDR_PLANETS_ARGS_DEFAULT_OPTICAL_THICKNESS_THRESHOLD = 1 HTRDR_PLANETS_ARGS_DEFAULT_GRID_DEFINITION_HINT = 512 +HTRDR_PLANETS_ARGS_DEFAULT_VOLRAD_BUDGET_SPT = 1000 ################################################################################ # Tools @@ -72,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 ################################################################################ @@ -93,34 +95,40 @@ S3D_VERSION = 0.10 SBUF_VERSION = 0.1 SCAM_VERSION = 0.2 SSF_VERSION = 0.9 +SMSH_VERSION = 0.1 SSP_VERSION = 0.14 SVX_VERSION = 0.3 # Atmosphere -ATMOSPHERE_DPDC_CFLAGS =\ - $$($(PKG_CONFIG) $(PCFLAGS) --cflags htsky rsys s3d scam ssf star-sp svx) -ATMOSPHERE_DPDC_LIBS =\ - $$($(PKG_CONFIG) $(PCFLAGS) --libs htsky rsys s3d scam ssf star-sp svx) -lm +ATMOSPHERE_INCS = $$($(PKG_CONFIG_LOCAL) $(PCFLAGS) --cflags\ + htrdr-core htsky rsys s3d scam ssf star-sp svx) +ATMOSPHERE_LIBS = $$($(PKG_CONFIG_LOCAL) $(PCFLAGS) --libs\ + htrdr-core htsky rsys s3d scam ssf star-sp svx) -lm # Combustion -COMBUSTION_DPDC_CFLAGS =\ - $$($(PKG_CONFIG) $(PCFLAGS) --cflags atrstm rsys s3d scam ssf star-sp svx) -COMBUSTION_DPDC_LIBS =\ - $$($(PKG_CONFIG) $(PCFLAGS) --libs atrstm rsys s3d scam ssf star-sp svx) -lm +COMBUSTION_INCS = $$($(PKG_CONFIG_LOCAL) $(PCFLAGS) --cflags\ + atrstm htrdr-core rsys s3d scam ssf star-sp svx) +COMBUSTION_LIBS = $$($(PKG_CONFIG_LOCAL) $(PCFLAGS) --libs\ + atrstm htrdr-core rsys s3d scam ssf star-sp svx) -lm # Core -CORE_DPDC_CFLAGS =\ - $$($(PKG_CONFIG) $(PCFLAGS) --cflags aw $(MPI_PC) mrumtl rsys s3d scam ssf star-sp)\ - -fopenmp -CORE_DPDC_LIBS =\ - $$($(PKG_CONFIG) $(PCFLAGS) --libs aw $(MPI_PC) mrumtl rsys s3d scam ssf star-sp)\ - -fopenmp -lm +CORE_INCS = $$($(PKG_CONFIG_LOCAL) $(PCFLAGS) --cflags\ + aw $(MPI_PC) mrumtl rsys s3d scam ssf star-sp) -fopenmp +CORE_LIBS = $$($(PKG_CONFIG_LOCAL) $(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_LOCAL) $(PCFLAGS) --cflags\ + $(MPI_PC) htrdr-core rnatm rngrd rsys s3d sbuf scam smsh ssf star-sp svx) +PLANETS_LIBS = $$($(PKG_CONFIG_LOCAL) $(PCFLAGS) --libs\ + $(MPI_PC) htrdr-core rnatm rngrd rsys s3d sbuf scam smsh ssf star-sp svx) -lm + +################################################################################ +# Name of the core library +################################################################################ +CORE_NAME_STATIC = libhtrdr-core.a +CORE_NAME_SHARED = libhtrdr-core.so +CORE_NAME = $(CORE_NAME_$(LIB_TYPE)) ################################################################################ # Compilation options diff --git a/doc/htrdr-atmosphere.1.in b/doc/htrdr-atmosphere.1.in @@ -1,12 +1,12 @@ -.\" Copyright (C) 2018-2019, 2022-2024 Centre National de la Recherche Scientifique +.\" 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-2024 Institut Pierre-Simon Laplace -.\" Copyright (C) 2022-2024 Institut de Physique du Globe de Paris -.\" Copyright (C) 2018-2024 |Méso|Star> (contact@meso-star.com) -.\" Copyright (C) 2022-2024 Observatoire de Paris -.\" Copyright (C) 2022-2024 Université de Reims Champagne-Ardenne -.\" Copyright (C) 2022-2024 Université de Versaille Saint-Quentin -.\" Copyright (C) 2018-2019, 2022-2024 Université Paul Sabatier +.\" 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 @@ -23,9 +23,15 @@ .Dd January 24, 2024 .Dt HTRDR-ATMOSPHERE 1 .Os +.\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +.\" Name and Short description +.\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" .Sh NAME .Nm htrdr-atmosphere .Nd simulate radiative transfer in cloudy atmospheres +.\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +.\" Summary of options +.\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" .Sh SYNOPSIS .Nm .Op Fl dfhRrv @@ -46,6 +52,9 @@ .Op Fl t Ar threads_count .Op Fl V Ar x , Ns Ar y , Ns Ar z .Fl a Pa atmosphere +.\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +.\" Detailed description +.\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" .Sh DESCRIPTION .Nm simulates radiative transfer in scenes composed of an atmospheric gas @@ -421,6 +430,9 @@ Make .Nm verbose. .El +.\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +.\" Output image +.\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" .Sh OUTPUT IMAGE Images calculated by .Nm @@ -429,6 +441,7 @@ are saved in format. This section describes the nature and arrangement of image data depending on the type of calculation performed. +.\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" .Ss XYZ image For an image rendering in the visible part of the spectrum .Pq default behavior or option Fl s Cm cie_xyz , @@ -441,6 +454,7 @@ average radiance of the pixel. The second value is its associated standard deviation. The fourth and final pair records the microsecond estimate of the computation time per radiative path and its standard error. +.\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" .Ss Longwave image For infrared calculations .Pq option Fl s Cm lw= Ns Ar wlen_min , Ns Ar wlen_max @@ -456,6 +470,7 @@ The fifth and sixth pixel components are not used. Finally, the last 2 components of the pixel record the estimate in microseconds of the computation time per radiative path and its standard error. +.\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" .Ss Shortwave image For shortwave calculations .Pq option Fl s Cm sw= Ns Ar wlen_min , Ns Ar wlen_max @@ -474,8 +489,14 @@ components that store the estimate of the radiative path computation time .Pq in microseconds and its standard error. +.\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +.\" Returned status +.\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" .Sh EXIT STATUS .Ex -std +.\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +.\" Examples of use +.\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" .Sh EXAMPLES Render a clear sky scene, i.e. a scene without any cloud, whose sun is at zenith. @@ -623,6 +644,9 @@ N="$(grep -ce "^# vtk" output)" sed /^---$/d output \\ | csplit -f octree -k - %^#\\ vtk% /^#\\ vtk/ {$((${N}-2))} .Ed +.\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +.\" References +.\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" .Sh SEE ALSO .Xr mpirun 1 , .Xr htcp 5 , @@ -654,6 +678,9 @@ Highly Resolved Cloudy Atmospheres .%D 2019 .%U https://dx.doi.org/10.1029/2018MS001602 .Re +.\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +.\" Used and implemented standards +.\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" .Sh STANDARDS .Rs .%A International Organization for Standardization / CIE @@ -674,6 +701,9 @@ Highly Resolved Cloudy Atmospheres .%D July 1997 .%T MPI-2: Extensions to The Message-Passing Interface .Re +.\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +.\" Brief implementation history +.\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" .Sh HISTORY .Nm has been initially developed as part of diff --git a/doc/htrdr-combustion.1.in b/doc/htrdr-combustion.1.in @@ -1,12 +1,12 @@ -.\" Copyright (C) 2018-2019, 2022-2024 Centre National de la Recherche Scientifique +.\" 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-2024 Institut Pierre-Simon Laplace -.\" Copyright (C) 2022-2024 Institut de Physique du Globe de Paris -.\" Copyright (C) 2018-2024 |Méso|Star> (contact@meso-star.com) -.\" Copyright (C) 2022-2024 Observatoire de Paris -.\" Copyright (C) 2022-2024 Université de Reims Champagne-Ardenne -.\" Copyright (C) 2022-2024 Université de Versaille Saint-Quentin -.\" Copyright (C) 2018-2019, 2022-2024 Université Paul Sabatier +.\" 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 diff --git a/doc/htrdr-image.5 b/doc/htrdr-image.5 @@ -1,12 +1,12 @@ -.\" Copyright (C) 2018-2019, 2022-2024 Centre National de la Recherche Scientifique +.\" 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-2024 Institut Pierre-Simon Laplace -.\" Copyright (C) 2022-2024 Institut de Physique du Globe de Paris -.\" Copyright (C) 2018-2024 |Méso|Star> (contact@meso-star.com) -.\" Copyright (C) 2022-2024 Observatoire de Paris -.\" Copyright (C) 2022-2024 Université de Reims Champagne-Ardenne -.\" Copyright (C) 2022-2024 Université de Versaille Saint-Quentin -.\" Copyright (C) 2018-2019, 2022-2024 Université Paul Sabatier +.\" 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 diff --git a/doc/htrdr-materials.5 b/doc/htrdr-materials.5 @@ -1,12 +1,12 @@ -.\" Copyright (C) 2018-2019, 2022-2024 Centre National de la Recherche Scientifique +.\" 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-2024 Institut Pierre-Simon Laplace -.\" Copyright (C) 2022-2024 Institut de Physique du Globe de Paris -.\" Copyright (C) 2018-2024 |Méso|Star> (contact@meso-star.com) -.\" Copyright (C) 2022-2024 Observatoire de Paris -.\" Copyright (C) 2022-2024 Université de Reims Champagne-Ardenne -.\" Copyright (C) 2022-2024 Université de Versaille Saint-Quentin -.\" Copyright (C) 2018-2019, 2022-2024 Université Paul Sabatier +.\" 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 diff --git a/doc/htrdr-obj.5 b/doc/htrdr-obj.5 @@ -1,12 +1,12 @@ -.\" Copyright (C) 2018-2019, 2022-2024 Centre National de la Recherche Scientifique +.\" 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-2024 Institut Pierre-Simon Laplace -.\" Copyright (C) 2022-2024 Institut de Physique du Globe de Paris -.\" Copyright (C) 2018-2024 |Méso|Star> (contact@meso-star.com) -.\" Copyright (C) 2022-2024 Observatoire de Paris -.\" Copyright (C) 2022-2024 Université de Reims Champagne-Ardenne -.\" Copyright (C) 2022-2024 Université de Versaille Saint-Quentin -.\" Copyright (C) 2018-2019, 2022-2024 Université Paul Sabatier +.\" 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 diff --git a/doc/htrdr-planets.1.in b/doc/htrdr-planets.1.in @@ -1,12 +1,12 @@ -.\" Copyright (C) 2018-2019, 2022-2024 Centre National de la Recherche Scientifique +.\" 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-2024 Institut Pierre-Simon Laplace -.\" Copyright (C) 2022-2024 Institut de Physique du Globe de Paris -.\" Copyright (C) 2018-2024 |Méso|Star> (contact@meso-star.com) -.\" Copyright (C) 2022-2024 Observatoire de Paris -.\" Copyright (C) 2022-2024 Université de Reims Champagne-Ardenne -.\" Copyright (C) 2022-2024 Université de Versaille Saint-Quentin -.\" Copyright (C) 2018-2019, 2022-2024 Université Paul Sabatier +.\" 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 @@ -20,34 +20,44 @@ .\" .\" 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 November 6, 2024 +.Dd October 2, 2025 .Dt HTRDR-PLANETS 1 .Os +.\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +.\" Name and Short description +.\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" .Sh NAME .Nm htrdr-planets .Nd simulate radiative transfer in 3D planetary atmosphere +.\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +.\" Summary of options +.\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" .Sh SYNOPSIS .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 Pa accel_struct_storage -.Op Fl o Pa output +.Op Fl o Ar output +.Op Fl P Ar ortho_camera_opt Ns Op : Ns Ar ortho_camera_opt No ... +.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 +.Op Fl t Ar thread_count .Fl g Ar gas_opt Ns Op : Ns Ar gas_opt No ... +.\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +.\" Detailed description +.\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" .Sh DESCRIPTION .Nm simulates the radiative transfer of a terrestrial planet in the visible or the infrared part of the spectrum. The planet's ground .Pq option Fl G -can be any set of triangles with BRDFs and temperatures defined per triangle. +can be any set of triangles with BRDFs and temperatures defined per +triangle. The atmosphere is composed of a gas mixture .Pq option Fl g and a potentially empty set of aerosols @@ -61,21 +71,30 @@ Aerosol phase functions are also defined per node. .Pp .Nm -is mainly a renderer that calculates an image +is a renderer that calculates an image .Pq option Fl i for a given observation position .Pq option Fl C . -Its internal rendering algorithm is based on Monte Carlo integration, -which consists for each pixel of simulating a given number of optical -paths from the sensor, taking into account the phenomena of light -absorption and scattering. +In addition to rendering images, it can also be used to estimate the +volumic radiative budget for a set of tetrehedra +.Pq option Fl r . +Its algorithms are based on Monte Carlo integration, which involves +simulating a given number of optical paths for each estimate, taking +into account light absorption and scattering phenomena. +Thanks to the Monte Carlo, +.Nm +calculates not only the quantities of interest, but also their +uncertainty +.Pq standard deviation of the distribution of weights +at no extra cost. .Pp .Nm offers three ways to perform spectral integration .Pq option Fl s . -By default, it calculates an image for the visible part of the spectrum between -380 and 780 nanometers, for the three components of the CIE 1931 XYZ color space -which are then recombined to obtain the final color for each pixel. +By default, it calculates an image for the visible part of the spectrum +between 380 and 780 nanometers, for the three components of the CIE 1931 +XYZ color space which are then recombined to obtain the final color for +each pixel. The other two methods are to explicitly define the longwave or shortwave spectral range to be integrated and continuously sample a wavelength in this range. @@ -92,6 +111,7 @@ expressed in Kelvin. The estimated radiances are given in W/sr/m^2, except for monochromatic calculations where the calculated spectral radiance is defined in W/sr/m^2/nm. +Finally, the estimated volumic radiative budgets is given in W/m^3. .Pp .Nm implements mixed parallelism. @@ -114,13 +134,13 @@ necessary. .Pp The aerosol options are as follows: .Bl -tag -width Ds -.It Cm mesh= Ns Pa volumetric_mesh +.It Cm mesh= Ns Ar volume_mesh Aerosol tetrahedral mesh saved in .Xr smsh 5 format. .It Cm name= Ns Ar string Name assigned to the aerosol. -.It Cm radprop= Ns Pa radiative_properties +.It Cm radprop= Ns Ar radiative_properties Radiatve properties of the aerosol saved in .Xr sars 5 format. @@ -129,7 +149,7 @@ This file and the tetrahedral mesh .Pq option Cm mesh must therefore be consistent with each other, i.e. the nodes must be listed in the same order. -.It Cm phasefn= Ns Pa phase_functions_list +.It Cm phasefn= Ns Ar phase_functions_list List in .Xr rnsl 5 format of phase functions to be loaded. @@ -139,7 +159,7 @@ format. The correspondence between these phase functions and the nodes of the volumetric mesh is defined in another file .Pq option Cm phaseids . -.It Cm phaseids= Ns Pa per_node_phase_function +.It Cm phaseids= Ns Ar per_node_phase_function Path to the .Xr rnpfi 5 file that stores the index of the phase function to be used per @@ -151,6 +171,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 @@ -192,7 +288,7 @@ Default is @HTRDR_ARGS_DEFAULT_CAMERA_UP@. .El .It Fl d Write atmospheric acceleration structures to -.Pa output . +.Ar output . Each structure is saved in legacy VTK format. To divide the resulting output into N files .Pq N > 1 , @@ -205,14 +301,14 @@ csplit -f octree -k output %^#\\ vtk% /^#\\ vtk/ \\ .Ed .It Fl f Force overwriting of -.Pa output +.Ar output file. .It Fl G Ar ground_opt Ns Op : Ns Ar ground_opt No ... The planet's ground. .Pp The ground options are as follows: .Bl -tag -width Ds -.It Cm brdf= Ns Pa brdfs_list +.It Cm brdf= Ns Ar brdfs_list List in .Xr rnsl 5 format of the BRDFs to be loaded. @@ -222,7 +318,7 @@ format. The correspondence between these BRDFs and the triangles of the surface mesh is defined in another file .Pq option Cm prop . -.It Cm mesh= Ns Pa surface_mesh +.It Cm mesh= Ns Ar surface_mesh Ground triangular mesh saved in .Xr smsh 5 format. @@ -242,11 +338,11 @@ Gas mixture. .Pp The gas options are as follows: .Bl -tag -width Ds -.It Cm mesh= Ns Pa volumetric_mesh +.It Cm mesh= Ns Ar volumetric_mesh Gas tetrahedral mesh saved in .Xr smsh 5 format. -.It Cm ck= Ns Pa correlated_k +.It Cm ck= Ns Ar correlated_k Correlated K fof the gas saved in .Xr sck 5 format. @@ -255,7 +351,7 @@ This file and the tetrahedral mesh .Pq option Cm mesh must therefore be consistent with each other, i.e. the nodes must be listed in the same order. -.It Cm temp= Ns Pa temperature +.It Cm temp= Ns Ar temperature Gas temperatures saved in .Xr rngt 5 format. @@ -287,27 +383,50 @@ 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 Pa accel_struct_storage -File where atmospheric acceleration structures are stored/loaded. -.Pp -If -.Pa accel_struct_storage -does not exist, it is created and is used to store the built -acceleration structures. -.Pp -If -.Pa 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 -.Pa 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 Pa output +.It Fl o Ar output Output file. If not defined, data is written to standard output. +.It Fl P Ar ortho_camera_opt Ns Op : Ns Ar ortho_camera_opt No ... +Set up an orthographic camera. +.Pp +The options for an orthographic camera are as follows: +.Bl -tag -width Ds +.It Cm height= Ns Ar lenght +Image plane height. +Its width is calculated from this length and the image ratio +to guarantee square pixels +.Pq see Fl i No option . +.It Cm pos= Ns Ar x , Ns Ar y , Ns Ar z +Camera position. +Default is @HTRDR_ARGS_DEFAULT_CAMERA_POS@. +.It Cm tgt= Ns Ar x , Ns Ar y , Ns Ar z +Targeted position. +Default is @HTRDR_ARGS_DEFAULT_CAMERA_TGT@. +.It Cm up= Ns Ar x , Ns Ar y , Ns Ar z +Upward vector that the top of the camera is pointing towards. +Default is @HTRDR_ARGS_DEFAULT_CAMERA_UP@. +.El +.It Fl r Ar volrad_budget_opt Ns Op : Ns Ar volrad_budget_opt No ... +Define the calculation of the volumic radiative budget. +Calculation is no longer a rendering: +neither a camera +.Pq option Fl C +nor an image +.Pq option Fl i +is required. +.Pp +The volumic radiative budget options are as follows: +.Bl -tag -width Ds +.It Cm mesh= Ns Ar volume_mesh +Tetrahedral mesh in +.Xr smsh 5 +format on which the volumic radiative budget is estimated per +tetrahedron. +.It Cm spt= Ns Ar samples_per_tetrahedron +Number of samples to estimate the volumic radiative budget of each +tetrahedron. +Default is @HTRDR_PLANETS_ARGS_DEFAULT_VOLRAD_BUDGET_SPT@. +.El .It Fl S Ar source_opt Ns Op : Ns Ar source_opt No ... Define the external source. .Pp @@ -382,70 +501,111 @@ 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 +.It Fl t Ar thread_count 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 verbose. .El -.Sh OUTPUT IMAGE -Images calculated by +.\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +.\" Output data +.\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +.Sh OUTPUT DATA +The output of .Nm -are saved in -.Xr htrdr-image 5 -format. -This section describes the nature and arrangement of image data -depending on the type of calculation performed. +depends on the type of calculation invoked. +This section describes the nature and layout of these output data. +.\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" .Ss XYZ image For an image rendering in the visible part of the spectrum .Pq default behavior or option Fl s Cm cie_xyz , -the pixel components store 4 estimates. +the output is an +.Xr htrdr-image 5 +whose pixel components store 4 estimates. +.Pp The first, second, and third pairs of floating point values encode the estimated integrated radiance in W/sr/m^2 for the X, Y, and Z components of the CIE 1931 XYZ color space. The first value of each pair is the expected value of the average radiance of the pixel. The second value is its associated standard deviation. +.Pp The fourth and final pair records the microsecond estimate of the computation time per radiative path and its standard error. +.\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" .Ss Longwave image For infrared calculations .Pq option Fl s Cm lw= Ns Ar wlen_min , Ns Ar wlen_max -the first and second pixel components store the expected value and the -standard error of the estimated brightness temperature (in K), +the output is an +.Xr htrdr-image 5 +whose first and second pixel components store the expected value and the +standard error of the estimated brightness temperature +.Pq in K , respectively. +.Pp The third and fourth components record the expected value and the standard deviation of the pixel radiance which is either an integrated radiance in W/sr/m^2 or a spectral radiance in W/sr/m^2/nm depending on whether this radiance was calculated for a spectral range or at a single wavelength. +.Pp The fifth and sixth pixel components are not used. +.Pp Finally, the last 2 components of the pixel record the estimate in microseconds of the computation time per radiative path and its standard error. +.\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" .Ss Shortwave image For shortwave calculations .Pq option Fl s Cm sw= Ns Ar wlen_min , Ns Ar wlen_max -the output image is formatted as for a longwave image except that the -first and second components of the pixels are not used, as no brightness -temperature has been evaluated. +the output is an +.Xr htrdr-image 5 +formatted as for a longwave image except that the first and second +components of the pixels are not used, as no brightness temperature has +been evaluated. That is, the third and fourth values record the estimated radiance per pixel and the seventh and eighth values store the estimate of the calculation time by radiative path. The other values are set to 0. +.\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +.Ss Volumic Radiative Budget +For volumic radiative budget +.Pq option Fl r +the output is a list of 15 ASCII values per line, with as many lines as +there are tetrahedra in the volume mesh as an argument to the +.Fl r +option. +The lines follow the order of the input meshes. +.Pp +The total radiative volumic budget is decomposed into its direct and +diffuse components. +For each component +.Pq total, direct and diffuse parts , +the following information is recorded: the average +.Bq W/m^3 , +the associated standard deviation +.Bq W/m^3 , +the sum of Monte Carlo weights and the sum of squared weights. +The purpose of these last two values is to help calculate the expected value +and the standard deviation of the volumic radiative budget for a set of +tetrahedra. +.Pp +After these 12 values, the total number of realisations is recorded. +.Pp +Finally, the last two values are the estimate and associated standard +error of the calculation time per radiative path. +.\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +.\" Returned status +.\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" .Sh EXIT STATUS .Ex -std +.\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +.\" Examples of use +.\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" .Sh EXAMPLES An .Nm @@ -566,7 +726,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 @@ -586,8 +746,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 \\ @@ -608,9 +767,12 @@ 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 +.\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +.\" References +.\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" .Sh SEE ALSO .Xr htrdr-image 5 , .Xr mrumtl 5 , @@ -621,6 +783,9 @@ htrdr-planets -v -N \\ .Xr sars 5 , .Xr sck 5 , .Xr smsh 5 +.\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +.\" Used and implemented standards +.\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" .Sh STANDARDS .Rs .%A International Organization for Standardization / CIE @@ -641,6 +806,9 @@ htrdr-planets -v -N \\ .%D July 1997 .%T MPI-2: Extensions to The Message-Passing Interface .Re +.\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +.\" Brief implementation history +.\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" .Sh HISTORY .Nm has been developed as part of diff --git a/doc/htrdr.1 b/doc/htrdr.1 @@ -1,12 +1,12 @@ -.\" Copyright (C) 2018-2019, 2022-2024 Centre National de la Recherche Scientifique +.\" 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-2024 Institut Pierre-Simon Laplace -.\" Copyright (C) 2022-2024 Institut de Physique du Globe de Paris -.\" Copyright (C) 2018-2024 |Méso|Star> (contact@meso-star.com) -.\" Copyright (C) 2022-2024 Observatoire de Paris -.\" Copyright (C) 2022-2024 Université de Reims Champagne-Ardenne -.\" Copyright (C) 2022-2024 Université de Versaille Saint-Quentin -.\" Copyright (C) 2018-2019, 2022-2024 Université Paul Sabatier +.\" 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 diff --git a/doc/rnrl.5 b/doc/rnrl.5 @@ -1,12 +1,12 @@ -.\" Copyright (C) 2018-2019, 2022-2024 Centre National de la Recherche Scientifique +.\" 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-2024 Institut Pierre-Simon Laplace -.\" Copyright (C) 2022-2024 Institut de Physique du Globe de Paris -.\" Copyright (C) 2018-2024 |Méso|Star> (contact@meso-star.com) -.\" Copyright (C) 2022-2024 Observatoire de Paris -.\" Copyright (C) 2022-2024 Université de Reims Champagne-Ardenne -.\" Copyright (C) 2022-2024 Université de Versaille Saint-Quentin -.\" Copyright (C) 2018-2019, 2022-2024 Université Paul Sabatier +.\" 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 diff --git a/htrdr-planets.pc.in b/htrdr-planets.pc.in @@ -7,6 +7,7 @@ Requires.private:\ s3d >= @S3D_VERSION@,\ sbuf >= @SBUF_VERSION@,\ scam >= @SCAM_VERSION@,\ + smsh >= @SMSH_VERSION@,\ ssf >= @SSF_VERSION@,\ star-sp >= @SSP_VERSION@,\ svx >= @SVX_VERSION@ diff --git a/install.sh b/install.sh @@ -1,14 +1,14 @@ #!/bin/sh -# Copyright (C) 2018-2019, 2022-2024 Centre National de la Recherche Scientifique +# 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-2024 Institut Pierre-Simon Laplace -# Copyright (C) 2022-2024 Institut de Physique du Globe de Paris -# Copyright (C) 2018-2024 |Méso|Star> (contact@meso-star.com) -# Copyright (C) 2022-2024 Observatoire de Paris -# Copyright (C) 2022-2024 Université de Reims Champagne-Ardenne -# Copyright (C) 2022-2024 Université de Versaille Saint-Quentin -# Copyright (C) 2018-2019, 2022-2024 Université Paul Sabatier +# 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 diff --git a/src/atmosphere/htrdr_atmosphere.c b/src/atmosphere/htrdr_atmosphere.c @@ -1,12 +1,12 @@ -/* Copyright (C) 2018-2019, 2022-2024 Centre National de la Recherche Scientifique +/* 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-2024 Institut Pierre-Simon Laplace - * Copyright (C) 2022-2024 Institut de Physique du Globe de Paris - * Copyright (C) 2018-2024 |Méso|Star> (contact@meso-star.com) - * Copyright (C) 2022-2024 Observatoire de Paris - * Copyright (C) 2022-2024 Université de Reims Champagne-Ardenne - * Copyright (C) 2022-2024 Université de Versaille Saint-Quentin - * Copyright (C) 2018-2019, 2022-2024 Université Paul Sabatier + * 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 @@ -116,9 +116,13 @@ setup_camera_orthographic const struct htrdr_atmosphere_args* args) { struct scam_orthographic_args cam_args = SCAM_ORTHOGRAPHIC_ARGS_DEFAULT; - ASSERT(cmd && args && args->image.definition[0] && args->image.definition[1]); + res_T res = RES_OK; + + ASSERT(cmd && args); ASSERT(cmd->output_type == HTRDR_ATMOSPHERE_ARGS_OUTPUT_IMAGE); ASSERT(args->cam_type == HTRDR_ARGS_CAMERA_ORTHOGRAPHIC); + ASSERT(htrdr_args_camera_orthographic_check(&args->cam_ortho) == RES_OK); + ASSERT(htrdr_args_image_check(&args->image) == RES_OK); d3_set(cam_args.position, args->cam_ortho.position); d3_set(cam_args.target, args->cam_ortho.target); @@ -128,12 +132,18 @@ setup_camera_orthographic (double)args->image.definition[0] / (double)args->image.definition[1]; - return scam_create_orthographic + res = scam_create_orthographic (htrdr_get_logger(cmd->htrdr), htrdr_get_allocator(cmd->htrdr), htrdr_get_verbosity_level(cmd->htrdr), &cam_args, &cmd->camera); + if(res != RES_OK) goto error; + +exit: + return res; +error: + goto exit; } static res_T @@ -142,9 +152,13 @@ setup_camera_perspective const struct htrdr_atmosphere_args* args) { struct scam_perspective_args cam_args = SCAM_PERSPECTIVE_ARGS_DEFAULT; - ASSERT(cmd && args && args->image.definition[0] && args->image.definition[1]); + res_T res = RES_OK; + + ASSERT(cmd && args); ASSERT(cmd->output_type == HTRDR_ATMOSPHERE_ARGS_OUTPUT_IMAGE); ASSERT(args->cam_type == HTRDR_ARGS_CAMERA_PERSPECTIVE); + ASSERT(htrdr_args_camera_perspective_check(&args->cam_persp) == RES_OK); + ASSERT(htrdr_args_image_check(&args->image) == RES_OK); d3_set(cam_args.position, args->cam_persp.position); d3_set(cam_args.target, args->cam_persp.target); @@ -156,12 +170,18 @@ setup_camera_perspective cam_args.lens_radius = args->cam_persp.lens_radius; cam_args.focal_distance = args->cam_persp.focal_dst; - return scam_create_perspective + res = scam_create_perspective (htrdr_get_logger(cmd->htrdr), htrdr_get_allocator(cmd->htrdr), htrdr_get_verbosity_level(cmd->htrdr), &cam_args, &cmd->camera); + if(res != RES_OK) goto error; + +exit: + return res; +error: + goto exit; } static res_T diff --git a/src/atmosphere/htrdr_atmosphere.h b/src/atmosphere/htrdr_atmosphere.h @@ -1,12 +1,12 @@ -/* Copyright (C) 2018-2019, 2022-2024 Centre National de la Recherche Scientifique +/* 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-2024 Institut Pierre-Simon Laplace - * Copyright (C) 2022-2024 Institut de Physique du Globe de Paris - * Copyright (C) 2018-2024 |Méso|Star> (contact@meso-star.com) - * Copyright (C) 2022-2024 Observatoire de Paris - * Copyright (C) 2022-2024 Université de Reims Champagne-Ardenne - * Copyright (C) 2022-2024 Université de Versaille Saint-Quentin - * Copyright (C) 2018-2019, 2022-2024 Université Paul Sabatier + * 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 diff --git a/src/atmosphere/htrdr_atmosphere_args.c b/src/atmosphere/htrdr_atmosphere_args.c @@ -1,12 +1,12 @@ -/* Copyright (C) 2018-2019, 2022-2024 Centre National de la Recherche Scientifique +/* 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-2024 Institut Pierre-Simon Laplace - * Copyright (C) 2022-2024 Institut de Physique du Globe de Paris - * Copyright (C) 2018-2024 |Méso|Star> (contact@meso-star.com) - * Copyright (C) 2022-2024 Observatoire de Paris - * Copyright (C) 2022-2024 Université de Reims Champagne-Ardenne - * Copyright (C) 2022-2024 Université de Versaille Saint-Quentin - * Copyright (C) 2018-2019, 2022-2024 Université Paul Sabatier + * 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 diff --git a/src/atmosphere/htrdr_atmosphere_args.h.in b/src/atmosphere/htrdr_atmosphere_args.h.in @@ -1,10 +1,10 @@ -/* Copyright (C) 2018-2019, 2022-2024 Centre National de la Recherche Scientifique +/* 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-2024 Institut de Physique du Globe de Paris - * Copyright (C) 2018-2024 |Méso|Star> (contact@meso-star.com) - * Copyright (C) 2022-2024 Université de Reims Champagne-Ardenne - * Copyright (C) 2022-2024 Université de Versaille Saint-Quentin - * Copyright (C) 2018-2019, 2022-2024 Université Paul Sabatier + * 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 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 diff --git a/src/atmosphere/htrdr_atmosphere_c.h b/src/atmosphere/htrdr_atmosphere_c.h @@ -1,12 +1,12 @@ -/* Copyright (C) 2018-2019, 2022-2024 Centre National de la Recherche Scientifique +/* 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-2024 Institut Pierre-Simon Laplace - * Copyright (C) 2022-2024 Institut de Physique du Globe de Paris - * Copyright (C) 2018-2024 |Méso|Star> (contact@meso-star.com) - * Copyright (C) 2022-2024 Observatoire de Paris - * Copyright (C) 2022-2024 Université de Reims Champagne-Ardenne - * Copyright (C) 2022-2024 Université de Versaille Saint-Quentin - * Copyright (C) 2018-2019, 2022-2024 Université Paul Sabatier + * 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 diff --git a/src/atmosphere/htrdr_atmosphere_compute_radiance_lw.c b/src/atmosphere/htrdr_atmosphere_compute_radiance_lw.c @@ -1,12 +1,12 @@ -/* Copyright (C) 2018-2019, 2022-2024 Centre National de la Recherche Scientifique +/* 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-2024 Institut Pierre-Simon Laplace - * Copyright (C) 2022-2024 Institut de Physique du Globe de Paris - * Copyright (C) 2018-2024 |Méso|Star> (contact@meso-star.com) - * Copyright (C) 2022-2024 Observatoire de Paris - * Copyright (C) 2022-2024 Université de Reims Champagne-Ardenne - * Copyright (C) 2022-2024 Université de Versaille Saint-Quentin - * Copyright (C) 2018-2019, 2022-2024 Université Paul Sabatier + * 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 diff --git a/src/atmosphere/htrdr_atmosphere_compute_radiance_sw.c b/src/atmosphere/htrdr_atmosphere_compute_radiance_sw.c @@ -1,12 +1,12 @@ -/* Copyright (C) 2018-2019, 2022-2024 Centre National de la Recherche Scientifique +/* 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-2024 Institut Pierre-Simon Laplace - * Copyright (C) 2022-2024 Institut de Physique du Globe de Paris - * Copyright (C) 2018-2024 |Méso|Star> (contact@meso-star.com) - * Copyright (C) 2022-2024 Observatoire de Paris - * Copyright (C) 2022-2024 Université de Reims Champagne-Ardenne - * Copyright (C) 2022-2024 Université de Versaille Saint-Quentin - * Copyright (C) 2018-2019, 2022-2024 Université Paul Sabatier + * 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 diff --git a/src/atmosphere/htrdr_atmosphere_draw_map.c b/src/atmosphere/htrdr_atmosphere_draw_map.c @@ -1,12 +1,12 @@ -/* Copyright (C) 2018-2019, 2022-2024 Centre National de la Recherche Scientifique +/* 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-2024 Institut Pierre-Simon Laplace - * Copyright (C) 2022-2024 Institut de Physique du Globe de Paris - * Copyright (C) 2018-2024 |Méso|Star> (contact@meso-star.com) - * Copyright (C) 2022-2024 Observatoire de Paris - * Copyright (C) 2022-2024 Université de Reims Champagne-Ardenne - * Copyright (C) 2022-2024 Université de Versaille Saint-Quentin - * Copyright (C) 2018-2019, 2022-2024 Université Paul Sabatier + * 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 @@ -639,4 +639,3 @@ exit: error: goto exit; } - diff --git a/src/atmosphere/htrdr_atmosphere_ground.c b/src/atmosphere/htrdr_atmosphere_ground.c @@ -1,12 +1,12 @@ -/* Copyright (C) 2018-2019, 2022-2024 Centre National de la Recherche Scientifique +/* 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-2024 Institut Pierre-Simon Laplace - * Copyright (C) 2022-2024 Institut de Physique du Globe de Paris - * Copyright (C) 2018-2024 |Méso|Star> (contact@meso-star.com) - * Copyright (C) 2022-2024 Observatoire de Paris - * Copyright (C) 2022-2024 Université de Reims Champagne-Ardenne - * Copyright (C) 2022-2024 Université de Versaille Saint-Quentin - * Copyright (C) 2018-2019, 2022-2024 Université Paul Sabatier + * 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 diff --git a/src/atmosphere/htrdr_atmosphere_ground.h b/src/atmosphere/htrdr_atmosphere_ground.h @@ -1,12 +1,12 @@ -/* Copyright (C) 2018-2019, 2022-2024 Centre National de la Recherche Scientifique +/* 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-2024 Institut Pierre-Simon Laplace - * Copyright (C) 2022-2024 Institut de Physique du Globe de Paris - * Copyright (C) 2018-2024 |Méso|Star> (contact@meso-star.com) - * Copyright (C) 2022-2024 Observatoire de Paris - * Copyright (C) 2022-2024 Université de Reims Champagne-Ardenne - * Copyright (C) 2022-2024 Université de Versaille Saint-Quentin - * Copyright (C) 2018-2019, 2022-2024 Université Paul Sabatier + * 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 diff --git a/src/atmosphere/htrdr_atmosphere_main.c b/src/atmosphere/htrdr_atmosphere_main.c @@ -1,12 +1,12 @@ -/* Copyright (C) 2018-2019, 2022-2024 Centre National de la Recherche Scientifique +/* 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-2024 Institut Pierre-Simon Laplace - * Copyright (C) 2022-2024 Institut de Physique du Globe de Paris - * Copyright (C) 2018-2024 |Méso|Star> (contact@meso-star.com) - * Copyright (C) 2022-2024 Observatoire de Paris - * Copyright (C) 2022-2024 Université de Reims Champagne-Ardenne - * Copyright (C) 2022-2024 Université de Versaille Saint-Quentin - * Copyright (C) 2018-2019, 2022-2024 Université Paul Sabatier + * 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 diff --git a/src/atmosphere/htrdr_atmosphere_sun.c b/src/atmosphere/htrdr_atmosphere_sun.c @@ -1,12 +1,12 @@ -/* Copyright (C) 2018-2019, 2022-2024 Centre National de la Recherche Scientifique +/* 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-2024 Institut Pierre-Simon Laplace - * Copyright (C) 2022-2024 Institut de Physique du Globe de Paris - * Copyright (C) 2018-2024 |Méso|Star> (contact@meso-star.com) - * Copyright (C) 2022-2024 Observatoire de Paris - * Copyright (C) 2022-2024 Université de Reims Champagne-Ardenne - * Copyright (C) 2022-2024 Université de Versaille Saint-Quentin - * Copyright (C) 2018-2019, 2022-2024 Université Paul Sabatier + * 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 diff --git a/src/atmosphere/htrdr_atmosphere_sun.h b/src/atmosphere/htrdr_atmosphere_sun.h @@ -1,12 +1,12 @@ -/* Copyright (C) 2018-2019, 2022-2024 Centre National de la Recherche Scientifique +/* 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-2024 Institut Pierre-Simon Laplace - * Copyright (C) 2022-2024 Institut de Physique du Globe de Paris - * Copyright (C) 2018-2024 |Méso|Star> (contact@meso-star.com) - * Copyright (C) 2022-2024 Observatoire de Paris - * Copyright (C) 2022-2024 Université de Reims Champagne-Ardenne - * Copyright (C) 2022-2024 Université de Versaille Saint-Quentin - * Copyright (C) 2018-2019, 2022-2024 Université Paul Sabatier + * 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 diff --git a/src/combustion/htrdr_combustion.c b/src/combustion/htrdr_combustion.c @@ -1,12 +1,12 @@ -/* Copyright (C) 2018-2019, 2022-2024 Centre National de la Recherche Scientifique +/* 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-2024 Institut Pierre-Simon Laplace - * Copyright (C) 2022-2024 Institut de Physique du Globe de Paris - * Copyright (C) 2018-2024 |Méso|Star> (contact@meso-star.com) - * Copyright (C) 2022-2024 Observatoire de Paris - * Copyright (C) 2022-2024 Université de Reims Champagne-Ardenne - * Copyright (C) 2022-2024 Université de Versaille Saint-Quentin - * Copyright (C) 2018-2019, 2022-2024 Université Paul Sabatier + * 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 diff --git a/src/combustion/htrdr_combustion.h b/src/combustion/htrdr_combustion.h @@ -1,12 +1,12 @@ -/* Copyright (C) 2018-2019, 2022-2024 Centre National de la Recherche Scientifique +/* 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-2024 Institut Pierre-Simon Laplace - * Copyright (C) 2022-2024 Institut de Physique du Globe de Paris - * Copyright (C) 2018-2024 |Méso|Star> (contact@meso-star.com) - * Copyright (C) 2022-2024 Observatoire de Paris - * Copyright (C) 2022-2024 Université de Reims Champagne-Ardenne - * Copyright (C) 2022-2024 Université de Versaille Saint-Quentin - * Copyright (C) 2018-2019, 2022-2024 Université Paul Sabatier + * 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 diff --git a/src/combustion/htrdr_combustion_args.c b/src/combustion/htrdr_combustion_args.c @@ -1,12 +1,12 @@ -/* Copyright (C) 2018-2019, 2022-2024 Centre National de la Recherche Scientifique +/* 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-2024 Institut Pierre-Simon Laplace - * Copyright (C) 2022-2024 Institut de Physique du Globe de Paris - * Copyright (C) 2018-2024 |Méso|Star> (contact@meso-star.com) - * Copyright (C) 2022-2024 Observatoire de Paris - * Copyright (C) 2022-2024 Université de Reims Champagne-Ardenne - * Copyright (C) 2022-2024 Université de Versaille Saint-Quentin - * Copyright (C) 2018-2019, 2022-2024 Université Paul Sabatier + * 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 diff --git a/src/combustion/htrdr_combustion_args.h.in b/src/combustion/htrdr_combustion_args.h.in @@ -1,10 +1,10 @@ -/* Copyright (C) 2018-2019, 2022-2024 Centre National de la Recherche Scientifique +/* 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-2024 Institut de Physique du Globe de Paris - * Copyright (C) 2018-2024 |Méso|Star> (contact@meso-star.com) - * Copyright (C) 2022-2024 Université de Reims Champagne-Ardenne - * Copyright (C) 2022-2024 Université de Versaille Saint-Quentin - * Copyright (C) 2018-2019, 2022-2024 Université Paul Sabatier + * 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 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 diff --git a/src/combustion/htrdr_combustion_c.h b/src/combustion/htrdr_combustion_c.h @@ -1,12 +1,12 @@ -/* Copyright (C) 2018-2019, 2022-2024 Centre National de la Recherche Scientifique +/* 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-2024 Institut Pierre-Simon Laplace - * Copyright (C) 2022-2024 Institut de Physique du Globe de Paris - * Copyright (C) 2018-2024 |Méso|Star> (contact@meso-star.com) - * Copyright (C) 2022-2024 Observatoire de Paris - * Copyright (C) 2022-2024 Université de Reims Champagne-Ardenne - * Copyright (C) 2022-2024 Université de Versaille Saint-Quentin - * Copyright (C) 2018-2019, 2022-2024 Université Paul Sabatier + * 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 diff --git a/src/combustion/htrdr_combustion_compute_radiance_sw.c b/src/combustion/htrdr_combustion_compute_radiance_sw.c @@ -1,12 +1,12 @@ -/* Copyright (C) 2018-2019, 2022-2024 Centre National de la Recherche Scientifique +/* 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-2024 Institut Pierre-Simon Laplace - * Copyright (C) 2022-2024 Institut de Physique du Globe de Paris - * Copyright (C) 2018-2024 |Méso|Star> (contact@meso-star.com) - * Copyright (C) 2022-2024 Observatoire de Paris - * Copyright (C) 2022-2024 Université de Reims Champagne-Ardenne - * Copyright (C) 2022-2024 Université de Versaille Saint-Quentin - * Copyright (C) 2018-2019, 2022-2024 Université Paul Sabatier + * 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 diff --git a/src/combustion/htrdr_combustion_draw_map.c b/src/combustion/htrdr_combustion_draw_map.c @@ -1,12 +1,12 @@ -/* Copyright (C) 2018-2019, 2022-2024 Centre National de la Recherche Scientifique +/* 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-2024 Institut Pierre-Simon Laplace - * Copyright (C) 2022-2024 Institut de Physique du Globe de Paris - * Copyright (C) 2018-2024 |Méso|Star> (contact@meso-star.com) - * Copyright (C) 2022-2024 Observatoire de Paris - * Copyright (C) 2022-2024 Université de Reims Champagne-Ardenne - * Copyright (C) 2022-2024 Université de Versaille Saint-Quentin - * Copyright (C) 2018-2019, 2022-2024 Université Paul Sabatier + * 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 diff --git a/src/combustion/htrdr_combustion_geometry_ray_filter.c b/src/combustion/htrdr_combustion_geometry_ray_filter.c @@ -1,12 +1,12 @@ -/* Copyright (C) 2018-2019, 2022-2024 Centre National de la Recherche Scientifique +/* 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-2024 Institut Pierre-Simon Laplace - * Copyright (C) 2022-2024 Institut de Physique du Globe de Paris - * Copyright (C) 2018-2024 |Méso|Star> (contact@meso-star.com) - * Copyright (C) 2022-2024 Observatoire de Paris - * Copyright (C) 2022-2024 Université de Reims Champagne-Ardenne - * Copyright (C) 2022-2024 Université de Versaille Saint-Quentin - * Copyright (C) 2018-2019, 2022-2024 Université Paul Sabatier + * 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 diff --git a/src/combustion/htrdr_combustion_geometry_ray_filter.h b/src/combustion/htrdr_combustion_geometry_ray_filter.h @@ -1,12 +1,12 @@ -/* Copyright (C) 2018-2019, 2022-2024 Centre National de la Recherche Scientifique +/* 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-2024 Institut Pierre-Simon Laplace - * Copyright (C) 2022-2024 Institut de Physique du Globe de Paris - * Copyright (C) 2018-2024 |Méso|Star> (contact@meso-star.com) - * Copyright (C) 2022-2024 Observatoire de Paris - * Copyright (C) 2022-2024 Université de Reims Champagne-Ardenne - * Copyright (C) 2022-2024 Université de Versaille Saint-Quentin - * Copyright (C) 2018-2019, 2022-2024 Université Paul Sabatier + * 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 diff --git a/src/combustion/htrdr_combustion_laser.c b/src/combustion/htrdr_combustion_laser.c @@ -1,12 +1,12 @@ -/* Copyright (C) 2018-2019, 2022-2024 Centre National de la Recherche Scientifique +/* 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-2024 Institut Pierre-Simon Laplace - * Copyright (C) 2022-2024 Institut de Physique du Globe de Paris - * Copyright (C) 2018-2024 |Méso|Star> (contact@meso-star.com) - * Copyright (C) 2022-2024 Observatoire de Paris - * Copyright (C) 2022-2024 Université de Reims Champagne-Ardenne - * Copyright (C) 2022-2024 Université de Versaille Saint-Quentin - * Copyright (C) 2018-2019, 2022-2024 Université Paul Sabatier + * 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 diff --git a/src/combustion/htrdr_combustion_laser.h b/src/combustion/htrdr_combustion_laser.h @@ -1,12 +1,12 @@ -/* Copyright (C) 2018-2019, 2022-2024 Centre National de la Recherche Scientifique +/* 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-2024 Institut Pierre-Simon Laplace - * Copyright (C) 2022-2024 Institut de Physique du Globe de Paris - * Copyright (C) 2018-2024 |Méso|Star> (contact@meso-star.com) - * Copyright (C) 2022-2024 Observatoire de Paris - * Copyright (C) 2022-2024 Université de Reims Champagne-Ardenne - * Copyright (C) 2022-2024 Université de Versaille Saint-Quentin - * Copyright (C) 2018-2019, 2022-2024 Université Paul Sabatier + * 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 diff --git a/src/combustion/htrdr_combustion_main.c b/src/combustion/htrdr_combustion_main.c @@ -1,12 +1,12 @@ -/* Copyright (C) 2018-2019, 2022-2024 Centre National de la Recherche Scientifique +/* 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-2024 Institut Pierre-Simon Laplace - * Copyright (C) 2022-2024 Institut de Physique du Globe de Paris - * Copyright (C) 2018-2024 |Méso|Star> (contact@meso-star.com) - * Copyright (C) 2022-2024 Observatoire de Paris - * Copyright (C) 2022-2024 Université de Reims Champagne-Ardenne - * Copyright (C) 2022-2024 Université de Versaille Saint-Quentin - * Copyright (C) 2018-2019, 2022-2024 Université Paul Sabatier + * 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 diff --git a/src/combustion/htrdr_combustion_phase_func.c b/src/combustion/htrdr_combustion_phase_func.c @@ -1,12 +1,12 @@ -/* Copyright (C) 2018-2019, 2022-2024 Centre National de la Recherche Scientifique +/* 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-2024 Institut Pierre-Simon Laplace - * Copyright (C) 2022-2024 Institut de Physique du Globe de Paris - * Copyright (C) 2018-2024 |Méso|Star> (contact@meso-star.com) - * Copyright (C) 2022-2024 Observatoire de Paris - * Copyright (C) 2022-2024 Université de Reims Champagne-Ardenne - * Copyright (C) 2022-2024 Université de Versaille Saint-Quentin - * Copyright (C) 2018-2019, 2022-2024 Université Paul Sabatier + * 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 diff --git a/src/combustion/test_htrdr_combustion_laser.c b/src/combustion/test_htrdr_combustion_laser.c @@ -1,12 +1,12 @@ -/* Copyright (C) 2018-2019, 2022-2024 Centre National de la Recherche Scientifique +/* 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-2024 Institut Pierre-Simon Laplace - * Copyright (C) 2022-2024 Institut de Physique du Globe de Paris - * Copyright (C) 2018-2024 |Méso|Star> (contact@meso-star.com) - * Copyright (C) 2022-2024 Observatoire de Paris - * Copyright (C) 2022-2024 Université de Reims Champagne-Ardenne - * Copyright (C) 2022-2024 Université de Versaille Saint-Quentin - * Copyright (C) 2018-2019, 2022-2024 Université Paul Sabatier + * 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 diff --git a/src/commands/htrdr_atmosphere_cmd.c b/src/commands/htrdr_atmosphere_cmd.c @@ -1,12 +1,12 @@ -/* Copyright (C) 2018-2019, 2022-2024 Centre National de la Recherche Scientifique +/* 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-2024 Institut Pierre-Simon Laplace - * Copyright (C) 2022-2024 Institut de Physique du Globe de Paris - * Copyright (C) 2018-2024 |Méso|Star> (contact@meso-star.com) - * Copyright (C) 2022-2024 Observatoire de Paris - * Copyright (C) 2022-2024 Université de Reims Champagne-Ardenne - * Copyright (C) 2022-2024 Université de Versaille Saint-Quentin - * Copyright (C) 2018-2019, 2022-2024 Université Paul Sabatier + * 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 @@ -21,21 +21,10 @@ * 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" -#else - #include <stdio.h> -#endif +#include "atmosphere/htrdr_atmosphere.h" int main(int argc, char** argv) { -#ifdef HTRDR_BUILD_ATMOSPHERE return htrdr_atmosphere_main(argc, argv); -#else - (void)argc, (void)argv; - fprintf(stderr, - "The htrdr-atmosphere command is not available in this htrdr build.\n"); - return 1; -#endif } diff --git a/src/commands/htrdr_cmd.c b/src/commands/htrdr_cmd.c @@ -1,126 +0,0 @@ -/* Copyright (C) 2018-2019, 2022-2024 Centre National de la Recherche Scientifique - * Copyright (C) 2020-2022 Institut Mines Télécom Albi-Carmaux - * Copyright (C) 2022-2024 Institut Pierre-Simon Laplace - * Copyright (C) 2022-2024 Institut de Physique du Globe de Paris - * Copyright (C) 2018-2024 |Méso|Star> (contact@meso-star.com) - * Copyright (C) 2022-2024 Observatoire de Paris - * Copyright (C) 2022-2024 Université de Reims Champagne-Ardenne - * Copyright (C) 2022-2024 Université de Versaille Saint-Quentin - * Copyright (C) 2018-2019, 2022-2024 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/commands/htrdr_combustion_cmd.c b/src/commands/htrdr_combustion_cmd.c @@ -1,12 +1,12 @@ -/* Copyright (C) 2018-2019, 2022-2024 Centre National de la Recherche Scientifique +/* 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-2024 Institut Pierre-Simon Laplace - * Copyright (C) 2022-2024 Institut de Physique du Globe de Paris - * Copyright (C) 2018-2024 |Méso|Star> (contact@meso-star.com) - * Copyright (C) 2022-2024 Observatoire de Paris - * Copyright (C) 2022-2024 Université de Reims Champagne-Ardenne - * Copyright (C) 2022-2024 Université de Versaille Saint-Quentin - * Copyright (C) 2018-2019, 2022-2024 Université Paul Sabatier + * 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 @@ -21,21 +21,10 @@ * 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_COMBUSTION - #include "combustion/htrdr_combustion.h" -#else - #include <stdio.h> -#endif +#include "combustion/htrdr_combustion.h" int main(int argc, char** argv) { -#ifdef HTRDR_BUILD_COMBUSTION return htrdr_combustion_main(argc, argv); -#else - (void)argc, (void)argv; - fprintf(stderr, - "The htrdr-combustion command is not available in this htrdr build.\n"); - return 1; -#endif } diff --git a/src/commands/htrdr_planets_cmd.c b/src/commands/htrdr_planets_cmd.c @@ -1,12 +1,12 @@ -/* Copyright (C) 2018-2019, 2022-2024 Centre National de la Recherche Scientifique +/* 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-2024 Institut Pierre-Simon Laplace - * Copyright (C) 2022-2024 Institut de Physique du Globe de Paris - * Copyright (C) 2018-2024 |Méso|Star> (contact@meso-star.com) - * Copyright (C) 2022-2024 Observatoire de Paris - * Copyright (C) 2022-2024 Université de Reims Champagne-Ardenne - * Copyright (C) 2022-2024 Université de Versaille Saint-Quentin - * Copyright (C) 2018-2019, 2022-2024 Université Paul Sabatier + * 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 @@ -21,21 +21,10 @@ * 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_PLANETS - #include "planets/htrdr_planets.h" -#else - #include <stdio.h> -#endif +#include "planets/htrdr_planets.h" int main(int argc, char** argv) { -#ifdef HTRDR_BUILD_PLANETS return htrdr_planets_main(argc, argv); -#else - (void)argc, (void)argv; - fprintf(stderr, - "The htrdr-planets command is not available in this htrdr build.\n"); - return 1; -#endif } diff --git a/src/core/htrdr.c b/src/core/htrdr.c @@ -1,12 +1,12 @@ -/* Copyright (C) 2018-2019, 2022-2024 Centre National de la Recherche Scientifique +/* 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-2024 Institut Pierre-Simon Laplace - * Copyright (C) 2022-2024 Institut de Physique du Globe de Paris - * Copyright (C) 2018-2024 |Méso|Star> (contact@meso-star.com) - * Copyright (C) 2022-2024 Observatoire de Paris - * Copyright (C) 2022-2024 Université de Reims Champagne-Ardenne - * Copyright (C) 2022-2024 Université de Versaille Saint-Quentin - * Copyright (C) 2018-2019, 2022-2024 Université Paul Sabatier + * 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 @@ -369,8 +369,12 @@ htrdr_create } FOR_EACH(ithread, 0, htrdr->nthreads) { + const size_t per_thread_size = + 4*1024*1024 /* 4 MB for the RNG cache */ + + 16*1024; /* 16 KB for remaining allocations */ + res = mem_init_lifo_allocator - (&htrdr->lifo_allocators[ithread], htrdr->allocator, 16384); + (&htrdr->lifo_allocators[ithread], htrdr->allocator, per_thread_size); if(res != RES_OK) { htrdr_log_err(htrdr, "%s: could not initialise the LIFO allocator of the thread %lu -- %s.\n", diff --git a/src/core/htrdr.h b/src/core/htrdr.h @@ -1,12 +1,12 @@ -/* Copyright (C) 2018-2019, 2022-2024 Centre National de la Recherche Scientifique +/* 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-2024 Institut Pierre-Simon Laplace - * Copyright (C) 2022-2024 Institut de Physique du Globe de Paris - * Copyright (C) 2018-2024 |Méso|Star> (contact@meso-star.com) - * Copyright (C) 2022-2024 Observatoire de Paris - * Copyright (C) 2022-2024 Université de Reims Champagne-Ardenne - * Copyright (C) 2022-2024 Université de Versaille Saint-Quentin - * Copyright (C) 2018-2019, 2022-2024 Université Paul Sabatier + * 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 @@ -64,13 +64,13 @@ htrdr_fprint_copyright(const char* cmd, FILE* stream) { (void)cmd; fprintf(stream, -"Copyright (C) 2018-2019, 2022-2024 Centre National de la Recherche Scientifique\n" +"Copyright (C) 2018-2019, 2022-2025 Centre National de la Recherche Scientifique\n" "Copyright (C) 2020-2022 Institut Mines Télécom Albi-Carmaux\n" -"Copyright (C) 2022-2024 Institut de Physique du Globe de Paris\n" -"Copyright (C) 2018-2024 |Méso|Star> <contact@meso-star.com>\n" -"Copyright (C) 2022-2024 Université de Reims Champagne-Ardenne\n" -"Copyright (C) 2022-2024 Université de Versaille Saint-Quentin\n" -"Copyright (C) 2018-2019, 2022-2024 Université Paul Sabatier\n"); +"Copyright (C) 2022-2025 Institut de Physique du Globe de Paris\n" +"Copyright (C) 2018-2025 |Méso|Star> <contact@meso-star.com>\n" +"Copyright (C) 2022-2025 Université de Reims Champagne-Ardenne\n" +"Copyright (C) 2022-2025 Université de Versaille Saint-Quentin\n" +"Copyright (C) 2018-2019, 2022-2025 Université Paul Sabatier\n"); } static INLINE void diff --git a/src/core/htrdr_accum.h b/src/core/htrdr_accum.h @@ -1,12 +1,12 @@ -/* Copyright (C) 2018-2019, 2022-2024 Centre National de la Recherche Scientifique +/* 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-2024 Institut Pierre-Simon Laplace - * Copyright (C) 2022-2024 Institut de Physique du Globe de Paris - * Copyright (C) 2018-2024 |Méso|Star> (contact@meso-star.com) - * Copyright (C) 2022-2024 Observatoire de Paris - * Copyright (C) 2022-2024 Université de Reims Champagne-Ardenne - * Copyright (C) 2022-2024 Université de Versaille Saint-Quentin - * Copyright (C) 2018-2019, 2022-2024 Université Paul Sabatier + * 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 diff --git a/src/core/htrdr_args.c b/src/core/htrdr_args.c @@ -1,12 +1,12 @@ -/* Copyright (C) 2018-2019, 2022-2024 Centre National de la Recherche Scientifique +/* 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-2024 Institut Pierre-Simon Laplace - * Copyright (C) 2022-2024 Institut de Physique du Globe de Paris - * Copyright (C) 2018-2024 |Méso|Star> (contact@meso-star.com) - * Copyright (C) 2022-2024 Observatoire de Paris - * Copyright (C) 2022-2024 Université de Reims Champagne-Ardenne - * Copyright (C) 2022-2024 Université de Versaille Saint-Quentin - * Copyright (C) 2018-2019, 2022-2024 Université Paul Sabatier + * 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 @@ -655,6 +655,18 @@ htrdr_args_camera_orthographic_parse } res_T +htrdr_args_camera_orthographic_check + (const struct htrdr_args_camera_orthographic* cam) +{ + if(!cam) return RES_BAD_ARG; + + /* Invalid image plane height */ + if(cam->height <= 0) return RES_BAD_ARG; + + return RES_OK; +} + +res_T htrdr_args_rectangle_parse(struct htrdr_args_rectangle* rect, const char* str) { if(!rect || !str) return RES_BAD_ARG; diff --git a/src/core/htrdr_args.h.in b/src/core/htrdr_args.h.in @@ -1,10 +1,10 @@ -/* Copyright (C) 2018-2019, 2022-2024 Centre National de la Recherche Scientifique +/* 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-2024 Institut de Physique du Globe de Paris - * Copyright (C) 2018-2024 |Méso|Star> (contact@meso-star.com) - * Copyright (C) 2022-2024 Université de Reims Champagne-Ardenne - * Copyright (C) 2022-2024 Université de Versaille Saint-Quentin - * Copyright (C) 2018-2019, 2022-2024 Université Paul Sabatier + * 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 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 @@ -146,6 +146,10 @@ htrdr_args_camera_orthographic_parse const char* str); HTRDR_API res_T +htrdr_args_camera_orthographic_check + (const struct htrdr_args_camera_orthographic* cam); + +HTRDR_API res_T htrdr_args_rectangle_parse (struct htrdr_args_rectangle* rect, const char* str); diff --git a/src/core/htrdr_buffer.c b/src/core/htrdr_buffer.c @@ -1,12 +1,12 @@ -/* Copyright (C) 2018-2019, 2022-2024 Centre National de la Recherche Scientifique +/* 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-2024 Institut Pierre-Simon Laplace - * Copyright (C) 2022-2024 Institut de Physique du Globe de Paris - * Copyright (C) 2018-2024 |Méso|Star> (contact@meso-star.com) - * Copyright (C) 2022-2024 Observatoire de Paris - * Copyright (C) 2022-2024 Université de Reims Champagne-Ardenne - * Copyright (C) 2022-2024 Université de Versaille Saint-Quentin - * Copyright (C) 2018-2019, 2022-2024 Université Paul Sabatier + * 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 @@ -67,9 +67,8 @@ htrdr_buffer_create res_T res = RES_OK; ASSERT(htrdr && layout && out_buf); - if(!htrdr_buffer_layout_check(layout)) { + if((res = htrdr_buffer_layout_check(layout)) != RES_OK) { htrdr_log_err(htrdr, "Invalid buffer memory layout.\n"); - res = RES_BAD_ARG; goto error; } diff --git a/src/core/htrdr_buffer.h b/src/core/htrdr_buffer.h @@ -1,12 +1,12 @@ -/* Copyright (C) 2018-2019, 2022-2024 Centre National de la Recherche Scientifique +/* 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-2024 Institut Pierre-Simon Laplace - * Copyright (C) 2022-2024 Institut de Physique du Globe de Paris - * Copyright (C) 2018-2024 |Méso|Star> (contact@meso-star.com) - * Copyright (C) 2022-2024 Observatoire de Paris - * Copyright (C) 2022-2024 Université de Reims Champagne-Ardenne - * Copyright (C) 2022-2024 Université de Versaille Saint-Quentin - * Copyright (C) 2018-2019, 2022-2024 Université Paul Sabatier + * 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 @@ -65,15 +65,32 @@ htrdr_buffer_layout_eq && a->alignment == b->alignment; } -static INLINE int +static INLINE res_T htrdr_buffer_layout_check(const struct htrdr_buffer_layout* layout) { - return layout - && layout->width - && layout->height - && layout->elmt_size - && layout->width*layout->elmt_size <= layout->pitch - && IS_POW2(layout->alignment); + if(!layout) return RES_BAD_ARG; + + /* Invalid resolution */ + if(!layout->width || !layout->height) { + return RES_BAD_ARG; + } + + /* An element cannot be empty */ + if(!layout->elmt_size) { + return RES_BAD_ARG; + } + + /* Check pitch consistency */ + if(!layout->width*layout->elmt_size > layout->pitch) { + return RES_BAD_ARG; + } + + /* Ensure that the alignement is a power of two */ + if(!IS_POW2(layout->alignment)) { + return RES_BAD_ARG; + } + + return RES_OK; } /* Forward declarations */ diff --git a/src/core/htrdr_c.h b/src/core/htrdr_c.h @@ -1,12 +1,12 @@ -/* Copyright (C) 2018-2019, 2022-2024 Centre National de la Recherche Scientifique +/* 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-2024 Institut Pierre-Simon Laplace - * Copyright (C) 2022-2024 Institut de Physique du Globe de Paris - * Copyright (C) 2018-2024 |Méso|Star> (contact@meso-star.com) - * Copyright (C) 2022-2024 Observatoire de Paris - * Copyright (C) 2022-2024 Université de Reims Champagne-Ardenne - * Copyright (C) 2022-2024 Université de Versaille Saint-Quentin - * Copyright (C) 2018-2019, 2022-2024 Université Paul Sabatier + * 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 @@ -34,11 +34,15 @@ #define MPI(Func) MPI_##Func #endif +/* Number of consecutively generated random numbers assigned to a thread */ +#define RNG_SEQUENCE_SIZE 10000 + enum htrdr_mpi_message { HTRDR_MPI_PROGRESS_RENDERING, HTRDR_MPI_STEAL_REQUEST, HTRDR_MPI_WORK_STEALING, - HTRDR_MPI_TILE_DATA + HTRDR_MPI_TILE_DATA, + HTRDR_MPI_CHUNK_DATA }; struct s3d_device; diff --git a/src/core/htrdr_draw_map.c b/src/core/htrdr_draw_map.c @@ -1,12 +1,12 @@ -/* Copyright (C) 2018-2019, 2022-2024 Centre National de la Recherche Scientifique +/* 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-2024 Institut Pierre-Simon Laplace - * Copyright (C) 2022-2024 Institut de Physique du Globe de Paris - * Copyright (C) 2018-2024 |Méso|Star> (contact@meso-star.com) - * Copyright (C) 2022-2024 Observatoire de Paris - * Copyright (C) 2022-2024 Université de Reims Champagne-Ardenne - * Copyright (C) 2022-2024 Université de Versaille Saint-Quentin - * Copyright (C) 2018-2019, 2022-2024 Université Paul Sabatier + * 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 @@ -21,17 +21,15 @@ * 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 /* nanosleep */ - #include "core/htrdr.h" #include "core/htrdr_c.h" #include "core/htrdr_buffer.h" #include "core/htrdr_draw_map.h" #include "core/htrdr_log.h" +#include "core/htrdr_proc_work.h" #include <rsys/clock_time.h> #include <rsys/cstr.h> -#include <rsys/dynamic_array_u32.h> #include <rsys/list.h> #include <rsys/math.h> #include <rsys/morton.h> @@ -42,12 +40,8 @@ #include <omp.h> #include <mpi.h> -#include <time.h> #include <unistd.h> -#define RNG_SEQUENCE_SIZE 10000 - -#define TILE_MCODE_NULL UINT32_MAX #define TILE_SIZE 8 /* Definition in X & Y of a tile */ STATIC_ASSERT(IS_POW2(TILE_SIZE), TILE_SIZE_must_be_a_power_of_2); @@ -58,7 +52,7 @@ struct tile { ref_T ref; struct tile_data { - size_t pixsz; /* Sizeof on pixel */ + size_t pixsz; /* Size of a pixel */ size_t pixal; /* Pixel alignment */ uint16_t x, y; /* 2D coordinates of the tile in tile space */ /* Simulate the flexible array member of the C99 standard */ @@ -66,30 +60,29 @@ struct tile { } data; }; -/* List of tile to compute onto the MPI process. */ -struct proc_work { - struct mutex* mutex; - struct darray_u32 tiles; /* #tiles to render */ - size_t itile; /* Next tile to render in the above list of tiles */ -}; - /******************************************************************************* * Helper functions ******************************************************************************/ -static INLINE int +static INLINE res_T check_draw_map_args(const struct htrdr_draw_map_args* args) { - return args - && args->draw_pixel - && args->spp - && htrdr_buffer_layout_check(&args->buffer_layout); + if(!args) return RES_BAD_ARG; + + /* A functor must be defined */ + if(!args->draw_pixel) return RES_BAD_ARG; + + /* The number of realisations cannot be null */ + if(!args->spp) return RES_BAD_ARG; + + /* Check buffer layout consistency */ + return htrdr_buffer_layout_check(&args->buffer_layout); } static INLINE void tile_ref_get(struct tile* tile) { ASSERT(tile); - tile_ref_get(tile); + ref_get(&tile->ref); } static INLINE void @@ -190,218 +183,6 @@ write_tile_data } } -static INLINE void -proc_work_init(struct mem_allocator* allocator, struct proc_work* work) -{ - ASSERT(work); - darray_u32_init(allocator, &work->tiles); - work->itile = 0; - CHK(work->mutex = mutex_create()); -} - -static INLINE void -proc_work_release(struct proc_work* work) -{ - darray_u32_release(&work->tiles); - mutex_destroy(work->mutex); -} - -static INLINE void -proc_work_reset(struct proc_work* work) -{ - ASSERT(work); - mutex_lock(work->mutex); - darray_u32_clear(&work->tiles); - work->itile = 0; - mutex_unlock(work->mutex); -} - -static INLINE void -proc_work_add_tile(struct proc_work* work, const uint32_t mcode) -{ - mutex_lock(work->mutex); - CHK(darray_u32_push_back(&work->tiles, &mcode) == RES_OK); - mutex_unlock(work->mutex); -} - -static INLINE uint32_t -proc_work_get_tile(struct proc_work* work) -{ - uint32_t mcode; - ASSERT(work); - mutex_lock(work->mutex); - if(work->itile >= darray_u32_size_get(&work->tiles)) { - mcode = TILE_MCODE_NULL; - } else { - mcode = darray_u32_cdata_get(&work->tiles)[work->itile]; - ++work->itile; - } - mutex_unlock(work->mutex); - return mcode; -} - -static INLINE size_t -proc_work_get_ntiles(struct proc_work* work) -{ - size_t sz = 0; - ASSERT(work); - mutex_lock(work->mutex); - sz = darray_u32_size_get(&work->tiles); - mutex_unlock(work->mutex); - return sz; -} - -static void -mpi_wait_for_request(struct htrdr* htrdr, MPI_Request* req) -{ - ASSERT(htrdr && req); - - /* Wait for process synchronisation */ - for(;;) { - struct timespec t; - int complete; - t.tv_sec = 0; - t.tv_nsec = 10000000; /* 10ms */ - - mutex_lock(htrdr->mpi_mutex); - MPI(Test(req, &complete, MPI_STATUS_IGNORE)); - mutex_unlock(htrdr->mpi_mutex); - if(complete) break; - - nanosleep(&t, NULL); - } -} - -static void -mpi_probe_thieves - (struct htrdr* htrdr, - struct proc_work* work, - ATOMIC* probe_thieves) -{ - uint32_t tiles[UINT8_MAX]; - struct timespec t; - ASSERT(htrdr && work && probe_thieves); - - if(htrdr->mpi_nprocs == 1) /* The process is alone. No thief is possible */ - return; - - t.tv_sec = 0; - - /* Protect MPI calls of multiple invocations from concurrent threads */ - #define P_MPI(Func) { \ - mutex_lock(htrdr->mpi_mutex); \ - MPI(Func); \ - mutex_unlock(htrdr->mpi_mutex); \ - } (void)0 - - while(ATOMIC_GET(probe_thieves)) { - MPI_Status status; - size_t itile; - int msg; - - /* Probe if a steal request was submitted by any processes */ - P_MPI(Iprobe(MPI_ANY_SOURCE, HTRDR_MPI_STEAL_REQUEST, MPI_COMM_WORLD, &msg, - &status)); - - if(msg) { /* A steal request was posted */ - MPI_Request req; - uint8_t ntiles_to_steal; - - /* Asynchronously receive the steal request */ - P_MPI(Irecv(&ntiles_to_steal, 1, MPI_UINT8_T, status.MPI_SOURCE, - HTRDR_MPI_STEAL_REQUEST, MPI_COMM_WORLD, &req)); - - /* Wait for the completion of the steal request */ - mpi_wait_for_request(htrdr, &req); - - /* Thief some tiles */ - FOR_EACH(itile, 0, ntiles_to_steal) { - tiles[itile] = proc_work_get_tile(work); - } - P_MPI(Send(&tiles, ntiles_to_steal, MPI_UINT32_T, status.MPI_SOURCE, - HTRDR_MPI_WORK_STEALING, MPI_COMM_WORLD)); - } - t.tv_nsec = 500000000; /* 500ms */ - nanosleep(&t, NULL); - } - #undef P_MPI -} - -static int -mpi_sample_working_process(struct htrdr* htrdr, struct ssp_rng* rng) -{ - int iproc, i; - int dst_rank; - ASSERT(htrdr && rng && htrdr->mpi_nworking_procs); - - /* Sample the index of the 1st active process */ - iproc = (int)(ssp_rng_canonical(rng) * (double)htrdr->mpi_nworking_procs); - - /* Find the rank of the sampled active process. Use a simple linear search - * since the overall number of processes should be quite low; at most few - * dozens. */ - i = 0; - FOR_EACH(dst_rank, 0, htrdr->mpi_nprocs) { - if(htrdr->mpi_working_procs[dst_rank] == 0) continue; /* Inactive process */ - if(i == iproc) break; /* The rank of the sampled process is found */ - ++i; - } - ASSERT(dst_rank < htrdr->mpi_nprocs); - return dst_rank; -} - -/* Return the number of stolen tiles */ -static size_t -mpi_steal_work - (struct htrdr* htrdr, - struct ssp_rng* rng, - struct proc_work* work) -{ - MPI_Request req; - size_t itile; - size_t nthieves = 0; - uint32_t tiles[UINT8_MAX]; /* Morton code of the stolen tile */ - int proc_to_steal; /* Process to steal */ - uint8_t ntiles_to_steal = MMIN((uint8_t)(htrdr->nthreads*2), 16); - ASSERT(htrdr && rng && work && htrdr->nthreads < UINT8_MAX); - - /* Protect MPI calls of multiple invocations from concurrent threads */ - #define P_MPI(Func) { \ - mutex_lock(htrdr->mpi_mutex); \ - MPI(Func); \ - mutex_unlock(htrdr->mpi_mutex); \ - } (void)0 - - /* No more working process => nohting to steal */ - if(!htrdr->mpi_nworking_procs) return 0; - - /* Sample a process to steal */ - proc_to_steal = mpi_sample_working_process(htrdr, rng); - - /* Send a steal request to the sampled process and wait for a response */ - P_MPI(Send(&ntiles_to_steal, 1, MPI_UINT8_T, proc_to_steal, - HTRDR_MPI_STEAL_REQUEST, MPI_COMM_WORLD)); - - /* Receive the stolen tile from the sampled process */ - P_MPI(Irecv(tiles, ntiles_to_steal, MPI_UINT32_T, proc_to_steal, - HTRDR_MPI_WORK_STEALING, MPI_COMM_WORLD, &req)); - - mpi_wait_for_request(htrdr, &req); - - FOR_EACH(itile, 0, ntiles_to_steal) { - if(tiles[itile] == TILE_MCODE_NULL) { - ASSERT(htrdr->mpi_working_procs[proc_to_steal] != 0); - htrdr->mpi_working_procs[proc_to_steal] = 0; - htrdr->mpi_nworking_procs--; - break; - } - proc_work_add_tile(work, tiles[itile]); - ++nthieves; - } - #undef P_MPI - return nthieves; -} - static res_T mpi_gather_tiles (struct htrdr* htrdr, @@ -415,7 +196,8 @@ mpi_gather_tiles struct list_node* node = NULL; struct tile* tile = NULL; res_T res = RES_OK; - ASSERT(htrdr && tiles && htrdr_buffer_layout_check(buf_layout)); + ASSERT(htrdr && tiles); + ASSERT(htrdr_buffer_layout_check(buf_layout) == RES_OK); ASSERT(htrdr->mpi_rank != 0 || buf); (void)ntiles; @@ -501,7 +283,7 @@ draw_tile size_t npixels; size_t mcode; /* Morton code of tile pixel */ ASSERT(htrdr && tile_org && tile_sz && pix_sz && rng && tile); - ASSERT(check_draw_map_args(args)); + ASSERT(check_draw_map_args(args) == RES_OK); (void)tile_mcode; /* Adjust the #pixels to process them wrt a morton order */ @@ -555,9 +337,14 @@ draw_map size_t proc_ntiles = 0; ATOMIC nsolved_tiles = 0; ATOMIC res = RES_OK; - ASSERT(htrdr && check_draw_map_args(args) && work && tiles); + + /* Pre conditions */ + ASSERT(check_draw_map_args(args) == RES_OK); + ASSERT(htrdr && work && tiles); ASSERT(ntiles_x && ntiles_y && ntiles_adjusted >= ntiles_x*ntiles_y); ASSERT(pix_sz && pix_sz[0] > 0 && pix_sz[1] > 0); + + /* Avoid the "unused variable" warning */ (void)ntiles_x, (void)ntiles_y; res = ssp_rng_create(htrdr->allocator, SSP_RNG_MT19937_64, &rng_proc); @@ -567,7 +354,7 @@ draw_map goto error; } - proc_ntiles = proc_work_get_ntiles(work); + proc_ntiles = proc_work_get_nchunks(work); nthreads = MMIN(htrdr->nthreads, proc_ntiles); /* The process is not considered as a working process for himself */ @@ -583,7 +370,7 @@ draw_map struct ssp_rng_proxy* rng_proxy = NULL; struct ssp_rng* rng; struct tile* tile; - uint32_t mcode = TILE_MCODE_NULL; + uint64_t mcode = CHUNK_ID_NULL; uint16_t tile_org[2]; size_t tile_sz[2]; size_t n; @@ -593,20 +380,21 @@ draw_map /* Get a tile to draw */ #pragma omp critical { - mcode = proc_work_get_tile(work); - if(mcode == TILE_MCODE_NULL) { /* No more work on this process */ + mcode = proc_work_get_chunk(work); + if(mcode == CHUNK_ID_NULL) { /* No more work on this process */ /* Try to steal works to concurrent processes */ proc_work_reset(work); nthieves = mpi_steal_work(htrdr, rng_proc, work); if(nthieves != 0) { - mcode = proc_work_get_tile(work); + mcode = proc_work_get_chunk(work); } } } - if(mcode == TILE_MCODE_NULL) break; /* No more work */ + if(mcode == CHUNK_ID_NULL) break; /* No more work */ + ASSERT(mcode <= UINT32_MAX); /* Decode the morton code to retrieve the tile index */ - morton_xy_decode_u16(mcode, tile_org); + morton_xy_decode_u16((uint32_t)mcode, tile_org); ASSERT(tile_org[0] < ntiles_x && tile_org[1] < ntiles_y); /* Create the tile */ @@ -654,7 +442,7 @@ draw_map SSP(rng_proxy_create_rng(rng_proxy, 0, &rng)); /* Launch the tile rendering */ - res_local = draw_tile(htrdr, args, (size_t)ithread, mcode, + res_local = draw_tile(htrdr, args, (size_t)ithread, (uint32_t)mcode, tile_org, tile_sz, pix_sz, rng, tile); SSP(rng_proxy_ref_put(rng_proxy)); @@ -718,11 +506,12 @@ htrdr_draw_map size_t itile; struct proc_work work; size_t proc_ntiles_adjusted; + size_t remaining_tiles; double pix_sz[2]; ATOMIC probe_thieves = 1; ATOMIC res = RES_OK; - ASSERT(htrdr && check_draw_map_args(args)); + ASSERT(htrdr && check_draw_map_args(args) == RES_OK); ASSERT(htrdr->mpi_rank != 0 || buf); #ifndef NDEBUG @@ -752,9 +541,15 @@ htrdr_draw_map /* Define the initial number of tiles of the current process */ proc_ntiles_adjusted = ntiles_adjusted / (size_t)htrdr->mpi_nprocs; - if(htrdr->mpi_rank == 0) { /* Affect the remaining tiles to the master proc */ - proc_ntiles_adjusted += - ntiles_adjusted - proc_ntiles_adjusted*(size_t)htrdr->mpi_nprocs; + + remaining_tiles = + ntiles_adjusted - proc_ntiles_adjusted*(size_t)htrdr->mpi_nprocs; + + /* Distribute the remaining tiles among the processes. Each process whose + * rank is lower than the number of remaining tiles takes an additional + * tile */ + if((size_t)htrdr->mpi_rank < remaining_tiles) { + ++proc_ntiles_adjusted; } /* Define the initial list of tiles of the process */ @@ -765,9 +560,11 @@ htrdr_draw_map morton_xy_decode_u16(mcode, tile_org); if(tile_org[0] >= ntiles_x || tile_org[1] >= ntiles_y) continue; - proc_work_add_tile(&work, mcode); + proc_work_add_chunk(&work, mcode); } + /* On the master process, request and print the progress report, since the + * other processes have been able to start the calculation */ if(htrdr->mpi_rank == 0) { fetch_mpi_progress(htrdr, HTRDR_MPI_PROGRESS_RENDERING); print_mpi_progress(htrdr, HTRDR_MPI_PROGRESS_RENDERING); @@ -822,4 +619,3 @@ exit: error: goto exit; } - diff --git a/src/core/htrdr_draw_map.h b/src/core/htrdr_draw_map.h @@ -1,12 +1,12 @@ -/* Copyright (C) 2018-2019, 2022-2024 Centre National de la Recherche Scientifique +/* 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-2024 Institut Pierre-Simon Laplace - * Copyright (C) 2022-2024 Institut de Physique du Globe de Paris - * Copyright (C) 2018-2024 |Méso|Star> (contact@meso-star.com) - * Copyright (C) 2022-2024 Observatoire de Paris - * Copyright (C) 2022-2024 Université de Reims Champagne-Ardenne - * Copyright (C) 2022-2024 Université de Versaille Saint-Quentin - * Copyright (C) 2018-2019, 2022-2024 Université Paul Sabatier + * 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 diff --git a/src/core/htrdr_geometry.c b/src/core/htrdr_geometry.c @@ -1,12 +1,12 @@ -/* Copyright (C) 2018-2019, 2022-2024 Centre National de la Recherche Scientifique +/* 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-2024 Institut Pierre-Simon Laplace - * Copyright (C) 2022-2024 Institut de Physique du Globe de Paris - * Copyright (C) 2018-2024 |Méso|Star> (contact@meso-star.com) - * Copyright (C) 2022-2024 Observatoire de Paris - * Copyright (C) 2022-2024 Université de Reims Champagne-Ardenne - * Copyright (C) 2022-2024 Université de Versaille Saint-Quentin - * Copyright (C) 2018-2019, 2022-2024 Université Paul Sabatier + * 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 diff --git a/src/core/htrdr_geometry.h b/src/core/htrdr_geometry.h @@ -1,12 +1,12 @@ -/* Copyright (C) 2018-2019, 2022-2024 Centre National de la Recherche Scientifique +/* 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-2024 Institut Pierre-Simon Laplace - * Copyright (C) 2022-2024 Institut de Physique du Globe de Paris - * Copyright (C) 2018-2024 |Méso|Star> (contact@meso-star.com) - * Copyright (C) 2022-2024 Observatoire de Paris - * Copyright (C) 2022-2024 Université de Reims Champagne-Ardenne - * Copyright (C) 2022-2024 Université de Versaille Saint-Quentin - * Copyright (C) 2018-2019, 2022-2024 Université Paul Sabatier + * 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 diff --git a/src/core/htrdr_interface.h b/src/core/htrdr_interface.h @@ -1,12 +1,12 @@ -/* Copyright (C) 2018-2019, 2022-2024 Centre National de la Recherche Scientifique +/* 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-2024 Institut Pierre-Simon Laplace - * Copyright (C) 2022-2024 Institut de Physique du Globe de Paris - * Copyright (C) 2018-2024 |Méso|Star> (contact@meso-star.com) - * Copyright (C) 2022-2024 Observatoire de Paris - * Copyright (C) 2022-2024 Université de Reims Champagne-Ardenne - * Copyright (C) 2022-2024 Université de Versaille Saint-Quentin - * Copyright (C) 2018-2019, 2022-2024 Université Paul Sabatier + * 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 diff --git a/src/core/htrdr_log.c b/src/core/htrdr_log.c @@ -1,12 +1,12 @@ -/* Copyright (C) 2018-2019, 2022-2024 Centre National de la Recherche Scientifique +/* 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-2024 Institut Pierre-Simon Laplace - * Copyright (C) 2022-2024 Institut de Physique du Globe de Paris - * Copyright (C) 2018-2024 |Méso|Star> (contact@meso-star.com) - * Copyright (C) 2022-2024 Observatoire de Paris - * Copyright (C) 2022-2024 Université de Reims Champagne-Ardenne - * Copyright (C) 2022-2024 Université de Versaille Saint-Quentin - * Copyright (C) 2018-2019, 2022-2024 Université Paul Sabatier + * 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 @@ -33,25 +33,37 @@ static void print_out(const char* msg, void* ctx) { + struct htrdr* htrdr = ctx; ASSERT(msg); - (void)ctx; - fprintf(stderr, HTRDR_LOG_INFO_PREFIX"%s", msg); + + /* Log standard message only on master process */ + if(htrdr->verbose && htrdr->mpi_rank == 0) { + fprintf(stderr, HTRDR_LOG_INFO_PREFIX"%s", msg); + } } static void print_err(const char* msg, void* ctx) { + struct htrdr* htrdr = ctx; ASSERT(msg); - (void)ctx; - fprintf(stderr, HTRDR_LOG_ERROR_PREFIX"%s", msg); + + /* Log errors on all processes */ + if(htrdr->verbose) { + fprintf(stderr, HTRDR_LOG_ERROR_PREFIX"%s", msg); + } } static void print_warn(const char* msg, void* ctx) { - ASSERT(msg); - (void)ctx; - fprintf(stderr, HTRDR_LOG_WARNING_PREFIX"%s", msg); + struct htrdr* htrdr = ctx; + ASSERT(msg && ctx); + + /* Log warnings only on master process */ + if(htrdr->verbose && htrdr->mpi_rank == 0) { + fprintf(stderr, HTRDR_LOG_WARNING_PREFIX"%s", msg); + } } static void @@ -62,9 +74,7 @@ log_msg va_list vargs) { ASSERT(htrdr && msg); - if(htrdr->verbose) { - CHK(logger_vprint(&htrdr->logger, stream, msg, vargs) == RES_OK); - } + CHK(logger_vprint(&htrdr->logger, stream, msg, vargs) == RES_OK); } /******************************************************************************* @@ -73,14 +83,11 @@ log_msg void htrdr_log(struct htrdr* htrdr, const char* msg, ...) { + va_list vargs_list; ASSERT(htrdr && msg); - /* Log standard message only on master process */ - if(htrdr->mpi_rank == 0) { - va_list vargs_list; - va_start(vargs_list, msg); - log_msg(htrdr, LOG_OUTPUT, msg, vargs_list); - va_end(vargs_list); - } + va_start(vargs_list, msg); + log_msg(htrdr, LOG_OUTPUT, msg, vargs_list); + va_end(vargs_list); } void @@ -88,7 +95,6 @@ htrdr_log_err(struct htrdr* htrdr, const char* msg, ...) { va_list vargs_list; ASSERT(htrdr && msg); - /* Log errors on all processes */ va_start(vargs_list, msg); log_msg(htrdr, LOG_ERROR, msg, vargs_list); va_end(vargs_list); @@ -97,14 +103,11 @@ htrdr_log_err(struct htrdr* htrdr, const char* msg, ...) void htrdr_log_warn(struct htrdr* htrdr, const char* msg, ...) { + va_list vargs_list; ASSERT(htrdr && msg); - /* Log warnings only on master process */ - if(htrdr->mpi_rank == 0) { - va_list vargs_list; - va_start(vargs_list, msg); - log_msg(htrdr, LOG_WARNING, msg, vargs_list); - va_end(vargs_list); - } + va_start(vargs_list, msg); + log_msg(htrdr, LOG_WARNING, msg, vargs_list); + va_end(vargs_list); } /******************************************************************************* @@ -114,7 +117,7 @@ void setup_logger(struct htrdr* htrdr) { logger_init(htrdr->allocator, &htrdr->logger); - logger_set_stream(&htrdr->logger, LOG_OUTPUT, print_out, NULL); - logger_set_stream(&htrdr->logger, LOG_ERROR, print_err, NULL); - logger_set_stream(&htrdr->logger, LOG_WARNING, print_warn, NULL); + logger_set_stream(&htrdr->logger, LOG_OUTPUT, print_out, htrdr); + logger_set_stream(&htrdr->logger, LOG_ERROR, print_err, htrdr); + logger_set_stream(&htrdr->logger, LOG_WARNING, print_warn, htrdr); } diff --git a/src/core/htrdr_log.h b/src/core/htrdr_log.h @@ -1,12 +1,12 @@ -/* Copyright (C) 2018-2019, 2022-2024 Centre National de la Recherche Scientifique +/* 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-2024 Institut Pierre-Simon Laplace - * Copyright (C) 2022-2024 Institut de Physique du Globe de Paris - * Copyright (C) 2018-2024 |Méso|Star> (contact@meso-star.com) - * Copyright (C) 2022-2024 Observatoire de Paris - * Copyright (C) 2022-2024 Université de Reims Champagne-Ardenne - * Copyright (C) 2022-2024 Université de Versaille Saint-Quentin - * Copyright (C) 2018-2019, 2022-2024 Université Paul Sabatier + * 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 diff --git a/src/core/htrdr_materials.c b/src/core/htrdr_materials.c @@ -1,12 +1,12 @@ -/* Copyright (C) 2018-2019, 2022-2024 Centre National de la Recherche Scientifique +/* 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-2024 Institut Pierre-Simon Laplace - * Copyright (C) 2022-2024 Institut de Physique du Globe de Paris - * Copyright (C) 2018-2024 |Méso|Star> (contact@meso-star.com) - * Copyright (C) 2022-2024 Observatoire de Paris - * Copyright (C) 2022-2024 Université de Reims Champagne-Ardenne - * Copyright (C) 2022-2024 Université de Versaille Saint-Quentin - * Copyright (C) 2018-2019, 2022-2024 Université Paul Sabatier + * 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 diff --git a/src/core/htrdr_materials.h b/src/core/htrdr_materials.h @@ -1,12 +1,12 @@ -/* Copyright (C) 2018-2019, 2022-2024 Centre National de la Recherche Scientifique +/* 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-2024 Institut Pierre-Simon Laplace - * Copyright (C) 2022-2024 Institut de Physique du Globe de Paris - * Copyright (C) 2018-2024 |Méso|Star> (contact@meso-star.com) - * Copyright (C) 2022-2024 Observatoire de Paris - * Copyright (C) 2022-2024 Université de Reims Champagne-Ardenne - * Copyright (C) 2022-2024 Université de Versaille Saint-Quentin - * Copyright (C) 2018-2019, 2022-2024 Université Paul Sabatier + * 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 diff --git a/src/core/htrdr_proc_work.c b/src/core/htrdr_proc_work.c @@ -0,0 +1,267 @@ +/* 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/>. */ + +#define _POSIX_C_SOURCE 200112L /* nanosleep */ + +#include "core/htrdr_c.h" +#include "core/htrdr_proc_work.h" + +#include <star/ssp.h> + +#include <rsys/mutex.h> + +#include <time.h> + +/******************************************************************************* + * Helper functions + ******************************************************************************/ +/* Return the rank of a working process */ +static int +sample_working_process(struct htrdr* htrdr, struct ssp_rng* rng) +{ + int iproc, i; + int dst_rank; + ASSERT(htrdr && rng && htrdr->mpi_nworking_procs); + + /* Sample the index of the 1st active process */ + iproc = (int)(ssp_rng_canonical(rng) * (double)htrdr->mpi_nworking_procs); + + /* Find the rank of the sampled active process. Use a simple linear search + * since the overall number of processes should be quite low; at most few + * dozens. */ + i = 0; + FOR_EACH(dst_rank, 0, htrdr->mpi_nprocs) { + if(htrdr->mpi_working_procs[dst_rank] == 0) continue; /* Inactive process */ + if(i == iproc) break; /* The rank of the sampled process is found */ + ++i; + } + ASSERT(dst_rank < htrdr->mpi_nprocs); + return dst_rank; +} + +/******************************************************************************* + * Local functions + ******************************************************************************/ +void +proc_work_init(struct mem_allocator* allocator, struct proc_work* work) +{ + ASSERT(work); + darray_u64_init(allocator, &work->chunks); + work->index = 0; + CHK(work->mutex = mutex_create()); +} + +void +proc_work_release(struct proc_work* work) +{ + darray_u64_release(&work->chunks); + mutex_destroy(work->mutex); +} + +void +proc_work_reset(struct proc_work* work) +{ + ASSERT(work); + mutex_lock(work->mutex); + darray_u64_clear(&work->chunks); + work->index = 0; + mutex_unlock(work->mutex); +} + +void +proc_work_add_chunk(struct proc_work* work, const uint64_t ichunk) +{ + mutex_lock(work->mutex); + CHK(darray_u64_push_back(&work->chunks, &ichunk) == RES_OK); + mutex_unlock(work->mutex); +} + +uint64_t +proc_work_get_chunk(struct proc_work* work) +{ + uint64_t ichunk = CHUNK_ID_NULL; + ASSERT(work); + + mutex_lock(work->mutex); + if(work->index >= darray_u64_size_get(&work->chunks)) { + ichunk = CHUNK_ID_NULL; + } else { + ichunk = darray_u64_cdata_get(&work->chunks)[work->index]; + ++work->index; + } + mutex_unlock(work->mutex); + return ichunk; +} + +size_t +proc_work_get_nchunks(struct proc_work* work) +{ + size_t sz = 0; + ASSERT(work); + + mutex_lock(work->mutex); + sz = darray_u64_size_get(&work->chunks); + mutex_unlock(work->mutex); + return sz; +} + +void +mpi_wait_for_request(struct htrdr* htrdr, MPI_Request* req) +{ + ASSERT(htrdr && req); + + /* Wait for process synchronisation */ + for(;;) { + struct timespec t; + int complete; + t.tv_sec = 0; + t.tv_nsec = 10000000; /* 10ms */ + + mutex_lock(htrdr->mpi_mutex); + MPI(Test(req, &complete, MPI_STATUS_IGNORE)); + mutex_unlock(htrdr->mpi_mutex); + if(complete) break; + + nanosleep(&t, NULL); + } +} + +void +mpi_probe_thieves + (struct htrdr* htrdr, + struct proc_work* work, + ATOMIC* probe_thieves) +{ + uint64_t chunks[UINT8_MAX]; + struct timespec t; + ASSERT(htrdr && work && probe_thieves); + + if(htrdr->mpi_nprocs == 1) /* The process is alone. No thief is possible */ + return; + + t.tv_sec = 0; + + /* Protect MPI calls of multiple invocations from concurrent threads */ + #define P_MPI(Func) { \ + mutex_lock(htrdr->mpi_mutex); \ + MPI(Func); \ + mutex_unlock(htrdr->mpi_mutex); \ + } (void)0 + + while(ATOMIC_GET(probe_thieves)) { + MPI_Status status; + uint8_t i = 0; + int msg = 0; + + /* Probe if a steal request was submitted by any processes */ + P_MPI(Iprobe(MPI_ANY_SOURCE, HTRDR_MPI_STEAL_REQUEST, MPI_COMM_WORLD, &msg, + &status)); + + if(msg) { /* A steal request was posted */ + MPI_Request req; + uint8_t nchunks_to_steal; + + /* Asynchronously receive the steal request */ + P_MPI(Irecv(&nchunks_to_steal, 1, MPI_UINT8_T, status.MPI_SOURCE, + HTRDR_MPI_STEAL_REQUEST, MPI_COMM_WORLD, &req)); + + /* Wait for the completion of the steal request */ + mpi_wait_for_request(htrdr, &req); + + /* Thief some chunks */ + FOR_EACH(i, 0, nchunks_to_steal) { + chunks[i] = proc_work_get_chunk(work); + } + P_MPI(Send(&chunks, nchunks_to_steal, MPI_UINT64_T, status.MPI_SOURCE, + HTRDR_MPI_WORK_STEALING, MPI_COMM_WORLD)); + } + + /* Don't constantly check for thieves */ + t.tv_nsec = 10000000; /* 10ms */ + nanosleep(&t, NULL); + } + #undef P_MPI +} + +/* Return the number of stolen tiles */ +size_t +mpi_steal_work + (struct htrdr* htrdr, + struct ssp_rng* rng, + struct proc_work* work) +{ + MPI_Request req; + size_t nthieves = 0; + uint64_t chunks[UINT8_MAX]; /* Index of the stolen chunks */ + int proc_to_steal; /* Rank of the process to steal */ + + /* Empircally set the number of chunks to steal */ + const uint8_t nchunks_to_steal = MMIN((uint8_t)(htrdr->nthreads*4), 32); + uint8_t i = 0; + + ASSERT(htrdr && rng && work && htrdr->nthreads < UINT8_MAX); + + /* Protect MPI calls of multiple invocations from concurrent threads */ + #define P_MPI(Func) { \ + mutex_lock(htrdr->mpi_mutex); \ + MPI(Func); \ + mutex_unlock(htrdr->mpi_mutex); \ + } (void)0 + + /* No more working process => nothing to steal */ + if(!htrdr->mpi_nworking_procs) return 0; + + /* Sample a process to steal */ + proc_to_steal = sample_working_process(htrdr, rng); + + /* Send a steal request to the sampled process and wait for a response */ + P_MPI(Send(&nchunks_to_steal, 1, MPI_UINT8_T, proc_to_steal, + HTRDR_MPI_STEAL_REQUEST, MPI_COMM_WORLD)); + + /* Receive the stolen chunks from the sampled process */ + P_MPI(Irecv(chunks, nchunks_to_steal, MPI_UINT64_T, proc_to_steal, + HTRDR_MPI_WORK_STEALING, MPI_COMM_WORLD, &req)); + + mpi_wait_for_request(htrdr, &req); + + FOR_EACH(i, 0, nchunks_to_steal) { + + if(chunks[i] != CHUNK_ID_NULL) { + /* Save stolen chunk in job list */ + proc_work_add_chunk(work, chunks[i]); + ++nthieves; + + } else { + /* The process has returned at least one invalid chunk, + * i.e. it has nothing further to do. + * Remove it from the working process */ + ASSERT(htrdr->mpi_working_procs[proc_to_steal] != 0); + htrdr->mpi_working_procs[proc_to_steal] = 0; + htrdr->mpi_nworking_procs--; + + break; /* No more to steal */ + } + } + #undef P_MPI + return nthieves; +} diff --git a/src/core/htrdr_proc_work.h b/src/core/htrdr_proc_work.h @@ -0,0 +1,94 @@ +/* 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/>. */ + +#ifndef HTRDR_PROC_WORK_H +#define HTRDR_PROC_WORK_H + +#include <rsys/dynamic_array_u64.h> + +#include <mpi.h> + +#define CHUNK_ID_NULL UINT64_MAX + +/* Forward declarations */ +struct mutex; +struct ssp_rng; + +/* List of chunks to compute onto the MPI process */ +struct proc_work { + struct mutex* mutex; + struct darray_u64 chunks; /* #chunks to solve */ + uint64_t index; /* Next chunk to solve in the above list of chunks */ +}; + +extern LOCAL_SYM void +proc_work_init + (struct mem_allocator* allocator, + struct proc_work* work); + +extern LOCAL_SYM void +proc_work_release + (struct proc_work* work); + +extern LOCAL_SYM void +proc_work_reset + (struct proc_work* work); + +extern LOCAL_SYM void +proc_work_add_chunk + (struct proc_work* work, + const uint64_t ichunk); + +/* Return the index of the next chunk to be processed */ +extern LOCAL_SYM uint64_t +proc_work_get_chunk + (struct proc_work* work); + +extern LOCAL_SYM uint64_t +proc_work_get_nchunks + (struct proc_work* work); + +/* Wait for the completion of an MPI request */ +extern LOCAL_SYM void +mpi_wait_for_request + (struct htrdr* htrdr, + MPI_Request* req); + +/* Active polling of the "steal" request submitted by other processes to + * relieve the current process of the chunks assigned to it. + * The function runs until probe_thieves is set to 0 by the caller. */ +extern LOCAL_SYM void +mpi_probe_thieves + (struct htrdr* htrdr, + struct proc_work* work, + ATOMIC* probe_thieves); + +/* Unload a working process by taking chunks from it, + * i.e. submit a steal request and wait for it to be honored */ +extern LOCAL_SYM size_t +mpi_steal_work + (struct htrdr* htrdr, + struct ssp_rng* rng, + struct proc_work* work); + +#endif /* HTRDR_PROC_WORK_H */ diff --git a/src/core/htrdr_ran_wlen_cie_xyz.c b/src/core/htrdr_ran_wlen_cie_xyz.c @@ -1,12 +1,12 @@ -/* Copyright (C) 2018-2019, 2022-2024 Centre National de la Recherche Scientifique +/* 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-2024 Institut Pierre-Simon Laplace - * Copyright (C) 2022-2024 Institut de Physique du Globe de Paris - * Copyright (C) 2018-2024 |Méso|Star> (contact@meso-star.com) - * Copyright (C) 2022-2024 Observatoire de Paris - * Copyright (C) 2022-2024 Université de Reims Champagne-Ardenne - * Copyright (C) 2022-2024 Université de Versaille Saint-Quentin - * Copyright (C) 2018-2019, 2022-2024 Université Paul Sabatier + * 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 diff --git a/src/core/htrdr_ran_wlen_cie_xyz.h b/src/core/htrdr_ran_wlen_cie_xyz.h @@ -1,12 +1,12 @@ -/* Copyright (C) 2018-2019, 2022-2024 Centre National de la Recherche Scientifique +/* 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-2024 Institut Pierre-Simon Laplace - * Copyright (C) 2022-2024 Institut de Physique du Globe de Paris - * Copyright (C) 2018-2024 |Méso|Star> (contact@meso-star.com) - * Copyright (C) 2022-2024 Observatoire de Paris - * Copyright (C) 2022-2024 Université de Reims Champagne-Ardenne - * Copyright (C) 2022-2024 Université de Versaille Saint-Quentin - * Copyright (C) 2018-2019, 2022-2024 Université Paul Sabatier + * 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 diff --git a/src/core/htrdr_ran_wlen_discrete.c b/src/core/htrdr_ran_wlen_discrete.c @@ -1,12 +1,12 @@ -/* Copyright (C) 2018-2019, 2022-2024 Centre National de la Recherche Scientifique +/* 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-2024 Institut Pierre-Simon Laplace - * Copyright (C) 2022-2024 Institut de Physique du Globe de Paris - * Copyright (C) 2018-2024 |Méso|Star> (contact@meso-star.com) - * Copyright (C) 2022-2024 Observatoire de Paris - * Copyright (C) 2022-2024 Université de Reims Champagne-Ardenne - * Copyright (C) 2022-2024 Université de Versaille Saint-Quentin - * Copyright (C) 2018-2019, 2022-2024 Université Paul Sabatier + * 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 @@ -239,8 +239,10 @@ htrdr_ran_wlen_discrete_create res = setup_per_wlen_radiance(ran, args); if(res != RES_OK) goto error; - res = setup_distribution(ran, args); - if(res != RES_OK) goto error; + if(ran->nbands != 0) { + res = setup_distribution(ran, args); + if(res != RES_OK) goto error; + } exit: *out_ran = ran; @@ -271,42 +273,53 @@ htrdr_ran_wlen_discrete_sample const double r1, double* pdf) /* In nm⁻¹ */ { - double* find = NULL; - const double* proba = NULL; - const double* cumul = NULL; - const double* wlens = NULL; - double w0, w1; /* Wavelengths of the sampled band in nm */ - double lambda; /* Sampled wavelength in nm */ - size_t iband = 0; - double r0_next = nextafter(r0, DBL_MAX); + double lambda = 0; + + ASSERT(ran); ASSERT(0 <= r0 && r0 < 1); ASSERT(0 <= r1 && r1 < 1); - cumul = darray_double_cdata_get(&ran->cumul); - proba = darray_double_cdata_get(&ran->proba); - wlens = darray_double_cdata_get(&ran->wlens); - - /* Sample a band. Use r0_next rather than r0 to find the first entry that is - * not less than *or equal* to r0 */ - find = search_lower_bound - (&r0_next, cumul, ran->nbands, sizeof(double), cmp_dbl); - ASSERT(find); - - iband = (size_t)(find - cumul); - ASSERT(iband < ran->nbands); - ASSERT(cumul[iband] > r0 && (!iband || cumul[iband-1] <= r0)); - - /* Retrieve the boundaries of the sampled band */ - w0 = wlens[iband+0]; - w1 = wlens[iband+1]; - - /* Uniformely sample the wavelength in [w0, w1[ */ - lambda = w0 + r1 * (w1 - w0); - - if(pdf) { - const double pdf_wlen = 1.f / (w1-w0); - *pdf = proba[iband] * pdf_wlen; + if(ran->nbands == 0) { + ASSERT(darray_double_size_get(&ran->wlens) == 1); + lambda = darray_double_cdata_get(&ran->wlens)[0]; + if(pdf) *pdf = 1; + + } else { + double* find = NULL; + const double* proba = NULL; + const double* cumul = NULL; + const double* wlens = NULL; + double w0, w1; /* Wavelengths of the sampled band in nm */ + size_t iband = 0; + double r0_next = nextafter(r0, DBL_MAX); + ASSERT(0 <= r0 && r0 < 1); + ASSERT(0 <= r1 && r1 < 1); + + cumul = darray_double_cdata_get(&ran->cumul); + proba = darray_double_cdata_get(&ran->proba); + wlens = darray_double_cdata_get(&ran->wlens); + + /* Sample a band. Use r0_next rather than r0 to find the first entry that is + * not less than *or equal* to r0 */ + find = search_lower_bound + (&r0_next, cumul, ran->nbands, sizeof(double), cmp_dbl); + ASSERT(find); + + iband = (size_t)(find - cumul); + ASSERT(iband < ran->nbands); + ASSERT(cumul[iband] > r0 && (!iband || cumul[iband-1] <= r0)); + + /* Retrieve the boundaries of the sampled band */ + w0 = wlens[iband+0]; + w1 = wlens[iband+1]; + + /* Uniformely sample the wavelength in [w0, w1[ */ + lambda = w0 + r1 * (w1 - w0); + + if(pdf) { + const double pdf_wlen = 1.f / (w1-w0); + *pdf = proba[iband] * pdf_wlen; + } } - return lambda; } diff --git a/src/core/htrdr_ran_wlen_discrete.h b/src/core/htrdr_ran_wlen_discrete.h @@ -1,12 +1,12 @@ -/* Copyright (C) 2018-2019, 2022-2024 Centre National de la Recherche Scientifique +/* 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-2024 Institut Pierre-Simon Laplace - * Copyright (C) 2022-2024 Institut de Physique du Globe de Paris - * Copyright (C) 2018-2024 |Méso|Star> (contact@meso-star.com) - * Copyright (C) 2022-2024 Observatoire de Paris - * Copyright (C) 2022-2024 Université de Reims Champagne-Ardenne - * Copyright (C) 2022-2024 Université de Versaille Saint-Quentin - * Copyright (C) 2018-2019, 2022-2024 Université Paul Sabatier + * 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 diff --git a/src/core/htrdr_ran_wlen_planck.c b/src/core/htrdr_ran_wlen_planck.c @@ -1,12 +1,12 @@ -/* Copyright (C) 2018-2019, 2022-2024 Centre National de la Recherche Scientifique +/* 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-2024 Institut Pierre-Simon Laplace - * Copyright (C) 2022-2024 Institut de Physique du Globe de Paris - * Copyright (C) 2018-2024 |Méso|Star> (contact@meso-star.com) - * Copyright (C) 2022-2024 Observatoire de Paris - * Copyright (C) 2022-2024 Université de Reims Champagne-Ardenne - * Copyright (C) 2022-2024 Université de Versaille Saint-Quentin - * Copyright (C) 2018-2019, 2022-2024 Université Paul Sabatier + * 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 diff --git a/src/core/htrdr_ran_wlen_planck.h b/src/core/htrdr_ran_wlen_planck.h @@ -1,12 +1,12 @@ -/* Copyright (C) 2018-2019, 2022-2024 Centre National de la Recherche Scientifique +/* 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-2024 Institut Pierre-Simon Laplace - * Copyright (C) 2022-2024 Institut de Physique du Globe de Paris - * Copyright (C) 2018-2024 |Méso|Star> (contact@meso-star.com) - * Copyright (C) 2022-2024 Observatoire de Paris - * Copyright (C) 2022-2024 Université de Reims Champagne-Ardenne - * Copyright (C) 2022-2024 Université de Versaille Saint-Quentin - * Copyright (C) 2018-2019, 2022-2024 Université Paul Sabatier + * 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 diff --git a/src/core/htrdr_rectangle.c b/src/core/htrdr_rectangle.c @@ -1,12 +1,12 @@ -/* Copyright (C) 2018-2019, 2022-2024 Centre National de la Recherche Scientifique +/* 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-2024 Institut Pierre-Simon Laplace - * Copyright (C) 2022-2024 Institut de Physique du Globe de Paris - * Copyright (C) 2018-2024 |Méso|Star> (contact@meso-star.com) - * Copyright (C) 2022-2024 Observatoire de Paris - * Copyright (C) 2022-2024 Université de Reims Champagne-Ardenne - * Copyright (C) 2022-2024 Université de Versaille Saint-Quentin - * Copyright (C) 2018-2019, 2022-2024 Université Paul Sabatier + * 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 diff --git a/src/core/htrdr_rectangle.h b/src/core/htrdr_rectangle.h @@ -1,12 +1,12 @@ -/* Copyright (C) 2018-2019, 2022-2024 Centre National de la Recherche Scientifique +/* 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-2024 Institut Pierre-Simon Laplace - * Copyright (C) 2022-2024 Institut de Physique du Globe de Paris - * Copyright (C) 2018-2024 |Méso|Star> (contact@meso-star.com) - * Copyright (C) 2022-2024 Observatoire de Paris - * Copyright (C) 2022-2024 Université de Reims Champagne-Ardenne - * Copyright (C) 2022-2024 Université de Versaille Saint-Quentin - * Copyright (C) 2018-2019, 2022-2024 Université Paul Sabatier + * 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 diff --git a/src/core/htrdr_sensor.h b/src/core/htrdr_sensor.h @@ -1,12 +1,12 @@ -/* Copyright (C) 2018-2019, 2022-2024 Centre National de la Recherche Scientifique +/* 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-2024 Institut Pierre-Simon Laplace - * Copyright (C) 2022-2024 Institut de Physique du Globe de Paris - * Copyright (C) 2018-2024 |Méso|Star> (contact@meso-star.com) - * Copyright (C) 2022-2024 Observatoire de Paris - * Copyright (C) 2022-2024 Université de Reims Champagne-Ardenne - * Copyright (C) 2022-2024 Université de Versaille Saint-Quentin - * Copyright (C) 2018-2019, 2022-2024 Université Paul Sabatier + * 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 diff --git a/src/core/htrdr_slab.c b/src/core/htrdr_slab.c @@ -1,12 +1,12 @@ -/* Copyright (C) 2018-2019, 2022-2024 Centre National de la Recherche Scientifique +/* 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-2024 Institut Pierre-Simon Laplace - * Copyright (C) 2022-2024 Institut de Physique du Globe de Paris - * Copyright (C) 2018-2024 |Méso|Star> (contact@meso-star.com) - * Copyright (C) 2022-2024 Observatoire de Paris - * Copyright (C) 2022-2024 Université de Reims Champagne-Ardenne - * Copyright (C) 2022-2024 Université de Versaille Saint-Quentin - * Copyright (C) 2018-2019, 2022-2024 Université Paul Sabatier + * 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 diff --git a/src/core/htrdr_slab.h b/src/core/htrdr_slab.h @@ -1,12 +1,12 @@ -/* Copyright (C) 2018-2019, 2022-2024 Centre National de la Recherche Scientifique +/* 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-2024 Institut Pierre-Simon Laplace - * Copyright (C) 2022-2024 Institut de Physique du Globe de Paris - * Copyright (C) 2018-2024 |Méso|Star> (contact@meso-star.com) - * Copyright (C) 2022-2024 Observatoire de Paris - * Copyright (C) 2022-2024 Université de Reims Champagne-Ardenne - * Copyright (C) 2022-2024 Université de Versaille Saint-Quentin - * Copyright (C) 2018-2019, 2022-2024 Université Paul Sabatier + * 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 diff --git a/src/core/htrdr_solve_buffer.c b/src/core/htrdr_solve_buffer.c @@ -0,0 +1,593 @@ +/* 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/>. */ + +#include "core/htrdr.h" +#include "core/htrdr_c.h" +#include "core/htrdr_buffer.h" +#include "core/htrdr_proc_work.h" +#include "core/htrdr_log.h" +#include "core/htrdr_solve_buffer.h" + +#include <rsys/clock_time.h> +#include <rsys/cstr.h> +#include <rsys/list.h> +#include <rsys/math.h> +#include <rsys/mutex.h> +#include <rsys/ref_count.h> + +#include <star/ssp.h> + +#include <mpi.h> +#include <omp.h> + +#define CHUNK_SIZE 32 /* Number of items in one chunk */ + +/* Collection of items */ +struct chunk { + struct list_node node; + struct mem_allocator* allocator; + ref_T ref; + + struct chunk_data { + size_t item_sz; /* Size of an item */ + size_t item_al; /* Item alignment */ + uint64_t index; /* Chunk index in chunk space */ + /* Simulate the flexible array member of the C99 standard */ + char ALIGN(16) items[1/*Dummy*/]; + } data; +}; + +/******************************************************************************* + * Helper functions + ******************************************************************************/ +static INLINE res_T +check_solve_buffer_args(const struct htrdr_solve_buffer_args* args) +{ + if(!args) return RES_BAD_ARG; + + /* A functor must be defined */ + if(!args->solve_item) return RES_BAD_ARG; + + /* The number of realisations cannot be null */ + if(!args->nrealisations) return RES_BAD_ARG; + + /* The buffer must in one-dimensional */ + if(args->buffer_layout.height != 1) return RES_BAD_ARG; + + /* Check buffer layout consistency */ + return htrdr_buffer_layout_check(&args->buffer_layout); +} + +static INLINE void +release_chunk(ref_T* ref) +{ + struct chunk* chunk = CONTAINER_OF(ref, struct chunk, ref); + ASSERT(ref); + MEM_RM(chunk->allocator, chunk); +} + +static INLINE void +chunk_ref_get(struct chunk* chunk) +{ + ASSERT(chunk); + ref_get(&chunk->ref); +} + +static INLINE void +chunk_ref_put(struct chunk* chunk) +{ + ASSERT(chunk); + ref_put(&chunk->ref, release_chunk); +} + +static FINLINE struct chunk* +chunk_create + (struct mem_allocator* allocator, + const size_t item_sz, /* Size in bytes */ + const size_t item_al, /* Alignment in bytes */ + const uint64_t ichunk) /* Chunk index */ +{ + struct chunk* chunk = NULL; + const size_t header_sz = sizeof(*chunk) - 1/*dummy octet in flexible array*/; + const size_t buf_sz = CHUNK_SIZE*item_sz; + + /* Pre conditions */ + ASSERT(allocator); + ASSERT(IS_ALIGNED(item_sz, item_al)); + ASSERT(IS_POW2(item_al)); + + chunk = MEM_ALLOC_ALIGNED(allocator, header_sz + buf_sz, 16); + if(!chunk) goto error; + ref_init(&chunk->ref); + list_init(&chunk->node); + chunk->allocator = allocator; + chunk->data.item_sz = item_sz; + chunk->data.item_al = item_al; + chunk->data.index = ichunk; + CHK(IS_ALIGNED(chunk->data.items, item_al)); + +exit: + return chunk; +error: + if(chunk) { chunk_ref_put(chunk); chunk = NULL; } + goto exit; +} + +static FINLINE void* +chunk_at(struct chunk* chunk, const size_t i) +{ + ASSERT(chunk && i < CHUNK_SIZE); + return (void*)(chunk->data.items + i*chunk->data.item_sz); +} + +static void +release_chunk_list(struct list_node* chunks) +{ + struct list_node* node = NULL; + struct list_node* tmp = NULL; + ASSERT(chunks); + + LIST_FOR_EACH_SAFE(node, tmp, chunks) { + struct chunk* chunk = CONTAINER_OF(node, struct chunk, node); + list_del(node); + chunk_ref_put(chunk); + } +} + +static INLINE uint64_t +get_chunk + (struct htrdr* htrdr, + struct ssp_rng* rng, + struct proc_work* work) +{ + uint64_t ichunk = CHUNK_ID_NULL; + + /* Make the function critical, as the entire process must be executed + * atomically. Indeed, the first thread to query an invalid chunk steals work + * from other processes. So, when the function exits, the other threads will + * have valid chunks */ + #pragma omp critical + { + ichunk = proc_work_get_chunk(work); + if(ichunk == CHUNK_ID_NULL) { /* No more work on this process */ + size_t nthieves = 0; + + proc_work_reset(work); + nthieves = mpi_steal_work(htrdr, rng, work); + if(nthieves != 0) { + ichunk = proc_work_get_chunk(work); + } + } + } + + return ichunk; +} + +static INLINE void +status_update(struct htrdr* htrdr, const int32_t progress) +{ + ASSERT(htrdr); + + #pragma omp critical + if(progress > htrdr->mpi_progress_render[0]) { + htrdr->mpi_progress_render[0] = progress; + + /* Print update on master process */ + if(htrdr->mpi_rank == 0) { + update_mpi_progress(htrdr, HTRDR_MPI_PROGRESS_RENDERING); + + /* Send the progress percentage to the master process */ + } else { + send_mpi_progress(htrdr, HTRDR_MPI_PROGRESS_RENDERING, progress); + } + } +} + +static struct ssp_rng* +rng_create + (struct htrdr* htrdr, + const size_t ithread, + const size_t nchunks, + const uint64_t ichunk) +{ + struct ssp_rng_proxy_create2_args args = SSP_RNG_PROXY_CREATE2_ARGS_NULL; + struct ssp_rng_proxy* proxy = NULL; + struct ssp_rng* rng = NULL; + struct mem_allocator* allocator = NULL; + ASSERT(htrdr); + + allocator = htrdr_get_thread_allocator(htrdr, (size_t)ithread); + + args.type = SSP_RNG_THREEFRY; + args.sequence_offset = RNG_SEQUENCE_SIZE * (size_t)ichunk; + args.sequence_size = RNG_SEQUENCE_SIZE; + args.sequence_pitch = RNG_SEQUENCE_SIZE * nchunks; + args.nbuckets = 1; + SSP(rng_proxy_create2(allocator, &args, &proxy)); + SSP(rng_proxy_create_rng(proxy, 0, &rng)); + SSP(rng_proxy_ref_put(proxy)); + + return rng; +} + +static void +write_chunk_data + (struct htrdr* htrdr, + struct htrdr_buffer* buf, + const struct chunk_data* chunk_data) +{ + struct htrdr_buffer_layout layout = HTRDR_BUFFER_LAYOUT_NULL; + char* mem = NULL; + size_t iitem = 0; + size_t nitems = 0; + + ASSERT(htrdr && buf && chunk_data); + ASSERT(chunk_data->index != CHUNK_ID_NULL); + (void)htrdr; + + htrdr_buffer_get_layout(buf, &layout); + ASSERT(layout.height == 1); + ASSERT(layout.elmt_size == chunk_data->item_sz); + + /* Calculate the index of the first item to write */ + iitem = chunk_data->index * CHUNK_SIZE; + + /* Define the number of items to write into the buffer */ + nitems = MMIN(iitem + CHUNK_SIZE, layout.width) - iitem; + + /* Calculate destination address for writing chunk data */ + mem = htrdr_buffer_get_data(buf); + mem = mem + iitem*layout.elmt_size; + + /* Write the chunk items into the buffer */ + memcpy(mem, chunk_data->items, nitems*layout.elmt_size); +} + +static res_T +mpi_gather_chunks + (struct htrdr* htrdr, + const struct htrdr_buffer_layout* layout, + struct htrdr_buffer* buf, /* Can be NULL for non master processes */ + const size_t nchunks, + struct list_node* chunks) +{ + size_t msg_sz = 0; + struct list_node* node = NULL; + struct chunk* chunk = NULL; /* Temporary chunk */ + res_T res = RES_OK; + + /* Pre conditions */ + ASSERT(htrdr && layout && chunks); + ASSERT(layout->height == 1); + ASSERT(htrdr_buffer_layout_check(layout) == RES_OK); + + /* Compute the size of chunk data */ + msg_sz = sizeof(struct chunk_data) + + CHUNK_SIZE*layout->elmt_size + -1 /* Dummy octet of the flexible array */; + ASSERT(msg_sz <= INT_MAX); + + /* Non master process: Send the computed chunk to the master process */ + if(htrdr->mpi_rank != 0) { + LIST_FOR_EACH(node, chunks) { + struct chunk* c = CONTAINER_OF(node, struct chunk, node); + MPI(Send(&c->data, (int)msg_sz, MPI_CHAR, 0/*Master process*/, + HTRDR_MPI_CHUNK_DATA, MPI_COMM_WORLD)); + } + + /* Master rrocess */ + } else { + size_t ichunk = 0; + ASSERT(buf); + +#ifndef NDEBUG + /* Check that the submitted buffer layout matches the buffer layout */ + { + struct htrdr_buffer_layout buf_layout = HTRDR_BUFFER_LAYOUT_NULL; + htrdr_buffer_get_layout(buf, &buf_layout); + ASSERT(htrdr_buffer_layout_eq(&buf_layout, layout)); + } +#endif + + /* Write data for chunks resolved by the master process */ + LIST_FOR_EACH(node, chunks) { + struct chunk* c = CONTAINER_OF(node, struct chunk, node); + write_chunk_data(htrdr, buf, &c->data); + ++ichunk; + } + + /* There are chunks unresolved by the master process */ + if(ichunk != nchunks) { + ASSERT(htrdr->mpi_nprocs > 1); + + /* Create a temporary chunk to receive the chunk data computed by the + * non master processes */ + chunk = chunk_create + (htrdr->allocator, + layout->elmt_size, + layout->alignment, + CHUNK_ID_NULL); /* Dummy chunk id that is going to be overwritten */ + if(!chunk) goto error; + } + + /* Gather chunks sent by non master processes */ + FOR_EACH(ichunk, ichunk, nchunks) { + MPI(Recv(&chunk->data, (int)msg_sz, MPI_CHAR, MPI_ANY_SOURCE, + HTRDR_MPI_CHUNK_DATA, MPI_COMM_WORLD, MPI_STATUS_IGNORE)); + write_chunk_data(htrdr, buf, &chunk->data); + } + } + +exit: + if(chunk) chunk_ref_put(chunk); + return res; +error: + htrdr_log_err(htrdr, "Error while gathering results -- %s\n", + res_to_cstr(res)); + goto exit; +} + +static res_T +solve_chunk + (struct htrdr* htrdr, + const struct htrdr_solve_buffer_args* args, + const size_t ithread, + const uint64_t ichunk, + struct ssp_rng* rng, + struct chunk* chunk) +{ + struct htrdr_solve_item_args item_args = HTRDR_SOLVE_ITEM_ARGS_NULL; + size_t i = 0; + size_t nitems = 0; + + ASSERT(htrdr && args && rng && chunk); + ASSERT(args->buffer_layout.height == 1); + ASSERT(ichunk * CHUNK_SIZE < args->buffer_layout.width); + + nitems = args->buffer_layout.width; + + /* Setup the shared item arguments */ + item_args.rng = rng; + item_args.nrealisations = args->nrealisations; + item_args.ithread = ithread; + item_args.context = args->context; + + FOR_EACH(i, 0, CHUNK_SIZE) { + void* item = NULL; + size_t item_id = ichunk*CHUNK_SIZE + i; + + if(item_id >= nitems) { + /* The item is out of the range, + * i.e. we've reached the total number of items to solve */ + break; + } + + /* Fetch the item */ + item = chunk_at(chunk, i); + + /* Setup the item index */ + item_args.item_id = item_id; + + /* Solve the item */ + args->solve_item(htrdr, &item_args, item); + } + return RES_OK; +} + +static res_T +solve_buffer + (struct htrdr* htrdr, + const struct htrdr_solve_buffer_args* args, + const size_t nchunks, /* Total #chunks distributed between processes */ + struct proc_work* work, + struct list_node* chunks) +{ + struct ssp_rng* rng_proc = NULL; /* Used to sample a working process */ + size_t nchunks_proc = 0; /* #chunks of the process */ + size_t nthreads = 0; /* #threads to use */ + ATOMIC nchunks_solved = 0; /* #chunks solved bu the process */ + ATOMIC res = RES_OK; + + /* Pre-conditions */ + ASSERT(htrdr && args && work && chunks); + + res = ssp_rng_create(htrdr->allocator, SSP_RNG_MT19937_64, &rng_proc); + if(res != RES_OK) goto error; + + nchunks_proc = proc_work_get_nchunks(work); + nthreads = MMIN(htrdr->nthreads, nchunks_proc); + + /* The process is not considered as a working process for himself */ + htrdr->mpi_working_procs[htrdr->mpi_rank] = 0; + --htrdr->mpi_nworking_procs; + + omp_set_num_threads((int)nthreads); + #pragma omp parallel + for(;;) { + /* Chunk */ + uint64_t ichunk = get_chunk(htrdr, rng_proc, work); + struct chunk* chunk = NULL; + + /* Miscellaneous */ + const size_t ithread = (size_t)omp_get_thread_num(); + struct ssp_rng* rng = NULL; + size_t n = 0; + int32_t pcent = 0; + res_T res_local = RES_OK; + + if(ichunk == CHUNK_ID_NULL) break; /* No more work */ + + chunk = chunk_create + (htrdr->allocator, + args->buffer_layout.elmt_size, + args->buffer_layout.alignment, + ichunk); + if(!chunk) { + ATOMIC_SET(&res, RES_MEM_ERR); + break; + } + + #pragma omp critical + list_add_tail(chunks, &chunk->node); /* Register the chunk */ + + rng = rng_create(htrdr, ithread, nchunks, ichunk); + res_local = solve_chunk(htrdr, args, ithread, ichunk, rng, chunk); + + SSP(rng_ref_put(rng)); + if(res_local != RES_OK) { + ATOMIC_SET(&res, res_local); + break; + } + + /* Status update */ + n = (size_t)ATOMIC_INCR(&nchunks_solved); + pcent = (int32_t)((double)n * 100.0 / (double)nchunks_proc + 0.5/*round*/); + status_update(htrdr, pcent); + } + + if(ATOMIC_GET(&res) != RES_OK) goto error; + + /* Asynchronously wait for processes completion. Use an asynchronous barrier to + * avoid a dead lock with the `mpi_probe_thieves' thread that requires also + * the `mpi_mutex'. */ + { + MPI_Request req; + + mutex_lock(htrdr->mpi_mutex); + MPI(Ibarrier(MPI_COMM_WORLD, &req)); + mutex_unlock(htrdr->mpi_mutex); + + mpi_wait_for_request(htrdr, &req); + } + +exit: + if(rng_proc) SSP(rng_ref_put(rng_proc)); + return (res_T)res; +error: + htrdr_log_err(htrdr, "Error while solving buffer -- %s\n", + res_to_cstr((res_T)res)); + goto exit; +} + +/******************************************************************************* + * Local functions + ******************************************************************************/ +res_T +htrdr_solve_buffer + (struct htrdr* htrdr, + const struct htrdr_solve_buffer_args* args, + struct htrdr_buffer* buf) +{ + /* Time registration */ + char strbuf[128]; + struct time t0, t1; + + /* Chunks */ + struct list_node chunks; /* List of solved chunks */ + size_t nchunks = 0; /* Overall number of chunks */ + size_t nchunks_proc = 0; /* #chunks for the current proc*/ + size_t nchunks_remain = 0; /* Remaining #chunks to distribute between procs */ + + /* Miscellaneous */ + struct proc_work work; + size_t nitems = 0; /* Number of Monte Carlo estimations */ + size_t i = 0; + ATOMIC probe_thieves = 1; /* Boolean that controls thieves' polling */ + + res_T res = RES_OK; + ASSERT(htrdr && check_solve_buffer_args(args) == RES_OK); + ASSERT(htrdr->mpi_rank != 0 || buf); + + list_init(&chunks); + proc_work_init(htrdr->allocator, &work); + + nitems = args->buffer_layout.width; + nchunks = (nitems + (CHUNK_SIZE-1)/*ceil*/) / CHUNK_SIZE; + nchunks_proc = nchunks / (size_t)htrdr->mpi_nprocs; + nchunks_remain = nchunks - nchunks_proc*(size_t)htrdr->mpi_nprocs; + + /* Distribute the remaining chunks among the processes. Each process whose + * rank is lower than the number of remaining chunks takes an additional + * chunk */ + if((size_t)htrdr->mpi_rank < nchunks_remain) { + ++nchunks_proc; + } + + /* Register the list of chunks to be processed by the current process */ + FOR_EACH(i, 0, nchunks_proc) { + size_t ichunk = i * (size_t)htrdr->mpi_nprocs + (size_t)htrdr->mpi_rank; + proc_work_add_chunk(&work, (uint64_t)ichunk); + } + + /* On the master process, request and print the progress report, since the + * other processes have been able to start the calculation */ + if(htrdr->mpi_rank == 0) { + fetch_mpi_progress(htrdr, HTRDR_MPI_PROGRESS_RENDERING); + print_mpi_progress(htrdr, HTRDR_MPI_PROGRESS_RENDERING); + } + + /* Start of calculation time recording */ + time_current(&t0); + + /* Enable nested threads to enable parallelization of the solve function */ + omp_set_nested(1); + + #pragma omp parallel sections num_threads(2) + { + /* Polling of steal queries */ + #pragma omp section + mpi_probe_thieves(htrdr, &work, &probe_thieves); + + #pragma omp section + { + solve_buffer(htrdr, args, nchunks, &work, &chunks); + /* The process have no more work to do. Stop polling for thieves */ + ATOMIC_SET(&probe_thieves, 0); + } + } + + if(htrdr->mpi_rank == 0) { + update_mpi_progress(htrdr, HTRDR_MPI_PROGRESS_RENDERING); + htrdr_log(htrdr, "\n"); /* Add a new line after the progress statuses */ + } + + /* Stop time recording */ + time_sub(&t0, time_current(&t1), &t0); + time_dump(&t0, TIME_ALL, NULL, strbuf, sizeof(strbuf)); + htrdr_log(htrdr, "Calculation time: %s\n", strbuf); + + /* Gather chunks on master process */ + time_current(&t0); + res = mpi_gather_chunks(htrdr, &args->buffer_layout, buf, nchunks, &chunks); + if(res != RES_OK) goto error; + time_sub(&t0, time_current(&t1), &t0); + time_dump(&t0, TIME_ALL, NULL, strbuf, sizeof(strbuf)); + htrdr_log(htrdr, "Time to gather results: %s\n", strbuf); + +exit: + release_chunk_list(&chunks); + proc_work_release(&work); + return res; +error: + goto exit; +} diff --git a/src/core/htrdr_solve_buffer.h b/src/core/htrdr_solve_buffer.h @@ -0,0 +1,72 @@ +/* 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/>. */ + +#ifndef HTRDR_SOLVE_BUFFER_H +#define HTRDR_SOLVE_BUFFER_H + +struct htrdr_solve_item_args { + struct ssp_rng* rng; /* Random Number Generator */ + size_t item_id; /* Index of the item */ + size_t nrealisations; /* #realisations to estimate the item */ + size_t ithread; /* Id of the thread solving the item */ + void* context; /* User defined data */ +}; +#define HTRDR_SOLVE_ITEM_ARGS_NULL__ {NULL, 0, 0, 0, NULL} +static const struct htrdr_solve_item_args HTRDR_SOLVE_ITEM_ARGS_NULL = + HTRDR_SOLVE_ITEM_ARGS_NULL__; + +typedef void +(*htrdr_solve_item_T) + (struct htrdr* htrdr, + const struct htrdr_solve_item_args* args, + void* item); /* Output data */ + +struct htrdr_solve_buffer_args { + htrdr_solve_item_T solve_item; /* User defined functor */ + struct htrdr_buffer_layout buffer_layout; + size_t nrealisations; /* #realisations per item */ + void* context; /* User defined data */ +}; +#define HTRDR_SOLVE_BUFFER_ARGS_NULL__ { \ + NULL, /* Solver item functor */ \ + HTRDR_BUFFER_LAYOUT_NULL__, /* Layout of the destination buffer */ \ + 0, /* #realisations per item */ \ + NULL /* User defined data */ \ +} +static const struct htrdr_solve_buffer_args HTRDR_SOLVE_BUFFER_ARGS_NULL = + HTRDR_SOLVE_BUFFER_ARGS_NULL__; + +/******************************************************************************* + * Exported symbols + ******************************************************************************/ +BEGIN_DECLS + +HTRDR_API res_T +htrdr_solve_buffer + (struct htrdr* htrdr, + const struct htrdr_solve_buffer_args* args, + struct htrdr_buffer* buf); /* May be NULL for non master processes */ + +END_DECLS + +#endif /* HTRDR_SOLVE_BUFFER_H */ diff --git a/src/core/htrdr_spectral.c b/src/core/htrdr_spectral.c @@ -1,12 +1,12 @@ -/* Copyright (C) 2018-2019, 2022-2024 Centre National de la Recherche Scientifique +/* 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-2024 Institut Pierre-Simon Laplace - * Copyright (C) 2022-2024 Institut de Physique du Globe de Paris - * Copyright (C) 2018-2024 |Méso|Star> (contact@meso-star.com) - * Copyright (C) 2022-2024 Observatoire de Paris - * Copyright (C) 2022-2024 Université de Reims Champagne-Ardenne - * Copyright (C) 2022-2024 Université de Versaille Saint-Quentin - * Copyright (C) 2018-2019, 2022-2024 Université Paul Sabatier + * 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 diff --git a/src/core/htrdr_spectral.h b/src/core/htrdr_spectral.h @@ -1,12 +1,12 @@ -/* Copyright (C) 2018-2019, 2022-2024 Centre National de la Recherche Scientifique +/* 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-2024 Institut Pierre-Simon Laplace - * Copyright (C) 2022-2024 Institut de Physique du Globe de Paris - * Copyright (C) 2018-2024 |Méso|Star> (contact@meso-star.com) - * Copyright (C) 2022-2024 Observatoire de Paris - * Copyright (C) 2022-2024 Université de Reims Champagne-Ardenne - * Copyright (C) 2022-2024 Université de Versaille Saint-Quentin - * Copyright (C) 2018-2019, 2022-2024 Université Paul Sabatier + * 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 diff --git a/src/core/htrdr_version.h.in b/src/core/htrdr_version.h.in @@ -1,10 +1,10 @@ -/* Copyright (C) 2018-2019, 2022-2024 Centre National de la Recherche Scientifique +/* 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-2024 Institut de Physique du Globe de Paris - * Copyright (C) 2018-2024 |Méso|Star> (contact@meso-star.com) - * Copyright (C) 2022-2024 Université de Reims Champagne-Ardenne - * Copyright (C) 2022-2024 Université de Versaille Saint-Quentin - * Copyright (C) 2018-2019, 2022-2024 Université Paul Sabatier + * 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 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 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 @@ -1,12 +1,12 @@ -/* Copyright (C) 2018-2019, 2022-2024 Centre National de la Recherche Scientifique +/* 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-2024 Institut Pierre-Simon Laplace - * Copyright (C) 2022-2024 Institut de Physique du Globe de Paris - * Copyright (C) 2018-2024 |Méso|Star> (contact@meso-star.com) - * Copyright (C) 2022-2024 Observatoire de Paris - * Copyright (C) 2022-2024 Université de Reims Champagne-Ardenne - * Copyright (C) 2022-2024 Université de Versaille Saint-Quentin - * Copyright (C) 2018-2019, 2022-2024 Université Paul Sabatier + * 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 @@ -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" @@ -38,6 +38,7 @@ #include <rad-net/rngrd.h> #include <star/scam.h> +#include <star/smsh.h> #include <rsys/cstr.h> #include <rsys/double3.h> @@ -48,6 +49,9 @@ #include <unistd.h> /* close */ #include <sys/stat.h> +#include <mpi.h> +#include <time.h> + /******************************************************************************* * Helper function ******************************************************************************/ @@ -85,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+"); @@ -97,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) { @@ -110,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); @@ -119,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; @@ -244,6 +297,10 @@ setup_spectral_domain res_T res = RES_OK; ASSERT(cmd && args); + /* No spectral distribution required to write octrees */ + if(cmd->output_type == HTRDR_PLANETS_ARGS_OUTPUT_OCTREES) + goto exit; + cmd->spectral_domain = args->spectral_domain; /* Configure the spectral distribution */ @@ -340,7 +397,11 @@ setup_source res_T res = RES_OK; ASSERT(cmd && args); - if(cmd->output_type == HTRDR_PLANETS_ARGS_OUTPUT_OCTREES) + if(cmd->output_type == HTRDR_PLANETS_ARGS_OUTPUT_OCTREES + /* No source in Longwave. + * Check the spectral domain type on the input arguments, because when the + * source is configured, the spectral dimension may not yet be set */ + || args->spectral_domain.type == HTRDR_SPECTRAL_LW) goto exit; res = htrdr_planets_source_create(cmd->htrdr, &args->source, &cmd->source); @@ -353,17 +414,54 @@ error: } static res_T -setup_camera +setup_camera_orthographic (struct htrdr_planets* cmd, const struct htrdr_planets_args* args) { - struct scam_perspective_args cam_args = SCAM_PERSPECTIVE_ARGS_DEFAULT; + struct scam_orthographic_args cam_args = SCAM_ORTHOGRAPHIC_ARGS_DEFAULT; res_T res = RES_OK; + + /* Check pre-conditions */ ASSERT(cmd && args); + ASSERT(cmd->output_type == HTRDR_PLANETS_ARGS_OUTPUT_IMAGE); + ASSERT(args->cam_type == HTRDR_ARGS_CAMERA_ORTHOGRAPHIC); + ASSERT(htrdr_args_camera_orthographic_check(&args->cam_ortho) == RES_OK); + ASSERT(htrdr_args_image_check(&args->image) == RES_OK); - if(cmd->output_type != HTRDR_PLANETS_ARGS_OUTPUT_IMAGE) - goto exit; + d3_set(cam_args.position, args->cam_ortho.position); + d3_set(cam_args.target, args->cam_ortho.target); + d3_set(cam_args.up, args->cam_ortho.up); + cam_args.height = args->cam_ortho.height; + cam_args.aspect_ratio = + (double)args->image.definition[0] + / (double)args->image.definition[1]; + + res = scam_create_orthographic + (htrdr_get_logger(cmd->htrdr), + htrdr_get_allocator(cmd->htrdr), + htrdr_get_verbosity_level(cmd->htrdr), + &cam_args, + &cmd->camera); + if(res != RES_OK) goto error; + +exit: + return res; +error: + goto exit; +} +static res_T +setup_camera_perspective + (struct htrdr_planets* cmd, + const struct htrdr_planets_args* args) +{ + struct scam_perspective_args cam_args = SCAM_PERSPECTIVE_ARGS_DEFAULT; + res_T res = RES_OK; + + /* Check pre-conditions */ + ASSERT(cmd && args); + ASSERT(args->output_type == HTRDR_PLANETS_ARGS_OUTPUT_IMAGE); + ASSERT(args->cam_type == HTRDR_ARGS_CAMERA_PERSPECTIVE); ASSERT(htrdr_args_camera_perspective_check(&args->cam_persp) == RES_OK); ASSERT(htrdr_args_image_check(&args->image) == RES_OK); @@ -392,16 +490,35 @@ error: } static res_T -setup_buffer +setup_camera + (struct htrdr_planets* cmd, + const struct htrdr_planets_args* args) +{ + res_T res = RES_OK; + ASSERT(cmd->output_type == HTRDR_PLANETS_ARGS_OUTPUT_IMAGE); + + switch(args->cam_type) { + case HTRDR_ARGS_CAMERA_ORTHOGRAPHIC: + res = setup_camera_orthographic(cmd, args); + break; + case HTRDR_ARGS_CAMERA_PERSPECTIVE: + res = setup_camera_perspective(cmd, args); + break; + default: FATAL("Unreachable code.\n"); break; + } + + return res; +} + +static res_T +setup_buffer_image (struct htrdr_planets* cmd, const struct htrdr_planets_args* args) { struct htrdr_pixel_format pixfmt = HTRDR_PIXEL_FORMAT_NULL; res_T res = RES_OK; ASSERT(cmd && args); - - if(cmd->output_type != HTRDR_PLANETS_ARGS_OUTPUT_IMAGE) - goto exit; + ASSERT(cmd->output_type == HTRDR_PLANETS_ARGS_OUTPUT_IMAGE); planets_get_pixel_format(cmd, &pixfmt); @@ -429,6 +546,127 @@ error: goto exit; } +static res_T +setup_buffer_raw + (struct htrdr_planets* cmd, + const struct htrdr_planets_args* args) +{ + struct smsh_desc desc = SMSH_DESC_NULL; + size_t sz = 0; /* Size of a voxel storing volumic radiative budget */ + size_t al = 0; /* Alignment of a voxel storing volumic radiative budget */ + res_T res = RES_OK; + + ASSERT(cmd && args); + ASSERT(cmd->output_type == HTRDR_PLANETS_ARGS_OUTPUT_VOLUMIC_RADIATIVE_BUDGET); + ASSERT(cmd->volrad_mesh != NULL); /* The volurad mesh must be defined */ + + res = smsh_get_desc(cmd->volrad_mesh, &desc); + if(res != RES_OK) goto error; + + /* Setup buffer layout for volumic radiative budget calculation */ + sz = sizeof(struct planets_voxel_radiative_budget); + al = ALIGNOF(struct planets_voxel_radiative_budget); + cmd->buf_layout.width = desc.ncells; + cmd->buf_layout.height = 1; + cmd->buf_layout.pitch = desc.ncells * sz; + cmd->buf_layout.elmt_size = sz; + cmd->buf_layout.alignment = al; + + /* Save the number of samples per tetrahedron */ + cmd->spt = args->volrad_budget.spt; + + /* Create the raw buffer only on master process; buffer parts calculated by + * other processes are collected there */ + if(htrdr_get_mpi_rank(cmd->htrdr) != 0) goto exit; + + res = htrdr_buffer_create(cmd->htrdr, &cmd->buf_layout, &cmd->buf); + if(res != RES_OK) goto error; + +exit: + return res; +error: + if(cmd->buf) { htrdr_buffer_ref_put(cmd->buf); cmd->buf = NULL; } + goto exit; +} + +static res_T +setup_buffer + (struct htrdr_planets* cmd, + const struct htrdr_planets_args* args) +{ + res_T res = RES_OK; + ASSERT(cmd && args); + + switch(cmd->output_type) { + case HTRDR_PLANETS_ARGS_OUTPUT_IMAGE: + res = setup_buffer_image(cmd, args); + break; + case HTRDR_PLANETS_ARGS_OUTPUT_VOLUMIC_RADIATIVE_BUDGET: + res = setup_buffer_raw(cmd, args); + break; + default: /* Nothing to do */ break; + } + if(res != RES_OK) goto error; + +exit: + return res; +error: + goto exit; +} + +static res_T +setup_volrad_budget_mesh + (struct htrdr_planets* cmd, + const struct htrdr_planets_args* args) +{ + struct smsh_create_args create_args = SMSH_CREATE_ARGS_DEFAULT; + struct smsh_load_args load_args = SMSH_LOAD_ARGS_NULL; + struct smsh_desc desc = SMSH_DESC_NULL; + res_T res = RES_OK; + ASSERT(cmd && args); + + if(cmd->output_type != HTRDR_PLANETS_ARGS_OUTPUT_VOLUMIC_RADIATIVE_BUDGET) + goto exit; + + /* Store the number of samples per tetrahedron to be used */ + cmd->spt = args->volrad_budget.spt; + + create_args.logger = htrdr_get_logger(cmd->htrdr); + create_args.allocator = htrdr_get_allocator(cmd->htrdr); + create_args.verbose = htrdr_get_verbosity_level(cmd->htrdr); + res = smsh_create(&create_args, &cmd->volrad_mesh); + if(res != RES_OK) goto error; + + load_args.path = args->volrad_budget.smsh_filename; + res = smsh_load(cmd->volrad_mesh, &load_args); + if(res != RES_OK) goto error; + + res = smsh_get_desc(cmd->volrad_mesh, &desc); + if(res != RES_OK) goto error; + + /* Check that the loaded mesh is effectively a volume mesh */ + if(desc.dnode != 3 || desc.dcell != 4) { + htrdr_log_err(cmd->htrdr, + "%s: the volumic radiative budget calculation " + "expects a 3D tetrahedral mesh " + "(dimension of mesh: %u; dimension of the vertices: %u)\n", + args->volrad_budget.smsh_filename, + desc.dnode, + desc.dcell); + res = RES_BAD_ARG; + goto error; + } + +exit: + return res; +error: + if(cmd->volrad_mesh) { + SMSH(ref_put(cmd->volrad_mesh)); + cmd->volrad_mesh = NULL; + } + goto exit; +} + static INLINE res_T write_vtk_octrees(const struct htrdr_planets* cmd) { @@ -468,6 +706,7 @@ planets_release(ref_T* ref) if(cmd->output && cmd->output != stdout) CHK(fclose(cmd->output) == 0); if(cmd->buf) htrdr_buffer_ref_put(cmd->buf); if(cmd->camera) SCAM(ref_put(cmd->camera)); + if(cmd->volrad_mesh) SMSH(ref_put(cmd->volrad_mesh)); str_release(&cmd->output_name); htrdr = cmd->htrdr; @@ -518,6 +757,8 @@ htrdr_planets_create if(res != RES_OK) goto error; res = setup_spectral_domain(cmd, args); if(res != RES_OK) goto error; + res = setup_volrad_budget_mesh(cmd, args); + if(res != RES_OK) goto error; res = setup_buffer(cmd, args); if(res != RES_OK) goto error; @@ -559,6 +800,9 @@ htrdr_planets_run(struct htrdr_planets* cmd) case HTRDR_PLANETS_ARGS_OUTPUT_OCTREES: res = write_vtk_octrees(cmd); break; + case HTRDR_PLANETS_ARGS_OUTPUT_VOLUMIC_RADIATIVE_BUDGET: + res = planets_solve_volrad_budget(cmd); + break; default: FATAL("Unreachable code\n"); break; } if(res != RES_OK) goto error; diff --git a/src/planets/htrdr_planets.h b/src/planets/htrdr_planets.h @@ -1,12 +1,12 @@ -/* Copyright (C) 2018-2019, 2022-2024 Centre National de la Recherche Scientifique +/* 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-2024 Institut Pierre-Simon Laplace - * Copyright (C) 2022-2024 Institut de Physique du Globe de Paris - * Copyright (C) 2018-2024 |Méso|Star> (contact@meso-star.com) - * Copyright (C) 2022-2024 Observatoire de Paris - * Copyright (C) 2022-2024 Université de Reims Champagne-Ardenne - * Copyright (C) 2022-2024 Université de Versaille Saint-Quentin - * Copyright (C) 2018-2019, 2022-2024 Université Paul Sabatier + * 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 diff --git a/src/planets/htrdr_planets_args.c b/src/planets/htrdr_planets_args.c @@ -1,12 +1,12 @@ -/* Copyright (C) 2018-2019, 2022-2024 Centre National de la Recherche Scientifique +/* 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-2024 Institut Pierre-Simon Laplace - * Copyright (C) 2022-2024 Institut de Physique du Globe de Paris - * Copyright (C) 2018-2024 |Méso|Star> (contact@meso-star.com) - * Copyright (C) 2022-2024 Observatoire de Paris - * Copyright (C) 2022-2024 Université de Reims Champagne-Ardenne - * Copyright (C) 2022-2024 Université de Versaille Saint-Quentin - * Copyright (C) 2018-2019, 2022-2024 Université Paul Sabatier + * 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 @@ -102,17 +102,49 @@ check_spectral_args(const struct htrdr_planets_spectral_args* args) return RES_OK; } + +static INLINE res_T +check_volrad_budget_args(const struct htrdr_planets_volrad_budget_args* args) +{ + if(!args) return RES_BAD_ARG; + + /* Filename could not be NULL */ + if(!args->smsh_filename) return RES_BAD_ARG; + + /* Samples per tetrahedron could not be zero */ + if(!args->spt) return RES_BAD_ARG; + + 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] [-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(" -g gas_opt[:gas_opt ...] \n"); + printf(" [-i image_opt[:image_opt ...]] [-o output]\n"); + printf(" [-P ortho_camera_opt[:ortho_camera_opt ...]]\n"); + printf(" [-r volrad_budget_opt[:volrad_budget_opt ...]]\n"); + printf(" [-S source_opt[:source_opt ...]]\n"); + printf(" [-s spectral_opt[:spectral_opt ...]] [-t threads_count]\n"); + printf(" -g gas_opt[:gas_opt ...]\n"); } static INLINE char* @@ -506,6 +538,153 @@ error: goto exit; } +static res_T +parse_volrad_budget_parameters(const char* str, void* ptr) +{ + enum { MESH, SPT } 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 volumic radiative budget calculation `%s'\n", + 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, "mesh")) iparam = MESH; + else if(!strcmp(key, "spt")) iparam = SPT; + else { + fprintf(stderr, "Invalid volumic radiative budget parameter `%s'\n", key); + res = RES_BAD_ARG; + goto error; + } + + if(!val) { + fprintf(stderr, + "Invalid null value for the volumic radiative budget parameter `%s'.\n", + key); + res = RES_BAD_ARG; + goto error; + } + + switch(iparam) { + case MESH: + if(args->volrad_budget.smsh_filename) { + mem_rm(args->volrad_budget.smsh_filename); + } + if(!(args->volrad_budget.smsh_filename = str_dup(val))) { + res = RES_MEM_ERR; + } + break; + case SPT: /* Sample Per Tetrahedron */ + res = cstr_to_uint(val, &args->volrad_budget.spt); + break; + default: FATAL("Unreachable code\n"); break; + } + if(res != RES_OK) { + fprintf(stderr, + "Unable to parse the volumic radiative budget parameter `%s' -- %s\n", + str, res_to_cstr(res)); + goto error; + } + +exit: + return res; +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 ******************************************************************************/ @@ -518,7 +697,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:S:s:T:t:V:v")) != -1) { + while((opt = getopt(argc, argv, "a:b:C:dfG:g:hi:No:P:r:S:s:t:v")) != -1) { switch(opt) { case 'a': (void)sa_add(args->aerosols, 1); @@ -529,9 +708,13 @@ 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; + args->cam_type = HTRDR_ARGS_CAMERA_PERSPECTIVE; + res = htrdr_args_camera_perspective_parse(&args->cam_persp, optarg); break; case 'd': args->output_type = HTRDR_PLANETS_ARGS_OUTPUT_OCTREES; @@ -560,26 +743,26 @@ 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 'P': + args->output_type = HTRDR_PLANETS_ARGS_OUTPUT_IMAGE; + args->cam_type = HTRDR_ARGS_CAMERA_ORTHOGRAPHIC; + res = htrdr_args_camera_orthographic_parse(&args->cam_ortho, optarg); + break; + case 'r': + res = cstr_parse_list(optarg, ':', parse_volrad_budget_parameters, args); + args->output_type = HTRDR_PLANETS_ARGS_OUTPUT_VOLUMIC_RADIATIVE_BUDGET; + break; case 'S': res = cstr_parse_list(optarg, ':', parse_source_parameters, args); break; 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; } @@ -616,6 +799,16 @@ htrdr_planets_args_init(struct htrdr_planets_args* args, int argc, char** argv) } } + if(args->output_type == HTRDR_PLANETS_ARGS_OUTPUT_VOLUMIC_RADIATIVE_BUDGET + && args->spectral_domain.type != HTRDR_SPECTRAL_LW + && args->spectral_domain.type != HTRDR_SPECTRAL_SW) { + fprintf(stderr, + "volumic radiative budget can be evaluated in " + "longwave or shortwave only -- option '-s'\n"); + res = RES_BAD_ARG; + goto error; + } + exit: return res; error: @@ -638,6 +831,8 @@ htrdr_planets_args_release(struct htrdr_planets_args* args) if(args->ground.mtllst_filename) mem_rm(args->ground.mtllst_filename); 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; @@ -671,9 +866,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); @@ -692,7 +886,7 @@ htrdr_planets_args_check(const struct htrdr_planets_args* args) } } - if(args->output_type != HTRDR_PLANETS_ARGS_OUTPUT_IMAGE) { + if(args->output_type == HTRDR_PLANETS_ARGS_OUTPUT_IMAGE) { res = htrdr_args_camera_perspective_check(&args->cam_persp); if(res != RES_OK) return res; @@ -700,6 +894,18 @@ htrdr_planets_args_check(const struct htrdr_planets_args* args) if(res != RES_OK) return res; } + if(args->output_type == HTRDR_PLANETS_ARGS_OUTPUT_VOLUMIC_RADIATIVE_BUDGET) { + res = check_volrad_budget_args(&args->volrad_budget); + if(res != RES_OK) return res; + + /* The volumic radiative budget can be evaluated + * in longwave or shortwave only */ + if(args->spectral_domain.type != HTRDR_SPECTRAL_LW + && args->spectral_domain.type != HTRDR_SPECTRAL_SW) { + return RES_BAD_ARG; + } + } + /* Check miscalleneous parameters */ if(args->nthreads == 0 || (unsigned)args->output_type >= HTRDR_PLANETS_ARGS_OUTPUT_TYPES_COUNT__) diff --git a/src/planets/htrdr_planets_args.h.in b/src/planets/htrdr_planets_args.h.in @@ -1,10 +1,10 @@ -/* Copyright (C) 2018-2019, 2022-2024 Centre National de la Recherche Scientifique +/* 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-2024 Institut de Physique du Globe de Paris - * Copyright (C) 2018-2024 |Méso|Star> (contact@meso-star.com) - * Copyright (C) 2022-2024 Université de Reims Champagne-Ardenne - * Copyright (C) 2022-2024 Université de Versaille Saint-Quentin - * Copyright (C) 2018-2019, 2022-2024 Université Paul Sabatier + * 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 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 @@ -32,6 +32,7 @@ enum htrdr_planets_args_output_type { HTRDR_PLANETS_ARGS_OUTPUT_IMAGE, HTRDR_PLANETS_ARGS_OUTPUT_OCTREES, + HTRDR_PLANETS_ARGS_OUTPUT_VOLUMIC_RADIATIVE_BUDGET, HTRDR_PLANETS_ARGS_OUTPUT_TYPES_COUNT__ }; @@ -70,6 +71,36 @@ struct htrdr_planets_ground_args { static const struct htrdr_planets_ground_args HTRDR_PLANETS_GROUND_ARGS_NULL = HTRDR_PLANETS_GROUND_ARGS_NULL__; +struct htrdr_planets_volrad_budget_args { + char* smsh_filename; /* The Star-Mesh geometry */ + unsigned spt; /* Number of MC realisations per tetrahedron */ +}; +#define HTRDR_PLANETS_VOLRAD_BUDGET_ARGS_NULL__ { \ + NULL, @HTRDR_PLANETS_ARGS_DEFAULT_VOLRAD_BUDGET_SPT@ \ +} +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; @@ -77,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 */ @@ -90,9 +117,14 @@ struct htrdr_planets_args { struct htrdr_args_image image; struct htrdr_args_camera_perspective cam_persp; /* Perspective camera */ + struct htrdr_args_camera_orthographic cam_ortho; /* Orthographic camera */ + enum htrdr_args_camera_type cam_type; + + /* Input parameters for volumic radiative budget calculation */ + 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 */ @@ -105,10 +137,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 */ \ @@ -116,6 +145,10 @@ struct htrdr_planets_args { HTRDR_ARGS_IMAGE_DEFAULT__, /* Image */ \ \ HTRDR_ARGS_CAMERA_PERSPECTIVE_DEFAULT__, /* Perspective camera */ \ + HTRDR_ARGS_CAMERA_ORTHOGRAPHIC_DEFAULT__, /* Orthographic camera */ \ + HTRDR_ARGS_CAMERA_PERSPECTIVE, \ + \ + HTRDR_PLANETS_VOLRAD_BUDGET_ARGS_NULL__, /* Volumic radiative budget */ \ \ UINT_MAX, /* Number of threads */ \ HTRDR_PLANETS_ARGS_OUTPUT_IMAGE, \ diff --git a/src/planets/htrdr_planets_c.h b/src/planets/htrdr_planets_c.h @@ -1,12 +1,12 @@ -/* Copyright (C) 2018-2019, 2022-2024 Centre National de la Recherche Scientifique +/* 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-2024 Institut Pierre-Simon Laplace - * Copyright (C) 2022-2024 Institut de Physique du Globe de Paris - * Copyright (C) 2018-2024 |Méso|Star> (contact@meso-star.com) - * Copyright (C) 2022-2024 Observatoire de Paris - * Copyright (C) 2022-2024 Université de Reims Champagne-Ardenne - * Copyright (C) 2022-2024 Université de Versaille Saint-Quentin - * Copyright (C) 2018-2019, 2022-2024 Université Paul Sabatier + * 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 @@ -56,10 +56,10 @@ static const struct planets_pixel_xwave PLANETS_PIXEL_XWAVE_NULL = PLANETS_PIXEL_XWAVE_NULL__; struct planets_pixel_image { - struct htrdr_estimate X; /* In W/m²/sr */ - struct htrdr_estimate Y; /* In W/m²/sr */ - struct htrdr_estimate Z; /* In W/m²/sr */ - struct htrdr_accum time; /* In µs */ + struct htrdr_estimate X; /* In W/m^2/sr */ + struct htrdr_estimate Y; /* In W/m^2/sr */ + struct htrdr_estimate Z; /* In W/m^2/sr */ + struct htrdr_accum time; /* In us */ }; #define PLANETS_PIXEL_IMAGE_NULL__ { \ HTRDR_ESTIMATE_NULL__, \ @@ -68,6 +68,37 @@ struct planets_pixel_image { HTRDR_ACCUM_NULL__ \ } +enum planets_volrad_weight_type { + PLANETS_VOLRAD_TOTAL, /* 0 */ + PLANETS_VOLRAD_DIRECT, /* 1 */ + PLANETS_VOLRAD_DIFFUSE, /* 2 */ + PLANETS_VOLRAD_WEIGHTS_COUNT /* 3 */ +}; + +struct planets_voxel_radiative_budget { + struct htrdr_accum volrad_budget[PLANETS_VOLRAD_WEIGHTS_COUNT]; /* W/m^3 */ + struct htrdr_accum time; /* In us */ +}; +#define PLANETS_VOXEL_RADIATIVE_BUDGET_NULL__ { \ + { \ + HTRDR_ACCUM_NULL__, \ + HTRDR_ACCUM_NULL__, \ + HTRDR_ACCUM_NULL__ \ + }, \ + HTRDR_ACCUM_NULL__ \ +} +static const struct planets_voxel_radiative_budget +PLANETS_VOXEL_RADIATIVE_BUDGET_NULL = PLANETS_VOXEL_RADIATIVE_BUDGET_NULL__; + +enum planets_radiance_cpnt_flag { + PLANETS_RADIANCE_CPNT_DIRECT = BIT(0), + PLANETS_RADIANCE_CPNT_DIFFUSE = BIT(1), + PLANETS_RADIANCE_CPNT_NONE = 0, + PLANETS_RADIANCE_CPNT_ALL = + PLANETS_RADIANCE_CPNT_DIRECT + | PLANETS_RADIANCE_CPNT_DIFFUSE +}; + struct planets_compute_radiance_args { struct ssp_rng* rng; size_t ithread; /* Index of the thread executing the function */ @@ -78,8 +109,11 @@ struct planets_compute_radiance_args { double wlen; /* In nm */ size_t iband; /* Spectral band index */ size_t iquad; /* Quadrature point */ + + int component; /* Combination of planets_radiance_cpnt_flag */ }; -#define PLANETS_COMPUTE_RADIANCE_ARGS_NULL__ {NULL, 0, {0,0,0}, {0,0,0}, 0, 0, 0} +#define PLANETS_COMPUTE_RADIANCE_ARGS_NULL__ \ + {NULL, 0, {0,0,0}, {0,0,0}, 0, 0, 0, PLANETS_RADIANCE_CPNT_ALL} static const struct planets_compute_radiance_args PLANETS_COMPUTE_RADIANCE_ARGS_NULL = PLANETS_COMPUTE_RADIANCE_ARGS_NULL__; @@ -99,12 +133,16 @@ struct htrdr_planets { struct str output_name; enum htrdr_planets_args_output_type output_type; + /* Image rendering */ struct scam* camera; - struct htrdr_buffer_layout buf_layout; struct htrdr_buffer* buf; /* NULL on non master processes */ size_t spp; /* Samples per pixel */ + /* Volumic radiative budget */ + struct smsh* volrad_mesh; + size_t spt; /* Samples per tetrahedron */ + ref_T ref; struct htrdr* htrdr; }; @@ -113,6 +151,10 @@ extern LOCAL_SYM res_T planets_draw_map (struct htrdr_planets* cmd); +extern LOCAL_SYM res_T +planets_solve_volrad_budget + (struct htrdr_planets* cmd); + extern LOCAL_SYM void planets_get_pixel_format (const struct htrdr_planets* cmd, diff --git a/src/planets/htrdr_planets_compute_radiance.c b/src/planets/htrdr_planets_compute_radiance.c @@ -1,12 +1,12 @@ -/* Copyright (C) 2018-2019, 2022-2024 Centre National de la Recherche Scientifique +/* 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-2024 Institut Pierre-Simon Laplace - * Copyright (C) 2022-2024 Institut de Physique du Globe de Paris - * Copyright (C) 2018-2024 |Méso|Star> (contact@meso-star.com) - * Copyright (C) 2022-2024 Observatoire de Paris - * Copyright (C) 2022-2024 Université de Reims Champagne-Ardenne - * Copyright (C) 2022-2024 Université de Versaille Saint-Quentin - * Copyright (C) 2018-2019, 2022-2024 Université Paul Sabatier + * 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 @@ -504,9 +504,6 @@ volume_scattering ssf_phase_sample(phase, args->rng, wo, sc_dir, NULL); - /* Sample a direction toward the source */ - pdf = htrdr_planets_source_sample_direction(cmd->source, args->rng, sc_pos, wi); - /* In short wave, manage the contribution of the external source */ switch(cmd->spectral_domain.type) { case HTRDR_SPECTRAL_LW: @@ -515,6 +512,10 @@ volume_scattering case HTRDR_SPECTRAL_SW: case HTRDR_SPECTRAL_SW_CIE_XYZ: + /* Sample a direction toward the source */ + pdf = htrdr_planets_source_sample_direction + (cmd->source, args->rng, sc_pos, wi); + /* Calculate the direct contribution at the scattering position */ Ld = direct_contribution(cmd, args, sc_pos, wi, NULL); rho = ssf_phase_eval(phase, wo, wi); @@ -603,16 +604,34 @@ planets_compute_radiance double L = 0; /* Radiance in W/m²/sr/m */ size_t nsc = 0; /* Number of surface or volume scatterings (for debug) */ int longwave = 0; + int shortwave = 0; + int direct = 0; + int diffuse = 0; ASSERT(cmd && check_planets_compute_radiance_args(cmd, args) == RES_OK); d3_set(pos, args->path_org); d3_set(dir, args->path_dir); + longwave = cmd->spectral_domain.type == HTRDR_SPECTRAL_LW; + shortwave = !longwave; - if(!longwave && htrdr_planets_source_is_targeted(cmd->source, pos, dir)) { + /* In shortwave define which components are enabled */ + if(shortwave) { + direct = (args->component & PLANETS_RADIANCE_CPNT_DIRECT) != 0; + diffuse = (args->component & PLANETS_RADIANCE_CPNT_DIFFUSE) != 0; + } + + /* Handle direct shortwave contribution */ + if(shortwave + && direct + && htrdr_planets_source_is_targeted(cmd->source, pos, dir)) { L = direct_contribution(cmd, args, pos, dir, NULL); /* In W/m²/sr/m */ } + /* Nothing left to do: if only the diffuse component is required + * in the SW, the diffuse component should not be computed */ + if(shortwave && !diffuse) return L; + for(;;) { double ev_pos[3]; double sc_dir[3]; diff --git a/src/planets/htrdr_planets_draw_map.c b/src/planets/htrdr_planets_draw_map.c @@ -1,12 +1,12 @@ -/* Copyright (C) 2018-2019, 2022-2024 Centre National de la Recherche Scientifique +/* 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-2024 Institut Pierre-Simon Laplace - * Copyright (C) 2022-2024 Institut de Physique du Globe de Paris - * Copyright (C) 2018-2024 |Méso|Star> (contact@meso-star.com) - * Copyright (C) 2022-2024 Observatoire de Paris - * Copyright (C) 2022-2024 Université de Reims Champagne-Ardenne - * Copyright (C) 2022-2024 Université de Versaille Saint-Quentin - * Copyright (C) 2018-2019, 2022-2024 Université Paul Sabatier + * 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 @@ -442,12 +442,18 @@ planets_draw_map(struct htrdr_planets* cmd) || cmd->spectral_domain.type == HTRDR_SPECTRAL_SW) { struct htrdr_estimate L; double omega; /* Solid angle of the camera */ + enum scam_type type = SCAM_NONE; htrdr_accum_get_estimation(&radiance_acc, &L); - SCAM(perspective_get_solid_angle(cmd->camera, &omega)); htrdr_log(cmd->htrdr, "Radiance in W/m²/sr: %g +/- %g\n", L.E, L.SE); - htrdr_log(cmd->htrdr, "Radiance in W/m² (solid angle = %g sr): %g +/- %g\n", - omega, L.E*omega, L.SE*omega); + + SCAM(get_type(cmd->camera, &type)); + if(type == SCAM_PERSPECTIVE) { + SCAM(perspective_get_solid_angle(cmd->camera, &omega)); + + htrdr_log(cmd->htrdr, "Radiance in W/m² (solid angle = %g sr): %g +/- %g\n", + omega, L.E*omega, L.SE*omega); + } } exit: diff --git a/src/planets/htrdr_planets_main.c b/src/planets/htrdr_planets_main.c @@ -1,12 +1,12 @@ -/* Copyright (C) 2018-2019, 2022-2024 Centre National de la Recherche Scientifique +/* 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-2024 Institut Pierre-Simon Laplace - * Copyright (C) 2022-2024 Institut de Physique du Globe de Paris - * Copyright (C) 2018-2024 |Méso|Star> (contact@meso-star.com) - * Copyright (C) 2022-2024 Observatoire de Paris - * Copyright (C) 2022-2024 Université de Reims Champagne-Ardenne - * Copyright (C) 2022-2024 Université de Versaille Saint-Quentin - * Copyright (C) 2018-2019, 2022-2024 Université Paul Sabatier + * 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 diff --git a/src/planets/htrdr_planets_solve_volrad_budget.c b/src/planets/htrdr_planets_solve_volrad_budget.c @@ -0,0 +1,449 @@ +/* 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/>. */ + +#include "planets/htrdr_planets_c.h" +#include "planets/htrdr_planets_source.h" + +#include "core/htrdr_accum.h" +#include "core/htrdr_log.h" +#include "core/htrdr_ran_wlen_discrete.h" +#include "core/htrdr_ran_wlen_planck.h" +#include "core/htrdr_solve_buffer.h" + +#include <star/smsh.h> +#include <star/ssp.h> + +#include <rsys/clock_time.h> + +/******************************************************************************* + * Helper functions + ******************************************************************************/ +static void +spectral_sampling + (struct htrdr_planets* cmd, + const struct htrdr_solve_item_args* args, + double* out_wlen, /* Sampled wavelength [nm] */ + double* out_wlen_pdf, /* [nm^-1] */ + size_t* out_iband, /* Spectral band in which the sampled wavelength falls */ + size_t* out_iquad) /* Sampled quadrature point in the spectral band */ +{ + size_t iband_range[2] = {0, 0}; + size_t iband = 0; + size_t iquad = 0; + double r0, r1, r2; /* Random Numbers */ + double wlen[2] = {0,0}; /* [nm] */ + double pdf = 0; /* [nm^1] */ + + /* Preconditions */ + ASSERT(cmd && args && out_wlen && out_wlen_pdf && out_iband && out_iquad); + + r0 = ssp_rng_canonical(args->rng); + r1 = ssp_rng_canonical(args->rng); + r2 = ssp_rng_canonical(args->rng); + + /* Sample a wavelength with respect to the type of spectral integration */ + switch(cmd->spectral_domain.type) { + /* Longwave */ + case HTRDR_SPECTRAL_LW: + wlen[0] = htrdr_ran_wlen_planck_sample(cmd->planck, r0, r1, &pdf); + break; + /* Shortwave */ + case HTRDR_SPECTRAL_SW: + if(htrdr_planets_source_does_radiance_vary_spectrally(cmd->source)) { + wlen[0] = htrdr_ran_wlen_discrete_sample(cmd->discrete, r0, r1, &pdf); + } else { + wlen[0] = htrdr_ran_wlen_planck_sample(cmd->planck, r0, r1, &pdf); + } + break; + default: FATAL("Unreachable code\n"); break; + } + wlen[1] = wlen[0]; + + /* Find the band the wavelength belongs to */ + RNATM(find_bands(cmd->atmosphere, wlen, iband_range)); + ASSERT(iband_range[0] == iband_range[1]); + iband = iband_range[0]; + + /* Sample a quadrature point */ + RNATM(band_sample_quad_pt(cmd->atmosphere, r2, iband, &iquad)); + + *out_wlen = wlen[0]; + *out_wlen_pdf = pdf; + *out_iband = iband; + *out_iquad = iquad; +} + +static INLINE void +position_sampling + (const struct htrdr_solve_item_args* args, + const struct smsh_desc* desc, + double pos[3]) +{ + const double* v0 = NULL; + const double* v1 = NULL; + const double* v2 = NULL; + const double* v3 = NULL; + + /* Preconditions */ + ASSERT(args && desc && pos); + + /* Retrieve the vertices of the tetrahedron */ + v0 = desc->nodes + desc->cells[args->item_id*4/*#vertices*/+0]*3/*#coords*/; + v1 = desc->nodes + desc->cells[args->item_id*4/*#vertices*/+1]*3/*#coords*/; + v2 = desc->nodes + desc->cells[args->item_id*4/*#vertices*/+2]*3/*#coords*/; + v3 = desc->nodes + desc->cells[args->item_id*4/*#vertices*/+3]*3/*#coords*/; + + ssp_ran_tetrahedron_uniform(args->rng, v0, v1, v2, v3, pos, NULL/*pdf*/); +} + +static double /* [W/m^2/sr/m] */ +get_source + (struct htrdr_planets* cmd, + const double pos[3], + const double wlen) /* [nm] */ +{ + struct rnatm_cell_pos cell_pos = RNATM_CELL_POS_NULL; + double temperature = 0; /* [K] */ + double source = 0; /* [W/m^2/sr/m] */ + const double wlen_m = wlen * 1.e-9; /* Wavelength [m] */ + ASSERT(cmd && pos); + + switch(cmd->spectral_domain.type) { + case HTRDR_SPECTRAL_SW: + /* In shortwave, the source is external to the system */ + source = 0; /* [W/m^2/sr/m] */ + break; + + case HTRDR_SPECTRAL_LW: + RNATM(fetch_cell(cmd->atmosphere, pos, RNATM_GAS, &cell_pos)); + + if(SUVM_PRIMITIVE_NONE(&cell_pos.prim)) { + /* The position is not in the gas */ + source = 0; /* [W/m^2/sr/m] */ + + } else { + /* Fetch the source temperature */ + RNATM(cell_get_gas_temperature(cmd->atmosphere, &cell_pos, &temperature)); + source = htrdr_planck_monochromatic(wlen_m, temperature); /* [W/m^2/sr/m] */ + } + break; + + default: FATAL("Unreachable code\n"); break; + } + + return source; /* [W/m^2/sr/m] */ +} + +/* Return the total absorption coefficient, + * i.e. the sum of the gas and aerosol ka */ +static double +get_ka + (struct htrdr_planets* cmd, + const double pos[3], + const size_t iband, /* Spectral band */ + const size_t iquad) /* Quadrature point */ +{ + struct rnatm_cell_pos cells[RNATM_MAX_COMPONENTS_COUNT]; + struct rnatm_get_radcoef_args get_k_args = RNATM_GET_RADCOEF_ARGS_NULL; + double ka = 0; + + ASSERT(cmd && pos); + + get_k_args.cells = cells; + get_k_args.iband = iband; + get_k_args.iquad = iquad; + get_k_args.radcoef = RNATM_RADCOEF_Ka; + + /* Retrieve the list of aerosol and gas cells in which pos lies */ + RNATM(fetch_cell_list(cmd->atmosphere, pos, get_k_args.cells, NULL)); + + /* Retrive the total absorption coefficient */ + RNATM(get_radcoef(cmd->atmosphere, &get_k_args, &ka)); + + return ka; +} + +static void +realisation + (struct htrdr_planets* cmd, + const struct htrdr_solve_item_args* args, + const struct smsh_desc* volrad_mesh_desc, + double weights[PLANETS_VOLRAD_WEIGHTS_COUNT]) /* [W/m^3] */ +{ + struct planets_compute_radiance_args rad_args = + PLANETS_COMPUTE_RADIANCE_ARGS_NULL; + + /* Spectral integration */ + double wlen = 0; /* Wavelength [nm] */ + double wlen_pdf_nm = 0; /* Wavelength pdf [nm^-1] */ + double wlen_pdf_m = 0; /* Wavelength pdf [m^-1] */ + size_t iband = 0; /* Spectral band */ + size_t iquad = 0; /* Quadrature point */ + + /* Spatial & angular integration */ + double dir_src[3] = {0,0,0}; /* Direction toward the source */ + double dir[3] = {0,0,0}; + double pos[3] = {0,0,0}; + double dir_src_pdf = 0; + double dir_pdf = 0; + + double S = 0; /* Source [W/m^2/sr/m] */ + double L_direct = 0; /* Direct radiance [W/m^2/sr/m] */ + double L_diffuse = 0; /* Diffuse radiance [W/m^2/sr/m] */ + double ka = 0; /* Absorption coefficient */ + + /* Preconditions */ + ASSERT(cmd && args && volrad_mesh_desc); + ASSERT(cmd->output_type == HTRDR_PLANETS_ARGS_OUTPUT_VOLUMIC_RADIATIVE_BUDGET); + + /* Initialise the weights */ + memset(weights, 0, sizeof(double)*PLANETS_VOLRAD_WEIGHTS_COUNT); + + spectral_sampling(cmd, args, &wlen, &wlen_pdf_nm, &iband, &iquad); + position_sampling(args, volrad_mesh_desc, pos); + ssp_ran_sphere_uniform(args->rng, dir, &dir_pdf); + + S = get_source(cmd, pos, wlen); /* [W/m^2/sr/m] */ + + ka = get_ka(cmd, pos, iband, iquad); + wlen_pdf_m = wlen_pdf_nm * 1.e9; /* Transform pdf from nm^-1 to m^-1 */ + + /* Compute the radiance in W/m^2/sr/m */ + d3_set(rad_args.path_org, pos); + rad_args.rng = args->rng; + rad_args.ithread = args->ithread; + rad_args.wlen = wlen; /* [nm] */ + rad_args.iband = iband; + rad_args.iquad = iquad; + + if(cmd->spectral_domain.type == HTRDR_SPECTRAL_LW) { + /* In the longwave (radiation due to the medium), simply sample a radiative + * path for the sampled direction and position: the radiance is considered + * as purely diffuse. */ + d3_set(rad_args.path_dir, dir); + L_diffuse = planets_compute_radiance(cmd, &rad_args); /* [W/m^2/sr/m] */ + + /* Calculate the weights [W/m^3] */ + weights[PLANETS_VOLRAD_DIRECT] = 0.0; + weights[PLANETS_VOLRAD_DIFFUSE] = ka * (L_diffuse - S) / (wlen_pdf_m * dir_pdf); + + } else { + /* In the so-called shortwave region (actually, the radiation due the + * external source) is decomposed in its direct and diffuse components */ + + dir_src_pdf = htrdr_planets_source_sample_direction + (cmd->source, args->rng, pos, dir_src); + + d3_set(rad_args.path_dir, dir_src); + rad_args.component = PLANETS_RADIANCE_CPNT_DIRECT; + L_direct = planets_compute_radiance(cmd, &rad_args); /* [W/m^2/sr/m] */ + + d3_set(rad_args.path_dir, dir); + rad_args.component = PLANETS_RADIANCE_CPNT_DIFFUSE; + L_diffuse = planets_compute_radiance(cmd, &rad_args); /* [W/m^2/sr/m] */ + + /* Calculate the weights [W/m^3] */ + weights[PLANETS_VOLRAD_DIRECT] = ka * (L_direct - S) / (wlen_pdf_m * dir_src_pdf); + weights[PLANETS_VOLRAD_DIFFUSE] = ka * (L_diffuse - S) / (wlen_pdf_m * dir_pdf); + } + + /* Calculate the weights [W/m^3] */ + weights[PLANETS_VOLRAD_TOTAL] = + weights[PLANETS_VOLRAD_DIRECT] + + weights[PLANETS_VOLRAD_DIFFUSE]; +} + +static void +solve_volumic_radiative_budget + (struct htrdr* htrdr, + const struct htrdr_solve_item_args* args, + void* data) +{ + /* Volumic mesh on which volumic radiative budget is estimated */ + struct smsh_desc volrad_mesh_desc = SMSH_DESC_NULL; + + /* Miscellaneous */ + struct htrdr_planets* cmd = NULL; + struct planets_voxel_radiative_budget* voxel = data; + size_t i = 0; + + /* Preconditions */ + ASSERT(htrdr && args && data); + (void)htrdr, (void)cmd; + + cmd = args->context; + ASSERT(cmd); + ASSERT(cmd->output_type == HTRDR_PLANETS_ARGS_OUTPUT_VOLUMIC_RADIATIVE_BUDGET); + + SMSH(get_desc(cmd->volrad_mesh, &volrad_mesh_desc)); + + /* Initialse voxel accumulators to 0 */ + *voxel = PLANETS_VOXEL_RADIATIVE_BUDGET_NULL; + + FOR_EACH(i, 0, args->nrealisations) { + /* Time recording */ + struct time t0, t1; + + /* Monte Carlo weights */ + double w[PLANETS_VOLRAD_WEIGHTS_COUNT] = {0}; /* [W/m^3] */ + double usec = 0; /* [us] */ + + int iweight = 0; + + /* Start of realisation time recording */ + time_current(&t0); + + /* Run the realisation */ + realisation(cmd, args, &volrad_mesh_desc, w); + + /* Stop time recording */ + time_sub(&t0, time_current(&t1), &t0); + usec = (double)time_val(&t0, TIME_NSEC) * 0.001; + + FOR_EACH(iweight, 0, PLANETS_VOLRAD_WEIGHTS_COUNT){ + /* Update the volumic radiance budget accumulator */ + voxel->volrad_budget[iweight].sum_weights += w[iweight]; + voxel->volrad_budget[iweight].sum_weights_sqr += w[iweight]*w[iweight]; + voxel->volrad_budget[iweight].nweights += 1; + } + + /* Update the per realisation time accumulator */ + voxel->time.sum_weights += usec; + voxel->time.sum_weights_sqr += usec*usec; + voxel->time.nweights += 1; + } +} + +static res_T +write_buffer + (struct htrdr_planets* cmd, + struct htrdr_buffer* buf, + struct htrdr_accum* out_budget, /* W/m^3 */ + struct htrdr_accum* out_time, /* us */ + FILE* stream) +{ + struct htrdr_buffer_layout layout = HTRDR_BUFFER_LAYOUT_NULL; + size_t x = 0; + + /* Preconditions */ + ASSERT(cmd && buf && out_budget && out_time && stream); + + htrdr_buffer_get_layout(buf, &layout); + ASSERT(layout.height == 1); + (void)cmd; + + /* Reset global accumulators */ + *out_budget = HTRDR_ACCUM_NULL; + *out_time = HTRDR_ACCUM_NULL; + + FOR_EACH(x, 0, layout.width) { + struct planets_voxel_radiative_budget* voxel = htrdr_buffer_at(buf, x, 0); + struct htrdr_estimate estim_time = HTRDR_ESTIMATE_NULL; + struct htrdr_accum* budget = NULL; + int iestim = 0; + + budget = voxel->volrad_budget; + FOR_EACH(iestim, 0, PLANETS_VOLRAD_WEIGHTS_COUNT) { + struct htrdr_estimate estim_budget = HTRDR_ESTIMATE_NULL; + + /* Write the estimate of the volumic radiative budget */ + htrdr_accum_get_estimation(&budget[iestim], &estim_budget); + fprintf(stream, "%g %g ", estim_budget.E, estim_budget.SE); + + /* Write the accumulator of the volumic radiative budget */ + fprintf(stream, "%g %g ", + budget[iestim].sum_weights, + budget[iestim].sum_weights_sqr); + } + + /* Write the number of realisations. + * It must be the same for all components */ + ASSERT(budget[PLANETS_VOLRAD_TOTAL].nweights + == budget[PLANETS_VOLRAD_DIRECT].nweights); + ASSERT(budget[PLANETS_VOLRAD_TOTAL].nweights + == budget[PLANETS_VOLRAD_DIFFUSE].nweights); + fprintf(stream, "%lu ", (unsigned long)budget[PLANETS_VOLRAD_TOTAL].nweights); + + /* Write the estimate of the per realisation time */ + htrdr_accum_get_estimation(&voxel->time, &estim_time); + fprintf(stream, "%g %g\n", estim_time.E, estim_time.SE); + + /* Update the overall (total) volumic radiative budget accumulator */ + out_budget->sum_weights += budget[PLANETS_VOLRAD_TOTAL].sum_weights; + out_budget->sum_weights_sqr += budget[PLANETS_VOLRAD_TOTAL].sum_weights_sqr; + out_budget->nweights += budget[PLANETS_VOLRAD_TOTAL].nweights; + + /* Update the overall per realisation time accumulator */ + out_time->sum_weights += voxel->time.sum_weights; + out_time->sum_weights_sqr += voxel->time.sum_weights_sqr; + out_time->nweights += voxel->time.nweights; + } + return RES_OK; +} + +/******************************************************************************* + * Local functions + ******************************************************************************/ +res_T +planets_solve_volrad_budget(struct htrdr_planets* cmd) +{ + struct htrdr_solve_buffer_args args = HTRDR_SOLVE_BUFFER_ARGS_NULL; + struct htrdr_accum acc_budget = HTRDR_ACCUM_NULL; + struct htrdr_accum acc_time = HTRDR_ACCUM_NULL; + struct htrdr_estimate estim_budget = HTRDR_ESTIMATE_NULL; + struct htrdr_estimate estim_time = HTRDR_ESTIMATE_NULL; + res_T res = RES_OK; + + /* Preconditions */ + ASSERT(cmd); + ASSERT(cmd->output_type == HTRDR_PLANETS_ARGS_OUTPUT_VOLUMIC_RADIATIVE_BUDGET); + + args.solve_item = solve_volumic_radiative_budget; + args.buffer_layout = cmd->buf_layout; + args.nrealisations = cmd->spt; + args.context = cmd; + + res = htrdr_solve_buffer(cmd->htrdr, &args, cmd->buf); + if(res != RES_OK) goto error; + + /* Nothing more to do on non master processes */ + if(htrdr_get_mpi_rank(cmd->htrdr) != 0) goto exit; + + /* Write outut data */ + res = write_buffer(cmd, cmd->buf, &acc_budget, &acc_time, cmd->output); + if(res != RES_OK) goto error; + + htrdr_accum_get_estimation(&acc_time, &estim_time); + htrdr_accum_get_estimation(&acc_budget, &estim_budget); + + /* Write overall results */ + htrdr_log(cmd->htrdr, "Time per radiative path (in µs): %g +/- %g\n", + estim_time.E, estim_time.SE); + htrdr_log(cmd->htrdr, "Volumic radiative budget (in W/m³): %g +/- %g\n", + estim_budget.E, estim_budget.SE); + +exit: + return res; +error: + goto exit; +} diff --git a/src/planets/htrdr_planets_source.c b/src/planets/htrdr_planets_source.c @@ -1,12 +1,12 @@ -/* Copyright (C) 2018-2019, 2022-2024 Centre National de la Recherche Scientifique +/* 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-2024 Institut Pierre-Simon Laplace - * Copyright (C) 2022-2024 Institut de Physique du Globe de Paris - * Copyright (C) 2018-2024 |Méso|Star> (contact@meso-star.com) - * Copyright (C) 2022-2024 Observatoire de Paris - * Copyright (C) 2022-2024 Université de Reims Champagne-Ardenne - * Copyright (C) 2022-2024 Université de Versaille Saint-Quentin - * Copyright (C) 2018-2019, 2022-2024 Université Paul Sabatier + * 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 @@ -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; diff --git a/src/planets/htrdr_planets_source.h b/src/planets/htrdr_planets_source.h @@ -1,12 +1,12 @@ -/* Copyright (C) 2018-2019, 2022-2024 Centre National de la Recherche Scientifique +/* 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-2024 Institut Pierre-Simon Laplace - * Copyright (C) 2022-2024 Institut de Physique du Globe de Paris - * Copyright (C) 2018-2024 |Méso|Star> (contact@meso-star.com) - * Copyright (C) 2022-2024 Observatoire de Paris - * Copyright (C) 2022-2024 Université de Reims Champagne-Ardenne - * Copyright (C) 2022-2024 Université de Versaille Saint-Quentin - * Copyright (C) 2018-2019, 2022-2024 Université Paul Sabatier + * 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 diff --git a/src/planets/test_htrdr_planets_source.c b/src/planets/test_htrdr_planets_source.c @@ -1,12 +1,12 @@ -/* Copyright (C) 2018-2019, 2022-2024 Centre National de la Recherche Scientifique +/* 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-2024 Institut Pierre-Simon Laplace - * Copyright (C) 2022-2024 Institut de Physique du Globe de Paris - * Copyright (C) 2018-2024 |Méso|Star> (contact@meso-star.com) - * Copyright (C) 2022-2024 Observatoire de Paris - * Copyright (C) 2022-2024 Université de Reims Champagne-Ardenne - * Copyright (C) 2022-2024 Université de Versaille Saint-Quentin - * Copyright (C) 2018-2019, 2022-2024 Université Paul Sabatier + * 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 @@ -177,6 +177,51 @@ test_spectrum(struct htrdr* htrdr) } static void +test_spectrum_1_entry(struct htrdr* htrdr) +{ + struct htrdr_ran_wlen_discrete_create_args distrib_args = + HTRDR_RAN_WLEN_DISCRETE_CREATE_ARGS_NULL; + struct htrdr_ran_wlen_discrete* distrib = NULL; + + struct htrdr_planets_source_args source_args = HTRDR_PLANETS_SOURCE_ARGS_NULL; + struct htrdr_planets_source_spectrum spectrum; + struct htrdr_planets_source* source = NULL; + + FILE* fp = NULL; + char rnrl_filename[] = "rnrl.bin"; + double range[2] = {0,0}; + double lambda = 0; + double pdf = 0; + + CHK(fp = fopen(rnrl_filename, "w")); + write_per_wlen_radiances(fp, 4096, 1, 16, 16); + CHK(fclose(fp) == 0); + + source_args.rnrl_filename = rnrl_filename; + source_args.longitude = 0; + source_args.latitude = 0; + source_args.distance = 0; + source_args.radius = 1; + source_args.temperature = -1; + CHK(htrdr_planets_source_create(htrdr, &source_args, &source) == RES_OK); + + range[0] = range[1] = 0; + CHK(htrdr_planets_source_get_spectrum(source, range, &spectrum) == RES_OK); + + distrib_args.get = htrdr_planets_source_spectrum_at; + distrib_args.nwavelengths = spectrum.size; + distrib_args.context = &spectrum; + CHK(htrdr_ran_wlen_discrete_create(htrdr, &distrib_args, &distrib) == RES_OK); + + lambda = htrdr_ran_wlen_discrete_sample(distrib, 0.3, 0.5, &pdf); + CHK(lambda == 0); + CHK(pdf == 1); + + htrdr_planets_source_ref_put(source); + htrdr_ran_wlen_discrete_ref_put(distrib); +} + +static void test_spectrum_fail(struct htrdr* htrdr) { struct htrdr_planets_source_args source_args = HTRDR_PLANETS_SOURCE_ARGS_NULL; @@ -237,7 +282,7 @@ test_spectrum_from_files(struct htrdr* htrdr, int argc, char** argv) struct htrdr_planets_source_args source_args = HTRDR_PLANETS_SOURCE_ARGS_NULL; struct htrdr_planets_source_spectrum spectrum = HTRDR_PLANETS_SOURCE_SPECTRUM_NULL; struct htrdr_planets_source* source = NULL; - size_t i; + int i; source_args.longitude = 0; source_args.latitude = 0; @@ -291,6 +336,7 @@ main(int argc, char** argv) test_spectrum_from_files(htrdr, argc, argv); } else { test_spectrum(htrdr); + test_spectrum_1_entry(htrdr); test_spectrum_fail(htrdr); }