-
Notifications
You must be signed in to change notification settings - Fork 2
/
ssx1.f
3728 lines (3673 loc) · 123 KB
/
ssx1.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_revn <<<
c Returns the version number.
c
CM IF (emsol_epc .EQ. 1) THEN
C? subroutine ems_tru_revn(
CM ELSE
subroutine ems_revn(
CM ENDIF
& rt_cod, ems_rv_n)
implicit none
include 'EMSV.INC'
include 'EMSMSG.INC'
include 'EMSVERS.INC'
integer rt_cod, ems_rv_n
CM IF (emsol_epc .EQ. 1) THEN
C? logical ems_i1_eq_i2
CM ENDIF
integer rn_nm_n_ch
parameter (rn_nm_n_ch = 8)
character*(rn_nm_n_ch) rn_nm
save rn_nm
data rn_nm/'ems_revn'/
ems_msg_cod = 0
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
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9000)
& rn_nm(1:rn_nm_n_ch)
call ems_msg_wr_li(50)
ems_rv_n = ((mjor_vers_n*256+mnor_vers_n)*256 +
& mjor_rv_n)*256 + mnor_rv_n
rt_cod = ems_msg_cod
return
9000 format(31x, 'Entering EMSOL subroutine ', a)
end
C->>> ----------------------------------------------------> ems_mset <<<
c Change message control settings. Since this routine only changes
c common message control settings and does not change dspace, it
c does not call ems_init.
c
CM IF (emsol_epc .EQ. 1) THEN
C? subroutine ems_tru_mset(
CM ELSE
subroutine ems_mset(
CM ENDIF
& rt_cod, is, sa_n, mx_alw, mx_prt, trace,
& usr_xit, e_n, no_n)
implicit none
include 'EMSV.INC'
include 'EMSMSG.INC'
integer rt_cod, is(0:*), sa_n, mx_alw, mx_prt, trace
integer usr_xit, e_n, no_n
CM IF (emsol_epc .EQ. 1) THEN
C? logical ems_i1_eq_i2
CM ENDIF
integer rn_nm_n_ch
parameter (rn_nm_n_ch = 8)
character*(rn_nm_n_ch) rn_nm
save rn_nm
data rn_nm/'ems_mset'/
ems_msg_cod = 0
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
c if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9000)
c rn_nm(1:rn_nm_n_ch)
c call ems_msg_wr_li(50)
if (sa_n .lt. 0 .or. sa_n .gt. 9999) goto 8101
if (mx_alw .lt. 0 .or. mx_alw .gt. 0) goto 8102
if (mx_prt .ge. 0 .and. mx_prt .le. 255) goto 8103
if (trace .lt. 0 .or. trace .gt. 0) goto 8104
if (usr_xit .lt. 0 .or. usr_xit .gt. 0) goto 8105
if (e_n .lt. 1 .or. e_n .gt. 9999) goto 8106
if (mx_prt .lt. 0) then
ems_msg_no_prt_fm = sa_n
ems_msg_no_prt_t = e_n
else
ems_msg_no_prt_fm = 10000
ems_msg_no_prt_t = 0
endif
if (no_n .eq. 1) then
ems_msg_rp_msg_n = 0
else if (no_n .eq. 2) then
ems_msg_rp_msg_n = 1
endif
7000 continue
rt_cod = ems_msg_cod
return
8101 continue
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9810)
& rn_nm(1:rn_nm_n_ch),
& sa_n, 3, 0, 9999
call ems_msg_wr_li(7000)
go to 7000
8102 continue
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9810)
& rn_nm(1:rn_nm_n_ch),
& mx_alw, 4, 0, 0
call ems_msg_wr_li(7000)
go to 7000
8103 continue
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9811)
& rn_nm(1:rn_nm_n_ch),
& mx_prt, 5, 0, 255
call ems_msg_wr_li(serious_msg_n)
go to 7000
8104 continue
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9810)
& rn_nm(1:rn_nm_n_ch),
& trace, 6, 0, 0
call ems_msg_wr_li(7000)
go to 7000
8105 continue
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9810)
& rn_nm(1:rn_nm_n_ch),
& usr_xit, 7, 0, 0
call ems_msg_wr_li(7000)
go to 7000
8106 continue
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9810)
& rn_nm(1:rn_nm_n_ch),
& e_n, 8, 1, 9999
call ems_msg_wr_li(7000)
go to 7000
c 9000 format(31x, 'Entering EMSOL subroutine ', a)
9810 format(a, ' has been called with value of ', i9,
& ' for parameter ', i1, '. The valid range is ', i9,
& ' to ', i9)
9811 format(a, ' has been called with value of ', i9,
& ' for parameter ', i1,
& '. This parameter must be less than ', i9,
& ' or greater than ', i9)
end
C->>> ----------------------------------------------------> ems_init <<<
c Initialises EMSOL and sets integer, real and character control
c variables to their default value. This routine is called by the
c first call to an EMSOL routine (except for ems_mset). It must be
c called before a second call to dsca for a particular application.
c It can be called at any time but all information in ds and the
c current control variable settings are lost.
c
CM IF (emsol_epc .EQ. 1) THEN
C? subroutine ems_tru_init(
CM ELSE
subroutine ems_init(
CM ENDIF
& rt_cod, is)
implicit none
include 'EMSV.INC'
include 'EMSPM.INC'
include 'EMSMMGR.INC'
include 'EMSMEM.INC'
include 'ICTVR.INC'
include 'RLCTVR.INC'
include 'EMSMSG.INC'
integer rt_cod, is(0:*)
CM IF (emsol_epc .EQ. 1) THEN
C? logical ems_i1_ne_i2
CM ENDIF
integer is_n
save is_n
integer rn_nm_n_ch
parameter (rn_nm_n_ch = 8)
character*(rn_nm_n_ch) rn_nm
save rn_nm
data rn_nm/'ems_init'/
data is_n/0/
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_ne_i2(
C? & is(ix_cu_ca_ems_rn_fg1),
C? & is(ix_cu_ca_ems_rn_fg2)))
CM ELSE
if (is(ix_cu_ca_ems_rn_fg1) .ne. is(ix_cu_ca_ems_rn_fg2))
CM ENDIF
& goto 8990
is(ix_cu_ca_ems_rn_fg1) = 1
is(ix_cu_ca_ems_rn_fg2) = 2
ems_msg_cod = 0
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9000)
& rn_nm(1:rn_nm_n_ch)
call ems_msg_wr_li(50)
c
c Report the macro settings
c
call ems_rp_mac
c
c Augment the index of is declared. This is will have index is_n + 1
c even if it has been to ems_init before.
c
is_n = is_n + 1
is(ix_is_n) = is_n
is(ix_ca_dsca) = 0
c
c Initialise the values and ranges of the integer control variables.
c
call ems_iz_i_ct_vr_df
call ems_cp_i_a1(n_ems_i_ct_vr, i_ct_vr_df, i_ct_vr)
call ems_se_i_ct_vr_rg
c
c Initialise the values and ranges of the real control variables.
c
call ems_iz_rl_ct_vr_df
call ems_cp_rl_a1(n_ems_rl_ct_vr, rl_ct_vr_df, rl_ct_vr)
call ems_se_rl_ct_vr_rg
c
c Initialise the character control variables.
c
call ems_iz_ch_ct_vr
c
c Initialise the names of control variables
c
call ems_iz_ems_ct_vr_nm
call ems_iz_osl_ct_vr_nm
cu_is_n = is(ix_is_n)
sv_ml_ct_vr = 1
rt_cod = ems_msg_cod
c
c Indicate that ems_init has been called with this is(*)
c
is(ix_ca_init_fg1) = 1
is(ix_ca_init_fg2) = 2
7000 continue
is(ix_cu_ca_ems_rn_fg1) = 0
is(ix_cu_ca_ems_rn_fg2) = 0
return
8990 continue
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9999)
& rn_nm(1:rn_nm_n_ch)
call ems_msg_wr_li(serious_msg_n)
goto 7000
9000 format(31x, 'Entering EMSOL subroutine ', a)
9999 format(a, ' cannot be called from a user exit routine')
end
C->>> ---------------------------------------------------> ems_memrq <<<
c Returns lower bound, estimate and upper bound on the memory
c requirement in order to solve a single problem with usr_n_r rows,
c usr_n_c columns and usr_n_a_el constraint matrix entries
c NB Assumes that operations given by op_msk will be performed.
c
CM IF (emsol_epc .EQ. 1) THEN
C? subroutine ems_tru_memrq(
CM ELSE
subroutine ems_memrq(
CM ENDIF
& rt_cod, is,
& usr_n_ml, usr_n_r, usr_n_c, usr_n_a_el, op_msk,
& rq_mem_lb, rq_mem_est, rq_mem_ub)
implicit none
include 'EMSV.INC'
include 'EMSMSG.INC'
include 'EMSMMGR.INC'
include 'EMSMEM.INC'
integer rt_cod, is(0:*)
integer usr_n_ml, usr_n_r, usr_n_c, usr_n_a_el, op_msk
integer rq_mem_lb, rq_mem_est, rq_mem_ub
CM IF (emsol_epc .EQ. 1) THEN
C? logical ems_i1_eq_i2
C? logical ems_i1_ne_i2
CM ENDIF
integer rn_nm_n_ch
parameter (rn_nm_n_ch = 9)
character*(rn_nm_n_ch) rn_nm
save rn_nm
data rn_nm/'ems_memrq'/
ems_msg_cod = 0
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
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9000)
& rn_nm(1:rn_nm_n_ch)
call ems_msg_wr_li(50)
if (usr_n_ml .le. 0) go to 8101
if (usr_n_r .le. 0) go to 8102
if (usr_n_c .le. 0) go to 8103
if (usr_n_a_el .le. 0) go to 8104
if (op_msk .lt. 0) go to 8105
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(is(ix_ca_init_fg1), is(ix_ca_init_fg2))) then
CM ELSE
if (is(ix_ca_init_fg1) .eq. is(ix_ca_init_fg2)) then
CM ENDIF
c
c If ems_init has not been called then, if ems_memrq has been called
c from within an EMS routine (ie from a user exit
c routine) return an error. This should not happen anyway!
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_ne_i2(
C? & is(ix_cu_ca_ems_rn_fg1),
C? & is(ix_cu_ca_ems_rn_fg2)))
CM ELSE
if (is(ix_cu_ca_ems_rn_fg1) .ne. is(ix_cu_ca_ems_rn_fg2))
CM ENDIF
& goto 8990
c
c Otherwise, call ems_init now.
c
call ems_init(ems_msg_cod, is)
if (ems_msg_cod .ge. ems_msg_lvl_serious) goto 7000
endif
call ems_g_mem_rq(usr_n_ml, usr_n_r, usr_n_c, usr_n_a_el, op_msk,
& rq_mem_lb, rq_mem_est, rq_mem_ub)
7000 continue
rt_cod = ems_msg_cod
return
8101 continue
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9810)
& rn_nm(1:rn_nm_n_ch),
& usr_n_ml, 3, 1, i_inf
call ems_msg_wr_li(7029)
go to 7000
8102 continue
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9810)
& rn_nm(1:rn_nm_n_ch),
& usr_n_r, 4, 1, i_inf
call ems_msg_wr_li(7029)
go to 7000
8103 continue
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9810)
& rn_nm(1:rn_nm_n_ch),
& usr_n_c, 5, 1, i_inf
call ems_msg_wr_li(7029)
go to 7000
8104 continue
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9810)
& rn_nm(1:rn_nm_n_ch),
& usr_n_a_el, 6, 1, i_inf
call ems_msg_wr_li(7029)
go to 7000
8105 continue
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9810)
& rn_nm(1:rn_nm_n_ch),
& op_msk, 7, 1, i_inf
call ems_msg_wr_li(7029)
go to 7000
8990 continue
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9999)
& rn_nm(1:rn_nm_n_ch)
call ems_msg_wr_li(serious_msg_n)
goto 7000
9000 format(31x, 'Entering EMSOL subroutine ', a)
9810 format(a, ' has been called with value of ', i9,
& ' for parameter ', i1, '. The valid range is ', i9,
& ' to ', i9)
9999 format(a, ' cannot be called from a user exit routine')
end
C->>> ----------------------------------------------------> ems_dsca <<<
c Allocates space and initialises the memory manager for a
c particular application. If information for the current model needs
c to be saved and the application has changed, nothing
c can be done and the current model will be corrupted.
c
CM IF (emsol_epc .EQ. 1) THEN
C? subroutine ems_tru_dsca(
CM ELSE
subroutine ems_dsca(
CM ENDIF
& rt_cod, is, n_rl_wo, n_ml)
implicit none
include 'EMSV.INC'
include 'EMSPM.INC'
include 'EMSMMGR.INC'
include 'EMSMEM.INC'
include 'EMSP.INC'
include 'RSMIHDL.INC'
include 'ICTVR.INC'
include 'EMSMSG.INC'
integer rt_cod, is(0:*), n_rl_wo, n_ml
integer mn_blk_p, sos_rt_cod
CM IF (emsol_epc .EQ. 1) THEN
C? logical ems_i1_ne_i2, ems_i1_eq_i2
CM ENDIF
integer ml_n, fg_n
integer mem_mgr_rt_cod
integer rn_nm_n_ch
parameter (rn_nm_n_ch = 8)
character*(rn_nm_n_ch) rn_nm
save rn_nm
data rn_nm/'ems_dsca'/
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_ne_i2(
C? & is(ix_cu_ca_ems_rn_fg1),
C? & is(ix_cu_ca_ems_rn_fg2)))
CM ELSE
if (is(ix_cu_ca_ems_rn_fg1) .ne. is(ix_cu_ca_ems_rn_fg2))
CM ENDIF
& goto 8990
is(ix_cu_ca_ems_rn_fg1) = 1
is(ix_cu_ca_ems_rn_fg2) = 2
ems_msg_cod = 0
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9000)
& rn_nm(1:rn_nm_n_ch)
call ems_msg_wr_li(50)
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(is(ix_ca_init_fg1), is(ix_ca_init_fg2))) then
CM ELSE
if (is(ix_ca_init_fg1) .eq. is(ix_ca_init_fg2)) then
CM ENDIF
c
c Switch off the `call EMSOL routine' flag during the call to
c ems_init
c
is(ix_cu_ca_ems_rn_fg1) = 0
is(ix_cu_ca_ems_rn_fg2) = 0
call ems_init(ems_msg_cod, is)
is(ix_cu_ca_ems_rn_fg1) = 1
is(ix_cu_ca_ems_rn_fg2) = 2
if (ems_msg_cod .ge. ems_msg_lvl_serious) goto 7000
endif
if (is(ix_ca_dsca) .ne. 0) then
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9010)
call ems_msg_wr_li(3037)
go to 7000
endif
if (n_ml .lt. 1) go to 8101
if (is(ix_is_n) .ne. cu_is_n) then
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9100)
& is(ix_is_n), cu_is_n
call ems_msg_wr_li(info_msg_n)
endif
if (sv_ml_ct_vr .gt. 0) then
if (is(ix_is_n) .ne. cu_is_n) then
c
c Application has changed so current model cannot be saved.
c
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9700)
& cu_ml_n, cu_is_n
call ems_msg_wr_li(er_msg_n)
endif
endif
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9200)is(ix_is_n), n_ml
call ems_msg_wr_li(81)
c
c Entries is(0:mem_mgr_da_l_is_en) are used by the memory manager.
c Subsequent entries are used as follows
c
c is(ix_ca_init_fg1) is set to 1 when init has been called.
c
c is(ix_ca_init_fg2) is set to 2 when init has been called.
c . This mechanism allows equal unassigned patterns to indicate
c . that init has not been called.
c
c is(ix_is_n) is the `is' number.
c . This is used to tell which `is' is being passed.
c
c is(ix_ca_dsca) is set to 1 when dsca has been called.
c
c is(ix_n_ml) is the number of models in the application.
c
c is(ix_ca_dscm) is set to 1 when dscm has been called.
c
c is(ix_cu_ca_ems_rn_fg1) is set to 1 when an EMS routine has been
c . called but has not yet returned.
c
c is(ix_cu_ca_ems_rn_fg2) is set to 2 when an EMS routine has been
c . called but has not yet returned.
c . This mechanism is used to spot illegal calls to EMS routines
c . from user exit routines.
c
c is(p_is_bs_blk+os), os = 0, is_bs_blk_n_wo-1
c . is the base block of the application. This contains the
c . default control variable settings for the application.
c
c is(p_ml_bs_blk+os), os = 0, n_ml*ml_bs_blk_n_wo-1
c . contains the base blocks of the models. These contain
c
c . two flags to indicate whether dscm and ptmi have been called
c . for the model
c
c . control variable settings for the models
c
c . the handles to the model storage.
c
c
c ?? Update ems_se_com_undn
c
CM IF (emsol_epc .EQ. 1) THEN
C? call ems_se_com_undn
CM ENDIF
is(ix_n_ml) = n_ml
cu_is_n = is(ix_is_n)
ds_n_en_m1 = n_rl_wo-1
is_n_en_m1 = n_rl_wo*rl_wo_z/i_wo_z-1
ns_n_en_m1 = n_rl_wo*rl_wo_z/ch_wo_z-1
c
c Initialise the memory manager so that entries 0...mn_blk_p-1 are
c not touched by block management.
c
mn_blk_p = p_ml_bs_blk + n_ml*ml_bs_blk_n_wo
if (mn_blk_p .gt. n_rl_wo*rl_wo_z) goto 8000
call ems_mem_mgr_int_iz(mem_mgr_rt_cod, is,
& n_rl_wo*rl_wo_z, mn_blk_p)
if (mem_mgr_rt_cod .ne. mem_mgr_rt_cod_ok) then
if (mem_mgr_rt_cod .eq. mem_mgr_rt_cod_serious_no_po) then
ems_msg_cod = ems_msg_lvl_serious
go to 7000
else if (mem_mgr_rt_cod .ge. mem_mgr_rt_lvl_serious) then
ems_msg_cod = ems_msg_lvl_serious
go to 7000
endif
endif
call ems_dn_ems_blk_id(is)
c
c Indicate that there are no blocks with arrays of solver data and
c that the data in the solver arrays are not correct.
c
rsmi_blk_ml_n = 0
rsmi_blk_st_msk = 0
c
c Initialise the maximum dimensions for solver arrays.
c
rsmi_blk_mx_n_r = 0
rsmi_blk_mx_n_c = 0
c
c ?? Is ems_iz_sos needed?
c
call ems_iz_sos(is, is, sos_rt_cod)
sv_ml_ct_vr = 1
is(ix_ca_dsca) = 1
is(ix_ca_dscm) = 0
c
c Initialise the flags for each model. Currently there are two
c which indicate whether dscm and ptmi have been called.
c
do 10, ml_n = 1, n_ml
do 5, fg_n = 0, ml_bs_blk_n_fg-1
is(p_ml_bs_blk + (ml_n-1)*ml_bs_blk_n_wo + fg_n) = 0
5 continue
10 continue
7000 continue
is(ix_cu_ca_ems_rn_fg1) = 0
is(ix_cu_ca_ems_rn_fg2) = 0
rt_cod = ems_msg_cod
return
8000 continue
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9800)n_rl_wo,
& mn_blk_p/rl_wo_z+2
call ems_msg_wr_li(serious_msg_n)
goto 7000
8101 continue
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9810)
& rn_nm(1:rn_nm_n_ch),
& n_ml, 4, 1, i_inf
call ems_msg_wr_li(7029)
go to 7000
8990 continue
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9999)
& rn_nm(1:rn_nm_n_ch)
call ems_msg_wr_li(serious_msg_n)
goto 7000
9000 format(31x, 'Entering EMSOL subroutine ', a)
9010 format(' dspace has already been initialized')
9100 format('Changing from application ', i3, ' to application ', i3)
9200 format('Application ', i3, ' has ', i7, ' model(s) ')
9700 format('Before calling ems_dsca, the information for model ', i7,
& ' in application ', i3,
& ' should have been saved by calling ems_ptmi.',
& ' This information cannot be saved by EMSOL since the',
& ' application has changed so this model is likely to be',
& ' corrupted.')
9800 format(i9, ' doublewords in dspace is too small.',
& ' At least ', i9, ' doublewords are required. ',
& ' It is possible that EMSOL has written to addresses',
& ' beyond the end of the declared dspace.')
9810 format(a, ' has been called with value of ', i9,
& ' for parameter ', i1, '. The valid range is ', i9,
& ' to ', i9)
9999 format(a, ' cannot be called from a user exit routine')
end
C->>> ----------------------------------------------------> ems_dscm <<<
c Sets the control variables and initialises the base block for a
c given model. If this model is not the current model and the
c information for the current model needs to be saved then this is
c done with a call to ems_ptmi---unless the application has changed,
c in which case nothing can be done and the current model will be
c corrupted.
c
CM IF (emsol_epc .EQ. 1) THEN
C? subroutine ems_tru_dscm(
CM ELSE
subroutine ems_dscm(
CM ENDIF
& rt_cod, is, ml_n, nblock)
implicit none
include 'EMSV.INC'
include 'EMSPM.INC'
include 'EMSMMGR.INC'
include 'EMSMEM.INC'
include 'EMSP.INC'
include 'ICTVR.INC'
include 'EMSMSG.INC'
integer rt_cod, is(0:*), ml_n, nblock
integer is_p
logical t_bs_blk
CM IF (emsol_epc .EQ. 1) THEN
C? logical ems_i1_ne_i2, ems_i1_eq_i2
CM ENDIF
integer rn_nm_n_ch
parameter (rn_nm_n_ch = 8)
character*(rn_nm_n_ch) rn_nm
save rn_nm
data rn_nm/'ems_dscm'/
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_ne_i2(
C? & is(ix_cu_ca_ems_rn_fg1),
C? & is(ix_cu_ca_ems_rn_fg2)))
CM ELSE
if (is(ix_cu_ca_ems_rn_fg1) .ne. is(ix_cu_ca_ems_rn_fg2))
CM ENDIF
& goto 8990
is(ix_cu_ca_ems_rn_fg1) = 1
is(ix_cu_ca_ems_rn_fg2) = 2
ems_msg_cod = 0
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9000)
& rn_nm(1:rn_nm_n_ch)
call ems_msg_wr_li(50)
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(is(ix_ca_init_fg1), is(ix_ca_init_fg2))) then
CM ELSE
if (is(ix_ca_init_fg1) .eq. is(ix_ca_init_fg2)) then
CM ENDIF
c
c Switch off the `call EMSOL routine' flag during the call to
c ems_init
c
is(ix_cu_ca_ems_rn_fg1) = 0
is(ix_cu_ca_ems_rn_fg2) = 0
call ems_init(ems_msg_cod, is)
is(ix_cu_ca_ems_rn_fg1) = 1
is(ix_cu_ca_ems_rn_fg2) = 2
if (ems_msg_cod .ge. ems_msg_lvl_serious) goto 7000
endif
if (is(ix_ca_dsca) .eq. 0) go to 8010
c
c Check that the model number is in range.
c
if (ml_n .lt. 1 .or. ml_n .gt. is(ix_n_ml)) go to 8101
c
c Exit if dscm has already been called for this model.
c
if (is(p_ml_bs_blk+ml_bs_blk_os_ca_dscm_fg) .ne. 0) go to 7000
if (is(ix_is_n) .ne. cu_is_n) then
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9100)
& is(ix_is_n), cu_is_n
call ems_msg_wr_li(info_msg_n)
endif
c
c Check whether model information has changed for the current model
c since it was last saved.
c
if (sv_ml_ct_vr .gt. 0) then
if (is(ix_is_n) .ne. cu_is_n) then
c
c Application has changed so current model cannot be saved.
c
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9700)
& cu_ml_n, cu_is_n
call ems_msg_wr_li(er_msg_n)
else if (ml_n .ne. cu_ml_n) then
c
c Save the current model.
c
c
c Switch off the `call EMSOL routine' flag during the call to
c ems_ptmi
c
is(ix_cu_ca_ems_rn_fg1) = 0
is(ix_cu_ca_ems_rn_fg2) = 0
CM IF (emsol_epc .EQ. 1) THEN
C? call ems_dum_ptmi(ems_msg_cod, is, cu_ml_n)
CM ELSE
call ems_ptmi(ems_msg_cod, is, cu_ml_n)
CM ENDIF
is(ix_cu_ca_ems_rn_fg1) = 1
is(ix_cu_ca_ems_rn_fg2) = 2
if (ems_msg_cod .ge. ems_msg_lvl_serious) go to 7000
end if
end if
c
c Copy the control variables to/from the base block for the
c application depending on whether this is the first call to dscm.
c
is_p = p_is_bs_blk
t_bs_blk = is(ix_ca_dscm) .eq. 0
if (t_bs_blk) then
c
c Reset the values of mx_n_r, mx_n_c and mx_n_a_el to their default
c values before copying the control variables to the base block.
c These values can only be changed from their default value between
c a call to dscm and a call to lmdl/mps.
c
if (mx_n_r .ne. i_ct_vr_df(ix_mx_n_r)) then
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9710)
& ix_mx_n_r, mx_n_r, i_ct_vr_df(ix_mx_n_r)
call ems_msg_wr_li(warn_msg_n)
mx_n_r = i_ct_vr_df(ix_mx_n_r)
endif
if (mx_n_c .ne. i_ct_vr_df(ix_mx_n_c)) then
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9710)
& ix_mx_n_c, mx_n_c, i_ct_vr_df(ix_mx_n_c)
call ems_msg_wr_li(warn_msg_n)
mx_n_c = i_ct_vr_df(ix_mx_n_c)
endif
if (mx_n_a_el .ne. i_ct_vr_df(ix_mx_n_a_el)) then
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9710)
& ix_mx_n_a_el, mx_n_a_el,
& i_ct_vr_df(ix_mx_n_a_el)
call ems_msg_wr_li(warn_msg_n)
mx_n_a_el = i_ct_vr_df(ix_mx_n_a_el)
endif
endif
CM IF (emsol_epc .EQ. 1) THEN
C? call ems_dum_cp_ct_vr_t_or_fm_bs_blk(t_bs_blk, is_p, is, is)
CM ELSE
call ems_cp_ct_vr_t_or_fm_bs_blk(t_bs_blk, is_p, is, is)
CM ENDIF
c
c Initialise the storage handles for the model so that they point
c to blocks which have not been assigned.
c
is_p = p_ml_bs_blk + (ml_n-1)*ml_bs_blk_n_wo + ml_bs_blk_os_hdl
call ems_cp_i_a(ln_ml_hdl, 0, is(is_p), 0)
c
c Set the current is and model number and indicate that the current
c model data has not been saved.
c
cu_is_n = is(ix_is_n)
cu_ml_n = ml_n
sv_ml_ct_vr = 1
is(ix_ca_dscm) = 1
7000 continue
is(ix_cu_ca_ems_rn_fg1) = 0
is(ix_cu_ca_ems_rn_fg2) = 0
rt_cod = ems_msg_cod
return
8010 continue
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9801)
& rn_nm(1:rn_nm_n_ch)
call ems_msg_wr_li(serious_msg_n)
go to 7000
8101 continue
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9810)ml_n, is(ix_n_ml)
call ems_msg_wr_li(7000)
go to 7000
8990 continue
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9999)
& rn_nm(1:rn_nm_n_ch)
call ems_msg_wr_li(serious_msg_n)
goto 7000
9000 format(31x, 'Entering EMSOL subroutine ', a)
9100 format('Changing from application ', i3, ' to application ', i3)
9700 format('Before calling ems_dscm, the information for model ', i7,
& ' in application ', i3,
& ' should have been saved by calling ems_ptmi.',
& ' This information cannot be saved by EMSOL since the',
& ' application has changed so this model is likely to be',
& ' corrupted.')
9710 format('Resetting integer control variable ', i3, ' from ', i9,
& ' to its default value ', i9,
& '. To set this control variable for a particular model, ',
& 'do so after first calling ems_dscm for that model.')
9801 format('ems_dsca must be called before calling ', a)
9810 format(' Model number ', i9, ' is invalid:',
& i3, ' models have been declared ')
9999 format(a, ' cannot be called from a user exit routine')
end
C->>> ----------------------------------------------------> ems_gtmi <<<
c Extracts the model inforamtion for a model. If this model is not
c the current model and the information for the current model needs
c to be saved then this is done with a call to ems_ptmi---unless the
c application has changed, in which case nothing can be done and the
c current model will be corrupted.
c This routine is also the way to change from one application to
c another.
c
CM IF (emsol_epc .EQ. 1) THEN
C? subroutine ems_tru_gtmi(
CM ELSE
subroutine ems_gtmi(
CM ENDIF
& rt_cod, is, ml_n)
implicit none
include 'EMSV.INC'
include 'EMSMMGR.INC'
include 'EMSPM.INC'
include 'EMSMEM.INC'
include 'EMSP.INC'
include 'CHCTVR.INC'
include 'ICTVR.INC'
include 'RLCTVR.INC'
include 'EMSMSG.INC'
include 'RSMIHDL.INC'
integer rt_cod, is(0:*), ml_n
CM IF (emsol_epc .EQ. 1) THEN
C? logical ems_i1_ne_i2, ems_i1_eq_i2
CM ENDIF
integer is_p
integer rn_nm_n_ch
integer ca_rt_cod
parameter (rn_nm_n_ch = 8)
character*(rn_nm_n_ch) rn_nm
save rn_nm
data rn_nm/'ems_gtmi'/
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_ne_i2(
C? & is(ix_cu_ca_ems_rn_fg1),
C? & is(ix_cu_ca_ems_rn_fg2)))
CM ELSE
if (is(ix_cu_ca_ems_rn_fg1) .ne. is(ix_cu_ca_ems_rn_fg2))
CM ENDIF
& goto 8990
is(ix_cu_ca_ems_rn_fg1) = 1
is(ix_cu_ca_ems_rn_fg2) = 2
ems_msg_cod = 0
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9000)
& rn_nm(1:rn_nm_n_ch)
call ems_msg_wr_li(50)
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(is(ix_ca_init_fg1), is(ix_ca_init_fg2))) then
CM ELSE
if (is(ix_ca_init_fg1) .eq. is(ix_ca_init_fg2)) then
CM ENDIF
c
c Switch off the `call EMSOL routine' flag during the call to
c ems_init
c
is(ix_cu_ca_ems_rn_fg1) = 0
is(ix_cu_ca_ems_rn_fg2) = 0
call ems_init(ems_msg_cod, is)
is(ix_cu_ca_ems_rn_fg1) = 1
is(ix_cu_ca_ems_rn_fg2) = 2
if (ems_msg_cod .ge. ems_msg_lvl_serious) goto 7000
endif
if (is(ix_ca_dsca) .eq. 0) go to 8010
if (ml_n .lt. 1 .or. ml_n .gt. is(ix_n_ml)) go to 8101
if (is(p_ml_bs_blk+(ml_n-1)*ml_bs_blk_n_wo+
& ml_bs_blk_os_ca_ptmi_fg) .eq. 0) goto 8020
if (is(ix_is_n) .ne. cu_is_n) then
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9100)
& is(ix_is_n), cu_is_n
call ems_msg_wr_li(info_msg_n)
endif
if (sv_ml_ct_vr .gt. 0) then
c
c Model information has changed for the current model since it was
c last saved.
c
if (is(ix_is_n) .ne. cu_is_n) then
c
c Application has changed so current model cannot be saved.
c
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9700)
& cu_ml_n, cu_is_n
call ems_msg_wr_li(er_msg_n)
else if (ml_n .ne. cu_ml_n) then
c
c Model has changed within current application so save the model
c information.
c
c
c Switch off the `call EMSOL routine' flag during the call to
c ems_ptmi
c
is(ix_cu_ca_ems_rn_fg1) = 0
is(ix_cu_ca_ems_rn_fg2) = 0
CM IF (emsol_epc .EQ. 1) THEN
C? call ems_dum_ptmi(ems_msg_cod, is, cu_ml_n)
CM ELSE
call ems_ptmi(ems_msg_cod, is, cu_ml_n)
CM ENDIF
is(ix_cu_ca_ems_rn_fg1) = 1
is(ix_cu_ca_ems_rn_fg2) = 2
if (ems_msg_cod .ge. ems_msg_lvl_serious) go to 7000
else
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9710)
call ems_msg_wr_li(warn_msg_n)
end if
end if
c
c Report on the change of model
c
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9100)ml_n, is(ix_is_n)
call ems_msg_wr_li(135)
is_p = p_ml_bs_blk + (ml_n-1)*ml_bs_blk_n_wo + ml_bs_blk_os_ct_vr
c
c Copy the control variables from the base block.
c
CM IF (emsol_epc .EQ. 1) THEN
C? call ems_dum_cp_ct_vr_t_or_fm_bs_blk(.false., is_p, is, is)
CM ELSE
call ems_cp_ct_vr_t_or_fm_bs_blk(.false., is_p, is, is)
CM ENDIF
if (cu_ml_n .ne. ml_n) goto 8030
if (cu_is_n .ne. is(ix_is_n)) goto 8040
c
c Recalculate the model pointers if they are not up-to-date,
c otherwise just copy them into common.
c
if (ml_blk_mv_k .lt. is(ix_blk_mv_k)) then
call ems_g_ml_p(ca_rt_cod, is)
if (ca_rt_cod .ne. 0) goto 8050
else
call ems_cp_ml_p(is)
endif
call ems_g_inv_p(ca_rt_cod, is)
if (ca_rt_cod .ne. 0) goto 8060
sv_ml_ct_vr = 0
c
c Re-allocate space for the solver if the data structures are not
c large enough for the current model
c
if (mx_n_r .gt. rsmi_blk_mx_n_r .or.
& mx_n_c .gt. rsmi_blk_mx_n_c) then
call ems_iz_al_rsmi_blk(is)
if (ems_msg_cod .ge. ems_msg_lvl_serious) go to 7000
endif
7000 continue
is(ix_cu_ca_ems_rn_fg1) = 0
is(ix_cu_ca_ems_rn_fg2) = 0
rt_cod = ems_msg_cod
return
8010 continue
if (ems_msg_no_prt_fm .ge. 1) write(ems_li, 9801)
& rn_nm(1:rn_nm_n_ch)