
********************* MNETGN ***************************************    MNE00010
C                                                                       MNE00020
C                         MNETGN WAS DEVELOPED AT SOUTHERN              MNE00030
C                         METHODIST UNIVERSITY, DALLAS, TX, DURING      MNE00040
C                         AUTUMN 1976 BY DR J. L. KENNINGTON AND        MNE00050
C                         A. I. ALI.        TELE. NO. - (214) 692-3072  MNE00060
C                                                                       MNE00070
C     REVISED    JUNE 1986     JLK                                      MNE00080
C////////////////////////////////////////////////////////////////////// MNE00090
C                                                                       MNE00100
C        DATA STRUCTURE FOR MULTICOMMODITY GENERATOR - MNETGN           MNE00110
C                                                                       MNE00120
C        FOR EACH PROBLEM TO BE GENERATED THE FOLLOWING THREE DATA CARDSMNE00130
C        BE PROVIDED.  IN ADDITION, THE LAST DATA CARD MUST BE BLANK.   MNE00140
C        I N P U T                                                      MNE00150
C                                                                       MNE00160
C        VARIABLE                                          FORMAT AND COMNE00170
C                                                                       MNE00180
C        FIRST CARD                                                     MNE00190
C        ISEED   - SEED FOR RANDOM NO GENERATOR, NONZERO        I3   1-3MNE00200
C        NPROB   - PROBLEM NUMBER                               I5   4-8MNE00210
C        SECOND CARD                                                    MNE00220
C        NODES   - NUMBER OF NODES                              I5   1-5MNE00230
C        DENS    - NUMBER OF ARCS                               I5   6-1MNE00240
C        NSORC   - NUMBER OF SOURCES ( PURE AND TRANSHIPMENT)   I5   11-MNE00250
C        NSINK   - NUMBER OF SINKS (PURE AND TRANSHIPMENT)      I5   16-MNE00260
C        NCOMM   - NUMBER OF COMMODITIES                        I5   21-MNE00270
C        NTSORC  - NUMBER OF TRANSHIPMENT SOURCES               I5   26-MNE00280
C        NTSINK  - NUMBER OF TRANSHIPMENT SINKS                 I5   31-MNE00290
C        LCHAIN  - LENGTH OF LONGEST CHAIN IN SKELETON          I5   36-MNE00300
C        THIRD CARD                                                     MNE00310
C        MINCST  - LOWER BOUND ON COST                          I5   1-5MNE00320
C        MAXCST  - UPPER BOUND ON COST                          I5   6-1MNE00330
C        MINSUP  - LOWER BOUND ON TOTAL SUPPLY                  I5   11-MNE00340
C        MAXSUP  - UPPER BOUND ON TOTAL SUPPLY                  I5   16-MNE00350
C        MINBND  - LOWER BOUND ON INDIVIDUAL ARC BOUNDS         I5   21-MNE00360
C        MAXBND  - UPPER BOUND ON INDIVIDUAL ARC BOUNDS         I5   26-MNE00370
C        MINCAP  - LOWER BOUND ON MUTUAL ARC CAPACITIES         I5   31-MNE00380
C        MAXCAP  - UPPER BOUND ON MUTUAL ARC CAPACITIES         I5   36-MNE00390
C        BHICST  - PERCENT OF ARCS WITH HIGH COST               F5.0 41-MNE00400
C        BBND    - PERCENT OF ARCS WITH INDIVIDUAL ARC BOUNDS   F5.0 46-MNE00410
C        BCAP    - PERCENT OF ARCS WITH MUTUAL ARC CAPACITIES   F5.0 51-MNE00420
C                                                                       MNE00430
C        THE FOLLOWING ARRAYS NEED TO BE DIMENSIONED AS INDICATED FOR THMNE00440
C        LARGEST PROBLEM IN ANY ONE RUN.                                MNE00450
C        ARRAYS                                                         MNE00460
C                                                                       MNE00470
C        CAT(NODES,NCOMM)                                               MNE00480
C        IPRED(NODES)                                                   MNE00490
C        IFLAG(NODES)                                                   MNE00500
C        ISUP(NSORC,NCOMM+1)                                            MNE00510
C        IDEM(NSINK,NCOMM)                                              MNE00520
C        LSINKS(NSINK)                                                  MNE00530
C        TSUP(NCOMM)           - TOTAL SUPPLY FOR EACH COMMODITY.       MNE00540
C        MUT(LCHAIN)                                                    MNE00550
C        MUTS(NSINK)                                                    MNE00560
C                                                                       MNE00570
C     N O T E --- NCOMM MUST BE .LE. NODES                              MNE00580
C                                                                       MNE00590
C                                                                       MNE00600
C        -----  FILES                                                   MNE00610
C                                                                       MNE00620
C        TAPE1  -  /TITLE/NO. NODES,NO.COMMODITIES/REQUIREMENTS/ESTIMATEMNE00630
C                  OF BEFORE SETS/                                      MNE00640
C                  /ARC DATA/.                                          MNE00650
C                  /MUTUAL ARC CAPACITIES/.                             MNE00660
C        TAPE2 - MPS FORMAT                                             MNE00670
C                                                                       MNE00680
C        TAPE5 - INPUT FILE                                             MNE00690
C                                                                       MNE00700
C        TAPE6 - OUTPUT CONCERNING GENERATED PROBLEM                    MNE00710
C                                                                       MNE00720
C        TAPES3,4,7,8,9,10,11 - SCRATCH                                 MNE00730
C                                                                       MNE00740
C                                                                       MNE00750
C///////////////////////////////////////////////////////////////////////MNE00760
      INTEGER ZCOMM,ZNODES                                              MNE00770
      PARAMETER (ZCOMM=70, ZNODES=1000)                                  MNE00780
C                                                                       MNE00790
      INTEGER IPRED(ZNODES),ITAIL(ZNODES),IFLAG(ZNODES),                MNE00800
     1 ISUP(ZNODES,ZCOMM),IDEM(ZNODES,ZCOMM),LSINKS(70),TSUP(ZCOMM)     MNE00810
      INTEGER MUT(ZNODES),MUTS(ZNODES)                                  MNE00820
      INTEGER DENS,CAT(ZNODES,ZCOMM)                                    MNE00830
      CHARACTER*10 ANAME,BLANK,XNAME                                    MNE00840
      CHARACTER*5 Z                                                     MNE00850
      DATA BLANK/' '     /                                              MNE00860
C        THE FORMAT STATEMENTS                                          MNE00870
C                                                                       MNE00880
100   FORMAT(I3,I5)                                                     MNE00890
101   FORMAT(8I5)                                                       MNE00900
102   FORMAT(8I5,3F5.0)                                                 MNE00910
103   FORMAT(1X,8I5)                                                    MNE00920
104   FORMAT(1X,8I5,3F5.0)                                              MNE00930
105   FORMAT(2I5,I10)                                                   MNE00940
106   FORMAT(I5,I10)                                                    MNE00950
107   FORMAT('X',A9,3I5,2F10.1,I5)                                      MNE00960
108   FORMAT(' PROBLEM NUMBER ',I5)                                     MNE00970
109   FORMAT(1H0,'PROBLEM NO.',I4,' - ',I5,' NODE,',I5,' ARC,',I5,      MNE00980
     2     'COMMODITY MCNF HAS BEEN GENERATED')                         MNE00990
