-
Notifications
You must be signed in to change notification settings - Fork 5
/
NARP.FOR
8835 lines (8537 loc) · 235 KB
/
NARP.FOR
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
CMS$OPTIMIZE:'ON:xp'
PROGRAM NARP2020
C**********************************************************************
C This Fortran program was originally developed by Prof. Chanan Singh
C (Texas A&M University) and the Associated Power Analysts, Inc.
C**********************************************************************
C TO COMPILE WITH FTN77 ON PRIME USE:
Cff
C FTN77 NARP.FTN -SI -BIG -INTL -ZEROISE -SAVE -OPTIMIZE
C SEG -LOAD
C LO NARP.BIN
C LI VAPPLB
C LI F77LIB
C LI
C Q
C**********************************************************************
C TO COMPILE ON 486 OR 386/387 PC WITH SALFORD FTN77 USE:
C
C FTN77 NARP/LINK/INTL/SI/SAVE/ZEROISE
C**********************************************************************
C TO COMPILE ON THE 486 OR 386 PC WITH FULL ERROR CHECKING USE:
C
C FTN77 NARPE/SI/INTL/ZEROISE/SAVE/FULLCHECK/B NARPE.OBJ
C FTN77 SEEDER/SI/INTL/ZEROISE/SAVE/B SEEDER.OBJ
C LINK77 <LINKNARP
C
C note: NARPE.FOR is the regular narp program with subroutines SEEDER,
C GSTATE, and LSTATE removed. These subroutines are put in another
C file called SEEDER.FOR. File LINKNARP then has the following data:
C
C LOAD NARPE.OBJ
C LOAD SEEDER.OBJ
C FILE NARPE.EXE
C**********************************************************************
C!MS$DEBUG
INCLUDE "NARPCOM.txt"
INCLUDE 'NARPERC.txt'
WRITE(*,44)
44 FORMAT(15X,'NARP Version - March 3, 1996',/)
C
C CHANGE TO MAKE TU IBM COMPILER WORK
EX4 = ' '
EX2 = ' '
C CHANGE TO MAKE PRIME COMPILER WORK
SSQ=0.
XLAST=0.
IOPN=0
C OPTION ERR INTRODUCED IN OPEN STATEMENTS OF LEEI,INPUTB AND INPUTC
OPEN(UNIT=8,FILE='LEEI',STATUS='OLD',ACCESS='SEQUENTIAL',ERR=100)
OPEN(UNIT=18,FILE='TEMP',STATUS='OLD',ERR=105)
GO TO 200
105 CONTINUE
OPEN(UNIT=18,FILE='TEMP',STATUS='NEW')
GO TO 200
100 WRITE(*,110)
110 FORMAT(15X,'LOAD DATA FILE LEEI DOES NOT EXIST',/
*,15X,'PROGRAM ABORTED',/)
IOPN=IOPN+1
200 CONTINUE
OPEN(UNIT=14,FILE='EXTRA',STATUS='OLD',ACCESS='SEQUENTIAL',ERR=610
*)
GO TO 611
610 CONTINUE
OPEN(UNIT=14,FILE='EXTRA',STATUS='NEW',ACCESS='SEQUENTIAL')
611 CONTINUE
OPEN(UNIT=10,FILE='INPUTB',STATUS='OLD',ACCESS='SEQUENTIAL',ERR=3
*00)
GO TO 400
300 WRITE(*,115)
115 FORMAT(15X,'BASE DATA FILE INPUTB DOES NOT EXIST',/,
*15X,'PROGRAM ABORTED',/)
IOPN=IOPN+1
400 CONTINUE
OPEN(UNIT=11,FILE='INPUTC',STATUS='OLD',ACCESS='SEQUENTIAL',ERR=5
*00)
GO TO 600
500 WRITE(*,120)
120 FORMAT(15X,'CHANGE DATA FILE INPUTC DOES NOT EXIST',/,
*15X,'PROGRAM ABORTED',/)
IOPN=IOPN+1
600 CONTINUE
C REMOVED STATUS='NEW' TO GIVE ADDITIONAL FLEXIBILITY ON O/P FILES...GENE P.
OPEN(UNIT=12,FILE='INTMDT',STATUS='OLD',ACCESS='SEQUENTIAL',ERR=61
*5)
GO TO 616
615 CONTINUE
OPEN(UNIT=12,FILE='INTMDT',STATUS='NEW',ACCESS='SEQUENTIAL')
616 CONTINUE
OPEN(UNIT=9,FILE='DATOUT',STATUS='OLD',ACCESS='SEQUENTIAL',ERR=
*620)
GO TO 621
620 CONTINUE
OPEN(UNIT=9,FILE='DATOUT',STATUS='NEW',ACCESS='SEQUENTIAL')
621 CONTINUE
OPEN(UNIT=16,FILE='OUTPUT',STATUS='OLD',ACCESS='SEQUENTIAL',
*ERR=601)
GO TO 602
C601 WRITE(*,603)
C603 FORMAT(15X,'FILE OUTPUT EXISTS AND CAN NOT BE OVERWRITTEN,',/
C *,15X,'PROGRAM ABORTED.',/)
C GO TO 700
601 CONTINUE
OPEN(UNIT=16,FILE='OUTPUT',STATUS='NEW',ACCESS='SEQUENTIAL')
602 CONTINUE
C OPEN(UNIT=15,FILE='DUMP',STATUS='OLD',FORM='UNFORMATTED',
C *DEFAULTFILE='.BIN', ACCESS='SEQUENTIAL',ERR=800)
OPEN(UNIT=15,FILE='DUMP',STATUS='OLD',FORM='UNFORMATTED',
* ACCESS='SEQUENTIAL',ERR=800)
C IF DUMP EXISTS ASSUME RESTART- C. SINGH DEC 1993
IRST=1
GO TO 850
C IF DUMP DOES NOT EXIST OPEN DUMP AND ASSUME A BASE RUN - C. SINGH DEC 1993
800 IRST=0
OPEN(UNIT=15,FILE='DUMP',STATUS='NEW',FORM='UNFORMATTED',
* ACCESS='SEQUENTIAL')
C OPEN(UNIT=15,FILE='DUMP',STATUS='NEW',FORM='UNFORMATTED',
C *DEFAULTFILE='.BIN', ACCESS='SEQUENTIAL')
850 CONTINUE
C
C
C FOR PRIME USE OPEN THIS STATEMENT FOR FILE 15
C OPEN(UNIT=15,FILE='DUMP',FORM='UNFORMATTED',ACCESS='SEQUENTIAL')
C MOVED THE ABOVE LINE TO THE RSTART AND INTM ROUTINES ... GENE PRESTON
IF(IOPN.NE.0)GO TO 700
NOTIFY = 20
JU = 16
JU1 = 12
JU2 = 10
JU3 = 11
JU4 = 9
NFCST = 1
NOERR = 1
LVLTRC = 0
NHRSYR = 8760
WRITE(*,389)
389 FORMAT(15X,'CALL INITFL',/)
CALL INITFL
CALL DATAF1(JU)
IF(IABORT.NE.0)GO TO 700
IF(IRST.EQ.0)GO TO 362
OPEN(UNIT=13,FILE='TRAOUT',STATUS='OLD',ACCESS='APPEND',ERR=356)
GO TO 361
356 CONTINUE
IF(IOI.EQ.0)GO TO 359
WRITE(*,357)
357 FORMAT(15X,'FOR RESTART TRAOUT DOES NOT EXIST, PROGRAM ABORTED',/)
GO TO 700
362 CONTINUE
OPEN(UNIT=13,FILE='TRAOUT',STATUS='OLD',ACCESS='SEQUENTIAL',
*ERR=359)
GO TO 361
359 CONTINUE
OPEN(UNIT=13,FILE='TRAOUT',STATUS='NEW',ACCESS='SEQUENTIAL')
WRITE(*,351)
351 FORMAT(15X,'FILE TRAOUT DOES NOT EXIST, A NEW FILE OPENED.')
361 CONTINUE
LSTEP = MAXEUE/20
CALL INITL
C CALL ECHOER
C CALL DUMPIT
C DO 20 I=1,100000
C INDUMP(I)=0
C20 CONTINUE
IFIN=FINISH/8760
C LOGIC FOR DUMPING INTERMEDIATE RESULTS CHANGED
C INDUMP ARRAY NO LONGER REQUIRED
C APRIL 1994 -C. SINGH
C INDUMP(IFIN)=1
C IDL=IFIN/INTV
C DO 30 I=1,IDL
C J=I*INTV
C INDUMP(J)=1
C30 CONTINUE
INTVT=INTV
IF(IRST.EQ.0)GO TO 10
CALL RSTART
INTVTT=CLOCK/8760
WRITE(*,66)
66 FORMAT(15x,///,15X,'**WARNING ! THIS IS A RESTART CASE.')
WRITE(*,33)INTVTT
33 FORMAT(15X,'**NUMBER OF PREVIOUS REPLICATIONS : ',I8,/)
10 CONTINUE
CALL CONTRL(RFLAG)
700 CONTINUE
CLOSE(UNIT=16)
C CLOSE REST OF OUTPUT FILES TO PROPERLY PLACE AN EOF MARKER...GENE P. 1/26/89
C CLOSE AND DELETE FILES -C. SINGH DEC 1993
CLOSE(UNIT=9,STATUS='DELETE')
CLOSE(UNIT=12,STATUS='DELETE')
IF(IOI.NE.0)GO TO 950
CLOSE(UNIT=13,STATUS='DELETE')
950 CONTINUE
CLOSE(UNIT=14,STATUS='DELETE')
IF(IREM.NE.0)GO TO 900
CLOSE(UNIT=15,STATUS='DELETE')
900 CONTINUE
STOP
END
BLOCK DATA
INCLUDE 'NARPERC.txt'
C INTEGER*2 MAXHR,MXPLHR,INTCH,LNSTAT,LINENO,MARGIN,LNCAP,NLINES
C MOVED TO ERCCOM TO ELIMINATE COMMON BLOCK MISALIGNMENT ERROR ... GENE 1/26/89
DATA PLNDST /600*1.0/
DATA CADJ /20*0.0/
DATA SADJ /20*0.0/
DATA LSFLG/20*0/
DATA BLPA /1800*0.0/
DATA SUSTAT /96*0.0/
DATA LOLTHA,LOLGHA,MGNTHA,MGNGHA,LOLTPA,LOLGPA,MGNTPA,MGNGPA
@/800 * 0/
DATA LOLTHP,LOLGHP,MGNTHP,MGNGHP,LOLTPP,LOLGPP,MGNTPP,MGNGPP
@/40 * 0/
DATA SOLTHA,SOLGHA,SGNTHA,SGNGHA,SOLTPA,SOLGPA,SGNTPA,SGNGPA
@,SOLSHA,SGNSHA,SOLSPA,SGNSPA/1200 * 0.0/
DATA SOLTHP,SOLGHP,SGNTHP,SGNGHP,SOLTPP,SOLGPP,SGNTPP,SGNGPP
@,SOLSHP,SGNSHP,SOLSPP,SGNSPP/60 * 0.0/
DATA HLOLE,DPLOLE,EUES/1320*0.0/
DATA XNEWA,XNEWP,SSQA,SSQP/126*0.0/
C ADDED THE FOLLOWING LINE ... GENE PRESTON
DATA WOLSHA/20*0./
END
SUBROUTINE INITL
C:::::LAST UPDATE: 6/22/88
INCLUDE 'NARPERC.txt'
C WRITE (16,1000)
C1000 FORMAT (/,' ',' ENTERING SUBROUT. INITL',/)
CLOCK = 0.0
C......BEGIN YEAR IN FIRST QUARTER......................................
JQRTR = 1
C......INITIALIZE FLAGS.................................................
LSSFLG = 0.0
SFLAG = 1.0
C......SCHEDULE ALL QUARTERLY STATE CHANGES.............................
ATRIB(2) = 3.0
ATRIB(1) = 0.5
CALL FILEM
ATRIB(2) = 3.0
ATRIB(1) = QTR(1)
CALL FILEM
ATRIB(1) = QTR(2)
CALL FILEM
ATRIB(1) = QTR(3)
CALL FILEM
C...DO NOT PUT ANYTHING BETWEEN THESE TWO FILEM CALLS. NEED THE 8760.
C.....SCHEDULE FIRST CALL TO YEAR
ATRIB(1) = 8760.
ATRIB(2) = 4.
CALL FILEM
C......SCHEDULE FIRST CALL TO SBRTNE WEEK TO SCHEDULE PLANNED OUTAGE....
ATRIB(1) = 0.5
ATRIB(2) = 2.0
CALL FILEM
C......SCHEDULE FIRST MONTE CARLO DRAW..................................
ATRIB(2) = 1.0
CC ATRIB(1) = DFLOAT(JSTEP)
ATRIB(1) = JSTEP
CALL FILEM
RETURN
END
SUBROUTINE DUMPIT
INCLUDE 'NARPERC.txt'
WRITE(16,*)
WRITE(16,*) ' AREA LSFLAG MARGIN CADJ CAPREQ SADJ',
@ ' SYSCON SYSOWN TRNSFR'
WRITE(16,*) ' ---- ------ ------ ---- ------ ----',
@ ' ------ ------ ------'
DO 10 J = 1, NOAREA
10 WRITE(16,1010) J,LSFLG(J),MARGIN(J),CADJ(J),CAPREQ(J),SADJ(J),
@ SYSCON(J),SYSOWN(J),TRNSFR(J)
1010 FORMAT(3X,I2,4X,I1,2X,I6,4X,6X,F5.2,5(2X,F5.2))
WRITE(16,*)
WRITE(16,*) ' UNIT CLASS JNTOWN AVAIL DERATE PCTAVL PLNDST',
@ ' RATING RANDG'
WRITE(16,*) ' ---- ----- ------ ----- ------ ------ ------',
@ ' ------ -----'
DO 20 J = 1, NUNITS
20 WRITE(16,1020) J,ICLASS(J),JNTOWN(J),AVAIL(J),DERATE(J),
@ PCTAVL(J),PLNDST(J),RATING(J),RANDG(J)
1020 FORMAT(2X,I3,3X,I2,3X,I2,6X,4(2X,F5.2),2X,F7.2,2X,F6.4)
WRITE(16,*)
WRITE(16,*)' LINE LNCAP LNSTAT RANDL'
WRITE(16,*)' ---- ----- ------ -----'
DO 30 L = 1, NLINES
30 WRITE(16,1030) L,LNCAP(L),LNSTAT(L),RANDL(L)
1030 FORMAT(3X,I2,2X,I4,3X,I2,3X,F5.4)
RETURN
END
SUBROUTINE ECHOER
C LAST UPDATE: 07/09/88 PJW
INCLUDE 'NARPERC.txt'
WRITE(16,*) ' PEAK LOADS'
WRITE(16,*) ' -------------------------------------------'
WRITE(16,1000) (PKLOAD(J),J=1,NOAREA)
WRITE(16,*) ' -------------------------------------------'
1000 FORMAT( (5X,F12.4))
WRITE(16,*)
WRITE(16,*) ' UNIT RATING DERATED CLASS',
@ ' PLANNED OUTAGES'
WRITE(16,*) ' ---- ------ ------- -----',
@ ' ------------------------------'
DO 10 I=1,NUNITS
10 WRITE(16,1002) I,RATING(I),DERATE(I),ICLASS(I),(IDATES(I,K),
@ K=1,4)
1002 FORMAT(6X,I3,2X,2X,F6.1,2X,F6.1,6X,I1,4(1X,I7))
WRITE(16,*)
WRITE(16,*) ' WEEKLY SCHEDULE OF PLANNED OUTAGES'
WRITE(16,*) ' ----------------------------------'
DO 20 I=1,52
20 WRITE(16,1003) I,(JPLOUT(I,J),J=1,30)
1003 FORMAT(5X,I2,3X,30I4)
WRITE(16,*)
WRITE(16,*) ' UNIT TRANSITIONS QUARTERLY RATINGS'
WRITE(16,*) ' ---- ----------- -----------------',
@ '--------------------'
DO 25 I=1,NUNITS
25 WRITE(16,1004) I,(PROBG(I,J),J=1,2),(RATES(I,N),N=1,4)
1004 FORMAT(5X,I3,5X,2(2X,F6.4),5X,4(2X,F6.1))
WRITE(16,*)
WRITE(16,*) ' LINE PROBABILITIES'
WRITE(16,*) ' ------------------'
WRITE(16,1005) (PROBL(K,1), K = 1,5)
1005 FORMAT(5(3X,F6.4),/,/)
WRITE(16,*) ' DAILY SCHEDULE OF PEAK LOADS'
WRITE(16,*) ' ----------------------------'
DO 30 I=1,365
30 WRITE(16,1006) I,(DYLOAD(J,I),J=1,3)
1006 FORMAT(5X,I3,3(4X,F16.2))
WRITE(16,*)
WRITE(16,*) ' HOURLY LOADS'
WRITE(16,*) '--------------------------------------------'
DO 40 I = 1, 8760, 24
40 WRITE(16,1007) I, (HRLOAD(1,M),M=I,I+23)
1007 FORMAT(2X,I4,8(1X,F6.0),/,2(6X,8(1X,F6.0),/))
RETURN
END
C!MS$NODEBUG
SUBROUTINE SEEDER
C:::::LAST UPDATE: 6/18/88
INCLUDE 'NARPERC.txt'
C.......................................................................
C
C......Each Generator and Each Transmission Line has a dedicated Random
C Number Seed. We assert those seeds in this Subrout. A User
C Defined Global Seed (JSEED) initiates this process
C
C......Draw a Random Number for Each Generator..........................
C%%% WRITE (16,1000)
C1000 FORMAT(/,' ', 'ENTERING SUBROUTNE SEEDER',/)
IGSEED(1) = JSEED
DO 10 I = 1, NUNITS
IGSEED(I) = IGSEED(I) * 9649599
IF (IGSEED(I) .LT. 0) THEN
IGSEED(I) = IGSEED(I) + 2147483647
IGSEED(I)=IGSEED(I)+1
END IF
J = I + 1
IGSEED(J) = IGSEED(I)
C! WRITE (16,1010) I, IGSEED(J)
C 1010 FORMAT(5X,I3,5X,I12)
10 CONTINUE
C......Continue, Seeding Lines..........................................
ILSEED(1) = IGSEED(NUNITS)
DO 20 I = 1, NLINES
ILSEED(I) = ILSEED(I) * 9649599
IF (ILSEED(I) .LT. 0) THEN
ILSEED(I) = ILSEED(I) + 2147483647
ILSEED(I) = ILSEED(I) + 1
END IF
J = I + 1
ILSEED(J) = ILSEED(I)
C! WRITE(16,1010) I, ILSEED(J)
20 CONTINUE
RETURN
END
SUBROUTINE GSTATE
C:::::LAST UPDATE: 6/18/88
INCLUDE 'NARPERC.txt'
INCLUDE 'NARPCOM.txt'
C.......................................................................
C GSTATE determines the available capacity for each
C generator ... up to NUNITS ...
C It uses In-Line Code for the Pseudo_Random_
C Number_Generator
C.......................................................................
C WRITE(*,1000) NUNITS
C1000 FORMAT(/,' ','ENTERING SUBROUTNE GSTATE, THE # OF UNITS IS',I4)
C......Draw a random number for each unit...............................
DO 10 I = 1, NUNITS
IGSEED(I) = IGSEED(I) * 65539
IF (IGSEED(I) .LT. 0) THEN
IGSEED(I) = IGSEED(I) + 2147483647
IGSEED(I) = IGSEED(I) + 1
END IF
YFL = FLOAT(IGSEED(I))
YFL = YFL * .4656613E-9
RANDG(I) = YFL
C WRITE(*,11)YFL
C 11 FORMAT(10X,F8.6)
10 CONTINUE
C......Determine the State and Available Capacity for Each Generator....
DO 20 I = 1, NUNITS
IF (RANDG(I) .LT. PROBG(I,1)) THEN
PCTAVL(I) = 1.0
ELSE IF (RANDG(I) .LT. PROBG(I,2)) THEN
PCTAVL(I) = DERATE(I)
ELSE
PCTAVL(I) = 0.0
C IF (I.EQ.1) WRITE(*,*)'UNIT 1, AREA 1 FAILED'
C IF (I.EQ.2) WRITE(*,*)'UNIT 2, AREA 1 FAILED'
C IF (I.EQ.33) WRITE(*,*)'UNIT 1, AREA 2 FAILED'
ENDIF
AVAIL(I) = PCTAVL(I) * RATING(I) * PLNDST(I)
20 CONTINUE
C%%% set trace ......................................................
CH
C IF (CLOCK.EQ.43810.) THEN
C IF (LVLTRC .GE. 1) THEN
C IF(JHOUR.EQ.755) THEN
C WRITE(*,1029) JHOUR,CLOCK
C1029 FORMAT(/' HOUR =',I5,' CLOCK =',F12.0)
C WRITE(*,*) ' UNIT RANDOM PROBABILITIES PLAN PCT',
C @ ' RATING AVAIL'
C WRITE(*,*) ' ---- ----- ------ ------------- ---- ---',
C @ ' ------ -----'
C DO 30 I = 1, NUNITS
C IJ=' '
C IF(PLNDST(I).EQ.0.) IJ='MAIN'
C WRITE(*,1030) I,NAMU(I),NUMP(I),RANDG(I),(PROBG(I,J),J=1,2),
C @ PLNDST(I),PCTAVL(I),RATING(I),AVAIL(I),IJ
C1030 FORMAT(I5,1X,A4,A2,2X,F5.4,2(2X,F6.4),2X,F4.2,3X,F4.2,3X,F6.1,2X,
C 1 F9.1,2X,A4)
C 30 CONTINUE
C END IF
CH
RETURN
END
SUBROUTINE LSTATE
C:::::LAST UPDATE: 6/18/88
INCLUDE 'NARPERC.txt'
C.......................................................................
C
C LSTATE establishes the STATUS for each line.
C It uses In-Line Code for the Pseudo_Random_
C Number_Generator
C.......................................................................
C WRITE(*,1000)
C1000 FORMAT(/,' ','ENTERING SUBROUTNE LSTATE')
C......Draw a random number for each line...............................
DO 10 I = 1, NLINES
ILSEED(I) = ILSEED(I) * 65539
IF (ILSEED(I) .LT. 0) THEN
ILSEED(I) = ILSEED(I) + 2147483647
ILSEED(I) = ILSEED(I) + 1
END IF
C WRITE(*,*)I,ILSEED(I)
YFL = FLOAT(ILSEED(I))
C WRITE(*,*)I,YFL
YFL = YFL * .4656613E-9
C WRITE(*,*)I,YFL
RANDL(I) = YFL
10 CONTINUE
C......Determine the STATUS of each line................................
DO 20 I = 1, NLINES
IF (RANDL(I) .LE. PROBL(1,I)) THEN
LNSTAT(I) = 1
ELSE IF (RANDL(I) .LE. PROBL(2,I)) THEN
LNSTAT(I) = 2
ELSE IF (RANDL(I) .LE. PROBL(3,I)) THEN
LNSTAT(I) = 3
ELSE IF (RANDL(I) .LE. PROBL(4,I)) THEN
LNSTAT(I) = 4
ELSE IF (RANDL(I) .LE. PROBL(5,I)) THEN
LNSTAT(I) = 5
ELSE
LNSTAT(I) = 6
ENDIF
C WRITE(*,1020) I,LNSTAT(I)
C1020 FORMAT (' ','LINE =',I3,' STATE =',I2)
20 CONTINUE
RETURN
END
C!MS$DEBUG
SUBROUTINE INITFL
C::::::LAST UPDATE: 6/18/88
INCLUDE 'NARPERC.txt'
C%%% WRITE (16,1000)
C1000 FORMAT(/,' ',' ENTERING SUBROUTNE INITFL ')
C......Initialize Pointers into EVNTS Array.............................
MFA = 1
IPOINT = 0
MXCELL = 100
N = MXCELL - 1
DO 10 I = 1, MXCELL
EVNTS(I) = 0.0
10 CONTINUE
DO 20 I = 1, N, 4
J = I + 4
EVNTS(I) = J
20 CONTINUE
C! DO 30 I = 1, 100, 4
C! WRITE(16,1030) I,(EVNTS(J),J=I,I+3)
C!1030 FORMAT(5X,I4,4(5X,F10.0))
C! 30 CONTINUE
RETURN
END
SUBROUTINE FILEM
C:::::LAST UPDATE: 6/27/88
INCLUDE 'NARPERC.txt'
C.....PLACE DATA INTO ARRAY EVNTS.......................................
C%%% WRITE(16,1000) ATRIB(1), ATRIB(2)
C1000 FORMAT (/,' ',' FILING EVENT; ATRIB VECTOR IS ',(2F12.2),/)
C .....PRINT ARRAR EVNTS
C WRITE(16,5)IPOINT
C 5 FORMAT(10X,'CONTENTS OF ARRAY EVNTS',/,10X,'IPOINT = ',I4,/)
K = 0
NEW = MFA
EVNTS(NEW+1) = ATRIB(1)
EVNTS(NEW+2) = ATRIB(2)
NUMINQ = NUMINQ + 1
C WRITE(16,1001) IPOINT,MFA,NUMINQ
C1001 FORMAT(' ',' IPOINT = ',I3,' MFA = ',I3,' NUMINQ = ',I3)
C.....REDEFINE FIRST AVAILABLE ENTRY....................................
MFA = EVNTS(MFA)
C100 IF (IPOINT .GT. 0) THEN THE 100 IS NOT USED ... GENE P. 1/26/89
IF (IPOINT .GT. 0) THEN
GOTO 110
END IF
C.....FILE 1 IS EMPTY, SET FIRST POINTER TO NEW ENTRY, SUCCESSOR TO 0...
IPOINT = NEW
EVNTS(NEW) = 0
C WRITE(16,1002) IPOINT, MFA, NEW
C1002 FORMAT(' ','EVNTS ARRAY IS EMPTY, FILING FIRST ENTRY',/,
C @ 'IPOINT = ',I3,' MFA = ',I3,' NEW = ',I3)
RETURN
C.....FILE 1 CONTAINS ENTRIES, SYNCHRONIZE..............................
110 J = IPOINT
IF (ATRIB(1) .GT. EVNTS(J+1)) THEN
GOTO 115
END IF
C.....NEW ENTRY BECOMES FIRST ENTRY,....................................
C.....RESET FIRST POINTER AND DEFINE SUCCESSOR..........................
IPOINT = NEW
EVNTS(NEW) = J
C DO 11 I=1,50
C WRITE(16,20)EVNTS(I)
C 11 CONTINUE
C 20 FORMAT(5X,F10.2)
C WRITE(16,5)IPOINT
RETURN
C......NEW ENTRY GOES INTO MIDDLE OF FILE...............................
115 K = J
J = EVNTS(J)
IF (J .EQ. 0) THEN
GO TO 120
END IF
IF (ATRIB(1) .GT. EVNTS(J+1)) THEN
GO TO 115
END IF
C.....FILE INTO MIDDLE - SET SUCCESSOR POINTER..........................
EVNTS(NEW) = J
C.....SET PREDECESSOR'S SUCCESSOR POINTER...............................
EVNTS(K) = NEW
C DO 12 I=1,50
C WRITE(16,20)EVNTS(I)
C 12 CONTINUE
C WRITE(16,5)IPOINT
RETURN
C.....NEW ENTRY BECOMES LAST IN FILE....................................
120 EVNTS(K) = NEW
EVNTS(NEW)=0
C DO 13 I=1,50
C WRITE(16,20)EVNTS(I)
C 13 CONTINUE
C WRITE(16,5)IPOINT
RETURN
END
SUBROUTINE REMOVE
C:::::LAST UPDATE: 6/18/88
INCLUDE 'NARPERC.txt'
C%%% WRITE(16,1000)
C1000 FORMAT(/,' ',' REMOVING EVENT FROM EVENT LIST',/)
IF (NUMINQ .LE. 0) THEN
WRITE(16,1001)
1001 FORMAT(' ','ERROR IN REMOVE, EVENTS LIST IS EMPTY')
STOP
END IF
C......REMOVE ENTRY FROM EVNTS ARRAY ...................................
ATRIB(1) = EVNTS(IPOINT + 1)
ATRIB(2) = EVNTS(IPOINT + 2)
C%%% WRITE(16,1009) ATRIB(1), ATRIB(2)
C1009 FORMAT(' ', 'ATRIB VECTOR IS: ',2F12.2)
NUMBER = ATRIB(2)
NUMINQ = NUMINQ - 1
C......UPDATE FILE POINTERS...FIRST UPDATE MFA..........................
MFA = IPOINT
EVNTS(IPOINT + 1) = 0.
EVNTS(IPOINT + 2) = 0.
C......FIRST POSITION POINTER..ITEM ALWAYS REMOVED FROM FIRST POSITION
IPOINT = EVNTS(IPOINT)
C WRITE(16,1010) IPOINT, NUMINQ
C1010 FORMAT(' ',' IPOINT = ',I3,' NUMINQ = ',I3)
RETURN
END
SUBROUTINE CONTRL(RFLAG)
C:::::LAST UPDATE: 6/16/88
INCLUDE 'NARPERC.txt'
C%%% WRITE(16,1000)
C1000 FORMAT (/,' ',' ::::::::::::::::: IN CONTRL :::::::::::::::::'/,/)
C......PULLS THE NEXT EVENT FROM FILE AND CHECKS TIME. EVENTS IS CALLED.
C......UNLESS END OF SIMULATION IS REACHED, THEN REPORT IS CALLED.......
10 IF (IPOINT .EQ. 0) THEN
WRITE(16,1001)
1001 FORMAT(/,' ',' ERROR: POINTER TO EVENT FILE IS 0 AND CONTROL',
+ ' HAS BEEN CALLED')
C WRITE (16,1109)
C1109 FORMAT(/,/,' ','ECHO CHECKING EVENTS ARRAY',/,/)
C DO 88 I = 1, 100, 4
C 88 WRITE(16,1188) (EVNTS(J),J = I, I+3)
C1188 FORMAT(4(5X,F7.2))
RETURN
END IF
IF (CLOCK .GT. EVNTS(IPOINT+1)) THEN
WRITE(16,1010) ATRIB(1), ATRIB(2)
1010 FORMAT(' ','ERROR: NEXT EVENT TO OCCUR SCHEDULED PRIOR TO ',
+ 'CURRENT TIME. ',/,5X,'ATRIB VECTOR IS ',2(F12.2,5X))
WRITE (16,1020) EVNTS(IPOINT+1),EVNTS(IPOINT+2)
1020 FORMAT(' ','PENDING EVENTS ATRIB VECTOR IS ',2(F12.2,5X))
RETURN
ELSE
CONTINUE
END IF
IF(RFLAG.EQ.1.0) THEN
RETURN
ELSE
CONTINUE
END IF
IF (EVNTS(IPOINT+1) .GT. (FINISH+1.0)) THEN
IYEAR = CLOCK/8760.D0
CALL REPORT(IYEAR)
RETURN
ELSE
CALL REMOVE
CLOCK = ATRIB(1)
NUMBER = ATRIB(2)
C WRITE(16,1002) CLOCK,NUMBER
C1002 FORMAT(' ',' SIMULATION CLOCK UPDATED TO: ',F12.0,/,
C + ' ',' FOR EVENT TYPE: ',I2)
CALL EVENTS(NUMBER,RFLAG)
CH CALL EVENTS
END IF
GO TO 10
END
SUBROUTINE EVENTS(NUMBER,RFLAG)
CH SUBROUTINE EVENTS
INCLUDE 'NARPERC.txt'
C::::::LAST UPDATE: 6/18/88
DATA IERR /0/
C%%% WRITE(16,1000) NUMBER
C1000 FORMAT(/,' ',' EVENTS CALLED WITH ARGUMENT = ',I2)
GO TO (1,2,3,4) NUMBER
1 CALL HOUR
JHOUR=JHOURT
RETURN
2 CALL WEEK
RETURN
3 CALL QUARTR
RETURN
4 CALL YEAR(IERR,RFLAG)
IF (IERR.EQ.1) WRITE(*,*) 'ERROR IN SUBROUTINE YEAR'
RETURN
END
SUBROUTINE WEEK
C:::::LAST UPDATE: 7/06/88
INCLUDE 'NARPERC.txt'
C%%% WRITE (16,1000)
C1000 FORMAT (' ','SUBROUTNE WEEK CALLED')
ATRIB(1) = CLOCK + 168
CALL FILEM
DO 10 I = 1, NUNITS
PLNDST(I) = 1.0
10 CONTINUE
JWEEK = JHOUR/168 + 1
C WRITE(*,*)JWEEK,JHOUR
IF(JWEEK.GT.52)RETURN
MT=JPLOUT(JWEEK,1)+1
IF (MT.EQ.1) RETURN
C WRITE(16,*)
C WRITE(16,*)' SCHEDULED OUT THIS WEEK '
C WRITE(16,*)' ================================================'
C WRITE (16,1010) JWEEK,(JPLOUT(JWEEK,M),M=2,MT)
C1010 FORMAT (' WEEK ',I3,5X,12(I2,2X))
DO 20 M = 2,MT
J = JPLOUT(JWEEK,M)
PLNDST(J) = 0.0
20 CONTINUE
RETURN
END
SUBROUTINE FINDLD(NFACT)
C:::::LAST UPDATE: 6/18/88
INCLUDE 'NARPERC.txt'
C WRITE(*,1000) JDAY
C1000 FORMAT (/,' ','ENTERING SUBROUTNE FINDLD, JDAY =',I4)
C WRITE(*,*)JHOUR,JDAY
C......NFACT IS THE NUMBER OF THE FORECAST ERROR FACTOR TO BE USED......
C......CAPREQ(J) IS PASSED TO TRANSMISSION MODULE.......................
DO 10 J = 1, NOAREA
C IF (NFACT.GT.1) THEN
C WRITE(*,1010) J,HRLOAD(J,JHOUR),PKLOAD(J),FCTERR(J,NFACT)
C1010 FORMAT (' ','FOR AREA ',I2,' HRLOAD = ',F7.5,' PKLOAD =',
C @ F6.0,' FCTERR = ',F6.2)
C ENDIF
CAPREQ(J) = HRLOAD(J,JHOUR) * FCTERR(J,NFACT)
10 CONTINUE
C WRITE (16,1001) CLOCK
C1001 FORMAT(' ',' AT TIME: ',F12.2)
DO 20 J = 1, NOAREA
IF (NFACT.GT.1) THEN
C WRITE(16,1002) J, CAPREQ(J)
ENDIF
C1002 FORMAT(' ',' CAPACITY REQUIRED FOR AREA ',I2,' = ',F12.4)
20 CONTINUE
RETURN
END
SUBROUTINE FINDTN
C:::::LAST UPDATE: 6/18/88
INCLUDE 'NARPERC.txt'
C WRITE(16,1000)
C1000 FORMAT(/,' ',' ENTERING SUBROUTNE FINDTN')
C......INTCH IS MATRIX OF CONTRACT INTERCHANGES.........................
C......JENT IS POINTER IDENTIFYING INVOLVED AREAS.......................
C......TRNSFR STORES NET TRANSFER TO (FROM) REST OF POOL................
C......TRANSFERS TREATED AS FROM HIGHER TO LOWER AREA NUMBER...........
DO 5 I=1,NOAREA
TRNSFR(I)=0.
5 CONTINUE
DO 10 J2 = 1, NOAREA
DO 10 J1 = 1, NOAREA
IF (JENT(J1,J2) .GT. 0) THEN
JPOINT = JENT(J1,J2)
TRNSFR(J1) =TRNSFR(J1)+INTCH(JPOINT,JDAY)
TRNSFR(J2) =TRNSFR(J2)-INTCH(JPOINT,JDAY)
END IF
10 CONTINUE
C DO 20 J = 1, NOAREA
C WRITE(*,1001) J, TRNSFR(J)
C1001 FORMAT(' ',' AREA: ',I2,' TRANSFER: ',F12.2)
C 20 CONTINUE
RETURN
END
SUBROUTINE QUARTR
INCLUDE 'NARPERC.txt'
DATA IQ/0/
C IQ = 1
IQ = IQ + 1
C WRITE(*,1000)IQ
C 1000 FORMAT (' ','ENTERING SUBROUTNE QUARTR',I2)
IF (IQ .EQ. 5) IQ = 1
DO 5 I = 1, NOAREA
SUMAR4= 0.0
SUMAR3= 0.0
SUMAR2= 0.0
SUMAR1= 0.0
DO 4 J = 1, NOGEN(I)
SUMAR4 = SUMAR4 + RATES(J,4)
SUMAR3 = SUMAR3 + RATES(J,3)
SUMAR2 = SUMAR2 + RATES(J,2)
4 SUMAR1 = SUMAR1 + RATES(J,1)
C WRITE(*,6) SUMAR1,SUMAR2,SUMAR3,SUMAR4
5 CONTINUE
C 6 FORMAT(' ',' AREA RATINGS =',4(F7.1,1X))
DO 10 I = 1, NUNITS
RATING(I) = RATES(I,IQ)
10 CONTINUE
C WRITE(*,1001) CLOCK
1001 FORMAT(' ',' AT TIME: ',F12.2,' QRTRLY RATING CHANGE COMPLETED')
CC ATRIB(1) = CLOCK + DFLOAT(NHRSYR)
ATRIB(1) = CLOCK + NHRSYR
CALL FILEM
RETURN
END
SUBROUTINE HOUR
C:::::LAST UPDATE: 6/30/88
INCLUDE 'NARPERC.txt'
DIMENSION LOAD(20)
DOUBLE PRECISION DXX
DATA IFLAG,JFLAG /0,0/
C.......................................................................
CC ATRIB(1) = CLOCK + DFLOAT(JSTEP)
ATRIB(1) = CLOCK + JSTEP
CALL FILEM
C WRITE(*,1000)
C1000 FORMAT(/,' ', 'ENTERING SUBROUTNE HOUR')
C......UPDATE HOUR NUMBER...............................................
C XX = FLOAT(NHRSYR)
DXX = 8760.
JHOUR = DMOD(CLOCK,DXX)
IF(JHOUR.EQ.0)JHOUR=8760
JJ = MOD(JHOUR,JFREQ)
CH .......
C JDAY = JHOUR/24+1
JDAY = (JHOUR-.1)/24 + 1
IF (JDAY.GT.365) JDAY = 365
CH .......
JHOURT=JHOUR
IF(JSTEP.EQ.24)JHOUR=MXPLHR(JDAY)
C WRITE(*,*)JHOUR,MXPLHR(JDAY)
C......DRAW GENERATOR STATUSES AND SUM CAPACITIES BY AREA...............
C IF (MOD(JHOUR,1000).EQ.0) WRITE(*,5533) CLOCK
C5533 FORMAT(' ','IN HOUR AT TIME ',F8.0)
CH .......
IF(JJ.EQ.0)JJ=1
IF (JJ.EQ.1. OR . JFREQ.EQ.1) THEN
CALL GSTATE
CALL SUMCAP
CALL LSTATE
CALLS = 0.
CALL FINDTN
ENDIF
C STMULT(I,1) IS FORWARD DIRECTION ADJUSTMENT
C STMULT(I,2) IS BACKWARD DIRECTION ADJUSTMENT
DO 22 I=1,NLINES
DO 22 J=1,2