-
Notifications
You must be signed in to change notification settings - Fork 2
/
ems_msg.f
343 lines (331 loc) · 10.9 KB
/
ems_msg.f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
CM
C->>> -----------------------------------------------> ems_msg_wr_li <<<
subroutine ems_msg_wr_li(usr_msg_n)
implicit none
include 'EMSV.INC'
include 'EMSVERS.INC'
include 'EMSMSG.INC'
include 'EMSMSGN.INC'
integer usr_msg_n
CM IF (emsol_epc .EQ. 1) THEN
C? logical ems_i1_eq_i2
CM ENDIF
character*4 ch4_msg_n
integer ems_ln_t_l_ch
integer ln_t_l_ch, p0, p1, msg_n, sa
integer parlp_li_sa_ln, li_sa_ln
parameter (
& parlp_li_sa_ln = 13,
& li_sa_ln = 10)
character*(li_sa_ln) li_sa
character*(parlp_li_sa_ln) parlp_li_sa
character*80 msg_6_li
logical no_prcs_n, wr_cn0
character*13 ch13_vers
integer ch13_vers_ln
CM IF (emsol_epc .EQ. 1) THEN
C?c
C?c Have to use a function compiled without unassigned variable
C?c checking in order to test values which may be unassigned.
C?c
C? if (ems_i1_eq_i2(ems_msg_iz_ct_vr_com_fg1,
C? & ems_msg_iz_ct_vr_com_fg2))
CM ELSE
if (ems_msg_iz_ct_vr_com_fg1 .eq. ems_msg_iz_ct_vr_com_fg2)
CM ENDIF
& call ems_msg_iz_ct_vr_com
msg_n = usr_msg_n
no_prcs_n = ems_msg_my_prcs_n .lt. 0
wr_cn0 =
& ems_msg_wr_cn .ne. ems_msg_er_cn .and.
& ems_msg_wr_cn .ne. 6 .and.
& msg_n .ge. bs_warn_msg_n
if (ems_msg_no_prt_fm .le. 0 .or.
& (msg_n .ge. ems_msg_no_prt_fm .and.
& msg_n .le. ems_msg_no_prt_t)) then
c
c If printing has been switched off still maintain the return code.
c
if (msg_n .ge. bs_serious_msg_n) then
ems_msg_cod = ems_msg_lvl_serious
else if (msg_n .ge. bs_er_msg_n) then
ems_msg_cod = max(ems_msg_lvl_er, ems_msg_cod)
else if (msg_n .ge. bs_warn_msg_n) then
ems_msg_cod = max(ems_msg_lvl_warn, ems_msg_cod)
else if (msg_n .ge. bs_info_msg_n) then
ems_msg_cod = max(ems_msg_lvl_info, ems_msg_cod)
endif
goto 7000
endif
if (.not. no_prcs_n) write(parlp_li_sa, 9800)ems_msg_my_prcs_n
10 continue
if (ems_msg_pg_n .eq. 0 .and. msg_n .ne. 6) then
ems_msg_pg_n = 1
ems_msg_pg_li_n = 1
if (ems_msg_rp_msg_n .eq. 1) li_sa = '1'//li_prefix//'0006I '
call ems_msg_g_ch13_vers(ch13_vers, ch13_vers_ln)
write(msg_6_li, 9100)package, ch13_vers(1:ch13_vers_ln),
& ems_msg_pg_n
ln_t_l_ch = ems_ln_t_l_ch(msg_6_li)
if (no_prcs_n) then
p0 = 1
p1 = min(ln_t_l_ch, ems_msg_wr_li_ln-li_sa_ln)
if (ems_msg_rp_msg_n .eq. 1) then
write(ems_msg_wr_cn, 9000)li_sa, msg_6_li(p0:p1)
else
write(ems_msg_wr_cn, 9001)msg_6_li(p0:p1)
endif
else
p0 = 1
p1 = min(ln_t_l_ch,
& ems_msg_wr_li_ln-li_sa_ln-parlp_li_sa_ln)
if (ems_msg_rp_msg_n .eq. 1) then
write(ems_msg_wr_cn, 9810)parlp_li_sa, li_sa,
& msg_6_li(p0:p1)
else
write(ems_msg_wr_cn, 9811)parlp_li_sa, msg_6_li(p0:p1)
endif
endif
100 continue
if (p1 .ge. ln_t_l_ch) goto 200
ems_msg_pg_li_n = ems_msg_pg_li_n + 1
p0 = p1 + 1
p1 = min(ln_t_l_ch, p1+ems_msg_wr_li_ln)
if (no_prcs_n) then
write(ems_msg_wr_cn, 9001)msg_6_li(p0:p1)
else
write(ems_msg_wr_cn, 9811)parlp_li_sa, msg_6_li(p0:p1)
endif
goto 100
endif
200 continue
call ems_wr_i_t_ch(msg_n, ch4_msg_n, sa, '0')
if (msg_n .eq. 6) then
ems_msg_pg_n = ems_msg_pg_n + 1
ems_msg_pg_li_n = 1
if (ems_msg_rp_msg_n .eq. 1) li_sa = '1'//li_prefix//ch4_msg_n
if (ems_msg_no_prt_fm .ge. 1) then
call ems_msg_g_ch13_vers(ch13_vers, ch13_vers_ln)
write(ems_li, 9100)
& package, ch13_vers(1:ch13_vers_ln), ems_msg_pg_n
endif
else
ems_msg_pg_li_n = ems_msg_pg_li_n + 1
if (ems_msg_rp_msg_n .eq. 1) li_sa = ' '//li_prefix//ch4_msg_n
endif
ln_t_l_ch = ems_ln_t_l_ch(ems_li)
if (msg_n .lt. 0 .or. msg_n .gt. 9999) then
if (ems_msg_rp_msg_n .eq. 1) then
write(ems_msg_wr_cn, 9990)li_prefix, msg_n
else
write(ems_msg_wr_cn, 9991)msg_n
endif
ems_msg_cod = ems_msg_lvl_serious
goto 2000
endif
if (msg_n .ge. bs_serious_msg_n) then
li_sa(li_sa_ln-1:li_sa_ln) = 'S '
ems_msg_cod = ems_msg_lvl_serious
else if (msg_n .ge. bs_er_msg_n) then
li_sa(li_sa_ln-1:li_sa_ln) = 'E '
ems_msg_cod = max(ems_msg_lvl_er, ems_msg_cod)
else if (msg_n .ge. bs_warn_msg_n) then
li_sa(li_sa_ln-1:li_sa_ln) = 'W '
ems_msg_cod = max(ems_msg_lvl_warn, ems_msg_cod)
else
li_sa(li_sa_ln-1:li_sa_ln) = 'I '
ems_msg_cod = max(ems_msg_lvl_info, ems_msg_cod)
endif
p0 = 1
if (no_prcs_n) then
p1 = min(ln_t_l_ch, ems_msg_wr_li_ln-li_sa_ln)
if (p1 .gt. 0) then
if (ems_msg_rp_msg_n .eq. 1) then
write(ems_msg_wr_cn, 9000)li_sa, ems_li(p0:p1)
if (wr_cn0) write(ems_msg_er_cn, 9000)
& li_sa, ems_li(p0:p1)
else
write(ems_msg_wr_cn, 9001)ems_li(p0:p1)
if (wr_cn0) write(ems_msg_er_cn, 9001)ems_li(p0:p1)
endif
else
if (ems_msg_rp_msg_n .eq. 1) then
write(ems_msg_wr_cn, 9000)li_sa
if (wr_cn0) write(ems_msg_er_cn, 9000)li_sa
else
write(ems_msg_wr_cn, 9001)
if (wr_cn0) write(ems_msg_er_cn, 9001)
endif
endif
else
p1 = min(ln_t_l_ch, ems_msg_wr_li_ln-li_sa_ln-parlp_li_sa_ln)
if (p1 .gt. 0) then
if (ems_msg_rp_msg_n .eq. 1) then
write(ems_msg_wr_cn, 9810)parlp_li_sa, li_sa,
& ems_li(p0:p1)
if (wr_cn0) write(ems_msg_er_cn, 9810)parlp_li_sa,
& li_sa, ems_li(p0:p1)
else
write(ems_msg_wr_cn, 9811)parlp_li_sa, ems_li(p0:p1)
if (wr_cn0)
& write(ems_msg_er_cn, 9811)parlp_li_sa, ems_li(p0:p1)
endif
else
if (ems_msg_rp_msg_n .eq. 1) then
write(ems_msg_wr_cn, 9810)parlp_li_sa, li_sa
if (wr_cn0) write(ems_msg_er_cn, 9810)parlp_li_sa, li_sa
else
write(ems_msg_wr_cn, 9811)parlp_li_sa
if (wr_cn0) write(ems_msg_er_cn, 9811)parlp_li_sa
endif
endif
endif
1000 continue
if (p1 .ge. ln_t_l_ch) goto 2000
ems_msg_pg_li_n = ems_msg_pg_li_n + 1
p0 = p1 + 1
p1 = min(ln_t_l_ch, p1+ems_msg_wr_li_ln)
if (no_prcs_n) then
write(ems_msg_wr_cn, 9001)ems_li(p0:p1)
if (wr_cn0) write(ems_msg_er_cn, 9001)ems_li(p0:p1)
else
write(ems_msg_wr_cn, 9811)parlp_li_sa, ems_li(p0:p1)
if (wr_cn0) write(ems_msg_er_cn, 9811)
& parlp_li_sa, ems_li(p0:p1)
endif
goto 1000
2000 continue
if (ems_msg_pg_li_n .ge. ems_msg_n_pg_li) then
msg_n = 6
go to 10
endif
7000 continue
return
9000 format(a10, a)
9001 format(a)
9100 format(a50, ': Version ', a, ' Page', i5)
9800 format('Process ', i3, ': ')
9810 format(a13, a10, a)
9811 format(a13, a)
9990 format(1x, a4, '9999S Unidentified message id ', i9)
9991 format(' Unidentified message id ', i9)
end
subroutine ems_msg_g_ch13_vers(ch13_vers, ch13_vers_ln)
implicit none
include 'EMSVERS.INC'
character*13 ch13_vers
integer ch13_vers_ln
integer p
p = 1
write(ch13_vers(p:p), 9001)mjor_vers_n
p = p + 1
ch13_vers(p:p) = '.'
p = p + 1
if (mnor_vers_n .le. 9) then
write(ch13_vers(p:p), 9001)mnor_vers_n
p = p + 1
else
write(ch13_vers(p:p+1), 9002)mnor_vers_n
p = p + 2
endif
ch13_vers(p:p) = '.'
p = p + 1
if (mjor_rv_n .le. 9) then
write(ch13_vers(p:p), 9001)mjor_rv_n
p = p + 1
else
write(ch13_vers(p:p+1), 9002)mjor_rv_n
p = p + 2
endif
if (mnor_rv_n .gt. 0) then
ch13_vers(p:p) = '.'
p = p + 1
write(ch13_vers(p:p), 9001)mnor_rv_n
p = p + 1
endif
ch13_vers_ln = p-1
return
9001 format(i1)
9002 format(i2)
end
C->>> ------------------------------------------> ems_msg_wr_li_t_cn <<<
subroutine ems_msg_wr_li_t_cn(rt_cod, wr_cn)
implicit none
include 'EMSMSG.INC'
integer rt_cod, wr_cn
integer ems_ln_t_l_ch
integer ln_t_l_ch
integer rt_cod_serious_f7_wr_er
parameter (rt_cod_serious_f7_wr_er = ems_msg_lvl_serious)
rt_cod = 0
if (wr_cn .lt. 0) goto 7100
ln_t_l_ch = ems_ln_t_l_ch(ems_li)
if (ln_t_l_ch .lt. 1) goto 7100
write(wr_cn, 9000, err=8990)ems_li(1:ln_t_l_ch)
7100 continue
return
9000 format(a)
8990 continue
rt_cod = max(rt_cod_serious_f7_wr_er, rt_cod)
goto 7100
end
C->>> ----------------------------------------> ems_msg_iz_ct_vr_com <<<
subroutine ems_msg_iz_ct_vr_com
implicit none
include 'EMSMSG.INC'
CM IF (emsol_epc .EQ. 1) THEN
C? call ems_debug_se_i_a_undn(ems_msg_ct_vr, 1, n_ems_msg_ct_vr)
CM ENDIF
ems_msg_iz_ct_vr_com_fg1 = 1
ems_msg_iz_ct_vr_com_fg2 = 2
ems_msg_cod = 0
ems_msg_wr_cn = 6
ems_msg_er_cn = 0
ems_msg_no_prt_fm = 10000
ems_msg_no_prt_t = 0
ems_msg_rp_msg_n = 1
ems_msg_wr_li_ln = 80
ems_msg_n_pg_li = 55
ems_msg_my_prcs_n = -1
ems_msg_pg_n = 0
ems_msg_pg_li_n = 0
return
end
C->>> -----------------------------------------------> ems_wr_i_t_ch <<<
c Writes an integer to a character variable: right justified and
c with leading entries filled with ch1_bf_f_dgt. The entry of the
c first digit (or sign if negative) is also returned. If the integer
c requires a larger field then only the right-most entries are
c written.
c
subroutine ems_wr_i_t_ch(i, ch, sa, ch1_bf_f_dgt)
implicit none
character*(*) ch
integer i, sa
character*1 ch1_bf_f_dgt
integer ch_ln, ichar0
integer te_i, dgt
integer p
ch_ln = len(ch)
p = ch_ln
te_i = iabs(i)
ichar0 = ichar('0')
10 continue
dgt = te_i - 10*(te_i/10)
ch(p:p) = char(ichar0+dgt)
te_i = te_i/10
if (te_i .eq. 0) then
if (i .lt. 0 .and. p .gt. 1) then
p = p - 1
ch(p:p) = '-'
endif
sa = p
do 20, p = 1, sa-1
ch(p:p) = ch1_bf_f_dgt
20 continue
else
p = p - 1
if (p .ge. 1) goto 10
endif
return
end