120   FORMAT(1H1,55X,'PROBLEM NUMBER  ',I2)                             MNE01000
121   FORMAT(2I5,I10)                                                   MNE01010
122   FORMAT(16I5)                                                      MNE01020
127   FORMAT(A10)                                                       MNE01030
C                                                                       MNE01040
141   FORMAT('0    INPUT ERROR - SOURCES  +  SINKS .GT. NODES')         MNE01050
142   FORMAT('0    INPUT ERROR - NTSORC GREATER THAN NSORC')            MNE01060
143   FORMAT('0    INPUT ERROR - NTSINK GREATER THAN NSINK')            MNE01070
144   FORMAT('0    INPUT ERROR - A VARIABLE ON INPUT CARD 2 IS  .LT. 0')MNE01080
145   FORMAT('0    INPUT ERROR - MINCST.GT.MAXCST')                     MNE01090
146   FORMAT('0    INPUT ERROR - MINSUP.GT.MAXSUP')                     MNE01100
147   FORMAT('0    INPUT ERROR - MINBND.GT.MAXBND')                     MNE01110
148   FORMAT('0    INPUT ERROR - MINCAP.GT.MAXCAP')                     MNE01120
149   FORMAT('0    INPUT ERROR - BHICST OR BBND OR BCAP NOT IN (0,100)')MNE01130
150   FORMAT('     INPUT ERROR - MINSUP.LT.NSORC')                      MNE01140
C                                                                       MNE01150
160   FORMAT(1H0,' ',10(5X,I5))                                         MNE01160
161   FORMAT(1H0,'TSUP(NCOMM)')                                         MNE01170
162   FORMAT(1H0,'ISUP(NODES,NCOMM+1)')                                 MNE01180
163   FORMAT(1H0,'IPRED(NODES)')                                        MNE01190
164   FORMAT(1X,'LSORC=',I5,'NSORT=',I5)                                MNE01200
165   FORMAT(5(5X,I5))                                                  MNE01210
166   FORMAT(' ITAIL(',I3,')=',I3,' IHEAD(',I3,')=',I3)                 MNE01220
168   FORMAT('0IDEM(NODES,NCOMM+1)',10I10)                              MNE01230
169   FORMAT(1X,50I2)                                                   MNE01240
170   FORMAT(1X,24I5)                                                   MNE01250
C                                                                       MNE01260
C                                                                       MNE01270
C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - MNE01280
C                                                                       MNE01290
C        INPUT OF ISEED AND INITIALIZATION OF THE RANDOM NO. GENERATOR  MNE01300
C                                                                       MNE01310
1000  READ(5,100,END=999) ISEED,NPROB                                   MNE01320
      IF(ISEED.EQ.0) CALL ERRMSG(5)                                     MNE01330
      REWIND 3                                                          MNE01340
      REWIND 4                                                          MNE01350
      REWIND 7                                                          MNE01360
C                                                                       MNE01370
      WRITE(6,120) NPROB                                                MNE01380
      WRITE(6,103) ISEED                                                MNE01390
C                                                                       MNE01400
C        THE FOLLOWING SEGMENT WARMS UP THE GENERATOR                   MNE01410
C                                                                       MNE01420
      ISEED=MOD(ISEED,500)+150                                          MNE01430
      K=ISEED                                                           MNE01440
      DO 10 I=1,K                                                       MNE01450
10    J=RAND(ISEED)                                                     MNE01460
C                                                                       MNE01470
      READ(5,101) NODES,DENS,NSORC,NSINK,NCOMM,NTSORC,NTSINK,LCHAIN     MNE01480
      READ(5,102) MINCST,MAXCST,MINSUP,MAXSUP,MINBND,MAXBND,MINCAP,     MNE01490
     1MAXCAP,BHICST,BBND,BCAP                                           MNE01500
C                                                                       MNE01510
      WRITE(6,103) NODES,DENS,NSORC,NSINK,NCOMM,NTSORC,NTSINK,LCHAIN    MNE01520
      WRITE(6,104)MINCST,MAXCST,MINSUP,MAXSUP,MINBND,MAXBND,MINCAP,     MNE01530
     1MAXCAP,BHICST,BBND,BCAP                                           MNE01540
C        INPUT CHECKS AND ERROR MESSAGES                                MNE01550
C                                                                       MNE01560
      IND=0                                                             MNE01570
      IF(NSORC+NSINK.GT.NODES) IND=1                                    MNE01580
      IF(NSORC+NSINK.GT.NODES) WRITE(6,141)                             MNE01590
      IF(NTSORC.GT.NSORC)  WRITE(6,142)                                 MNE01600
      IF(NTSORC.GT.NSORC) IND=1                                         MNE01610
      IF(NTSINK.GT.NSINK) IND=1                                         MNE01620
      IF(NTSINK.GT.NSINK) WRITE(6,143)                                  MNE01630
      IF(NODES .LT.0) IND=1                                             MNE01640
      IF(DENS  .LT.0) IND=1                                             MNE01650
      IF(NSORC .LT.0) IND=1                                             MNE01660
      IF(NSINK .LT.0) IND=1                                             MNE01670
      IF(NCOMM .LT.0) IND=1                                             MNE01680
      IF(NTSORC.LT.0) IND=1                                             MNE01690
      IF(NTSINK.LT.0) IND=1                                             MNE01700
      IF(NODES .LT.0) WRITE(6,144)                                      MNE01710
      IF(DENS  .LT.0) WRITE(6,144)                                      MNE01720
      IF(NSORC .LT.0) WRITE(6,144)                                      MNE01730
      IF(NSINK .LT.0) WRITE(6,144)                                      MNE01740
      IF(NCOMM .LT.0) WRITE(6,144)                                      MNE01750
      IF(NTSORC.LT.0) WRITE(6,144)                                      MNE01760
      IF(NTSINK.LT.0) WRITE(6,144)                                      MNE01770
      IF(MINCST.GT.MAXCST) IND=1                                        MNE01780
      IF(MINCST.GT.MAXCST) WRITE(6,145)                                 MNE01790
      IF(MINSUP.GT.MAXSUP) IND=1                                        MNE01800
      IF(MINSUP.GT.MAXSUP) WRITE(6,146)                                 MNE01810
      IF(MINBND.GT.MAXBND) IND=1                                        MNE01820
      IF(MINBND.GT.MAXBND) WRITE(6,147)                                 MNE01830
      IF(MINCAP.GT.MAXCAP) IND=1                                        MNE01840
      IF(MINCAP.GT.MAXCAP) WRITE(6,148)                                 MNE01850
      IF(BHICST.LT.0..OR.BHICST.GT.100.) IND=1                          MNE01860
      IF(BHICST.LT.0..OR.BHICST.GT.100.) WRITE(6,149)                   MNE01870
      IF(BBND  .LT.0..OR.BBND  .GT.100.) IND=1                          MNE01880
      IF(BBND  .LT.0..OR.BBND  .GT.100.) WRITE(6,149)                   MNE01890
      IF(BCAP  .LT.0..OR.BCAP  .GT.100.) IND=1                          MNE01900
      IF(BCAP  .LT.0..OR.BCAP  .GT.100.) WRITE(6,149)                   MNE01910
      IF(MINSUP.LT.NSORC) IND=1                                         MNE01920
      IF(MINSUP.LT.NSORC) WRITE(6,150)                                  MNE01930
      IF(IND.EQ.1) GO TO 1000                                           MNE01940
      IF(NCOMM+1.GT.ZCOMM) CALL ERRMSG(1)                               MNE01950
      IF(NODES+1.GT.ZNODES) CALL ERRMSG(2)                              MNE01960
      IISPAN = 5                                                        MNE01970
      WRITE(1,122) IISPAN                                               MNE01980
      WRITE(1,108) NPROB                                                MNE01990
      WRITE(1,105) NODES,NCOMM                                          MNE02000
C- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  MNE02010
C                                                                       MNE02020
C        SET CONSTANTS                                                  MNE02030
C                                                                       MNE02040
      NPSORC=NSORC-NTSORC                                               MNE02050
      NPSINK=NSINK-NTSINK                                               MNE02060
      LPSOR=NSORC-NTSORC                                                MNE02070
      ITSOR=LPSOR+1                                                     MNE02080
      IPT=NSORC+1                                                       MNE02090
      LPT=NODES-NSINK                                                   MNE02100
      ITSIN=LPT+1                                                       MNE02110
      LTSIN=NODES-NSINK+NTSINK                                          MNE02120
      IPSIN=LTSIN+1                                                     MNE02130
      NTRANS=LPT-NSORC                                                  MNE02140
      PCAP=BCAP/100.                                                    MNE02150
      PHICST=BHICST/100.                                                MNE02160
      PBND=BBND/100.                                                    MNE02170
      IBDDIF=MAXBND-MINBND                                              MNE02180
      ICTDIF=MAXCST-MINCST                                              MNE02190
      ICPDIF=MAXCAP-MINCAP                                              MNE02200
      ICBDIF=MAXBND-MINBND                                              MNE02210
      KTRAN=LTSIN-LPSOR                                                 MNE02220
      IS=0                                                              MNE02230
      NARC=0                                                            MNE02240
C                                                                       MNE02250
C        SET AVERAGE CHAIN LENGTH AND NUMBER OF SINKS CONNECTED TO EACH MNE02260
C                                                                       MNE02270
      FNAVE1=FLOAT(KTRAN)/FLOAT(NSORC)                                  MNE02280
      FNAVE2=FLOAT(NSINK)/FLOAT(NSORC)                                  MNE02290
C                                                                       MNE02300
C        GENERATE TOTAL SUPPLY FOR EACH COMMODITY                       MNE02310
C                                                                       MNE02320
      DO 20 K=1,NCOMM                                                   MNE02330
20    TSUP(K)=RAND(ISEED)*(MAXSUP-MINSUP)+MINSUP                        MNE02340
C                                                                       MNE02350
C        DISTRIBUTE TOTAL SUPPLY AMONG SOURCES                          MNE02360
C                                                                       MNE02370
      DO 30 K=1,NCOMM                                                   MNE02380
      KS=TSUP(K)/NSORC                                                  MNE02390
C        INITIALIZE SUPPLY FOR NODE I, COMMODITY K                      MNE02400
      DO 31 I=1,NSORC                                                   MNE02410
31    ISUP(I,K)=0                                                       MNE02420
      DO 300 I=1,NSORC                                                  MNE02430
      KSP=KS*RAND(ISEED)+1                                              MNE02440
      J=NSORC*RAND(ISEED)+1                                             MNE02450
      ISUP(I,K)=ISUP(I,K) + KSP                                         MNE02460
300   ISUP(J,K)=ISUP(J,K) + KS - KSP                                    MNE02470
      J=NSORC*RAND(ISEED) +1                                            MNE02480
      ISUP(J,K)=ISUP(J,K)+TSUP(K) -(KS*NSORC)                           MNE02490
      DO 30 I=1,NSORC                                                   MNE02500
