Saturne 8 - User code compile errors
Posted: Thu Dec 19, 2024 4:44 pm
Hello. I updated Saturne from 7.0.2 to 8.x and found multiple compile errors that I don't know how to resolve correctly.
Configuration is:
==========
Hardware setup: Local server (Dell R620, 24 cores, local MPI)
OS: CentOS 7.5 KDE + vault repo
Kernel: 3.10.0-1160.66.1.el7.x86_64
System gcc: 4.8.5
MPI: OpenMPI-1.8.4 (I consider newer versions problematic)
My old Saturne 7.0.2 version worked good with this configuration. Trying to compile 8.2.0 version I found that it requires full C11 support so I installed devtoolset-7 to obtain newer gcc-7.3.1 (system gcc was not touched, there is a special shell [environment variables] created with "source /opt/rh/devtoolset-7/enable" command). Full C11 support started from gcc-4.9.
With new gcc Saturne compiles without errors, bit I face problems running my user code. It's a small library for relaxation and limitations for stability, heat exchanger model and hand-made gas combustion model.
I started with current feature version 8.2.0. First thing I encountered was user code compilation test error. Digging a bit I found that it originates from including "cs_headers.h". Error is:
It doesn't see Reynolds stress components field pointers. It turned out that, compared with 7.0.2 version, "install/include/code_saturne/cs_field_pointer.h" file is missing lines with these pointer IDs or something. In version 7.0.2, this part looks like:
While in 8.x versions it's:
I added Rxx pointer IDs and this error disappeared, but is it correct method? Why are there no Rxx pointer IDs in newer versions? Behavior is the same for 8.0.4 and 8.2.0 versions.
Then, when I started calculation, another compile error appeared:
This is specific for 8.2.0 version. With 8.0.4, there is no this error.
I compared "cs_meg_source_terms.cxx" for 8.0.4 and 8.2.0 versions and have not found differences in temperature declaration. This line is the same, although functions are some different. For conveniency, here are cs_meg_source_terms functions for different versions.
Saturne 8.0.4:
Saturne 8.2.0:
Is it a bug in 8.2.0 or C++ compatibility problem? I ran these experiments with gcc-7.3.1 from devtoolset-7.
Third error is connected with enthalpy pointer. I have relaxation/limiting "cs_user_parameters.c" file, among others, there are lines:
If I try to use CS_F_(h) I have memory violation error right from the start of calculation. If enthaply-related lines are removed, calculation runs. Also, in 7.0.2 version there is no this problem. Strange thing is that if I look at "cs_field_pointers.h" I see CS_ENUMF_(h) line both in 8.0.4 and 8.2.0 versions. Why does the program doesn't want to set this pointer? It doesn't return NULL cause there is a NULL-pointer check that will not allow memory violation. CS_F_(h) return something not-null but incorrect that leads to memory violation error.
Thanks for your attention.
Configuration is:
==========
Hardware setup: Local server (Dell R620, 24 cores, local MPI)
OS: CentOS 7.5 KDE + vault repo
Kernel: 3.10.0-1160.66.1.el7.x86_64
System gcc: 4.8.5
MPI: OpenMPI-1.8.4 (I consider newer versions problematic)
My old Saturne 7.0.2 version worked good with this configuration. Trying to compile 8.2.0 version I found that it requires full C11 support so I installed devtoolset-7 to obtain newer gcc-7.3.1 (system gcc was not touched, there is a special shell [environment variables] created with "source /opt/rh/devtoolset-7/enable" command). Full C11 support started from gcc-4.9.
With new gcc Saturne compiles without errors, bit I face problems running my user code. It's a small library for relaxation and limitations for stability, heat exchanger model and hand-made gas combustion model.
I started with current feature version 8.2.0. First thing I encountered was user code compilation test error. Digging a bit I found that it originates from including "cs_headers.h". Error is:
Code: Select all
In file included from /Programs/Code_Saturne-8.0.4-MPI-1.8.4/install-std/include/code_saturne/cs_base_headers.h:55:0,
from /Programs/Code_Saturne-8.0.4-MPI-1.8.4/install-std/include/code_saturne/cs_headers.h:41,
from /run/media/antech/WD-Data-500/Storage/Media/Work/PK-176/Saturne/RESU/20241219-1319/src/CmnParSet.c:22:
/Programs/Code_Saturne-8.0.4-MPI-1.8.4/install-std/include/code_saturne/cs_field_pointer.h:51:41: error: ‘CS_FIELD_POINTER_r11’ undeclared (first use in this function); did you mean ‘CS_FIELD_POINTER_f1m’?
Code: Select all
typedef enum {
...
CS_ENUMF_(r11), /*!< Reynolds stress component \f$ R_{xx} \f$ */
CS_ENUMF_(r22), /*!< Reynolds stress component \f$ R_{yy} \f$ */
CS_ENUMF_(r33), /*!< Reynolds stress component \f$ R_{zz} \f$ */
CS_ENUMF_(r12), /*!< Reynolds stress component \f$ R_{xy} \f$ */
CS_ENUMF_(r23), /*!< Reynolds stress component \f$ R_{yz} \f$ */
CS_ENUMF_(r13), /*!< Reynolds stress component \f$ R_{xz} \f$ */
CS_ENUMF_(rij), /*!< Reynolds stress tensor \f$ R_{ij} \f$ */
...
}
Code: Select all
typedef enum {
...
CS_ENUMF_(rij), /*!< Reynolds stress tensor \f$ R_{ij} \f$ */
...
}
Then, when I started calculation, another compile error appeared:
Code: Select all
/run/media/antech/WD-Data-500/Storage/Media/Work/PK-176/Saturne/RESU/20241219-1307/src/cs_meg_source_terms.cxx:52:13: error: ‘temperature’ does not name a type; did you mean ‘temperature_vals’?
const temperature = temperature_vals[c_id];
^~~~~~~~~~~
I compared "cs_meg_source_terms.cxx" for 8.0.4 and 8.2.0 versions and have not found differences in temperature declaration. This line is the same, although functions are some different. For conveniency, here are cs_meg_source_terms functions for different versions.
Saturne 8.0.4:
Code: Select all
cs_real_t *
cs_meg_source_terms(const char *zone_name,
const cs_lnum_t n_elts,
const cs_lnum_t *elt_ids,
const cs_real_t xyz[][3],
const char *name,
const char *source_type)
{
cs_real_t *new_vals = NULL;
/* User defined source term for temperature over zone DUCT
-------------------------------------------------------- */
if (strcmp(zone_name, "DUCT") == 0 &&
strcmp(name, "temperature") == 0 &&
strcmp(source_type, "thermal_source_term") == 0) {
const cs_lnum_t vals_size = n_elts * 2;
BFT_MALLOC(new_vals, vals_size, cs_real_t);
const cs_real_t *temperature_vals = cs_field_by_name("temperature")->val;
for (cs_lnum_t e_id = 0; e_id < n_elts; e_id++) {
cs_lnum_t c_id = elt_ids[e_id];
const temperature = temperature_vals[c_id];
new_vals[2 * e_id + 0] = - 0 * 1.07E3 * (temperature - 118);
new_vals[2 * e_id + 1] = 0;
}
}
return new_vals;
}
Code: Select all
void
cs_meg_source_terms(const char *zone_name,
const cs_lnum_t n_elts,
const cs_lnum_t *elt_ids,
const cs_real_t xyz[][3],
const char *name,
const char *source_type,
cs_real_t *retvals)
{
/* User defined source term for temperature over zone DUCT
-------------------------------------------------------- */
if (strcmp(zone_name, "DUCT") == 0 &&
strcmp(name, "temperature") == 0 &&
strcmp(source_type, "thermal_source_term") == 0) {
const cs_real_t *temperature_vals = cs_field_by_name("temperature")->val;
for (cs_lnum_t e_id = 0; e_id < n_elts; e_id++) {
cs_lnum_t c_id = elt_ids[e_id];
const temperature = temperature_vals[c_id];
retvals[2 * e_id + 0] = - 0 * 1.07E3 * (temperature - 118);
retvals[2 * e_id + 1] = 0;
}
}
}
Third error is connected with enthalpy pointer. I have relaxation/limiting "cs_user_parameters.c" file, among others, there are lines:
Code: Select all
field=CS_F_(h); /* Field structure */
if (field!=NULL) /* Field present */
{
eqnPar=cs_field_get_equation_param(field); /* Field options structure */
eqnPar->relaxv=entRlxCoef; /* Relaxation factor */
};
Thanks for your attention.