-
Notifications
You must be signed in to change notification settings - Fork 3
/
readstarlog.c
53 lines (47 loc) · 1.45 KB
/
readstarlog.c
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
#include <stdio.h>
#include <rpc/xdr.h>
#include <assert.h>
typedef struct sfEvent /* Holds statistics of the star
formation event */
{
int iOrdStar;
int iOrdGas;
double timeForm;
double rForm[3];
double vForm[3];
double massForm;
double rhoForm;
double TForm;
} SFEVENT;
int main(int argc, char **argv)
{
XDR xdrs;
int magic;
xdrstdio_create(&xdrs,stdin,XDR_DECODE);
xdr_int(&xdrs, &magic);
assert(magic == sizeof(SFEVENT));
printf("# iOrder iOrdGas timeForm rFormX rFormY rFormZ vFormX vFormY vFromZ massForm rhoForm TempForm\n");
while(1) {
SFEVENT SfEv;
SFEVENT *pSfEv = &SfEv;
if(xdr_int(&xdrs, &(pSfEv->iOrdStar)) == 0)
break; /* End of file (hopefully) */
xdr_int(&xdrs, &(pSfEv->iOrdGas));
xdr_double(&xdrs, &(pSfEv->timeForm));
xdr_double(&xdrs, &(pSfEv->rForm[0]));
xdr_double(&xdrs, &(pSfEv->rForm[1]));
xdr_double(&xdrs, &(pSfEv->rForm[2]));
xdr_double(&xdrs, &(pSfEv->vForm[0]));
xdr_double(&xdrs, &(pSfEv->vForm[1]));
xdr_double(&xdrs, &(pSfEv->vForm[2]));
xdr_double(&xdrs, &(pSfEv->massForm));
xdr_double(&xdrs, &(pSfEv->rhoForm));
xdr_double(&xdrs, &(pSfEv->TForm));
printf("%d %d %g %g %g %g %g %g %g %g %g %g\n", SfEv.iOrdStar,
SfEv.iOrdGas, SfEv.timeForm, SfEv.rForm[0], SfEv.rForm[1],
SfEv.rForm[2], SfEv.vForm[0], SfEv.vForm[1], SfEv.vForm[2],
SfEv.massForm, SfEv.rhoForm, SfEv.TForm);
}
xdr_destroy(&xdrs);
return 0;
}