source: trunk/LMDZ.GENERIC/libf/phystd/mod_phys_lmdz_omp_data.F90 @ 1255

Last change on this file since 1255 was 1216, checked in by emillour, 11 years ago

Generic model:
Major cleanup, in order to ease the use of LMDZ.GENERIC with (parallel) dynamics
in LMDZ.COMMON: (NB: this will break LMDZ.UNIVERSAL, which should be thrashed
in the near future)

  • Updated makegcm_* scripts (and makdim) and added the "-full" (to enforce full recomputation of the model) option
  • In dyn3d: converted control.h to module control_mod.F90 and converted iniadvtrac.F to module infotrac.F90
  • Added module mod_const_mpi.F90 in dyn3d (not used in serial mode)
  • Rearanged input/outputs routines everywhere to handle serial/MPI cases. physdem.F => phyredem.F90 , phyetat0.F => phyetat0.F90 ; all read/write routines for startfi files are gathered in module iostart.F90
  • added parallelism related routines init_phys_lmdz.F90, comgeomphy.F90, dimphy.F90, iniphysiq.F90, mod_grid_phy_lmdz.F90, mod_phys_lmdz_mpi_data.F90, mod_phys_lmdz_mpi_transfert.F90, mod_phys_lmdz_omp_data.F90, mod_phys_lmdz_omp_transfert.F90, mod_phys_lmdz_para.F90, mod_phys_lmdz_transfert_para.F90 in phymars and mod_const_mpi.F90 in dyn3d (for compliance with parallelism)
  • added created generic routines 'planetwide_maxval' and 'planetwide_minval', in module "planetwide_mod", that enable obtaining the max and min of a field over the whole planet. This should be further imroved with computation of means (possibly area weighed), etc.

EM

File size: 2.8 KB
Line 
1!
2!$Id: mod_phys_lmdz_omp_data.F90 1575 2011-09-21 13:57:48Z jghattas $
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(*,*)'--------> TASK ',omp_rank
97  WRITE(*,*)'omp_size =',omp_size
98  WRITE(*,*)'omp_rank =',omp_rank
99  WRITE(*,*)'is_omp_root =',is_omp_root
100  WRITE(*,*)'klon_omp_para_nb =',klon_omp_para_nb
101  WRITE(*,*)'klon_omp_para_begin =',klon_omp_para_begin
102  WRITE(*,*)'klon_omp_para_end =',klon_omp_para_end   
103  WRITE(*,*)'klon_omp =',klon_omp
104  WRITE(*,*)'klon_omp_begin =',klon_omp_begin
105  WRITE(*,*)'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.