bdy_oce.F90 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. MODULE bdy_oce
  2. !!======================================================================
  3. !! *** MODULE bdy_oce ***
  4. !! Unstructured Open Boundary Cond. : define related variables
  5. !!======================================================================
  6. !! History : 1.0 ! 2001-05 (J. Chanut, A. Sellar) Original code
  7. !! 3.0 ! 2008-04 (NEMO team) add in the reference version
  8. !! 3.3 ! 2010-09 (D. Storkey) add ice boundary conditions
  9. !! 3.4 ! 2011 (D. Storkey) rewrite in preparation for OBC-BDY merge
  10. !! 3.6 ! 2012-01 (C. Rousset) add ice boundary conditions for lim3
  11. !!----------------------------------------------------------------------
  12. #if defined key_bdy
  13. !!----------------------------------------------------------------------
  14. !! 'key_bdy' Unstructured Open Boundary Condition
  15. !!----------------------------------------------------------------------
  16. USE par_oce ! ocean parameters
  17. USE bdy_par ! Unstructured boundary parameters
  18. USE lib_mpp ! distributed memory computing
  19. IMPLICIT NONE
  20. PUBLIC
  21. TYPE, PUBLIC :: OBC_INDEX !: Indices and weights which define the open boundary
  22. INTEGER, DIMENSION(jpbgrd) :: nblen
  23. INTEGER, DIMENSION(jpbgrd) :: nblenrim
  24. INTEGER, POINTER, DIMENSION(:,:) :: nbi
  25. INTEGER, POINTER, DIMENSION(:,:) :: nbj
  26. INTEGER, POINTER, DIMENSION(:,:) :: nbr
  27. INTEGER, POINTER, DIMENSION(:,:) :: nbmap
  28. REAL(wp) , POINTER, DIMENSION(:,:) :: nbw
  29. REAL(wp) , POINTER, DIMENSION(:,:) :: nbd
  30. REAL(wp) , POINTER, DIMENSION(:,:) :: nbdout
  31. REAL(wp) , POINTER, DIMENSION(:,:) :: flagu
  32. REAL(wp) , POINTER, DIMENSION(:,:) :: flagv
  33. END TYPE OBC_INDEX
  34. !! Logicals in OBC_DATA structure are true if the chosen algorithm requires this
  35. !! field as external data. If true the data can come from external files
  36. !! or model initial conditions. If false then no "external" data array
  37. !! is required for this field.
  38. TYPE, PUBLIC :: OBC_DATA !: Storage for external data
  39. INTEGER, DIMENSION(2) :: nread
  40. LOGICAL :: ll_ssh
  41. LOGICAL :: ll_u2d
  42. LOGICAL :: ll_v2d
  43. LOGICAL :: ll_u3d
  44. LOGICAL :: ll_v3d
  45. LOGICAL :: ll_tem
  46. LOGICAL :: ll_sal
  47. REAL(wp), POINTER, DIMENSION(:) :: ssh
  48. REAL(wp), POINTER, DIMENSION(:) :: u2d
  49. REAL(wp), POINTER, DIMENSION(:) :: v2d
  50. REAL(wp), POINTER, DIMENSION(:,:) :: u3d
  51. REAL(wp), POINTER, DIMENSION(:,:) :: v3d
  52. REAL(wp), POINTER, DIMENSION(:,:) :: tem
  53. REAL(wp), POINTER, DIMENSION(:,:) :: sal
  54. #if defined key_lim2
  55. LOGICAL :: ll_frld
  56. LOGICAL :: ll_hicif
  57. LOGICAL :: ll_hsnif
  58. REAL(wp), POINTER, DIMENSION(:) :: frld
  59. REAL(wp), POINTER, DIMENSION(:) :: hicif
  60. REAL(wp), POINTER, DIMENSION(:) :: hsnif
  61. #elif defined key_lim3
  62. LOGICAL :: ll_a_i
  63. LOGICAL :: ll_ht_i
  64. LOGICAL :: ll_ht_s
  65. REAL, POINTER, DIMENSION(:,:) :: a_i !: now ice leads fraction climatology
  66. REAL, POINTER, DIMENSION(:,:) :: ht_i !: Now ice thickness climatology
  67. REAL, POINTER, DIMENSION(:,:) :: ht_s !: now snow thickness
  68. #endif
  69. END TYPE OBC_DATA
  70. !!----------------------------------------------------------------------
  71. !! Namelist variables
  72. !!----------------------------------------------------------------------
  73. CHARACTER(len=80), DIMENSION(jp_bdy) :: cn_coords_file !: Name of bdy coordinates file
  74. CHARACTER(len=80) :: cn_mask_file !: Name of bdy mask file
  75. !
  76. LOGICAL, DIMENSION(jp_bdy) :: ln_coords_file !: =T read bdy coordinates from file;
  77. ! !: =F read bdy coordinates from namelist
  78. LOGICAL :: ln_mask_file !: =T read bdymask from file
  79. LOGICAL :: ln_vol !: =T volume correction
  80. !
  81. INTEGER :: nb_bdy !: number of open boundary sets
  82. INTEGER, DIMENSION(jp_bdy) :: nn_rimwidth !: boundary rim width for Flow Relaxation Scheme
  83. INTEGER :: nn_volctl !: = 0 the total volume will have the variability of the surface Flux E-P
  84. ! ! = 1 the volume will be constant during all the integration.
  85. CHARACTER(len=20), DIMENSION(jp_bdy) :: cn_dyn2d ! Choice of boundary condition for barotropic variables (U,V,SSH)
  86. INTEGER, DIMENSION(jp_bdy) :: nn_dyn2d_dta !: = 0 use the initial state as bdy dta ;
  87. !: = 1 read it in a NetCDF file
  88. !: = 2 read tidal harmonic forcing from a NetCDF file
  89. !: = 3 read external data AND tidal harmonic forcing from NetCDF files
  90. CHARACTER(len=20), DIMENSION(jp_bdy) :: cn_dyn3d ! Choice of boundary condition for baroclinic velocities
  91. INTEGER, DIMENSION(jp_bdy) :: nn_dyn3d_dta !: = 0 use the initial state as bdy dta ;
  92. !: = 1 read it in a NetCDF file
  93. CHARACTER(len=20), DIMENSION(jp_bdy) :: cn_tra ! Choice of boundary condition for active tracers (T and S)
  94. INTEGER, DIMENSION(jp_bdy) :: nn_tra_dta !: = 0 use the initial state as bdy dta ;
  95. !: = 1 read it in a NetCDF file
  96. LOGICAL, DIMENSION(jp_bdy) :: ln_tra_dmp !: =T Tracer damping
  97. LOGICAL, DIMENSION(jp_bdy) :: ln_dyn3d_dmp !: =T Baroclinic velocity damping
  98. REAL(wp), DIMENSION(jp_bdy) :: rn_time_dmp !: Damping time scale in days
  99. REAL(wp), DIMENSION(jp_bdy) :: rn_time_dmp_out !: Damping time scale in days at radiation outflow points
  100. CHARACTER(len=20), DIMENSION(jp_bdy) :: cn_ice_lim ! Choice of boundary condition for sea ice variables
  101. INTEGER, DIMENSION(jp_bdy) :: nn_ice_lim_dta !: = 0 use the initial state as bdy dta ;
  102. !: = 1 read it in a NetCDF file
  103. REAL(wp), DIMENSION(jp_bdy) :: rn_ice_tem !: choice of the temperature of incoming sea ice
  104. REAL(wp), DIMENSION(jp_bdy) :: rn_ice_sal !: choice of the salinity of incoming sea ice
  105. REAL(wp), DIMENSION(jp_bdy) :: rn_ice_age !: choice of the age of incoming sea ice
  106. !
  107. !!----------------------------------------------------------------------
  108. !! Global variables
  109. !!----------------------------------------------------------------------
  110. REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:), TARGET :: bdytmask !: Mask defining computational domain at T-points
  111. REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:), TARGET :: bdyumask !: Mask defining computational domain at U-points
  112. REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:), TARGET :: bdyvmask !: Mask defining computational domain at V-points
  113. REAL(wp) :: bdysurftot !: Lateral surface of unstructured open boundary
  114. !!----------------------------------------------------------------------
  115. !! open boundary data variables
  116. !!----------------------------------------------------------------------
  117. INTEGER, DIMENSION(jp_bdy) :: nn_dta !: =0 => *all* data is set to initial conditions
  118. !: =1 => some data to be read in from data files
  119. REAL(wp), ALLOCATABLE, DIMENSION(:,:,:), TARGET :: dta_global !: workspace for reading in global data arrays (unstr. bdy)
  120. REAL(wp), ALLOCATABLE, DIMENSION(:,:,:), TARGET :: dta_global2 !: workspace for reading in global data arrays (struct. bdy)
  121. !$AGRIF_DO_NOT_TREAT
  122. TYPE(OBC_INDEX), DIMENSION(jp_bdy), TARGET :: idx_bdy !: bdy indices (local process)
  123. TYPE(OBC_DATA) , DIMENSION(jp_bdy), TARGET :: dta_bdy !: bdy external data (local process)
  124. !$AGRIF_END_DO_NOT_TREAT
  125. !!----------------------------------------------------------------------
  126. !! NEMO/OPA 4.0 , NEMO Consortium (2011)
  127. !! $Id: bdy_oce.F90 4699 2014-07-02 11:39:48Z clem $
  128. !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
  129. !!----------------------------------------------------------------------
  130. CONTAINS
  131. FUNCTION bdy_oce_alloc()
  132. !!----------------------------------------------------------------------
  133. USE lib_mpp, ONLY: ctl_warn, mpp_sum
  134. !
  135. INTEGER :: bdy_oce_alloc
  136. !!----------------------------------------------------------------------
  137. !
  138. ALLOCATE( bdytmask(jpi,jpj) , bdyumask(jpi,jpj), bdyvmask(jpi,jpj), &
  139. & STAT=bdy_oce_alloc )
  140. !
  141. ! Initialize masks
  142. bdytmask(:,:) = 1._wp
  143. bdyumask(:,:) = 1._wp
  144. bdyvmask(:,:) = 1._wp
  145. !
  146. IF( lk_mpp ) CALL mpp_sum ( bdy_oce_alloc )
  147. IF( bdy_oce_alloc /= 0 ) CALL ctl_warn('bdy_oce_alloc: failed to allocate arrays.')
  148. !
  149. END FUNCTION bdy_oce_alloc
  150. #else
  151. !!----------------------------------------------------------------------
  152. !! Dummy module NO Unstructured Open Boundary Condition
  153. !!----------------------------------------------------------------------
  154. LOGICAL :: ln_tides = .false. !: =T apply tidal harmonic forcing along open boundaries
  155. #endif
  156. !!======================================================================
  157. END MODULE bdy_oce