forked from coldlogix/auto
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cutt.cpp
104 lines (95 loc) · 2.8 KB
/
cutt.cpp
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
//---------------------------------------------------------------------
// Thomas Ortlepp 11.09.2001 / 15.04.2002
// Version 1.2
// Phasendaten aus dat File ausschneiden
//---------------------------------------------------------------------
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include "common.hpp"
#define ja 1
#define nein 0
char fa[250],fb[250];
double extstep=0.0003,offset;
int main (int argc, char *argv[])
{
output=nein;
printf("cutt v 1.21 Thomas Ortlepp 21.10.2002 \n");
printf("--------------------------------------\n");
char s[100],ta[10]=".END",tb[10]="loop",f3[50]=".conf";
int c,n,q=0,zd=0;
double tx=40.0e-12,eps=1e-15;
printf("Auswertungstabelle der Phasenwerte erstellen\n");
FILE *ex,*ey;
double w;
if (argc==2)
{
strcpy(fconf,argv[1]); // config-File .conf
strcat(fconf,f3);
readfilename(fa,"simout");
readfilename(fb,"extout");
extstep=readvalue("extstep");
// printf("Einlesen der Datei :%s %s\n",fa,fb);
// c=1-n;
n=100;
c=-99;
}
else
{
printf("Programmaufruf: \n");
printf("ext config-filename \n");
printf("simout, extout muss im .conf File stehen!\n");
printf("extstep muss auch in .conf stehen ( Schrittweite fuer Spalten 2-x ) \n");
printf("Umwandlung von simout in extout Daten\n");
exit(1);
}
tx=1e-12*readvalue("timestep");
// printf("Einlesen der Datei :%s %s\n",fa,fb);
printf("Einlesen der Datei :%s\n",fa);
ex=fopen(fa,"r+");
if (ex==NULL) {
fprintf(stderr, "Unable to open %s\n", fa);
exit(-2);
}
ey=fopen(fb,"w+");
if (ey==NULL) {
fprintf(stderr, "Unable to open %s\n", fb);
exit(-2);
}
fscanf(ex,"%s",s);
// printf("%s\n",s);
while (strcmp(s,ta)!=0) // Vergleich ".end"
fscanf(ex,"%s",s);
if (output==ja) printf("%s\n",s);
fscanf(ex,"%s",s);
while (strcmp(s,tb)!=0) // Kopie bis "loop"
{
if (output==ja) printf("%s ",s);
w=atof(s);
if( (c<0)&&(fabs(w)>eps) )
{
n=99+c;
c=1;
if (output==ja) printf("Zähler: n=%d ",n);
q=0;
fprintf(ey,"\n");
zd++;
}
// fprintf(ey,"%s ",s);
if (c<0) offset=extstep*(c%n+99);
else offset=extstep*((c-1)%n);
fprintf(ey,"%15.14lf ",w+offset );
fscanf(ex,"%s ",s);
if (c++%n==0)
{
if (output==ja) printf("\n");
fprintf(ey,"\n");
}
}
printf("%d Zeilen geschrieben!\n",c+3);
fclose(ey);
fclose(ex);
printf("Fertig!\n");
return 0;
}