30    ISUP(I,K)=MAX0(ISUP(I,K),NSINK)                                   MNE02510
C        ADD TOTAL SUPPLIES AT EACH NODE I AND STORE SUM IN ISUP(I,NCOMMMNE02520
      DO 32 I=1,NSORC                                                   MNE02530
      ITOTAL=0                                                          MNE02540
      DO 33 K=1,NCOMM                                                   MNE02550
33    ITOTAL=ITOTAL+ISUP(I,K)                                           MNE02560
32    ISUP(I,NCOMM+1)=ITOTAL                                            MNE02570
C                                                                       MNE02580
C        RESET FLAGS AND BEFORE SETS                                    MNE02590
C                                                                       MNE02600
      DO 2000 I=1,NODES                                                 MNE02610
      DO1950K=1,NCOMM                                                   MNE02620
1950  CAT(I,K)=0                                                        MNE02630
2000  IFLAG(I)=0                                                        MNE02640
C                                                                       MNE02650
C        INITIALIZE DEMANDS                                             MNE02660
C                                                                       MNE02670
      DO 2005 I=1,NSINK                                                 MNE02680
      DO 2005 K=1,NCOMM                                                 MNE02690
2005  IDEM(I,K)=0                                                       MNE02700
      NUM = 0                                                           MNE02710
C                                                                       MNE02720
      DO 600 LSORC=1,NSORC                                              MNE02730
      DO601I601=ITSIN,NODES                                             MNE02740
      IFLAG(I601)=0                                                     MNE02750
601   CONTINUE                                                          MNE02760
C                                                                       MNE02770
C        DETERMINE CHAIN LENGTH                                         MNE02780
C                                                                       MNE02790
      LEN=0                                                             MNE02800
      LAST=LSORC                                                        MNE02810
      IF(NPSORC+NPSINK.EQ.NODES) GO TO 2035                             MNE02820
      LEN=3*FNAVE1*RAND(ISEED)+1                                        MNE02830
      LEN=MIN0(LEN,LCHAIN)                                              MNE02840
C                                                                       MNE02850
C        SELECT TRANSSHIPMENT NODES                                     MNE02860
C                                                                       MNE02870
C                                                                       MNE02880
      DO 2020 I=1,LEN                                                   MNE02890
      DO 2015 I1=1,4                                                    MNE02900
2010  L=KTRAN*RAND(ISEED) + ITSOR                                       MNE02910
      IF(L.EQ.LAST.OR.L.EQ.LSORC) GO TO 2010                            MNE02920
      IF(IFLAG(L).EQ.0) GO TO 2017                                      MNE02930
2015  CONTINUE                                                          MNE02940
2017  CONTINUE                                                          MNE02950
      IPRED(I)=L                                                        MNE02960
      LAST=L                                                            MNE02970
      IF(L.LT.ITSIN) IFLAG(L)=1                                         MNE02980
2020  CONTINUE                                                          MNE02990
C                                                                       MNE03000
      IF(LSORC.NE.NSORC) GO TO 2035                                     MNE03010
C                                                                       MNE03020
C          CONNECT ALL PURE TRANSSHIPMENT NODES NOT CONNECTED TO LAST   MNE03030
C          CHAIN                                                        MNE03040
C                                                                       MNE03050
      DO 2030 I=IPT,LPT                                                 MNE03060
      IF(IFLAG(I).NE.0) GO TO 2030                                      MNE03070
      LAST=I                                                            MNE03080
      LEN=LEN+1                                                         MNE03090
      IF(LEN.GT.ZNODES) CALL ERRMSG(2)                                  MNE03100
      IPRED(LEN)=I                                                      MNE03110
2030  CONTINUE                                                          MNE03120
2035  CONTINUE                                                          MNE03130
C                                                                       MNE03140
C        RANDOMLY SELECT THE NUMBER OF SINKS TO BE CONNECTED TO THIS    MNE03150
C        CHAIN                                                          MNE03160
C                                                                       MNE03170
      NSKSR=3*FNAVE2*RAND(ISEED)+1                                      MNE03180
      NSKSR=MIN0(NSKSR,NSINK)                                           MNE03190
C                                                                       MNE03200
C        SELECT SINKS AT RANDOM                                         MNE03210
C                                                                       MNE03220
      DO 2040 I=1,NSKSR                                                 MNE03230
      DO 2036 I1=1,10                                                   MNE03240
2031  CONTINUE                                                          MNE03250
      L=NSINK*RAND(ISEED) + ITSIN                                       MNE03260
      IF(L.EQ.LAST) GO TO 2031                                          MNE03270
      IF(IFLAG(L).EQ.0) GO TO 2037                                      MNE03280
2036  CONTINUE                                                          MNE03290
2037  CONTINUE                                                          MNE03300
      LSINKS(I)=L                                                       MNE03310
2040  IFLAG(L)=1                                                        MNE03320
C                                                                       MNE03330
      IF(LSORC.NE.NSORC) GO TO 2060                                     MNE03340
C                                                                       MNE03350
C        CONNECT ALL REMAINING SINKS TO THE LAST CHAIN                  MNE03360
C                                                                       MNE03370
      DO 2050 I=ITSIN,NODES                                             MNE03380
      IF(IFLAG(I).NE.0) GO TO 2050                                      MNE03390
      NSKSR=NSKSR+1                                                     MNE03400
      IF(NSKSR.GT.ZNODES) CALL ERRMSG(2)                                MNE03410
      LSINKS(NSKSR)=I                                                   MNE03420
2050  CONTINUE                                                          MNE03430
2060  CONTINUE                                                          MNE03440
C                                                                       MNE03450
C        DETERMINE ARCS TO BE MUTUALLY CAPACITATED AND ASSIGN NUMBERS   MNE03460
C        AND CAPACITIES                                                 MNE03470
C                                                                       MNE03480
      IF(NPSORC+NPSINK.EQ.NODES) GO TO 1112                             MNE03490
      DO 2090 I=1,LEN                                                   MNE03500
      IF(RAND(ISEED).GT.PCAP) GO TO 2085                                MNE03510
      IS=IS+1                                                           MNE03520
      WRITE(4,106) IS,ISUP(LSORC,NCOMM+1)                               MNE03530
      MUT(I)=IS                                                         MNE03540
      GO TO 2090                                                        MNE03550
2085  MUT(I)=0                                                          MNE03560
2090  CONTINUE                                                          MNE03570
C                                                                       MNE03580
1112  DO 3000 I=1,NSKSR                                                 MNE03590
      IF(RAND(ISEED).GT.PCAP) GO TO 2095                                MNE03600
      IS=IS+1                                                           MNE03610
      WRITE(4,106) IS,ISUP(LSORC,NCOMM+1)                               MNE03620
      MUTS(I)=IS                                                        MNE03630
      GO TO 3000                                                        MNE03640
2095  MUTS(I)=0                                                         MNE03650
3000  CONTINUE                                                          MNE03660
C                                                                       MNE03670
C        GENERATE DEMANDS AND COSTS FOR EACH COMMODITY                  MNE03680
C                                                                       MNE03690
      DO 4000 KOMM=1,NCOMM                                              MNE03700
      KS=ISUP(LSORC,KOMM)/NSKSR                                         MNE03710
C                                                                       MNE03720
      DO 3020 K=1,NSKSR                                                 MNE03730
      J=NSKSR*RAND(ISEED)+1                                             MNE03740
      KSP=KS*RAND(ISEED)+1                                              MNE03750
      LI=LSINKS(K)-LPT                                                  MNE03760
      IDEM(LI,KOMM)=IDEM(LI,KOMM) + KSP                                 MNE03770
      LI=LSINKS(J) - LPT                                                MNE03780
      IDEM(LI,KOMM)=IDEM(LI,KOMM) + KS-KSP                              MNE03790
3020  CONTINUE                                                          MNE03800
      J=NSKSR*RAND(ISEED)+1                                             MNE03810
      LI=LSINKS(J) - LPT                                                MNE03820
      IDEM(LI,KOMM)=IDEM(LI,KOMM) + ISUP(LSORC,KOMM) -  KS*NSKSR        MNE03830
C                                                                       MNE03840
C        DEVELOP COST AND CAPACITIES FOR ARCS                           MNE03850
C                                                                       MNE03860
      NF=LSORC                                                          MNE03870
      IF(NPSORC+NPSINK.EQ.NODES) GO TO 1113                             MNE03880
      DO 3050 I=1,LEN                                                   MNE03890
      NT=IPRED(I)                                                       MNE03900
      IF(NT.EQ.NF) CALL ERRMSG(3)                                       MNE03910
C                                                                       MNE03920
C        DETERMINE IF ARC GETS HIGH COST                                MNE03930
C                                                                       MNE03940
      COST=MAXCST                                                       MNE03950
      IF(RAND(ISEED).LE.PHICST) GO TO 3030                              MNE03960
      COST=MINCST + RAND(ISEED)*ICTDIF                                  MNE03970
C                                                                       MNE03980
C        DETERMINE IF ARC HAS INDIVIDUAL CAPACITY                       MNE03990
C                                                                       MNE04000
3030  CAP=-1.0                                                          MNE04010
      IF(RAND(ISEED).GE.PBND) GO TO 3040                                MNE04020
      CAP = ISUP(LSORC,KOMM)                                            MNE04030
3040  CONTINUE                                                          MNE04040
      NUM = NUM + 1                                                     MNE04050
      ANAME = Z(NUM)                                                    MNE04060
      WRITE(3,107) ANAME,NF,NT,KOMM,COST,CAP,MUT(I)                     MNE04070
      CAT(NT,KOMM)=CAT(NT,KOMM) + 1                                     MNE04080
3050  NF=NT                                                             MNE04090
C                                                                       MNE04100
1113  DO 3080 I=1,NSKSR                                                 MNE04110
C                                                                       MNE04120
C        DETERMINE IF ARC GETS HIGH COST                                MNE04130
C                                                                       MNE04140
      NT=LSINKS(I)                                                      MNE04150
      IF(LAST.EQ.NT) CALL ERRMSG(4)                                     MNE04160
C                                                                       MNE04170
      COST=MAXCST                                                       MNE04180
      IF(RAND(ISEED).LE.PHICST) GO TO 3060                              MNE04190
      COST=MINCST + RAND(ISEED)*ICTDIF                                  MNE04200
C                                                                       MNE04210
C                                                                       MNE04220
C        DETERMINE IF ARC HAS INDIVIDUAL CAPACITY                       MNE04230
C                                                                       MNE04240
3060  CAP=-1.0                                                          MNE04250
      IF(RAND(ISEED).GE.PBND) GO TO 3070                                MNE04260
      CAP=ISUP(LSORC,KOMM)                                              MNE04270
3070  CONTINUE                                                          MNE04280
      NUM = NUM + 1                                                     MNE04290
      ANAME = Z(NUM)                                                    MNE04300
      WRITE(3,107) ANAME,LAST,NT,KOMM,COST,CAP,MUTS(I)                  MNE04310
      CAT(NT,KOMM)=CAT(NT,KOMM) + 1                                     MNE04320
3080  CONTINUE                                                          MNE04330
C                                                                       MNE04340
      NARC=NARC+LEN+NSKSR                                               MNE04350
4000  CONTINUE                                                          MNE04360
600   CONTINUE                                                          MNE04370
C                                                                       MNE04380
C        ADD OTHER ARCS IF NARC .LT. DENS                               MNE04390
C                                                                       MNE04400
4040  IF(NARC.GE.DENS) GO TO 6000                                       MNE04410
C                                                                       MNE04420
C        SELECT FROM NODE AND TO NODE AT RANDOM                         MNE04430
C                                                                       MNE04440
C---------GET TO NODE                                                   MNE04450
      NT=(NODES-LPSOR)*RAND(ISEED)+ITSOR                                MNE04460
40440 CONTINUE                                                          MNE04470
      NF= NODES*RAND(ISEED)                                             MNE04480
      IF(NF.EQ.NT) GO TO 40440                                          MNE04490
c
c Problem with transfer - incomplete line as follows:
c    EQ.0 ) GO TO 40440                                          MNE04500
c Replaced with:
      if(NF.EQ.0 ) GO TO 40440                                          MNE04500
