source: trunk/LMDZ.COMMON/libf/phy_common/mod_phys_lmdz_omp_data.F90 @ 3554

Last change on this file since 3554 was 1682, checked in by emillour, 8 years ago

All GCMs: set things up to enable pluging physics with dynamico

  • dyn3d
  • gcm.F90 : move I/O initialization (dates) to be done before physics

initialization

  • dyn3dpar
  • gcm.F : move I/O initialization (dates) to be done before physics

initialization

  • dynphy_lonlat:
  • inigeomphy_mod.F90 : add ind_cell_glo computation and transfer

to init_geometry

  • phy_common:
  • geometry_mod.F90 : add ind_cell_glo module variable to store global

column index

  • print_control_mod.F90 : make initialization occur via init_print_control_mod

to avoid circular module dependencies

  • init_print_control_mod.F90 : added to initialize print_control_mod module

variables

  • mod_phys_lmdz_mpi_data.F90 : use print_control_mod (rather than iniprint.h)
  • mod_phys_lmdz_para.F90 : use print_control_mod (rather than iniprint.h)
  • mod_phys_lmdz_omp_data.F90 : add is_omp_master (alias of is_omp_root) module

variable and use print_control_mod (rather than
iniprint.h)

  • physics_distribution_mod.F90 : add call to init_dimphy in

init_physics_distribution

  • xios_writefield.F90 : generic routine to output field with XIOS (for debug)
  • misc:
  • handle_err_m.F90 : call abort_physic, rather than abort_gcm
  • wxios.F90 : updates to enable unstructured grids

set module variable g_ctx_name to "LMDZ"
wxios_init(): remove call to wxios_context_init
wxios_context_init(): call xios_context_initialize with COMM_LMDZ_PHY
add routine wxios_set_context() to get handle and set context to XIOS
wxios_domain_param(): change arguments and generate the domain in-place
add wxios_domain_param_unstructured(): generate domain for unstructured case

NB: access is via "domain group" (whereas it is via "domain" in

wxios_domain_param)

  • dynphy_lonlat/phy[std|mars|venus|titan]:
  • iniphysiq_mod.F90 : Remove call to init_dimphy (which is now done in

phy_common/physics_distribution_mod.F90)

EM

