source: LMDZ4/branches/LMDZ4-dev/libf/phylmd/iophy.F90 @ 1259

Last change on this file since 1259 was 1001, checked in by Laurent Fairhead, 16 years ago
  • Modifs sur le parallelisme: masquage dans la physique
  • Inclusion strato
  • mise en coherence etat0
  • le mode offline fonctionne maintenant en parallele,
  • les fichiers de la dynamiques sont correctement sortis et peuvent etre reconstruit avec rebuild
  • la version parallele de la dynamique peut s'executer sans MPI (sur 1 proc)
  • L'OPENMP fonctionne maintenant sans la parallelisation MPI.

YM
LF

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.3 KB
Line 
1!
2! $Header$
3!
4module iophy
5 
6  REAL,private,allocatable,dimension(:,:),save :: tmp_tab2d
7  REAL,private,allocatable,dimension(:,:,:),save :: tmp_tab3d
8  INTEGER,private,allocatable,dimension(:),save :: ndex2d
9  INTEGER,private,allocatable,dimension(:),save :: ndex3d
10! abd  REAL,private,allocatable,dimension(:),save :: io_lat
11! abd  REAL,private,allocatable,dimension(:),save :: io_lon
12  REAL,allocatable,dimension(:),save :: io_lat
13  REAL,allocatable,dimension(:),save :: io_lon
14  INTEGER, save :: phys_domain_id
15 
16  INTERFACE histwrite_phy
17    MODULE PROCEDURE histwrite2d_phy,histwrite3d_phy
18  END INTERFACE
19
20
21contains
22
23  subroutine init_iophy_new(rlat,rlon)
24  USE dimphy
25  USE mod_phys_lmdz_para
26  USE mod_grid_phy_lmdz
27  USE ioipsl
28  implicit none
29  include 'dimensions.h'   
30    real,dimension(klon),intent(in) :: rlon
31    real,dimension(klon),intent(in) :: rlat
32
33    REAL,dimension(klon_glo)        :: rlat_glo
34    REAL,dimension(klon_glo)        :: rlon_glo
35   
36    INTEGER,DIMENSION(2) :: ddid
37    INTEGER,DIMENSION(2) :: dsg
38    INTEGER,DIMENSION(2) :: dsl
39    INTEGER,DIMENSION(2) :: dpf
40    INTEGER,DIMENSION(2) :: dpl
41    INTEGER,DIMENSION(2) :: dhs
42    INTEGER,DIMENSION(2) :: dhe
43    INTEGER :: i   
44
45    CALL gather(rlat,rlat_glo)
46    CALL bcast(rlat_glo)
47    CALL gather(rlon,rlon_glo)
48    CALL bcast(rlon_glo)
49   
50!$OMP MASTER 
51    ALLOCATE(io_lat(jjm+1-1/iim))
52    io_lat(1)=rlat_glo(1)
53    io_lat(jjm+1-1/iim)=rlat_glo(klon_glo)
54    IF (iim > 1) then
55      DO i=2,jjm
56        io_lat(i)=rlat_glo(2+(i-2)*iim)
57      ENDDO
58    ENDIF
59
60    ALLOCATE(io_lon(iim))
61    io_lon(:)=rlon_glo(2-1/iim:iim+1-1/iim)
62
63
64    allocate(tmp_tab2d(iim,jj_nb))
65    allocate(tmp_tab3d(iim,jj_nb,klev))
66    allocate(ndex2d(iim*jj_nb))
67    allocate(ndex3d(iim*jj_nb*klev))
68    ndex2d(:)=0
69    ndex3d(:)=0
70   
71    ddid=(/ 1,2 /)
72    dsg=(/ iim, jjm+1-1/iim /)
73    dsl=(/ iim, jj_nb /)
74    dpf=(/ 1,jj_begin /)
75    dpl=(/ iim, jj_end /)
76    dhs=(/ ii_begin-1,0 /)
77    if (mpi_rank==mpi_size-1) then
78      dhe=(/0,0/)
79    else
80      dhe=(/ iim-ii_end,0 /) 
81    endif
82   
83    call flio_dom_set(mpi_size,mpi_rank,ddid,dsg,dsl,dpf,dpl,dhs,dhe, &
84                      'APPLE',phys_domain_id)
85
86!$OMP END MASTER
87     
88  end subroutine init_iophy_new
89
90  subroutine init_iophy(lat,lon)
91  USE dimphy
92  USE mod_phys_lmdz_para
93  use ioipsl
94  implicit none
95  include 'dimensions.h'   
96    real,dimension(iim),intent(in) :: lon
97    real,dimension(jjm+1-1/iim),intent(in) :: lat
98
99    INTEGER,DIMENSION(2) :: ddid
100    INTEGER,DIMENSION(2) :: dsg
101    INTEGER,DIMENSION(2) :: dsl
102    INTEGER,DIMENSION(2) :: dpf
103    INTEGER,DIMENSION(2) :: dpl
104    INTEGER,DIMENSION(2) :: dhs
105    INTEGER,DIMENSION(2) :: dhe
106
107!$OMP MASTER 
108    allocate(io_lat(jjm+1-1/iim))
109    io_lat(:)=lat(:)
110    allocate(io_lon(iim))
111    io_lon(:)=lon(:)
112    allocate(tmp_tab2d(iim,jj_nb))
113    allocate(tmp_tab3d(iim,jj_nb,klev))
114    allocate(ndex2d(iim*jj_nb))
115    allocate(ndex3d(iim*jj_nb*klev))
116    ndex2d(:)=0
117    ndex3d(:)=0
118   
119    ddid=(/ 1,2 /)
120    dsg=(/ iim, jjm+1-1/iim /)
121    dsl=(/ iim, jj_nb /)
122    dpf=(/ 1,jj_begin /)
123    dpl=(/ iim, jj_end /)
124    dhs=(/ ii_begin-1,0 /)
125    if (mpi_rank==mpi_size-1) then
126      dhe=(/0,0/)
127    else
128      dhe=(/ iim-ii_end,0 /) 
129    endif
130   
131    call flio_dom_set(mpi_size,mpi_rank,ddid,dsg,dsl,dpf,dpl,dhs,dhe, &
132                      'APPLE',phys_domain_id)
133
134!$OMP END MASTER
135     
136  end subroutine init_iophy
137 
138  subroutine histbeg_phy(name,itau0,zjulian,dtime,nhori,nid_day)
139  USE dimphy
140  USE mod_phys_lmdz_para
141  use ioipsl
142  use write_field
143  implicit none
144  include 'dimensions.h'
145   
146    character*(*), intent(IN) :: name
147    integer, intent(in) :: itau0
148    real,intent(in) :: zjulian
149    real,intent(in) :: dtime
150    integer,intent(out) :: nhori
151    integer,intent(out) :: nid_day
152
153!$OMP MASTER   
154    if (is_sequential) then
155      call histbeg(name,iim,io_lon, jj_nb,io_lat(jj_begin:jj_end), &
156                   1,iim,1,jj_nb,itau0, zjulian, dtime, nhori, nid_day)
157    else
158      call histbeg(name,iim,io_lon, jj_nb,io_lat(jj_begin:jj_end), &
159                   1,iim,1,jj_nb,itau0, zjulian, dtime, nhori, nid_day,phys_domain_id)
160    endif
161!$OMP END MASTER
162 
163  end subroutine histbeg_phy
164 
165  subroutine histwrite2d_phy(nid,name,itau,field)
166  USE dimphy
167  USE mod_phys_lmdz_para
168  USE ioipsl
169  implicit none
170  include 'dimensions.h'
171   
172    integer,intent(in) :: nid
173    character*(*), intent(IN) :: name
174    integer, intent(in) :: itau
175    real,dimension(klon),intent(in) :: field
176   
177    REAL,dimension(klon_mpi) :: buffer_omp
178   
179    CALL Gather_omp(field,buffer_omp)   
180!$OMP MASTER
181    CALL grid1Dto2D_mpi(buffer_omp,tmp_tab2d)
182    CALL histwrite(nid,name,itau,tmp_tab2d,iim*jj_nb,ndex2d)
183!$OMP END MASTER   
184  end subroutine histwrite2d_phy
185 
186  subroutine histwrite3d_phy(nid,name,itau,field)
187  USE dimphy
188  USE mod_phys_lmdz_para
189
190  use ioipsl
191  implicit none
192  include 'dimensions.h'
193   
194    integer,intent(in) :: nid
195    character*(*), intent(IN) :: name
196    integer, intent(in) :: itau
197    real,dimension(klon,klev),intent(in) :: field
198
199    REAL,dimension(klon_mpi,klev) :: buffer_omp
200   
201    CALL Gather_omp(field,buffer_omp)
202!$OMP MASTER
203    CALL grid1Dto2D_mpi(buffer_omp,tmp_tab3d)
204    CALL histwrite(nid,name,itau,tmp_tab3d,iim*jj_nb*klev,ndex3d)
205!$OMP END MASTER   
206  end subroutine histwrite3d_phy
207 
208 
209
210end module iophy
Note: See TracBrowser for help on using the repository browser.