C                                                                       MNE04510
C        SELECT NUMBER OF COMMODITIES AT RANDOM                         MNE04520
C                                                                       MNE04530
      NOCOM=NCOMM*RAND(ISEED)+1                                         MNE04540
C                                                                       MNE04550
C        DETERMINE IF ARC HAS MUTUAL CAPACITY                           MNE04560
C                                                                       MNE04570
      ISS=0                                                             MNE04580
      IF(RAND(ISEED).GT.PCAP) GO TO 4050                                MNE04590
      IS=IS+1                                                           MNE04600
      ISS=IS                                                            MNE04610
      ICAP=MINCAP+RAND(ISEED)*ICPDIF                                    MNE04620
      WRITE(4,106) IS,ICAP                                              MNE04630
4050  CONTINUE                                                          MNE04640
C                                                                       MNE04650
      DO 5000 I5000=1,NOCOM                                             MNE04660
C                                                                       MNE04670
C        SELECT COMMODITY AT RANDOM                                     MNE04680
C                                                                       MNE04690
4052  CONTINUE                                                          MNE04700
      KOMM=NCOMM*RAND(ISEED)+1                                          MNE04710
C                                                                       MNE04720
C        DETERMINE COST AND CAPACITY                                    MNE04730
C                                                                       MNE04740
      COST=MINCST+RAND(ISEED)*ICTDIF                                    MNE04750
4100  CAP=-1.0                                                          MNE04760
      IF(RAND(ISEED).GE.PBND) GO TO 4200                                MNE04770
      CAP=MINBND+RAND(ISEED)*ICBDIF                                     MNE04780
4200  CONTINUE                                                          MNE04790
      CAT(NT,KOMM)=CAT(NT,KOMM)+1                                       MNE04800
      NUM = NUM + 1                                                     MNE04810
      ANAME = Z(NUM)                                                    MNE04820
      WRITE(3,107) ANAME,NF,NT,KOMM,COST,CAP,ISS                        MNE04830
5000  CONTINUE                                                          MNE04840
      NARC=NARC+NOCOM                                                   MNE04850
      GO TO 4040                                                        MNE04860
C                                                                       MNE04870
6000  continue
      WRITE(3,127) BLANK                                                MNE04880
      WRITE(4,127) BLANK                                                MNE04890
C    IS IS THE TOTAL NO OF ARCS WITH MUTUAL ARC CAPACITY                MNE04900
C    IT IS SET TO JTEMP AND STORED IN TAPE7 TO BE USED LATER            MNE04910
      JTEMP=IS                                                          MNE04920
      WRITE(7,171) JTEMP                                                MNE04930
171   FORMAT(I5)                                                        MNE04940
C                                                                       MNE04950
C                                                                       MNE04960
      REWIND 3                                                          MNE04970
      REWIND 4                                                          MNE04980
C                                                                       MNE04990
C        OUTPUT REQUIREMENTS                                            MNE05000
C                                                                       MNE05010
      DO 6010 I=1,NSORC                                                 MNE05020
      DO 6010 K=1,NCOMM                                                 MNE05030
      WRITE(1,121) I,K,ISUP(I,K)                                        MNE05040
      WRITE(7,121) I,K,ISUP(I,K)                                        MNE05050
6010  CONTINUE                                                          MNE05060
C                                                                       MNE05070
      DO 6020 I=1,NSINK                                                 MNE05080
      DO 6020 K=1,NCOMM                                                 MNE05090
      IR=-IDEM(I,K)                                                     MNE05100
C                                                                       MNE05110
      IN=I+LPT                                                          MNE05120
      WRITE(1,121) IN,K,IR                                              MNE05130
      WRITE(7,121) IN,K,IR                                              MNE05140
6020  CONTINUE                                                          MNE05150
      WRITE(1,127) BLANK                                                MNE05160
C                                                                       MNE05170
C--WRITE ARCS ONTO FILE 1                                               MNE05180
C                                                                       MNE05190
6040  CONTINUE                                                          MNE05200
      READ(3,107)  XNAME,NF,NT,KOMM,COST,CAP,IS                         MNE05210
      WRITE(1,107) XNAME,NF,NT,KOMM,COST,CAP,IS                         MNE05220
      IF(XNAME.NE.BLANK) GO TO 6040                                     MNE05230
C                                                                       MNE05240
6050  CONTINUE                                                          MNE05250
      READ(4,106)  IS,IC                                                MNE05260
      WRITE(1,106) IS,IC                                                MNE05270
      IF(IC.NE.0) GO TO 6050                                            MNE05280