File size: 3.4 KB
Line 
1!
2!$Id: mod_phys_lmdz_omp_data.F90 2429 2016-01-27 12:43:09Z fairhead $
3!
4MODULE mod_phys_lmdz_omp_data
5
6  INTEGER,SAVE :: omp_size
7  INTEGER,SAVE :: omp_rank
8  LOGICAL,SAVE :: is_omp_root
9  LOGICAL,SAVE :: is_omp_master  ! alias of is_omp_root
10  LOGICAL,SAVE :: is_using_omp
11  LOGICAL,SAVE :: is_north_pole_phy, is_south_pole_phy
12 
13  INTEGER,SAVE,DIMENSION(:),ALLOCATABLE :: klon_omp_para_nb
14  INTEGER,SAVE,DIMENSION(:),ALLOCATABLE :: klon_omp_para_begin
15  INTEGER,SAVE,DIMENSION(:),ALLOCATABLE :: klon_omp_para_end   
16 
17  INTEGER,SAVE :: klon_omp
18  INTEGER,SAVE :: klon_omp_begin
19  INTEGER,SAVE :: klon_omp_end
20!$OMP  THREADPRIVATE(omp_rank,klon_omp,is_omp_root,is_omp_master,klon_omp_begin,klon_omp_end)
21!$OMP  THREADPRIVATE(is_north_pole_phy, is_south_pole_phy)
22
23CONTAINS
24 
25  SUBROUTINE Init_phys_lmdz_omp_data(klon_mpi)
26    USE dimphy
27    USE mod_phys_lmdz_mpi_data, ONLY : is_north_pole_dyn, is_south_pole_dyn
28    IMPLICIT NONE
29    INTEGER, INTENT(in) :: klon_mpi
30
31    INTEGER :: i
32
33    CHARACTER (LEN=20) :: modname='Init_phys_lmdz_omp_data'
34    CHARACTER (LEN=80) :: abort_message
35
36
37#ifdef CPP_OMP   
38    INTEGER :: OMP_GET_NUM_THREADS
39    EXTERNAL OMP_GET_NUM_THREADS
40    INTEGER :: OMP_GET_THREAD_NUM
41    EXTERNAL OMP_GET_THREAD_NUM
42#endif 
43
44#ifdef CPP_OMP
45!$OMP MASTER
46        is_using_omp=.TRUE.
47        omp_size=OMP_GET_NUM_THREADS()
48!$OMP END MASTER
49!$OMP BARRIER
50        omp_rank=OMP_GET_THREAD_NUM()   
51#else   
52    is_using_omp=.FALSE.
53    omp_size=1
54    omp_rank=0
55#endif
56
57   is_omp_root=.FALSE.
58!$OMP MASTER
59   IF (omp_rank==0) THEN
60     is_omp_root=.TRUE.
61   ELSE
62     abort_message = 'ANORMAL : OMP_MASTER /= 0'
63     CALL abort_physic (modname,abort_message,1)
64   ENDIF
65!$OMP END MASTER
66   is_omp_master=is_omp_root
67
68!$OMP MASTER
69
70    ALLOCATE(klon_omp_para_nb(0:omp_size-1))
71    ALLOCATE(klon_omp_para_begin(0:omp_size-1))
72    ALLOCATE(klon_omp_para_end(0:omp_size-1))
73   
74    DO i=0,omp_size-1
75      klon_omp_para_nb(i)=klon_mpi/omp_size
76      IF (i<MOD(klon_mpi,omp_size)) klon_omp_para_nb(i)=klon_omp_para_nb(i)+1
77    ENDDO
78   
79    klon_omp_para_begin(0) = 1
80    klon_omp_para_end(0) = klon_omp_para_nb(0)
81   
82    DO i=1,omp_size-1
83      klon_omp_para_begin(i)=klon_omp_para_end(i-1)+1
84      klon_omp_para_end(i)=klon_omp_para_begin(i)+klon_omp_para_nb(i)-1
85    ENDDO
86!$OMP END MASTER
87!$OMP BARRIER
88
89   if ((is_north_pole_dyn) .AND. (omp_rank == 0 )) then
90      is_north_pole_phy = .TRUE.
91    else
92      is_north_pole_phy = .FALSE.
93    endif
94    if ((is_south_pole_dyn) .AND. (omp_rank == omp_size-1)) then
95      is_south_pole_phy = .TRUE.
96    else
97      is_south_pole_phy = .FALSE.
98    endif
99   
100    klon_omp=klon_omp_para_nb(omp_rank)
101    klon_omp_begin=klon_omp_para_begin(omp_rank)
102    klon_omp_end=klon_omp_para_end(omp_rank)
103   
104    CALL Print_module_data
105   
106  END SUBROUTINE Init_phys_lmdz_omp_data
107
108  SUBROUTINE Print_module_data
109  USE print_control_mod, ONLY: lunout
110  IMPLICIT NONE
111
112!$OMP CRITICAL 
113  WRITE(lunout,*)'--------> TASK ',omp_rank
114  WRITE(lunout,*)'omp_size =',omp_size
115  WRITE(lunout,*)'omp_rank =',omp_rank
116  WRITE(lunout,*)'is_omp_root =',is_omp_root
117  WRITE(lunout,*)'klon_omp_para_nb =',klon_omp_para_nb
118  WRITE(lunout,*)'klon_omp_para_begin =',klon_omp_para_begin
119  WRITE(lunout,*)'klon_omp_para_end =',klon_omp_para_end   
120  WRITE(lunout,*)'klon_omp =',klon_omp
121  WRITE(lunout,*)'klon_omp_begin =',klon_omp_begin
122  WRITE(lunout,*)'klon_omp_end =',klon_omp_end   
123!$OMP END CRITICAL
124
125  END SUBROUTINE Print_module_data
126END MODULE mod_phys_lmdz_omp_data
Note: See TracBrowser for help on using the repository browser.