diff --git a/bfps/cpp/particles/p2p_distr_mpi.hpp b/bfps/cpp/particles/p2p_distr_mpi.hpp
index 31d5f4f81d97bbf7373a3530a47afff661d2d737..740aba18a0d353a8fb96ca699481e748bdb5d5b8 100644
--- a/bfps/cpp/particles/p2p_distr_mpi.hpp
+++ b/bfps/cpp/particles/p2p_distr_mpi.hpp
@@ -351,6 +351,7 @@ public:
 
         // Offset per cell layers
         long int previous_index = 0;
+        variable_used_only_in_assert(previous_index);
         std::unique_ptr<partsize_t[]> particles_offset_layers(new partsize_t[my_nb_cell_levels+1]());
         for(int idxPartition = 0 ; idxPartition < current_partition_size ; ++idxPartition){
             for(partsize_t idx_part = current_offset_particles_for_partition[idxPartition] ;
diff --git a/bfps/cpp/particles/particles_distr_mpi.hpp b/bfps/cpp/particles/particles_distr_mpi.hpp
index 10a566e5fb13a986391be4da0644371e9da13701..251119be950ad8219ee611d858ca8ac6c9986dbe 100644
--- a/bfps/cpp/particles/particles_distr_mpi.hpp
+++ b/bfps/cpp/particles/particles_distr_mpi.hpp
@@ -523,6 +523,7 @@ public:
             for(int idxPartition = 0 ; idxPartition < current_partition_size ; ++idxPartition){
                 for(partsize_t idx = 0 ; idx < current_my_nb_particles_per_partition[idxPartition] ; ++idx){
                     const int partition_level = in_computer.pbc_field_layer((*inout_positions_particles)[(idx+partOffset)*size_particle_positions+IDX_Z], IDX_Z);
+                    variable_used_only_in_assert(partition_level);
                     assert(partition_level == current_partition_interval.first + idxPartition
                            || partition_level == (current_partition_interval.first + idxPartition-1+int(field_grid_dim[IDX_Z]))%int(field_grid_dim[IDX_Z])
                            || partition_level == (current_partition_interval.first + idxPartition+1)%int(field_grid_dim[IDX_Z]));
diff --git a/bfps/cpp/particles/particles_inner_computer.hpp b/bfps/cpp/particles/particles_inner_computer.hpp
index f1fe322a3c30d87c6e3244c6c85f1ff3002f9a00..b2eb95dd12ec3bc2a0aaf9d4f51d395f7e2b8cd7 100644
--- a/bfps/cpp/particles/particles_inner_computer.hpp
+++ b/bfps/cpp/particles/particles_inner_computer.hpp
@@ -46,6 +46,7 @@ public:
                     pos_part[idx0+IDX_X]*pos_part[idx0+IDX_X] +
                     pos_part[idx0+IDX_Y]*pos_part[idx0+IDX_Y] +
                     pos_part[idx0+IDX_Z]*pos_part[idx0+IDX_Z]);
+            variable_used_only_in_assert(orientation_size);
             assert(orientation_size > 0.99);
             assert(orientation_size < 1.01);
             // I call "rotation" to be the right hand side of the orientation part of the ODE
diff --git a/bfps/cpp/particles/particles_input_hdf5.hpp b/bfps/cpp/particles/particles_input_hdf5.hpp
index 20239f062e93183a23542bc06407a2f637ffbe67..40fef3c48a734dfc2b449382da9831b6f5feeebb 100644
--- a/bfps/cpp/particles/particles_input_hdf5.hpp
+++ b/bfps/cpp/particles/particles_input_hdf5.hpp
@@ -79,6 +79,7 @@ public:
         assert(plist_id_par >= 0);
         {
             int retTest = H5Pset_fapl_mpio(plist_id_par, mpi_comm, MPI_INFO_NULL);
+            variable_used_only_in_assert(retTest);
             assert(retTest >= 0);
         }
 
@@ -98,6 +99,7 @@ public:
 
             std::vector<hsize_t> state_dim_array(space_dim);
             int hdfret = H5Sget_simple_extent_dims(dspace, &state_dim_array[0], NULL);
+            variable_used_only_in_assert(hdfret);
             assert(hdfret >= 0);
             // Last value is the position dim of the particles
             assert(state_dim_array.back() == size_particle_positions);
@@ -126,6 +128,7 @@ public:
 
             // Chichi comment: wouldn't &rhs_dim_array.front() be safer?
             int hdfret = H5Sget_simple_extent_dims(dspace, &rhs_dim_array[0], NULL);
+            variable_used_only_in_assert(hdfret);
             assert(hdfret >= 0);
             assert(rhs_dim_array.back() == size_particle_rhs);
             // Chichi comment: this assertion will fail in general
@@ -166,6 +169,7 @@ public:
 
             int rethdf = H5Sselect_hyperslab(rspace, H5S_SELECT_SET, offset,
                                              NULL, mem_dims, NULL);
+            variable_used_only_in_assert(rethdf);
             assert(rethdf >= 0);
             rethdf = H5Dread(dset, type_id, mspace, rspace, H5P_DEFAULT, split_particles_positions.get());
             assert(rethdf >= 0);
@@ -197,6 +201,7 @@ public:
 
                 int rethdf = H5Sselect_hyperslab( rspace, H5S_SELECT_SET, offset,
                                                  NULL, mem_dims, NULL);
+                variable_used_only_in_assert(rethdf);
                 assert(rethdf >= 0);
                 rethdf = H5Dread(dset, type_id, mspace, rspace, H5P_DEFAULT, split_particles_rhs[idx_rhs].get());
                 assert(rethdf >= 0);
@@ -208,6 +213,7 @@ public:
                 assert(rethdf >= 0);
             }
             int rethdf = H5Dclose(dset);
+            variable_used_only_in_assert(rethdf);
             assert(rethdf >= 0);
         }
 
@@ -274,7 +280,7 @@ public:
             split_particles_indexes.release();
 
             my_particles_rhs.resize(nb_rhs);
-            for(int idx_rhs = 0 ; idx_rhs < int(nb_rhs) ; ++idx_rhs){                
+            for(int idx_rhs = 0 ; idx_rhs < int(nb_rhs) ; ++idx_rhs){
                 if(nb_particles_for_me){
                     my_particles_rhs[idx_rhs].reset(new real_number[exchanger.getTotalToRecv()*size_particle_rhs]);
                 }
@@ -285,6 +291,7 @@ public:
         {
             TIMEZONE("close");
             int hdfret = H5Fclose(particle_file);
+            variable_used_only_in_assert(hdfret);
             assert(hdfret >= 0);
             hdfret = H5Pclose(plist_id_par);
             assert(hdfret >= 0);
diff --git a/bfps/cpp/particles/particles_output_hdf5.hpp b/bfps/cpp/particles/particles_output_hdf5.hpp
index 22d2fa851b0092f3eecfec456dc90d0e8e009169..0098ba542812d68e462fadf19c94d600f4637af3 100644
--- a/bfps/cpp/particles/particles_output_hdf5.hpp
+++ b/bfps/cpp/particles/particles_output_hdf5.hpp
@@ -59,6 +59,7 @@ public:
                     plist_id_par,
                     Parent::getComWriter(),
                     MPI_INFO_NULL);
+            variable_used_only_in_assert(retTest);
             assert(retTest >= 0);
 
             // Parallel HDF5 write
@@ -97,6 +98,7 @@ public:
             TIMEZONE("particles_output_hdf5::close_file");
 
             int rethdf = H5Gclose(dset_id_state);
+            variable_used_only_in_assert(rethdf);
             assert(rethdf >= 0);
 
             rethdf = H5Gclose(dset_id_rhs);
@@ -197,6 +199,7 @@ public:
         assert(plist_id >= 0);
         {
             int rethdf = H5Pset_dxpl_mpio(plist_id, use_collective_io ? H5FD_MPIO_COLLECTIVE : H5FD_MPIO_INDEPENDENT);
+            variable_used_only_in_assert(rethdf);
             assert(rethdf >= 0);
         }
 
@@ -233,6 +236,7 @@ public:
                     NULL,
                     count,
                     NULL);
+            variable_used_only_in_assert(rethdf);
             assert(rethdf >= 0);
 
             herr_t	status = H5Dwrite(
@@ -242,6 +246,7 @@ public:
                     filespace,
                     plist_id,
                     particles_positions);
+            variable_used_only_in_assert(status);
             assert(status >= 0);
             rethdf = H5Sclose(memspace);
             assert(rethdf >= 0);
@@ -289,6 +294,7 @@ public:
                         NULL,
                         count,
                         NULL);
+                variable_used_only_in_assert(rethdf);
                 assert(rethdf >= 0);
 
                 herr_t	status = H5Dwrite(
@@ -298,6 +304,7 @@ public:
                         filespace,
                         plist_id,
                         particles_rhs[idx_rhs].get());
+                variable_used_only_in_assert(status);
                 assert(status >= 0);
                 rethdf = H5Sclose(filespace);
                 assert(rethdf >= 0);
@@ -305,11 +312,13 @@ public:
                 assert(rethdf >= 0);
             }
             int rethdf = H5Dclose(dataset_id);
