source: issm/trunk/src/c/solutions/prognostic2.cpp@ 3913

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

Moved all objects in Bamg to objects directory.
Moved all solutions from parallel to solutoins.
Moved all modules from top c/ directory to c/modules directory
cleaned up all object dependencies in Bamg/objects (fiouh!)
That will do for the week-end:)

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