prefor1.f 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. ! ==================================================================
  2. ! ------------------------------------------------------------------
  3. !
  4. subroutine prefor1(b)
  5. use lsgvar
  6. implicit none
  7. !
  8. ! ------------------------------------------------------------------
  9. !
  10. !**** *prefor1*.
  11. !
  12. ! by E. Maier-Reimer.
  13. ! Last modified by U. Mikolajewicz 9/87.
  14. !
  15. !** Purpose.
  16. ! --------
  17. ! *prefor1* computes the right hand side of the equation for the
  18. ! barotropic velocities, when *nsve*=2.
  19. !
  20. ! Input.
  21. ! ------
  22. ! zeta surface elevation (common /lsgsur/ ).
  23. ! p norm pressure. (common /lsgpre/ ).
  24. ! taux windstress/density. (common /lsgfie/ ).
  25. ! tauy (common /lsgfie/ ).
  26. !
  27. ! Output.
  28. ! -------
  29. ! b array containing the value of the right hand side of
  30. ! the equation for the barotropic velocities.
  31. ! parameter.
  32. !
  33. ! Interface.
  34. ! ----------
  35. ! *call* *prefor1*(*b*)
  36. ! *b* an array with dimension b(matrx)
  37. !
  38. ! ------------------------------------------------------------------
  39. !
  40. ! Parameter declaration.
  41. ! ----------------------
  42. !
  43. real (kind=8) :: b(matrx)
  44. !
  45. ! ------------------------------------------------------------------
  46. !
  47. !
  48. ! Declaration of local variables.
  49. ! -------------------------------
  50. !
  51. integer :: i,j,k,l,m1
  52. real (kind=8) :: b1(ien,jen,2),b2(matrx),zetar(ien,jen)
  53. real (kind=8) :: pr(ien,jen,ken)
  54. real (kind=8) :: pra(ien*jen*ken),zetara(ien*jen)
  55. real (kind=8) :: b1a(ien*jen*2)
  56. real (kind=8) :: b1b(ien*jen,2)
  57. real (kind=8) :: prb(ien*jen,ken)
  58. equivalence (pra,pr)
  59. equivalence (zetar,zetara)
  60. equivalence (b1,b1a)
  61. equivalence (b1,b1b)
  62. equivalence (prb,pr)
  63. !
  64. !* 1. Set initial values.
  65. ! -------------------
  66. !
  67. ! *zetar* next surface elevation to the right.
  68. !
  69. l=ien*jen-1
  70. do i=1,l
  71. zetara(i)=zetaa(i+1)
  72. end do
  73. do j=1,jen
  74. zetar(ien,j)=zeta(1,j)
  75. end do
  76. !
  77. ! *pr* norm pressure the right.
  78. !
  79. l=ien*jen*ken-1
  80. do i=2,l+1
  81. pra(i-1)=pb(i)
  82. end do
  83. do k=1,ken
  84. do j=1,jen
  85. pr(ien,j,k)=p(1,j,k)
  86. end do
  87. end do
  88. !
  89. !* 2. Computation of the terms.
  90. ! -------------------------
  91. l=ien*jen*2
  92. do i=1,l
  93. b1a(i)=0.
  94. end do
  95. !
  96. ! Computation of the terms containing windstress and surfaceslope.
  97. !
  98. l=ien*(jen-2)
  99. do i=ien+1,ien+l
  100. b1b(i,1)=tauxa(i)+g*dliha(i)*(zetaa(i)-zetara(i))*deptha(i)
  101. b1b(i,2)=tauya(i)+g*dpin*(zetara(i+ien)-zetaa(i-ien))*deptha(i)
  102. end do
  103. !
  104. ! Computation of the horizontal pressure differences in the entire
  105. ! water mass.
  106. !
  107. do k=1,ken
  108. do i=ien+1,ien+l
  109. b1b(i,1)=b1b(i,1)-dliha(i)*(prb(i,k)-pa(i,k))*deltaa(i,k)
  110. b1b(i,2)=b1b(i,2)-dpin*(pa(i-ien,k)-prb(i+ien,k))*deltaa(i,k)
  111. end do
  112. end do
  113. !
  114. ! Scaling with the depth.
  115. !
  116. do i=ien+1,ien+l
  117. if (deptha(i)>0) then
  118. b1b(i,1)=b1b(i,1)/deptha(i)
  119. b1b(i,2)=b1b(i,2)/deptha(i)
  120. end if
  121. end do
  122. !
  123. ! 3. Construction of the output array *b*.
  124. ! -------------------------------------
  125. !
  126. l=ien*jen
  127. m1=matrx/2
  128. j=-1
  129. do i=1,l
  130. if (numxa(i)>0.) then
  131. b(numxa(i)*2-1)=b1b(i,1)
  132. b(numxa(i)*2)=0.
  133. end if
  134. end do
  135. j=-1
  136. do i=1,l
  137. if (numxa(i)>0.) then
  138. b2(2*numxa(i)-1)=0.
  139. b2(2*numxa(i))=b1b(i,2)
  140. end if
  141. end do
  142. do i=1,matrx
  143. b(i)=b(i)+b2(i)
  144. end do
  145. ! do k=1,jen
  146. ! write (80,'("numx(:,",i4,")=",i5)') k
  147. ! write (80,'(16I5)') numx(:,k)
  148. ! enddo
  149. ! write (81,'(8e10.3)') b
  150. !
  151. end subroutine prefor1