1/*
2 * Copyright (C) Bull S.A. 2001
3 * Copyright (c) International Business Machines  Corp., 2001
4 *
5 *   This program is free software;  you can redistribute it and/or modify
6 *   it under the terms of the GNU General Public License as published by
7 *   the Free Software Foundation; either version 2 of the License, or
8 *   (at your option) any later version.
9 *
10 *   This program is distributed in the hope that it will be useful,
11 *   but WITHOUT ANY WARRANTY;  without even the implied warranty of
12 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
13 *   the GNU General Public License for more details.
14 *
15 *   You should have received a copy of the GNU General Public License
16 *   along with this program;  if not, write to the Free Software
17 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19
20/******************************************************************************/
21/*                                                                            */
22/* Dec-03-2001  Created: Jacky Malcles & Jean Noel Cordenner                  */
23/*              These tests are adapted from AIX float PVT tests.             */
24/*                                                                            */
25/******************************************************************************/
26#include 	<float.h>
27#include 	<stdio.h>
28#include 	<stdlib.h>
29#include 	<string.h>
30#include 	<errno.h>
31#include        <limits.h>
32#include        <unistd.h>
33#include        <fcntl.h>
34#include        <errno.h>
35#include        <sys/signal.h>
36#include        <math.h>
37
38static int create_Result_file(void)
39{
40
41	int i, nbVal;
42	double tabR[20000], Inc;
43	char *F_name;
44	int fp;
45
46	F_name = "j0_out.ref2";
47	nbVal = 20000;
48
49	Inc = exp(1);
50
51	for (i = 0; i < nbVal; i++)
52		tabR[i] = j0(Inc * i);
53
54	fp = open(F_name, O_RDWR | O_CREAT | O_TRUNC, 0777);
55	if (!fp) {
56		printf("error opening file");
57		close(fp);
58		return -1;
59	} else {
60		for (i = 0; i < nbVal; i++) {
61			write(fp, &tabR[i], sizeof(double));
62		}
63
64		close(fp);
65		return 0;
66	}
67	return 0;
68}
69
70static int create_Data_file(void)
71{
72	int i, nbVal;
73	double tabD[20000], Inc;
74	char *F_name;
75	int fp;
76
77	F_name = "j0_inp.ref";
78	nbVal = 20000;
79
80	Inc = exp(1);
81
82	for (i = 0; i < nbVal; i++)
83		tabD[i] = (Inc * i);
84
85	fp = open(F_name, O_RDWR | O_CREAT | O_TRUNC, 0777);
86	if (!fp) {
87		printf("error opening file");
88		close(fp);
89		return -1;
90	} else {
91		for (i = 0; i < nbVal; i++) {
92			write(fp, &tabD[i], sizeof(double));
93		}
94		close(fp);
95		return 0;
96	}
97	return 0;
98}
99
100int main(int argc, char *argv[])
101{
102	if (argc > 1) {
103		switch (atoi(argv[1])) {
104		case 1:
105			if (create_Data_file() == 0)
106				printf("Data file created\n");
107			else
108				printf("problem during %s data file creation\n",
109				       argv[0]);
110			break;
111
112		case 2:
113			if (create_Result_file() == 0)
114				printf("Result file created\n");
115			else
116				printf
117				    ("problem during %s result file creation\n",
118				     argv[0]);
119			break;
120		default:
121			printf("Bad arglist code for: '%s'\n", argv[0]);
122			return -1;
123			break;
124		}
125	} else {
126		if (create_Data_file() != 0)
127			printf("problem during %s data file creation\n",
128			       argv[0]);
129		if (create_Result_file() != 0)
130			printf("problem during %s result file creation\n",
131			       argv[0]);
132	}
133	return (0);
134}
135