source: trunk/LMDZ.MARS/libf/phy_common/mod_phys_lmdz_omp_data.F90 @ 1621

Last change on this file since 1621 was 1543, checked in by emillour, 9 years ago

All models: Further adaptations to keep up with changes in LMDZ5 concerning
physics/dynamics separation:

  • dyn3d:
  • adapted gcm.F so that all physics initializations are now done in iniphysiq.
  • dyn3dpar:
  • adapted gcm.F so that all physics initializations are now done in iniphysiq.
  • updated calfis_p.F to follow up with changes.
  • copied over updated "bands.F90" from LMDZ5.
  • dynphy_lonlat:
  • calfis_p.F90, mod_interface_dyn_phys.F90, follow up of changes in phy_common/mod_* routines
  • phy_common:
  • added "geometry_mod.F90" to store information about the grid (replaces phy*/comgeomphy.F90) and give variables friendlier names: rlond => longitude , rlatd => latitude, airephy => cell_area, cuphy => dx , cvphy => dy
  • added "physics_distribution_mod.F90"
  • updated "mod_grid_phy_lmdz.F90", "mod_phys_lmdz_mpi_data.F90", "mod_phys_lmdz_para.F90", "mod_phys_lmdz_mpi_transfert.F90", "mod_grid_phy_lmdz.F90", "mod_phys_lmdz_omp_data.F90", "mod_phys_lmdz_omp_transfert.F90", "write_field_phy.F90" and "ioipsl_getin_p_mod.F90" to LMDZ5 versions.
  • phy[venus/titan/mars/std]:
  • removed "init_phys_lmdz.F90", "comgeomphy.F90"; adapted routines to use geometry_mod (longitude, latitude, cell_area, etc.)

EM

File size: 2.8 KB
Line 
1!
2!$Id: mod_phys_lmdz_omp_data.F90 2326 2015-07-10 12:24:29Z emillour $
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_using_omp
10 
11  INTEGER,SAVE,DIMENSION(:),ALLOCATABLE :: klon_omp_para_nb
12  INTEGER,SAVE,DIMENSION(:),ALLOCATABLE :: klon_omp_para_begin
13  INTEGER,SAVE,DIMENSION(:),ALLOCATABLE :: klon_omp_para_end   
14 
15  INTEGER,SAVE :: klon_omp
16  INTEGER,SAVE :: klon_omp_begin
17  INTEGER,SAVE :: klon_omp_end
18!$OMP  THREADPRIVATE(omp_rank,klon_omp,is_omp_root,klon_omp_begin,klon_omp_end)
19
20CONTAINS
21 
22  SUBROUTINE Init_phys_lmdz_omp_data(klon_mpi)
23    USE dimphy
24    IMPLICIT NONE
25    INTEGER, INTENT(in) :: klon_mpi
26
27    INTEGER :: i
28
29    CHARACTER (LEN=20) :: modname='Init_phys_lmdz_omp_data'
30    CHARACTER (LEN=80) :: abort_message
31
32
33#ifdef CPP_OMP   
34    INTEGER :: OMP_GET_NUM_THREADS
35    EXTERNAL OMP_GET_NUM_THREADS
36    INTEGER :: OMP_GET_THREAD_NUM
37    EXTERNAL OMP_GET_THREAD_NUM
38#endif 
39
40#ifdef CPP_OMP
41!$OMP MASTER
42        is_using_omp=.TRUE.
43        omp_size=OMP_GET_NUM_THREADS()
44!$OMP END MASTER
45        omp_rank=OMP_GET_THREAD_NUM()   
46#else   
47    is_using_omp=.FALSE.
48    omp_size=1
49    omp_rank=0
50#endif
51
52   is_omp_root=.FALSE.
53!$OMP MASTER
54   IF (omp_rank==0) THEN
55     is_omp_root=.TRUE.
56   ELSE
57     abort_message = 'ANORMAL : OMP_MASTER /= 0'
58     CALL abort_gcm (modname,abort_message,1)
59   ENDIF
60!$OMP END MASTER
61
62
63!$OMP MASTER
64    ALLOCATE(klon_omp_para_nb(0:omp_size-1))
65    ALLOCATE(klon_omp_para_begin(0:omp_size-1))
66    ALLOCATE(klon_omp_para_end(0:omp_size-1))
67   
68    DO i=0,omp_size-1
69      klon_omp_para_nb(i)=klon_mpi/omp_size
70      IF (i<MOD(klon_mpi,omp_size)) klon_omp_para_nb(i)=klon_omp_para_nb(i)+1
71    ENDDO
72   
73    klon_omp_para_begin(0) = 1
74    klon_omp_para_end(0) = klon_omp_para_nb(0)
75   
76    DO i=1,omp_size-1
77      klon_omp_para_begin(i)=klon_omp_para_end(i-1)+1
78      klon_omp_para_end(i)=klon_omp_para_begin(i)+klon_omp_para_nb(i)-1
79    ENDDO
80!$OMP END MASTER
81!$OMP BARRIER
82   
83    klon_omp=klon_omp_para_nb(omp_rank)
84    klon_omp_begin=klon_omp_para_begin(omp_rank)
85    klon_omp_end=klon_omp_para_end(omp_rank)
86   
87    CALL Print_module_data
88   
89  END SUBROUTINE Init_phys_lmdz_omp_data
90
91  SUBROUTINE Print_module_data
92  IMPLICIT NONE
93  INCLUDE "iniprint.h"
94
95!$OMP CRITICAL 
96  WRITE(lunout,*)'--------> TASK ',omp_rank
97  WRITE(lunout,*)'omp_size =',omp_size
98  WRITE(lunout,*)'omp_rank =',omp_rank
99  WRITE(lunout,*)'is_omp_root =',is_omp_root
100  WRITE(lunout,*)'klon_omp_para_nb =',klon_omp_para_nb
101  WRITE(lunout,*)'klon_omp_para_begin =',klon_omp_para_begin
102  WRITE(lunout,*)'klon_omp_para_end =',klon_omp_para_end   
103  WRITE(lunout,*)'klon_omp =',klon_omp
104  WRITE(lunout,*)'klon_omp_begin =',klon_omp_begin
105  WRITE(lunout,*)'klon_omp_end =',klon_omp_end   
106!$OMP END CRITICAL
107
108  END SUBROUTINE Print_module_data
109END MODULE mod_phys_lmdz_omp_data
Note: See TracBrowser for help on using the repository browser.