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

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

Finished CreateFemModel with one model framework

File size: 3.8 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
29 /*FemModel: */
30 FemModel* femmodel=NULL;
31
32 /*Results: */
33 Results* results=NULL;
34
35 bool waitonlock=false;
36
37 /*time*/
38 double start, finish;
39 double start_core, finish_core;
40 double start_init, finish_init;
41
42 int analyses[5]={DiagnosticHorizAnalysisEnum,DiagnosticVertAnalysisEnum,DiagnosticStokesAnalysisEnum,DiagnosticHutterAnalysisEnum,SlopecomputeAnalysisEnum};
43
44 MODULEBOOT();
45
46 #if !defined(_PARALLEL_) || (defined(_PARALLEL_) && !defined(_HAVE_PETSC_))
47 ISSMERROR(" parallel executable was compiled without support of parallel libraries!");
48 #endif
49
50 /*Initialize Petsc and get start time*/
51 PetscInitialize(&argc,&argv,(char *)0,"");
52 MPI_Barrier(MPI_COMM_WORLD); start=MPI_Wtime();
53
54 /*Size and rank: */
55 MPI_Comm_rank(MPI_COMM_WORLD,&my_rank);
56 MPI_Comm_size(MPI_COMM_WORLD,&num_procs);
57
58 _printf_("recover , input file name and output file name:\n");
59 inputfilename=argv[2];
60 outputfilename=argv[3];
61 lockname=argv[4];
62
63 /*Initialize femmodel structure: */
64 MPI_Barrier(MPI_COMM_WORLD); start_init=MPI_Wtime();
65
66 /*Open handle to data on disk: */
67 fid=pfopen(inputfilename,"rb");
68
69 _printf_("create finite element model, using analyses types statically defined above:\n");
70 femmodel=new FemModel(iomodel,analyses,5);
71
72 /*get parameters: */
73 femmodel->parameters->FindParam(&qmu_analysis,QmuAnalysisEnum);
74 femmodel->parameters->FindParam(&control_analysis,ControlAnalysisEnum);
75 femmodel->parameters->FindParam(&waitonlock,WaitOnLockEnum);
76
77 MPI_Barrier(MPI_COMM_WORLD); finish_init=MPI_Wtime();
78
79 /*are we running the solution sequence, or a qmu wrapper around it? : */
80 if(!qmu_analysis){
81 if(!control_analysis){
82
83 _printf_("call computational core:\n");
84 MPI_Barrier(MPI_COMM_WORLD); start_core=MPI_Wtime( );
85 results=diagnostic_core(femmodel);
86 MPI_Barrier(MPI_COMM_WORLD); finish_core=MPI_Wtime( );
87
88 }
89 else{
90 /*run control analysis: */
91 _printf_("call computational core:\n");
92 MPI_Barrier(MPI_COMM_WORLD); start_core=MPI_Wtime( );
93 results=control_core(femmodel);
94 MPI_Barrier(MPI_COMM_WORLD); finish_core=MPI_Wtime( );
95
96 }
97
98 _printf_("write results to disk:\n");
99 OutputResults(results,outputfilename);
100 }
101 else{
102 /*run qmu analysis: */
103 _printf_("calling qmu analysis on diagnostic core:\n");
104
105 #ifdef _HAVE_DAKOTA_
106 MPI_Barrier(MPI_COMM_WORLD); start_core=MPI_Wtime( );
107 Qmux(femmodel,DiagnosticAnalysisEnum,NoneAnalysisEnum);
108 MPI_Barrier(MPI_COMM_WORLD); finish_core=MPI_Wtime( );
109 #else
110 ISSMERROR(" Dakota not present, cannot do qmu!");
111 #endif
112 }
113
114 if (waitonlock>0){
115 _printf_("write lock file:\n");
116 WriteLockFile(lockname);
117 }
118
119 /*Free ressources */
120 delete femmodel;
121 delete results;
122
123 /*Get finish time and close*/
124 MPI_Barrier(MPI_COMM_WORLD); finish = MPI_Wtime( );
125 _printf_("\n %-34s %f seconds \n","FemModel initialization elapsed time:",finish_init-start_init);
126 _printf_(" %-34s %f seconds \n","Core solution elapsed time:",finish_core-start_core);
127 _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);
128 _printf_("closing MPI and Petsc\n");
129 PetscFinalize();
130
131 /*end module: */
132 MODULEEND();
133
134 return 0; //unix success return;
135}
Note: See TracBrowser for help on using the repository browser.