1 /*
2 $Id$
3 *======================================================================
4 *
5 * DISCLAIMER
6 *
7 * This material was prepared as an account of work sponsored by an
8 * agency of the United States Government. Neither the United States
9 * Government nor the United States Department of Energy, nor Battelle,
10 * nor any of their employees, MAKES ANY WARRANTY, EXPRESS OR IMPLIED, OR
11 * ASSUMES ANY LEGAL LIABILITY OR RESPONSIBILITY FOR THE ACCURACY,
12 * COMPLETENESS, OR USEFULNESS OF ANY INFORMATION, APPARATUS, PRODUCT,
13 * SOFTWARE, OR PROCESS DISCLOSED, OR REPRESENTS THAT ITS USE WOULD NOT
14 * INFRINGE PRIVATELY OWNED RIGHTS.
15 *
16 * ACKNOWLEDGMENT
17 *
18 * This software and its documentation were produced with Government
19 * support under Contract Number DE-AC06-76RLO-1830 awarded by the United
20 * States Department of Energy. The Government retains a paid-up
21 * non-exclusive, irrevocable worldwide license to reproduce, prepare
22 * derivative works, perform publicly and display publicly by or for the
23 * Government, including the right to distribute to other Government
24 * contractors.
25 *
26 *======================================================================
27 *
28 * -- PEIGS routine (version 2.1) --
29 * Pacific Northwest Laboratory
30 * July 28, 1995
31 *
32 *======================================================================
33 */
34 #include <stdio.h>
35 #include <memory.h>
36 #include <math.h>
37 #include <stdlib.h>
38
39 #include "globalp.c.h"
40
pdiff(n,data,proclist,nprocs,iwork,msg1,msg2,info)41 void pdiff( n, data, proclist, nprocs, iwork, msg1, msg2, info )
42 char *data, *msg1, *msg2;
43 Integer *n, *proclist, *nprocs, *iwork, *info;
44 {
45 /*
46 This routine performs an element by element comparision of a
47 length n array of characters, data, on a processor with its
48 neighbor as described by a list of processors proclist[0:nprocs-1].
49
50 n ........... number of bytes of data in array data
51
52 *data ....... pointer to char (char *)
53 character array with n elements which should be the
54 same on all processors in proclist
55
56 *nprocs ...... number of processor ids in proclist
57
58 *proclist ... pointer to Integer (Integer *)
59 a list of 'nprocs' processor ids on which 'data' should be
60 the same.
61
62 There must be no repeated processor ids in proclist
63
64 iwork ....... pointer to Integer (Integer *)
65 workspace of length at least n bytes, i.e., the same
66 size as data
67
68 msg1 ........ pointer to char (char *)
69 General error message, e.g. "Error in pdspevx"
70
71 msg2 ........ pointer to char (char *)
72 Specific error message indicating what data represents
73 so can tell user what data differs on different
74 processors
75
76 *info = 0: 'data' on this processor is the same as 'data' on
77 one of this processor's neighbors.
78
79 = 1: 'data' on this processor is different from 'data' on
80 one of this processor's neighbors. *info = 1 on one
81 processor does not mean that *info != 0 on all processors
82 in proclist. To do this you need to do a global operation.
83 This is typically by pgexit().
84
85 The processors on which *info = 1 print an error message
86 to stderr
87 */
88
89 static Integer TYPE = 10;
90
91 Integer isize, me, last_proc, next_proc, indx;
92
93 extern Integer indxL ();
94 extern Integer mxwrit_(), mxread_(), mxmynd_();
95
96
97 *info = 0;
98
99 me = mxmynd_();
100
101 indx = indxL ( me, *nprocs, proclist);
102
103 if ( indx < 0 ) {
104 fprintf( stderr, " Error in pdiff. me = %d not in proclist. \n", me );
105 exit(-1);
106 }
107
108 if ( *nprocs < 2 )
109 return;
110
111 last_proc = (indx + *nprocs - 1) % *nprocs;
112 last_proc = proclist[last_proc];
113 next_proc = (indx + 1) % *nprocs;
114 next_proc = proclist[next_proc];
115
116 isize = *n;
117
118 if ( ( (indx + 2) % 2) == 0 ) {
119 mxwrit_( (Integer *)data, &isize, &next_proc, &TYPE );
120 mxread_( iwork, &isize, &last_proc, &TYPE );
121 }
122 else {
123 mxread_( iwork, &isize, &last_proc, &TYPE );
124 mxwrit_( (Integer *)data, &isize, &next_proc, &TYPE );
125 }
126
127 indx = memcmp( data, iwork, *n );
128 indx = abs(indx);
129
130 if( indx != 0 ) {
131 fprintf( stderr, " %s %s is different on processors %d and %d \n",
132 msg1, msg2, me, last_proc );
133
134 *info = 1;
135 }
136
137 return;
138 }
139
140