source: issm/trunk-jpl/src/c/classes/objects/ExternalResults/BoolExternalResult.cpp@ 12822

Last change on this file since 12822 was 12562, checked in by utke, 13 years ago
File size: 3.3 KB
Line 
1/*!\file BoolExternalResult.c
2 * \brief: implementation of the BoolExternalResult object
3 */
4
5/*header files: */
6/*{{{*/
7#ifdef HAVE_CONFIG_H
8 #include <config.h>
9#else
10#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
11#endif
12
13#include <stdio.h>
14#include <string.h>
15#include "../objects.h"
16#include "../../EnumDefinitions/EnumDefinitions.h"
17#include "../../shared/shared.h"
18#include "../../Container/Container.h"
19#include "../../include/include.h"
20/*}}}*/
21
22/*BoolExternalResult constructors and destructor*/
23/*FUNCTION BoolExternalResult::BoolExternalResult(){{{*/
24BoolExternalResult::BoolExternalResult(){
25 return;
26}
27/*}}}*/
28/*FUNCTION BoolExternalResult::BoolExternalResult(int enum_type,bool value){{{*/
29BoolExternalResult::BoolExternalResult(int in_id, int in_enum_type,bool in_value,int in_step, IssmDouble in_time){
30
31 id=in_id;
32 enum_type=in_enum_type;
33 value=in_value;
34 step=in_step;
35 time=in_time;
36}
37/*}}}*/
38/*FUNCTION BoolExternalResult::~BoolExternalResult(){{{*/
39BoolExternalResult::~BoolExternalResult(){
40 return;
41}
42/*}}}*/
43
44/*Object virtual functions definitions:*/
45/*FUNCTION BoolExternalResult::Echo {{{*/
46void BoolExternalResult::Echo(void){
47 this->DeepEcho();
48}
49/*}}}*/
50/*FUNCTION BoolExternalResult::DeepEcho{{{*/
51void BoolExternalResult::DeepEcho(void){
52
53 _printLine_("BoolExternalResult:");
54 _printLine_(" id: " << this->id);
55 _printLine_(" enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")");
56 _printLine_(" value: " <<(this->value?"true":"false"));
57 _printLine_(" step: " << this->step);
58 _printLine_(" time: " << this->time);
59}
60/*}}}*/
61/*FUNCTION BoolExternalResult::Id{{{*/
62int BoolExternalResult::Id(void){ return -1; }
63/*}}}*/
64/*FUNCTION BoolExternalResult::MyRank{{{*/
65int BoolExternalResult::MyRank(void){
66 extern int my_rank;
67 return my_rank;
68}
69/*}}}*/
70/*FUNCTION BoolExternalResult::ObjectEnum{{{*/
71int BoolExternalResult::ObjectEnum(void){
72
73 return BoolExternalResultEnum;
74
75}
76/*}}}*/
77/*FUNCTION BoolExternalResult::copy{{{*/
78Object* BoolExternalResult::copy() {
79
80 return new BoolExternalResult(this->id,this->enum_type,this->value,this->step,this->time);
81
82}
83/*}}}*/
84
85/*BoolExternalResult management: */
86/*FUNCTION BoolExternalResult::WriteData{{{*/
87void BoolExternalResult::WriteData(FILE* fid,bool io_gather){
88
89 int length;
90 int type;
91 int size;
92 IssmPDouble passiveDouble;
93 extern int my_rank;
94 char* name = NULL;
95
96 /*return if now on cpu 0: */
97 if(my_rank)return;
98
99 /*First write enum: */
100 EnumToStringx(&name,this->enum_type);
101 length=(strlen(name)+1)*sizeof(char);
102 fwrite(&length,sizeof(int),1,fid);
103 fwrite(name,length,1,fid);
104 xDelete<char>(name);
105
106 /*Now write time and step: */
107 passiveDouble=reCast<IssmPDouble>(time);
108 fwrite(&passiveDouble,sizeof(IssmPDouble),1,fid);
109 fwrite(&step,sizeof(int),1,fid);
110
111 /*writing a IssmDouble, type is 1, size is 1: */
112 type=1;
113 size=1;
114 fwrite(&type,sizeof(int),1,fid);
115 fwrite(&size,sizeof(int),1,fid);
116 /*Now write bool, after casting it: */
117 passiveDouble=reCast<IssmPDouble>(this->value);
118 fwrite(&passiveDouble,size*sizeof(IssmPDouble),1,fid);
119
120}
121/*}}}*/
122/*FUNCTION BoolExternalResult::GetResultName{{{*/
123void BoolExternalResult::GetResultName(char** pname){
124 EnumToStringx(pname,this->enum_type);
125}
126/*}}}*/
127/*FUNCTION BoolExternalResult::GetStep{{{*/
128int BoolExternalResult::GetStep(void){
129
130 return this->step;
131}
132/*}}}*/
Note: See TracBrowser for help on using the repository browser.