dom_xios.F90 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. MODULE dom_xios
  2. # if defined key_iomput
  3. USE dom_oce
  4. IMPLICIT NONE
  5. REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) :: lon_grid_T, lat_grid_T, area_grid_T
  6. REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) :: lon_grid_U, lat_grid_U, area_grid_U
  7. REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) :: lon_grid_V, lat_grid_V, area_grid_V
  8. REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) :: lon_grid_W, lat_grid_W, area_grid_W
  9. REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) :: bounds_lon_grid_T, bounds_lat_grid_T
  10. REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) :: bounds_lon_grid_U, bounds_lat_grid_U
  11. REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) :: bounds_lon_grid_V, bounds_lat_grid_V
  12. REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) :: bounds_lon_grid_W, bounds_lat_grid_W
  13. INTEGER, PUBLIC, SAVE :: n_ibegin, n_ni
  14. INTEGER, PUBLIC, SAVE :: n_jbegin, n_nj
  15. INTEGER, PUBLIC, SAVE :: n_data_ibegin, n_data_ni
  16. INTEGER, PUBLIC, SAVE :: n_data_jbegin, n_data_nj
  17. LOGICAL, PUBLIC, SAVE :: using_xios_coordinates=.FALSE.
  18. CONTAINS
  19. SUBROUTINE init_dom_xios(iin,ijn,iimppt,ijmppt,ildi,ildj,ilei,ilej)
  20. INTEGER,INTENT(IN) :: iin(jpnij), ijn(jpnij)
  21. INTEGER,INTENT(IN) :: iimppt(jpni,jpnj), ijmppt(jpni,jpnj)
  22. INTEGER,INTENT(IN) :: ildi(jpni,jpnj), ildj(jpni,jpnj)
  23. INTEGER,INTENT(IN) :: ilei(jpni,jpnj), ilej(jpni,jpnj)
  24. INTEGER :: rank(jpni,jpnj)
  25. LOGICAL :: tag_x(jpni,jpnj)
  26. LOGICAL :: tag_y(jpni,jpnj)
  27. INTEGER :: jproc,i,j
  28. INTEGER :: iend,jend
  29. rank(:,:)=-1
  30. tag_x(:,:)=.FALSE.
  31. tag_y(:,:)=.FALSE.
  32. DO jproc = 1, jpnij
  33. rank(iin(jproc),ijn(jproc))=jproc
  34. ENDDO
  35. !! Distribute holes to neighbour domains
  36. DO j=2,jpnj
  37. DO i=1,jpni
  38. IF (rank(i,j)==-1 .AND. rank(i,j-1)/=-1 .AND. .NOT. tag_x(i,j-1)) THEN
  39. rank(i,j)=rank(i,j-1)
  40. tag_y(i,j)=.TRUE.
  41. tag_y(i,j-1)=.TRUE.
  42. ENDIF
  43. ENDDO
  44. ENDDO
  45. DO j=jpnj-1,1,-1
  46. DO i=1,jpni
  47. IF (rank(i,j)==-1 .AND. rank(i,j+1)/=-1 .AND. .NOT. tag_x(i,j+1)) THEN
  48. rank(i,j)=rank(i,j+1)
  49. tag_y(i,j)=.TRUE.
  50. tag_y(i,j+1)=.TRUE.
  51. ENDIF
  52. ENDDO
  53. ENDDO
  54. DO j=1,jpnj
  55. DO i=2,jpni
  56. IF (rank(i,j)==-1 .AND. rank(i-1,j)/=-1 .AND. .NOT. tag_y(i-1,j)) THEN
  57. rank(i,j)=rank(i-1,j)
  58. tag_x(i,j)=.TRUE.
  59. tag_x(i-1,j)=.TRUE.
  60. ENDIF
  61. ENDDO
  62. ENDDO
  63. DO j=1,jpnj
  64. DO i=jpni-1,1,-1
  65. IF (rank(i,j)==-1 .AND. rank(i+1,j)/=-1 .AND. .NOT. tag_y(i+1,j)) THEN
  66. rank(i,j)=rank(i+1,j)
  67. tag_x(i,j)=.TRUE.
  68. tag_x(i+1,j)=.TRUE.
  69. ENDIF
  70. ENDDO
  71. ENDDO
  72. !!!! compute new domain decomposition for xios
  73. n_ibegin=jpiglo
  74. n_jbegin=jpjglo
  75. iend=-1
  76. jend=-1
  77. DO j=1,jpnj
  78. DO i=1,jpni
  79. IF (rank(i,j)==narea) THEN
  80. n_ibegin=min(n_ibegin,iimppt(i,j)+ildi(i,j)-1)
  81. iend=max(iend,iimppt(i,j)+ilei(i,j)-1)
  82. n_jbegin=min(n_jbegin,ijmppt(i,j)+ildj(i,j)-1)
  83. jend=max(jend,ijmppt(i,j)+ilej(i,j)-1)
  84. ENDIF
  85. ENDDO
  86. ENDDO
  87. n_ni=iend-n_ibegin+1
  88. n_nj=jend-n_jbegin+1
  89. n_data_ibegin=nimpp-n_ibegin
  90. n_data_ni=jpi
  91. n_data_jbegin=njmpp-n_jbegin
  92. n_data_nj=jpj
  93. ALLOCATE(lon_grid_T(n_ni,n_nj), lat_grid_T(n_ni,n_nj),area_grid_T(n_ni,n_nj))
  94. ALLOCATE(lon_grid_U(n_ni,n_nj), lat_grid_U(n_ni,n_nj),area_grid_U(n_ni,n_nj))
  95. ALLOCATE(lon_grid_V(n_ni,n_nj), lat_grid_V(n_ni,n_nj),area_grid_V(n_ni,n_nj))
  96. ALLOCATE(lon_grid_W(n_ni,n_nj), lat_grid_W(n_ni,n_nj),area_grid_W(n_ni,n_nj))
  97. ALLOCATE(bounds_lon_grid_T(4,n_ni,n_nj), bounds_lat_grid_T(4,n_ni,n_nj))
  98. ALLOCATE(bounds_lon_grid_U(4,n_ni,n_nj), bounds_lat_grid_U(4,n_ni,n_nj))
  99. ALLOCATE(bounds_lon_grid_V(4,n_ni,n_nj), bounds_lat_grid_V(4,n_ni,n_nj))
  100. ALLOCATE(bounds_lon_grid_W(4,n_ni,n_nj), bounds_lat_grid_W(4,n_ni,n_nj))
  101. END SUBROUTINE init_dom_xios
  102. #else
  103. CONTAINS
  104. USE par_oce
  105. SUBROUTINE init_dom_xios(iin,ijn,iimppt,ijmppt,ildi,ildj,ilei,ilej)
  106. INTEGER,INTENT(IN) :: iin(jpnij), ijn(jpnij)
  107. INTEGER,INTENT(IN) :: iimppt(jpni,jpnj), ijmppt(jpni,jpnj)
  108. INTEGER,INTENT(IN) :: ildi(jpni,jpnj), ildj(jpni,jpnj)
  109. INTEGER,INTENT(IN) :: ilei(jpni,jpnj), ilej(jpni,jpnj)
  110. END SUBROUTINE init_dom_xios
  111. #endif
  112. END MODULE dom_xios