-
Notifications
You must be signed in to change notification settings - Fork 1
/
bench_mod1erro.f
2478 lines (2464 loc) · 156 KB
/
bench_mod1erro.f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
C=====Main Programme
C=====First layer subroutines used: DATSIM, DECAL, PSHOCK, UPDAT, EXO
C=====Delated subroutines: LIMHVV,LIMVV,LIMLVV,XPN,YLOG,QRSOLV,LMPAR,
C=========================LMDIF,FDJAC2,PRINTX,WORJAC,SUBCHX
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
CHARACTER*8 NAME, IXOG
LOGICAL LFIX2
COMMON/ALPHA/ NAME(300), IXOG(600)
COMMON/L2/E(300,300), X(600,300), ER(300,300),
1 ERX(600,300), EE(300,300), XX(600,300)
COMMON/HELEN/F(300),A(600),BA(300),JX(10),VX(10),
1 KAG,MAG,NDOG,LEXOG,IPAR,IRAND,B,NSTART,ITMX,PX,P,TOL,TOLR,BR
2,PR,NPER,NSK,IJX,IPER,IDATE,NEGP,T,IOPT,IDYN,ITR,NARG,BSTEP,MAXITR
3,NXGP,NCG,IDYN1,IRANDX,IB,IRHO
COMMON/BASDAT/ XB(600,300)
COMMON/KGROUP/KK(41)/JGROUP/JJ(41)
COMMON/WOREQN/IBLOC,NCONV,NBLOC
COMMON/NEWCAL/NEN(100),NEX(100),NENH(100),NEXP,MXEH,IOPTT,IOPTB,
1IOPTC
COMMON/SIMDIM/NAG,LPER,MAXE,MAXX,MAXP
COMMON/FIX2/ LFIX2, NFIX2, LDOFIX, NFIXMX, NFIXEND
COMMON/SHK/err(10,1000)
COMMON/TERMCF/term_coef(2,4)
open(unit=14,file='qerror',status='old')
do 2001 j=1,147
READ(14,*)(ERR(I,j),I=1,10)
2001 continue
open(17,file='term_coef',status='old')
do 7001 i=1,2
read (17,*)term_coef(i,:)
7001 continue
C=====Step 1: Read in the bench data
NAG=0
C===== KEX=0
MAXE=300
MAXX=300
LPER=200
MAXP=NAG+LPER
NG=NEGP+NXGP
C=====1st row of the bench_data files
READ(5,15) NEGP,NXGP,NPER,LAG,NSTART,ITMX,IB,NCG,IRAND
1,NSK,IJX,IOPT,IDYN,IDYN1,NBLOC,IRANDX,IOPTDA,NIT,IOPTAC
C=====2nd row of the bench_data files
READ(5,15)(KK(I+1),I=1,NG)
READ(5,15)(JJ(I+1),I=1,NCG), IRHO
JJ(1)=0
KK(1)=0
DO 1 I=1,NEGP
1 KK(I+1)=KK(I+1)+KK(I)
NDOG=KK(NEGP+1)
KK(NEGP+1)=0
DO 2 I=1,NXGP
2 KK(NEGP+I+1)=KK(NEGP+I+1)+KK(NEGP+I)
LEXOG=KK(NEGP+NXGP+1)
C=====3rd row of the bench_data files
DO 3 I=1,NCG
3 JJ(I+1)=JJ(I+1)+JJ(I)
IPAR=JJ(NCG+1)
C=====4th row of the bench_data files
READ(5,21) PX,P,TOL,B,BR,PR,T
C=====5th row of the bench_data files
IF(IDYN.GT.0) READ(5,23) NARG,MAXITR,BSTEP,TOLR,IOPTC,IOPTB,
> IOPTT, LDOFIX
23 FORMAT(I8,I8,F4.0,F8.0,4I4)
IF(NSK.NE.0) CALL PSHOCK
MAG=LAG+1
KAG=LAG+NPER
C=====Step 2: Write the information to the console(output.out)
WRITE(6,30)
30 FORMAT(1H1,130(1H*)/,59X,'PROGRAM SIMM',/,1X,130(1H*)//)
WRITE(6,20)
WRITE(6,19) NDOG,LEXOG,NPER,LAG,NSTART,ITMX,IB,IPAR,IRAND,
1NSK,IJX,IOPT,IDYN,IDYN1,NBLOC,NARG,IRANDX,IOPTDA,NIT,IOPTAC
WRITE(6,22) PX,P,TOL,B,BR,PR,T,BSTEP,TOLR,MAXITR,IOPTC,IOPTB,
> IOPTT, LDOFIX
IF((NDOG.GT.MAXE).OR.(LEXOG.GT.MAXX)) WRITE(6,10)
IF(LAG.GT.NAG) WRITE(6,11)
IF(NPER.GT.LPER) WRITE(6,12)
10 FORMAT(46H VARIABLE DIMENSIONS EXCEED MAXIMUM DIMENSIONS)
11 FORMAT(50H SPECIFIED NUMBER OF LAGS EXCEED ALLOWABLE MAXIMUM)
12 FORMAT(52H SPECIFIED FORECAST PERIOD EXCEEDS ALLOWABLE MAXIMUM)
15 FORMAT(20I4)
21 FORMAT(20F4.0)
16 FORMAT(16H END OF FORECAST)
19 FORMAT(10X,'NDOG =',I4/10X,'LEXOG =',I4/10X,'NPER =',I4/
110X,'LAG =',I4/10X,'NSTART =',I4/10X,'ITMX =',I4/
210X,'IB =',I4/10X,'IPAR =',I4/10X,'IRAND =',I4/
310X,'NSK =',I4/10X,'IJX =',I4/10X,'IOPT =',I4/
410X,'IDYN =',I4/10X,'IDYN1 =',I4/10X,'IBLOC =',I4/
510X,'NARG =',I5/10X,'IRANDX =',I4/10X,'IOPTDA =',I4/
610X,'NIT =',I4/10X,'IOPTAC =',I4)
20 FORMAT(8X,'INPUT PARAMETERS')
22 FORMAT(10X,'PX =',F8.3/10X,'P =',F8.3/10X,'TOL =',F8.3
1/10X,'B =',F8.3/10X,'BR =',F8.3/10X,'PR =',F8.3/
210X,'T =',F8.3/10X,'BSTEP =',F8.3/10X,'TOLR =',F8.3
3/10X,'MAXITR =',I4/10X,'IOPTC =',I4/10X,'IOPTB =',I4/10X,
4 'IOPTT =',I4/10X,'LDOFIX =',I4)
C=====Step 3: Read initial values of endogenous and exogenous variables and
C=====residuals, and coefficient values by call to DATSIM.
DO 4 I=1,MAXE
DO 4 J=1,MAXP
4 ER(I,J)=0.0D0
KEX=0
CALL DATSIM(IOPTDA,IOPTAC,KSTART,KEND)
IF(IOPTDA.GT.0) CALL EXO(IOPTAC,KEX)
IF(IOPTDA.EQ.2) NSTART = NSTART + KSTART -1
C=====Step 4: Solve system of equations by call to DEBCAL.
CALL DEBCAL
C=====Step 5: Rolling forecast
IF(NIT.EQ.0.AND.IOPTDA.LT.2) GOTO 100
NRUNS=NIT
IF(IOPTDA.EQ.2) NRUNS=KEND-KSTART
IF (NRUNS.LE.0) GOTO 100
IF(IDYN.GT.0) KEX=1
DO 200 IT=1,NRUNS
CALL UPDAT(IOPTDA,IOPTAC,KSTART)
CALL EXO(IOPTAC,KEX)
CALL DEBCAL
200 CONTINUE
100 CONTINUE
C=====Step 6: Save the residuals,shocks, endogenous/exogenous data
open (unit=50, file='allout.out')
do 102, i=4,147
write(50,1111) e(1,i),e(2,i),e(3,i),e(4,i),e(5,i),e(6,i),
>e(7,i),e(8,i),e(9,i),e(10,i),e(11,i),e(12,i),e(13,i),e(14,i),
>e(15,i),e(16,i),x(17,i),x(18,i),x(19,i),x(20,i),x(21,i),
>x(22,i),x(23,i),x(24,i),x(25,i)
102 continue
close(50)
1111 format(25f13.8)
1112 format(7f12.8)
DO 1113 I = 1,NDOG
WRITE(13,9002) ( E(I,J),J=1,147 )
1113 CONTINUE
DO 1114 I = 1,LEXOG
WRITE(13,9002) ( X(I,J),J=1,147 )
1114 CONTINUE
9002 FORMAT(4F18.12)
C=====Step 7: What is this?
DO 1100 IC = 1,2
NV = KK(IC+1) - KK(IC)
DO 8000 IV = 1,NV
LPRINT = 0
KVAR = KK(IC) + IV
DO 6000 IY = 1,KAG
V = ER(KVAR,IY)
IF ( ABS(V) .GT. 0.000001 ) THEN
LPRINT = 1
END IF
6000 CONTINUE
IF ( LPRINT .EQ. 1 ) THEN
WRITE(9,7000) IC,IV
WRITE(9,7500) ( ER(KVAR,IY),IY=1,147 )
END IF
7000 FORMAT(2I2)
7500 FORMAT(4F18.12)
8000 CONTINUE
1100 CONTINUE
STOP
END
C===SUBROUTINE EQN
SUBROUTINE EQN
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
CHARACTER*8 NAME, IXOG
COMMON/ALPHA/ NAME(300), IXOG(600)
COMMON/L2/E(300,300), X(600,300), ER(300,300),
1 DUMMY(1500,300)
COMMON/HELEN/V(300),Z(600),BA(300),JX(10),VX(10),
1 KAG,MAG,NDOG,LEXOG,IPAR,IRAND,B,NSTART,ITMX,XX,P,TOL,TOLR,BR
2,PR,NPER,NSK,IJX,I,IDATE,NEGP,T,IOPT,IDYN,ITR,NARG,BSTEP,MAXITR
3,NXGP,NCG,IDYN1,IRANDX,IB,IRHO
COMMON/KGROUP/K01,K02,K03,K04,K05,K06,K07,K08,K09,K10,K11,K12,K13,
1K14,K15,K16,K17,K18,K19,K20,K21,K22,K23,K24,K25,K26,K27,K28,K29,
2K30,K31,K32,K33,K34,K35,K36,K37,K38,K39,K40,K41
COMMON/JGROUP/J01,J02,J03,J04,J05,J06,J07,J08,J09,J10,J11,J12,J13,
1J14,J15,J16,J17,J18,J19,J20,J21,J22,J23,J24,J25,J26,J27,J28,J29,
2J30,J31,J32,J33,J34,J35,J36,J37,J38,J39,J40,J41
COMMON/WOREQN/IBLOC,NCONV,NBLOC
CALL SWUS
RETURN
END
C===SUBROUTINE SUBPXE(II,J,K,ERX,NN)
SUBROUTINE SUBPXE(II,J,K,ERX,NN)
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
CHARACTER*8 NAME, IXOG
COMMON/ALPHA/ NAME(300), IXOG(600)
COMMON/L2/E(300,300), X(600,300), ER(300,300),
1 DUMMY(1500,300)
COMMON/HELEN/V(300),Z(600),BA(300),JX(10),VX(10),
1 KAG,MAG,NDOG,LEXOG,IPAR,IRAND,B,NSTART,ITMX,XX,P,TOL,TOLR,BR
2,PR,NPER,NSK,IJX,IPER,IDATE,NEGP,T,IOPT,IDYN,ITR,NARG,BSTEP,MAXITR
3,NXGP,NCG,IDYN1,IRANDX,IB,IRHO
COMMON/KGROUP/KK(41)
COMMON/JGROUP/JJ(41)
COMMON/WOREQN/IBLOC,NCONV,NBLOC
L=KK(II)+J
IF(NN.EQ.2) GOTO 2
1 X(L,IPER+K)=ERX
GOTO 3
2 ER(L,IPER+K)=ERX
3 RETURN
END
C===SUBROUTINE EXOG(KEX)
SUBROUTINE EXOG(KEX)
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
CHARACTER*8 NAME, IXOG
COMMON/ALPHA/ NAME(300), IXOG(600)
COMMON/L2/E(300,300), X(600,300), ER(300,300),
1 ERX(600,300), EE(300,300), XX(600,300)
COMMON/HELEN/V(300),A(600),BA(300),JX(10),VX(10),
1 KAG,MAG,NDOG,LEXOG,IPAR,IRAND,B,NSTART,ITMX,PX,P,TOL,TOLR,BR
2,PR,NPER,NSK,IJX,I ,IDATE,NEGP,T,IOPT,IDYN,ITR,NARG,BSTEP,MAXITR
3,NXGP,NCG,IDYN1,IRANDX,IB,IRHO
COMMON/KGROUP/KK(41)/JGROUP/JJ(41)
DO 10 IC = 1 , 9
10 CALL EXCO (IC)
CALL EXCOM
RETURN
END
C===SUBROUTINE EXCO (ICE)
SUBROUTINE EXCO (ICE)
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
CHARACTER*8 NAME, IXOG
COMMON/ALPHA/ NAME(300), IXOG(600)
COMMON/L2/E(300,300), X(600,300), ER(300,300),
1 ERX(600,300), EE(300,300), XX(600,300)
COMMON/HELEN/F(300),A(600),BA(300),JX(10),VX(10),
1 KAG,MAG,NDOG,LEXOG,IPAR,IRAND,B,NSTART,ITMX,PX,P,TOL,TOLR,BR
2,PR,NPER,NSK,IJX,I ,IDATE,NEGP,T,IOPT,IDYN,ITR,NARG,BSTEP,MAXITR
3,NXGP,NCG,IDYN1,IRANDX,IB,IRHO
COMMON/KGROUP/KK(41)/JGROUP/JJ(41)
DV(I,J,K)= VV(I,J,K) - VV(I,J,K-1)
DL(I,J,K)= VV(I,J,K) / VV(I,J,K-1)
N = 1+ I-MAG
ICX= 20 + ICE
EX1 = VV(ICX,8,-1)
CALL SUBPXE(ICX,1,0,EX1,1)
EX2 = VV(ICX,2,-1)*(DL(ICX,2,-1)+DL(ICX,2,-2))/2.0D0
CALL SUBPXE(ICX,2,0,EX2,1)
EX4 = VV(ICX,4,-1)
CALL SUBPXE(ICX,4,0,EX4,1)
EX5 = 0.0D0
CALL SUBPXE(ICX,5,0,EX5,1)
EX6 = 0.0D0
CALL SUBPXE(ICX,6,0,EX6,1)
EX7 = VV(ICX,8,-1)
CALL SUBPXE(ICX,7,0,EX7,1)
EX8 = VV(ICX,8,-1)
CALL SUBPXE(ICX,8,0,EX8,1)
EX9 = 0.0D0
CALL SUBPXE(ICX,9,0,EX9,1)
EX10 = 0.0D0
CALL SUBPXE(ICX,10,0,EX10,1)
EX11 = VV(ICE,15,-N)
CALL SUBPXE(ICX,11,0,EX11,1)
EX12 = VV(ICE,15,-N)
CALL SUBPXE(ICX,12,0,EX12,1)
EX3 = VV(ICX,2,0)*(DV(ICX,4,0) +(VV(ICE,6,-N)/VV(ICX,2,-N))*
1 DV(ICX,8,0) + VV(ICX,3,-1)/VV(ICX,2,-1) )
CALL SUBPXE(ICX, 3,0,EX3 ,1)
RETURN
END
C===SUBROUTINE EXCOM
SUBROUTINE EXCOM
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
CHARACTER*8 NAME, IXOG
COMMON/ALPHA/ NAME(300), IXOG(600)
COMMON/L2/E(300,300), X(600,300), ER(300,300),
1 ERX(600,300), EE(300,300), XX(600,300)
COMMON/HELEN/F(300),A(600),BA(300),JX(10),VX(10),
1 KAG,MAG,NDOG,LEXOG,IPAR,IRAND,B,NSTART,ITMX,PX,P,TOL,TOLR,BR
2,PR,NPER,NSK,IJX,I ,IDATE,NEGP,T,IOPT,IDYN,ITR,NARG,BSTEP,MAXITR
3,NXGP,NCG,IDYN1,IRANDX,IB,IRHO
COMMON/KGROUP/KK(41)/JGROUP/JJ(41)
DV(I,J,K)= VV(I,J,K) - VV(I,J,K-1)
DL(I,J,K)= VV(I,J,K) / VV(I,J,K-1)
N = I-MAG
CALL SUBPXE(33,1,0,0.0D0,1)
CALL SUBPXE(33,2,0,0.0D0,1)
CALL SUBPXE(33,3,0,0.0D0,1)
CALL SUBPXE(33,4,0,0.0D0,1)
CALL SUBPXE(33,5,0,0.0D0,1)
CALL SUBPXE(33,6,0,0.0D0,1)
CALL SUBPXE(33,7,0,0.0D0,1)
RETURN
END
C===SUBROUTINE DATSIM(IOPTDA,IOPTAC,KSTART,KEND)
SUBROUTINE DATSIM(IOPTDA,IOPTAC,KSTART,KEND)
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
CHARACTER*8 NAME, IXOG
COMMON/ALPHA/ NAME(300), IXOG(600)
COMMON/L2/E(300,300), X(600,300), ER(300,300),
1 ERX(600,300), EE(300,300), XX(600,300)
COMMON/HELEN/F(300),A(600),BA(300),JX(10),VX(10),
1 KAG,MAG,NDOG,LEXOG,IPAR,IRAND,B,NSTART,ITMX,PX,P,TOL,TOLR,BR
2,PR,NPER,NSK,IJX,IPER,IDATE,NEGP,T,IOPT,IDYN,ITR,NARG,BSTEP,MAXITR
3,NXGP,NCG,IDYN1,IRANDX,IB,IRHO
COMMON/KGROUP/KK(41)/JGROUP/JJ(41)
COMMON/POWELL/R(200000),DIR(200000),L(200000),ICTRL
COMMON/NEWCAL/NEN(100),NEX(100),NENH(100),NEXP,MXEH,IOPTT,IOPTB,
1IOPTC
COMMON/ARFUNC/ ARCOEF(11,50,6)
IF(IDYN.EQ.0.OR.IOPTC.EQ.1) GOTO 165
K=0
DO 160 IG=1,NEGP
KKI=KK(IG)+1
KKT=KK(IG+1)
IF(IG.EQ.NEGP) KKT=NDOG
IF((KKT-KKI).LT.0) GOTO 160
DO 155 J=KKI,KKT
READ(5,102) NAME(J),NCKEX
IF(NCKEX.LE.0) GOTO 155
DO 157 II=1,NCKEX
READ(5,103) NEXH,NEXV
K=K+1
NEN(K)=J
NEX(K)=KK(IG+NEGP)+NEXV
NENH(K)=NEXH
157 CONTINUE
155 CONTINUE
160 CONTINUE
NEXP=K
MXEH=0
DO 159 J=1,NEXP
159 IF(MXEH.LT.NENH(J)) MXEH=NENH(J)
NGX=NEXP*NPER
IF(IOPTB.EQ.0) NGX=NEXP*(NPER+1)
NARG=NGX
GOTO 175
165 CONTINUE
DO 50 I=1,NDOG
50 READ(5,101) NAME(I)
175 CONTINUE
DO 55 I=1,LEXOG
55 READ(5,101) IXOG(I)
IF(IOPTC.EQ.1) GOTO 180
WRITE(6,1005) NARG,NEXP,MXEH,IOPTB
DO 170 K=1,NEXP
170 WRITE(6,1006) NEN(K),NAME(NEN(K)),NENH(K),NEX(K),IXOG(NEX(K))
1005 FORMAT(/10X,'NARG =',I4/10X,'NEXP =',I4/10X,'MXEH =',
1 I4//,' ENDOG. VAR. EXP. HORIZON EXP. VAR. ("EXO. VAR.")'
2 ,I4/)
1006 FORMAT(/2X,I4,2X,A8,6X,I4,6X,I4,2X,A8)
180 CONTINUE
LAG=MAG-1
KG1=KAG
IF(IOPTDA.EQ.2) GOTO 200
IF(IOPTDA.EQ.1) KG1=MAG
IF(IB.EQ.0) GO TO 20
DO 1 J=1,MAG
1 READ(5,*) (E(I,J),I=1,NDOG)
DO 10 J=1,KG1
10 READ(5,*) (X(I,J),I=1,LEXOG)
GO TO 60
20 CONTINUE
DO 22 I=1,NDOG
22 READ(5,*) (E(I,J),J=1,KAG)
60 IF(IRAND.EQ.0) GOTO 26
DO 25 K=1,IRAND
READ(5,2) IGP,IVB
KKK=KK(IGP)+IVB
25 READ(5,*) (ER(KKK,J),J=1,KAG)
26 CONTINUE
IF(IB.NE.0) GOTO 65
DO 24 I=1,LEXOG
24 READ(5,*) (X(I,J),J=1,KG1)
65 IF(IRANDX.EQ.0) GOTO 199
DO 27 K=1,IRANDX
READ(5,2) IGP,IVB
KKK=KK(IGP)+IVB
27 READ(5,*) (ERX(KKK,J),J=1,KAG)
2 FORMAT(2I2)
GOTO 199
200 CONTINUE
READ(5,3) ISSZ,KSTART,KEND
DO 201 I=1,NDOG
201 READ(5,*)(EE(I,J) ,J=1,ISSZ)
DO 202 I=1,LEXOG
202 READ(5,*)(XX(I,J) ,J=1,ISSZ)
KSL=KSTART-LAG
IF(KSL.GT.0) GOTO 203
3 FORMAT(3I4)
KSTART=1-KSL
NSTART=NSTART-KSL+1
KSL=KSTART-LAG
203 CONTINUE
MG1=MAG-1
DO 204 J=1,NDOG
DO 204 I=1,MG1
204 E(J,I)=EE(J,KSL-1+I)
MG1=MAG-1
IF(IOPTAC.EQ.1) MG1=MG1+1
DO 205 J=1,LEXOG
DO 205 I=1,MG1
205 X(J,I)=XX(J,KSL-1+I)
DO 206 J=1,NDOG
206 E(J,MAG)=E(J,MAG-1)
199 CONTINUE
WRITE(6,709)
709 FORMAT(1H1,55X,'COEFFICIENT VALUES',/)
OPEN(UNIT=123,FILE='coef.data',STATUS='old')
READ(123,*) (A(I),I=1,IPAR)
CLOSE(123)
OPEN(UNIT=123,FILE='ar_coeffs.data',STATUS='old')
READ(123,*) (A(I),I=IPAR+1,IPAR+IRHO)
CLOSE(123)
WRITE(6,710) (A(M),M=1,IPAR+IRHO)
710 FORMAT(10X,10F12.4)
WRITE(6,304)
304 FORMAT(1H1)
101 FORMAT(A8)
102 FORMAT(A8,I4)
103 FORMAT(2I4)
RETURN
END
C===SUBROUTINE ALISON(NDUM,FX)
SUBROUTINE ALISON(NDUM,FX)
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
CHARACTER*8 NAME, IXOG
COMMON/ALPHA/ NAME(300), IXOG(600)
COMMON/L2/E(300,300), X(600,300), ER(300,300),
1 DUMMY(1500,300)
COMMON/HELEN/F(300),A(600),BA(300),JX(10),VX(10),
1 KAG,MAG,NDOG,LEXOG,IPAR,IRAND,B,NSTART,ITMX,PX,P,TOL,TOLR,BR
2,PR,NPER,NSK,IJX,IPER,IDATE,NEGP,T,IOPT,IDYN,ITR,NARG,BSTEP,MAXITR
3,NXGP,NCG,IDYN1,IRANDX,IB,IRHO
COMMON/KGROUP/KK(41)
COMMON/POWELL/R(200000),DIR(200000),L(200000),ICTRL
COMMON/NEWCAL/NEN(100),NEX(100),NENH(100),NEXP,MXEH,IOPTT,IOPTB,
1IOPTC
KX(I,J)=600*(J-1)+I
KVV(IG,J,K)=KX(KK(IG)+J,I+K)
IF(IDYN.EQ.2) CALL CONT(IDYN1)
I=KAG
MXEH1=MXEH+1
GOTO (10,20,30) (IOPTT+1)
10 CONTINUE
DO 101 IE=1,NEXP
IF(IE.EQ.1) GOTO 100
IF(NEN(IE-1).EQ.NEN(IE)) GOTO 101
100 CONTINUE
DO 1 K =1,MXEH1
1 E(NEN(IE),I+K)=X(NEX(IE),I)
101 CONTINUE
GOTO 40
20 CONTINUE
DO 202 IE=1,NEXP
IF(IE.EQ.1) GOTO 200
IF(NEN(IE-1).EQ.NEN(IE)) GOTO 202
200 CONTINUE
DO 2 K =1,MXEH1
2 E(NEN(IE),I+K)=E(NEN(IE),I)
202 CONTINUE
GOTO 40
30 CONTINUE
DO 303 IE=1,NEXP
IF(IE.EQ.1) GOTO 300
IF(NEN(IE-1).EQ.NEN(IE)) GOTO 303
300 CONTINUE
IF(E(NEN(IE),I-1).EQ.0.0D0) GOTO 31
DKG=E(NEN(IE),I)/E(NEN(IE),I-1)
GOTO 32
31 DKG=1.0D0
32 CONTINUE
DO 3 K =1,MXEH1
3 E(NEN(IE),I+K)=E(NEN(IE),I+K-1)*DKG
303 CONTINUE
40 CONTINUE
DO 50 IE=1,NEXP
50 X(NEX(IE),I+1)=E(NEN(IE),I+NENH(IE))
J =0
DO 4 IE=1,NEXP
DO 4 I =MAG,KAG
J=J+1
L(J)=KX(NEX(IE),I)
R(J)=E(NEN(IE),I+NENH(IE))-X(NEX(IE),I)
4 CONTINUE
I=MAG-1
DO 5 IE=1,NEXP
J=J+1
L(J)=KX(NEX(IE),I)
R(J)=E(NEN(IE),I+NENH(IE))-X(NEX(IE),I)
5 CONTINUE
RETURN
END
C===SUBROUTINE UPDAT(IOPTDA,IOPTAC,KSTART)
SUBROUTINE UPDAT(IOPTDA,IOPTAC,KSTART)
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
CHARACTER*8 NAME, IXOG
COMMON/ALPHA/ NAME(300), IXOG(600)
COMMON/L2/E(300,300), X(600,300), ER(300,300),
1 ERX(600,300), EE(300,300), XX(600,300)
COMMON/HELEN/F(300),A(600),BA(300),JX(10),VX(10),
1 KAG,MAG,NDOG,LEXOG,IPAR,IRAND,B,NSTART,ITMX,PX,P,TOL,TOLR,BR
2,PR,NPER,NSK,IJX,IPER,IDATE,NEGP,T,IOPT,IDYN,ITR,NARG,BSTEP,MAXITR
3,NXGP,NCG,IDYN1,IRANDX,IB,IRHO
COMMON/KGROUP/KK(41)/JGROUP/JJ(41)
COMMON/POWELL/R(200000),DIR(200000),L(200000),ICTRL
NSTART=NSTART+1
MG2=MAG-2
IF(MG2.LE.0) GOTO 50
DO 10 J=1,NDOG
DO 10 I=1,MG2
10 E(J,I)=E(J,I+1)
IF(IOPTAC.EQ.1) MG2=MG2+1
DO 20 J=1,LEXOG
DO 20 I=1,MG2
20 X(J,I)=X(J,I+1)
50 CONTINUE
MG1=MAG-1
IF(IOPTDA.EQ.2) GOTO 40
READ(5,*) (E(J,MG1),J=1,NDOG)
IF(IOPTAC.EQ.1) MG1=MG1+1
READ(5,*) (X(J,MG1),J=1,LEXOG)
GOTO 45
40 CONTINUE
DO 23 J=1,NDOG
23 E(J,MG1)=EE(J,KSTART)
KSST=KSTART
IF(IOPTAC.EQ.1) MG1=MG1+1
IF(IOPTAC.EQ.1) KSST=KSTART+1
DO 24 J=1,LEXOG
24 X(J,MG1)=XX(J,KSST)
KSTART=KSTART+1
45 CONTINUE
DO 25 J=1,NDOG
25 E(J,MAG)=E(J,MAG+1)
RETURN
END
C===SUBROUTINE EXO(IOPTAC,KEX)
SUBROUTINE EXO(IOPTAC,KEX)
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
CHARACTER*8 NAME, IXOG
COMMON/ALPHA/ NAME(300), IXOG(600)
COMMON/L2/E(300,300), X(600,300), ER(300,300),
1 ERX(600,300), EE(300,300), XX(600,300)
COMMON/HELEN/f(300),A(600),BA(300),JX(10),VX(10),
1 KAG,MAG,NDOG,LEXOG,IPAR,IRAND,B,NSTART,ITMX,PX,P,TOL,TOLR,BR
2,PR,NPER,NSK,IJX,IPER,IDATE,NEGP,T,IOPT,IDYN,ITR,NARG,BSTEP,MAXITR
3,NXGP,NCG,IDYN1,IRANDX,IB,IRHO
COMMON/NEWCAL/NEN(100),NEX(100),NENH(100),NEXP,MXEH,IOPTT,IOPTB,
1IOPTC
MG=MAG
IF(IOPTAC.EQ.1) MG=MG+1
IF (IOPTC.GT.0.OR.KEX.EQ.0) GOTO 10
DO 30 J=1,NEXP
30 X(NEX(J),MG-1)=X(NEX(J),MG)
10 CONTINUE
DO 20 I=MG,KAG
IPER=I
CALL EXOG(KEX)
IF (IOPTC.GT.0.OR.KEX.EQ.0) GOTO 20
DO 40 J=1,NEXP
40 X(NEX(J),I)=X(NEX(J),I+1)
20 CONTINUE
RETURN
END
C===SUBROUTINE DEBCAL
SUBROUTINE DEBCAL
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
CHARACTER*8 NAME, IXOG, AJX(10)
COMMON/ALPHA/ NAME(300), IXOG(600)
COMMON/L2/E(300,300) ,X(600,300),ER(300,300),
& ERX(600,300),EE(300,300),XX(600,300)
COMMON/HELEN/F(300),A(600),BA(300),JX(10),VX(10),
1 KAG,MAG,NDOG,LEXOG,IPAR,IRAND,B,NSTART,ITMX,PX,P,TOL,TOLR,BR
2,PR,NPER,NSK,IJX,IPER,IDATE,NEGP,T,IOPT,IDYN,ITR,NARG,BSTEP,MAXITR
3,NXGP,NCG,IDYN1,IRANDX,IB,IRHO
COMMON/KGROUP/KK(41)/JGROUP/JJ(41)
COMMON/POWELL/R(200000),DIR(200000),L(200000),ICTRL
COMMON/NEWCAL/NEN(100),NEX(100),NENH(100),NEXP,MXEH,IOPTT,IOPTB,
1IOPTC
COMMON/FIX2/ LFIX2, NFIX2, LDOFIX, NFIXMX, NFIXEND
DIMENSION NJX(10)
DIMENSION XEQUIV(120000)
EQUIVALENCE ( XEQUIV(1),X(1,1) )
EXTERNAL CALCFX,ALISON
COMMON/SHK/err(10,1000)
character*18 errname, gen_errname, xname, gen_xname
199 IF(NSK.NE.0) CALL SHOCK
WRITE(6,226)
226 FORMAT(1H1,60X,'INPUT DATA')
DO 225 K=1,NEGP
KKK=KK(K+1)
IF(K.EQ.NEGP) KKK=NDOG
KKK=KKK-KK(K)
IF(KKK.EQ.0) GOTO 225
ISTART=NSTART-MAG
WRITE(6,409) K
DO 222 I=1,MAG,10
DO 223 J=1,10
223 JX(J)=ISTART+J
IE=MIN0(10,MAG-I+1)
WRITE(6,408)(JX(J),J=1,IE)
DO 224 J=1,KKK
KJ=KK(K)+J
224 WRITE(6,405) NAME(KJ),(E(KJ,I+M-1),M=1,IE)
ISTART=ISTART+10
222 CONTINUE
225 CONTINUE
405 FORMAT(2X,A8,10F12.4)
408 FORMAT(/14X,I4,9(8X,I4))
409 FORMAT(//,2X,'GROUP',I3,' ENDOGENOUS VARIABLES')
DO 525 K=1,NXGP
KKK=KK(NEGP+K+1)-KK(NEGP+K)
IF(KKK.EQ.0) GOTO 525
K2=K+NEGP
WRITE(6,509) K2
509 FORMAT(//,2X,'GROUP',I3,' EXOGENOUS VARIABLES')
ISTART=NSTART-MAG
DO 522 I=1,KAG,10
DO 523 J=1,10
523 JX(J)=ISTART+J
IE=MIN0(10,KAG-I+1)
WRITE(6,408)(JX(J),J=1,IE)
DO 524 J=1,KKK
KJ=KK(NEGP+K)+J
524 WRITE(6,405) IXOG(KJ),(X(KJ,I+M-1),M=1,IE)
ISTART=ISTART+10
522 CONTINUE
525 CONTINUE
IF(IRAND.EQ.0) GOTO 625
DO 626 K=1,NEGP
KKK=KK(K+1)
IF(K.EQ.NEGP) KKK=NDOG
KKK=KKK-KK(K)
IF(KKK.EQ.0) GOTO 626
WRITE(6,609) K
609 FORMAT(//,2X,'GROUP',I3,' RESIDUAL VALUES')
ISTART=NSTART-MAG
DO 622 I=1,KAG,10
DO 623 J=1,10
623 JX(J)=ISTART+J
IE=MIN0(10,KAG-I+1)
WRITE(6,408)(JX(J),J=1,IE)
DO 624 J=1,KKK
KJ=KK(K)+J
624 WRITE(6,405) NAME(KJ),(ER(KJ,I+M-1),M=1,IE)
ISTART=ISTART+10
622 CONTINUE
626 CONTINUE
625 CONTINUE
IF(IRANDX.EQ.0) GOTO 725
DO 726 K=1,NEGP
KKK=KK(NEGP+K+1)
IF(K.EQ.NXGP) KKK=LEXOG
KKK=KKK-KK(NEGP+K)
IF(KKK.EQ.0) GOTO 726
WRITE(6,709) (K+NEGP)
709 FORMAT(//,2X,'GROUP',I3,' RESIDUAL VALUES')
ISTART=NSTART-MAG
DO 722 I=1,KAG,10
DO 723 J=1,10
723 JX(J)=ISTART+J
IE=MIN0(10,KAG-I+1)
WRITE(6,408)(JX(J),J=1,IE)
DO 724 J=1,KKK
KJ=KK(NEGP+K)+J
724 WRITE(6,405) IXOG(KJ),(ERX(KJ,I+M-1),M=1,IE)
ISTART=ISTART+10
722 CONTINUE
726 CONTINUE
725 CONTINUE
WRITE(6,204)
open(unit=35,file='nlag')
read(35,*)nlag
close(35)
NBGN = nlag+1
NEND = nlag+1
open(unit=35,file='lags_endog')
do 3013 i=1,ndog
3013 read(35,*)(e(i,j),j=1,nlag)
close(35)
DO 1111 ILOOP = NBGN,NEND
MAG = ILOOP
LAG = MAG - 1
KAG = MAG + 49
open(unit=35,file='lags_exog')
do 3015 i=1,lexog
3015 read(35,*)(x(i,j),j=1,nlag)
close(35)
ICTRL=0
ITR=-1
IF(IDYN.GT.0) ITR=0
IF(IDYN.EQ.2) GOTO 50
100 CALL CONT(IDYN1)
IF(IDYN.EQ.0) CALL PRINT
IF(IOPTC.GT.0) GOTO 111
CALL ALISON(NARG,FX)
GOTO 112
111 CALL CALCFX(FX)
112 CONTINUE
DO 602 I=1,50
TOLR = 0.5
IF(XEQUIV(L(I)).EQ.0.0D0) GOTO 982
Z=ABS(R(I)/XEQUIV(L(I)))
IF(Z.GT.TOLR.AND.ABS(R(I)).GT.TOLR) GOTO 65
GOTO 602
982 IF(ABS(R(I)).GT.(0.1D0*TOLR)) GOTO 65
602 CONTINUE
DO 603 I=51,100
TOLR = 0.5
IF(XEQUIV(L(I)).EQ.0.0D0) GOTO 983
Z=ABS(R(I)/XEQUIV(L(I)))
IF(Z.GT.TOLR.AND.ABS(R(I)).GT.TOLR) GOTO 65
GOTO 603
983 IF(ABS(R(I)).GT.(0.1D0*TOLR)) GOTO 65
603 CONTINUE
WRITE(6,600) ITR
600 FORMAT(' RATIONAL EXPECTATIONS VARIABLES CONVERGED IN ',I4,
1' ITERATIONS')
66 CALL PRINT
write(*,*)'before qerror'
write(*,*)'model shocks ',(err(i,mag),i=1,10)
errname = gen_errname(ILOOP)
open(unit=99,file=errname)
xname = gen_xname(ILOOP)
open(unit=98,file=xname)
IC=1
DO 8010 IV = 1,16
WRITE(99,7001) IC,IV
WRITE(99,7501) ( ER(IV,IY),IY=1,199 )
8010 continue
DO 8020 I=1,LEXOG
8020 WRITE(98,7501) (X(I,J), J=1,199)
7001 FORMAT(2I2)
7501 FORMAT(4F18.12)
open(unit=35,file='lags_endog')
do 3016 i=1,ndog
3016 write(35,*)(e(i,j),j=1,mag)
close(35)
open(unit=35,file='lags_exog')
do 3017 i=1,lexog
3017 write(35,*)(x(i,j),j=1,mag)
close(35)
new_lag=nlag+1
open(unit=35,file='nlag')
write(35,*)new_lag
close(35)
1111 continue
return
65 IF(ITR.LT.MAXITR) GOTO 62
WRITE(6,601) MAXITR
601 FORMAT(' RATIONAL EXPECTATIONS VARIABLES FAILED TO CONVERGE IN ',
1I4,' ITERATIONS')
CALL PRINT
62 DO 63 I=1,NARG
J=L(I)
63 XEQUIV(J)=XEQUIV(J)+BSTEP*R(I)
IF(ABS(P).NE.1.0D0) GOTO 100
WRITE(6,73)
DO 71 I=1,NARG,4
DO 72 J=1,4
IT=(L(I+J-1)-1)/600
IV=L(I+J-1)-IT*600
IT=IT+1
AJX(J)=IXOG(IV)
72 NJX(J+4)=NSTART-MAG+IT
IE=MIN0(4,NARG-I+1)
WRITE(6,74) (AJX(J),NJX(J+4),R(I+J-1),XEQUIV(L(I+J-1)),J=1,IE)
71 CONTINUE
73 FORMAT(4(4X,'VARIABLE',3X,'RESIDUAL NEW VALUE'))
74 FORMAT(4(1X,A8,'(',I4,')',2F9.4))
GOTO 100
50 DO 51 I=1,NARG
51 DIR(I)=1.0D0
ICTRL=0
IF(IOPTC.GT.0) GOTO 322
CALL POW
GOTO 323
322 CALL POW
323 CONTINUE
CALL PRINT
101 FORMAT(10A8)
201 FORMAT(3(2X,A8,F15.4,10X)/)
204 FORMAT(1H1)
END
C===SUBROUTINE FUNCTO
SUBROUTINE FUNCTO
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
CHARACTER*8 NAME, IXOG
COMMON/ALPHA/ NAME(300), IXOG(600)
COMMON/L2/E(300,300), X(600,300), ER(300,300),
1 DUMMY(1500,300)
COMMON/HELEN/F(300),A(600),BA(300),JX(10),VX(10),
1 KAG,MAG,NDOG,LEXOG,IPAR,IRAND,B,NSTART,ITMX,PX,P,TOL,TOLR,BR
2,PR,NPER,NSK,IJX,I,IDATE,NEGP,T,IOPT,IDYN,ITR,NARG,BSTEP,MAXITR
3,NXGP,NCG,IDYN1,IRANDX,IB,IRHO
ITR=ITR+1
IF(ITR.GT.0.AND.ABS(P).EQ.1.0D0) WRITE(6,320) ITR
IDATE = NSTART
T = FLOAT(IDATE-1900)
DO 3 I=MAG,KAG
K=1
100 DO 30 J=1,NDOG
30 F(J)=0.0D0
CALL EQN
IF(IOPT.EQ.0) GOTO 55
DO 51 J=1,NDOG
EOLD=E(J,I)
F(J)=F(J)-EOLD
E(J,I)=E(J,I)+B*(F(J))
SRES=F(J)/EOLD
IF(P.LT.0.0D0) WRITE(6,300) EOLD,E(J,I),SRES,J
51 CONTINUE
GO TO 50
55 CONTINUE
DO 60 J=1,NDOG
EOLD=E(J,I)-B*F(J)
RES=0.0D0
IF(EOLD.EQ.0.0D0) GO TO 99
RES=F(J)/EOLD
99 IF (P.LT.0.0D0) WRITE(6,300) EOLD,E(J,I),RES,J
60 CONTINUE
50 CONTINUE
DO 61 J=1,NDOG
IF(E(J,I).EQ.0.0D0) GO TO 98
Z=ABS(F(J)/E(J,I))
IF(Z.GE.TOL .AND. ABS(F(J)).GE.0.01D0) GO TO 62
GO TO 61
98 IF(ABS(F(J)).GE.0.001D0) GO TO 62
61 CONTINUE
GO TO 63
62 K=K+1
IF(K.LE.ITMX) GOTO 100
70 WRITE(6,301) IDATE,K
63 IF(ABS(P).EQ.1.0D0) WRITE(6,310) IDATE,K
IF(I.EQ.KAG) GO TO 3
IDATE = IDATE + 1
T = FLOAT(IDATE-1900)
IF(ITR.GT.1) GOTO 3
3 CONTINUE
DO 33 J=1,NDOG
33 F(J)=0.0D0
RETURN
300 FORMAT(1H ,3F15.4,I4)
310 FORMAT(10X,'PERIOD ',I4,' MODEL CONVERGED IN ',I4,' ITERATIONS')
301 FORMAT(10X,'PERIOD ',I4,' MODEL FAILED TO CONVERGE IN ',I4,' ITERA
1TIONS')
320 FORMAT(' RATIONAL EXPECTATIONS ITERATION ',I4)
END
C===SUBROUTINE CONT(IDY)
SUBROUTINE CONT(IDY)
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
IF(IDY.NE.0) GOTO (1,2,3,4),IDY
CALL FUNCTO
RETURN
1 CALL FUNCT
RETURN
2 CALL FUNCTP
RETURN
3 CALL FUNCTH
RETURN
4 CALL FNCTLM
RETURN
END
C===SUBROUTINE FUNCT
SUBROUTINE FUNCT
IMPLICIT DOUBLE PRECISION ( A-H,O-Z)
CHARACTER*8 NAME, IXOG
COMMON/ALPHA/ NAME(300), IXOG(600)
COMMON/L2/E(300,300), X(600,300), ER(300,300),
1 DUMMY(1500,300)
COMMON/HELEN/F(300),A(600),BA(300),JX(10),VX(10),
1 KAG,MAG,NDOG,LEXOG,IPAR,IRAND,B,NSTART,ITMX,PX,P,TOL,TOLR,BR
2,PR,NPER,NSK,IJX,I,IDATE,NEGP,T,IOPT,IDYN,ITR,NARG,BSTEP,MAXITR
3,NXGP,NCG,IDYN1,IRANDX,IB,IRHO
COMMON/WOREQN/IBLOC,NCONV,NBLOC
COMMON/KGROUP/KK(41)/JGROUP/JJ(41)
PARAMETER ( MXWITR = 20,
+ NUNITY = 1,
+ NZERO = 0,
+ P01 = 0.01,
+ P001 = 0.001,
+ P0001 = 0.0001,
+ P00001 = 0.00001,
+ SMALL = 0.000001,
+ UNITY = 1.0 )
ITR = ITR + NUNITY
IDATE = NSTART
T = FLOAT(IDATE-1900)
DO 2001 IPER = MAG,KAG
I = IPER
IKW = NZERO
NCONV = NZERO
1000 CONTINUE
IKW = IKW + NUNITY
NBLOC1 = NBLOC - NUNITY
2000 DO 1001 IC = NUNITY,NBLOC1
K = NZERO
IBLOC = IC
KKIB = KK(IC) + NUNITY
KKIB1 = KK(IC+NUNITY)
3000 CALL EQN
DO 6000 J = KKIB,KKIB1
YABS = ABS( E(J,IPER) )
FABS = ABS( F(J) )
RATIO = UNITY
IF ( YABS .GT. P0001 ) RATIO = FABS/YABS
IF ((RATIO.LT.P0001) .OR. (FABS.LT.P0001.AND.YABS.LT.P0001)) THEN
GO TO 6000
ELSE
IF ( K .LT. ITMX ) THEN
K = K + NUNITY
GO TO 3000
ELSE
WRITE(6,4000) IDATE, IC, K
4000 FORMAT(1X,'**** ',I4,' : GROUP ',I2,' FAILED TO CONVERGE IN ',I4,
+ ' ITERATIONS ****')
GO TO 1001
END IF
END IF
6000 CONTINUE
1001 CONTINUE
1002 IBLOC = NBLOC
CALL EQN
IF ( NCONV .EQ. NZERO .AND. IKW .LT. MXWITR ) GO TO 1000
IF ( NCONV .EQ. NZERO .AND. IKW .GE. MXWITR ) THEN
WRITE(6,1003) IDATE, IKW
1003 FORMAT(1X,'**** ',I4,' : CONSISTENCY NOT REACHED IN ',I3,
+ ' ITERATIONS ****')
END IF
IF ( IPER .EQ. KAG ) GO TO 2001
IDATE = IDATE + NUNITY
T = FLOAT(IDATE-1900)
1400 CONTINUE
2001 CONTINUE
RETURN
END
C===SUBROUTINE FUNCTP
SUBROUTINE FUNCTP
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
CHARACTER*8 NAME, IXOG
COMMON/ALPHA/ NAME(300), IXOG(600)
COMMON/L2/E(300,300), X(600,300), ER(300,300),
1 DUMMY(1500,300)
COMMON/HELEN/F(300),A(600),BA(300),JX(10),VX(10),
1 KAG,MAG,NDOG,LEXOG,IPAR,IRAND,B,NSTART,ITMX,PX,P,TOL,TOLR,BR
2,PR,NPER,NSK,IJX,I,IDATE,NEGP,T,IOPT,IDYN,ITR,NARG,BSTEP,MAXITR
3,NXGP,NCG,IDYN1,IRANDX,IB,IRHO
COMMON/POWELL/R(200000),DIR(200000),L(200000),ICTRL
COMMON/WOREQN/IBLOC,NCONV,NBLOC
COMMON/KGROUP/KK(41)/JGROUP/JJ(41)
EXTERNAL FCNP
ITR=ITR+1
IF (ITR.GT.0 .AND. ABS(P).EQ.1.0D0) WRITE(6,320) ITR
IDATE = NSTART
T = FLOAT(IDATE-1900)
MXWITR=20
IC=1
IBLOC=IC
KKIB=1
KKIB1=NDOG
ND=NDOG
DO 3 I=MAG,KAG
NCONV=0
IKW=0
200 CONTINUE
IKW=IKW+1
K=1
DO 250 IC=1,NBLOC
IF(NBLOC.EQ.1) GOTO 100
IBLOC=IC
KKIB=KK(IC)+1
KKIB1=KK(IC+1)
ND=KK(IC+1)-KK(IC)
100 CALL EQN
IF(NBLOC.GT.1.AND.IC.EQ.NBLOC) GOTO 53
DO 51 J=1,ND
DIR(J)=B*F(KK(IC)+J)
F(KK(IC)+J)=0.0D0
R(J)=E(KK(IC)+J,I)
51 CONTINUE
CALL POW
DO 52 J=1,ND
52 E(KK(IC)+J,I)=R(J)
53 IF (P.GE.0.0D0) GOTO 250
DO 60 J=KKIB,KKIB1
WRITE(6,300) E(J,I),J,IBLOC
60 CONTINUE
250 CONTINUE
IF(NCONV.EQ.1) GOTO 251
IF(IKW.LE.MXWITR) GOTO 200
WRITE(6,302)IDATE,IKW
251 IF(ABS(P).EQ.1.0D0) WRITE(6,303)IDATE,IKW
IF(I.EQ.KAG) GO TO 3
IDATE = IDATE + 1
T = FLOAT(IDATE-1900)
IF(ITR.GT.1) GOTO 3