-
Notifications
You must be signed in to change notification settings - Fork 2
/
util.f
2111 lines (2040 loc) · 64.6 KB
/
util.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
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
CM
C->>> -------------------------------------------> ems_iz_ems_fi_com <<<
c Initialises the common block of EMS file keywords.
c
subroutine ems_iz_ems_fi_com
implicit none
include 'EMSV.INC'
include 'EMSFI.INC'
ems_fi_cmt_ky_1 = '!'
ems_fi_cmt_ky_2 = '#'
ems_fi_cmt_ky_3 = '*'
ems_fi_mps_ml_nm_ky = 'name'
ems_fi_fmt_ky = 'ems_file_format'
ems_fi_mx_ky = 'maximize'
ems_fi_mn_ky = 'minimize'
ems_fi_n_r_ky = 'n_rows'
ems_fi_n_c_ky = 'n_columns'
ems_fi_n_mtx_el_ky = 'n_matrix_elements'
ems_fi_r_ky = 'rows'
ems_fi_c_ky = 'columns'
ems_fi_mtx_ky = 'matrix'
ems_fi_c_bd_ky = 'column_bounds'
ems_fi_r_bd_ky = 'row_bounds'
ems_fi_c_co_ky = 'column_costs'
ems_fi_nm_ky = 'names'
ems_fi_ob_fn_cs_ky = 'objective_constant'
ems_fi_r_co_ky = 'row_costs'
ems_fi_pwl_ky = 'piecewise_linear'
ems_fi_bs_ky = 'basis'
ems_fi_bs_in_alt_fmt_ky = 'basis_in_alternative_format'
ems_fi_e_lin_ky = 'end_linear'
c
c Indicate that the common block of EMS file keywords has been
c initialised.
c
ems_fi_iz_com_fg1 = 1
ems_fi_iz_com_fg2 = 2
return
end
C->>> --------------------------------------------> ems_rd_ems_fi_ky <<<
c Reads the next non-blank, non-comment line in an EMS file as a
c keyword and puts it into lower case.
c
subroutine ems_rd_ems_fi_ky(ems_fi_rd_cn, ems_fi_ky)
implicit none
include 'EMSV.INC'
include 'EMSFI.INC'
include 'EMSMSG.INC'
integer ems_fi_rd_cn
character*(*) ems_fi_ky
CM IF (emsol_epc .EQ. 1) THEN
C? logical ems_i1_eq_i2
CM ENDIF
c
c Make sure that ems_iz_ems_fi_com has been called
c
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_fi_iz_com_fg1,
C? & ems_fi_iz_com_fg2)) goto 8000
CM ELSE
if (ems_fi_iz_com_fg1 .eq. ems_fi_iz_com_fg2) goto 8000
CM ENDIF
1 continue
read(ems_fi_rd_cn, '(a)', err = 8020, end = 8010)ems_fi_ky
c read(ems_fi_rd_cn, *, err = 8020, end = 8010)ems_fi_ky
if (ems_fi_ky(1:ems_fi_cmt_ky_n_ch) .eq. ems_fi_cmt_ky_1) goto 1
if (ems_fi_ky(1:ems_fi_cmt_ky_n_ch) .eq. ems_fi_cmt_ky_2) goto 1
if (ems_fi_ky(1:ems_fi_cmt_ky_n_ch) .eq. ems_fi_cmt_ky_3) goto 1
call ems_str_t_lo_case(ems_fi_ky)
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9100)ems_fi_ky
call ems_msg_wr_li(info_msg_n)
7000 continue
return
8000 continue
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9800)
call ems_msg_wr_li(serious_msg_n)
goto 7000
8010 continue
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9801)ems_fi_ml_nm
call ems_msg_wr_li(serious_msg_n)
goto 7000
8020 continue
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9802)ems_fi_ml_nm
call ems_msg_wr_li(serious_msg_n)
goto 7000
9100 format('Read EMS file keyword: ', a)
9800 format('Must call ems_iz_ems_fi_com before EMSOL file ops')
9801 format('Premature end of file for model ', a8)
9802 format('Error reading file for model ', a8)
end
C->>> ----------------------------------------> ems_se_msg_my_prcs_n <<<
c Sets the value of ems_msg_my_prcs_n
c
subroutine ems_se_msg_my_prcs_n(ps_my_prcs_n)
implicit none
integer ps_my_prcs_n
include 'EMSMSG.INC'
ems_msg_my_prcs_n = ps_my_prcs_n
return
end
C->>> --------------------------------------------> ems_fi_io_ml_hdr <<<
c Read/writes the header from/to an EMS file.
c
subroutine ems_fi_io_ml_hdr(
& ems_fi_cn, rd_fi, fi_io,
& ch_ml_nm, ch_ob_nm, ch_rhs_nm, ch_rg_nm, ch_bd_nm)
implicit none
include 'EMSV.INC'
include 'EMSFI.INC'
include 'EMSMSG.INC'
integer ems_fi_cn, fi_io
logical rd_fi
character*8 ch_ml_nm, ch_ob_nm, ch_rhs_nm, ch_rg_nm, ch_bd_nm
if (rd_fi) then
c
c ?? '(a8)' to be * once ******** becomes UNNAMED in NwMagic
c
read(ems_fi_cn, '(a8)', err = 8020, end = 8010)ch_ml_nm
read(ems_fi_cn, '(a8)', err = 8020, end = 8010)ch_ob_nm
read(ems_fi_cn, '(a8)', err = 8020, end = 8010)ch_rhs_nm
read(ems_fi_cn, '(a8)', err = 8020, end = 8010)ch_rg_nm
read(ems_fi_cn, '(a8)', err = 8020, end = 8010)ch_bd_nm
ems_fi_ml_nm = ch_ml_nm
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9000)ems_fi_ml_nm
call ems_msg_wr_li(info_msg_n)
else
write(ems_fi_cn, 9100, err = 8030)ch_ml_nm, ': matrix'
write(ems_fi_cn, 9100, err = 8030)ch_ob_nm, ': Objective'
write(ems_fi_cn, 9100, err = 8030)ch_rhs_nm, ': rhs'
write(ems_fi_cn, 9100, err = 8030)ch_rg_nm, ': ranges'
write(ems_fi_cn, 9100, err = 8030)ch_bd_nm, ': bounds'
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9010)ems_fi_ml_nm
call ems_msg_wr_li(info_msg_n)
endif
7000 continue
return
8010 continue
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9801)ems_fi_ml_nm
call ems_msg_wr_li(serious_msg_n)
goto 7000
8020 continue
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9802)ems_fi_ml_nm
call ems_msg_wr_li(serious_msg_n)
goto 7000
8030 continue
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9803)ems_fi_ml_nm
call ems_msg_wr_li(serious_msg_n)
goto 7000
9000 format('Reading model ', a8)
9010 format('Writing model ', a8)
9100 format(a8, a)
9801 format('Premature end of file for model ', a8)
9802 format('Error reading file for model ', a8)
9803 format('Error writing file for model ', a8)
end
C->>> --------------------------------------------> ems_fi_io_ml_dim <<<
c Read/writes the model dimesions from/to an EMS file.
c
subroutine ems_fi_io_ml_dim(
& ems_fi_cn, rd_fi, fi_io, fi_fmt_vers_n,
& rd_nx_ky, ems_fi_ky,
& n_r, n_c, n_a_el)
implicit none
include 'EMSV.INC'
include 'EMSFI.INC'
include 'EMSMSG.INC'
integer ems_fi_cn, fi_io, fi_fmt_vers_n
logical rd_fi
logical rd_nx_ky
character*(*) ems_fi_ky
integer n_r, n_c, n_a_el
if (rd_fi) then
rd_nx_ky = .false.
if (fi_fmt_vers_n .eq. 0) then
read(ems_fi_cn, *, err = 8020, end = 8010)n_r, n_c, n_a_el
else
100 continue
call ems_rd_ems_fi_ky(ems_fi_cn, ems_fi_ky)
if (ems_msg_cod .ge. ems_msg_lvl_serious) goto 7000
if (ems_fi_ky(1:ems_fi_n_r_ky_n_ch) .eq.
& ems_fi_n_r_ky) then
read(ems_fi_cn, *, err = 8020, end = 8010)n_r
goto 100
else if (ems_fi_ky(1:ems_fi_n_c_ky_n_ch) .eq.
& ems_fi_n_c_ky) then
read(ems_fi_cn, *, err = 8020, end = 8010)n_c
goto 100
else if (ems_fi_ky(1:ems_fi_n_mtx_el_ky_n_ch) .eq.
& ems_fi_n_mtx_el_ky) then
read(ems_fi_cn, *, err = 8020, end = 8010)n_a_el
goto 100
endif
rd_nx_ky = .true.
endif
else
write(ems_fi_cn, 9000, err = 8030)ems_fi_n_r_ky
write(ems_fi_cn, *, err = 8030)n_r
write(ems_fi_cn, 9000, err = 8030)ems_fi_n_c_ky
write(ems_fi_cn, *, err = 8030)n_c
write(ems_fi_cn, 9000, err = 8030)ems_fi_n_mtx_el_ky
write(ems_fi_cn, *, err = 8030)n_a_el
endif
7000 continue
return
8010 continue
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9801)ems_fi_ml_nm
call ems_msg_wr_li(serious_msg_n)
goto 7000
8020 continue
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9802)ems_fi_ml_nm
call ems_msg_wr_li(serious_msg_n)
goto 7000
8030 continue
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9803)ems_fi_ml_nm
call ems_msg_wr_li(serious_msg_n)
goto 7000
9000 format(a)
9801 format('Premature end of file for model ', a8)
9802 format('Error reading file for model ', a8)
9803 format('Error writing file for model ', a8)
end
C->>> --------------------------------------------> ems_fi_io_ml_mtx <<<
c Read/write the matrix from/to an EMS file.
c
subroutine ems_fi_io_ml_mtx(
& ems_fi_cn, rd_fi, fi_io,
& n_r, n_c, n_a_el,
& mtx_r_v,
& mtx_r_ix,
& mtx_c_sa)
implicit none
include 'EMSV.INC'
include 'EMSFI.INC'
include 'EMSMSG.INC'
integer ems_fi_cn, fi_io
logical rd_fi
integer n_r, n_c, n_a_el
double precision mtx_r_v(n_a_el)
integer mtx_r_ix(n_a_el)
integer mtx_c_sa(n_c+1)
logical a_rd_e, a_rd_er, a_wr_er
if (rd_fi) then
call ems_rd_fr_fmt_i_a(
& ems_fi_cn, mtx_c_sa, 1, n_c+1, a_rd_er, a_rd_e)
if (a_rd_er) go to 8010
if (a_rd_e) go to 8020
call ems_rd_fr_fmt_i_a(
& ems_fi_cn, mtx_r_ix, 1, n_a_el, a_rd_er, a_rd_e)
if (a_rd_er) go to 8010
if (a_rd_e) go to 8020
call ems_rd_fr_fmt_rl_a(
& ems_fi_cn, mtx_r_v, 1, n_a_el, a_rd_er, a_rd_e)
if (a_rd_er) go to 8010
if (a_rd_e) go to 8020
ems_fi_io_msk = ior(ems_fi_io_mtx_bt, ems_fi_io_msk)
else
write(ems_fi_cn, 9000, err = 8030)ems_fi_mtx_ky
call ems_wr_fr_fmt_i_a(ems_fi_cn, mtx_c_sa, 1, n_c+1, a_wr_er)
if (a_wr_er) goto 8030
call ems_wr_fr_fmt_i_a(ems_fi_cn, mtx_r_ix, 1, n_a_el, a_wr_er)
if (a_wr_er) goto 8030
call ems_wr_fr_fmt_rl_a(ems_fi_cn, mtx_r_v, 1, n_a_el, a_wr_er)
if (a_wr_er) goto 8030
endif
7000 continue
return
8010 continue
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9801)ems_fi_ml_nm
call ems_msg_wr_li(serious_msg_n)
goto 7000
8020 continue
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9802)ems_fi_ml_nm
call ems_msg_wr_li(serious_msg_n)
goto 7000
8030 continue
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9803)ems_fi_ml_nm
call ems_msg_wr_li(serious_msg_n)
goto 7000
9000 format(a)
9801 format('Premature end of file for model ', a8)
9802 format('Error reading file for model ', a8)
9803 format('Error writing file for model ', a8)
end
C->>> ---------------------------------------------> ems_fi_io_ml_bd <<<
c Read/write the bounds from/to an EMS file.
c
subroutine ems_fi_io_ml_bd(
& ems_fi_cn, rd_fi, fi_io,
& n_r, n_c,
& c_lb, r_lb,
& c_ub, r_ub)
implicit none
include 'EMSV.INC'
include 'EMSFI.INC'
include 'EMSMSG.INC'
integer ems_fi_cn, fi_io
logical rd_fi
integer n_r, n_c
double precision c_lb(n_c)
double precision r_lb(n_r)
double precision c_ub(n_c)
double precision r_ub(n_r)
logical a_rd_e, a_rd_er, a_wr_er
if (rd_fi) then
call ems_rd_fr_fmt_rl_a(
& ems_fi_cn, c_lb, 1, n_c, a_rd_er, a_rd_e)
if (a_rd_er) go to 8010
if (a_rd_e) go to 8020
call ems_rd_fr_fmt_rl_a(
& ems_fi_cn, r_lb, 1, n_r, a_rd_er, a_rd_e)
if (a_rd_er) go to 8010
if (a_rd_e) go to 8020
call ems_rd_fr_fmt_rl_a(
& ems_fi_cn, c_ub, 1, n_c, a_rd_er, a_rd_e)
if (a_rd_er) go to 8010
if (a_rd_e) go to 8020
call ems_rd_fr_fmt_rl_a(
& ems_fi_cn, r_ub, 1, n_r, a_rd_er, a_rd_e)
if (a_rd_er) go to 8010
if (a_rd_e) go to 8020
ems_fi_io_msk = ior(ems_fi_io_bd_msk, ems_fi_io_msk)
else
write(ems_fi_cn, 9000, err = 8030)ems_fi_c_bd_ky
call ems_wr_fr_fmt_rl_a(ems_fi_cn, c_lb, 1, n_c, a_wr_er)
if (a_wr_er) goto 8030
call ems_wr_fr_fmt_rl_a(ems_fi_cn, c_ub, 1, n_c, a_wr_er)
if (a_wr_er) goto 8030
write(ems_fi_cn, 9000, err = 8030)ems_fi_r_bd_ky
call ems_wr_fr_fmt_rl_a(ems_fi_cn, r_lb, 1, n_r, a_wr_er)
if (a_wr_er) goto 8030
call ems_wr_fr_fmt_rl_a(ems_fi_cn, r_ub, 1, n_r, a_wr_er)
if (a_wr_er) goto 8030
endif
7000 continue
return
8010 continue
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9801)ems_fi_ml_nm
call ems_msg_wr_li(serious_msg_n)
goto 7000
8020 continue
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9802)ems_fi_ml_nm
call ems_msg_wr_li(serious_msg_n)
goto 7000
8030 continue
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9803)ems_fi_ml_nm
call ems_msg_wr_li(serious_msg_n)
goto 7000
9000 format(a)
9801 format('Premature end of file for model ', a8)
9802 format('Error reading file for model ', a8)
9803 format('Error writing file for model ', a8)
end
C->>> -------------------------------------------> ems_fi_io_ml_r_bd <<<
c Read/write the row bounds from/to an EMS file.
c
subroutine ems_fi_io_ml_r_bd(
& ems_fi_cn, rd_fi, fi_io,
& n_r,
& r_lb, r_ub)
implicit none
include 'EMSV.INC'
include 'EMSFI.INC'
include 'EMSMSG.INC'
integer ems_fi_cn, fi_io
logical rd_fi
integer n_r
double precision r_lb(n_r)
double precision r_ub(n_r)
logical a_rd_e, a_rd_er, a_wr_er
if (rd_fi) then
call ems_rd_fr_fmt_rl_a(
& ems_fi_cn, r_lb, 1, n_r, a_rd_er, a_rd_e)
if (a_rd_er) go to 8010
if (a_rd_e) go to 8020
call ems_rd_fr_fmt_rl_a(
& ems_fi_cn, r_ub, 1, n_r, a_rd_er, a_rd_e)
if (a_rd_er) go to 8010
if (a_rd_e) go to 8020
ems_fi_io_msk = ior(ems_fi_io_r_bd_msk, ems_fi_io_msk)
else
write(ems_fi_cn, 9000, err = 8030)ems_fi_r_bd_ky
call ems_wr_fr_fmt_rl_a(ems_fi_cn, r_lb, 1, n_r, a_wr_er)
if (a_wr_er) goto 8030
call ems_wr_fr_fmt_rl_a(ems_fi_cn, r_ub, 1, n_r, a_wr_er)
if (a_wr_er) goto 8030
endif
7000 continue
return
8010 continue
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9801)ems_fi_ml_nm
call ems_msg_wr_li(serious_msg_n)
goto 7000
8020 continue
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9802)ems_fi_ml_nm
call ems_msg_wr_li(serious_msg_n)
goto 7000
8030 continue
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9803)ems_fi_ml_nm
call ems_msg_wr_li(serious_msg_n)
goto 7000
9000 format(a)
9801 format('Premature end of file for model ', a8)
9802 format('Error reading file for model ', a8)
9803 format('Error writing file for model ', a8)
end
C->>> -------------------------------------------> ems_fi_io_ml_c_bd <<<
c Read/write the column bounds from/to an EMS file.
c
subroutine ems_fi_io_ml_c_bd(
& ems_fi_cn, rd_fi, fi_io,
& n_c,
& c_lb, c_ub)
implicit none
include 'EMSV.INC'
include 'EMSFI.INC'
include 'EMSMSG.INC'
integer ems_fi_cn, fi_io
logical rd_fi
integer n_c
double precision c_lb(n_c)
double precision c_ub(n_c)
logical a_rd_e, a_rd_er, a_wr_er
if (rd_fi) then
call ems_rd_fr_fmt_rl_a(
& ems_fi_cn, c_lb, 1, n_c, a_rd_er, a_rd_e)
if (a_rd_er) go to 8010
if (a_rd_e) go to 8020
call ems_rd_fr_fmt_rl_a(
& ems_fi_cn, c_ub, 1, n_c, a_rd_er, a_rd_e)
if (a_rd_er) go to 8010
if (a_rd_e) go to 8020
ems_fi_io_msk = ior(ems_fi_io_c_bd_msk, ems_fi_io_msk)
else
write(ems_fi_cn, 9000, err = 8030)ems_fi_c_bd_ky
call ems_wr_fr_fmt_rl_a(ems_fi_cn, c_lb, 1, n_c, a_wr_er)
if (a_wr_er) goto 8030
call ems_wr_fr_fmt_rl_a(ems_fi_cn, c_ub, 1, n_c, a_wr_er)
if (a_wr_er) goto 8030
endif
7000 continue
return
8010 continue
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9801)ems_fi_ml_nm
call ems_msg_wr_li(serious_msg_n)
goto 7000
8020 continue
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9802)ems_fi_ml_nm
call ems_msg_wr_li(serious_msg_n)
goto 7000
8030 continue
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9803)ems_fi_ml_nm
call ems_msg_wr_li(serious_msg_n)
goto 7000
9000 format(a)
9801 format('Premature end of file for model ', a8)
9802 format('Error reading file for model ', a8)
9803 format('Error writing file for model ', a8)
end
C->>> -------------------------------------------> ems_fi_io_ml_c_co <<<
c Read/write the column costs from/to an EMS file.
c
subroutine ems_fi_io_ml_c_co(
& ems_fi_cn, rd_fi, fi_io,
& n_c,
& c_co)
implicit none
include 'EMSV.INC'
include 'EMSFI.INC'
include 'EMSMSG.INC'
integer ems_fi_cn, fi_io
logical rd_fi
integer n_c
double precision c_co(n_c)
logical a_rd_e, a_rd_er, a_wr_er
if (rd_fi) then
call ems_rd_fr_fmt_rl_a(
& ems_fi_cn, c_co, 1, n_c, a_rd_er, a_rd_e)
if (a_rd_er) go to 8010
if (a_rd_e) go to 8020
ems_fi_io_msk = ior(ems_fi_io_c_co_bt, ems_fi_io_msk)
else
write(ems_fi_cn, 9000, err = 8030)ems_fi_c_co_ky
call ems_wr_fr_fmt_rl_a(ems_fi_cn, c_co, 1, n_c, a_wr_er)
if (a_wr_er) goto 8030
endif
7000 continue
return
8010 continue
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9801)ems_fi_ml_nm
call ems_msg_wr_li(serious_msg_n)
goto 7000
8020 continue
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9802)ems_fi_ml_nm
call ems_msg_wr_li(serious_msg_n)
goto 7000
8030 continue
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9803)ems_fi_ml_nm
call ems_msg_wr_li(serious_msg_n)
goto 7000
9000 format(a)
9801 format('Premature end of file for model ', a8)
9802 format('Error reading file for model ', a8)
9803 format('Error writing file for model ', a8)
end
C->>> ---------------------------------------------> ems_fi_io_ml_nm <<<
c Read/write new-style names from/to an EMS file.
c
subroutine ems_fi_io_ml_nm(
& rd_nx_ky, ems_fi_ky,
& ems_fi_cn, rd_fi, fi_io,
& n_r, n_c,
& ml_nm_n_ch, ml_nm_n_rl,
& mu_ch, rl_c_nm, rl_r_nm)
implicit none
include 'EMSV.INC'
include 'EMSFI.INC'
include 'EMSMSG.INC'
logical rd_nx_ky
character*(*) ems_fi_ky
integer ems_fi_cn, fi_io
logical rd_fi
character*(*) mu_ch
integer n_r, n_c, ml_nm_n_ch, ml_nm_n_rl
double precision rl_c_nm(ml_nm_n_rl, n_c)
double precision rl_r_nm(ml_nm_n_rl, n_r)
integer r_n, c_n, null
character*14 f7_rd_nm_fmt
character*8 ch8
double precision rl
equivalence (rl, ch8)
c
c Names are of length ml_nm_n_ch with each line being of format
c i9, 2x, a<ml_nm_n_ch>. The names are in sections: one for rows and
c one for columns, each headed by a keyword
c
if (rd_fi) then
c write(f7_rd_nm_fmt, '(a10, i3, a1)')
c & '(i9, 2x, a', ml_nm_n_ch, ')'
f7_rd_nm_fmt = '(i9, 2x, a)'
c print*, 'Reading names using format:', f7_rd_nm_fmt
rd_nx_ky = .false.
100 continue
call ems_rd_ems_fi_ky(ems_fi_cn, ems_fi_ky)
if (ems_msg_cod .ge. ems_msg_lvl_serious) goto 7000
if (ems_fi_ky(1:ems_fi_r_ky_n_ch) .eq. ems_fi_r_ky) then
do 160, r_n = 1, n_r
read(ems_fi_cn, f7_rd_nm_fmt, err = 8020, end = 8010)
& null, mu_ch(1:ml_nm_n_ch)
call ems_ch_t_rl(ml_nm_n_ch, mu_ch, rl_r_nm(1, r_n))
160 continue
ems_fi_io_msk = ior(ems_fi_io_r_nm_bt, ems_fi_io_msk)
goto 100
else if (ems_fi_ky(1:ems_fi_c_ky_n_ch) .eq. ems_fi_c_ky) then
do 170, c_n = 1, n_c
read(ems_fi_cn, f7_rd_nm_fmt, err = 8020, end = 8010)
& null, mu_ch(1:ml_nm_n_ch)
call ems_ch_t_rl(ml_nm_n_ch, mu_ch, rl_c_nm(1, c_n))
170 continue
ems_fi_io_msk = ior(ems_fi_io_c_nm_bt, ems_fi_io_msk)
goto 100
endif
rd_nx_ky = .true.
else
if (ml_nm_n_ch .ne. 8) call ems_iz_ch(mu_ch, ' ')
write(ems_fi_cn, 9000, err = 8030)ems_fi_nm_ky
write(ems_fi_cn, *, err = 8030)ml_nm_n_ch
write(ems_fi_cn, 9000, err = 8030)ems_fi_c_ky
do 120, c_n = 1, n_c
if (ml_nm_n_ch .eq. 8) then
rl = rl_c_nm(1, c_n)
write(ems_fi_cn, 9200)c_n, ch8
else
call ems_rl_t_ch(ml_nm_n_ch, rl_c_nm(1, c_n), mu_ch)
write(ems_fi_cn, 9200)c_n, mu_ch(1:ml_nm_n_ch)
endif
120 continue
write(ems_fi_cn, 9000, err = 8030)ems_fi_r_ky
do 125, r_n = 1, n_r
if (ml_nm_n_ch .eq. 8) then
rl = rl_r_nm(1, r_n)
write(ems_fi_cn, 9200)r_n, ch8
else
call ems_rl_t_ch(ml_nm_n_ch, rl_r_nm(1, r_n), mu_ch)
write(ems_fi_cn, 9200)r_n, mu_ch(1:ml_nm_n_ch)
endif
125 continue
endif
7000 continue
return
8010 continue
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9801)ems_fi_ml_nm
call ems_msg_wr_li(serious_msg_n)
goto 7000
8020 continue
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9802)ems_fi_ml_nm
call ems_msg_wr_li(serious_msg_n)
goto 7000
8030 continue
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9803)ems_fi_ml_nm
call ems_msg_wr_li(serious_msg_n)
goto 7000
9000 format(a)
9200 format(i9, 2x, a)
9801 format('Premature end of file for model ', a8)
9802 format('Error reading file for model ', a8)
9803 format('Error writing file for model ', a8)
end
C->>> -----------------------------------------> ems_fi_io_ml_nm_ol <<<
c Read old-style names from/to an EMS file.
c
subroutine ems_fi_io_ml_nm_ol(
& ems_fi_cn, rd_fi, fi_io,
& n_r, n_c,
& rl_c_nm, rl_r_nm)
implicit none
include 'EMSV.INC'
include 'EMSFI.INC'
include 'EMSMSG.INC'
integer ems_fi_cn, fi_io
logical rd_fi
integer n_r, n_c
double precision rl_c_nm(n_c)
double precision rl_r_nm(n_r)
integer r_n, c_n
character*8 ch8
double precision rl
equivalence (rl, ch8)
c
c Names are of length 8 with each line being of format a8
c
do 10, c_n = 1, n_c
read(ems_fi_cn, *, err = 8020, end = 8010)ch8
rl_c_nm(c_n) = rl
10 continue
do 20, r_n = 1, n_r
read(ems_fi_cn, *, err = 8020, end = 8010)ch8
rl_r_nm(r_n) = rl
20 continue
ems_fi_io_msk = ior(ems_fi_io_nm_msk, ems_fi_io_msk)
7000 continue
return
8010 continue
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9801)ems_fi_ml_nm
call ems_msg_wr_li(serious_msg_n)
goto 7000
8020 continue
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9802)ems_fi_ml_nm
call ems_msg_wr_li(serious_msg_n)
goto 7000
c 8030 continue
c if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9803)ems_fi_ml_nm
c call ems_msg_wr_li(serious_msg_n)
c goto 7000
9801 format('Premature end of file for model ', a8)
9802 format('Error reading file for model ', a8)
c 9803 format('Error writing file for model ', a8)
end
C->>> --------------------------------------> ems_fi_io_ml_ob_fn_cs <<<
c Read/write the objective function constant from/to an EMS file.
c
subroutine ems_fi_io_ml_ob_fn_cs(
& ems_fi_cn, rd_fi, fi_io,
& ob_fn_cs)
implicit none
include 'EMSV.INC'
include 'EMSFI.INC'
include 'EMSMSG.INC'
integer ems_fi_cn, fi_io
logical rd_fi
double precision ob_fn_cs
double precision rl_v
if (rd_fi) then
read(ems_fi_cn, *, err = 8020, end = 8010)rl_v
ob_fn_cs = rl_v
else
write(ems_fi_cn, 9000, err = 8030)ems_fi_ob_fn_cs_ky
write(ems_fi_cn, *, err = 8030)ob_fn_cs
endif
7000 continue
return
8010 continue
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9801)ems_fi_ml_nm
call ems_msg_wr_li(serious_msg_n)
goto 7000
8020 continue
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9802)ems_fi_ml_nm
call ems_msg_wr_li(serious_msg_n)
goto 7000
8030 continue
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9803)ems_fi_ml_nm
call ems_msg_wr_li(serious_msg_n)
goto 7000
9000 format(a)
9801 format('Premature end of file for model ', a8)
9802 format('Error reading file for model ', a8)
9803 format('Error writing file for model ', a8)
end
C->>> ------------------------------------------> ems_fi_io_ml_r_co <<<
c Read row costs from/to an EMS file.
c
subroutine ems_fi_io_ml_r_co(
& ems_fi_cn, rd_fi, fi_io,
& n_r,
& r_co)
implicit none
include 'EMSV.INC'
include 'EMSFI.INC'
include 'EMSMSG.INC'
integer ems_fi_cn, fi_io
logical rd_fi
integer n_r
double precision r_co(n_r)
logical a_rd_e, a_rd_er, a_wr_er
if (rd_fi) then
call ems_rd_fr_fmt_rl_a(
& ems_fi_cn, r_co, 1, n_r, a_rd_er, a_rd_e)
if (a_rd_er) go to 8010
if (a_rd_e) go to 8020
ems_fi_io_msk = ior(ems_fi_io_r_co_bt, ems_fi_io_msk)
else
write(ems_fi_cn, 9000, err = 8030)ems_fi_r_co_ky
call ems_wr_fr_fmt_rl_a(ems_fi_cn, r_co, 1, n_r, a_wr_er)
if (a_wr_er) goto 8030
endif
7000 continue
return
8010 continue
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9801)ems_fi_ml_nm
call ems_msg_wr_li(serious_msg_n)
goto 7000
8020 continue
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9802)ems_fi_ml_nm
call ems_msg_wr_li(serious_msg_n)
goto 7000
8030 continue
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9803)ems_fi_ml_nm
call ems_msg_wr_li(serious_msg_n)
goto 7000
9000 format(a)
9801 format('Premature end of file for model ', a8)
9802 format('Error reading file for model ', a8)
9803 format('Error writing file for model ', a8)
end
C->>> --------------------------------------------> ems_fi_io_ml_bs <<<
c Read a basis from/to an EMS file.
c
subroutine ems_fi_io_ml_bs(
& ems_fi_cn, rd_fi, fi_io,
& n_r, n_c,
& c_st, r_st,
& c_pr_act, r_pr_act,
& scl_pr_act, c_scl, r_scl)
implicit none
include 'EMSV.INC'
include 'EMSFI.INC'
include 'EMSMSG.INC'
integer ems_fi_cn, fi_io
logical rd_fi
integer n_r, n_c
integer c_st(n_c)
integer r_st(n_r)
double precision c_pr_act(n_c)
double precision r_pr_act(n_r)
logical scl_pr_act
double precision c_scl(n_c)
double precision r_scl(n_r)
integer r_n, c_n
double precision pr_act_v
if (rd_fi) then
if (scl_pr_act) then
do 10, c_n = 1, n_c
read(ems_fi_cn, *, err = 8020, end = 8010)
& c_st(c_n), pr_act_v
c_pr_act(c_n) = pr_act_v*c_scl(c_n)
10 continue
do 20, r_n = 1, n_r
read(ems_fi_cn, *, err = 8020, end = 8010)
& r_st(r_n), pr_act_v
r_pr_act(r_n) = pr_act_v*r_scl(r_n)
20 continue
else
do 30, c_n = 1, n_c
read(ems_fi_cn, *, err = 8020, end = 8010)
& c_st(c_n), c_pr_act(c_n)
30 continue
do 40, r_n = 1, n_r
read(ems_fi_cn, *, err = 8020, end = 8010)
& r_st(r_n), r_pr_act(r_n)
40 continue
endif
ems_fi_io_msk = ior(ems_fi_io_bs_bt, ems_fi_io_msk)
else
write(ems_fi_cn, 9000, err = 8030)ems_fi_bs_ky
if (scl_pr_act) then
do 110, c_n = 1, n_c
pr_act_v = c_pr_act(c_n)/c_scl(c_n)
write(ems_fi_cn, *, err = 8030)c_st(c_n), pr_act_v
110 continue
do 120, r_n = 1, n_r
pr_act_v = r_pr_act(r_n)/r_scl(r_n)
write(ems_fi_cn, *, err = 8030)r_st(r_n), pr_act_v
120 continue
else
do 130, c_n = 1, n_c
write(ems_fi_cn, *, err = 8030)c_st(c_n), c_pr_act(c_n)
130 continue
do 140, r_n = 1, n_r
write(ems_fi_cn, *, err = 8030)r_st(r_n), r_pr_act(r_n)
140 continue
endif
endif
7000 continue
return
8010 continue
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9801)ems_fi_ml_nm
call ems_msg_wr_li(serious_msg_n)
goto 7000
8020 continue
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9802)ems_fi_ml_nm
call ems_msg_wr_li(serious_msg_n)
goto 7000
8030 continue
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9803)ems_fi_ml_nm
call ems_msg_wr_li(serious_msg_n)
goto 7000
9000 format(a)
9801 format('Premature end of file for model ', a8)
9802 format('Error reading file for model ', a8)
9803 format('Error writing file for model ', a8)
end
C->>> ---------------------------------> ems_fi_io_ml_bs_in_alt_fmt <<<
c Read/write a basis in alternative format from/to an EMS file.
c
subroutine ems_fi_io_ml_bs_in_alt_fmt(
& ems_fi_cn, rd_fi, fi_io,
& n_r, n_c,
& c_lb, r_lb,
& c_ub, r_ub,
& c_st, r_st,
& c_pr_act, r_pr_act,
& su_vr_bs_bt, bc_vr_bs_st, non_bc_vr_bs_st)
implicit none
include 'EMSV.INC'
include 'EMSFI.INC'
include 'EMSMSG.INC'
integer ems_fi_cn, fi_io
logical rd_fi
integer n_r, n_c
integer c_st(n_c)
integer r_st(n_r)
double precision c_lb(n_c)
double precision r_lb(n_r)
double precision c_ub(n_c)
double precision r_ub(n_r)
double precision c_pr_act(n_c)
double precision r_pr_act(n_r)
integer su_vr_bs_bt, bc_vr_bs_st, non_bc_vr_bs_st
integer r_n, c_n, rd_st
c integer n_vr_in_r, n_vr_in_c
if (rd_fi) then
c n_vr_in_r = 0
c n_vr_in_c = 0
do 10, c_n = 1, n_c
read(ems_fi_cn, *, err = 8020, end = 8010)rd_st
if (rd_st .gt. 0) then
c n_vr_in_r = n_vr_in_r + 1
c_st(c_n) = c_st(c_n) -
& iand(c_st(c_n), su_vr_bs_bt) +
& bc_vr_bs_st
else
c n_vr_in_c = n_vr_in_c + 1
c_st(c_n) = c_st(c_n) -
& iand(c_st(c_n), su_vr_bs_bt) +
& non_bc_vr_bs_st
if (rd_st .eq. 0) then
c_pr_act(c_n) = c_lb(c_n)
else
c_pr_act(c_n) = c_ub(c_n)
endif
endif
10 continue
c print*, ' After Structurals'
c print*, ' n_vr_in_r ', n_vr_in_r
c print*, ' n_vr_in_c ', n_vr_in_c
do 20, r_n = 1, n_r
read(ems_fi_cn, *, err = 8020, end = 8010)rd_st
if (rd_st .gt. 0) then
c n_vr_in_r = n_vr_in_r + 1
r_st(r_n) = r_st(r_n) -
& iand(r_st(r_n), su_vr_bs_bt) +
& bc_vr_bs_st
else
c n_vr_in_c = n_vr_in_c + 1
r_st(r_n) = r_st(r_n) -
& iand(r_st(r_n), su_vr_bs_bt) +
& non_bc_vr_bs_st
if (rd_st .eq. 0) then
r_pr_act(r_n) = r_lb(r_n)
else
r_pr_act(r_n) = r_ub(r_n)
endif
endif
20 continue
c print*, ' Finally'
c print*, ' n_vr_in_r, n_r ', n_vr_in_r, n_r
c print*, ' n_vr_in_c, n_c ', n_vr_in_c, n_c
ems_fi_io_msk = ior(ems_fi_io_bs_in_alt_fmt_bt, ems_fi_io_msk)
endif
7000 continue
return
8010 continue
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9801)ems_fi_ml_nm
call ems_msg_wr_li(serious_msg_n)
goto 7000
8020 continue
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9802)ems_fi_ml_nm
call ems_msg_wr_li(serious_msg_n)
goto 7000
c 8030 continue
c if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9803)ems_fi_ml_nm
c call ems_msg_wr_li(serious_msg_n)
c goto 7000
9801 format('Premature end of file for model ', a8)
9802 format('Error reading file for model ', a8)
c 9803 format('Error writing file for model ', a8)
end
C->>> ------------------------------------------------> ems_ck_ml_bd <<<
c Checks that that the bounds/costs are consistent and there is a
c feasible value in [-tl_mx_act, tl_mx_act].
c
subroutine ems_ck_ml_bd(n_r, n_c,
& r_lbc, r_ubc,
& c_lbc, c_ubc,
& tl_mx_act)
implicit none
include 'EMSMSG.INC'
integer n_r, n_c
double precision r_lbc(n_r), c_lbc(n_c)
double precision r_ubc(n_r), c_ubc(n_c)
double precision tl_mx_act
integer r_n, c_n
do 10, r_n = 1, n_r
if (r_lbc(r_n) .gt. r_ubc(r_n)) goto 8100
if (r_lbc(r_n) .gt. tl_mx_act) goto 8110
if (r_ubc(r_n) .lt. -tl_mx_act) goto 8120
10 continue
do 20, c_n = 1, n_c
if (c_lbc(c_n) .gt. c_ubc(c_n)) goto 8200
if (c_lbc(c_n) .gt. tl_mx_act) goto 8210
if (c_ubc(c_n) .lt. -tl_mx_act) goto 8220
20 continue
7000 continue
return
8100 continue
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9810)
& r_n, r_lbc(r_n), r_ubc(r_n)
call ems_msg_wr_li(serious_msg_n)
goto 7000
8110 continue
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9811)
& r_n, r_lbc(r_n), tl_mx_act
call ems_msg_wr_li(serious_msg_n)
goto 7000
8120 continue
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9812)
& r_n, r_ubc(r_n), -tl_mx_act
call ems_msg_wr_li(serious_msg_n)