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

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

New results API

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