Ice Sheet System Model  4.18
Code documentation
PrintfFunction.cpp
Go to the documentation of this file.
1 /*\file PrintfFunction.c
2  *\brief: this function is used by the _printf_ macro, to take into account the
3  *fact we may be running on a cluster.
4  */
5 
6 #ifdef HAVE_CONFIG_H
7  #include <config.h>
8 #else
9 #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
10 #endif
11 
12 #include <stdarg.h>
13 #include <cstdio>
14 #include <string>
15 #include <iostream>
16 #include <iomanip>
17 
18 #ifdef _HAVE_ANDROID_NDK_
19 #include <android/log.h>
20 #endif
21 #include "./Print.h"
22 #include "../Comm/IssmComm.h"
23 #include "../../String/sharedstring.h"
24 #include "../../MemOps/MemOps.h"
25 
26 int PrintfFunctionOnCpu0(const string & message){
27 
28  /*recover my_rank:*/
29  int my_rank=IssmComm::GetRank();
30 
31  if(my_rank==0){
32  #ifdef _HAVE_ANDROID_JNI_
33  __android_log_print(ANDROID_LOG_INFO, "Native",message.c_str());
34  #else
35  ApiPrintf(message.c_str());
36  #endif
37  }
38  return 1;
39 }
40 int PrintfFunctionOnAllCpus(const string & message){
41 
42  #ifdef _HAVE_ANDROID_JNI_
43  __android_log_print(ANDROID_LOG_INFO, "Native",message.c_str());
44  #else
45  ApiPrintf(message.c_str());
46  #endif
47 
48  return 1;
49 }
PrintfFunctionOnCpu0
int PrintfFunctionOnCpu0(const string &message)
Definition: PrintfFunction.cpp:26
ApiPrintf
void ApiPrintf(const char *string)
Definition: ApiPrintf.cpp:13
Print.h
IssmComm::GetRank
static int GetRank(void)
Definition: IssmComm.cpp:34
PrintfFunctionOnAllCpus
int PrintfFunctionOnAllCpus(const string &message)
Definition: PrintfFunction.cpp:40