1 | ! |
---|
2 | !$Header$ |
---|
3 | ! |
---|
4 | MODULE mod_phys_lmdz_para |
---|
5 | USE mod_phys_lmdz_transfert_para |
---|
6 | USE mod_phys_lmdz_mpi_data |
---|
7 | USE mod_phys_lmdz_omp_data |
---|
8 | |
---|
9 | INTEGER,SAVE :: klon_loc |
---|
10 | LOGICAL,SAVE :: is_sequential |
---|
11 | LOGICAL,SAVE :: is_parallel |
---|
12 | LOGICAL,SAVE :: is_master |
---|
13 | |
---|
14 | !$OMP THREADPRIVATE(klon_loc,is_master) |
---|
15 | !$OMP THREADPRIVATE(is_sequential,is_parallel) |
---|
16 | |
---|
17 | CONTAINS |
---|
18 | |
---|
19 | SUBROUTINE Init_phys_lmdz_para(iim,jjp1,nb_proc,distrib) |
---|
20 | IMPLICIT NONE |
---|
21 | INTEGER,INTENT(in) :: iim |
---|
22 | INTEGER,INTENT(in) :: jjp1 |
---|
23 | INTEGER,INTENT(in) :: nb_proc |
---|
24 | INTEGER,INTENT(in) :: distrib(0:nb_proc-1) |
---|
25 | |
---|
26 | CALL Init_phys_lmdz_mpi_data(iim,jjp1,nb_proc,distrib) |
---|
27 | !$OMP PARALLEL |
---|
28 | CALL Init_phys_lmdz_omp_data(klon_mpi) |
---|
29 | klon_loc=klon_omp |
---|
30 | IF (is_mpi_root .AND. is_omp_root) THEN |
---|
31 | is_master=.TRUE. |
---|
32 | ELSE |
---|
33 | is_master=.FALSE. |
---|
34 | ENDIF |
---|
35 | CALL Test_transfert |
---|
36 | !$OMP END PARALLEL |
---|
37 | IF (is_using_mpi .OR. is_using_omp) THEN |
---|
38 | is_sequential=.FALSE. |
---|
39 | is_parallel=.TRUE. |
---|
40 | ELSE |
---|
41 | is_sequential=.TRUE. |
---|
42 | is_parallel=.FALSE. |
---|
43 | ENDIF |
---|
44 | |
---|
45 | END SUBROUTINE Init_phys_lmdz_para |
---|
46 | |
---|
47 | SUBROUTINE Test_transfert |
---|
48 | USE mod_grid_phy_lmdz, only: klon_glo, nbp_lev, nbp_lon, nbp_lat, & |
---|
49 | grid1dTo2d_glo, grid2dTo1d_glo |
---|
50 | IMPLICIT NONE |
---|
51 | ! INCLUDE "iniprint.h" |
---|
52 | |
---|
53 | REAL :: Test_Field1d_glo(klon_glo,nbp_lev) |
---|
54 | REAL :: tmp1d_glo(klon_glo,nbp_lev) |
---|
55 | REAL :: Test_Field2d_glo(nbp_lon,nbp_lat,nbp_lev) |
---|
56 | REAL :: tmp2d_glo(nbp_lon,nbp_lat,nbp_lev) |
---|
57 | REAL :: Test_Field1d_loc(klon_loc,nbp_lev) |
---|
58 | REAL :: Test_Field2d_loc(nbp_lon,jj_nb,nbp_lev) |
---|
59 | REAL :: CheckSum |
---|
60 | |
---|
61 | INTEGER :: i,l |
---|
62 | |
---|
63 | Test_Field1d_glo = 0. |
---|
64 | Test_Field2d_glo = 0. |
---|
65 | Test_Field1d_loc = 0. |
---|
66 | Test_Field2d_loc = 0. |
---|
67 | |
---|
68 | IF (is_mpi_root) THEN |
---|
69 | !$OMP MASTER |
---|
70 | DO l=1,nbp_lev |
---|
71 | DO i=1,klon_glo |
---|
72 | ! Test_Field1d_glo(i,l)=MOD(i,10)+10*(l-1) |
---|
73 | Test_Field1d_glo(i,l)=1 |
---|
74 | ENDDO |
---|
75 | ENDDO |
---|
76 | !$OMP END MASTER |
---|
77 | ENDIF |
---|
78 | |
---|
79 | CALL Scatter(Test_Field1d_glo,Test_Field1d_loc) |
---|
80 | CALL Gather(Test_Field1d_loc,tmp1d_glo) |
---|
81 | |
---|
82 | IF (is_mpi_root) THEN |
---|
83 | !$OMP MASTER |
---|
84 | Checksum=sum(Test_Field1d_glo-tmp1d_glo) |
---|
85 | WRITE(*,*) "------> Checksum =",Checksum," MUST BE 0" |
---|
86 | !$OMP END MASTER |
---|
87 | ENDIF |
---|
88 | |
---|
89 | CALL grid1dTo2d_glo(Test_Field1d_glo,Test_Field2d_glo) |
---|
90 | CALL scatter2D(Test_Field2d_glo,Test_Field1d_loc) |
---|
91 | CALL gather2d(Test_Field1d_loc,Test_Field2d_glo) |
---|
92 | CALL grid2dTo1d_glo(Test_Field2d_glo,tmp1d_glo) |
---|
93 | |
---|
94 | IF (is_mpi_root) THEN |
---|
95 | !$OMP MASTER |
---|
96 | Checksum=sum(Test_Field1d_glo-tmp1d_glo) |
---|
97 | WRITE(*,*) "------> Checksum =",Checksum," MUST BE 0" |
---|
98 | !$OMP END MASTER |
---|
99 | ENDIF |
---|
100 | |
---|
101 | CALL bcast(Test_Field1d_glo) |
---|
102 | CALL reduce_sum(Test_Field1d_glo,tmp1d_glo) |
---|
103 | |
---|
104 | IF (is_mpi_root) THEN |
---|
105 | !$OMP MASTER |
---|
106 | Checksum=sum(Test_Field1d_glo*omp_size*mpi_size-tmp1d_glo) |
---|
107 | WRITE(*,*) "------> Checksum =",Checksum," MUST BE 0" |
---|
108 | !$OMP END MASTER |
---|
109 | ENDIF |
---|
110 | |
---|
111 | |
---|
112 | END SUBROUTINE Test_transfert |
---|
113 | |
---|
114 | END MODULE mod_phys_lmdz_para |
---|
115 | |
---|