C                                                                       MNE05290
      WRITE(6,109) NPROB,NODES,NARC,NCOMM                               MNE05300
      CALL MPSDAT(NODES,NCOMM)                                          MNE05310
      GO TO 1000                                                        MNE05320
C                                                                       MNE05330
999   STOP 12345                                                        MNE05340
      END                                                               MNE05350
      FUNCTION RAND(I)                                                  MNE05360
C                                                                       MNE05370
C        THIS GENERATOR IS BASED ON THEOREM A, PAGE 15, VOL. 2 OF       MNE05380
C        KNUTH, THE ART OF COMPUTER PROGRAMMING -                       MNE05390
C                                                                       MNE05400
C        NOTE - 2**23 - 1 = 8388607                                     MNE05410
C                                                                       MNE05420
      I=MOD(5*I+7,8388607)                                              MNE05430
      RAND=FLOAT(I)/8388607.                                            MNE05440
      RETURN                                                            MNE05450
      END                                                               MNE05460
      SUBROUTINE MPSDAT(NODES,NCOMM)                                    MNE05470
C                                                                       MNE05480
C  RUN AN EXPERIMENT COMPARING MPSX PLAIN                               MNE05490
C                              MPSX GUB                                 MNE05500
C                              MCNF85                                   MNE05510
C                                                                       MNE05520
C                                                                       MNE05530
C     THIS SUBROUTINE GENERATES MPS CARD DECK                           MNE05540
C                                                                       MNE05550
      COMMON /BLCK1/ NNNN,CCCC                                          MNE05560
      INTEGER NNNN,CCCC,ROWNUM                                          MNE05570
      CHARACTER*5 Z,ZZ,ZZZ,ZCOL                                         MNE05580
      INTEGER   COMM, FROM, TO, ROW, ZERO                               MNE05590
      CHARACTER*10 BLANK                                                MNE05600
      DATA      BLANK/' ' /                                             MNE05610
      DATA      ONE/ 1.0 /                                              MNE05620
      DATA   ONENEG/-1.0 /                                              MNE05630
                                                                        MNE05640
106   FORMAT(I5,I10)                                                    MNE05650
107   FORMAT(A10,3I5,2F10.2,I5)                                         MNE05660
171   FORMAT(I5)                                                        MNE05670
121   FORMAT(2I5,I10)                                                   MNE05680
122   FORMAT(2I5,F15.5)                                                 MNE05690
*                                                                       MNE05700
*     * * * * *        DESCRIPTION OF FILES       * * * * *             MNE05710
*     2 : INPUT LINEAR PROGRAMMING DATA DECK                            MNE05720
*     8 : INPUT NETWORK DATA DECK                                       MNE05730
*     3 : ARC DATA FILE                                                 MNE05740
*    11 : BOUND SECTION DATA FILE                                       MNE05750
*     4 : MUTUAL CAPACITY ROW DATA FILE                                 MNE05760
*     7 : NODE DATA FILE                                                MNE05770
*    10 : RHS DATA FILE                                                 MNE05780
*                                                                       MNE05790
      NNNN = NODES                                                      MNE05800
      CCCC = NCOMM                                                      MNE05810
      REWIND 2                                                          MNE05820
      REWIND 3                                                          MNE05830
      REWIND 4                                                          MNE05840
      REWIND 7                                                          MNE05850
      REWIND 8                                                          MNE05860
      REWIND 9                                                          MNE05870
      REWIND 10                                                         MNE05880
      REWIND 11                                                         MNE05890
                                                                        MNE05900
      READ(7,171) NUMGUB                                                MNE05910
      ZERO = 0                                                          MNE05920
      READ(7,121) NODE,COMM,ISUP                                        MNE05930
      DO 420 I = 1,NODES                                                MNE05940
        DO 400 J = 1,NCOMM                                              MNE05950
        IF (NODE .EQ. I) GO TO 390                                      MNE05960
        WRITE(10,121) I,J,ZERO                                          MNE05970
        GO TO 400                                                       MNE05980
390     WRITE(10,121) NODE,COMM,ISUP                                    MNE05990
        READ(7,121,END=430) NODE,COMM,ISUP                              MNE06000
400     CONTINUE                                                        MNE06010
420   CONTINUE                                                          MNE06020
430   REWIND 10                                                         MNE06030
                                                                        MNE06040
      WRITE(8,10)                                                       MNE06050
      WRITE(8,11)                                                       MNE06060
      WRITE(8,12)                                                       MNE06070
10    FORMAT('NAME')                                                    MNE06080
11    FORMAT('ROWS')                                                    MNE06090
12    FORMAT(T2,'N',T5,'OBJ')                                           MNE06100
      WRITE(2,10)                                                       MNE06110
      WRITE(2,11)                                                       MNE06120
      WRITE(2,12)                                                       MNE06130
C                                                                       MNE06140
C-----ROWS SECTION                                                      MNE06150
C     INPUT = TAPES 10 & 4                                              MNE06160
C                                                                       MNE06170
                                                                        MNE06180
7121  READ(10,121,END=20) NODE, COMM,ISUP                               MNE06190
      SUP = ISUP                                                        MNE06200
                                                                        MNE06210
      WRITE(8,15) COMM, NODE, SUP                                       MNE06220
15    FORMAT(T2,'E',T5,'C',T6,I2,T8,'ROW',T11,I2,T62,'NODE',T67,F12.6)  MNE06230
                                                                        MNE06240
CCCC      WRITE(2,16) COMM,NODE                                         MNE06250
CCCC16    FORMAT(T2,'E',T5,'C',T6,I2,T8,'ROW',T11,I2)                   MNE06260
CCCC  K = (COMM-1)*NODES + NODE                                         MNE06270
CCCC      WRITE(2,16) K                                                 MNE06280
CCCC   16 FORMAT(' E  ',I5,'ROW')                                       MNE06290
      K = ROWNUM(NODE,COMM)                                             MNE06300
      ZZ = Z(K)                                                         MNE06310
      WRITE(2,16) ZZ                                                    MNE06320
   16 FORMAT(' E',T5,'ROW',A5)                                          MNE06330
      GO TO 7121                                                        MNE06340
20    CONTINUE                                                          MNE06350
      ICOUNT = 0                                                        MNE06360
      READ(4,106)ROW,ISUP                                               MNE06370
210   CONTINUE                                                          MNE06380
      IF (ICOUNT .EQ. NUMGUB) GO TO 35                                  MNE06390
      SUP = ISUP                                                        MNE06400
      WRITE(8,34) ROW,SUP                                               MNE06410
34    FORMAT(T2,'L',T5,'CAP',T8,I3,T62,'GUB',T67,F12.6)                 MNE06420
                                                                        MNE06430
