acsf.cpp 20.8 KB
Newer Older
1
//
kra568's avatar
kra568 committed
2
// Created by martin on 20.08.19.
3
4
//

5
#include <4neuro.h>
6
#include <iomanip>
7
#include <vector>
8
#include <memory>
kra568's avatar
kra568 committed
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59

void optimize_via_particle_swarm(l4n::NeuralNetwork& net,
                                 l4n::ErrorFunction& ef) {

    /* TRAINING METHOD SETUP */
    std::vector<double> domain_bounds(2 * (net.get_n_weights() + net.get_n_biases()));

    for (size_t i = 0; i < domain_bounds.size() / 2; ++i) {
        domain_bounds[2 * i]     = -150;
        domain_bounds[2 * i + 1] = 150;
    }

    double c1          = 1.7;
    double c2          = 1.7;
    double w           = 0.7;
    size_t n_particles = 300;
    size_t iter_max    = 500;

    /* if the maximal velocity from the previous step is less than 'gamma' times the current maximal velocity, then one
     * terminating criterion is met */
    double gamma = 0.5;

    /* if 'delta' times 'n' particles are in the centroid neighborhood given by the radius 'epsilon', then the second
     * terminating criterion is met ('n' is the total number of particles) */
    double epsilon = 0.02;
    double delta   = 0.7;

    l4n::ParticleSwarm swarm_01(
        &domain_bounds,
        c1,
        c2,
        w,
        gamma,
        epsilon,
        delta,
        n_particles,
        iter_max
    );
    swarm_01.optimize(ef);


    /* ERROR CALCULATION */
    std::cout << "Run finished! Error of the network[Particle swarm]: " << ef.eval(nullptr) << std::endl;
    std::cout
        << "***********************************************************************************************************************"
        << std::endl;
}

double optimize_via_gradient_descent(l4n::NeuralNetwork& net,
                                     l4n::ErrorFunction& ef) {

60
61
62
63
64
	if(l4n::mpi_rank == 0){
		std::cout
			<< "***********************************************************************************************************************"
			<< std::endl;
	}
kra568's avatar
kra568 committed
65
66
    l4n::GradientDescentBB gd(1e-6,
                              1000,
67
                              10);
kra568's avatar
kra568 committed
68
69
70
71
72
73

    gd.optimize(ef);


    /* ERROR CALCULATION */
    double err = ef.eval(nullptr);
74
75
76
	if(l4n::mpi_rank == 0){
		std::cout << "Run finished! Error of the network[Gradient descent]: " << err << std::endl;
	}
kra568's avatar
kra568 committed
77
78
79
80
81
82

    /* Just for validation test purposes - NOT necessary for the example to work! */
    return err;
}

double optimize_via_LBMQ(l4n::NeuralNetwork& net,
83
84
85
86
87
                         l4n::ErrorFunction& ef,
                         unsigned int niters,
                         unsigned int nb,
                         double tol
                         ) {
88
89
90
    if( niters == 0 ){
        return ef.eval(nullptr);
    }
91
92
93
94
95
96
97
98
99
100
101
102

    size_t max_iterations = niters;
    size_t batch_size = nb;
    double tolerance = tol;
    double tolerance_gradient = tol * 1e-6;
    double tolerance_parameters = tolerance_gradient;

	if(l4n::mpi_rank == 0){
		std::cout
			<< "***********************************************************************************************************************"
			<< std::endl;
	}
kra568's avatar
kra568 committed
103
104
105
106
107
108
109
110
    l4n::LevenbergMarquardt lm(
        max_iterations,
        batch_size,
        tolerance,
        tolerance_gradient,
        tolerance_parameters
    );

111
112
     double grate = 1e-2;
     l4n::SmoothingLearning sl( lm, tolerance, grate );
113

114
115
//     sl.optimize(ef);
	lm.optimize(ef);
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148

    /* ERROR CALCULATION */
    double err = ef.eval(nullptr);
    // std::cout << "Run finished! Error of the network[Levenberg-Marquardt]: " << err << std::endl;

    /* Just for validation test purposes - NOT necessary for the example to work! */
    return err;
}

