source: trunk/LMDZ.GENERIC/libf/dynlonlat_phylonlat/mod_phys_lmdz_omp_data.F90 @ 1403

Last change on this file since 1403 was 1403, checked in by emillour, 10 years ago

All models: Reorganizing the physics/dynamics interface.

  • makelmdz and makelmdz_fcm scripts adapted to handle the new directory settings
  • misc: (replaces what was the "bibio" directory)
  • Should only contain extremely generic (and non physics or dynamics-specific) routines
  • Therefore moved initdynav.F90, initfluxsto.F, inithist.F, writedynav.F90, write_field.F90, writehist.F to "dyn3d_common"
  • dynlonlat_phylonlat: (new interface directory)
  • This directory contains routines relevent to physics/dynamics grid interactions, e.g. routines gr_dyn_fi or gr_fi_dyn and calfis
  • Moreover the dynlonlat_phylonlat contains directories "phy*" corresponding to each physics package "phy*" to be used. These subdirectories should only contain specific interfaces (e.g. iniphysiq) or main programs (e.g. newstart)
  • phy*/dyn1d: this subdirectory contains the 1D model using physics from phy*

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.