1 #define BSMAINLOG
2 #include "BSprivate.h"
3 
4 int BSinit_called = 0;
5 int BSbegan_MPI = 0;
6 
7 /*@ BSinit - Initializes BlockSolve and MPI.  BSinit() calls
8     MPI_Init() if it has not already been called.
9 
10     Input Parameters:
11 .   argc - count of number of command line arguments
12 .   args - the command line arguments
13 
14     Notes:
15     If you want to call MPI_Init() separately, call it before
16     BSinit().
17 
18 .keywords: initialize, startup
19 
20 .seealso: BSfinalize()
21 
22  @*/
BSinit(int * argc,char *** args)23 int BSinit(int *argc,char ***args)
24 {
25 	int ierr, flag;
26 
27 	/* check to see if BSinit has already been called */
28 	if (BSinit_called) return 0;
29 
30 	/* Init MPI if not already done */
31 	MPI_Initialized(&flag);
32 	if (!flag) {
33 		ierr = MPI_Init(argc,args); CHKERRN(ierr);
34 		BSbegan_MPI = 1;
35 	}
36 
37 	/* Start up logging if MLOG is defined */
38 	MLOG_INIT();
39 
40 	BSinit_called = 1;
41 	return(0);
42 }
43 
44 /*@ BSfinalize - Finalizes BlockSolve and MPI.
45     Prints the log stuff if MLOG was defined.
46 
47 .keywords: finalize
48 
49 .seealso: BSinit()
50 
51  @*/
BSfinalize()52 int BSfinalize()
53 {
54 	/* do memory check if HAVE_PETSC defined */
55 	CHECK_MEMORY();
56 
57 	/* finalize MPI */
58 	if(BSbegan_MPI) {
59 		MPI_Finalize();
60 	}
61 
62 	return(0);
63 }
64 
65 /*@ BSprint_log - Print log stuff if MLOG is defined.
66 
67     Input Parameters:
68 .   procinfo - The usual procinfo
69 
70     Note: BSprint_log() will not print out anything
71     unless BSctx_set_print_log has been set to TRUE.
72 
73 .seealso: BSctx_set_print_log()
74 
75  @*/
BSprint_log(BSprocinfo * procinfo)76 int BSprint_log(BSprocinfo *procinfo)
77 {
78 	/* print out the log info and return */
79 	if(procinfo->print_log) {
80 		MLOG_PRINT(procinfo);
81 	}
82 
83 	return(0);
84 }
85 
86