double optimize_via_NormalizedGradientDescent(
	l4n::NeuralNetwork& net,
    l4n::ErrorFunction& ef,
    unsigned int niters,
    unsigned int nb,
    double tol
) {

    size_t max_iterations = niters;
    size_t batch_size = nb;
    double tolerance = tol * 1e-6;

	if(l4n::mpi_rank == 0){
		std::cout
			<< "***********************************************************************************************************************"
			<< std::endl;
	}
    l4n::NormalizedGradientDescent ngd(
        tolerance,
        max_iterations,
        batch_size
    );

    ngd.optimize(ef);
kra568's avatar
kra568 committed
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172


    /* ERROR CALCULATION */
    double err = ef.eval(nullptr);
    // std::cout << "Run finished! Error of the network[Levenberg-Marquardt]: " << err << std::endl;

    /* Just for validation test purposes - NOT necessary for the example to work! */
    return err;
}

double optimize_via_NelderMead(l4n::NeuralNetwork& net, l4n::ErrorFunction& ef) {
    l4n::NelderMead nm(500, 150);

    nm.optimize(ef);

    /* ERROR CALCULATION */
    double err = ef.eval(nullptr);
    std::cout << "Run finished! Error of the network[Nelder-Mead]: " << err << std::endl;

    /* Just for validation test purposes - NOT necessary for the example to work! */
    return err;

}

