1 !*----------------------------------------------------------------------------
4 !* Author: Michael Laufer
5 !* Toga Networks, a Huawei Company
6 !* michael.laufer@toganetworks.com
8 !* Computer Science Department, The Jerusalem College of Technology
10 !* Toga Networks, a Huawei Company
11 !* erick.fredj@toganetworks.com
13 !* Date: November 3, 2021
15 !*----------------------------------------------------------------------------
17 subroutine ext_adios2_RealFieldIO(IO,DataHandle,VarID,VStart,VCount,Data,Status)
19 use ext_adios2_support_routines
22 include 'wrf_status_codes.h'
23 character (*) ,intent(in) :: IO
24 integer ,intent(in) :: DataHandle
25 type(adios2_variable) ,intent(in) :: VarID
26 integer(kind=8),dimension(NVarDims) ,intent(in) :: VStart
27 integer(kind=8),dimension(NVarDims) ,intent(in) :: VCount
28 real ,intent(inout) :: Data
29 integer ,intent(out) :: Status
31 type(wrf_data_handle),pointer :: DH
32 integer(kind=8),dimension(NVarDims) :: VStart_mpi, VCount_mpi
34 !start arrays should start at 0 for ADIOS2
35 VStart_mpi = VStart - 1
37 call GetDH(DataHandle,DH,Status)
38 if(Status /= WRF_NO_ERR) then
39 write(msg,*) 'Warning Status = ',Status,' in ext_adios2_RealFieldIO ',__FILE__,', line', __LINE__
40 call wrf_debug ( WARN , TRIM(msg))
43 !adios2_set_selection to set start dims and count dims
44 call adios2_set_selection(VarID, VarID%ndims, VStart_mpi, VCount_mpi, stat)
45 call adios2_err(stat,Status)
46 if(Status /= WRF_NO_ERR) then
47 write(msg,*) 'adios2 error in ext_adios2_RealFieldIO ',__FILE__,', line', __LINE__
48 call wrf_debug ( WARN , TRIM(msg))
51 if(IO == 'write') then
52 call adios2_put(DH%adios2Engine, VarID, Data, adios2_mode_sync, stat)
54 call adios2_get(DH%adios2Engine, VarID, Data, adios2_mode_sync, stat)
56 call adios2_err(stat,Status)
57 if(Status /= WRF_NO_ERR) then
58 write(msg,*) 'adios2 error in ext_adios2_RealFieldIO ',__FILE__,', line', __LINE__
59 call wrf_debug ( WARN , TRIM(msg))
62 end subroutine ext_adios2_RealFieldIO
64 subroutine ext_adios2_DoubleFieldIO(IO,DataHandle,VarID,VStart,VCount,Data,Status)
66 use ext_adios2_support_routines
69 include 'wrf_status_codes.h'
70 character (*) ,intent(in) :: IO
71 integer ,intent(in) :: DataHandle
72 type(adios2_variable) ,intent(in) :: VarID
73 integer(kind=8) ,dimension(NVarDims) ,intent(in) :: VStart
74 integer(kind=8) ,dimension(NVarDims) ,intent(in) :: VCount
75 real*8 ,intent(inout) :: Data
76 integer ,intent(out) :: Status
78 type(wrf_data_handle),pointer :: DH
79 integer(kind=8),dimension(NVarDims) :: VStart_mpi, VCount_mpi
81 !start arrays should start at 0 for ADIOS2
82 VStart_mpi = VStart - 1
84 call GetDH(DataHandle,DH,Status)
85 if(Status /= WRF_NO_ERR) then
86 write(msg,*) 'Warning Status = ',Status,' in ext_adios2_DoubleFieldIO ',__FILE__,', line', __LINE__
87 call wrf_debug ( WARN , TRIM(msg))
90 !adios2_set_selection to set start dims and count dims
91 call adios2_set_selection(VarID, VarID%ndims, VStart_mpi, VCount_mpi, stat)
92 call adios2_err(stat,Status)
93 if(Status /= WRF_NO_ERR) then
94 write(msg,*) 'adios2 error in ext_adios2_DoubleFieldIO ',__FILE__,', line', __LINE__
95 call wrf_debug ( WARN , TRIM(msg))
98 if(IO == 'write') then
99 call adios2_put(DH%adios2Engine, VarID, Data, adios2_mode_sync, stat)
101 call adios2_get(DH%adios2Engine, VarID, Data, adios2_mode_sync, stat)
103 call adios2_err(stat,Status)
104 if(Status /= WRF_NO_ERR) then
105 write(msg,*) 'adios2 error in ext_adios2_DoubleFieldIO ',__FILE__,', line', __LINE__
106 call wrf_debug ( WARN , TRIM(msg))
109 end subroutine ext_adios2_DoubleFieldIO
111 subroutine ext_adios2_IntFieldIO(IO,DataHandle,VarID,VStart,VCount,Data,Status)
113 use ext_adios2_support_routines
116 include 'wrf_status_codes.h'
117 character (*) ,intent(in) :: IO
118 integer ,intent(in) :: DataHandle
119 type(adios2_variable) ,intent(in) :: VarID
120 integer(kind=8) ,dimension(NVarDims) ,intent(in) :: VStart
121 integer(kind=8) ,dimension(NVarDims) ,intent(in) :: VCount
122 integer ,intent(inout) :: Data
123 integer ,intent(out) :: Status
125 type(wrf_data_handle),pointer :: DH
126 integer(kind=8),dimension(NVarDims) :: VStart_mpi, VCount_mpi
128 !start arrays should start at 0 for ADIOS2
129 VStart_mpi = VStart - 1
131 call GetDH(DataHandle,DH,Status)
132 if(Status /= WRF_NO_ERR) then
133 write(msg,*) 'Warning Status = ',Status,' in ext_adios2_IntFieldIO ',__FILE__,', line', __LINE__
134 call wrf_debug ( WARN , TRIM(msg))
137 !adios2_set_selection to set start dims and count dims
138 call adios2_set_selection(VarID, VarID%ndims, VStart_mpi, VCount_mpi, stat)
139 call adios2_err(stat,Status)
140 if(Status /= WRF_NO_ERR) then
141 write(msg,*) 'adios2 error in ext_adios2_IntFieldIO ',__FILE__,', line', __LINE__
142 call wrf_debug ( WARN , TRIM(msg))
145 if(IO == 'write') then
146 call adios2_put(DH%adios2Engine, VarID, Data, adios2_mode_sync, stat)
148 call adios2_get(DH%adios2Engine, VarID, Data, adios2_mode_sync, stat)
150 call adios2_err(stat,Status)
151 if(Status /= WRF_NO_ERR) then
152 write(msg,*) 'adios2 error in ext_adios2_IntFieldIO ',__FILE__,', line', __LINE__
153 call wrf_debug ( WARN , TRIM(msg))
156 end subroutine ext_adios2_IntFieldIO
158 subroutine ext_adios2_LogicalFieldIO(IO,DataHandle,VarID,VStart,VCount,Data,Status)
160 use ext_adios2_support_routines
163 include 'wrf_status_codes.h'
164 character (*) ,intent(in) :: IO
165 integer ,intent(in) :: DataHandle
166 type(adios2_variable) ,intent(in) :: VarID
167 integer(kind=8) ,dimension(NVarDims) ,intent(in) :: VStart
168 integer(kind=8) ,dimension(NVarDims) ,intent(in) :: VCount
169 logical,dimension(VCount(1),VCount(2),VCount(3)) ,intent(inout) :: Data
170 integer ,intent(out) :: Status
172 type(wrf_data_handle),pointer :: DH
173 integer,dimension(:,:,:),allocatable :: Buffer
175 integer(kind=8),dimension(NVarDims) :: VStart_mpi, VCount_mpi
177 !start arrays should start at 0 for ADIOS2
178 VStart_mpi = VStart - 1
180 call GetDH(DataHandle,DH,Status)
181 if(Status /= WRF_NO_ERR) then
182 write(msg,*) 'Warning Status = ',Status,' in ext_adios2_LogicalFieldIO ',__FILE__,', line', __LINE__
183 call wrf_debug ( WARN , TRIM(msg))
186 !adios2_set_selection to set start dims and count dims
187 call adios2_set_selection(VarID, VarID%ndims, VStart_mpi, VCount_mpi, stat)
188 call adios2_err(stat,Status)
189 if(Status /= WRF_NO_ERR) then
190 write(msg,*) 'adios2 error in ext_adios2_LogicalFieldIO ',__FILE__,', line', __LINE__
191 call wrf_debug ( WARN , TRIM(msg))
194 allocate(Buffer(VCount(1),VCount(2),VCount(3)), STAT=stat)
196 Status = WRF_ERR_FATAL_ALLOCATION_ERROR
197 write(msg,*) 'Fatal ALLOCATION ERROR in ',__FILE__,', line', __LINE__
198 call wrf_debug ( FATAL , msg)
201 if(IO == 'write') then
213 call adios2_put(DH%adios2Engine, VarID, Buffer, adios2_mode_sync, stat)
214 call adios2_err(stat,Status)
215 if(Status /= WRF_NO_ERR) then
216 write(msg,*) 'adios2 error in ext_adios2_LogicalFieldIO ',__FILE__,', line', __LINE__
217 call wrf_debug ( WARN , TRIM(msg))
221 call adios2_get(DH%adios2Engine, VarID, Buffer, adios2_mode_sync, stat)
222 call adios2_err(stat,Status)
223 if(Status /= WRF_NO_ERR) then
224 write(msg,*) 'adios2 error in ext_adios2_LogicalFieldIO ',__FILE__,', line', __LINE__
225 call wrf_debug ( WARN , TRIM(msg))
230 deallocate(Buffer, STAT=stat)
232 Status = WRF_ERR_FATAL_DEALLOCATION_ERR
233 write(msg,*) 'Fatal DEALLOCATION ERROR in ',__FILE__,', line', __LINE__
234 call wrf_debug ( FATAL , msg)
238 end subroutine ext_adios2_LogicalFieldIO