summaryrefslogtreecommitdiff
path: root/src/comm/OverloadComm.c
blob: ad67682ea9d34dd6143eddfe2ee219135996fdd7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
 /*@@
   @file      Overload.c
   @date      Wed Feb  3 23:27:18 1999
   @author    Tom Goodale
   @desc 
   Contains routines to overload the communication functions.
   Uses the overload macros to make sure of consistency and
   to save typing !
   @enddesc 
 @@*/

#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>

#include "cctk_Flesh.h"
#include "cctk_FortranString.h"
#include "OverloadMacros.h"
#include "cctk_WarnLevel.h"

static char *rcsid="$Header$";

CCTK_FILEVERSION(comm_OverloadComm_c)

/* Define the prototypes for the dummy functions. */
#define OVERLOADABLE(name) OVERLOADABLE_DUMMYPROTOTYPE(name)

  /* Deal seperately with the SetupGH routine */
#define CCTKi_DummyAbort    CactusDefaultAbort
#define CCTKi_DummyBarrier  CactusDefaultBarrier
#define CCTKi_DummyExit     CactusDefaultExit
#define CCTKi_DummyMyProc   CactusDefaultMyProc
#define CCTKi_DummynProcs   CactusDefaultnProcs
#define CCTKi_DummySetupGH  CactusDefaultSetupGH

#include "CommOverloadables.h"

  /* Reset the #define to prevent complications. */
#undef CCTKi_DummySetupGH  
#undef CCTKi_DummyMyProc  
#undef CCTKi_DummynProcs
#undef CCTKi_DummyBarrier
#undef CCTKi_DummyExit
#undef CCTKi_DummyAbort

#undef OVERLOADABLE

/* Create the overloadable function variables and the 
 * functions allowing the variables to be set.
 */
#define OVERLOADABLE(name) OVERLOADABLE_FUNCTION(name)

#include "CommOverloadables.h"

#undef OVERLOADABLE


 /*@@
   @routine    CCTKi_SetupCommFunctions
   @date       Thu Feb  4 08:21:26 1999
   @author     Tom Goodale
   @desc 
   Set any comm function which hasn't been overloaded to the default.
   @enddesc 
   @calls     
   @calledby   
   @history 
 
   @endhistory 

@@*/
int CCTKi_SetupCommFunctions(void)
{

#define OVERLOADABLE(name) OVERLOADABLE_INITIALISE(name)

  /* Deal seperately with the SetupGH routine */
#define CCTKi_DummyAbort   CactusDefaultAbort
#define CCTKi_DummyBarrier CactusDefaultBarrier
#define CCTKi_DummyExit    CactusDefaultExit
#define CCTKi_DummyMyProc  CactusDefaultMyProc
#define CCTKi_DummynProcs  CactusDefaultnProcs
#define CCTKi_DummySetupGH CactusDefaultSetupGH

#include "CommOverloadables.h"

  /* Reset the #define to prevent complications. */
#undef CCTKi_DummyAbort
#undef CCTKi_DummyBarrier
#undef CCTKi_DummyExit
#undef CCTKi_DummyMyProc  
#undef CCTKi_DummynProcs
#undef CCTKi_DummySetupGH  

#undef OVERLOADABLE

  return 0;
}

/* Create the dummy functions. */
#define OVERLOADABLE(name) OVERLOADABLE_DUMMY(name)

#include "CommOverloadables.h"

#undef OVERLOADABLE



/*    Fortran bindings for the comm functions */



int CCTK_FCALL CCTK_FNAME(CCTK_Exit)(cGH *GH, int *retval)
{
  return CCTK_Exit(GH, *retval);
}

int CCTK_FCALL CCTK_FNAME(CCTK_ParallelInit)(cGH *GH)
{
  return CCTK_ParallelInit(GH);
}

int CCTK_FCALL CCTK_FNAME(CCTK_Abort)(cGH *GH, int *retval)
{
  CCTK_Abort(GH, *retval);
  return 0;
}

int CCTK_FCALL CCTK_FNAME(CCTK_SyncGroup)(cGH *GH, ONE_FORTSTRING_ARG)
{
  ONE_FORTSTRING_CREATE(group_name)
  CCTK_SyncGroup(GH,group_name);
  free(group_name); 
  return 0;
}

void CCTK_FCALL CCTK_FNAME(CCTK_EnableGroupComm)(int *ierr, cGH *GH, ONE_FORTSTRING_ARG)
{
  ONE_FORTSTRING_CREATE(group_name)
  *ierr = CCTK_EnableGroupComm(GH, group_name); 
  free(group_name);
}

void CCTK_FCALL CCTK_FNAME(CCTK_EnableGroupStorage)(int *ierr, cGH *GH, ONE_FORTSTRING_ARG)
{
  ONE_FORTSTRING_CREATE(group_name)
  *ierr = CCTK_EnableGroupStorage(GH, group_name);
  free(group_name);
}

int CCTK_FCALL CCTK_FNAME(CCTK_nProcs)(cGH *GH)
{
  return CCTK_nProcs(GH);
}
 
int CCTK_FCALL CCTK_FNAME(CCTK_MyProc)(cGH *GH)
{
  return CCTK_MyProc(GH);
}
 
int CCTK_FCALL CCTK_FNAME(CCTK_Barrier)(cGH *GH)
{
  return CCTK_Barrier(GH);
}