limtab_2.F90 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. MODULE limtab_2
  2. !!======================================================================
  3. !! *** MODULE limtab_2 ***
  4. !! LIM : transform 1D (2D) array to a 2D (1D) table
  5. !!======================================================================
  6. #if defined key_lim2
  7. !!----------------------------------------------------------------------
  8. !! tab_2d_1d : 2-D <==> 1-D
  9. !! tab_1d_2d : 1-D <==> 2-D
  10. !!----------------------------------------------------------------------
  11. USE par_kind
  12. IMPLICIT NONE
  13. PRIVATE
  14. PUBLIC tab_2d_1d_2 ! called by limthd
  15. PUBLIC tab_1d_2d_2 ! called by limthd
  16. !!----------------------------------------------------------------------
  17. !! NEMO/LIM2 4.0 , UCL - NEMO Consortium (2010)
  18. !! $Id: limtab_2.F90 2715 2011-03-30 15:58:35Z rblod $
  19. !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
  20. !!----------------------------------------------------------------------
  21. CONTAINS
  22. SUBROUTINE tab_2d_1d_2 ( ndim1d, tab1d, tab2d, ndim2d_x, ndim2d_y, tab_ind )
  23. !!----------------------------------------------------------------------
  24. !! *** ROUTINE tab_2d_1d ***
  25. !!----------------------------------------------------------------------
  26. INTEGER , INTENT(in ) :: ndim1d, ndim2d_x, ndim2d_y ! 1D & 2D sizes
  27. REAL(wp), DIMENSION(ndim2d_x,ndim2d_y), INTENT(in ) :: tab2d ! input 2D field
  28. INTEGER , DIMENSION(ndim1d) , INTENT(in ) :: tab_ind ! input index
  29. REAL(wp), DIMENSION(ndim1d) , INTENT( out) :: tab1d ! output 1D field
  30. !
  31. INTEGER :: jn , jid, jjd
  32. !!----------------------------------------------------------------------
  33. DO jn = 1, ndim1d
  34. jid = MOD( tab_ind(jn) - 1 , ndim2d_x ) + 1
  35. jjd = ( tab_ind(jn) - 1 ) / ndim2d_x + 1
  36. tab1d( jn) = tab2d( jid, jjd)
  37. END DO
  38. END SUBROUTINE tab_2d_1d_2
  39. SUBROUTINE tab_1d_2d_2 ( ndim1d, tab2d, tab_ind, tab1d, ndim2d_x, ndim2d_y )
  40. !!----------------------------------------------------------------------
  41. !! *** ROUTINE tab_2d_1d ***
  42. !!----------------------------------------------------------------------
  43. INTEGER , INTENT(in ) :: ndim1d, ndim2d_x, ndim2d_y ! 1d & 2D sizes
  44. REAL(wp), DIMENSION(ndim1d) , INTENT(in ) :: tab1d ! input 1D field
  45. INTEGER , DIMENSION(ndim1d) , INTENT(in ) :: tab_ind ! input index
  46. REAL(wp), DIMENSION(ndim2d_x,ndim2d_y), INTENT( out) :: tab2d ! output 2D field
  47. !
  48. INTEGER :: jn , jid, jjd
  49. !!----------------------------------------------------------------------
  50. DO jn = 1, ndim1d
  51. jid = MOD( tab_ind(jn) - 1 , ndim2d_x ) + 1
  52. jjd = ( tab_ind(jn) - 1 ) / ndim2d_x + 1
  53. tab2d(jid, jjd) = tab1d( jn)
  54. END DO
  55. END SUBROUTINE tab_1d_2d_2
  56. #else
  57. !!----------------------------------------------------------------------
  58. !! Default option Dummy module NO LIM sea-ice model
  59. !!----------------------------------------------------------------------
  60. #endif
  61. !!======================================================================
  62. END MODULE limtab_2