1 /* NIGHTFALL Light Curve Synthesis Program */
2 /* Copyright (C) 1998 Rainer Wichmann */
3 /* */
4 /* This program is free software; you can redistribute it */
5 /* and/or modify */
6 /* it under the terms of the GNU General Public License as */
7 /* published by */
8 /* the Free Software Foundation; either version 2 of the License, or */
9 /* (at your option) any later version. */
10 /* */
11 /* This program is distributed in the hope that it will be useful, */
12 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
13 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
14 /* GNU General Public License for more details. */
15 /* */
16 /* You should have received a copy of the GNU General Public License */
17 /* along with this program; if not, write to the Free Software */
18 /* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
19
20 #include <math.h>
21 #include <stdio.h>
22 #include <string.h>
23 #include <stdlib.h>
24 #include <ctype.h>
25 #include <float.h>
26 #include "Light.h"
27
28 #define CHECK_NONE 0
29 #define CHECK_LOWER 1
30 #define CHECK_UPPER 2
31 #define CHECK_BOTH 3
32 #define CHECK_UPPER_WARN_LOWER 4
33 #define NO_FIT -1
34
35 #ifdef _WITH_GTK
36
37 /******************************************************************
38 @package nightfall
39 @author Rainer Wichmann (rwichman@lsw.uni-heidelberg.de)
40 @version 1.0
41 @short Update the entry fields in GUI
42 @tip - entry fields are global variables
43 @param (void)
44 @return (void)
45 @heading Update GUI
46 *******************************************************************/
UpdateGui()47 void UpdateGui()
48 {
49 char InitString[64];
50
51 sprintf(InitString, "%8.5f", Binary[Primary].Mq);
52 gtk_entry_set_text (GTK_ENTRY (e_101), InitString);
53
54 if (Flags.edu != ON)
55 {
56 sprintf(InitString, "%8.5f", Binary[Primary].RocheFill);
57 }
58 else
59 {
60 sprintf(InitString, "%6.3f", Binary[Primary].Radius * PERIDIST / SOL_RADIUS);
61 }
62 gtk_entry_set_text (GTK_ENTRY (e_103), InitString);
63
64 sprintf(InitString, "%6.3f", RTOD*Orbit.Inclination);
65 gtk_entry_set_text (GTK_ENTRY (e_102), InitString);
66
67 if (Flags.edu != ON)
68 {
69 sprintf(InitString, "%8.5f", Binary[Secondary].RocheFill);
70 }
71 else
72 {
73 sprintf(InitString, "%6.3f", Binary[Secondary].Radius * PERIDIST / SOL_RADIUS);
74 }
75 gtk_entry_set_text (GTK_ENTRY (e_104), InitString);
76
77 sprintf(InitString, "%6.3f", Binary[Primary].Temperature);
78 gtk_entry_set_text (GTK_ENTRY (e_105), InitString);
79
80 sprintf(InitString, "%6.3f", Binary[Secondary].Temperature);
81 gtk_entry_set_text (GTK_ENTRY (e_106), InitString);
82
83 #ifdef HAVE_DISK
84 sprintf(InitString, "%6.3f", Binary[Disk].Rout);
85 if (e_114)
86 gtk_entry_set_text (GTK_ENTRY (e_114), InitString);
87
88 sprintf(InitString, "%6.3f", Binary[Disk].Rin);
89 if (e_115)
90 gtk_entry_set_text (GTK_ENTRY (e_115), InitString);
91
92 sprintf(InitString, "%6.3f", Binary[Disk].Tilt);
93 if (e_116)
94 gtk_entry_set_text (GTK_ENTRY (e_116), InitString);
95
96 sprintf(InitString, "%6.3f", Binary[Disk].Warp);
97 if (e_117)
98 gtk_entry_set_text (GTK_ENTRY (e_117), InitString);
99
100 sprintf(InitString, "%6.3f", Binary[Disk].Thick);
101 if (e_118)
102 gtk_entry_set_text (GTK_ENTRY (e_118), InitString);
103
104 sprintf(InitString, "%6.3f", Binary[Disk].HR);
105 if (e_119)
106 gtk_entry_set_text (GTK_ENTRY (e_119), InitString);
107
108 sprintf(InitString, "%6.3f", Binary[Disk].Temperature);
109 if (e_120)
110 gtk_entry_set_text (GTK_ENTRY (e_120), InitString);
111
112 sprintf(InitString, "%6.3f", Binary[Disk].tempHS);
113 if (e_130)
114 gtk_entry_set_text (GTK_ENTRY (e_130), InitString);
115
116 sprintf(InitString, "%6.3f", Binary[Disk].longitudeHS);
117 if (e_131)
118 gtk_entry_set_text (GTK_ENTRY (e_131), InitString);
119
120 sprintf(InitString, "%6.3f", Binary[Disk].extentHS);
121 if (e_132)
122 gtk_entry_set_text (GTK_ENTRY (e_132), InitString);
123
124 sprintf(InitString, "%6.3f", Binary[Disk].depthHS);
125 if (e_133)
126 gtk_entry_set_text (GTK_ENTRY (e_133), InitString);
127 #endif
128
129 sprintf(InitString, "%6.3f", Orbit.Excentricity);
130 if (e_107)
131 gtk_entry_set_text (GTK_ENTRY (e_107), InitString);
132
133 sprintf(InitString, "%6.3f", Orbit.Omega);
134 if (e_108)
135 gtk_entry_set_text (GTK_ENTRY (e_108), InitString);
136
137 sprintf(InitString, "%6.3f", Binary[Primary].Fratio);
138 if (e_109)
139 gtk_entry_set_text (GTK_ENTRY (e_109), InitString);
140
141 sprintf(InitString, "%6.3f", Binary[Secondary].Fratio);
142 if (e_110)
143 gtk_entry_set_text (GTK_ENTRY (e_110), InitString);
144
145 sprintf(InitString, "%8.1f", Orbit.LambdaZero);
146 if (e_111)
147 gtk_entry_set_text (GTK_ENTRY (e_111), InitString);
148
149 sprintf(InitString, "%3d", Flags.reflect);
150 if (e_113)
151 gtk_entry_set_text (GTK_ENTRY (e_113), InitString);
152
153 sprintf(InitString, "%8d", PhaseSteps);
154 if (e_112)
155 gtk_entry_set_text (GTK_ENTRY (e_112), InitString);
156
157 sprintf(InitString, "%3.1f", Binary[Primary].log_g);
158 if (e_121)
159 gtk_entry_set_text (GTK_ENTRY (e_121), InitString);
160
161 sprintf(InitString, "%3.1f", Binary[Secondary].log_g);
162 if (e_122)
163 gtk_entry_set_text (GTK_ENTRY (e_122), InitString);
164
165 if (SpotActive[0] == ON) {
166 sprintf(InitString, "%6.3f", Spot[Primary][0].longitude);
167 gtk_entry_set_text (GTK_ENTRY (e_401), InitString);
168
169 sprintf(InitString, "%6.3f", Spot[Primary][0].latitude);
170 gtk_entry_set_text (GTK_ENTRY (e_402), InitString);
171
172 sprintf(InitString, "%6.3f", Spot[Primary][0].radius);
173 gtk_entry_set_text (GTK_ENTRY (e_403), InitString);
174
175 sprintf(InitString, "%6.3f", Spot[Primary][0].dimfactor);
176 gtk_entry_set_text (GTK_ENTRY (e_404), InitString);
177
178 }
179
180 if (SpotActive[0] == OFF && SpotActive[1] == ON ) {
181 sprintf(InitString, "%6.3f", Spot[Primary][0].longitude);
182 gtk_entry_set_text (GTK_ENTRY (e_405), InitString);
183
184 sprintf(InitString, "%6.3f", Spot[Primary][0].latitude);
185 gtk_entry_set_text (GTK_ENTRY (e_406), InitString);
186
187 sprintf(InitString, "%6.3f", Spot[Primary][0].radius);
188 gtk_entry_set_text (GTK_ENTRY (e_407), InitString);
189
190 sprintf(InitString, "%6.3f", Spot[Primary][0].dimfactor);
191 gtk_entry_set_text (GTK_ENTRY (e_408), InitString);
192 }
193
194 if (SpotActive[1] == ON && SpotActive[0] == ON ) {
195 sprintf(InitString, "%6.3f", Spot[Primary][1].longitude);
196 gtk_entry_set_text (GTK_ENTRY (e_405), InitString);
197
198 sprintf(InitString, "%6.3f", Spot[Primary][1].latitude);
199 gtk_entry_set_text (GTK_ENTRY (e_406), InitString);
200
201 sprintf(InitString, "%6.3f", Spot[Primary][1].radius);
202 gtk_entry_set_text (GTK_ENTRY (e_407), InitString);
203
204 sprintf(InitString, "%6.3f", Spot[Primary][1].dimfactor);
205 gtk_entry_set_text (GTK_ENTRY (e_408), InitString);
206 }
207
208 /**************
209 fprintf(stderr, "P: %d %d S: %d %d ON=%d\n",
210 SpotActive[0],
211 SpotActive[1],
212 SpotActive[2],
213 SpotActive[3],
214 ON);
215 fprintf(stderr, "%6.3f\n", Spot[Secondary][0].longitude);
216 **************/
217
218 if (SpotActive[2] == ON ){
219 sprintf(InitString, "%6.3f", Spot[Secondary][0].longitude);
220 gtk_entry_set_text (GTK_ENTRY (e_409), InitString);
221
222 sprintf(InitString, "%6.3f", Spot[Secondary][0].latitude);
223 gtk_entry_set_text (GTK_ENTRY (e_410), InitString);
224
225 sprintf(InitString, "%6.3f", Spot[Secondary][0].radius);
226 gtk_entry_set_text (GTK_ENTRY (e_411), InitString);
227
228 sprintf(InitString, "%6.3f", Spot[Secondary][0].dimfactor);
229 gtk_entry_set_text (GTK_ENTRY (e_412), InitString);
230 }
231
232 if (SpotActive[2] == OFF && SpotActive[3] == ON ) {
233 sprintf(InitString, "%6.3f", Spot[Secondary][0].longitude);
234 gtk_entry_set_text (GTK_ENTRY (e_413), InitString);
235
236 sprintf(InitString, "%6.3f", Spot[Secondary][0].latitude);
237 gtk_entry_set_text (GTK_ENTRY (e_414), InitString);
238
239 sprintf(InitString, "%6.3f", Spot[Secondary][0].radius);
240 gtk_entry_set_text (GTK_ENTRY (e_415), InitString);
241
242 sprintf(InitString, "%6.3f", Spot[Secondary][0].dimfactor);
243 gtk_entry_set_text (GTK_ENTRY (e_416), InitString);
244 }
245
246 if (SpotActive[3] == ON && SpotActive[2] == ON ) {
247 sprintf(InitString, "%6.3f", Spot[Secondary][1].longitude);
248 gtk_entry_set_text (GTK_ENTRY (e_413), InitString);
249
250 sprintf(InitString, "%6.3f", Spot[Secondary][1].latitude);
251 gtk_entry_set_text (GTK_ENTRY (e_414), InitString);
252
253 sprintf(InitString, "%6.3f", Spot[Secondary][1].radius);
254 gtk_entry_set_text (GTK_ENTRY (e_415), InitString);
255
256 sprintf(InitString, "%6.3f", Spot[Secondary][1].dimfactor);
257 gtk_entry_set_text (GTK_ENTRY (e_416), InitString);
258 }
259
260 if (e_name)
261 gtk_entry_set_text (GTK_ENTRY (e_name), Orbit.Name);
262
263 sprintf(InitString, "%8.4f", Orbit.TruePeriod/86400.);
264 if (e_302)
265 gtk_entry_set_text (GTK_ENTRY (e_302), InitString);
266
267 sprintf(InitString, "%8.4f", Orbit.TrueMass/1.989E30 );
268 if (e_303)
269 gtk_entry_set_text (GTK_ENTRY (e_303), InitString);
270
271 sprintf(InitString, "%6.4f", Orbit.TrueDistance/SOL_RADIUS);
272 if (e_304)
273 gtk_entry_set_text (GTK_ENTRY (e_304), InitString);
274
275 sprintf(InitString, "%6.3f", Orbit.Third[Umag]);
276 if (e_501)
277 gtk_entry_set_text (GTK_ENTRY (e_501), InitString);
278
279 sprintf(InitString, "%6.3f", Orbit.Third[Bmag]);
280 if (e_502)
281 gtk_entry_set_text (GTK_ENTRY (e_502), InitString);
282
283 sprintf(InitString, "%6.3f", Orbit.Third[Vmag]);
284 if (e_503)
285 gtk_entry_set_text (GTK_ENTRY (e_503), InitString);
286
287 sprintf(InitString, "%6.3f", Orbit.Third[Rmag]);
288 if (e_504)
289 gtk_entry_set_text (GTK_ENTRY (e_504), InitString);
290
291 sprintf(InitString, "%6.3f", Orbit.Third[Imag]);
292 if (e_505)
293 gtk_entry_set_text (GTK_ENTRY (e_505), InitString);
294
295 sprintf(InitString, "%6.3f", Orbit.Third[Jmag]);
296 if (e_506)
297 gtk_entry_set_text (GTK_ENTRY (e_506), InitString);
298
299 sprintf(InitString, "%6.3f", Orbit.Third[Hmag]);
300 if (e_507)
301 gtk_entry_set_text (GTK_ENTRY (e_507), InitString);
302
303 sprintf(InitString, "%6.3f", Orbit.Third[Kmag]);
304 if (e_508)
305 gtk_entry_set_text (GTK_ENTRY (e_508), InitString);
306
307 sprintf(InitString, "%6.3f", Orbit.Third[umag]);
308 if (e_509)
309 gtk_entry_set_text (GTK_ENTRY (e_509), InitString);
310
311 sprintf(InitString, "%6.3f", Orbit.Third[vmag]);
312 if (e_510)
313 gtk_entry_set_text (GTK_ENTRY (e_510), InitString);
314
315 sprintf(InitString, "%6.3f", Orbit.Third[bmag]);
316 if (e_511)
317 gtk_entry_set_text (GTK_ENTRY (e_511), InitString);
318
319 sprintf(InitString, "%6.3f", Orbit.Third[ymag]);
320 if (e_512)
321 gtk_entry_set_text (GTK_ENTRY (e_512), InitString);
322
323 return;
324 }
325
326
327 /******************************************************************
328 @package nightfall
329 @author Rainer Wichmann (rwichman@lsw.uni-heidelberg.de)
330 @version 1.0
331 @short Write out a configuration file
332 @tip - all entries set to CONST
333 @param (char) *OutputFile The output file name
334 @return (void)
335 @heading Output Configuration
336 *******************************************************************/
WriteConfig(const char * OutputFile)337 void WriteConfig(const char *OutputFile)
338 {
339 FILE *out_file;
340 int spotcount;
341 FileType *dataFile = FileList;
342
343 out_file = fopen(OutputFile, "w");
344
345 if (out_file == NULL) {
346 WARNING(_("Could not open output config file"));
347 return;
348 }
349
350 /* setlocale (LC_NUMERIC, "C"); */
351
352 fprintf(out_file, "#####################################\n");
353 fprintf(out_file, "# \n");
354 fprintf(out_file, "# Nightfall configuration file \n");
355 fprintf(out_file, "# \n");
356 fprintf(out_file, "#####################################\n");
357
358 if (Flags.blackbody == OFF)
359 fprintf(out_file, "PrimaryLogG CONST %f\n\n",
360 Binary[Primary].log_g);
361 else
362 fprintf(out_file, "#PrimaryLogG CONST %f\n\n",
363 Binary[Primary].log_g);
364
365 if (Flags.blackbody == OFF)
366 fprintf(out_file, "SecondaryLogG CONST %f\n\n",
367 Binary[Secondary].log_g);
368 else
369 fprintf(out_file, "#SecondaryLogG CONST %f\n\n",
370 Binary[Secondary].log_g);
371
372 fprintf(out_file, "Name %s\n\n",
373 Orbit.Name);
374 fprintf(out_file, "MassRatio CONST %f\n\n",
375 Binary[Primary].Mq);
376 fprintf(out_file, "Inclination CONST %f\n\n",
377 RTOD*Orbit.Inclination);
378 fprintf(out_file, "PrimaryRocheFill CONST %f\n\n",
379 Binary[Primary].RocheFill);
380 fprintf(out_file, "SecondaryRocheFill CONST %f\n\n",
381 Binary[Secondary].RocheFill);
382 fprintf(out_file, "PrimaryTemperature CONST %f\n\n",
383 Binary[Primary].Temperature);
384 fprintf(out_file, "SecondaryTemperature CONST %f\n\n",
385 Binary[Secondary].Temperature);
386
387 #ifdef HAVE_DISK
388 if (Flags.disk == ON)
389 fprintf(out_file, "InnerDiskRadius CONST %f\n\n",
390 Binary[Disk].Rin);
391 else
392 fprintf(out_file, "#InnerDiskRadius CONST %f\n\n",
393 Binary[Disk].Rin);
394 if (Flags.disk == ON)
395 fprintf(out_file, "OuterDiskRadius CONST %f\n\n",
396 Binary[Disk].Rout);
397 else
398 fprintf(out_file, "#OuterDiskRadius CONST %f\n\n",
399 Binary[Disk].Rout);
400 if (Flags.disk == ON)
401 fprintf(out_file, "DiskTilt CONST %f\n\n",
402 Binary[Disk].Tilt);
403 else
404 fprintf(out_file, "#DiskTilt CONST %f\n\n",
405 Binary[Disk].Tilt);
406 if (Flags.disk == ON)
407 fprintf(out_file, "DiskWarp CONST %f\n\n",
408 Binary[Disk].Warp);
409 else
410 fprintf(out_file, "#DiskWarp CONST %f\n\n",
411 Binary[Disk].Warp);
412 if (Flags.disk == ON)
413 fprintf(out_file, "DiskThickness CONST %f\n\n",
414 Binary[Disk].Thick);
415 else
416 fprintf(out_file, "#DiskThickness CONST %f\n\n",
417 Binary[Disk].Thick);
418 if (Flags.disk == ON)
419 fprintf(out_file, "DiskHoverR CONST %f\n\n",
420 Binary[Disk].HR);
421 else
422 fprintf(out_file, "#DiskHoverR CONST %f\n\n",
423 Binary[Disk].HR);
424 if (Flags.disk == ON)
425 fprintf(out_file, "DiskTemperature CONST %f\n\n",
426 Binary[Disk].Temperature);
427 else
428 fprintf(out_file, "#DiskTemperature CONST %f\n\n",
429 Binary[Disk].Temperature);
430 if (Flags.disk == ON)
431 fprintf(out_file, "HotSpotTemperature CONST %f\n\n",
432 Binary[Disk].tempHS);
433 else
434 fprintf(out_file, "#HotSpotTemperature CONST %f\n\n",
435 Binary[Disk].tempHS);
436 if (Flags.disk == ON)
437 fprintf(out_file, "HotSpotLongitude CONST %f\n\n",
438 Binary[Disk].longitudeHS);
439 else
440 fprintf(out_file, "#HotSpotLongitude CONST %f\n\n",
441 Binary[Disk].longitudeHS);
442 if (Flags.disk == ON)
443 fprintf(out_file, "HotSpotExtent CONST %f\n\n",
444 Binary[Disk].extentHS);
445 else
446 fprintf(out_file, "#HotSpotExtent CONST %f\n\n",
447 Binary[Disk].extentHS);
448 if (Flags.disk == ON)
449 fprintf(out_file, "HotSpotDepth CONST %f\n\n",
450 Binary[Disk].depthHS);
451 else
452 fprintf(out_file, "#HotSpotDepth CONST %f\n\n",
453 Binary[Disk].depthHS);
454 if (Flags.disk == ON)
455 fprintf(out_file, "HotSpotPuff CONST %f\n\n",
456 Binary[Disk].puffHS);
457 else
458 fprintf(out_file, "#HotSpotPuff CONST %f\n\n",
459 Binary[Disk].puffHS);
460 if (Flags.disk == ON)
461 fprintf(out_file, "WarpMaximum CONST %f\n\n",
462 Binary[Disk].maxWarp);
463 else
464 fprintf(out_file, "#WarpMaximum CONST %f\n\n",
465 Binary[Disk].maxWarp);
466 if (Flags.disk == ON)
467 fprintf(out_file, "WarpLongitude CONST %f\n\n",
468 Binary[Disk].longitudeWarp);
469 else
470 fprintf(out_file, "#WarpLongitude CONST %f\n\n",
471 Binary[Disk].longitudeWarp);
472 if (Flags.disk == ON)
473 fprintf(out_file, "WarpWidth CONST %f\n\n",
474 Binary[Disk].widthWarp);
475 else
476 fprintf(out_file, "#WarpWidth CONST %f\n\n",
477 Binary[Disk].widthWarp);
478 if (Flags.disk == ON)
479 fprintf(out_file, "WarpCentre CONST %f\n\n",
480 Binary[Disk].centreWarp);
481 else
482 fprintf(out_file, "#WarpCentre CONST %f\n\n",
483 Binary[Disk].centreWarp);
484 #endif
485
486 fprintf(out_file, "ThirdLight_U CONST %f\n\n",
487 Orbit.Third[Umag]);
488 fprintf(out_file, "ThirdLight_B CONST %f\n\n",
489 Orbit.Third[Bmag]);
490 fprintf(out_file, "ThirdLight_V CONST %f\n\n",
491 Orbit.Third[Vmag]);
492 fprintf(out_file, "ThirdLight_R CONST %f\n\n",
493 Orbit.Third[Rmag]);
494 fprintf(out_file, "ThirdLight_I CONST %f\n\n",
495 Orbit.Third[Imag]);
496 fprintf(out_file, "ThirdLight_J CONST %f\n\n",
497 Orbit.Third[Jmag]);
498 fprintf(out_file, "ThirdLight_H CONST %f\n\n",
499 Orbit.Third[Hmag]);
500 fprintf(out_file, "ThirdLight_K CONST %f\n\n",
501 Orbit.Third[Kmag]);
502 fprintf(out_file, "ThirdLight_Str_u CONST %f\n\n",
503 Orbit.Third[umag]);
504 fprintf(out_file, "ThirdLight_Str_v CONST %f\n\n",
505 Orbit.Third[vmag]);
506 fprintf(out_file, "ThirdLight_Str_b CONST %f\n\n",
507 Orbit.Third[bmag]);
508 fprintf(out_file, "ThirdLight_Str_y CONST %f\n\n",
509 Orbit.Third[vmag]);
510
511 if (Flags.elliptic == ON)
512 fprintf(out_file, "EllipticOrbitEccentricity CONST %f\n\n",
513 Orbit.Excentricity);
514 else
515 fprintf(out_file, "#EllipticOrbitEccentricity CONST %f\n\n",
516 Orbit.Excentricity);
517
518 if (Flags.elliptic == ON)
519 fprintf(out_file, "EllipticOrbitPeriastronLength CONST %f\n\n",
520 Orbit.Omega);
521 else
522 fprintf(out_file, "#EllipticOrbitPeriastronLength CONST %f\n\n",
523 Orbit.Omega);
524
525 if (Flags.asynchron1 == ON)
526 fprintf(out_file, "PrimaryFRatio CONST %f\n\n",
527 Binary[Primary].Fratio);
528 else
529 fprintf(out_file, "#PrimaryFRatio CONST %f\n\n",
530 Binary[Primary].Fratio);
531
532 if (Flags.asynchron2 == ON)
533 fprintf(out_file, "SecondaryFRatio CONST %f\n\n",
534 Binary[Secondary].Fratio);
535 else
536 fprintf(out_file, "#SecondaryFRatio CONST %f\n\n",
537 Binary[Secondary].Fratio);
538
539 fprintf(out_file, "AbsoluteMass CONST %f\n\n",
540 Orbit.TrueMass/1.989E30);
541 fprintf(out_file, "AbsoluteDistance CONST %f\n\n",
542 Orbit.TrueDistance/SOL_RADIUS);
543 fprintf(out_file, "AbsolutePeriod CONST %f\n\n",
544 Orbit.TruePeriod/86400.);
545
546 if (Flags.Spots1 > 0) {
547 for (spotcount = 0; spotcount < Flags.Spots1; ++spotcount) {
548 fprintf(out_file, "SpotPrimary CONST CONST CONST CONST %f %f %f %f\n\n",
549 Spot[Primary][spotcount].longitude,
550 Spot[Primary][spotcount].latitude,
551 Spot[Primary][spotcount].radius,
552 Spot[Primary][spotcount].dimfactor);
553 }
554 }
555
556 if (Flags.Spots2 > 0) {
557 for (spotcount = 0; spotcount < Flags.Spots2; ++spotcount) {
558 fprintf(out_file, "SpotSecondary CONST CONST CONST CONST %f %f %f %f\n\n",
559 Spot[Secondary][spotcount].longitude,
560 Spot[Secondary][spotcount].latitude,
561 Spot[Secondary][spotcount].radius,
562 Spot[Secondary][spotcount].dimfactor);
563 }
564 }
565
566 while (dataFile != NULL) {
567 fprintf(out_file, "InputFile %s %d\n",
568 dataFile->DataFile, dataFile->DataFormat);
569 dataFile = dataFile->nextFile;
570 }
571
572 /* setlocale (LC_NUMERIC, ""); */
573 fclose(out_file);
574 }
575
576 #endif
577
578
579 /******************************************************************
580 @package nightfall
581 @author Rainer Wichmann (rwichman@lsw.uni-heidelberg.de)
582 @version 1.0
583 @short Parse a line for string, do error handling
584 @param (char) *InputFile The input file name
585 @param (char) *varname The test string
586 @param (char) *outvar The output variable
587 @param (int) numline The line number
588 @param (int) check_flag what to check
589 @param (float) lower lower limit
590 @param (float) upper upper limit
591 @param (int) die_flag die on failure
592 @param (int) fit_flag set fit for index fit_flag
593 @return (int) The exit status
594 @heading Read Configuration
595 *******************************************************************/
parse_double(char * in_line,char * varname,double * outvar,int numline,int check_flag,float lower,float upper,int die_flag,int fit_flag)596 int parse_double(char *in_line, char *varname, double *outvar, int numline,
597 int check_flag, float lower, float upper,
598 int die_flag, int fit_flag)
599 {
600 char first[MAX_CFG_INLINE+1]; /* first item */
601 char second[MAX_CFG_INLINE+1]; /* second item */
602 float third = 0.; /* third item */
603 int test;
604 char msg[84];
605 int success = OFF;
606
607 test = sscanf(in_line, "%s %s %f", first, second, &third);
608
609 /* fprintf(stderr, "%s\nData: %s / %s / %s\n",
610 in_line, first, second, third);
611 */
612
613 if (test == 3) {
614
615 if (Flags.debug[INFILE] == ON)
616 fprintf(stderr, _("search %s for %s\n"), first, varname);
617
618 if (strcmp(first, varname) == 0) {
619
620 /* ------------------- check bounds -------------------- */
621
622 if (check_flag == CHECK_UPPER || check_flag == CHECK_UPPER_WARN_LOWER) {
623 if (third <= upper) {
624 *outvar = third;
625 success = ON;
626 }
627 if (check_flag == CHECK_UPPER_WARN_LOWER && third < lower) {
628 sprintf(msg,
629 _("Parameter value too low (%8.3g,%8.3g) in .cfg file: %8.3g, line %6d\n"),
630 lower, upper, third, numline);
631 WARNING(msg);
632 }
633 }
634 else if (check_flag == CHECK_LOWER) {
635 if (third >= lower) {
636 *outvar = third;
637 success = ON;
638 }
639 }
640 else if (check_flag == CHECK_BOTH) {
641 if (third >= lower && third <= upper) {
642 *outvar = third;
643 success = ON;
644 }
645 }
646 else if (check_flag == CHECK_NONE) {
647 *outvar = third;
648 success = ON;
649 }
650
651 /* ------------------- handle error -------------------- */
652
653 if (success == OFF) {
654 sprintf(msg,
655 _("Range Error (%8.3g,%8.3g) in .cfg file: %8.3g, line %6d\n"),
656 lower, upper, third, numline);
657 #ifndef _WITH_GTK
658 if (die_flag == ON) nf_error (msg);
659 else WARNING(msg);
660 #else
661 if (Flags.interactive == OFF) {
662 if (die_flag == ON) nf_error (msg);
663 else WARNING(msg);
664 } else {
665 WARNING (msg);
666 }
667 #endif
668 return(OFF);
669 }
670
671 /* ------------------- set fit flag -------------------- */
672
673 if (success == ON && fit_flag != NO_FIT) {
674 if (strcmp(second, "fit") == 0) {
675 Flags.simplex[fit_flag] = ON;
676 } else if (strcmp(second, "const") != 0) {
677 sprintf(msg, _("Invalid line %6d in Config File\n"),
678 numline);
679 WARNING (msg);
680 }
681 }
682
683 /* ------------------- return success ------------------ */
684
685 if (Flags.debug[INFILE] == ON)
686 fprintf(stderr, _("success \n"));
687 return(ON);
688
689 }
690 }
691
692 /* ------------------- return failure ------------------ */
693
694 return(OFF);
695 }
696
697
698 /******************************************************************
699 @package nightfall
700 @author Rainer Wichmann (rwichman@lsw.uni-heidelberg.de)
701 @version 1.0
702 @tip Parse a configuration file
703 @param (char) *InputFile The input file name
704 @param (int) *numarg The number of mandatory params read
705 @return (void)
706 @heading Read Configuration
707 *******************************************************************/
ParseConfig(const char * InputFile,int * numarg)708 void ParseConfig(const char *InputFile, int *numarg)
709 {
710
711 char fullPath[1024]; /* full path to file */
712 char in_line[MAX_CFG_INLINE+1]; /* input line from file */
713 char first[MAX_CFG_INLINE+1]; /* first item */
714 char second[MAX_CFG_INLINE+1]; /* second item */
715 char third[MAX_CFG_INLINE+1]; /* third item */
716 char fourth[MAX_CFG_INLINE+1]; /* fourth item */
717 char fifth[MAX_CFG_INLINE+1]; /* fifth item */
718 float In1, In2, In3, In4; /* input data */
719 int Ii1; /* integer input */
720 int in_test; /* test variable */
721 int test; /* test variable */
722 int numline; /* lines read */
723 int mandatory; /* mandatory args read */
724 FILE *in_file; /* input filehandle */
725 char *InPtr ; /* pointer to inline */
726 char msg[64]; /* error message */
727 #ifdef _WITH_GTK
728 char InitString[64];
729 int i, j; /* loop variable */
730 #endif
731
732 numline = 0; mandatory = 0;
733
734 strncpy(fullPath, InputFile, sizeof(fullPath)-1);
735
736 in_file = fopen(InputFile, "r");
737
738 if (in_file == NULL) {
739
740 strcpy(fullPath, "./cfg/");
741 strncat(fullPath, InputFile, sizeof(fullPath)-strlen(InputFile)-7);
742 in_file = fopen(fullPath, "r");
743
744 if (in_file == NULL) {
745
746 strncpy(fullPath, data_cfg_fls(), sizeof(fullPath)-strlen(InputFile)-6);
747 /* strcat(fullPath, "/cfg/"); */
748 strcat(fullPath, "/");
749 strcat(fullPath, InputFile);
750 in_file = fopen(fullPath, "r");
751
752 }
753
754 }
755
756 /* ------ open file ----------- */
757
758 #ifdef _WITH_GTK
759 if (in_file == NULL) {
760 if ( Flags.interactive == ON && Flags.parseCL == OFF ) {
761 make_dialog(_(errmsg[7]));
762 return;
763 } else nf_error(_(errmsg[7]));
764 }
765 #else
766 if (in_file == NULL) nf_error(_(errmsg[7]));
767 #endif
768
769 #ifdef _WITH_GTK
770 if ( Flags.interactive == ON && Flags.parseCL == OFF )
771 my_appbar_push(_("Reading configuration"));
772 #endif
773
774 if (Flags.debug[INFILE] == ON) {
775 fprintf(stderr, "Configuration File is %s\n", InputFile);
776 }
777
778 #ifdef HAVE_DISK
779 Binary[Disk].Rin = 0.0;
780 #endif
781
782 #ifdef _WITH_GTK
783 if ( Flags.interactive == ON && Flags.parseCL == OFF ) {
784
785 /* ------ initialize ----------- */
786
787
788 Flags.PlotBand = -1;
789
790 Flags.Spots1 = 0;
791 Flags.Spots2 = 0;
792 Flags.fill = OFF;
793
794 Flags.disk = OFF;
795 Flags.elliptic = OFF;
796 Flags.asynchron1 = OFF;
797 Flags.asynchron2 = OFF;
798
799 Flags.first_pass = ON;
800 Flags.ProComputed = OFF;
801 Flags.IsComputed = OFF;
802
803 Orbit.Dist = 1.0;
804 Orbit.MinDist = 1.0;
805 Orbit.Excentricity = 0.0;
806 Orbit.Omega = 90.;
807 Orbit.TruePeriod = 0.0;
808 Orbit.TrueDistance = 0.0;
809 Orbit.TrueMass = 0.0;
810 strcpy(Orbit.Name, "(void)");
811 Orbit.LambdaZero = LAMDAZERO_DEFAULT; /* should be nanometer */
812 for (j = 0; j < NUM_MAG; ++j) Orbit.Third[j] = 0.0;
813
814 Binary[Primary].Fratio = 1.0;
815 Binary[Secondary].Fratio = 1.0;
816 Binary[Primary].RocheFill = 0.8;
817 Binary[Secondary].RocheFill = 0.8;
818 Binary[Primary].log_g = 4.0;
819 Binary[Secondary].log_g = 4.0;
820
821
822 if (Flags.edu != ON) {
823 gtk_toggle_button_set_active
824 (GTK_TOGGLE_BUTTON (t_eccentric_button), FALSE);
825 gtk_toggle_button_set_active
826 (GTK_TOGGLE_BUTTON (t_fpri_button), FALSE);
827 gtk_toggle_button_set_active
828 (GTK_TOGGLE_BUTTON (t_fsec_button), FALSE);
829 gtk_toggle_button_set_active
830 (GTK_TOGGLE_BUTTON (t_ssp1_button), FALSE);
831 gtk_toggle_button_set_active
832 (GTK_TOGGLE_BUTTON (t_ssp2_button), FALSE);
833 }
834 gtk_toggle_button_set_active
835 (GTK_TOGGLE_BUTTON (t_psp1_button), FALSE);
836 gtk_toggle_button_set_active
837 (GTK_TOGGLE_BUTTON (t_psp2_button), FALSE);
838
839 #ifdef HAVE_DISK
840 if (Flags.edu != ON) {
841 gtk_toggle_button_set_active
842 (GTK_TOGGLE_BUTTON (t_disk_button), FALSE);
843 }
844
845 Binary[Disk].Tilt = 0.0;
846 Binary[Disk].Warp = 0.0;
847 Binary[Disk].Thick = 0.01;
848 Binary[Disk].HR = 0.0; /* 0 for a flat disk */
849 Binary[Disk].Rout = 0.8;
850 Binary[Disk].Rin = 0.2;
851 Binary[Disk].Temperature = 8000.0;
852
853 Binary[Disk].tempHS = Binary[Disk].Temperature;
854 Binary[Disk].longitudeHS = 0.0;
855 Binary[Disk].extentHS = 0.0;
856 Binary[Disk].depthHS = 0.0;
857 #endif
858
859 TG_P1spot = 0, TG_P2spot = 0;
860 TG_S1spot = 0, TG_S2spot = 0;
861 for (i=0; i < 4; ++i) SpotActive[i] = 0;
862 TG_1spots = 0, TG_2spots = 0;
863 for (i=0; i < 16; ++i) FitSpotS[i] = 0;
864 for (i=0; i < 2; ++i) {
865 for (j=0; j < 2; ++j) {
866 SpotStore[i][j].nowlongitude = 0.0;
867 SpotStore[i][j].longitude = 0.0;
868 SpotStore[i][j].latitude = 0.0;
869 SpotStore[i][j].radius = 0.0;
870 SpotStore[i][j].dimfactor = 0.0;
871 Spot[i][j].longitude = 0.0;
872 Spot[i][j].latitude = 0.0;
873 Spot[i][j].radius = 0.0;
874 Spot[i][j].dimfactor = 0.0;
875 }
876 }
877
878 ClearList(); /* data file list */
879
880
881 /* ------ end initialize -------- */
882
883 }
884 #endif
885
886 /* setlocale (LC_NUMERIC, "C"); */
887
888 in_line[0] = '\n';
889
890 /* while (LireLigne(in_line, (int)(sizeof(in_line)), in_file) > 0) { */
891
892 while( NULL != fgets( in_line, MAX_CFG_INLINE, in_file )) {
893
894 ++numline;
895
896
897 /* clip off optional comment tail indicated by a semi-colon */
898 if( NULL != (InPtr = strchr( in_line, ';' )))
899 *InPtr = '\0';
900 else
901 InPtr = in_line + strlen( in_line );
902 /* clip off trailing and leading white space */
903 InPtr--;
904 while( isspace( *InPtr ) && InPtr >= in_line )
905 *InPtr-- = '\0';
906 InPtr = in_line;
907 while( isspace( *InPtr ))
908 InPtr++;
909 /* break if empty line */
910 if( 0 == strlen( InPtr ))
911 continue;
912
913
914 /* this is a header or empty line */
915 if (InPtr[0] == '#' || InPtr[0] == '\n') continue;
916
917 in_test = OFF;
918
919 if (Flags.debug[INFILE] == ON) {
920 fprintf(stderr, "LINE: %s\n", InPtr);
921 }
922
923 /* ----------- the name of the system --------------- */
924
925 test = sscanf(InPtr, "%s %s", first, second);
926 /* convert to lowercase */
927 nf_strlwr( first );
928
929 if (test == 2 && strcmp(first, "name") == 0) {
930 if (Flags.debug[INFILE] == ON)
931 fprintf(stderr, _("system name is %s\n"), second);
932 strcpy(Orbit.Name, second);
933 continue;
934 } else if (strcmp(first, "name") == 0) {
935 sprintf(msg, _("Invalid line %6d in Config File\n"),
936 numline);
937 WARNING (msg);
938 continue;
939 }
940
941 /* ----------------- input file ------------------ */
942
943 test = sscanf(InPtr, "%s %s %d", first, second, &Ii1);
944 /* convert to lowercase */
945 nf_strlwr( first );
946
947 if (test == 2 || test == 3 ) {
948 if (strcmp(first, "inputfile") == 0) {
949 if (Flags.debug[INFILE] == ON)
950 fprintf(stderr, _("read input file %s\n"), second);
951 if (test == 2 || Ii1 == NF_NATIVE_FILE ) Read(second);
952 continue;
953 }
954 }
955
956 /* ----------- convert to lowercase ------------------- */
957
958 nf_strlwr( InPtr );
959
960 /* ----------- the mandatory parameters --------------- */
961
962 /* test input, do error handling, put in variable */
963 in_test = parse_double(InPtr, "massratio", &Binary[Primary].Mq,
964 numline,
965 CHECK_BOTH, LIM_MQ_L, LIM_MQ_H, ON, 0);
966 if (in_test == ON) {
967 ++mandatory;
968 Binary[Secondary].Mq = 1.0/Binary[Primary].Mq;
969 continue;
970 }
971
972 in_test = parse_double(InPtr, "inclination", &Orbit.Inclination,
973 numline,
974 CHECK_BOTH, LIM_IN_L,
975 (float) RTOD*LIM_IN_H, ON, 1);
976 if (in_test == ON) {
977 ++mandatory;
978 Orbit.Inclination = DTOR*Orbit.Inclination;
979 continue;
980 }
981
982 in_test = parse_double(InPtr, "primaryrochefill",
983 &Binary[Primary].RocheFill,numline,
984 CHECK_BOTH, LIM_RF_L, LIM_RO_H, ON, 2);
985 if (in_test == ON) { ++mandatory; continue; }
986
987 in_test = parse_double(InPtr, "secondaryrochefill",
988 &Binary[Secondary].RocheFill,numline,
989 CHECK_BOTH, LIM_RF_L, LIM_RO_H, ON, 3);
990 if (in_test == ON) { ++mandatory; continue; }
991
992
993 if (Flags.blackbody == OFF) {
994 in_test = parse_double(InPtr, "primarytemperature",
995 &Binary[Primary].Temperature,numline,
996 CHECK_UPPER_WARN_LOWER, LIM_TM_L,
997 LIM_TM_H(Binary[Primary].log_g), ON, 4);
998 if (in_test == ON) { ++mandatory; continue; }
999 in_test = parse_double(InPtr, "secondarytemperature",
1000 &Binary[Secondary].Temperature,numline,
1001 CHECK_UPPER_WARN_LOWER, LIM_TM_L,
1002 LIM_TM_H(Binary[Secondary].log_g), ON, 5);
1003 if (in_test == ON) { ++mandatory; continue; }
1004 } else {
1005 in_test = parse_double(InPtr, "primarytemperature",
1006 &Binary[Primary].Temperature,numline,
1007 CHECK_BOTH, LIM_TB_L, LIM_TB_H, ON, 4);
1008 if (in_test == ON) { ++mandatory; continue; }
1009 in_test = parse_double(InPtr, "secondarytemperature",
1010 &Binary[Secondary].Temperature,numline,
1011 CHECK_BOTH, LIM_TB_L, LIM_TB_H, ON, 5);
1012 if (in_test == ON) { ++mandatory; continue; }
1013 }
1014
1015 #ifdef HAVE_DISK
1016 in_test = parse_double(InPtr, "innerdiskradius",
1017 &Binary[Disk].Rin, numline,
1018 CHECK_BOTH, LIM_IR_L, LIM_IR_H, ON, NO_FIT);
1019
1020 /* fprintf(stderr, "FIXME %d %f\n", in_test, Binary[Disk].Rin); */
1021
1022 if (in_test == ON) {
1023 Flags.disk = ON;
1024 #ifdef _WITH_GTK
1025 if (Flags.interactive == ON && Flags.parseCL == OFF )
1026 gtk_toggle_button_set_active
1027 (GTK_TOGGLE_BUTTON (t_disk_button), TRUE);
1028 #endif
1029
1030 continue;
1031 }
1032
1033
1034 in_test = parse_double(InPtr, "outerdiskradius",
1035 &Binary[Disk].Rout,numline,
1036 CHECK_BOTH, LIM_OR_L, LIM_OR_H, ON, NO_FIT);
1037 if (in_test == ON) continue;
1038
1039 in_test = parse_double(InPtr, "disktilt",
1040 &Binary[Disk].Tilt,numline,
1041 CHECK_BOTH, LIM_TI_L, LIM_TI_H, ON, NO_FIT);
1042 if (in_test == ON) continue;
1043
1044 in_test = parse_double(InPtr, "diskwarp",
1045 &Binary[Disk].Warp,numline,
1046 CHECK_BOTH, LIM_WA_L, LIM_WA_H, ON, NO_FIT);
1047 if (in_test == ON) continue;
1048
1049 in_test = parse_double(InPtr, "diskthickness",
1050 &Binary[Disk].Thick,numline,
1051 CHECK_BOTH, LIM_TH_L, LIM_TH_H, ON, NO_FIT);
1052 if (in_test == ON) continue;
1053
1054 in_test = parse_double(InPtr, "diskhoverr",
1055 &Binary[Disk].HR,numline,
1056 CHECK_BOTH, LIM_HR_L, LIM_HR_H, ON, NO_FIT);
1057 if (in_test == ON) continue;
1058
1059 in_test = parse_double(InPtr, "disktemperature",
1060 &Binary[Disk].Temperature,numline,
1061 CHECK_BOTH, LIM_DT_L, LIM_DT_H, ON, NO_FIT);
1062 if (in_test == ON) continue;
1063
1064 in_test = parse_double(InPtr, "hotspottemperature",
1065 &Binary[Disk].tempHS,numline,
1066 CHECK_BOTH, LIM_HST_L, LIM_HST_H, ON, NO_FIT);
1067 if (in_test == ON) continue;
1068
1069 in_test = parse_double(InPtr, "hotspotlongitude",
1070 &Binary[Disk].longitudeHS,numline,
1071 CHECK_BOTH, LIM_HSL_L, LIM_HSL_H, ON, NO_FIT);
1072 if (in_test == ON) continue;
1073
1074 in_test = parse_double(InPtr, "hotspotextent",
1075 &Binary[Disk].extentHS,numline,
1076 CHECK_BOTH, LIM_HSE_L, LIM_HSE_H, ON, NO_FIT);
1077 if (in_test == ON) continue;
1078
1079 in_test = parse_double(InPtr, "hotspotdepth",
1080 &Binary[Disk].depthHS,numline,
1081 CHECK_BOTH, LIM_HSD_L, LIM_HSD_H, ON, NO_FIT);
1082 if (in_test == ON) continue;
1083
1084 in_test = parse_double(InPtr, "hotspotpuff",
1085 &Binary[Disk].puffHS,numline,
1086 CHECK_BOTH, LIM_HSP_L, LIM_HSP_H, ON, NO_FIT);
1087 if (in_test == ON) continue;
1088
1089 in_test = parse_double(InPtr, "warpmaximum",
1090 &Binary[Disk].maxWarp, numline,
1091 CHECK_BOTH, LIM_WPM_L, LIM_WPM_H, ON, NO_FIT);
1092 if (in_test == ON) continue;
1093
1094 in_test = parse_double(InPtr, "warplongitude",
1095 &Binary[Disk].longitudeWarp, numline,
1096 CHECK_BOTH, LIM_WPL_L, LIM_WPL_H, ON, NO_FIT);
1097 if (in_test == ON) continue;
1098
1099 in_test = parse_double(InPtr, "warpwidth",
1100 &Binary[Disk].widthWarp, numline,
1101 CHECK_BOTH, LIM_WPW_L, LIM_WPW_H, ON, NO_FIT);
1102 if (in_test == ON) continue;
1103
1104 in_test = parse_double(InPtr, "warpcentre",
1105 &Binary[Disk].centreWarp, numline,
1106 CHECK_BOTH, LIM_WPC_L, LIM_WPC_H, ON, NO_FIT);
1107 if (in_test == ON) continue;
1108 #endif
1109
1110 /* ----------------- log g ------------------ */
1111
1112 in_test = parse_double(InPtr, "primarylogg",
1113 &Binary[Primary].log_g,numline,
1114 CHECK_BOTH, LIM_LOGG_L, LIM_LOGG_H, OFF, NO_FIT);
1115 if (in_test == ON) {
1116 Binary[Primary].log_g = 0.5 * ROUND(2.0 * Binary[Primary].log_g);
1117 Flags.blackbody = OFF;
1118 #ifdef _WITH_GTK
1119 if (Flags.interactive == ON && Flags.parseCL == OFF )
1120 gtk_toggle_button_set_active
1121 (GTK_TOGGLE_BUTTON (t_bbody_button), FALSE);
1122 #endif
1123 continue;
1124 }
1125
1126 in_test = parse_double(InPtr, "secondarylogg",
1127 &Binary[Secondary].log_g,numline,
1128 CHECK_BOTH, LIM_LOGG_L, LIM_LOGG_H, OFF, NO_FIT);
1129 if (in_test == ON) {
1130 Binary[Secondary].log_g = 0.5 * ROUND(2.0 * Binary[Secondary].log_g);
1131 Flags.blackbody = OFF;
1132 #ifdef _WITH_GTK
1133 if (Flags.interactive == ON && Flags.parseCL == OFF )
1134 gtk_toggle_button_set_active
1135 (GTK_TOGGLE_BUTTON (t_bbody_button), FALSE);
1136 #endif
1137 continue;
1138 }
1139
1140 /* ----------------- eccentric orbit ------------------ */
1141
1142 in_test = parse_double(InPtr, "ellipticorbiteccentricity",
1143 &Orbit.Excentricity,numline,
1144 CHECK_BOTH, LIM_EX_L, LIM_EX_H, OFF, 6);
1145 if (Orbit.Excentricity >= FLT_EPSILON) Flags.elliptic = ON;
1146 if (in_test == ON) {
1147 #ifdef _WITH_GTK
1148 if (Flags.interactive == ON && Flags.parseCL == OFF )
1149 gtk_toggle_button_set_active
1150 (GTK_TOGGLE_BUTTON (t_eccentric_button), TRUE);
1151 #endif
1152 continue;
1153 }
1154
1155 in_test = parse_double(InPtr, "ellipticorbitperiastronlength",
1156 &Orbit.Omega,numline,
1157 CHECK_BOTH, LIM_PA_L, LIM_PA_H, OFF, 7);
1158 if (in_test == ON) continue;
1159
1160 /* ------------- asyncroneous rotation ---------------- */
1161
1162 in_test = parse_double(InPtr, "primaryfratio",
1163 &Binary[Primary].Fratio,numline,
1164 CHECK_BOTH, LIM_FR_L, LIM_FR_H, OFF, 8);
1165 if ( fabs(Binary[Primary].Fratio-1.0) >= FLT_EPSILON)
1166 Flags.asynchron1 = ON;
1167 if (in_test == ON) {
1168 #ifdef _WITH_GTK
1169 if (Flags.interactive == ON && Flags.parseCL == OFF )
1170 gtk_toggle_button_set_active
1171 (GTK_TOGGLE_BUTTON (t_fpri_button), TRUE);
1172 #endif
1173 continue;
1174 }
1175
1176 in_test = parse_double(InPtr, "secondaryfratio",
1177 &Binary[Secondary].Fratio,numline,
1178 CHECK_BOTH, LIM_FR_L, LIM_FR_H, OFF, 9);
1179 if ( fabs(Binary[Secondary].Fratio-1.0) >= FLT_EPSILON)
1180 Flags.asynchron2 = ON;
1181 if (in_test == ON) {
1182 #ifdef _WITH_GTK
1183 if (Flags.interactive == ON && Flags.parseCL == OFF )
1184 gtk_toggle_button_set_active
1185 (GTK_TOGGLE_BUTTON (t_fsec_button), TRUE);
1186 #endif
1187 continue;
1188 }
1189
1190 /* ----------------- absolute values ------------------ */
1191
1192 in_test = parse_double(InPtr, "absolutemass",
1193 &Orbit.TrueMass,numline,
1194 CHECK_LOWER, LIM_MASS_L, 0.0, OFF, 26);
1195 if (in_test == ON) {
1196 Orbit.TrueMass = Orbit.TrueMass * 1.989E30;
1197 continue;
1198 }
1199
1200 in_test = parse_double(InPtr, "absolutedistance",
1201 &Orbit.TrueDistance,numline,
1202 CHECK_LOWER, LIM_DIST_L, 0.0, OFF, 27);
1203 if (in_test == ON) {
1204 Orbit.TrueDistance = Orbit.TrueDistance * SOL_RADIUS;
1205 continue;
1206 }
1207
1208 in_test = parse_double(InPtr, "absoluteperiod",
1209 &Orbit.TruePeriod,numline,
1210 CHECK_LOWER, LIM_PERI_L, 0.0, OFF, NO_FIT);
1211 if (in_test == ON) {
1212 Orbit.TruePeriod = Orbit.TruePeriod * 86400.;
1213 continue;
1214 }
1215
1216
1217 /* ----------------- spots ------------------ */
1218
1219 test = sscanf(InPtr, "%s %s", first, second);
1220
1221 if (strcmp(first, "spotprimary") == 0) {
1222 test = sscanf(in_line, "%s %s %s %s %s %f %f %f %f",
1223 first, second, third, fourth, fifth,
1224 &In1, &In2, &In3, &In4);
1225 if (test == 9) {
1226
1227 if (Flags.Spots1 == 0 ) {
1228 #ifdef _WITH_GTK
1229 if (Flags.interactive == ON && Flags.parseCL == OFF )
1230 gtk_toggle_button_set_active
1231 (GTK_TOGGLE_BUTTON (t_psp1_button), TRUE);
1232 SpotActive[0] = ON;
1233 #endif
1234 Flags.Spots1 = 0;
1235 }
1236
1237 if (Flags.Spots1 == 1 ) {
1238 #ifdef _WITH_GTK
1239 if (Flags.interactive == ON && Flags.parseCL == OFF )
1240 gtk_toggle_button_set_active
1241 (GTK_TOGGLE_BUTTON (t_psp2_button), TRUE);
1242 SpotActive[1] = ON;
1243 #endif
1244 Flags.Spots1 = 1;
1245 }
1246
1247 test = 0;
1248 if (In1 >= LIM_SLO_L && In1 <= LIM_SLO_H) {
1249 Spot[Primary][Flags.Spots1].longitude = In1; ++test;
1250 }
1251 if (In2 >= LIM_SLA_L && In2 <= LIM_SLA_H && test == 1){
1252 Spot[Primary][Flags.Spots1].latitude = In2; ++test;
1253 }
1254 if (In3 >= LIM_SRA_L && In3 <= LIM_SRA_H && test == 2){
1255 Spot[Primary][Flags.Spots1].radius = In3; ++test;
1256 }
1257 if (In4 >= LIM_SDF_L && In4 <= LIM_SDF_H && test == 3){
1258 Spot[Primary][Flags.Spots1].dimfactor = In4; ++test;
1259 }
1260
1261 if (test == 4) {
1262 #ifndef _WITH_GTK
1263 if (strcmp(second, "fit") == 0 && Flags.Spots1 < 2) {
1264 Flags.simplex[10+(Flags.Spots1 * 4) + 0] = ON;
1265 }
1266 if (strcmp(third, "fit") == 0 && Flags.Spots1 < 2) {
1267 Flags.simplex[10+(Flags.Spots1 * 4) + 1] = ON;
1268 }
1269 if (strcmp(fourth, "fit") == 0 && Flags.Spots1 < 2) {
1270 Flags.simplex[10+(Flags.Spots1 * 4) + 2] = ON;
1271 }
1272 if (strcmp(fifth, "fit") == 0 && Flags.Spots1 < 2) {
1273 Flags.simplex[10+(Flags.Spots1 * 4) + 3] = ON;
1274 }
1275 #endif
1276 ++Flags.Spots1;
1277
1278 continue;
1279 } else {
1280 sprintf(msg, _("Range Error in Config File, line %6d\n"),
1281 numline);
1282 WARNING (msg);
1283 }
1284 } else {
1285 sprintf(msg, _("Invalid line %6d in Config File\n"),
1286 numline);
1287 WARNING (msg);
1288 }
1289 continue;
1290 }
1291
1292 /* SECONDARY SPOTS */
1293
1294 test = sscanf(InPtr, "%s %s", first, second);
1295
1296 if (strcmp(first, "spotsecondary") == 0) {
1297 test = sscanf(in_line, "%s %s %s %s %s %f %f %f %f",
1298 first, second, third, fourth, fifth,
1299 &In1, &In2, &In3, &In4);
1300 if (test == 9) {
1301
1302 if (Flags.Spots2 == 0 ) {
1303 #ifdef _WITH_GTK
1304 if (Flags.interactive == ON && Flags.parseCL == OFF )
1305 gtk_toggle_button_set_active
1306 (GTK_TOGGLE_BUTTON (t_ssp1_button), TRUE);
1307 SpotActive[2] = ON;
1308 #endif
1309 Flags.Spots2 = 0;
1310 }
1311
1312 if (Flags.Spots2 == 1 ) {
1313 #ifdef _WITH_GTK
1314 if (Flags.interactive == ON && Flags.parseCL == OFF )
1315 gtk_toggle_button_set_active
1316 (GTK_TOGGLE_BUTTON (t_ssp2_button), TRUE);
1317 SpotActive[3] = ON;
1318 #endif
1319 Flags.Spots2 = 1;
1320 }
1321
1322 test = 0;
1323 if (In1 >= LIM_SLO_L && In1 <= LIM_SLO_H) {
1324 Spot[Secondary][Flags.Spots2].longitude = In1; ++test;
1325 }
1326 if (In2 >= LIM_SLA_L && In2 <= LIM_SLA_H && test == 1){
1327 Spot[Secondary][Flags.Spots2].latitude = In2; ++test;
1328 }
1329 if (In3 >= LIM_SRA_L && In3 <= LIM_SRA_H && test == 2){
1330 Spot[Secondary][Flags.Spots2].radius = In3; ++test;
1331 }
1332 if (In4 >= LIM_SDF_L && In4 <= LIM_SDF_H && test == 3){
1333 Spot[Secondary][Flags.Spots2].dimfactor = In4; ++test;
1334 }
1335 /*
1336 fprintf(stderr, "%6.3f\n", Spot[Secondary][0].longitude);
1337 */
1338
1339 if (test == 4) {
1340 #ifndef _WITH_GTK
1341 if (strcmp(second, "fit") == 0 && Flags.Spots2 < 2) {
1342 Flags.simplex[18+(Flags.Spots2 * 4) + 0] = ON;
1343 }
1344 if (strcmp(third, "fit") == 0 && Flags.Spots2 < 2) {
1345 Flags.simplex[18+(Flags.Spots2 * 4) + 1] = ON;
1346 }
1347 if (strcmp(fourth, "fit") == 0 && Flags.Spots2 < 2) {
1348 Flags.simplex[18+(Flags.Spots2 * 4) + 2] = ON;
1349 }
1350 if (strcmp(fifth, "fit") == 0 && Flags.Spots2 < 2) {
1351 Flags.simplex[18+(Flags.Spots2 * 4) + 3] = ON;
1352 }
1353 #endif
1354
1355
1356 ++Flags.Spots2;
1357 continue;
1358 } else {
1359 sprintf(msg, _("Range Error in Config File, line %6d\n"),
1360 numline);
1361 WARNING (msg);
1362 }
1363 } else {
1364 sprintf(msg, _("Invalid line %6d in Config File\n"),
1365 numline);
1366 WARNING (msg);
1367 }
1368 continue;
1369 }
1370
1371 /* ----------------- third light ------------------ */
1372
1373 in_test = parse_double(InPtr, "thirdlight_u",
1374 &Orbit.Third[Umag],numline,
1375 CHECK_BOTH, LIM_3L_L, LIM_3L_L, OFF, 28);
1376 if (in_test == ON) continue;
1377
1378 in_test = parse_double(InPtr, "thirdlight_b",
1379 &Orbit.Third[Bmag],numline,
1380 CHECK_BOTH, LIM_3L_L, LIM_3L_L, OFF, 29);
1381 if (in_test == ON) continue;
1382
1383 in_test = parse_double(InPtr, "thirdlight_v",
1384 &Orbit.Third[Vmag],numline,
1385 CHECK_BOTH, LIM_3L_L, LIM_3L_L, OFF, 30);
1386 if (in_test == ON) continue;
1387
1388 in_test = parse_double(InPtr, "thirdlight_r",
1389 &Orbit.Third[Rmag],numline,
1390 CHECK_BOTH, LIM_3L_L, LIM_3L_L, OFF, 31);
1391 if (in_test == ON) continue;
1392
1393 in_test = parse_double(InPtr, "thirdlight_i",
1394 &Orbit.Third[Imag],numline,
1395 CHECK_BOTH, LIM_3L_L, LIM_3L_L, OFF, 32);
1396 if (in_test == ON) continue;
1397
1398 in_test = parse_double(InPtr, "thirdlight_j",
1399 &Orbit.Third[Jmag],numline,
1400 CHECK_BOTH, LIM_3L_L, LIM_3L_L, OFF, 33);
1401 if (in_test == ON) continue;
1402
1403 in_test = parse_double(InPtr, "thirdlight_h",
1404 &Orbit.Third[Hmag],numline,
1405 CHECK_BOTH, LIM_3L_L, LIM_3L_L, OFF, 34);
1406 if (in_test == ON) continue;
1407
1408 in_test = parse_double(InPtr, "thirdlight_k",
1409 &Orbit.Third[Kmag],numline,
1410 CHECK_BOTH, LIM_3L_L, LIM_3L_L, OFF, 35);
1411 if (in_test == ON) continue;
1412
1413 in_test = parse_double(InPtr, "thirdlight_str_u",
1414 &Orbit.Third[umag],numline,
1415 CHECK_BOTH, LIM_3L_L, LIM_3L_L, OFF, 36);
1416 if (in_test == ON) continue;
1417
1418 in_test = parse_double(InPtr, "thirdlight_str_v",
1419 &Orbit.Third[umag],numline,
1420 CHECK_BOTH, LIM_3L_L, LIM_3L_L, OFF, 36);
1421 if (in_test == ON) continue;
1422
1423 in_test = parse_double(InPtr, "thirdlight_str_b",
1424 &Orbit.Third[umag],numline,
1425 CHECK_BOTH, LIM_3L_L, LIM_3L_L, OFF, 38);
1426 if (in_test == ON) continue;
1427
1428 in_test = parse_double(InPtr, "thirdlight_str_y",
1429 &Orbit.Third[umag],numline,
1430 CHECK_BOTH, LIM_3L_L, LIM_3L_L, OFF, 39);
1431 if (in_test == ON) continue;
1432
1433
1434 /* ----------------- lightcurve steps ----------------- */
1435
1436 test = sscanf(InPtr, "%s %s", first, second);
1437
1438 if (strcmp(first, "lightcurvesteps") == 0) {
1439 test = sscanf(in_line, "%s %d", first, &Ii1);
1440 if (test == 2) {
1441 if (Ii1 >= 0 && Ii1 < PHASESTEPS) PhaseSteps = Ii1;
1442 else {
1443 sprintf(msg, _("Range Error in Config File, line %6d\n"),
1444 numline);
1445 WARNING (msg);
1446 }
1447 #ifdef _WITH_GTK
1448 if (Flags.interactive == ON && Flags.parseCL == OFF ) {
1449 sprintf(msg, "%8d", PhaseSteps);
1450 gtk_entry_set_text (GTK_ENTRY (e_112), msg);
1451 }
1452 #endif
1453 } else {
1454 sprintf(msg, _("Invalid line %6d in Config File\n"),
1455 numline);
1456 WARNING (msg);
1457 }
1458 }
1459
1460
1461 /* ----------------- do we want a fit ----------------- */
1462
1463 test = sscanf(InPtr, "%s %f", first, &In1);
1464
1465 if (test == 2 && strcmp(first, "do_fit") == 0) {
1466 if ( In1 >= FLT_EPSILON ) {
1467 #ifndef _WITH_GTK
1468 Flags.WantFit = ON;
1469 Flags.SimplexTol = In1;
1470 if (fabs (Flags.SimplexTol - 0.001) <= FLT_EPSILON )
1471 Flags.anneal = ON;
1472 #endif
1473 continue;
1474 } else {
1475 sprintf(msg,
1476 _("Range Error (0.0, INDEF) in Config File, line %6d\n"),
1477 numline);
1478 WARNING (msg);
1479 }
1480 }
1481 }
1482 *numarg = mandatory;
1483
1484 if (Flags.PlotBand == -1) Flags.PlotBand = Vmag;
1485
1486 /* setlocale (LC_NUMERIC, ""); */
1487
1488
1489 #ifdef _WITH_GTK
1490 if (Flags.interactive == ON && Flags.parseCL == OFF ) {
1491 updateplotflagpage3 ();
1492
1493 sprintf(InitString, "%6.3f", Spot[Primary][0].longitude);
1494 gtk_entry_set_text (GTK_ENTRY (e_401), InitString);
1495
1496 sprintf(InitString, "%6.3f", Spot[Primary][0].latitude);
1497 gtk_entry_set_text (GTK_ENTRY (e_402), InitString);
1498
1499 sprintf(InitString, "%6.3f", Spot[Primary][0].radius);
1500 gtk_entry_set_text (GTK_ENTRY (e_403), InitString);
1501
1502 sprintf(InitString, "%6.3f", Spot[Primary][0].dimfactor);
1503 gtk_entry_set_text (GTK_ENTRY (e_404), InitString);
1504
1505 sprintf(InitString, "%6.3f", Spot[Primary][1].longitude);
1506 gtk_entry_set_text (GTK_ENTRY (e_405), InitString);
1507
1508 sprintf(InitString, "%6.3f", Spot[Primary][1].latitude);
1509 gtk_entry_set_text (GTK_ENTRY (e_406), InitString);
1510
1511 sprintf(InitString, "%6.3f", Spot[Primary][1].radius);
1512 gtk_entry_set_text (GTK_ENTRY (e_407), InitString);
1513
1514 sprintf(InitString, "%6.3f", Spot[Primary][1].dimfactor);
1515 gtk_entry_set_text (GTK_ENTRY (e_408), InitString);
1516
1517 if (Flags.edu != ON) {
1518 sprintf(InitString, "%6.3f", Spot[Secondary][0].longitude);
1519 gtk_entry_set_text (GTK_ENTRY (e_409), InitString);
1520
1521 sprintf(InitString, "%6.3f", Spot[Secondary][0].latitude);
1522 gtk_entry_set_text (GTK_ENTRY (e_410), InitString);
1523
1524 sprintf(InitString, "%6.3f", Spot[Secondary][0].radius);
1525 gtk_entry_set_text (GTK_ENTRY (e_411), InitString);
1526
1527 sprintf(InitString, "%6.3f", Spot[Secondary][0].dimfactor);
1528 gtk_entry_set_text (GTK_ENTRY (e_412), InitString);
1529
1530 sprintf(InitString, "%6.3f", Spot[Secondary][1].longitude);
1531 gtk_entry_set_text (GTK_ENTRY (e_413), InitString);
1532
1533 sprintf(InitString, "%6.3f", Spot[Secondary][1].latitude);
1534 gtk_entry_set_text (GTK_ENTRY (e_414), InitString);
1535
1536 sprintf(InitString, "%6.3f", Spot[Secondary][1].radius);
1537 gtk_entry_set_text (GTK_ENTRY (e_415), InitString);
1538
1539 sprintf(InitString, "%6.3f", Spot[Secondary][1].dimfactor);
1540 gtk_entry_set_text (GTK_ENTRY (e_416), InitString);
1541 }
1542 }
1543 #endif
1544
1545 (void) fclose(in_file);
1546
1547 strncpy(Flags.ConfFile, fullPath, 255);
1548 Flags.ConfFile[255] = '\0';
1549
1550
1551 return;
1552 }
1553