CCCC      WRITE(2,340) ROW                                              MNE06440
CCCC340   FORMAT(T2,'L',T5,'CAP',T8,I3)                                 MNE06450
CCCC  340 FORMAT(' L  ',I5,'CAP')                                       MNE06460
      ZZ = Z(ROW)                                                       MNE06470
      WRITE(2,340) ZZ                                                   MNE06480
  340 FORMAT(T2,'L',T5,'CAP',A5)                                        MNE06490
      ICOUNT = ICOUNT + 1                                               MNE06500
      READ(4,106) ROW, ISUP                                             MNE06510
      GO TO 210                                                         MNE06520
35    CONTINUE                                                          MNE06530
      REWIND 3                                                          MNE06540
      NROW = 0                                                          MNE06550
      NBND = 0                                                          MNE06560
      WRITE(2,21)                                                       MNE06570
      WRITE(8,21)                                                       MNE06580
21    FORMAT('COLUMNS')                                                 MNE06590
C                                                                       MNE06600
C-----COLUMNS SECTION                                                   MNE06610
C     INPUT = TAPE3                                                     MNE06620
C                                                                       MNE06630
350   READ(3,107) NAME,FROM,TO,COMM,COST,CAP,MUT                        MNE06640
      NROW = NROW + 1                                                   MNE06650
      IF (FROM .EQ. 0) GO TO 40                                         MNE06660
