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 !*----------------------------------------------------------------------------
18 use ext_adios2_support_routines
21 include 'wrf_status_codes.h'
22 integer ,intent(in) :: DataHandle
23 character*(*) ,intent(in) :: Element
26 integer ,intent(out) :: Status
27 type(wrf_data_handle) ,pointer :: DH
30 integer ,allocatable :: Buffer(:)
32 type(adios2_attribute) :: AttributeID
34 call GetDH(DataHandle,DH,Status)
35 if(Status /= WRF_NO_ERR) then
37 'Warning Status = ',Status,' in ',__FILE__,' ',ROUTINE_TYPE,', line', __LINE__
38 call wrf_debug ( WARN , msg)
41 IF ( adios2_ok_to_put_dom_ti( DataHandle ) ) THEN
42 if(DH%FileStatus == WRF_FILE_NOT_OPENED) then
43 Status = WRF_WARN_FILE_NOT_OPENED
45 'Warning FILE NOT OPENED in ',__FILE__,' ',ROUTINE_TYPE,', line', __LINE__
46 call wrf_debug ( WARN , msg)
47 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_READ) then
48 STATUS = WRF_WARN_WRITE_RONLY_FILE
50 'Warning WRITE READ ONLY FILE in ',__FILE__,' ',ROUTINE_TYPE,', line', __LINE__
51 call wrf_debug ( WARN , msg)
52 elseif(DH%FileStatus == WRF_FILE_OPENED_NOT_COMMITTED) then
54 allocate(Buffer(Count), STAT=stat)
56 Status = WRF_ERR_FATAL_ALLOCATION_ERROR
57 write(msg,*) 'Fatal ALLOCATION ERROR in ',__FILE__,' ',ROUTINE_TYPE,', line', __LINE__
58 call wrf_debug ( FATAL , msg)
68 call adios2_define_attribute(AttributeID, DH%adios2IO, Element, Buffer, Count, stat)
69 call adios2_err(stat,Status)
70 if(Status /= WRF_NO_ERR) then
71 write(msg,*) 'adios2 error in ext_adios2_put_dom_ti',__FILE__,', line', __LINE__
72 call wrf_debug ( WARN , TRIM(msg))
75 deallocate(Buffer, STAT=stat2)
77 Status = WRF_ERR_FATAL_DEALLOCATION_ERR
78 write(msg,*) 'Fatal DEALLOCATION ERROR in ',__FILE__,' ',ROUTINE_TYPE,', line', __LINE__
79 call wrf_debug ( FATAL , msg)
84 call adios2_define_attribute(AttributeID, DH%adios2IO, Element, Data, stat)
86 call adios2_define_attribute(AttributeID, DH%adios2IO, Element, Data, Count, stat)
88 call adios2_err(stat,Status)
89 if(Status /= WRF_NO_ERR) then
90 write(msg,*) 'adios2 error in ext_adios2_put_dom_ti ',__FILE__,', line', __LINE__
91 call wrf_debug ( WARN , TRIM(msg))
95 elseif (DH%FileStatus == WRF_FILE_OPENED_FOR_WRITE) then
97 allocate(Buffer(Count), STAT=stat)
99 Status = WRF_ERR_FATAL_ALLOCATION_ERROR
101 'Fatal ALLOCATION ERROR in ',__FILE__,' ',ROUTINE_TYPE,', line', __LINE__
102 call wrf_debug ( FATAL , msg)
112 call adios2_define_attribute(AttributeID, DH%adios2IO, Element, Buffer, Count, stat)
113 call adios2_err(stat,Status)
114 if(Status /= WRF_NO_ERR) then
115 write(msg,*) 'adios2 error in ext_adios2_put_dom_ti ',__FILE__,', line', __LINE__
116 call wrf_debug ( WARN , TRIM(msg))
119 deallocate(Buffer, STAT=stat2)
121 Status = WRF_ERR_FATAL_DEALLOCATION_ERR
123 'Fatal DEALLOCATION ERROR in ',__FILE__,' ',ROUTINE_TYPE,', line', __LINE__
124 call wrf_debug ( FATAL , msg)
129 call adios2_define_attribute(AttributeID, DH%adios2IO, Element, Data, stat)
131 call adios2_define_attribute(AttributeID, DH%adios2IO, Element, Data, Count, stat)
133 call adios2_err(stat,Status)
134 if(Status /= WRF_NO_ERR) then
135 write(msg,*) 'adios2 error in ext_adios2_put_dom_ti ',__FILE__,', line', __LINE__
136 call wrf_debug ( WARN , TRIM(msg))
141 Status = WRF_ERR_FATAL_BAD_FILE_STATUS
143 'Fatal error BAD FILE STATUS in ',__FILE__,' ',ROUTINE_TYPE,', line', __LINE__
144 call wrf_debug ( FATAL , msg)