+            variable_used_only_in_assert(rethdf);
             assert(rethdf >= 0);
         }
 
         {
             int rethdf = H5Pclose(plist_id);
+            variable_used_only_in_assert(rethdf);
             assert(rethdf >= 0);
         }
     }
diff --git a/bfps/cpp/particles/particles_output_sampling_hdf5.hpp b/bfps/cpp/particles/particles_output_sampling_hdf5.hpp
index dc21322668420ac661a74c656b47ddb9d2e67e12..22dafaedcd7095bd5214864f224003ea8d8be602 100644
--- a/bfps/cpp/particles/particles_output_sampling_hdf5.hpp
+++ b/bfps/cpp/particles/particles_output_sampling_hdf5.hpp
@@ -69,6 +69,7 @@ public:
                     plist_id_par,
                     Parent::getComWriter(),
                     MPI_INFO_NULL);
+            variable_used_only_in_assert(retTest);
             assert(retTest >= 0);
 
             // open file for parallel HDF5 access
@@ -93,6 +94,7 @@ public:
         if(Parent::isInvolved()){
             // close group
             int retTest = H5Gclose(pgroup_id);
+            variable_used_only_in_assert(retTest);
             assert(retTest >= 0);
             // close file
             retTest = H5Fclose(file_id);
@@ -106,6 +108,7 @@ public:
         if(Parent::isInvolved()){
             // close old group
             int retTest = H5Gclose(pgroup_id);
+            variable_used_only_in_assert(retTest);
             assert(retTest >= 0);
 
             // open new group
@@ -131,6 +134,7 @@ public:
         // update group
         int retTest = this->switch_to_group(
                 in_groupname);
+        variable_used_only_in_assert(retTest);
         assert(retTest == EXIT_SUCCESS);
         // update dataset name
         dataset_name = in_dataset_name + "/" + std::to_string(idx_time_step);
@@ -182,6 +186,7 @@ public:
                     (use_collective_io ?
                      H5FD_MPIO_COLLECTIVE :
                      H5FD_MPIO_INDEPENDENT));
+            variable_used_only_in_assert(rethdf);
             assert(rethdf >= 0);
         }
         {
@@ -219,6 +224,7 @@ public:
                     NULL,
                     count,
                     NULL);
