rngrd

Describe a surface and its physical properties
git clone git://git.meso-star.fr/rngrd.git
Log | Files | Refs | README | LICENSE

commit 88a05887ba9e842d0ab84e87c26283d1ead4d315
parent 9e0971934d926c98b34f5422916969042d4bc143
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Tue, 31 Oct 2023 12:25:28 +0100

Merge branch 'feature_posix_make' into develop

Diffstat:
M.gitignore | 14+++++++-------
AMakefile | 169+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
MREADME.md | 55++++++++++++++++++++++++-------------------------------
Dcmake/CMakeLists.txt | 148-------------------------------------------------------------------------------
Aconfig.mk | 120+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Ddoc/rnsp.5.scd | 84-------------------------------------------------------------------------------
Amake.sh | 46++++++++++++++++++++++++++++++++++++++++++++++
Arngrd.pc.in | 17+++++++++++++++++
Arnsp.5 | 107+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/rngrd.c | 2+-
Msrc/rngrd_mesh.c | 5++++-
Msrc/rngrd_properties.c | 2+-
12 files changed, 496 insertions(+), 273 deletions(-)

diff --git a/.gitignore b/.gitignore @@ -1,12 +1,12 @@ .gitignore -CMakeCache.txt -CMakeFiles -Makefile -tmp [Bb]uild* *.sw[po] -*.[ao] -*.orig +*.[aod] +*.so *~ +test* +!test*.[ch] +.config +.test tags - +*.pc diff --git a/Makefile b/Makefile @@ -0,0 +1,169 @@ +# Copyright (C) 2022, 2023 Centre National de la Recherche Scientifique +# Copyright (C) 2022, 2023 Institut Pierre-Simon Laplace +# Copyright (C) 2022, 2023 Institut de Physique du Globe de Paris +# Copyright (C) 2022, 2023 |Méso|Star> (contact@meso-star.com) +# Copyright (C) 2022, 2023 Observatoire de Paris +# Copyright (C) 2022, 2023 Université de Reims Champagne-Ardenne +# Copyright (C) 2022, 2023 Université de Versaille Saint-Quentin +# Copyright (C) 2022, 2023 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 = librngrd.a +LIBNAME_SHARED = librngrd.so +LIBNAME = $(LIBNAME_$(LIB_TYPE)) + +################################################################################ +# Library building +################################################################################ +SRC = src/rngrd.c src/rngrd_log.c src/rngrd_mesh.c src/rngrd_properties.c +OBJ = $(SRC:.c=.o) +DEP = $(SRC:.c=.d) + +build_library: .config $(DEP) + @$(MAKE) -fMakefile $$(for i in $(DEP); do echo -f $${i}; done) \ + $$(if [ -n "$(LIBNAME)" ]; then \ + echo "$(LIBNAME)"; \ + else \ + echo "$(LIBNAME_SHARED)"; \ + fi) + +$(DEP) $(OBJ): config.mk + +$(LIBNAME_SHARED): $(OBJ) + $(CC) $(CFLAGS_SO) $(DPDC_CFLAGS) -o $@ $(OBJ) $(LDFLAGS_SO) $(DPDC_LIBS) + +$(LIBNAME_STATIC): librngrd.o + $(AR) -rc $@ $? + $(RANLIB) $@ + +librngrd.o: $(OBJ) + $(LD) -r $(OBJ) -o $@ + $(OBJCOPY) $(OCPFLAGS) $@ + +.config: config.mk + @if ! $(PKG_CONFIG) --atleast-version $(MRUMTL_VERSION) mrumtl; then \ + echo "mrumtl $(MRUMTL_VERSION) not found" >&2; exit 1; fi + @if ! $(PKG_CONFIG) --atleast-version $(RNSL_VERSION) rnsl; then \ + echo "rnsl $(RNSL_VERSION) not found" >&2; exit 1; fi + @if ! $(PKG_CONFIG) --atleast-version $(RSYS_VERSION) rsys; then \ + echo "rsys $(RSYS_VERSION) not found" >&2; exit 1; fi + @if ! $(PKG_CONFIG) --atleast-version $(S3D_VERSION) s3d; then \ + echo "s3d $(S3D_VERSION) not found" >&2; exit 1; fi + @if ! $(PKG_CONFIG) --atleast-version $(SBUF_VERSION) sbuf; then \ + echo "sbuf $(SBUF_VERSION) not found" >&2; exit 1; fi + @if ! $(PKG_CONFIG) --atleast-version $(SMSH_VERSION) smsh; then \ + echo "smsh $(SMSH_VERSION) not found" >&2; exit 1; fi + @if ! $(PKG_CONFIG) --atleast-version $(SSF_VERSION) ssf; then \ + echo "ssf $(SSF_VERSION) not found" >&2; exit 1; fi + @echo "config done" > $@ + +.SUFFIXES: .c .d .o +.c.d: + @$(CC) $(CFLAGS_SO) $(DPDC_CFLAGS) -MM -MT "$(@:.d=.o) $@" $< -MF $@ + +.c.o: + $(CC) $(CFLAGS_SO) $(DPDC_CFLAGS) -DRNGRD_SHARED_BUILD -c $< -o $@ + +################################################################################ +# Installation +################################################################################ +pkg: + sed -e 's#@PREFIX@#$(PREFIX)#g'\ + -e 's#@VERSION@#$(VERSION)#g'\ + -e 's#@MRUMTL_VERSION@#$(MRUMTL_VERSION)#g'\ + -e 's#@RNSL_VERSION@#$(RNSL_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#@SMSH_VERSION@#$(SMSH_VERSION)#g'\ + -e 's#@SSF_VERSION@#$(SSF_VERSION)#g'\ + rngrd.pc.in > rngrd.pc + +rngrd-local.pc: rngrd.pc.in + sed -e '1d'\ + -e 's#^includedir=.*#includedir=./src/#'\ + -e 's#^libdir=.*#libdir=./#'\ + -e 's#@VERSION@#$(VERSION)#g'\ + -e 's#@MRUMTL_VERSION@#$(MRUMTL_VERSION)#g'\ + -e 's#@RNSL_VERSION@#$(RNSL_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#@SMSH_VERSION@#$(SMSH_VERSION)#g'\ + -e 's#@SSF_VERSION@#$(SSF_VERSION)#g'\ + rngrd.pc.in > $@ + +install: build_library pkg + @$(SHELL) make.sh install "$(DESTDIR)$(PREFIX)/lib" $(LIBNAME) + @$(SHELL) make.sh install "$(DESTDIR)$(PREFIX)/lib/pkgconfig" rngrd.pc + @$(SHELL) make.sh install "$(DESTDIR)$(PREFIX)/include/rad-net" src/rngrd.h + @$(SHELL) make.sh install "$(DESTDIR)$(PREFIX)/share/doc/rngrd" COPYING README.md + @$(SHELL) make.sh install "$(DESTDIR)$(PREFIX)/share/man/man5" rnsp.5 + +uninstall: + rm -f "$(DESTDIR)$(PREFIX)/lib/$(LIBNAME)" + rm -f "$(DESTDIR)$(PREFIX)/lib/pkgconfig/rngrd.pc" + rm -f "$(DESTDIR)$(PREFIX)/share/doc/rngrd/COPYING" + rm -f "$(DESTDIR)$(PREFIX)/share/doc/rngrd/README.md" + rm -f "$(DESTDIR)$(PREFIX)/include/rad-net/rngrd.h" + rm -f "$(DESTDIR)$(PREFIX)/share/man/man5/rnsp.5" + +################################################################################ +# Miscellaneous targets +################################################################################ +all: build_library build_tests + +clean: clean_test + rm -f $(OBJ) $(LIBNAME) + rm -f .config librngrd.o rngrd.pc rngrd-local.pc + +distclean: clean + rm -f $(DEP) src/test_rngrd.d + +lint: + shellcheck -o all make.sh + mandoc -Tlint -Wall rnsp.5 || [ $$? -le 1 ] + +################################################################################ +# Tests +################################################################################ +TEST_SRC = src/test_rngrd.c +TEST_OBJ = $(TEST_SRC:.c=.o) +TEST_DEP = $(TEST_SRC:.c=.d) + +PKG_CONFIG_LOCAL = PKG_CONFIG_PATH="./:$${PKG_CONFIG_PATH}" $(PKG_CONFIG) +RNGRD_CFLAGS = $$($(PKG_CONFIG_LOCAL) $(PCFLAGS) --cflags rngrd-local.pc) +RNGRD_LIBS = $$($(PKG_CONFIG_LOCAL) $(PCFLAGS) --libs rngrd-local.pc) + +build_tests: build_library src/test_rngrd.d + @$(MAKE) -fMakefile -f src/test_rngrd.d test_rngrd + +clean_test: + rm -f test_rngrd src/test_rngrd.o + +$(TEST_DEP): config.mk rngrd-local.pc + @$(CC) $(CFLAGS_EXE) $(RNGRD_CFLAGS) $(RSYS_CFLAGS) \ + -MM -MT "$(@:.d=.o) $@" $(@:.d=.c) -MF $@ + +src/test_rngrd.o: config.mk rngrd-local.pc + $(CC) $(CFLAGS_EXE) $(RNGRD_CFLAGS) $(RSYS_CFLAGS) -c $(@:.o=.c) -o $@ + +test_rngrd: src/test_rngrd.o config.mk rngrd-local.pc $(LIBNAME) + $(CC) $(CFLAGS_EXE) -o $@ src/$@.o $(LDFLAGS_EXE) $(RNGRD_LIBS) $(RSYS_LIBS) diff --git a/README.md b/README.md @@ -1,40 +1,33 @@ # Rad-Net GRounD -This C library loads and manages data representing the ground of a telluric -planet whose geometry is described by a -[Start-Mesh](https://gitlab.com/meso-star/star-mesh) file and radiative -properties loaded from [MruMtl](https://gitlab.com/meso-star/mrumtl) files. - -## How to build - -This library is compatible with 64-bits POSIX systems. It relies the -[CMake](http://www.cmake.org) and the -[RCMake](https://gitlab.com/vaplv/rcmake/) packages to build. It also depends -on the -[MruMtl](https://gitlab.com/meso-star/mrumtl), -[RNSL](htpps://gitlab.com/meso-star/rnsl), -[RSys](https://gitlab.com/vaplv/rsys/), -[Star-3D](https://gitlab.com/meso-star/star-3d), -[Star-Buffer](https://gitlab.com/meso-star/star-buffer), -[Star-Mesh](https://gitlab.com/meso-star/star-mesh) and -[Star-ScatteringFunctions](https://gitlab.com/meso-star/star-sf) -libraries. It optionally depends on [scdoc](https://sr.ht/~sircmpwn/scdoc/) -which, if available, is used to generate the man pages. - -First ensure that CMake is installed on your system. Then install the RCMake -package as well as the aforementioned prerequisites. Finally generate the -project from the `cmake/CMakeLists.txt` file by appending to the -`CMAKE_PREFIX_PATH` variable the install directories of its dependencies. The -resulting project can be edited, built, tested and installed as any CMake -project. Refer to the [CMake documentation](https://cmake.org/documentation) -for further informations on CMake. - -## Copyright notice +This C library loads and manages the geometric data and physical properties of +of a telluric planet's ground. + +## Requirements + +- C compiler +- POSIX make +- pkg-config +- [ModRadUrb: MaTeriaL](https://gitlab.com/meso-star/mrumtl) +- [Rad-Net String List](https://gitlab.com/meso-star/rnsl) +- [RSys](https://gitlab.com/vaplv/rsys) +- [Star 3D](https://gitlab.com/meso-star/star-3d) +- [Star Buffer](https://gitlab.com/meso-star/star-buffer) +- [Star Mesh](https://gitlab.com/meso-star/star-mesh) +- [Star Scattering Functions](https://gitlab.com/meso-star/star-sf) + +## Installation + +Edit config.mk as needed, then run: + + make clean install + +## Copyrights Copyright (C) 2022, 2023 Centre National de la Recherche Scientifique Copyright (C) 2022, 2023 Institut Pierre-Simon Laplace Copyright (C) 2022, 2023 Institut de Physique du Globe de Paris -Copyright (C) 2022, 2023 [|Méso|Star>](https://www.meso-star.com) (<contact@meso-star.com>) +Copyright (C) 2022, 2023 [|Méso|Star>](https://www.meso-star.com) (contact@meso-star.com) Copyright (C) 2022, 2023 Observatoire de Paris Copyright (C) 2022, 2023 Université de Reims Champagne-Ardenne Copyright (C) 2022, 2023 Université de Versaille Saint-Quentin diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt @@ -1,148 +0,0 @@ -# Copyright (C) 2022, 2023 Centre National de la Recherche Scientifique -# Copyright (C) 2022, 2023 Institut Pierre-Simon Laplace -# Copyright (C) 2022, 2023 Institut de Physique du Globe de Paris -# Copyright (C) 2022, 2023 |Meso|Star> (contact@meso-star.com) -# Copyright (C) 2022, 2023 Observatoire de Paris -# Copyright (C) 2022, 2023 Université de Reims Champagne-Ardenne -# Copyright (C) 2022, 2023 Université de Versaille Saint-Quentin -# Copyright (C) 2022, 2023 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/>. - -cmake_minimum_required(VERSION 3.1) -project(rngrd C) -enable_testing() - -set(RNGRD_SOURCE_DIR ${PROJECT_SOURCE_DIR}/../src) -option(NO_TEST "Do not build tests" OFF) - -################################################################################ -# Check dependencies -################################################################################ -find_package(MruMtl 0.1 REQUIRED) -find_package(RCMake 0.4 REQUIRED) -find_package(RNSL REQUIRED) -find_package(RSys 0.9 REQUIRED) -find_package(Star3D 0.8 REQUIRED) -find_package(StarBuffer REQUIRED) -find_package(StarMesh REQUIRED) -find_package(StarSF 0.7 REQUIRED) - -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${RCMAKE_SOURCE_DIR}) -include(rcmake) -include(rcmake_runtime) - -include_directories( - ${MruMtl_INCLUDE_DIR} - ${RNSL_INCLUDE_DIR} - ${RSys_INCLUDE_DIR} - ${Star3D_INCLUDE_DIR} - ${StarBuffer_INCLUDE_DIR} - ${StarMesh_INCLUDE_DIR} - ${StarSF_INCLUDE_DIR}) - -################################################################################ -# Configure and define targets -################################################################################ -set(VERSION_MAJOR 0) -set(VERSION_MINOR 0) -set(VERSION_PATCH 0) -set(VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}) - -set(RNGRD_FILES_SRC - rngrd.c - rngrd_log.c - rngrd_mesh.c - rngrd_properties.c) -set(RNGRD_FILES_INC - rngrd_c.h - rngrd_log.h) -set(RNGRD_FILES_INC_API rngrd.h) -set(RNGRD_FILES_DOC COPYING README.md) - -# Prepend each file in the `RNGRD_FILES_<SRC|INC>' list by `RNGRD_SOURCE_DIR' -rcmake_prepend_path(RNGRD_FILES_SRC ${RNGRD_SOURCE_DIR}) -rcmake_prepend_path(RNGRD_FILES_INC ${RNGRD_SOURCE_DIR}) -rcmake_prepend_path(RNGRD_FILES_INC_API ${RNGRD_SOURCE_DIR}) -rcmake_prepend_path(RNGRD_FILES_DOC ${PROJECT_SOURCE_DIR}/../) - -add_library(rngrd SHARED ${RNGRD_FILES_SRC} ${RNGRD_FILES_INC} ${RNGRD_FILES_INC_API}) -target_link_libraries(rngrd MruMtl RNSL RSys Star3D StarBuffer StarMesh StarSF) - -if(CMAKE_COMPILER_IS_GNUCC) - target_link_libraries(rngrd m) -endif() - -set_target_properties(rngrd PROPERTIES - DEFINE_SYMBOL RNGRD_SHARED_BUILD - VERSION ${VERSION} - SOVERSION ${VERSION_MAJOR}) - -rcmake_setup_devel(rngrd RNGRD ${VERSION} rad-net/rngrd_version.h) - -################################################################################ -# Add tests -################################################################################ -if(NOT NO_TEST) - function(build_test _name) - add_executable(${_name} - ${RNGRD_SOURCE_DIR}/${_name}.c) - target_link_libraries(${_name} rngrd RSys) - endfunction() - - function(new_test _name) - build_test(${_name}) - add_test(${_name} ${_name}) - endfunction() - - build_test(test_rngrd) - -endif() - -################################################################################ -# Man page -############################################################################### -find_program(SCDOC NAMES scdoc) -if(NOT SCDOC) - message(WARNING - "The `scdoc' program is missing. " - "The Rad Net GRounD man page cannot be generated.") -else() - set(_man_names rnsp.5) - - foreach(_man IN LISTS _man_names) - set(_src ${PROJECT_SOURCE_DIR}/../doc/${_man}.scd) - add_custom_command( - OUTPUT ${_man} - COMMAND ${SCDOC} < ${_src} > ${_man} - DEPENDS ${_src} - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - COMMENT "Buid ROFF man page ${_man}" - VERBATIM) - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${_man} DESTINATION share/man/man5) - endforeach() - add_custom_target(man-roff ALL DEPENDS ${_man_names}) -endif() - - -################################################################################ -# Define output & install directories -################################################################################ -install(TARGETS rngrd - ARCHIVE DESTINATION bin - LIBRARY DESTINATION lib - RUNTIME DESTINATION bin) -install(FILES ${RNGRD_FILES_INC_API} DESTINATION include/rad-net) -install(FILES ${RNGRD_FILES_DOC} DESTINATION share/doc/rngrd) - diff --git a/config.mk b/config.mk @@ -0,0 +1,120 @@ +VERSION = 0.0.0 +PREFIX = /usr/local + +LIB_TYPE = SHARED +#LIB_TYPE = STATIC + +BUILD_TYPE = RELEASE +#BUILD_TYPE = DEBUG + +################################################################################ +# Tools +################################################################################ +AR = ar +CC = cc +LD = ld +OBJCOPY = objcopy +PKG_CONFIG = pkg-config +RANLIB = ranlib + +################################################################################ +# Dependencies +################################################################################ +PCFLAGS_SHARED = +PCFLAGS_STATIC = --static +PCFLAGS = $(PCFLAGS_$(LIB_TYPE)) + +MRUMTL_VERSION = 0.2 +MRUMTL_CFLAGS = $$($(PKG_CONFIG) $(PCFLAGS) --cflags mrumtl) +MRUMTL_LIBS = $$($(PKG_CONFIG) $(PCFLAGS) --libs mrumtl) + +RNSL_VERSION = 0.1 +RNSL_CFLAGS = $$($(PKG_CONFIG) $(PCFLAGS) --cflags rnsl) +RNSL_LIBS = $$($(PKG_CONFIG) $(PCFLAGS) --libs rnsl) + +RSYS_VERSION = 0.14 +RSYS_CFLAGS = $$($(PKG_CONFIG) $(PCFLAGS) --cflags rsys) +RSYS_LIBS = $$($(PKG_CONFIG) $(PCFLAGS) --libs rsys) + +S3D_VERSION = 0.10 +S3D_CFLAGS = $$($(PKG_CONFIG) $(PCFLAGS) --cflags s3d) +S3D_LIBS = $$($(PKG_CONFIG) $(PCFLAGS) --libs s3d) + +SBUF_VERSION = 0.1 +SBUF_CFLAGS = $$($(PKG_CONFIG) $(PCFLAGS) --cflags sbuf) +SBUF_LIBS = $$($(PKG_CONFIG) $(PCFLAGS) --libs sbuf) + +SMSH_VERSION = 0.1 +SMSH_CFLAGS = $$($(PKG_CONFIG) $(PCFLAGS) --cflags smsh) +SMSH_LIBS = $$($(PKG_CONFIG) $(PCFLAGS) --libs smsh) + +SSF_VERSION = 0.9 +SSF_CFLAGS = $$($(PKG_CONFIG) $(PCFLAGS) --cflags ssf) +SSF_LIBS = $$($(PKG_CONFIG) $(PCFLAGS) --libs ssf) + +DPDC_CFLAGS =\ + $(MRUMTL_CFLAGS)\ + $(RNSL_CFLAGS)\ + $(RSYS_CFLAGS)\ + $(S3D_CFLAGS)\ + $(SBUF_CFLAGS)\ + $(SMSH_CFLAGS)\ + $(SSF_CFLAGS) + +DPDC_LIBS =\ + $(MRUMTL_LIBS)\ + $(RNSL_LIBS)\ + $(RSYS_LIBS)\ + $(S3D_LIBS)\ + $(SBUF_LIBS)\ + $(SMSH_LIBS)\ + $(SSF_LIBS)\ + -lm + +################################################################################ +# Compilation options +################################################################################ +WFLAGS =\ + -Wall\ + -Wcast-align\ + -Wconversion\ + -Wextra\ + -Wmissing-declarations\ + -Wmissing-prototypes\ + -Wshadow + +CFLAGS_HARDENED =\ + -D_FORTIFY_SOURCES=2\ + -fcf-protection=full\ + -fstack-clash-protection\ + -fstack-protector-strong + +CFLAGS_COMMON =\ + -std=c89\ + -pedantic\ + -fvisibility=hidden\ + -fstrict-aliasing\ + $(CFLAGS_HARDENED)\ + $(WFLAGS) + +CFLAGS_DEBUG = -g $(CFLAGS_COMMON) +CFLAGS_RELEASE = -O2 -DNDEBUG $(CFLAGS_COMMON) +CFLAGS = $(CFLAGS_$(BUILD_TYPE)) + +CFLAGS_SO = $(CFLAGS) -fPIC +CFLAGS_EXE = $(CFLAGS) -fPIE + +################################################################################ +# Linker options +################################################################################ +LDFLAGS_HARDENED = -Wl,-z,relro,-z,now +LDFLAGS_DEBUG = $(LDFLAGS_HARDENED) +LDFLAGS_RELEASE = -s $(LDFLAGS_HARDENED) +LDFLAGS = $(LDFLAGS_$(BUILD_TYPE)) + +LDFLAGS_SO = $(LDFLAGS) -shared -Wl,--no-undefined +LDFLAGS_EXE = $(LDFLAGS) -pie + +OCPFLAGS_DEBUG = --localize-hidden +OCPFLAGS_RELEASE = --localize-hidden --strip-unneeded +OCPFLAGS = $(OCPFLAGS_$(BUILD_TYPE)) diff --git a/doc/rnsp.5.scd b/doc/rnsp.5.scd @@ -1,84 +0,0 @@ -rnsp(5) - -; Copyright (C) 2022, 2023 Centre National de la Recherche Scientifique -; Copyright (C) 2022, 2023 Institut Pierre-Simon Laplace -; Copyright (C) 2022, 2023 Institut de Physique du Globe de Paris -; Copyright (C) 2022, 2023 |Méso|Star> (contact@meso-star.com) -; Copyright (C) 2022, 2023 Observatoire de Paris -; Copyright (C) 2022, 2023 Université de Reims Champagne-Ardenne -; Copyright (C) 2022, 2023 Université de Versaille Saint-Quentin -; Copyright (C) 2022, 2023 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/>. - -# NAME - -rnsp - Rad-Net Surface Properties file format - -# DESCRIPTION - -*rnsp* is a binary file format for storing surface mesh properties. The -properties are listed by geometric primitive (for example by triangle). The mesh -to which the properties are attached is _not_ described there but must be -defined in a separate file, for example in an *smsh*(5) file. The number of -available properties and their order should match the geometric primitives -listed in the corresponding mesh. - -A *rnsp* file is actually a Star-Buffer file (see *sbuf*(5)). It starts with a -header of 4 64-bit integers describing the layout of the data. The first integer -is a power of two (usually 4096) that defines the size of the memory page in -bytes to which the list of properties aligns (_pagesize_). The second integer -is the _size_ of the array, i.e. the number of property sets in the list. -Finally, the 2 remaining integers store the memory size (8 bytes) and the -memory alignment (8 bytes) of the property set defined by geometric primitive. - -Padding bytes follow the file header to align the listed properties to -_pagesize_. - -For each geometric primitive, the properties are composed of a 32-bit integer, -which is the material identifier of the primitive (_matid_), and a 32-bit -floating-point number that stores temperature in Kelvin. - -The end of the file is eventually padded with dummy bytes to ensure that the -overall file size is a multiple of _pagesize_. - -# BINARY FILE FORMAT - -Data are encoded with respect to the little endian bytes ordering, i.e. least -significant bytes are stored first. - -``` -<rnsp> ::= <pagesize> <size> 8 8 - <padding> - <properties> - <padding> - -<pagesize> ::= UINT64 -<size> ::= UINT64 # Number of items stored - ---- - -<properties> ::= <property> ... ... -<property> ::= <matid> <temperature> -<matid> ::= UINT32 -<temperature> ::= FLOAT # In K - ---- - -<padding> ::= [ BYTE ... ] # Ensure alignement -``` - -# SEE ALSO - -*sbuf*(5), *smsh*(5) diff --git a/make.sh b/make.sh @@ -0,0 +1,46 @@ +#!/bin/sh + +# Copyright (C) 2022, 2023 Centre National de la Recherche Scientifique +# Copyright (C) 2022, 2023 Institut Pierre-Simon Laplace +# Copyright (C) 2022, 2023 Institut de Physique du Globe de Paris +# Copyright (C) 2022, 2023 |Méso|Star> (contact@meso-star.com) +# Copyright (C) 2022, 2023 Observatoire de Paris +# Copyright (C) 2022, 2023 Université de Reims Champagne-Ardenne +# Copyright (C) 2022, 2023 Université de Versaille Saint-Quentin +# Copyright (C) 2022, 2023 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 + +install() +{ + prefix=$1 + shift 1 + + mkdir -p "${prefix}" + + for i in "$@"; do + dst="${prefix}/${i##*/}" + + if cmp -s "${i}" "${dst}"; then + printf "Up to date %s\n" "${dst}" + else + printf "Installing %s\n" "${dst}" + cp "${i}" "${prefix}" + fi + done +} + +"$@" diff --git a/rngrd.pc.in b/rngrd.pc.in @@ -0,0 +1,17 @@ +prefix=@PREFIX@ +includedir=${prefix}/include +libdir=${prefix}/lib + +Requires: rsys >= @RSYS_VERSION@, s3d >= @S3D_VERSION@ +Requires.private:\ + mrumtl >= @MRUMTL_VERSION@,\ + rnsl >= @RNSL_VERSION@,\ + sbuf >= @SBUF_VERSION@,\ + smsh >= @SMSH_VERSION@,\ + ssf >= @SSF_VERSION@ +Name: rngrd +Description: Rad-Net GRounD +Version: @VERSION@ +Libs: -L${libdir} -lrngrd +Libs.private: -lm +CFlags: -I${includedir} diff --git a/rnsp.5 b/rnsp.5 @@ -0,0 +1,107 @@ +.\" Copyright (C) 2022, 2023 Centre National de la Recherche Scientifique +.\" Copyright (C) 2022, 2023 Institut Pierre-Simon Laplace +.\" Copyright (C) 2022, 2023 Institut de Physique du Globe de Paris +.\" Copyright (C) 2022, 2023 |Méso|Star>(contact@meso-star.com) +.\" Copyright (C) 2022, 2023 Observatoire de Paris +.\" Copyright (C) 2022, 2023 Université de Reims Champagne-Ardenne +.\" Copyright (C) 2022, 2023 Université de Versaille Saint-Quentin +.\" Copyright (C) 2022, 2023 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/>. +.Dd September 15, 2023 +.Dt RNSP 5 +.Os +.Sh NAME +.Nm rnsp +.Nd Rad-Net Surface Properties file format +.Sh DESCRIPTION +.Nm +is a binary file format for storing surface mesh properties. +The properties are listed by geometric primitive +.Pq for example by triangle . +The mesh to which the properties are attached is +.Em not +described there but must be +defined in a separate file, for example in an +.Xr smsh 5 +file. +The number of available properties and their order should match the geometric +primitives listed in the corresponding mesh. +.Pp +A +.Nm +file is actually a Star-Buffer file +.Pq see Xr sbuf 5 . +It starts with a header of 4 integers. +The first integer is a power of two +.Pq usually 4096 +that defines the size of the memory page in bytes +.Pq Va pagesize +on which the list of properties are aligned. +By aligning data to +.Va pagesize , +and depending on system requirements, memory mapping can be used to +automatically load/unload pages on demand +.Pq see Xr mmap 2 . +The second integer is the +.Va size +of the array, i.e. the number of property sets stored in the list. +The 2 remaining integers store the memory size +.Pq 8 bytes +and the memory alignment +.Pq 8 bytes +of the property set defined by geometric primitive. +.Pp +Fill bytes follow the file header to align the listed properties to +.Va pagesize . +.Pp +For each geometric primitive, the properties are composed of a 32-bit integer, +which is the material identifier of the primitive +.Pq Va matid , +and a 32-bit floating-point number that stores temperature in Kelvin. +.Pp +Padding bytes are finally added at the end of the file to align its overall size +with the size of a page. +.Pp +Data are encoded with respect to the little endian bytes ordering, i.e. least +significant bytes are stored first. +.Pp +The file format is as follows: +.Bl -column (temperature) (::=) () +.It Ao Va rnsp Ac Ta ::= Ta Ao Va pagesize Ac Ao Va size Ac Li 8 8 +.It Ta Ta Aq Va padding +.It Ta Ta Aq Va properties +.It Ta Ta Aq Va padding +.It Ao Va pagesize Ac Ta ::= Ta Vt uint64_t +.It Ao Va size Ac Ta ::= Ta Vt uint64_t +# Number of items stored +.It \ Ta Ta +.It Ao Va properties Ac Ta ::= Ta Ao Va property Ac Va ... +.It Ao Va property Ac Ta ::= Ta Ao Va matid Ac Ao Va temperature Ac +.It Ao Va matid Ac Ta ::= Ta Vt uint32_t +.It Ao Va tempeature Ac Ta ::= Ta Vt float +# In K +.It \ Ta Ta +.It Ao Va padding Ac Ta ::= Ta Op Vt int8_t ... +.El +.Sh SEE ALSO +.Xr mmap 2 , +.Xr sbuf 5 , +.Xr smsh 5 +.Sh HISTORY +The +.Nm +format was first developed for the +.Xr htrdr-planeto 1 +program. diff --git a/src/rngrd.c b/src/rngrd.c @@ -24,7 +24,7 @@ #include "rngrd_c.h" #include "rngrd_log.h" -#include <modradurb/mrumtl.h> +#include <mrumtl.h> #include <star/s3d.h> #include <star/sbuf.h> diff --git a/src/rngrd_mesh.c b/src/rngrd_mesh.c @@ -308,6 +308,7 @@ setup_mesh(struct rngrd* ground, const struct rngrd_create_args* args) { struct smsh_create_args smsh_args = SMSH_CREATE_ARGS_DEFAULT; struct smsh_desc smsh_desc = SMSH_DESC_NULL; + struct smsh_load_args smsh_load_args = SMSH_LOAD_ARGS_NULL; struct smsh* smsh = NULL; res_T res = RES_OK; ASSERT(ground && args); @@ -320,7 +321,9 @@ setup_mesh(struct rngrd* ground, const struct rngrd_create_args* args) if(res != RES_OK) goto error; /* Load and retrieve the Star-Mesh data */ - res = smsh_load(smsh, args->smsh_filename); + smsh_load_args.path = args->smsh_filename; + smsh_load_args.memory_mapping = 1; + res = smsh_load(smsh, &smsh_load_args); if(res != RES_OK) goto error; res = smsh_get_desc(smsh, &smsh_desc); if(res != RES_OK) goto error; diff --git a/src/rngrd_properties.c b/src/rngrd_properties.c @@ -24,7 +24,7 @@ #include "rngrd_c.h" #include "rngrd_log.h" -#include <modradurb/mrumtl.h> +#include <mrumtl.h> #include <rad-net/rnsl.h> #include <star/sbuf.h>