Closed jayeshkrishna closed 3 weeks ago
This PR is mostly about getting the casting right for the C++ compiler.
@jayeshkrishna For ADIOS support, there are a few more type casting build errors to be fixed. Steps to reproduce on ANL GCE UB20 nodes:
module load cmake/3.20.5-zyz2eld
module load gcc/11.1.0-qsjmpcg
export PATH=/nfs/gce/projects/climate/software/linux-ubuntu20.04-x86_64/mpich/4.0/gcc-11.1.0/bin:$PATH
git clone --branch jayeshkrishna/move_c_to_cpp https://github.com/E3SM-Project/scorpio.git
cd scorpio
mkdir build
cd build
ADIOS2_DIR=/nfs/gce/projects/climate/software/linux-ubuntu20.04-x86_64/adios2/2.9.1/mpich-4.0/gcc-11.1.0 \
CC=mpicc CXX=mpicxx FC=mpifort cmake -Wno-dev \
-DWITH_ADIOS2=ON \
-DWITH_NETCDF=OFF \
-DPnetCDF_PATH=/nfs/gce/projects/climate/software/linux-ubuntu20.04-x86_64/pnetcdf/1.12.2/mpich-4.0/gcc-11.1.0 \
-DPIO_USE_MALLOC=ON \
-DPIO_ENABLE_EXAMPLES=ON \
..
make
@jayeshkrishna A patch to fix remaining type casting build errors when ADIOS support is enabled:
diff --git a/src/clib/pio_darray.cpp b/src/clib/pio_darray.cpp
index 6ad2691f..2e8cdffb 100644
--- a/src/clib/pio_darray.cpp
+++ b/src/clib/pio_darray.cpp
@@ -1135,7 +1135,7 @@ static int PIOc_write_decomp_adios(file_desc_t *file, int ioid)
if (can_merge_buffers)
{
ierr = MPI_BigAdios_Gatherv(mapbuf, (int)inp_count, m_type, file->block_array,
- file->array_counts, file->array_disp, m_type, 0, file->block_comm);
+ (int *)file->array_counts, (int *)file->array_disp, m_type, 0, file->block_comm);
if (ierr != PIO_NOERR)
{
return pio_err(NULL, file, PIO_EADIOS2ERR, __FILE__, __LINE__, "MPI_BigAdios_Gatherv failed for file (%s, ncid=%d)",
@@ -1840,7 +1840,7 @@ static int PIOc_write_darray_adios(file_desc_t *file, int varid, int ioid,
}
ierr = MPI_BigAdios_Gatherv(databuf, (int)inp_count, m_type, file->block_array,
- file->array_counts, file->array_disp, m_type, 0, file->block_comm);
+ (int *)file->array_counts, (int *)file->array_disp, m_type, 0, file->block_comm);
if (ierr != PIO_NOERR)
{
return pio_err(NULL, file, PIO_EADIOS2ERR, __FILE__, __LINE__, "MPI_BigAdios_Gatherv failed for file (%s, ncid=%d)",
@@ -2727,7 +2727,7 @@ static int PIOc_read_darray_adios(file_desc_t *file, int fndims, io_desc_t *iode
/* Get from cache */
const char *attr_data_buff = NULL;
- attr_data_buff = file->cache_darray_info->get(file->cache_darray_info, att_name);
+ attr_data_buff = (const char *)file->cache_darray_info->get(file->cache_darray_info, att_name);
if (attr_data_buff == NULL)
{
return pio_err(NULL, file, PIO_EADIOS2ERR, __FILE__, __LINE__,
@@ -2756,7 +2756,7 @@ static int PIOc_read_darray_adios(file_desc_t *file, int fndims, io_desc_t *iode
/* Try to read it from cache */
const int *decomp_info_buff = NULL;
- decomp_info_buff = file->cache_darray_info->get(file->cache_darray_info, decomp_name);
+ decomp_info_buff = (const int *)file->cache_darray_info->get(file->cache_darray_info, decomp_name);
if (decomp_info_buff == NULL)
{
/* We should search decomposition array from the step 0 if the decomp info is not in the cache, so we close and open the bp file */
diff --git a/src/clib/pio_getput_int.cpp b/src/clib/pio_getput_int.cpp
index fca4aeee..9bea09a4 100644
--- a/src/clib/pio_getput_int.cpp
+++ b/src/clib/pio_getput_int.cpp
@@ -1700,7 +1700,7 @@ int spio_get_vars_tc(int ncid, int varid, const PIO_Offset *start, const PIO_Off
char varname[PIO_MAX_NAME] = {'\0'};
snprintf(varname, PIO_MAX_NAME, "%d", varid);
- char *mem_buffer = file->cache_data_blocks->get(file->cache_data_blocks, varname);
+ char *mem_buffer = (char*)file->cache_data_blocks->get(file->cache_data_blocks, varname);
if (mem_buffer == NULL)
{
mem_buffer = (char *) calloc(av->adios_type_size, 1);
@@ -1881,7 +1881,7 @@ int spio_get_vars_tc(int ncid, int varid, const PIO_Offset *start, const PIO_Off
char varname_size[PIO_MAX_NAME] = {'\0'};
snprintf(varname_size, PIO_MAX_NAME, "%d %zu sel_size", varid, block_id);
- char *mem_buffer_size = mem_buffer_size = file->cache_block_sizes->get(file->cache_block_sizes, varname_size);
+ char *mem_buffer_size = (char*)file->cache_block_sizes->get(file->cache_block_sizes, varname_size);
if (mem_buffer_size == NULL)
{
mem_buffer_size = (char *) calloc(1, sizeof(size_t));
@@ -1937,7 +1937,7 @@ int spio_get_vars_tc(int ncid, int varid, const PIO_Offset *start, const PIO_Off
char varname[PIO_MAX_NAME] = {'\0'};
snprintf(varname, PIO_MAX_NAME, "%d %zu", varid, block_id);
- char *mem_buffer = file->cache_data_blocks->get(file->cache_data_blocks, varname);
+ char *mem_buffer = (char*)file->cache_data_blocks->get(file->cache_data_blocks, varname);
if (mem_buffer == NULL)
{
mem_buffer = (char *) calloc(var_size, av->adios_type_size);
diff --git a/src/clib/pioc_support.cpp b/src/clib/pioc_support.cpp
index 3153a335..7e3a5d35 100644
--- a/src/clib/pioc_support.cpp
+++ b/src/clib/pioc_support.cpp
@@ -3792,7 +3792,7 @@ static int adios_get_dim_ids(file_desc_t *file, int varid)
if (size_attr > 0)
{
- char **attr_data = (char *) calloc(size_attr, sizeof(char *));
+ char **attr_data = (char **) calloc(size_attr, sizeof(char *));
if (attr_data == NULL)
{
return pio_err(NULL, file, PIO_ENOMEM, __FILE__, __LINE__,
@@ -3941,7 +3941,7 @@ static int adios_get_adios_type(file_desc_t *file, int varid)
adios2_attribute *attr = adios2_inquire_attribute(file->ioH, attr_name);
if (attr != NULL)
{
- int32_t attr_data = adios2_type_unknown;
+ adios2_type attr_data = adios2_type_unknown;
size_t size_attr = 0;
adios2_error adiosErr = adios2_attribute_data(&attr_data, &size_attr, attr);
if (adiosErr != adios2_error_none)
Looking into issues found in builds with support for HDF5 and MPI-Serial libraries
MPI_Serial builds still fail with this version of SCORPIO due to missing const correctness in the MPI serial library headers/functions. This issue will be fixed in the MPI serial library soon.
Moving all C source files to C++. This change should allow us to add more C++ code/features without explicit C interfaces (internal).
(PS: Use "git log --follow src.cpp" to see the entire log history of the moved files)