-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathutils.c
More file actions
166 lines (133 loc) · 2.16 KB
/
utils.c
File metadata and controls
166 lines (133 loc) · 2.16 KB
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
#include <sys/stat.h>
#include <unistd.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <struct.h>
#include <constants.h>
#include <subroutines.h>
int iso_name_to_hitnumber(int N)
{
switch (N)
{
case 161:
case 181:
case 171:
case 162:
return MOL_H2O;
case 626:
case 636:
case 628:
case 627:
case 638:
case 637:
case 828:
case 728:
return MOL_CO2;
case 666:
case 668:
case 686:
case 667:
case 676:
return MOL_O3;
case 446:
case 456:
case 546:
case 448:
case 447:
return MOL_N2O;
case 26:
case 36:
case 28:
case 27:
case 38:
case 37:
return MOL_CO;
case 66:
case 68:
return MOL_O2;
case 44:
return MOL_N2;
case 46:
return MOL_NO;
case 61:
return MOL_OH;
case 6:
return MOL_O;
default:
printf("\nNo such iso: %d\n Exiting...\n",N);
exit(1);
}
}
int iso_name_to_iMol( int N,MOLECULE *mol,PARAMETERINFO *pars)
{
int iMol;
for (iMol=0;iMol<pars->NMOL;iMol++)
if (mol[iMol].iso == N) return iMol;
printf("\nNo such iso in the problem (iso_to_iMol): %d\n Exiting...\n",N);
exit(1);
}
double PROBDN(int N, int L)
{
int K;
K=N/2;
if(N%2)
{
if (L)
{
return ( 2.0/(N/2+1)/(N/2+2) );
}
else
{
printf("L=0,N=%d???,exiting...\n",N);
exit(1);
}
}
else
{
if (L)
{
return ( 2.0/(N/2+1)/(N/2+1) );
}
else
{
return ( 1.0/(N/2+1)/(N/2+1) );
}
}
}
int clear_Rmat ( double **Rmat, int NL)
{
int iu,il;
for (iu=0;iu<NL;iu++)
for (il=0;il<NL;il++)
Rmat[iu][il]=0.0;
return 0;
}
int clear_array ( double **A, int NX,int NY)
{
int ix,iy;
for (ix=0;ix<NX;ix++)
for (iy=0;iy<NY;iy++)
A[ix][iy]=0.0;
return 0;
}
int filesize(const char *filename)
{
struct stat st;
if (!stat( filename, &st)) return (st.st_size);
else return -1;
}
int hit_getint(char *rec, int len)
{
char buf[16];
strncpy(buf,rec,(unsigned int)len);
buf[len]='\0';
return atoi(buf);
}
double hit_getdbl(char *rec,int len)
{
char buf[16];
strncpy(buf,rec,(unsigned int)len);
buf[len]='\0';
return atof(buf);
}