source: LMDZ6/branches/Amaury_dev/libf/dyn3dmem/write_field_loc.F90 @ 5411

Last change on this file since 5411 was 5159, checked in by abarral, 5 months ago

Put dimensions.h and paramet.h into modules

  • Property copyright set to
    Name of program: LMDZ
    Creation date: 1984
    Version: LMDZ5
    License: CeCILL version 2
    Holder: Laboratoire de m\'et\'eorologie dynamique, CNRS, UMR 8539
    See the license file in the root directory
File size: 3.6 KB
Line 
1module write_field_loc
2IMPLICIT NONE
3 
4  interface WriteField_u
5    module procedure Write_field1d_u,Write_Field2d_u
6  end interface WriteField_u
7
8  interface WriteField_v
9    module procedure Write_field1d_v,Write_Field2d_v
10  end interface WriteField_v
11 
12  CONTAINS
13 
14  SUBROUTINE write_field1D_u(name,Field)
15    CHARACTER(LEN=*)   :: name
16    REAL, DIMENSION(:) :: Field
17
18    CALL write_field_u_gen(name,Field,1)
19
20  END SUBROUTINE  write_field1D_u
21
22  SUBROUTINE write_field2D_u(name,Field)
23    IMPLICIT NONE
24     
25    CHARACTER(LEN=*)   :: name
26    REAL, DIMENSION(:,:) :: Field
27    INTEGER :: ll
28   
29    ll=size(field,2)   
30    CALL write_field_u_gen(name,Field,ll)
31   
32    END SUBROUTINE  write_field2D_u
33
34
35   SUBROUTINE write_field_u_gen(name,Field,ll)
36    USE parallel_lmdz
37    USE lmdz_write_field
38    USE mod_hallo
39USE lmdz_dimensions, ONLY: iim, jjm, llm, ndm
40  USE lmdz_paramet
41    IMPLICIT NONE
42
43
44     
45    CHARACTER(LEN=*)   :: name
46    REAL, DIMENSION(ijb_u:ije_u,ll) :: Field
47    REAL, ALLOCATABLE,SAVE :: New_Field(:,:,:)
48    INTEGER,DIMENSION(0:mpi_size-1) :: jj_nb_master
49    type(Request),SAVE :: Request_write
50!$OMP THREADPRIVATE(Request_write)
51    INTEGER :: ll,i
52   
53   
54    jj_nb_master(:)=0
55    jj_nb_master(0)=jjp1
56!$OMP BARRIER
57!$OMP MASTER
58    allocate(New_Field(iip1,jjp1,ll))
59!$OMP END MASTER
60!$OMP BARRIER
61
62!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
63    DO i=1,ll   
64      New_Field(:,jj_begin:jj_end,i)=reshape(Field(ij_begin:ij_end,i),(/iip1,jj_nb/))
65    ENDDO
66!$OMP BARRIER   
67    CALL Register_SwapField(new_field,new_field,ip1jmp1,ll,jj_Nb_master,Request_write)
68    CALL SendRequest(Request_write)
69!$OMP BARRIER
70    CALL WaitRequest(Request_write)
71!$OMP BARRIER
72
73!$OMP MASTER
74    IF (MPI_Rank==0) CALL WriteField(name,New_Field)
75    DEALLOCATE(New_Field)
76!$OMP END MASTER       
77!$OMP BARRIER
78    END SUBROUTINE write_field_u_gen
79
80
81  SUBROUTINE write_field1D_v(name,Field)
82    CHARACTER(LEN=*)   :: name
83    REAL, DIMENSION(:) :: Field
84
85    CALL write_field_v_gen(name,Field,1)
86
87  END SUBROUTINE  write_field1D_v
88
89  SUBROUTINE write_field2D_v(name,Field)
90    IMPLICIT NONE
91     
92    CHARACTER(LEN=*)   :: name
93    REAL, DIMENSION(:,:) :: Field
94    INTEGER :: ll
95   
96    ll=size(field,2)   
97    CALL write_field_v_gen(name,Field,ll)
98   
99    END SUBROUTINE  write_field2D_v
100
101
102   SUBROUTINE write_field_v_gen(name,Field,ll)
103    USE parallel_lmdz
104    USE lmdz_write_field
105    USE mod_hallo
106USE lmdz_dimensions, ONLY: iim, jjm, llm, ndm
107  USE lmdz_paramet
108    IMPLICIT NONE
109
110
111     
112    CHARACTER(LEN=*)   :: name
113    REAL, DIMENSION(ijb_v:ije_v,ll) :: Field
114    REAL, ALLOCATABLE,SAVE :: New_Field(:,:,:)
115    INTEGER,DIMENSION(0:mpi_size-1) :: jj_nb_master
116    type(Request),SAVE :: Request_write
117!$OMP THREADPRIVATE(Request_write)   
118    INTEGER :: ll,i,jje,ije,jjn
119   
120   
121    jj_nb_master(:)=0
122    jj_nb_master(0)=jjp1
123
124!$OMP BARRIER
125!$OMP MASTER
126    allocate(New_Field(iip1,jjm,ll))
127!$OMP END MASTER
128!$OMP BARRIER
129
130   IF (pole_sud) THEN
131     jje=jj_end-1
132     ije=ij_end-iip1
133     jjn=jj_nb-1
134   ELSE
135     jje=jj_end
136     ije=ij_end
137     jjn=jj_nb
138   ENDIF
139   
140!$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
141    DO i=1,ll   
142      New_Field(:,jj_begin:jje,i)=reshape(Field(ij_begin:ije,i),(/iip1,jjn/))
143    ENDDO
144!$OMP BARRIER   
145    CALL Register_SwapField(new_field,new_field,ip1jm,ll,jj_Nb_master,Request_write)
146    CALL SendRequest(Request_write)
147!$OMP BARRIER
148    CALL WaitRequest(Request_write)
149!$OMP BARRIER
150
151!$OMP MASTER
152    IF (MPI_Rank==0) CALL WriteField(name,New_Field)
153    DEALLOCATE(New_Field)
154!$OMP END MASTER       
155!$OMP BARRIER
156    END SUBROUTINE write_field_v_gen
157   
158END MODULE write_field_loc
159 
Note: See TracBrowser for help on using the repository browser.