aver.f 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. ! ==================================================================
  2. subroutine aver(knt,ksum)
  3. use lsgvar
  4. implicit none
  5. !
  6. ! ------------------------------------------------------------------
  7. !
  8. !**** *aver* averages data sets.
  9. ! When mod(knt,ksum) equals zero, the averaging is performed.
  10. !
  11. ! by U. Mikolajewicz 1/89.
  12. ! optimzed by E. Kirk 2/2008
  13. !
  14. !* Input.
  15. ! ------
  16. ! *knt* actual time step (via parameterlist).
  17. ! *ksum* number of data sets to be averaged (via parameterlist).
  18. ! Various data sets for 1 time step via module lsgvar
  19. !
  20. !* Output.
  21. ! -------
  22. ! averaged data sets via module lsgvar
  23. !
  24. !* Interface.
  25. ! ----------
  26. ! *call* *aver(knt,ksum)*
  27. !
  28. ! ------------------------------------------------------------------
  29. integer, intent(in) :: knt
  30. integer, intent(in) :: ksum
  31. integer, save :: ncount = 0
  32. real (kind=8) :: fakt
  33. real (kind=8),save :: tmea(ienjen,ken)
  34. real (kind=8),save :: smea(ienjen,ken)
  35. real (kind=8),save :: umea(ienjen,ken)
  36. real (kind=8),save :: vmea(ienjen,ken)
  37. real (kind=8),save :: wmea(ienjen,ken)
  38. real (kind=8),save :: cmea(ienjen,ken)
  39. real (kind=8),save :: zmea(ienjen),simea(ienjen),fhmea(ienjen)
  40. real (kind=8),save :: fwmea(ienjen),ubmea(ienjen),vbmea(ienjen)
  41. real (kind=8),save :: hfmea(ienjen),psimea(ienjen),flwmea(ienjen)
  42. real (kind=8),save :: txmea(ienjen),tymea(ienjen),tbmea(ienjen)
  43. !
  44. !* 1. Copy or sum up
  45. ! ---------------
  46. !
  47. ! ncount counts the number of data sets summed up.
  48. !
  49. if (ncount == 0) then
  50. tmea(:,:) = ta(:,:)
  51. smea(:,:) = sa(:,:)
  52. umea(:,:) = utota(:,:)
  53. vmea(:,:) = vtota(:,:)
  54. wmea(:,:) = wa(:,:)
  55. cmea(:,:) = convaa(:,:)
  56. flwmea(:) = flwa(:)
  57. psimea(:) = psia(:)
  58. simea(:) = sicea(:)
  59. ubmea(:) = uba(:)
  60. vbmea(:) = vba(:)
  61. fhmea(:) = flha(:)
  62. fwmea(:) = fwa(:)
  63. txmea(:) = tauxa(:)
  64. tymea(:) = tauya(:)
  65. tbmea(:) = tba(:)
  66. hfmea(:) = hfa(:)
  67. zmea(:) = zetaa(:)
  68. else
  69. tmea(:,:) = tmea(:,:) + ta(:,:)
  70. smea(:,:) = smea(:,:) + sa(:,:)
  71. umea(:,:) = umea(:,:) + utota(:,:)
  72. vmea(:,:) = vmea(:,:) + vtota(:,:)
  73. wmea(:,:) = wmea(:,:) + wa(:,:)
  74. cmea(:,:) = cmea(:,:) + convaa(:,:)
  75. flwmea(:) = flwmea(:) + flwa(:)
  76. psimea(:) = psimea(:) + psia(:)
  77. simea(:) = simea(:) + sicea(:)
  78. ubmea(:) = ubmea(:) + uba(:)
  79. vbmea(:) = vbmea(:) + vba(:)
  80. fhmea(:) = fhmea(:) + flha(:)
  81. fwmea(:) = fwmea(:) + fwa(:)
  82. txmea(:) = txmea(:) + tauxa(:)
  83. tymea(:) = tymea(:) + tauya(:)
  84. tbmea(:) = tbmea(:) + tba(:)
  85. hfmea(:) = hfmea(:) + hfa(:)
  86. zmea(:) = zmea(:) + zetaa(:)
  87. end if
  88. ncount=ncount+1
  89. !
  90. !* 2. Final processing.
  91. ! -----------------
  92. if (mod(knt,ksum)/=0) return
  93. if (ncount<ksum-2) then
  94. print *," AVER: Warning !! average from begin of restart"
  95. print *," nstep=",knt," ncount=",ncount
  96. end if
  97. !
  98. !
  99. ! Divide through *ncount*.
  100. !
  101. fakt=1.0/float(ncount)
  102. !
  103. tmea(:,:) = tmea(:,:) * fakt
  104. smea(:,:) = smea(:,:) * fakt
  105. umea(:,:) = umea(:,:) * fakt
  106. vmea(:,:) = vmea(:,:) * fakt
  107. wmea(:,:) = wmea(:,:) * fakt
  108. cmea(:,:) = cmea(:,:) * fakt
  109. flwmea(:) = flwmea(:) * fakt
  110. psimea(:) = psimea(:) * fakt
  111. simea(:) = simea(:) * fakt
  112. ubmea(:) = ubmea(:) * fakt
  113. vbmea(:) = vbmea(:) * fakt
  114. fhmea(:) = fhmea(:) * fakt
  115. fwmea(:) = fwmea(:) * fakt
  116. txmea(:) = txmea(:) * fakt
  117. tymea(:) = tymea(:) * fakt
  118. tbmea(:) = tbmea(:) * fakt
  119. hfmea(:) = hfmea(:) * fakt
  120. zmea(:) = zmea(:) * fakt
  121. call outmea(tmea,smea,umea,vmea,zmea,simea,fhmea,flwmea,ubmea &
  122. & ,vbmea,wmea,cmea,txmea,tymea,tbmea,hfmea,psimea,fwmea &
  123. & ,ncount,knt)
  124. ncount=0
  125. return
  126. end subroutine aver