stardis-green

Post-processing of green functions
git clone git://git.meso-star.fr/stardis-green.git
Log | Files | Refs | README | LICENSE

commit 9e07d0b27c6c535724d158cc57a8b2d2e644f548
parent 1fad7bc43ce62dd0b3db024032a01b2396080b4a
Author: Christophe Coustet <christophe.coustet@meso-star.com>
Date:   Wed, 25 Nov 2020 16:08:51 +0100

Merge branch 'release_0.1.1'

Diffstat:
MREADME.md | 6++++++
Mcmake/CMakeLists.txt | 16+++++++---------
Mdoc/sgreen-input.5.txt | 8++++----
Mdoc/sgreen-output.5.txt | 8+++++---
Mdoc/sgreen.1.txt.in | 4++--
Msrc/green-compute.c | 1+
Msrc/green-input.c | 21++++++++++++++++-----
Msrc/green-main.c | 4++--
8 files changed, 43 insertions(+), 25 deletions(-)

diff --git a/README.md b/README.md @@ -24,6 +24,12 @@ variable the install directories of its dependencies. ## Release notes +### Version 0.1.1 + +- Check binary Green file format version (this require stardis 0.5.1). +- Man improvement. +- Ensure C89 compatibility. + ### Version 0.1 - Compatible with stardis v0.5.0 binary Green function files. diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt @@ -42,7 +42,7 @@ configure_file(${GREEN_SOURCE_DIR}/../doc/sgreen.1.txt.in set(GREEN_VERSION_MAJOR 0) set(GREEN_VERSION_MINOR 1) -set(GREEN_VERSION_PATCH 0) +set(GREEN_VERSION_PATCH 1) set(GREEN_VERSION ${GREEN_VERSION_MAJOR}.${GREEN_VERSION_MINOR}.${GREEN_VERSION_PATCH}) configure_file(${GREEN_SOURCE_DIR}/green-default.h.in @@ -113,18 +113,16 @@ rcmake_prepend_path(GREEN_FILES_DOC ${PROJECT_SOURCE_DIR}/../) add_executable(sgreen ${GREEN_FILES_SRC} ${GREEN_FILES_INC}) - + +set_target_properties(sgreen PROPERTIES + COMPILE_FLAGS "${OpenMP_C_FLAGS}" + VERSION ${GREEN_VERSION}) + if(CMAKE_COMPILER_IS_GNUCC) set(MATH_LIB m) - set_target_properties(sgreen PROPERTIES - COMPILE_FLAGS "-std=c99 ${OpenMP_C_FLAGS}" - LINK_FLAGS "${OpenMP_C_FLAGS}" - VERSION ${GREEN_VERSION}) + set_target_properties(sgreen PROPERTIES LINK_FLAGS "${OpenMP_C_FLAGS}") elseif(MSVC) set(GETOPT_LIB MuslGetopt) - set_target_properties(sgreen PROPERTIES - COMPILE_FLAGS ${OpenMP_C_FLAGS} - VERSION ${GREEN_VERSION}) endif() target_link_libraries(sgreen diff --git a/doc/sgreen-input.5.txt b/doc/sgreen-input.5.txt @@ -46,23 +46,23 @@ _______ <settings-file> ::= <settings-line> [ <settings-file> ] -<settings-line> ::= [ <variable> "=" <value> ] [ <settings-line> ] [ comment ] +<settings-line> ::= [ <var> "=" <value> ] [ <settings-line> ] [ comment ] ------------------------------------- -<variable> ::= <description-name>"."<field> +<var> ::= <description-name>"."<field> | "AMBIENT" # set ambient radiative temperature value <value> ::= REAL <comment> ::= "#" Any text introduced by the # character -<description-name> ::= STRING # no space allowed +<description-name> ::= STRING # no space allowed <field> ::= "T" # set the temperature value | "F" # set the flux value | "VP" # set the volumic power value - + ______________ NAMES diff --git a/doc/sgreen-output.5.txt b/doc/sgreen-output.5.txt @@ -28,7 +28,7 @@ The type of the data that are generated depends on the options used when *sgreen*(1) is invoked. When invoked with option *-a*, *sgreen*(1) outputs Monte-Carlo results, either in extended or compact format, whether option *-e* is used or not. Also, when invoked whith option *-s* *sgreen*(1) outputs an -HTML file contening a summary of the Green function used. +HTML file contening a summary of the Green function used. GRAMMAR ------- @@ -44,7 +44,8 @@ in a description is a comment and is not part of the output. _______ <output> ::= <MC-result> - <output> # as many ouput lines as provided setting lines + <output> # as many ouput lines as provided setting + # lines <MC-result> ::= <compact-MC-result> | <extended-MC-result> @@ -53,7 +54,8 @@ _______ <compact-MC-result> ::= <estimate> <standard-deviation> -<extended-MC-result> ::= <estimate> "+/-" <standard-deviation> ";" <applied-settings> +<extended-MC-result> ::= <estimate> "+/-" <standard-deviation> \ + ";" <applied-settings> <estimate> ::= REAL diff --git a/doc/sgreen.1.txt.in b/doc/sgreen.1.txt.in @@ -48,7 +48,7 @@ information on the system in an unbiased and very-fast statistical model. *sgreen*(1) also provides an additional functionality: summarize information on a Green function in HTML format to help understand what matters on the -simulated system. +simulated system. OPTIONS ------- @@ -95,7 +95,7 @@ function and output the corresponding Monte-Carlo results to stdout in extended format. Set verbosity level to 2. $ sgreen -g cube.green -a cube_settings.txt -e -V 2 - + Create a summary of the *heatsink.green* Green function and write it in the *heatsink_green.html* file; also apply the settings from the file *heatsink_settings.txt* and output the corresponding Monte-Carlo results to diff --git a/src/green-compute.c b/src/green-compute.c @@ -440,6 +440,7 @@ parse_line const struct str* keep_line; struct str line; ASSERT(file_name && green && settings && logs && idx >= 0); + (void)file_name; keep_line = darray_str_cdata_get(&green->settings) + idx; str_init(green->allocator, &line); diff --git a/src/green-input.c b/src/green-input.c @@ -61,18 +61,29 @@ read_green_function res_T res = RES_OK; unsigned i; char* pool_ptr; - char expected[] = "BINGREEN"; - char tmp[sizeof(expected)]; + const char expected_green_string[] = "GREEN_BIN_FILE:"; + const unsigned expected_file_fmt_version = 1; + char green_string[sizeof(expected_green_string)]; + unsigned file_fmt_version; ASSERT(green && stream); - /* Check Green string */ - FR(tmp, sizeof(tmp)); - if(strncmp(expected, tmp, sizeof(expected))) { + /* Check Green string and file format version */ + FR(green_string, sizeof(green_string)); + if(strncmp(expected_green_string, green_string, sizeof(expected_green_string))) + { logger_print(green->logger, LOG_ERROR, "File is not a binary Green file.\n"); res = RES_BAD_ARG; goto error; } + FR(&file_fmt_version, 1); + if(expected_file_fmt_version != file_fmt_version) { + logger_print(green->logger, LOG_ERROR, + "Incompatible file format version (%u VS expected %u).\n", + file_fmt_version, expected_file_fmt_version); + res = RES_BAD_ARG; + goto error; + } /* Read counts */ FR(&green->counts, 1); diff --git a/src/green-main.c b/src/green-main.c @@ -123,8 +123,8 @@ exit: char dump[4096] = { '\0' }; MEM_DUMP(&allocator, dump, sizeof(dump)); fprintf(stderr, "%s\n", dump); - fprintf(stderr, "\nMemory leaks: %zu Bytes\n", - MEM_ALLOCATED_SIZE(&allocator)); + fprintf(stderr, "\nMemory leaks: %lu Bytes\n", + (unsigned long)MEM_ALLOCATED_SIZE(&allocator)); } mem_shutdown_proxy_allocator(&allocator); }