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

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

small typos

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