limtab.F90 3.6 KB

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