173
void dynamic_test(
174
175
176
177
    unsigned int niters,
    unsigned int batch_size,
    double tol,
    std::vector<unsigned int> net_complx,
178
179
    const std::string& data_file,
    const std::string& net_file,
180
181
182
183
184
185
    const std::vector<double> &g2_cutoff_coefficients,
    const std::vector<double> &g2_extensions,
    const std::vector<double> &g2_shifts,
    const std::vector<double> &g5_cutoff_coefficients,
    const std::vector<double> &g5_extensions,
    const std::vector<bool> &g5_shiftsmax,
186
187
188
    const std::vector<double> &g5_angles,
    unsigned int cross_validation_k,
    unsigned int cross_validation_ntests,
189
190
	const std::string& cross_validation_file,
	const std::string& norm_file
191
){
192
    try {
193
/******************************** CREATING A SYSTEM OF RADIAL TRANS. FUNCTIONS ***************************/
194
195
196
197
198
199
200
201
202
        /* Specify cutoff functions */
        std::vector<l4n::CutoffFunction2> g2_cutofffunctions;
        for (auto                         el: g2_cutoff_coefficients) {
            g2_cutofffunctions.emplace_back(l4n::CutoffFunction2(el));
        }
        std::vector<l4n::CutoffFunction2> g5_cutofffunctions;
        for (auto                         el: g5_cutoff_coefficients) {
            g5_cutofffunctions.emplace_back(l4n::CutoffFunction2(el));
        }
203

204
205
206
207
208
209
210
211
212
        /* the used symmetry functions */
        std::vector<l4n::SymmetryFunction*> helium_sym_funcs(g2_extensions.size() + g5_extensions.size());
        /* Specify G2 symmetry functions */
        std::vector<l4n::G2>                G2functions;
        for (size_t                         i = 0; i < g2_extensions.size(); ++i) {
            G2functions.emplace_back(l4n::G2(&g2_cutofffunctions[i],
                                             g2_extensions[i],
                                             g2_shifts[i]));
        }
213

214
215
216
217
218
219
220
221
222
        /* Specify G2 symmetry functions */
        std::vector<l4n::G5> G5functions;
        auto                 shift            = G2functions.size();
        for (size_t          i                = 0; i < g5_extensions.size(); ++i) {
            G5functions.emplace_back(l4n::G5(&g5_cutofffunctions[i],
                                             g5_extensions[i],
                                             g5_shiftsmax[i],
                                             g5_angles[i]));
        }
223

224
225
226
227
228
229
        for (size_t i = 0; i < g2_extensions.size(); ++i) {
            helium_sym_funcs[i] = &G2functions[i];
        }
        for (size_t i = 0; i < g5_extensions.size(); ++i) {
            helium_sym_funcs[i + shift] = &G5functions[i];
        }
kra568's avatar
kra568 committed
230

231
232
233
234
        l4n::Element                                           helium = l4n::Element("He",
                                                                                     helium_sym_funcs);
        std::unordered_map<l4n::ELEMENT_SYMBOL, l4n::Element*> elements;
        elements[l4n::ELEMENT_SYMBOL::He] = &helium;
235
/**************************** FINISHED CREATING A SYSTEM OF RADIAL TRANS. FUNCTIONS ************************/
kra568's avatar
kra568 committed
236

237
/**************************** READING COORDINATE DATA FILE ************************/
238
        /* Read data */
239
        l4n::XYZReader reader(data_file,
240
241
                              true);
        reader.read();
kra568's avatar
kra568 committed
242

243
244
245
        if (l4n::mpi_rank == 0) {
            std::cout << "Finished reading data" << std::endl;
        }
kra568's avatar
kra568 committed
246

247
248
        std::shared_ptr<l4n::DataSet> ds = reader.get_acsf_data_set(elements);
        // ds->print_data();
kra568's avatar
kra568 committed
249

250
251
252
        std::shared_ptr<l4n::NormalizationStrategyACSF> ns;
        try {
            ns = std::make_shared<l4n::NormalizationStrategyACSF>(norm_file, *reader.get_element_list());
kra568's avatar
kra568 committed
253
        }
254
255
256
257
258
        catch (const std::exception& e) {
            if (lib4neuro::mpi_rank == 0) {
                std::cerr << e.what() << std::endl;
            }
            ns = std::make_shared<l4n::NormalizationStrategyACSF>(l4n::NormalizationStrategyACSF(elements,
259
260
                                                                                                  *reader.get_element_list(),
                                                                                                  *ds->get_data()));
261
        }
262

263
        ds->set_normalization_strategy(ns);
264
		ds->normalize( );
265
/**************************** FINISHED READING COORDINATE DATA FILE ************************/
266

267
/**************************** READING NETWORK FILE ************************/
268
269
        l4n::ACSFNeuralNetwork* net;
        try {
270
            net = new l4n::ACSFNeuralNetwork(net_file, *reader.get_element_list());
271
//        net.load_structure_from_file( src_net_file );
272
        }
273
274
275
276
        catch (const std::exception& e) {
            if (lib4neuro::mpi_rank == 0) {
                std::cerr << e.what() << std::endl;
            }
277
278
279
280
281
282
283
284
285
286
287
288
            /* Create a neural network */
            std::unordered_map<l4n::ELEMENT_SYMBOL, std::vector<unsigned int>> n_hidden_neurons;
            n_hidden_neurons[l4n::ELEMENT_SYMBOL::He] = net_complx;

            std::unordered_map<l4n::ELEMENT_SYMBOL, std::vector<l4n::NEURON_TYPE>> type_hidden_neurons;
            for (auto                                                              el :n_hidden_neurons) {
                for (auto i = 0; i < el.second.size() - 1; ++i) {
                    type_hidden_neurons[el.first].push_back(l4n::NEURON_TYPE::LOGISTIC);
                }
                type_hidden_neurons[el.first].push_back(l4n::NEURON_TYPE::LINEAR);
            }

289
290
291
292
293
294
295
            net = new l4n::ACSFNeuralNetwork(elements,
                                             *reader.get_element_list(),
                                             reader.contains_charge() && !reader.get_ignore_charge(),
                                             n_hidden_neurons,
                                             type_hidden_neurons);
            net->randomize_parameters();
        }
296
/**************************** FINISHED READING NETWORK FILE ************************/
297

298
299
300
        l4n::MSE mse(net,
                     ds.get(),
                     false);
301
302
//    l4n::ACSFNeuralNetwork net(elements, *reader.get_element_list(), reader.contains_charge() && !reader.get_ignore_charge(), n_hidden_neurons, type_hidden_neurons);
//    l4n::MSE mse(&net, ds.get(), false);
303

304
305
306
307
308
        double err1 = optimize_via_LBMQ(*net,
                                        mse,
                                        niters,
                                        batch_size,
                                        tol);
309
//    double err3 = optimize_via_NormalizedGradientDescent( net, mse, niters, batch_size, tol );
310
311
312
313
314
//    double err2 = optimize_via_gradient_descent(net, mse);




315

kra568's avatar
kra568 committed
316

317
318
319
320
        // if (lib4neuro::mpi_rank == 0 && cross_validation_ntests > 0) {
            // std::cout << "About to perform " << cross_validation_ntests << " cross validation tests using "
                      // << 100.0 / cross_validation_k << " [%] of train data as a test set" << std::endl;
        // }
321

322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
        // if (cross_validation_ntests > 0) {
            // l4n::LevenbergMarquardt lm(
                // niters,
                // batch_size,
                // tol,
                // tol * 1e-6,
                // tol * 1e-6
            // );
            // l4n::CrossValidator     cv(&lm,
                                       // &mse);

            // cv.run_k_fold_test(cross_validation_k,
                               // cross_validation_ntests,
                               // std::string(cross_validation_file));
        // }
337

338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
		ds->MPI_gather_data_on_master();

/* Print fit comparison with real data */

		if ( l4n::mpi_rank == 0 ) {
			std::vector<double> output;
			output.resize(1);

			double max_error_abs = 0.0, max_error_rel = 0.0;

			std::vector<std::vector<double>> out_dat;
			for (auto                        e : *mse.get_dataset()->get_data()) {
				net->eval_single(e.first,
								 output);
								 
				ns->de_normalize_output( e.second );
				ns->de_normalize_output( output );
				
				double error_    = std::abs(e.second.at(0) - output.at(0));
				double error_rel = 2.0 * error_ / (std::abs(output.at(0)) + std::abs(e.second.at(0)));

				out_dat.push_back({e.second[0], output[0], error_, error_rel});

				if (max_error_abs < error_) {
					max_error_abs = error_;
				}

				if (error_rel > max_error_rel) {
					max_error_rel = error_rel;
				}
			}
369
370
371
372
            std::cout << "*****************************************************" << std::endl;
            std::cout << "maximal absolute error: " << max_error_abs << std::endl;
            std::cout << "maximal relative error: " << 100 * max_error_rel << " %" << std::endl;
            std::cout << "*****************************************************" << std::endl;
373
374
            net->save_text( net_file );
            ns->save_text( norm_file );
375

376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
			std::vector<unsigned int> data_indices(out_dat.size());
			for( auto i = 0; i < out_dat.size(); ++i ){
				data_indices[ i ] = i;
			}
			std::sort(
				data_indices.begin(),
				data_indices.end(),
				[&out_dat](const unsigned int a, const unsigned int b){
					if( out_dat.at(a).at(3) < out_dat.at(b).at(3) ){
						return false;
					}
					if( out_dat.at(b).at(3) < out_dat.at(a).at(3) ){
						return true;
					}
					return false;
				}
			);

			if( niters == 0 ){
				std::cout << "expected output " << "predicted output " << "absolute error " << "relative error" << std::endl;
				for (auto el: data_indices) {
					printf("%c%20.18f %c%20.18f %c%20.18f %c%20.18f\n",
//						el,
						out_dat.at(el).at(0) < 0?'-':' ',
						std::abs(out_dat.at(el).at(0)),
						out_dat.at(el).at(1) < 0?'-':' ',
						std::abs(out_dat.at(el).at(1)),
						out_dat.at(el).at(2) < 0?'-':' ',
						std::abs(out_dat.at(el).at(2)),
						out_dat.at(el).at(3) < 0?'-':' ',
						std::abs(out_dat.at(el).at(3))
					);
				}
			}
			else{
				for (auto el: data_indices) {

					double error_    = out_dat.at(el).at(2);
					double error_rel = out_dat.at(el).at(3);

					if (error_rel > 0.05) {
						printf("[%6d] %c%20.18f %c%20.18f %c%20.18f %c%20.18f\n",
							el,
							out_dat.at(el).at(0) < 0?'-':' ',
							std::abs(out_dat.at(el).at(0)),
							out_dat.at(el).at(1) < 0?'-':' ',
							std::abs(out_dat.at(el).at(1)),
							out_dat.at(el).at(2) < 0?'-':' ',
							std::abs(out_dat.at(el).at(2)),
							out_dat.at(el).at(3) < 0?'-':' ',
							std::abs(out_dat.at(el).at(3))
						);
					}
				}
			}
		}
432
433
434
435


    } catch (...) {
        std::throw_with_nested( std::runtime_error("dynamic_test() error"));
436
    }
437
438
439
440
}

