source: LMDZ4/branches/V3_test/libf/phylmd/iophy.F90 @ 3947

Last change on this file since 3947 was 735, checked in by Laurent Fairhead, 18 years ago

Modifications version parallele
YM/LF

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.6 KB
RevLine 
[629]1module iophy
2 
3  REAL,private,allocatable,dimension(:,:),save :: tmp_tab2d
4  REAL,private,allocatable,dimension(:,:,:),save :: tmp_tab3d
5  INTEGER,private,allocatable,dimension(:),save :: ndex2d
6  INTEGER,private,allocatable,dimension(:),save :: ndex3d
7  REAL,private,allocatable,dimension(:),save :: io_lat
8  REAL,private,allocatable,dimension(:),save :: io_lon
[704]9  INTEGER, save :: phys_domain_id
[629]10 
11  INTERFACE histwrite_phy
12    MODULE PROCEDURE histwrite2d_phy,histwrite3d_phy
13  END INTERFACE
[704]14 
15  REAL,private,allocatable,save,dimension(:,:) :: buffer_omp
[629]16
17contains
18
19  subroutine init_iophy(lat,lon)
20  use dimphy
[704]21  use ioipsl
[629]22  implicit none
23  include 'dimensions90.h'   
24    real,dimension(iim),intent(in) :: lon
25    real,dimension(jjm+1),intent(in) :: lat
[704]26
27    INTEGER,DIMENSION(2) :: ddid
28    INTEGER,DIMENSION(2) :: dsg
29    INTEGER,DIMENSION(2) :: dsl
30    INTEGER,DIMENSION(2) :: dpf
31    INTEGER,DIMENSION(2) :: dpl
32    INTEGER,DIMENSION(2) :: dhs
33    INTEGER,DIMENSION(2) :: dhe
34
35!$OMP MASTER 
[629]36    allocate(io_lat(jjm+1))
37    io_lat(:)=lat(:)
38    allocate(io_lon(iim))
39    io_lon(:)=lon(:)
40    allocate(tmp_tab2d(iim,jjphy_nb))
41    allocate(tmp_tab3d(iim,jjphy_nb,klev))
42    allocate(ndex2d(iim*jjphy_nb))
43    allocate(ndex3d(iim*jjphy_nb*klev))
44    ndex2d(:)=0
45    ndex3d(:)=0
[704]46    allocate(buffer_omp(klon_mpi,klev))
47   
48    ddid=(/ 1,2 /)
49    dsg=(/ iim, jjm+1 /)
50    dsl=(/ iim, jjphy_nb /)
51    dpf=(/ 1,jjphy_begin /)
52    dpl=(/ iim, jjphy_end /)
53    dhs=(/ iiphy_begin-1,0 /)
54    if (phy_rank==phy_size-1) then
55      dhe=(/0,0/)
56    else
57      dhe=(/ iim-iiphy_end,0 /) 
58    endif
59   
60    call flio_dom_set(phy_size,phy_rank,ddid,dsg,dsl,dpf,dpl,dhs,dhe, &
61                      'APPLE',phys_domain_id)
[629]62
[704]63!$OMP END MASTER
64!$OMP FLUSH(buffer_omp)
65     
[629]66  end subroutine init_iophy
67 
68  subroutine histbeg_phy(name,itau0,zjulian,dtime,nhori,nid_day)
69  use dimphy
70  use ioipsl
71  use write_field
72  implicit none
73  include 'dimensions90.h'
74   
75    character*(*), intent(IN) :: name
76    integer, intent(in) :: itau0
77    real,intent(in) :: zjulian
78    real,intent(in) :: dtime
79    integer,intent(out) :: nhori
80    integer,intent(out) :: nid_day
[704]81
82!$OMP MASTER   
[629]83    if (monocpu) then
84      call histbeg(name,iim,io_lon, jjphy_nb,io_lat(jjphy_begin:jjphy_end), &
85                   1,iim,1,jjphy_nb,itau0, zjulian, dtime, nhori, nid_day)
86    else
[704]87      call histbeg(name,iim,io_lon, jjphy_nb,io_lat(jjphy_begin:jjphy_end), &
88                   1,iim,1,jjphy_nb,itau0, zjulian, dtime, nhori, nid_day,phys_domain_id)
[629]89    endif
[704]90!$OMP END MASTER
[629]91 
92  end subroutine histbeg_phy
93 
94  subroutine histwrite2d_phy(nid,name,itau,field)
95  use dimphy
96  use ioipsl
97  implicit none
98  include 'dimensions90.h'
99   
100    integer,intent(in) :: nid
101    character*(*), intent(IN) :: name
102    integer, intent(in) :: itau
103    real,dimension(klon),intent(in) :: field
[704]104
105    CALL GatherField_omp(field,buffer_omp,1)   
106!$OMP MASTER
107    CALL phy2dyn(buffer_omp,tmp_tab2d,1)
[629]108    CALL histwrite(nid,name,itau,tmp_tab2d,iim*jjphy_nb,ndex2d)
[704]109!$OMP END MASTER   
[629]110  end subroutine histwrite2d_phy
111 
112  subroutine histwrite3d_phy(nid,name,itau,field)
113  use dimphy
114  use ioipsl
115  implicit none
116  include 'dimensions90.h'
117   
118    integer,intent(in) :: nid
119    character*(*), intent(IN) :: name
120    integer, intent(in) :: itau
121    real,dimension(klon,klev),intent(in) :: field
122   
[704]123    CALL GatherField_omp(field,buffer_omp,klev)
124!$OMP MASTER
125    CALL phy2dyn(buffer_omp,tmp_tab3d,klev)
[629]126    CALL histwrite(nid,name,itau,tmp_tab3d,iim*jjphy_nb*klev,ndex3d)
[704]127!$OMP END MASTER   
[629]128  end subroutine histwrite3d_phy
129 
130 
131  subroutine phy2dyn(field_phy,field_dyn,nlev)
132  use dimphy
133  implicit none
134  include 'dimensions90.h'
135 
[735]136    real,dimension(klon_mpi,nlev),intent(in) :: field_phy
[629]137    real,dimension(iim,jjphy_nb,nlev),intent(out) :: field_dyn
138    integer,intent(in) :: nlev
139   
140    integer :: next
141    integer :: j,l
142   
143      do l=1,nlev
144               
145        if (jjphy_begin==jjphy_end) then
146          field_dyn(:,1,l)=0.
[735]147          field_dyn(iiphy_begin:iiphy_end,1,l)=field_phy(1:klon_mpi,l)
[629]148        else
149       
150         if (jjphy_begin==1) then
151            field_dyn(:,1,l)=field_phy(1,l)
152            next=2
153         else
154           field_dyn(:,1,l)=0.
[704]155           next=iim-iiphy_begin+2
[629]156           field_dyn(iiphy_begin:iim,1,l)=field_phy(1:next-1,l)   
157         endif
158       
159          do j=2,jjphy_nb-1
160            field_dyn(:,j,l)=field_phy(next:next+iim-1,l)
161            next=next+iim
162          enddo
163         
164          if (jjphy_end==jjm+1) then
[735]165             field_dyn(:,jjphy_nb,l)=field_phy(klon_mpi,l)
[629]166          else
167           field_dyn(:,jjphy_nb,l)=0.
168           field_dyn(1:iiphy_end,jjphy_nb,l)=field_phy(next:next+iiphy_end-1,l)   
169          endif
170         
171        endif
172     
173     enddo
174         
175    end subroutine phy2dyn         
176 
177         
178end module iophy
Note: See TracBrowser for help on using the repository browser.