| 1 | /* -------------------------------------------------------------------- */ |
| 2 | /* --------- N R L M S I S E - 0 0 M O D E L 2 0 0 1 ---------- */ |
| 3 | /* -------------------------------------------------------------------- */ |
| 4 | |
| 5 | /* This file is part of the NRLMSISE-00 C source code package - release |
| 6 | * 20041227 |
| 7 | * |
| 8 | * The NRLMSISE-00 model was developed by Mike Picone, Alan Hedin, and |
| 9 | * Doug Drob. They also wrote a NRLMSISE-00 distribution package in |
| 10 | * FORTRAN which is available at |
| 11 | * http://uap-www.nrl.navy.mil/models_web/msis/msis_home.htm |
| 12 | * |
| 13 | * Dominik Brodowski implemented and maintains this C version. You can |
| 14 | * reach him at [email protected]. See the file "DOCUMENTATION" for details, |
| 15 | * and check http://www.brodo.de/english/pub/nrlmsise/index.html for |
| 16 | * updated releases of this package. |
| 17 | */ |
| 18 | |
| 19 | |
| 20 | |
| 21 | /* ------------------------------------------------------------------- */ |
| 22 | /* ------------------------------- INPUT ----------------------------- */ |
| 23 | /* ------------------------------------------------------------------- */ |
| 24 | |
| 25 | struct nrlmsise_flags { |
| 26 | int switches[24]; |
| 27 | double sw[24]; |
| 28 | double swc[24]; |
| 29 | }; |
| 30 | /* |
| 31 | * Switches: to turn on and off particular variations use these switches. |
| 32 | * 0 is off, 1 is on, and 2 is main effects off but cross terms on. |
| 33 | * |
| 34 | * Standard values are 0 for switch 0 and 1 for switches 1 to 23. The |
| 35 | * array "switches" needs to be set accordingly by the calling program. |
| 36 | * The arrays sw and swc are set internally. |
| 37 | * |
| 38 | * switches[i]: |
| 39 | * i - explanation |
| 40 | * ----------------- |
| 41 | * 0 - output in meters and kilograms instead of centimeters and grams |
| 42 | * 1 - F10.7 effect on mean |
| 43 | * 2 - time independent |
| 44 | * 3 - symmetrical annual |
| 45 | * 4 - symmetrical semiannual |
| 46 | * 5 - asymmetrical annual |
| 47 | * 6 - asymmetrical semiannual |
| 48 | * 7 - diurnal |
| 49 | * 8 - semidiurnal |
| 50 | * 9 - daily ap [when this is set to -1 (!) the pointer |
| 51 | * ap_a in struct nrlmsise_input must |
| 52 | * point to a struct ap_array] |
| 53 | * 10 - all UT/long effects |
| 54 | * 11 - longitudinal |
| 55 | * 12 - UT and mixed UT/long |
| 56 | * 13 - mixed AP/UT/LONG |
| 57 | * 14 - terdiurnal |
| 58 | * 15 - departures from diffusive equilibrium |
| 59 | * 16 - all TINF var |
| 60 | * 17 - all TLB var |
| 61 | * 18 - all TN1 var |
| 62 | * 19 - all S var |
| 63 | * 20 - all TN2 var |
| 64 | * 21 - all NLB var |
| 65 | * 22 - all TN3 var |
| 66 | * 23 - turbo scale height var |
| 67 | */ |
| 68 | |
| 69 | struct ap_array { |
| 70 | double a[7]; |
| 71 | }; |
| 72 | /* Array containing the following magnetic values: |
| 73 | * 0 : daily AP |
| 74 | * 1 : 3 hr AP index for current time |
| 75 | * 2 : 3 hr AP index for 3 hrs before current time |
| 76 | * 3 : 3 hr AP index for 6 hrs before current time |
| 77 | * 4 : 3 hr AP index for 9 hrs before current time |
| 78 | * 5 : Average of eight 3 hr AP indicies from 12 to 33 hrs |
| 79 | * prior to current time |
| 80 | * 6 : Average of eight 3 hr AP indicies from 36 to 57 hrs |
| 81 | * prior to current time |
| 82 | */ |
| 83 | |
| 84 | |
| 85 | struct nrlmsise_input { |
| 86 | int year; /* year, currently ignored */ |
| 87 | int doy; /* day of year */ |
| 88 | double sec; /* seconds in day (UT) */ |
| 89 | double alt; /* altitude in kilometers */ |
| 90 | double g_lat; /* geodetic latitude */ |
| 91 | double g_long; /* geodetic longitude */ |
| 92 | double lst; /* local apparent solar time (hours), see note below */ |
| 93 | double f107A; /* 81 day average of F10.7 flux (centered on doy) */ |
| 94 | double f107; /* daily F10.7 flux for previous day */ |
| 95 | double ap; /* magnetic index(daily) */ |
| 96 | struct ap_array *ap_a; /* see above */ |
| 97 | }; |
| 98 | /* |
| 99 | * NOTES ON INPUT VARIABLES: |
| 100 | * UT, Local Time, and Longitude are used independently in the |
| 101 | * model and are not of equal importance for every situation. |
| 102 | * For the most physically realistic calculation these three |
| 103 | * variables should be consistent (lst=sec/3600 + g_long/15). |
| 104 | * The Equation of Time departures from the above formula |
| 105 | * for apparent local time can be included if available but |
| 106 | * are of minor importance. |
| 107 | * |
| 108 | * f107 and f107A values used to generate the model correspond |
| 109 | * to the 10.7 cm radio flux at the actual distance of the Earth |
| 110 | * from the Sun rather than the radio flux at 1 AU. The following |
| 111 | * site provides both classes of values: |
| 112 | * ftp://ftp.ngdc.noaa.gov/STP/SOLAR_DATA/SOLAR_RADIO/FLUX/ |
| 113 | * |
| 114 | * f107, f107A, and ap effects are neither large nor well |
| 115 | * established below 80 km and these parameters should be set to |
| 116 | * 150., 150., and 4. respectively. |
| 117 | */ |
| 118 | |
| 119 | |
| 120 | |
| 121 | /* ------------------------------------------------------------------- */ |
| 122 | /* ------------------------------ OUTPUT ----------------------------- */ |
| 123 | /* ------------------------------------------------------------------- */ |
| 124 | |
| 125 | struct nrlmsise_output { |
| 126 | double d[9]; /* densities */ |
| 127 | double t[2]; /* temperatures */ |
| 128 | }; |
| 129 | /* |
| 130 | * OUTPUT VARIABLES: |
| 131 | * d[0] - HE NUMBER DENSITY(CM-3) |
| 132 | * d[1] - O NUMBER DENSITY(CM-3) |
| 133 | * d[2] - N2 NUMBER DENSITY(CM-3) |
| 134 | * d[3] - O2 NUMBER DENSITY(CM-3) |
| 135 | * d[4] - AR NUMBER DENSITY(CM-3) |
| 136 | * d[5] - TOTAL MASS DENSITY(GM/CM3) [includes d[8] in td7d] |
| 137 | * d[6] - H NUMBER DENSITY(CM-3) |
| 138 | * d[7] - N NUMBER DENSITY(CM-3) |
| 139 | * d[8] - Anomalous oxygen NUMBER DENSITY(CM-3) |
| 140 | * t[0] - EXOSPHERIC TEMPERATURE |
| 141 | * t[1] - TEMPERATURE AT ALT |
| 142 | * |
| 143 | * |
| 144 | * O, H, and N are set to zero below 72.5 km |
| 145 | * |
| 146 | * t[0], Exospheric temperature, is set to global average for |
| 147 | * altitudes below 120 km. The 120 km gradient is left at global |
| 148 | * average value for altitudes below 72 km. |
| 149 | * |
| 150 | * d[5], TOTAL MASS DENSITY, is NOT the same for subroutines GTD7 |
| 151 | * and GTD7D |
| 152 | * |
| 153 | * SUBROUTINE GTD7 -- d[5] is the sum of the mass densities of the |
| 154 | * species labeled by indices 0-4 and 6-7 in output variable d. |
| 155 | * This includes He, O, N2, O2, Ar, H, and N but does NOT include |
| 156 | * anomalous oxygen (species index 8). |
| 157 | * |
| 158 | * SUBROUTINE GTD7D -- d[5] is the "effective total mass density |
| 159 | * for drag" and is the sum of the mass densities of all species |
| 160 | * in this model, INCLUDING anomalous oxygen. |
| 161 | */ |
| 162 | |
| 163 | |
| 164 | |
| 165 | /* ------------------------------------------------------------------- */ |
| 166 | /* --------------------------- PROTOTYPES ---------------------------- */ |
| 167 | /* ------------------------------------------------------------------- */ |
| 168 | |
| 169 | /* GTD7 */ |
| 170 | /* Neutral Atmosphere Empircial Model from the surface to lower |
| 171 | * exosphere. |
| 172 | */ |
| 173 | void gtd7 (struct nrlmsise_input *input, \ |
| 174 | struct nrlmsise_flags *flags, \ |
| 175 | struct nrlmsise_output *output); |
| 176 | |
| 177 | |
| 178 | /* GTD7D */ |
| 179 | /* This subroutine provides Effective Total Mass Density for output |
| 180 | * d[5] which includes contributions from "anomalous oxygen" which can |
| 181 | * affect satellite drag above 500 km. See the section "output" for |
| 182 | * additional details. |
| 183 | */ |
| 184 | void gtd7d(struct nrlmsise_input *input, \ |
| 185 | struct nrlmsise_flags *flags, \ |
| 186 | struct nrlmsise_output *output); |
| 187 | |
| 188 | |
| 189 | /* GTS7 */ |
| 190 | /* Thermospheric portion of NRLMSISE-00 |
| 191 | */ |
| 192 | void gts7 (struct nrlmsise_input *input, \ |
| 193 | struct nrlmsise_flags *flags, \ |
| 194 | struct nrlmsise_output *output); |
| 195 | |
| 196 | |
| 197 | /* GHP7 */ |
| 198 | /* To specify outputs at a pressure level (press) rather than at |
| 199 | * an altitude. |
| 200 | */ |
| 201 | void ghp7 (struct nrlmsise_input *input, \ |
| 202 | struct nrlmsise_flags *flags, \ |
| 203 | struct nrlmsise_output *output, \ |
| 204 | double press); |
| 205 | |
| 206 | |
| 207 | |
| 208 | /* ------------------------------------------------------------------- */ |
| 209 | /* ----------------------- COMPILATION TWEAKS ------------------------ */ |
| 210 | /* ------------------------------------------------------------------- */ |
| 211 | |
| 212 | /* "inlining" of functions */ |
| 213 | /* Some compilers (e.g. gcc) allow the inlining of functions into the |
| 214 | * calling routine. This means a lot of overhead can be removed, and |
| 215 | * the execution of the program runs much faster. However, the filesize |
| 216 | * and thus the loading time is increased. |
| 217 | */ |
| 218 | #ifdef INLINE |
| 219 | #define __inline_double static inline double |
| 220 | #else |
| 221 | #define __inline_double double |
| 222 | #endif |