C                                                                       MNE06670
C     NEXT TWO WRITE IS FOR LP INPUT FILE                               MNE06680
C                                                                       MNE06690
CCCC      WRITE(2,70)COMM, NROW, COST, COMM, FROM, ONE                  MNE06700
CCCC70    FORMAT(T5,'X',T6,I2,T8,I3,T15,'OBJ',T25,F12.6,                MNE06710
CCCC     # T40,'C',T41,I2,T43,'ROW',T46,I2,T50,F12.6)                   MNE06720
CCCC      K = (COMM-1)*NODES + FROM                                     MNE06730
CCCC      WRITE(2,70) NROW,COST,K,ONE                                   MNE06740
CCCC   70 FORMAT(T5,I5,'X',T15,'OBJ',T25,F12.6,T40,I5,'ROW',T50,F12.6)  MNE06750
CCCC      K = (COMM-1)*NODES + TO                                       MNE06760
      K = ROWNUM(FROM,COMM)                                             MNE06770
      ZZ = Z(K)                                                         MNE06780
      ZCOL = Z(NROW)                                                    MNE06790
      WRITE(2,70) ZCOL,COST,ZZ,ONE                                      MNE06800
   70 FORMAT(T5,'X',A5,T15,'OBJ',T25,F12.6,T40,'ROW',A5,T50,F12.6)      MNE06810
      K = ROWNUM(TO,COMM)                                               MNE06820
C                                                                       MNE06830
      IF (MUT .NE. 0) GO TO 700                                         MNE06840
CCCC      WRITE(2,30) COMM,NROW,COMM,TO                                 MNE06850
CCCC      WRITE(2,33) NROW,K,ONENEG                                     MNE06860
CCCC   33 FORMAT(T5,I5,'X',T15,I5,'ROW',T25,F12.6)                      MNE06870
      ZZ = Z(K)                                                         MNE06880
      WRITE(2,33) ZCOL,ZZ,ONENEG                                        MNE06890
   33 FORMAT(T5,'X',A5,T15,'ROW',A5,T25,F12.6)                          MNE06900
      GO TO 750                                                         MNE06910
700   CONTINUE                                                          MNE06920
                                                                        MNE06930
CCCC      WRITE(2,75)COMM, NROW, COMM, TO, MUT, ONE                     MNE06940
CCCC75    FORMAT(T5,'X',T6,I2,T8,I3,T15,'C',T16,I2,T18,                 MNE06950
CCCC     # 'ROW',T21,I2,T25,'   -1.0',T40,'CAP',T43,I3,T50,F12.6)       MNE06960
CCCC      WRITE(2,75) NROW,K,ONENEG,MUT,ONE                             MNE06970
CCCC   75 FORMAT(T5,I5,'X',T15,I5,'ROW',T25,F12.6,T40,I5,'CAP',T50,F12.6MNE06980
      ZZ = Z(K)                                                         MNE06990
      ZZZ = Z(MUT)                                                      MNE07000
      WRITE(2,75) ZCOL,ZZ,ONENEG,ZZZ,ONE                                MNE07010
   75 FORMAT(T5,'X',A5,T15,'ROW',A5,T25,F12.6,T40,'CAP',A5,T50,F12.6)   MNE07020
750   CONTINUE                                                          MNE07030
      IF (CAP .LT. 0.0) GO TO 250                                       MNE07040
      NBND = NBND + 1                                                   MNE07050
      WRITE(11,80) NBND,COMM,FROM,TO,NROW,CAP                           MNE07060
80    FORMAT(5I5,F10.2)                                                 MNE07070
C                                                                       MNE07080
C     WRITE 'OBJ' ROW ELEMENT OF THIS COLUMN                            MNE07090
C                                                                       MNE07100
      WRITE(8,25) COMM, NROW, COST, CAP                                 MNE07110
25    FORMAT(T5,'X',T6,I2,T8,I3,T15,'OBJ',T25,F12.6,                    MNE07120
     # T67,F12.6)                                                       MNE07130
      GO TO 280                                                         MNE07140
C                                                                       MNE07150
C     UNCAPACITATED ARC; DON'T PUT BOUNDS IN OBJ ROW ENTRY              MNE07160
C                                                                       MNE07170
250   WRITE(8,26) COMM, NROW, COST                                      MNE07180
26    FORMAT(T5,'X',T6,I2,T8,I3,T15,'OBJ',T25,F12.6)                    MNE07190
280   CONTINUE                                                          MNE07200
C                                                                       MNE07210
C     WRITE 'FROM' NODE DATA IN COLUMNS SECTION                         MNE07220
C                                                                       MNE07230
      WRITE(8,28) COMM,NROW,COMM,FROM                                   MNE07240
28    FORMAT(T5,'X',T6,I2,T8,I3,T15,'C',T16,I2,T18,                     MNE07250
     # 'ROW',T21,I2,T25,'    1.0')                                      MNE07260
C                                                                       MNE07270
C     WRITE 'TO' NODE DATA IN COLUMNS SECTION                           MNE07280
C                                                                       MNE07290
      WRITE(8,30) COMM, NROW, COMM, TO                                  MNE07300
30    FORMAT(T5,'X',T6,I2,T8,I3,T15,'C',T16,I2,T18,                     MNE07310
     # 'ROW',T21,I2,T25,'   -1.0')                                      MNE07320
      IF (MUT .EQ. 0) GO TO 350                                         MNE07330
C                                                                       MNE07340
C     WRITE COLUMN ELEMENT OF MUTUAL CAPACITY ROW                       MNE07350
C                                                                       MNE07360
      WRITE(8,32) COMM, NROW, MUT                                       MNE07370
32    FORMAT(T5,'X',T6,I2,T8,I3,T15,'CAP',T18,I3,                       MNE07380
     # T25,'    1.0')                                                   MNE07390
      GO TO 350                                                         MNE07400
40    CONTINUE                                                          MNE07410
      REWIND 10                                                         MNE07420
      WRITE(2,41)                                                       MNE07430
      WRITE(8,41)                                                       MNE07440
41    FORMAT('RHS')                                                     MNE07450
C                                                                       MNE07460
C-----RHS SECTION -------------------------------------------------     MNE07470
C     INPUT = TAPES 10 & 4                                              MNE07480
C                                                                       MNE07490
42    READ(10,121, END=50) NODE, COMM, ISUP                             MNE07500
      SUP = ISUP                                                        MNE07510
      WRITE(8,45) COMM, NODE, SUP                                       MNE07520
CCCC      WRITE(2,45) COMM,NODE,SUP                                     MNE07530
CCCC45    FORMAT(T5,'RHS',T15,'C',T16,I2,T18,'ROW',T21,I2,T25,F12.6)    MNE07540
CCCC      K = (COMM-1)*NODES + NODE                                     MNE07550
CCCC      WRITE(2,45) K,SUP                                             MNE07560
CCCC   45 FORMAT(T5,'RHS',T15,I5,'ROW',T25,F12.6)                       MNE07570
      K = ROWNUM(NODE,COMM)                                             MNE07580
      ZZ = Z(K)                                                         MNE07590
      WRITE(2,45) ZZ,SUP                                                MNE07600
   45 FORMAT(T5,'RHS',T15,'ROW',A5,T25,F12.6)                           MNE07610
      GO TO 42                                                          MNE07620
50    CONTINUE                                                          MNE07630
      REWIND 4                                                          MNE07640
9121  READ(4,106) ROW,ISUP                                              MNE07650
      IF (ROW .EQ. 0) GO TO 55                                          MNE07660
      SUP = ISUP                                                        MNE07670
      WRITE(8,46) ROW, SUP                                              MNE07680
CCCC  WRITE(2,46) ROW,SUP                                               MNE07690
CCCC46    FORMAT(T5,'RHS',T15,'CAP',T18,I3,T25,F12.6)                   MNE07700
CCCC   46 FORMAT(T5,'RHS',T15,I5,'CAP',T25,F12.6)                       MNE07710
      ZZ = Z(ROW)                                                       MNE07720
      WRITE(2,46) ZZ,SUP                                                MNE07730
   46 FORMAT(T5,'RHS',T15,'CAP',A5,T25,F12.6)                           MNE07740
      GO TO 9121                                                        MNE07750
55    CONTINUE                                                          MNE07760
      WRITE(8,60)                                                       MNE07770
60    FORMAT('ENDATA')                                                  MNE07780
      WRITE(2,601)                                                      MNE07790
601   FORMAT('BOUNDS')                                                  MNE07800
C                                                                       MNE07810
C-----BOUNDS SECTION----------------------------------------------      MNE07820
C     INPUT = TAPE11                                                    MNE07830
C                                                                       MNE07840
      REWIND 11                                                         MNE07850
1180  READ(11,80,END=600) NBND,COMM,FROM,TO,NROW,CAP                    MNE07860
CCCC      WRITE(2,560) COMM, NROW, CAP                                  MNE07870
CCCC560   FORMAT(T2,'UP',T15,'X',T16,I2,T18,I3,T25,F12.6)               MNE07880
CCCC      WRITE(2,560) NROW,CAP                                         MNE07890
CCCC  560 FORMAT(T2,'UP',T15,I5,'X',T25,F12.6)                          MNE07900
      ZZ = Z(NROW)                                                      MNE07910
      WRITE(2,560) ZZ,CAP                                               MNE07920
  560 FORMAT(T2,'UP',T5,'BND',T15,'X',A5,T25,F12.6)                     MNE07930
      GO TO 1180                                                        MNE07940
600   WRITE(2,60)                                                       MNE07950
      WRITE(2,61)BLANK                                                  MNE07960
61    FORMAT(T1,A10)                                                    MNE07970
      RETURN                                                            MNE07980
      END                                                               MNE07990
      FUNCTION ROWNUM(NODE,COMM)                                        MNE08000
C                                                                       MNE08010
C--ROWNUM CALCULATED THE ROW NUMBER FOR A NODE COMMODITY COMBINATION    MNE08020
C                                                                       MNE08030
      COMMON /BLCK1/ NNNN,CCCC                                          MNE08040
      INTEGER NNNN,CCCC,ROWNUM                                          MNE08050
      INTEGER COMM                                                      MNE08060
      ROWNUM = (NODE - 1) * CCCC + COMM                                 MNE08070
      RETURN                                                            MNE08080
      END                                                               MNE08090
      FUNCTION Z(K)                                                     MNE08100
C                                                                       MNE08110
C--Z CONVERTS THE INTEGER K INTO CHARACTER DATA IN Z                    MNE08120
C                                                                       MNE08130
      CHARACTER*1 C(5)                                                  MNE08140
      CHARACTER*5 Z                                                     MNE08150
      INTEGER K                                                         MNE08160
      DO 10 I=1,5                                                       MNE08170
      J = K/10**(5-I)  -  (K/10**(6-I))*10                              MNE08180
      C(I) = CHAR(J + ICHAR('0'))                                       MNE08190
   10 CONTINUE                                                          MNE08200
      WRITE(Z,1001) C                                                   MNE08210
 1001 FORMAT(5A1)                                                       MNE08220
      RETURN                                                            MNE08230
      END                                                               MNE08240
      SUBROUTINE ERRMSG(KEY)                                            MNE08250
C                                                                       MNE08260
C--ERRMSG PROVIDES ERROR MESSAGES                                       MNE08270
C                                                                       MNE08280
      GO TO(10,20,30,40,50),KEY                                         MNE08290
C                                                                       MNE08300
   10 CONTINUE                                                          MNE08310
      WRITE(6,15)                                                       MNE08320
   15 FORMAT(' --ERROR-- INCREASE ZCOMM')                               MNE08330
      STOP 10                                                           MNE08340
C                                                                       MNE08350
   20 CONTINUE                                                          MNE08360
      WRITE(6,25)                                                       MNE08370
   25 FORMAT(' --ERROR-- INCREASE ZNODES')                              MNE08380
      STOP 20                                                           MNE08390
C                                                                       MNE08400
   30 CONTINUE                                                          MNE08410
      WRITE(6,35)                                                       MNE08420
   35 FORMAT(' --ERROR-- CANNOT GENERATE PROBLEM USING THIS DATA',/,    MNE08430
     $ '          PLEASE USE NEW INPUT DATA')                           MNE08440
      STOP 30                                                           MNE08450
C                                                                       MNE08460
   40 CONTINUE                                                          MNE08470
      WRITE(6,35)                                                       MNE08480
      STOP 40                                                           MNE08490
C                                                                       MNE08500
   50 CONTINUE                                                          MNE08510
      WRITE(6,55)                                                       MNE08520
   55 FORMAT(' --ERROR-- SEED CANNOT BE ZERO')                          MNE08530
      STOP 50                                                           MNE08540
      END                                                               MNE08550

