source: issm/trunk/src/c/solutions/diagnostic.cpp@ 4039

Last change on this file since 4039 was 4039, checked in by Eric.Larour, 15 years ago

New OutputResults module, relying on patches, and embedded element results

File size: 3.7 KB
Line 
1/*!\file: diagnostic.cpp
2 * \brief: diagnostic solution
3 */
4
5#ifdef HAVE_CONFIG_H
6 #include "config.h"
7#else
8#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
9#endif
10
11#include "../objects/objects.h"
12#include "../shared/shared.h"
13#include "../DataSet/DataSet.h"
14#include "../EnumDefinitions/EnumDefinitions.h"
15#include "../include/include.h"
16#include "../modules/modules.h"
17#include "./solutions.h"
18
19int main(int argc,char* *argv){
20
21 /*I/O: */
22 FILE* fid=NULL;
23 char* inputfilename=NULL;
24 char* outputfilename=NULL;
25 char* lockname=NULL;
26 bool qmu_analysis=false;
27 bool control_analysis=false;
28 bool waitonlock=false;
29
30 /*FemModel: */
31 FemModel* femmodel=NULL;
32
33 /*time*/
34 double start, finish;
35 double start_core, finish_core;
36 double start_init, finish_init;
37
38 int analyses[5]={DiagnosticHorizAnalysisEnum,DiagnosticVertAnalysisEnum,DiagnosticStokesAnalysisEnum,DiagnosticHutterAnalysisEnum,SlopeComputeAnalysisEnum};
39 int solution_type=DiagnosticAnalysisEnum;
40
41 MODULEBOOT();
42
43 #if !defined(_PARALLEL_) || (defined(_PARALLEL_) && !defined(_HAVE_PETSC_))
44 ISSMERROR(" parallel executable was compiled without support of parallel libraries!");
45 #endif
46
47 /*Initialize Petsc and get start time*/
48 PetscInitialize(&argc,&argv,(char *)0,"");
49 MPI_Barrier(MPI_COMM_WORLD); start=MPI_Wtime();
50
51 /*Size and rank: */
52 MPI_Comm_rank(MPI_COMM_WORLD,&my_rank);
53 MPI_Comm_size(MPI_COMM_WORLD,&num_procs);
54
55 _printf_("recover , input file name and output file name:\n");
56 inputfilename=argv[2];
57 outputfilename=argv[3];
58 lockname=argv[4];
59
60 /*Initialize femmodel structure: */
61 MPI_Barrier(MPI_COMM_WORLD); start_init=MPI_Wtime();
62
63 /*Open handle to data on disk: */
64 fid=pfopen(inputfilename,"rb");
65
66 _printf_("create finite element model:\n");
67 femmodel=new FemModel(fid,solution_type,analyses,5);
68
69 /*get parameters: */
70 femmodel->parameters->FindParam(&qmu_analysis,QmuAnalysisEnum);
71 femmodel->parameters->FindParam(&control_analysis,ControlAnalysisEnum);
72 femmodel->parameters->FindParam(&waitonlock,WaitOnLockEnum);
73
74 MPI_Barrier(MPI_COMM_WORLD); finish_init=MPI_Wtime();
75
76 /*are we running the solution sequence, or a qmu wrapper around it? : */
77 if(!qmu_analysis){
78 if(!control_analysis){
79
80 _printf_("call computational core:\n");
81 MPI_Barrier(MPI_COMM_WORLD); start_core=MPI_Wtime( );
82 diagnostic_core(femmodel);
83 MPI_Barrier(MPI_COMM_WORLD); finish_core=MPI_Wtime( );
84
85 }
86 else{
87 /*run control analysis: */
88 _printf_("call computational core:\n");
89 MPI_Barrier(MPI_COMM_WORLD); start_core=MPI_Wtime( );
90 control_core(femmodel);
91 MPI_Barrier(MPI_COMM_WORLD); finish_core=MPI_Wtime( );
92
93 }
94
95 _printf_("write results to disk:\n");
96 OutputResults(femmodel,outputfilename);
97 }
98 else{
99 /*run qmu analysis: */
100 _printf_("calling qmu analysis on diagnostic core:\n");
101
102 #ifdef _HAVE_DAKOTA_
103 MPI_Barrier(MPI_COMM_WORLD); start_core=MPI_Wtime( );
104 Qmux(femmodel,DiagnosticAnalysisEnum,NoneAnalysisEnum);
105 MPI_Barrier(MPI_COMM_WORLD); finish_core=MPI_Wtime( );
106 #else
107 ISSMERROR(" Dakota not present, cannot do qmu!");
108 #endif
109 }
110
111 if (waitonlock>0){
112 _printf_("write lock file:\n");
113 WriteLockFile(lockname);
114 }
115
116 /*Free ressources */
117 delete femmodel;
118
119 /*Get finish time and close*/
120 MPI_Barrier(MPI_COMM_WORLD); finish = MPI_Wtime( );
121 _printf_("\n %-34s %f seconds \n","FemModel initialization elapsed time:",finish_init-start_init);
122 _printf_(" %-34s %f seconds \n","Core solution elapsed time:",finish_core-start_core);
123 _printf_("\n %s %i hrs %i min %i sec\n\n","Total elapsed time:",int((finish-start)/3600),int(int(finish-start)%3600/60),int(finish-start)%60);
124 _printf_("closing MPI and Petsc\n");
125 PetscFinalize();
126
127 /*end module: */
128 MODULEEND();
129
130 return 0; //unix success return;
131}
Note: See TracBrowser for help on using the repository browser.