source: trunk/MagicSoft/Simulation/Detector/ReflectorII/atm.c@ 1686

Last change on this file since 1686 was 1614, checked in by bigongia, 22 years ago
*** empty log message ***
File size: 1.8 KB
Line 
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/* AM Nov 2002: atmModel is now an external variable: */
12int atmModel=0; /* current atm. model */
13
14/* Function declarations */
15static float atm(float wavelength, float height, float theta);
16void SetAtmModel(char *model);
17int absorption(float wlen, float height, float theta);
18extern void attenu_(float *, float *, float *, float *); /* in Fortran */
19extern float ranf(void);
20
21void 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
31 /* 'erfc' must be inited, so keep the following line. */
32 Debug("Initing 'erfc': ret=%g\n", erfc(M_PI));
33} /* end of SetAtmModel */
34
35static float atm(float wavelength, float height, float theta)
36{ float transmittance = 1.0; /* final atm transmittance (ret. value) */
37
38 switch(atmModel)
39 { case ATM_NOATMOSPHERE: /* no atm at all: transmittance = 100% */
40 break;
41 case ATM_90PERCENT: /* atm. with transmittance = 90% */
42 transmittance = 0.9;
43 break;
44 case ATM_ISOTHERMAL: /* isothermal approximation */
45 /********************/
46 break;
47 case ATM_CORSIKA: /* atmosphere as defined in CORSIKA */
48 attenu_(&wavelength, &height, &theta, &transmittance);
49 break;
50 } /* end of atm switch */
51
52 return transmittance;
53} /* end of atm */
54
55int absorption(float wlen, float height, float theta)
56{ int ret = 0; /* 0: passed, 1: absorbed */
57
58 if (RandomNumber > atm(wlen, height, theta)) ret=1;
59
60 return ret;
61} /* end of absorption */
Note: See TracBrowser for help on using the repository browser.