mpp_map.F90 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. MODULE mpp_map
  2. !!======================================================================
  3. !! *** MODULE mpp_mpa ***
  4. !! NEMOVAR: MPP global grid point mapping to processors
  5. !!======================================================================
  6. !! History : 2.0 ! 2007-08 (K. Mogensen) Original code
  7. !!----------------------------------------------------------------------
  8. !!----------------------------------------------------------------------
  9. !! mppmap_init : Initialize mppmap.
  10. !!----------------------------------------------------------------------
  11. USE par_kind, ONLY : wp ! Precision variables
  12. USE par_oce , ONLY : jpi, jpj ! Ocean parameters
  13. USE dom_oce , ONLY : mig, mjg, nldi, nlei, nldj, nlej, narea ! Ocean space and time domain variables
  14. #if defined key_mpp_mpi
  15. USE lib_mpp, ONLY : mpi_comm_opa ! MPP library
  16. #endif
  17. USE in_out_manager ! I/O manager
  18. IMPLICIT NONE
  19. PRIVATE
  20. PUBLIC :: mppmap_init, mppmap !: ???
  21. INTEGER, DIMENSION(:,:), ALLOCATABLE :: mppmap ! ???
  22. !!----------------------------------------------------------------------
  23. !! NEMO/OPA 3.3 , NEMO Consortium (2010)
  24. !! $Id: mpp_map.F90 4245 2013-11-19 11:19:21Z cetlod $
  25. !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
  26. !!----------------------------------------------------------------------
  27. CONTAINS
  28. SUBROUTINE mppmap_init
  29. !!----------------------------------------------------------------------
  30. !! *** ROUTINE mppmap_init ***
  31. !!
  32. !! ** Purpose : Setup a global map of processor rank for all gridpoints
  33. !!
  34. !! ** Method : MPI all reduce.
  35. !!
  36. !! ** Action : This does only work for MPI.
  37. !!
  38. !! References : http://www.mpi-forum.org
  39. !!----------------------------------------------------------------------
  40. INTEGER, DIMENSION(:,:), ALLOCATABLE :: imppmap !
  41. #if defined key_mpp_mpi
  42. INTEGER :: ierr
  43. INCLUDE 'mpif.h'
  44. #endif
  45. !!----------------------------------------------------------------------
  46. IF (.NOT. ALLOCATED(mppmap)) THEN
  47. ALLOCATE( &
  48. & mppmap(jpiglo,jpjglo) &
  49. & )
  50. ENDIF
  51. ! Initialize local imppmap
  52. ALLOCATE( &
  53. & imppmap(jpiglo,jpjglo) &
  54. & )
  55. imppmap(:,:) = 0
  56. ! Setup local grid points
  57. imppmap(mig(nldi):mig(nlei),mjg(nldj):mjg(nlej)) = narea
  58. ! Get global data
  59. #if defined key_mpp_mpi
  60. ! Call the MPI library to find the max across processors
  61. CALL mpi_allreduce( imppmap, mppmap, jpiglo*jpjglo, mpi_integer, &
  62. & mpi_max, mpi_comm_opa, ierr )
  63. #else
  64. ! No MPP: Just copy the data
  65. mppmap(:,:) = imppmap(:,:)
  66. #endif
  67. !
  68. END SUBROUTINE mppmap_init
  69. !!======================================================================
  70. END MODULE mpp_map