int main( int argc, char** argv ) {
    MPI_INIT
kra568's avatar
kra568 committed
441

442
443
    unsigned int niters = 1000;
    unsigned int batch_size = 0;
444
445
	unsigned int cross_validation_k = 1;
	unsigned int cross_validation_ntests = 0;
446
    double tol = 1e-1;
447
448
    std::string data_file = "";
    std::string net_file = "";
Martin Beseda's avatar
Martin Beseda committed
449
    std::string cross_validation_file = "";
450
    std::string norm_file = "";
451
    unsigned int nlayers = 0;
452
453
    std::vector<unsigned int> net_complx = {2, 1};

Martin Beseda's avatar
Martin Beseda committed
454
    /* Parsing command-line parameters */
455
456
457
458
459
    size_t id = 1;
    if( argc > id ){
        niters = atoi( argv[id] );
    }
    id++;
460

461
462
    if( argc > id ){
        batch_size = atoi( argv[id] );
463
    }
464
465
466
467
    id++;

    if( argc > id ){
        tol = atof( argv[id] );
468
    }
469
470
471
    id++;

    if( argc > id ){
472
        data_file = argv[id];
473
    }
474
475
476
    id++;

    if( argc > id ){
477
        net_file = argv[id];
478
    }
479
480
481
482
    id++;

    if( argc > id ){
        nlayers = atoi( argv[id] );
483
484
        net_complx.resize(nlayers);
    }
485
486
    id++;

Martin Beseda's avatar
Martin Beseda committed
487
    for(unsigned int lidx = id; lidx < id + nlayers; ++lidx ){
488
489
490
491
492
493
494
495
496
497
498
499
500
        net_complx[lidx - id] = atoi( argv[lidx] );
    }
    id += nlayers;

    std::vector<double> g2_cutoff_coefficients = {};
    std::vector<double> g2_extensions = {};
    std::vector<double> g2_shifts = {};
    unsigned int ng2 = 0;
    if( argc > id ){
        ng2 = atoi( argv[id] );
        g2_extensions.resize(ng2);
        g2_shifts.resize(ng2);
        g2_cutoff_coefficients.resize(ng2);
501
    }
502
    id++;
kra568's avatar
kra568 committed
503

504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
    for( unsigned int sidx = id; sidx < id + ng2; ++sidx ){
        g2_cutoff_coefficients[sidx - id] = atof( argv[sidx] );
    }
    id += ng2;
    for( unsigned int sidx = id; sidx < id + ng2; ++sidx ){
        g2_extensions[sidx - id] = atof( argv[sidx] );
    }
    id += ng2;
    for( unsigned int sidx = id; sidx < id + ng2; ++sidx ){
        g2_shifts[sidx - id] = atof( argv[sidx] );
    }
    id += ng2;

    std::vector<double> g5_cutoff_coefficients = {};
    std::vector<double> g5_extensions = {};
    std::vector<bool> g5_shifts = {};
    std::vector<double> g5_angles = {};
    unsigned int ng5 = 0;
    if( argc > id ){
        ng5 = atoi( argv[id] );
        g5_extensions.resize(ng5);
        g5_shifts.resize(ng5);
        g5_angles.resize(ng5);
        g5_cutoff_coefficients.resize(ng5);
    }
    id++;

    for( unsigned int sidx = id; sidx < id + ng5; ++sidx ){
        g5_cutoff_coefficients[sidx - id] = atof( argv[sidx] );
    }
    id += ng5;
    for( unsigned int sidx = id; sidx < id + ng5; ++sidx ){
        g5_extensions[sidx - id] = atof( argv[sidx] );
    }
    id += ng5;
    for( unsigned int sidx = id; sidx < id + ng5; ++sidx ){
540
        g5_shifts[sidx - id] = atof( argv[sidx] );
541
542
543
544
545
546
547
    }
    id += ng5;
    for( unsigned int sidx = id; sidx < id + ng5; ++sidx ){
        g5_angles[sidx - id] = atof( argv[sidx] );
    }
    id += ng5;

548
549
550
551
552
553
554
555
556
    if( argc > id ){
        cross_validation_k = atoi( argv[id] );
    }
    id++;

    if( argc > id ){
        cross_validation_ntests = atoi( argv[id] );
    }
    id++;
557

558
559
560
561
	if(argc > id){
		cross_validation_file = argv[ id ];
	}
	id++;
562

563
564
565
566
567
	if(argc > id){
		norm_file = argv[ id ];
	}
	id++;

568
569
570
    nlayers = net_complx.size();
    ng2 = g2_extensions.size();
    ng5 = g5_extensions.size();
kra568's avatar
kra568 committed
571

572
573
574
575
    if( l4n::mpi_rank == 0 ){
        std::cout << "Maximal number of iterations: " << niters << std::endl;
        std::cout << "Batch size: " << batch_size << std::endl;
        std::cout << "Learning tolerance: " << tol << std::endl;
576

577
578
579
580
581
582
        std::cout << "# of network layers: " << nlayers << std::endl;
        std::cout << "# of neurons in the layers: ";
        for( auto el: net_complx ){
            std::cout << el << " ";
        }
        std::cout << std::endl;
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
        if( ng2 > 0 ){
            std::cout << "***********************************************************" << std::endl;
            std::cout << "number of G2 symmetry functions: " << ng2 << std::endl;
            for( size_t i = 0; i < ng2; ++i ){
                std::cout << " f" << i << ": cutoff " << g2_cutoff_coefficients[ i ] << ", extension " << g2_extensions[ i ] << ", shift " << g2_shifts[ i ] << std::endl;
            }
        }
        if( ng5 > 0 ){
            std::cout << "***********************************************************" << std::endl;
            std::cout << "number of G5 symmetry functions: " << ng5 << std::endl;
            for( size_t i = 0; i < ng5; ++i ){
                std::cout << " f" << i << ": cutoff " << g5_cutoff_coefficients[ i ] << ", extension " << g5_extensions[ i ] << ", shift " << g5_shifts[ i ] << ", angle " << g5_angles[ i ] << std::endl;
            }
        }
        std::cout << "***********************************************************" << std::endl;
598
599
600
        std::cout << "Data file: " << data_file << std::endl;
        std::cout << "Data normalization file: " << norm_file << std::endl;
        std::cout << "Network will be loaded from & saved to: " << net_file << std::endl;
601
602
603
604
605
606

        std::cout << "***********************************************************" << std::endl;
        std::cout << "Cross validation file: " << cross_validation_file << std::endl;
        std::cout << "Cross validation portion: " << cross_validation_k << std::endl;
        std::cout << "# of cross validation tests: " << cross_validation_ntests << std::endl;

607
608
        std::cout << "***********************************************************" << std::endl << std::endl;
    }
Martin Beseda's avatar
Martin Beseda committed
609

610
    try{
kra568's avatar
kra568 committed
611

612
        dynamic_test(
613
614
615
616
            niters,
            batch_size,
            tol,
            net_complx,
617
618
            data_file,
            net_file,
619
620
621
622
623
624
            g2_cutoff_coefficients,
            g2_extensions,
            g2_shifts,
            g2_cutoff_coefficients,
            g5_extensions,
            g5_shifts,
625
626
627
            g5_angles,
			cross_validation_k,
			cross_validation_ntests,
628
629
			cross_validation_file,
			norm_file
630
        );
631

kra568's avatar
kra568 committed
632
    } catch (const std::exception& e) {
633
        print_exception(e);
kra568's avatar
kra568 committed
634
635
        exit(EXIT_FAILURE);
    }
636

637
    MPI_FINISH
638
    return 0;
kra568's avatar
kra568 committed
639
}