1 | /*******************************************************************************
|
---|
2 | * *
|
---|
3 | * mcf_hepup_xdr.c -- XDR Utility routines for the Block Stdhep filters *
|
---|
4 | * *
|
---|
5 | * Copyright (c) 1994 Universities Research Association, Inc. *
|
---|
6 | * All rights reserved. *
|
---|
7 | * *
|
---|
8 | * This material resulted from work developed under a Government Contract and *
|
---|
9 | * is subject to the following license: The Government retains a paid-up, *
|
---|
10 | * nonexclusive, irrevocable worldwide license to reproduce, prepare derivative *
|
---|
11 | * works, perform publicly and display publicly by or for the Government, *
|
---|
12 | * including the right to distribute to other Government contractors. Neither *
|
---|
13 | * the United States nor the United States Department of Energy, nor any of *
|
---|
14 | * their employees, makes any warranty, express or implied, or assumes any *
|
---|
15 | * legal liability or responsibility for the accuracy, completeness, or *
|
---|
16 | * usefulness of any information, apparatus, product, or process disclosed, or *
|
---|
17 | * represents that its use would not infringe privately owned rights. *
|
---|
18 | * *
|
---|
19 | * *
|
---|
20 | * Written by Paul Lebrun, Lynn Garren *
|
---|
21 | * *
|
---|
22 | * *
|
---|
23 | *******************************************************************************/
|
---|
24 | #include <stdio.h>
|
---|
25 | #include <string.h>
|
---|
26 | #include <sys/param.h>
|
---|
27 | #include <rpc/types.h>
|
---|
28 | #include <sys/types.h>
|
---|
29 | #include <rpc/xdr.h>
|
---|
30 | #include <limits.h>
|
---|
31 | #ifdef SUNOS
|
---|
32 | #include <floatingpoint.h>
|
---|
33 | #else /* SUNOS */
|
---|
34 | #include <float.h>
|
---|
35 | #endif /* SUNOS */
|
---|
36 | #include <stdlib.h>
|
---|
37 | #include <time.h>
|
---|
38 | #include "Utilities/mcfio/mcfio_Dict.h"
|
---|
39 | #include "Utilities/mcfio/mcf_xdr.h"
|
---|
40 | #include "Utilities/stdhep/hepeup.h"
|
---|
41 | #include "Utilities/stdhep/heprup.h"
|
---|
42 | #include "Utilities/stdhep/stdver.h"
|
---|
43 | #ifndef FALSE
|
---|
44 | #define FALSE 0
|
---|
45 | #endif
|
---|
46 | #ifndef TRUE
|
---|
47 | #define TRUE 1
|
---|
48 | #endif
|
---|
49 |
|
---|
50 | extern struct stdver stdver_;
|
---|
51 | extern struct hepeup hepeup_;
|
---|
52 | extern struct heprup heprup_;
|
---|
53 |
|
---|
54 | bool_t xdr_hepeup_(XDR *xdrs, int *blockid,
|
---|
55 | int *ntot, char** version)
|
---|
56 |
|
---|
57 | {
|
---|
58 | /* Translate the HEPEUP COMMON block from the STDHEP package to/from
|
---|
59 | an XDR stream. Note that we do not allocate memory, because we fill
|
---|
60 | directly the COMMON. Also, mcfio will allocate the space for the
|
---|
61 | string version. */
|
---|
62 |
|
---|
63 | unsigned int nn, nn2, nn5;
|
---|
64 | int *idat;
|
---|
65 | double *dat;
|
---|
66 |
|
---|
67 | if ((xdrs->x_op == XDR_ENCODE) || (xdrs->x_op == XDR_MCFIOCODE)) {
|
---|
68 | if (*blockid != MCFIO_HEPEUP) {
|
---|
69 | fprintf (stderr, "mcf_hepup_xdr: Inconsistent Blockid %d \n ",
|
---|
70 | (*blockid));
|
---|
71 | return FALSE;
|
---|
72 | }
|
---|
73 |
|
---|
74 | nn = (unsigned int) hepeup_.nup; /* Number of elements in idup, istup, vtimup, spinup */
|
---|
75 | nn2 = 2*(unsigned int) hepeup_.nup; /* Number of elements in mothup, icolup */
|
---|
76 | nn5 = 5*(unsigned int) hepeup_.nup; /* Number of elements in pup */
|
---|
77 |
|
---|
78 | /* Total length in bytes include blockid, ntot, version, as well
|
---|
79 | as the common block entries */
|
---|
80 | *ntot = sizeof(int)*(5 + 2*nn + 2*nn2) + sizeof(double)*(4 + 2*nn + nn5);
|
---|
81 |
|
---|
82 | if (xdrs->x_op == XDR_MCFIOCODE) return TRUE;
|
---|
83 | strncpy(version[0],stdver_.stdhep_ver, 4);
|
---|
84 | }
|
---|
85 |
|
---|
86 | if ( (xdr_int(xdrs, blockid) &&
|
---|
87 | xdr_int(xdrs, ntot) &&
|
---|
88 | xdr_string(xdrs, version, MCF_XDR_VERSION_LENGTH) &&
|
---|
89 | xdr_int(xdrs, &(hepeup_.nup)) &&
|
---|
90 | xdr_int(xdrs, &(hepeup_.idprup))) == FALSE) return FALSE;
|
---|
91 |
|
---|
92 | if ((xdrs->x_op == XDR_DECODE) && ( *blockid != MCFIO_HEPEUP) ) {
|
---|
93 | fprintf (stderr, "mcf_hepup_xdr: Inconsistent Blockid %d \n ",
|
---|
94 | (*blockid));
|
---|
95 | return FALSE;
|
---|
96 | }
|
---|
97 |
|
---|
98 | if ( xdr_double(xdrs, &(hepeup_.xwgtup) ) == FALSE) return FALSE;
|
---|
99 | if ( xdr_double(xdrs, &(hepeup_.scalup) ) == FALSE) return FALSE;
|
---|
100 | if ( xdr_double(xdrs, &(hepeup_.aqedup) ) == FALSE) return FALSE;
|
---|
101 | if ( xdr_double(xdrs, &(hepeup_.aqcdup) ) == FALSE) return FALSE;
|
---|
102 | idat = hepeup_.idup;
|
---|
103 | if ( xdr_array(xdrs, (char **) &idat,
|
---|
104 | &nn, MAXNUP, sizeof(int), (void *) xdr_int) == FALSE) return FALSE;
|
---|
105 | idat = hepeup_.istup;
|
---|
106 | if ( xdr_array(xdrs, (char **) &idat,
|
---|
107 | &nn, MAXNUP, sizeof(int), (void *) xdr_int) == FALSE) return FALSE;
|
---|
108 | idat = (int *) hepeup_.mothup;
|
---|
109 | if ( xdr_array(xdrs, (char **) &idat,
|
---|
110 | &nn2, 2*MAXNUP, sizeof(int), (void *) xdr_int) == FALSE) return FALSE;
|
---|
111 | idat = (int *) hepeup_.icolup;
|
---|
112 | if ( xdr_array(xdrs, (char **) &idat,
|
---|
113 | &nn2, 2*MAXNUP, sizeof(int), (void *) xdr_int) == FALSE) return FALSE;
|
---|
114 | dat = (double *) hepeup_.pup;
|
---|
115 | if ( xdr_array(xdrs, (char **) &dat,
|
---|
116 | &nn5, 5*MAXNUP, sizeof(double), (void *) xdr_double) == FALSE) return FALSE;
|
---|
117 | dat = (double *) hepeup_.vtimup;
|
---|
118 | if ( xdr_array(xdrs, (char **) &dat,
|
---|
119 | &nn, MAXNUP, sizeof(double), (void *) xdr_double) == FALSE) return FALSE;
|
---|
120 | dat = (double *) hepeup_.spinup;
|
---|
121 | if ( xdr_array(xdrs, (char **) &dat,
|
---|
122 | &nn, MAXNUP, sizeof(double), (void *) xdr_double) == FALSE) return FALSE;
|
---|
123 | return TRUE;
|
---|
124 | }
|
---|
125 |
|
---|
126 | bool_t xdr_heprup_(XDR *xdrs, int *blockid,
|
---|
127 | int *ntot, char** version)
|
---|
128 |
|
---|
129 | {
|
---|
130 | /* Translate the HEPRUP COMMON block from the STDHEP package to/from
|
---|
131 | an XDR stream. Note that we do not allocate memory, because we fill
|
---|
132 | directly the COMMON. Also, mcfio will allocate the space for the
|
---|
133 | string version. */
|
---|
134 |
|
---|
135 | unsigned int nn, n2;
|
---|
136 | int *idat;
|
---|
137 | double *dat;
|
---|
138 |
|
---|
139 | if ((xdrs->x_op == XDR_ENCODE) || (xdrs->x_op == XDR_MCFIOCODE)) {
|
---|
140 | if (*blockid != MCFIO_HEPRUP) {
|
---|
141 | fprintf (stderr, "mcf_hepup_xdr: Inconsistent Blockid %d \n ",
|
---|
142 | (*blockid));
|
---|
143 | return FALSE;
|
---|
144 | }
|
---|
145 |
|
---|
146 | nn = (unsigned int) heprup_.nprup; /* Number of elements in xsecup, xerrup, xmaxup, lprup */
|
---|
147 | n2 = (unsigned int) 2; /* Number of elements in idbmup, ebmup, pdfgup, pdfsup */
|
---|
148 |
|
---|
149 | /* Total length in bytes include blockid, ntot, version, as well
|
---|
150 | as the common block entries */
|
---|
151 | *ntot = sizeof(int)*(5 + 3*n2 + nn) + sizeof(double)*(n2 + 3*nn);
|
---|
152 |
|
---|
153 | if (xdrs->x_op == XDR_MCFIOCODE) return TRUE;
|
---|
154 | strncpy(version[0],stdver_.stdhep_ver, 4);
|
---|
155 | }
|
---|
156 |
|
---|
157 | if ( (xdr_int(xdrs, blockid) &&
|
---|
158 | xdr_int(xdrs, ntot) &&
|
---|
159 | xdr_string(xdrs, version, MCF_XDR_VERSION_LENGTH) &&
|
---|
160 | xdr_int(xdrs, &(heprup_.idwtup)) &&
|
---|
161 | xdr_int(xdrs, &(heprup_.nprup))) == FALSE) return FALSE;
|
---|
162 |
|
---|
163 | if ((xdrs->x_op == XDR_DECODE) && ( *blockid != MCFIO_HEPRUP) ) {
|
---|
164 | fprintf (stderr, "mcf_hepup_xdr: Inconsistent Blockid %d \n ",
|
---|
165 | (*blockid));
|
---|
166 | return FALSE;
|
---|
167 | }
|
---|
168 | idat = heprup_.idbmup;
|
---|
169 | if ( xdr_array(xdrs, (char **) &idat,
|
---|
170 | &n2, 2, sizeof(int), (void *) xdr_int) == FALSE) return FALSE;
|
---|
171 | dat = (double *) heprup_.ebmup;
|
---|
172 | if ( xdr_array(xdrs, (char **) &dat,
|
---|
173 | &n2, 2, sizeof(double), (void *) xdr_double) == FALSE) return FALSE;
|
---|
174 | idat = heprup_.pdfgup;
|
---|
175 | if ( xdr_array(xdrs, (char **) &idat,
|
---|
176 | &n2, 2, sizeof(int), (void *) xdr_int) == FALSE) return FALSE;
|
---|
177 | idat = heprup_.pdfsup;
|
---|
178 | if ( xdr_array(xdrs, (char **) &idat,
|
---|
179 | &n2, 2, sizeof(int), (void *) xdr_int) == FALSE) return FALSE;
|
---|
180 | dat = (double *) heprup_.xsecup;
|
---|
181 | if ( xdr_array(xdrs, (char **) &dat,
|
---|
182 | &nn, MAXPUP, sizeof(double), (void *) xdr_double) == FALSE) return FALSE;
|
---|
183 | dat = (double *) heprup_.xerrup;
|
---|
184 | if ( xdr_array(xdrs, (char **) &dat,
|
---|
185 | &nn, MAXPUP, sizeof(double), (void *) xdr_double) == FALSE) return FALSE;
|
---|
186 | dat = (double *) heprup_.xmaxup;
|
---|
187 | if ( xdr_array(xdrs, (char **) &dat,
|
---|
188 | &nn, MAXPUP, sizeof(double), (void *) xdr_double) == FALSE) return FALSE;
|
---|
189 | idat = heprup_.lprup;
|
---|
190 | if ( xdr_array(xdrs, (char **) &idat,
|
---|
191 | &nn, MAXPUP, sizeof(int), (void *) xdr_int) == FALSE) return FALSE;
|
---|
192 |
|
---|
193 | return TRUE;
|
---|
194 | }
|
---|
195 |
|
---|
196 |
|
---|