1 | #include <stdio.h>
|
---|
2 | #include <string.h>
|
---|
3 | #include <math.h>
|
---|
4 | #include "diag.h"
|
---|
5 | #include "atm.h"
|
---|
6 | #include "init.h"
|
---|
7 |
|
---|
8 | /* random numbers */
|
---|
9 | #define RandomNumber ranf()
|
---|
10 |
|
---|
11 | /* Local declarations */
|
---|
12 | static int atmModel=0; /* current atm. model */
|
---|
13 |
|
---|
14 | /* Function declarations */
|
---|
15 | static float atm(float wavelength, float height, float theta);
|
---|
16 | void SetAtmModel(char *model);
|
---|
17 | int absorption(float wlen, float height, float theta);
|
---|
18 | extern void attenu_(float *, float *, float *, float *); /* in Fortran */
|
---|
19 | extern float ranf(void);
|
---|
20 |
|
---|
21 | void SetAtmModel(char *model)
|
---|
22 | {
|
---|
23 | while (strcmp(model, AtmModelNames[atmModel]))
|
---|
24 | if (++atmModel == sizeof(AtmModelNames)/sizeof(AtmModelNames[0]))
|
---|
25 | { atmModel = 0;
|
---|
26 | Error(ATM__NFND__ERR, model);
|
---|
27 | break; }
|
---|
28 |
|
---|
29 | Log(ATM__SET___LOG, AtmModelNames[atmModel]);
|
---|
30 | } /* end of SetAtmModel */
|
---|
31 |
|
---|
32 | static float atm(float wavelength, float height, float theta)
|
---|
33 | { float transmittance = 1.0; /* final atm transmittance (ret. value) */
|
---|
34 |
|
---|
35 | switch(atmModel)
|
---|
36 | { case ATM_NOATMOSPHERE: /* no atm at all: transmittance = 100% */
|
---|
37 | break;
|
---|
38 | case ATM_90PERCENT: /* atm. with transmittance = 90% */
|
---|
39 | transmittance = 0.9;
|
---|
40 | break;
|
---|
41 | case ATM_ISOTHERMAL: /* isothermal approximation */
|
---|
42 | /********************/
|
---|
43 | break;
|
---|
44 | case ATM_CORSIKA: /* atmosphere as defined in CORSIKA */
|
---|
45 | attenu_(&wavelength, &height, &theta, &transmittance);
|
---|
46 | break;
|
---|
47 | } /* end of atm switch */
|
---|
48 |
|
---|
49 | return transmittance;
|
---|
50 | } /* end of atm */
|
---|
51 |
|
---|
52 | int absorption(float wlen, float height, float theta)
|
---|
53 | { int ret = 0; /* 0: passed, 1: absorbed */
|
---|
54 |
|
---|
55 | if ( RandomNumber > atm(wlen, height, theta)) return 1;
|
---|
56 |
|
---|
57 | return ret;
|
---|
58 | } /* end of absorption */
|
---|