+            variable_used_only_in_assert(rethdf);
             assert(rethdf >= 0);
 
             herr_t	status = H5Dwrite(
@@ -228,6 +234,7 @@ public:
                     filespace,
                     plist_id,
                     particles_rhs[0].get());
+            variable_used_only_in_assert(status);
             assert(status >= 0);
             rethdf = H5Sclose(filespace);
             assert(rethdf >= 0);
@@ -239,6 +246,7 @@ public:
 
         {
             int rethdf = H5Pclose(plist_id);
+            variable_used_only_in_assert(rethdf);
             assert(rethdf >= 0);
         }
     }
diff --git a/bfps/cpp/particles/particles_system.hpp b/bfps/cpp/particles/particles_system.hpp
index e451f56a56b00a050d9d940085ad50ccf564ea30..f8688f61ab71d07058618cf13b16b62a6ea6c019 100644
--- a/bfps/cpp/particles/particles_system.hpp
+++ b/bfps/cpp/particles/particles_system.hpp
@@ -101,6 +101,7 @@ public:
 
         for(partsize_t idx_part = 0 ; idx_part < my_nb_particles ; ++idx_part){ // TODO remove me
             const int partition_level = computer.pbc_field_layer(my_particles_positions[idx_part*size_particle_positions+IDX_Z], IDX_Z);
+            variable_used_only_in_assert(partition_level);
             assert(partition_level >= current_partition_interval.first);
             assert(partition_level < current_partition_interval.second);
         }