source: trunk/LMDZ.MARS/libf/phymars/mod_phys_lmdz_para.F90 @ 1233

Last change on this file since 1233 was 1130, checked in by emillour, 11 years ago

Mars GCM:
Series of changes to enable running in parallel (using LMDZ.COMMON dynamics);
Current LMDZ.MARS can still notheless be compiled and run in serial mode
"as previously".
Summary of main changes:

  • Main programs (newstart, start2archive, xvik) that used to be in dyn3d have been moved to phymars.
  • dyn3d/control.h is now module control_mod.F90
  • 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 parallel case)
  • created generic routines 'planetwide_maxval' and 'planetwide_minval', in module "planetwide_mod", that enable obtaining the min and max of a field over the whole planet.

EM

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