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