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
24 character*(*) ,intent(in) :: Var
27 integer ,intent(out) :: Status
28 type(wrf_data_handle) ,pointer :: DH
29 character(31) :: VarName
31 integer ,allocatable :: Buffer(:)
35 type(adios2_attribute) :: AttributeID
39 call GetDH(DataHandle,DH,Status)
40 if(Status /= WRF_NO_ERR) then
42 'Warning Status = ',Status,' in ',__FILE__,' ',ROUTINE_TYPE,', line', __LINE__
43 call wrf_debug ( WARN , msg)
46 if(DH%FileStatus == WRF_FILE_NOT_OPENED) then
47 Status = WRF_WARN_FILE_NOT_OPENED
49 'Warning FILE NOT OPENED in ',__FILE__,' ',ROUTINE_TYPE,', line', __LINE__
50 call wrf_debug ( WARN , msg)
51 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_READ) then
52 Status = WRF_WARN_WRITE_RONLY_FILE
54 'Warning WRITE READ ONLY FILE in ',__FILE__,' ',ROUTINE_TYPE,', line', __LINE__
55 call wrf_debug ( WARN , msg)
56 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_WRITE) then
57 Status = WRF_WARN_MD_AFTER_OPEN
59 'Warning WRITE METADATA AFTER OPEN in ',__FILE__,' ',ROUTINE_TYPE,', line', __LINE__
60 call wrf_debug ( WARN , msg)
62 elseif(DH%FileStatus == WRF_FILE_OPENED_NOT_COMMITTED) then
64 if(TRIM(DH%VarNames(NVar)) == TRIM(VarName)) then
66 elseif(NVar == MaxVars) then
67 Status = WRF_WARN_VAR_NF
69 'Warning VARIABLE NOT FOUND in ',__FILE__,' ',ROUTINE_TYPE,', line', __LINE__ &
71 call wrf_debug ( WARN , msg)
76 allocate(Buffer(Count), STAT=stat)
78 Status = WRF_ERR_FATAL_ALLOCATION_ERROR
80 'Fatal ALLOCATION ERROR in ',__FILE__,' ',ROUTINE_TYPE,', line', __LINE__
81 call wrf_debug ( FATAL , msg)
91 call adios2_define_attribute(AttributeID,DH%adios2IO, trim(Element), &
92 Buffer, Count, DH%VarIDs(NVar)%name, stat)
93 call adios2_err(stat,Status)
94 if(Status /= WRF_NO_ERR) then
95 write(msg,*) 'ext_adios2_put_var_ti: adios2 error in ',__FILE__,', line', __LINE__
96 call wrf_debug ( WARN , TRIM(msg))
99 #elif defined(CHAR_TYPE)
100 call adios2_define_attribute(AttributeID,DH%adios2IO, trim(Element), &
101 Data, 1, DH%VarIDs(NVar)%name, stat)
102 call adios2_err(stat,Status)
103 if(Status /= WRF_NO_ERR) then
104 write(msg,*) 'ext_adios2_put_var_ti: adios2 error in ',__FILE__,', line', __LINE__
105 call wrf_debug ( WARN , TRIM(msg))
109 call adios2_define_attribute(AttributeID,DH%adios2IO, trim(Element), &
110 Data, Count, DH%VarIDs(NVar)%name, stat)
111 call adios2_err(stat,Status)
112 if(Status /= WRF_NO_ERR) then
113 write(msg,*) 'ext_adios2_put_var_ti : adios2 error in ',__FILE__,', line', __LINE__
114 call wrf_debug ( WARN , TRIM(msg))
119 deallocate(Buffer, STAT=stat)
121 Status = WRF_ERR_FATAL_DEALLOCATION_ERR
123 'Fatal DEALLOCATION ERROR in ',__FILE__,' ',ROUTINE_TYPE,', line', __LINE__
124 call wrf_debug ( FATAL , msg)
129 Status = WRF_ERR_FATAL_BAD_FILE_STATUS
131 'Fatal error BAD FILE STATUS in ',__FILE__,' ',ROUTINE_TYPE,', line', __LINE__
132 call wrf_debug ( FATAL , msg)