PageRenderTime 103ms CodeModel.GetById 29ms RepoModel.GetById 0ms app.codeStats 0ms

/OPENFVS_DIR_RESTRUCT_TEST_BRANCH/src/base/opexpn.f

http://open-fvs.googlecode.com/
FORTRAN Legacy | 244 lines | 129 code | 0 blank | 115 comment | 0 complexity | 5fbc689da74f42ffce6075378e71a1b3 MD5 | raw file
  1. SUBROUTINE OPEXPN (IOUT,NCYC,IY)
  2. IMPLICIT NONE
  3. C----------
  4. C **OPEXPN DATE OF LAST REVISION: 07/23/08
  5. C----------
  6. C
  7. C OPTION PROCESSING ROUTINE - NL CROOKSTON - JAN 1981 - MOSCOW
  8. C FROM 1991 TO 2003 THERE WERE NO CHANGES TO THIS ROUTINE!
  9. C IN MAY 2003 CROOKSTON ADDED PROVISIONS FOR CHARACTER ARGUMENTS
  10. C
  11. C EXPANDS THE ACTIVITY LIST SUCH THAT ACTIVITIES SPECIFIED FOR
  12. C ALL CYCLES ARE DUPLICATED ONCE FOR EACH CYCLE. AN ACTIVITY
  13. C SPECIFIED FOR ALL CYCLES WILL NOT BE ADDED TO A CYCLE WHICH
  14. C ALREADY CONTAINS THAT ACTIVITY.
  15. C
  16. COMMONS
  17. C
  18. C
  19. INCLUDE 'PRGPRM.F77'
  20. C
  21. C
  22. INCLUDE 'OPCOM.F77'
  23. C
  24. C
  25. COMMONS
  26. C
  27. INTEGER IY(MAXCY1),NCYC,IOUT,I,IY1,IMG3,IPSYR,ISYR,IC,J,IP,K
  28. INTEGER IY2,IP1,IPS,IPY,L
  29. C
  30. C STEP01: CONVERT ANY CYCLE NUMBERS IN THE DATE ARRAY TO DATES,
  31. C THEN SORT IOPSRT ON IDATE AND ISEQ.
  32. C
  33. IMG2=IMGL-1
  34. C
  35. C IF THERE ARE NO ACTIVITIES;
  36. C THEN: THE JOB IS DONE--RETURN.
  37. C
  38. IF (IMG2 .LE. 0) RETURN
  39. DO 10 I=1,IMG2
  40. IY1=IDATE(I)
  41. IF (IY1.LE.MAXCYC .AND. IY1.GT.0) THEN
  42. IF (IY(IY1).GT.0) IY1=IY(IY1)
  43. ENDIF
  44. IDATE(I)=IY1
  45. ISEQ(I)=I
  46. 10 CONTINUE
  47. ISEQDN=IMGL
  48. CALL OPSORT(IMG2,IDATE,ISEQ,IOPSRT,.TRUE.)
  49. C
  50. C STEP02: FIND THE STARTING YEAR (ISYR) IN THE
  51. C ACTIVITY DATE ARRAY (IDATE), AND:
  52. C SET IPSYR=1 IF THERE ARE NO 'ALL-CYCLE' ACTIVITIES.
  53. C SET IPSYR=0 IF ALL ACTIVITIES ARE 'ALL-CYCLE' ACTIVITIES.
  54. C SET IPSYR>1 TO EXPAND THE 'ALL-CYCLE' ACTIVITIES STORED IN
  55. C IACT((IOPSRT(J),J=1,IPSYR-1),*).
  56. C
  57. DO 20 I=1,IMG2
  58. IMG3=IOPSRT(I)
  59. IF (IDATE(IMG3).LE.0) GOTO 20
  60. IPSYR=I
  61. ISYR=IDATE(IMG3)
  62. GOTO 30
  63. 20 CONTINUE
  64. IPSYR=0
  65. 30 CONTINUE
  66. C
  67. C IF IPSYR=1, THERE ARE NO 'ALL-CYCLE' ACTIVITIES;
  68. C THEN: PROCESSING IS COMPLETE, RETURN.
  69. C
  70. IF (IPSYR .EQ. 1) RETURN
  71. C
  72. C ELSE:
  73. C STEP03: EXPAND THE 'ALL-CYCLE' ACTIVITIES.
  74. C
  75. C IF IPSYR>1 SOME SPICIFICLY DATED AND SOME 'ALL-CYCLE'
  76. C ACTIVITIES EXIST. THEN: BRANCH TO SPECIAL CODE.
  77. C
  78. IF (IPSYR .GT. 1) GOTO 70
  79. C
  80. C ELSE: ALL ACTIVITIES MUST BE ASSIGNED TO ALL CYCLES.
  81. C
  82. C ASSIGN THE FIRST DATE TO THE SPECIFIED ACTIVITIES.
  83. C
  84. ISYR=IY(1)
  85. DO 40 I=1,IMG2
  86. IDATE(I)=ISYR
  87. 40 CONTINUE
  88. C
  89. C IF THE NUMBER OF CYCLES = 1;
  90. C THEN: WE'ER DONE; RETURN
  91. C
  92. IF (NCYC .EQ. 1) RETURN
  93. C
  94. C ELSE: COPY THE SPECIFIED ACTIVITIES TO THE BOTTOM OF THE
  95. C ACTIVITY ARRAY AND ASSIGN THE NEXT CYCLE STARTING DATE
  96. C TO THE DATE ARRAY (IDATE). DO THIS FOR ALL CYCLES.
  97. C
  98. C MAKE SURE ALL OF THE ACTIVITIES WILL FIT.
  99. C
  100. IC=MAXACT/IMG2
  101. IF (IC.GE.NCYC) GOTO 50
  102. WRITE (IOUT,6010) NCYC,IC,IY(IC+1)
  103. 6010 FORMAT (/1X,I3,' CYCLES REQUESTED, ',I3,' CYCLES POSSIBLE. ',
  104. > 'PROJECTION WILL END IN ',I4)
  105. CALL ERRGRO (.TRUE.,10)
  106. NCYC=IC
  107. 50 CONTINUE
  108. C
  109. C COPY THE ACTIVITIES.
  110. C
  111. DO 67 IC=2,NCYC
  112. ISYR=IY(IC)
  113. J=(IC-1)*IMG2
  114. DO 65 IP=1,IMG2
  115. IMG3=J+IP
  116. IDATE(IMG3)=ISYR
  117. ISEQ(IMG3)=IMG3
  118. IOPSRT(IMG3)=IMG3
  119. DO K=1,5
  120. IACT(IMG3,K)=IACT(IP,K)
  121. ENDDO
  122. IF (IACT(IMG3,2).LE.0) GOTO 65
  123. DO 64 I=IACT(IMG3,2),IACT(IMG3,3)
  124. PARMS(IMPL)=PARMS(I)
  125. IMPL=IMPL+1
  126. IF (IMPL.GT.ITOPRM) GOTO 200
  127. 64 CONTINUE
  128. IACT(IMG3,2)=IMPL-(IACT(IMG3,3)-IACT(IMG3,2)+1)
  129. IACT(IMG3,3)=IMPL-1
  130. 65 CONTINUE
  131. 67 CONTINUE
  132. IMG2=IMG3
  133. IMGL=IMG2+1
  134. C
  135. RETURN
  136. 70 CONTINUE
  137. C
  138. C STEP04: ADD 'ALL-CYCLE' ACTIVITIES.
  139. C
  140. IMG1=IPSYR
  141. IPSYR=IPSYR-1
  142. IMG3=IMG2
  143. K=IMG1
  144. C
  145. C DO FOR ALL CYCLES.
  146. C
  147. DO 170 IC=1,NCYC
  148. C
  149. C FIND THE BEGINNING AND END OF THE CYCLE WITHIN THE ACTIVITY
  150. C ARRAY. NOTE THAT NO ACTIVITIES MAY YET EXIST FOR THE CYCLE.
  151. C
  152. IY1=IY(IC)
  153. IY2=IY(IC+1)
  154. IP1=0
  155. DO 100 IP=K,IMG2
  156. IPS=IOPSRT(IP)
  157. IPY=IDATE(IPS)
  158. IF (IPY .LT. IY1 .OR. IPY .GE. IY2) GOTO 90
  159. IF (IP1 .EQ. 0) IP1=IP
  160. 90 CONTINUE
  161. IF (IPY .LT. IY2) GOTO 100
  162. J=IP
  163. GOTO 105
  164. 100 CONTINUE
  165. GOTO 110
  166. 105 CONTINUE
  167. K=J
  168. 110 CONTINUE
  169. C
  170. C COPY THE ACTIVITIES.
  171. C
  172. ISYR=IY1
  173. C
  174. C DO FOR ALL 'ALL-CYCLE' ACTIVITIES.
  175. C
  176. DO 160 I=1,IPSYR
  177. J=IOPSRT(I)
  178. C
  179. C IF THERE IS NOT ENOUGH ROOM; THEN: BRANCH TO SPECIAL CODE.
  180. C
  181. IMG3=IMG3+1
  182. IF (IMG3 .GT. MAXACT) GOTO 200
  183. C
  184. C ELSE: ADD THE ACTIVITY
  185. C
  186. IDATE(IMG3)=ISYR
  187. ISEQ(IMG3)=IMG3
  188. IOPSRT(IMG3)=IMG3
  189. DO 150 L=1,5
  190. IACT(IMG3,L)=IACT(J,L)
  191. 150 CONTINUE
  192. C
  193. C DUPLICATE THE PARMETER LIST (BRANCH TO SPECIAL CODE IF THERE
  194. C IS NOT ENOUGH ROOM).
  195. C
  196. IF (IACT(IMG3,2).LE.0) GOTO 160
  197. DO 155 IP=IACT(IMG3,2),IACT(IMG3,3)
  198. PARMS(IMPL)=PARMS(IP)
  199. IMPL=IMPL+1
  200. IF (IMPL.GT.ITOPRM) GOTO 200
  201. 155 CONTINUE
  202. IACT(IMG3,2)=IMPL-(IACT(IMG3,3)-IACT(IMG3,2)+1)
  203. IACT(IMG3,3)=IMPL-1
  204. 160 CONTINUE
  205. 170 CONTINUE
  206. GOTO 300
  207. 200 CONTINUE
  208. C
  209. C SPECIAL CASE: OUT OF ROOM IN THE ACTIVITY ARRAYS.
  210. C BACK UP TO THE LAST COMPLETED CYCLE. SET THE NCYC VALUE
  211. C EQUAL TO THAT CYCLE, WRITE A MESSAGE AND GO ON. THIS
  212. C SHOULD BE A RATHER RARE EVENT, THEREFORE VERY LITTLE CODE
  213. C HAS BEEN WRITTEN TO TAKE MAX ADVANTAGE OF THE SITUATION.
  214. C (IF IT HAPPENS OFTEN, THE SOLUTION IS TO INCREASE THE SIZE OF
  215. C THE ACTIVITY ARRAYS.)
  216. C
  217. IC=IC-1
  218. IMG3=IMG3-1
  219. WRITE (IOUT,6010) NCYC,IC,IY(IC+1)
  220. CALL ERRGRO (.TRUE.,10)
  221. NCYC=IC
  222. 300 CONTINUE
  223. C
  224. C STEP05: MOVE THE ACTIVITIES IN THE BOTTOM OF THE LIST UP TO
  225. C THE TOP, OVERWRITTING THE 'ALL-CLCLE' ACTIVITIES.
  226. C
  227. IMG2=IMG3
  228. ISEQDN=IMG2+1
  229. DO 330 J=1,IPSYR
  230. I=IOPSRT(J)
  231. DO K=1,5
  232. IACT(I,K)=IACT(IMG2,K)
  233. ENDDO
  234. IDATE(I)=IDATE(IMG2)
  235. ISEQ(I)=ISEQ(IMG2)
  236. IMG2=IMG2-1
  237. 330 CONTINUE
  238. C
  239. C STEP06: REESTABLISH THE DATE SORT.
  240. C
  241. CALL OPSORT(IMG2,IDATE,ISEQ,IOPSRT,.FALSE.)
  242. IMGL=IMG2+1
  243. RETURN
  244. END