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 implicit none
285
286
287 integer(I4B), intent(in) :: n
288 integer(I4B), intent(in) :: nja
289 integer(I4B), dimension(n + 1), intent(in) :: ia
290 integer(I4B), dimension(nja), intent(in) :: ja
291 integer(I4B), intent(in) :: mmax
292 integer(I4B), dimension(mmax), intent(inout) :: v
293 integer(I4B), dimension(mmax), intent(inout) :: l
294 integer(I4B), dimension(n), intent(inout) :: head
295 integer(I4B), dimension(n), intent(inout) :: last
296 integer(I4B), dimension(n), intent(inout) :: next
297 integer(I4B), dimension(n), intent(inout) :: mark
298 integer(I4B), intent(inout) :: flag
299
300
301 integer(I4B) :: tag
302 integer(I4B) :: dmin
303 integer(I4B), pointer :: vk
304 integer(I4B), pointer :: ek
305 integer(I4B) :: tail
306 integer(I4B) :: k
307
308 allocate (vk)
309 ek => vk
310
311
312 tag = 0
313 call ims_mdi(n, nja, ia, ja, mmax, v, l, head, last, next, &
314 mark, tag, flag)
315 if (flag .ne. 0) return
316
317 k = 0
318 dmin = 1
319
320
3211 if (k >= n) go to 4
322
323
3242 if (head(dmin) > 0) go to 3
325 dmin = dmin + 1
326 go to 2
327
328
3293 vk = head(dmin)
330 head(dmin) = next(vk)
331 if (head(dmin) > 0) last(head(dmin)) = -dmin
332
333
334 k = k + 1
335 next(vk) = -k
336 last(ek) = dmin - 1
337 tag = tag + last(ek)
338 mark(vk) = tag
339
340
341 call ims_mdm(n, mmax, vk, tail, v, l, last, next, mark)
342
343
344 call ims_mdp(n, mmax, k, ek, tail, v, l, head, last, next, mark)
345
346
347 call ims_mdu(n, mmax, ek, dmin, v, l, head, last, next, mark)
348
349 go to 1
350
351
3524 do k = 1, n
353 next(k) = -next(k)
354 last(next(k)) = k
355 end do
356
357 deallocate (vk)
358
359 return