cloudy
trunk
Main Page
Related Pages
Data Structures
Files
File List
Globals
All
Data Structures
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
source
prt.cpp
Go to the documentation of this file.
1
/* This file is part of Cloudy and is copyright (C)1978-2008 by Gary J. Ferland and
2
* others. For conditions of distribution and use see copyright notice in license.txt */
3
/*prt_LineLabels punch all labels and wavelengths for emission line array */
4
/*sprt_wl write wavelength to string - must be kept parallel with prt_wl */
5
/*prt_wl - print floating wavelength in Angstroms, in output format */
6
#include "
cddefines.h
"
7
#include "
lines.h
"
8
#include "
prt.h
"
9
10
/*prt_wl print floating wavelength in Angstroms, in output format */
11
void
prt_wl
( FILE *ioOUT ,
realnum
wl
)
12
{
13
char
chString[100];
14
DEBUG_ENTRY
(
"prt_wl()"
);
15
16
sprt_wl
( chString , wl );
17
18
fprintf(ioOUT,
"%s"
, chString );
19
return
;
20
}
21
22
/* write wavelength to string */
23
void
sprt_wl
(
char
*chString ,
realnum
wl
)
24
{
25
char
chUnits[10];
26
27
DEBUG_ENTRY
(
"sprt_wl()"
);
28
29
/* print in A unless > 1e4, then use microns */
30
if
( wl > 1e8 )
31
{
32
/* centimeters */
33
strcpy( chUnits ,
"c"
);
34
wl /= 1e8;
35
}
36
else
if
( wl > 1e4 )
37
{
38
/* microns */
39
strcpy( chUnits ,
"m"
);
40
wl /= 1e4;
41
}
42
else
if
( wl == 0. )
43
{
44
strcpy( chUnits ,
" "
);
45
}
46
else
47
{
48
/* Angstroms units */
49
strcpy( chUnits ,
"A"
);
50
}
51
52
/* want total of four sig figs */
53
if
(
LineSave
.
sig_figs
== 4 )
54
{
55
if
( wl==0. )
56
{
57
sprintf(chString,
"%5i"
, 0 );
58
}
59
else
if
( wl<10. )
60
{
61
sprintf(chString,
"%5.3f"
, wl );
62
}
63
else
if
( wl<100. )
64
{
65
sprintf(chString,
"%5.2f"
, wl );
66
}
67
else
if
( wl < 1e3 )
68
{
69
sprintf(chString,
"%5.1f"
, wl );
70
}
71
else
if
( wl < 1e4 )
72
{
73
sprintf(chString,
"%5.0f"
, wl );
74
}
75
else
if
( wl < 1e5 )
76
{
77
sprintf(chString,
"%5i"
, (
int
)wl );
78
}
79
else
80
{
81
TotalInsanity
();
82
}
83
}
84
else
if
(
LineSave
.
sig_figs
== 5 )
85
{
86
/* this branch five sig figs */
87
if
( wl==0. )
88
{
89
sprintf(chString,
"%5i"
, 0 );
90
}
91
else
if
( wl<10. )
92
{
93
sprintf(chString,
"%5.4f"
, wl );
94
}
95
else
if
( wl<100. )
96
{
97
sprintf(chString,
"%5.3f"
, wl );
98
}
99
else
if
( wl < 1e3 )
100
{
101
sprintf(chString,
"%5.2f"
, wl );
102
}
103
else
if
( wl < 1e4 )
104
{
105
sprintf(chString,
"%5.1f"
, wl );
106
}
107
else
if
( wl < 1e5 )
108
{
109
sprintf(chString,
"%5.0f"
, wl );
110
}
111
else
if
( wl < 1e6 )
112
{
113
sprintf(chString,
"%5i"
, (
int
)wl );
114
}
115
else
116
{
117
TotalInsanity
();
118
}
119
}
120
else
121
{
122
ASSERT
(
LineSave
.
sig_figs
== 6 );
123
/* this branch five sig figs */
124
if
( wl==0. )
125
{
126
sprintf(chString,
"%6i"
, 0 );
127
}
128
else
if
( wl<10. )
129
{
130
sprintf(chString,
"%6.5f"
, wl );
131
}
132
else
if
( wl<100. )
133
{
134
sprintf(chString,
"%6.4f"
, wl );
135
}
136
else
if
( wl < 1e3 )
137
{
138
sprintf(chString,
"%6.3f"
, wl );
139
}
140
else
if
( wl < 1e4 )
141
{
142
sprintf(chString,
"%6.2f"
, wl );
143
}
144
else
if
( wl < 1e5 )
145
{
146
sprintf(chString,
"%6.1f"
, wl );
147
}
148
else
if
( wl < 1e6 )
149
{
150
sprintf(chString,
"%6.0f"
, wl );
151
}
152
else
if
( wl < 1e7 )
153
{
154
sprintf(chString,
"%6i"
, (
int
)wl );
155
}
156
else
157
{
158
TotalInsanity
();
159
}
160
}
161
strcat( chString , chUnits );
162
return
;
163
}
164
165
/*prt_LineLabels punch all labels and wavelengths for emission line array */
166
void
prt_LineLabels
(
167
/* io file handle */
168
FILE * ioOUT ,
169
/* print all if true, if false then do not print parts of
170
* transferred lines */
171
bool
lgPrintAll )
172
{
173
long
int
i;
174
175
DEBUG_ENTRY
(
"prt_LineLabels()"
);
176
177
for
( i=0; i <
LineSave
.
nsum
; i++ )
178
{
179
if
( strcmp(
LineSv
[i].chALab ,
"####"
)==0 )
180
{
181
/*fprintf( ioOUT, "%s ", LineSv[i].chALab );*/
182
fprintf( ioOUT,
"####\t%s"
,
LineSave
.
chHoldComments
[(
int
)
LineSv
[i].
wavelength
] );
183
}
184
else
185
{
186
if
( !lgPrintAll &&
187
(strcmp(
LineSv
[i].chALab ,
"Inwd"
)==0 ||
188
strcmp(
LineSv
[i].chALab ,
"Coll"
)==0 ||
189
strcmp(
LineSv
[i].chALab ,
"Pump"
)==0 ||
190
strcmp(
LineSv
[i].chALab ,
"Heat"
)==0)
191
)
192
/* option to do not print lots of redundant labels
193
* lgPrintAll is false by default set true with LONG option
194
* on punch line labels command */
195
continue
;
196
/* this format chosen to be identical to that used by final */
197
fprintf( ioOUT,
"%li\t%s\t"
,
198
i,
199
LineSv
[i].chALab );
200
/* wavelength as given in printout */
201
prt_wl
( ioOUT,
LineSv
[i].
wavelength
);
202
/* skip over leading spaces - a formatting problem */
203
long
int
j = 0;
204
while
(
LineSv
[i].chComment[j]!=
'\0'
&&
LineSv
[i].chComment[j]==
' '
)
205
++j;
206
/* comment entered when line intensity generated */
207
fprintf( ioOUT ,
"\t%s"
, &
LineSv
[i].chComment[j] );
208
}
209
fprintf( ioOUT,
"\n"
);
210
}
211
return
;
212
}
Generated for cloudy by
1.8.4