geometry.F90 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. !### macro's #####################################################
  2. !
  3. #define TRACEBACK write (gol,'("in ",a," (",a,", line",i5,")")') rname, __FILE__, __LINE__; call goErr
  4. #define IF_NOTOK_RETURN(action) if (status/=0) then; TRACEBACK; action; return; end if
  5. #define IF_ERROR_RETURN(action) if (status> 0) then; TRACEBACK; action; return; end if
  6. !
  7. #include "tm5.inc"
  8. !
  9. !---------------------------------------------------------------------------
  10. ! TM5-MP !
  11. !---------------------------------------------------------------------------
  12. !BOP
  13. !
  14. ! !MODULE: GEOMETRY
  15. !
  16. ! !DESCRIPTION: geometry related routines.
  17. !\\
  18. !\\
  19. ! !INTERFACE:
  20. !
  21. MODULE GEOMETRY
  22. !
  23. ! !USES:
  24. !
  25. use GO , only : gol, goErr, goPr
  26. use dims, only : lm
  27. IMPLICIT NONE
  28. PRIVATE
  29. !
  30. ! !PUBLIC MEMBER FUNCTIONS:
  31. !
  32. public :: geomtryv
  33. public :: geomtryh
  34. public :: calc_dxy
  35. !
  36. ! !REMARKS:
  37. !
  38. !EOP
  39. !-----------------------------------------------------------------------
  40. CONTAINS
  41. !-----------------------------------------------------------------------
  42. ! TM5-MP !
  43. !-----------------------------------------------------------------------
  44. !BOP
  45. !
  46. ! !IROUTINE: GEOMTRYH
  47. !
  48. ! !DESCRIPTION: fill area variables: region_dat(region)%dxyp and areag
  49. !\\
  50. !\\
  51. ! !INTERFACE:
  52. !
  53. SUBROUTINE GEOMTRYH( region )
  54. !
  55. ! !USES:
  56. !
  57. use binas, only: ae, pi
  58. use dims, only: dx, gtor, xref, dy, yref, im, jm, ybeg, areag
  59. use global_data, only: region_dat
  60. use tm5_distgrid, only: dgrid, Get_DistGrid
  61. !
  62. ! !INPUT PARAMETERS:
  63. !
  64. integer, intent(in) :: region
  65. !
  66. ! !REVISION HISTORY:
  67. ! mh, 27-jun-1989
  68. ! mh, 26-sep-1992
  69. ! aj, 23-may-1995
  70. ! mk, 5-nov-1999 zoom version
  71. ! 9 Nov 2011 - P. Le Sager - adapted for TM5-MP
  72. !
  73. ! !REMARKS:
  74. ! (1) areag is never used, but saved in several output files
  75. ! (2) FIXME ZOOM : NOT TESTED FOR REGION > 1
  76. !
  77. !EOP
  78. !---------------------------------------------------------------------
  79. !BOC
  80. real, pointer :: dxyp(:)
  81. integer :: j, i0, i1, j0, j1
  82. real :: dxx,dyy,lat,area, deltaX, yb
  83. ! --- begin ------------------------------------
  84. dxyp => region_dat(region)%dxyp
  85. call Get_DistGrid( dgrid(region), I_STRT=i0, I_STOP=i1, J_STRT=j0, J_STOP=j1 )
  86. !-------------------------------------------
  87. ! Standard horizontal geometry parent region (always global)
  88. !-------------------------------------------
  89. dxx = dx*gtor/xref(region)
  90. dyy = dy*gtor/yref(region)
  91. deltaX = (i1-i0+1)
  92. ! Cannot do that for bitwise reproductibility :
  93. ! yb = ybeg(region) + ( j0 - 1 ) * dy
  94. ! lat = yb*gtor
  95. ! Need to loop globally, and start at j=1:
  96. lat = ybeg(region)*gtor
  97. area =0.0
  98. do j=1,jm(region)
  99. if (j>=j0.and.j<=j1) then
  100. dxyp(j) = dxx * (sin(lat+dyy)-sin(lat))*ae**2
  101. area = area + dxyp(j)*deltaX
  102. end if
  103. lat = lat+dyy
  104. end do
  105. areag(region) = area
  106. nullify(dxyp)
  107. END SUBROUTINE GEOMTRYH
  108. !EOC
  109. !-------------------------------------------------------------------------
  110. ! TM5 !
  111. !-------------------------------------------------------------------------
  112. !BOP
  113. !
  114. ! !IROUTINE: CALC_DXY
  115. !
  116. ! !DESCRIPTION: for a 1x1 grid, covering the [-90., -90+nlat] latitude
  117. ! range, compute the area of each grid cells.
  118. !
  119. !\\
  120. !\\
  121. ! !INTERFACE:
  122. !
  123. SUBROUTINE CALC_DXY( dxy, nlat )
  124. !
  125. ! !USES:
  126. !
  127. use binas, only : ae, pi
  128. use dims, only : gtor, nlon360
  129. !
  130. ! !INPUT PARAMETERS:
  131. !
  132. integer, intent(in) :: nlat ! number of 1 degree zonal bands
  133. !
  134. ! !OUTPUT PARAMETERS:
  135. !
  136. real, intent(out) :: dxy(nlat) ! area for each zonal band
  137. !
  138. ! !REVISION HISTORY:
  139. ! 9 Nov 2011 - P. Le Sager -
  140. !
  141. ! !REMARKS:
  142. ! (1) this is called only once in the initexit/start routine, and with
  143. ! nlat=180, to fill the dims:dxy11 variable
  144. !
  145. !EOP
  146. !------------------------------------------------------------------------
  147. !BOC
  148. real :: dxx, dyy, lat
  149. integer :: j
  150. dxx = 1.0*gtor
  151. dyy = 1.0*gtor
  152. lat = -90.0*gtor
  153. do j=1,nlat
  154. dxy(j) = dxx * (sin(lat+dyy)-sin(lat))*ae**2
  155. lat = lat+dyy
  156. end do
  157. END SUBROUTINE CALC_DXY
  158. !EOC
  159. !-------------------------------------------------------
  160. ! TM5 !
  161. !-------------------------------------------------------
  162. !BOP
  163. !
  164. ! !IROUTINE: GEOMTRYV
  165. !
  166. ! !DESCRIPTION: define the vertical geometry of the tm
  167. ! model grid v9.1knmi (aj, 30-8-1995)
  168. !\\
  169. !\\
  170. ! !INTERFACE:
  171. !
  172. SUBROUTINE GEOMTRYV()
  173. !
  174. ! !USES:
  175. !
  176. use binas , only : grav
  177. use const_ec_v , only : a_ec, b_ec
  178. use dims , only : echlevs, at, bt, lm
  179. !
  180. ! !REVISION HISTORY:
  181. !
  182. ! !REMARKS:
  183. ! (1) used only by meteo_init_grid
  184. !
  185. !EOP
  186. !-----------------------------------------------------
  187. !BOC
  188. integer :: l
  189. ! hybride coeff at TM levels
  190. do l = 1, lm(1)+1
  191. at(l) = a_ec(echlevs(l-1))
  192. bt(l) = b_ec(echlevs(l-1))
  193. end do
  194. END SUBROUTINE GEOMTRYV
  195. !EOC
  196. END MODULE GEOMETRY