@@ -152,15 +152,13 @@ int main(int argc, char *argv[]) {
152152 MPI_Init (& argc , & argv );
153153
154154 // load the configuration tree
155- PC_tree_t conf = PC_parse_path ("ex2.yml" );
156-
155+ PC_tree_t conf = PC_parse_path ("config.yml" );
156+ PDI_init (PC_get (conf , ".pdi" ));
157+
157158 // NEVER USE MPI_COMM_WORLD IN THE CODE, use our own communicator main_comm
158159 // instead
159160 MPI_Comm main_comm = MPI_COMM_WORLD ;
160161
161- // initialize PDI, it can replace our main communicator by its own
162- PDI_init (PC_get (conf , ".pdi" ));
163-
164162 // load the MPI rank & size
165163 int psize_1d ;
166164 MPI_Comm_size (main_comm , & psize_1d );
@@ -172,8 +170,9 @@ int main(int argc, char *argv[]) {
172170 // load the alpha parameter
173171 PC_double (PC_get (conf , ".alpha" ), & alpha );
174172
175- // load the global data-size
176173 int global_size [2 ];
174+ // load the global data-size
175+ // you can use paraconf to read some parameters from the yml config file
177176 PC_int (PC_get (conf , ".global_size.height" ), & longval );
178177 global_size [0 ] = longval ;
179178 PC_int (PC_get (conf , ".global_size.width" ), & longval );
@@ -211,14 +210,8 @@ int main(int argc, char *argv[]) {
211210 // our loop counter so as to be able to use it outside the loop
212211 int ii = 0 ;
213212
214- //*** share useful configuration bits with PDI
215- //*** pcoord, psize, dsize
216- //...
217-
218213 // the main loop
219- for (; ii < 4 ; ++ ii ) {
220- //*** share the loop counter & main field at each iteration
221- //...
214+ for (; ii < 10 ; ++ ii ) {
222215
223216 // compute the values for the next iteration
224217 iter (cur , next );
@@ -231,18 +224,14 @@ int main(int argc, char *argv[]) {
231224 cur = next ;
232225 next = tmp ;
233226 }
234- //*** finally share the loop counter and main field after the main loop body
235- //...
236-
237- // finalize PDI
238- PDI_finalize ();
239227
240228 // destroy the paraconf configuration tree
241229 PC_tree_destroy (& conf );
242230
243231 // free the allocated memory
244232 free (cur );
245233 free (next );
234+ PDI_finalize ();
246235
247236 // finalize MPI
248237 MPI_Finalize ();
0 commit comments