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
27 integer ,intent(out) :: Status
28 type(wrf_data_handle) ,pointer :: DH
32 type(adios2_attribute) :: attribute
35 call GetDH(DataHandle,DH,Status)
36 if(Status /= WRF_NO_ERR) then
38 'Warning Status = ',Status,' in ',__FILE__,' ',ROUTINE_TYPE,', line', __LINE__
39 call wrf_debug ( WARN , msg)
42 ! Do nothing unless it is time to read time-independent domain metadata.
43 IF ( adios2_ok_to_get_dom_ti( DataHandle ) ) THEN
44 if(DH%FileStatus == WRF_FILE_NOT_OPENED) then
45 Status = WRF_WARN_FILE_NOT_OPENED
47 'Warning FILE NOT OPENED in ',__FILE__,' ',ROUTINE_TYPE,', line', __LINE__
48 call wrf_debug ( WARN , msg)
49 elseif(DH%FileStatus == WRF_FILE_OPENED_NOT_COMMITTED) then
50 Status = WRF_WARN_DRYRUN_READ
52 'Warning DRYRUN READ in ',__FILE__,' ',ROUTINE_TYPE,', line', __LINE__
53 call wrf_debug ( WARN , msg)
54 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_WRITE) then
55 Status = WRF_WARN_READ_WONLY_FILE
57 'Warning READ WRITE ONLY FILE in ',__FILE__,' ',ROUTINE_TYPE,', line', __LINE__
58 call wrf_debug ( WARN , msg)
59 elseif(DH%FileStatus == WRF_FILE_OPENED_FOR_READ) then
60 call adios2_inquire_attribute(attribute, DH%adios2IO, Element, stat)
61 call adios2_err(stat,Status)
62 if(Status /= WRF_NO_ERR) then
63 write(msg,*) 'adios2 error in ext_adios2_get_dom_ti',__FILE__,', line', __LINE__
64 call wrf_debug ( WARN , TRIM(msg))
67 Len = attribute%length
69 allocate(Buffer(Len), STAT=stat)
71 Status = WRF_ERR_FATAL_ALLOCATION_ERROR
73 'Fatal ALLOCATION ERROR in ',__FILE__,' ',ROUTINE_TYPE,', line', __LINE__
74 call wrf_debug ( FATAL , msg)
77 call adios2_attribute_data(Buffer, attribute, stat)
80 call adios2_attribute_data(Data, attribute, stat)
82 call adios2_err(stat,Status)
83 if(Status /= WRF_NO_ERR) then
84 write(msg,*) 'adios2 error in ext_adios2_get_dom_ti',__FILE__,', line', __LINE__
85 call wrf_debug ( WARN , TRIM(msg))
90 deallocate(Buffer, STAT=stat)
91 if(stat/= WRF_NO_ERR) then
92 Status = WRF_ERR_FATAL_DEALLOCATION_ERR
94 'Fatal DEALLOCATION ERROR in ',__FILE__,' ',ROUTINE_TYPE,', line', __LINE__
95 call wrf_debug ( FATAL , msg)
100 Status = WRF_WARN_MORE_DATA_IN_FILE
107 Status = WRF_ERR_FATAL_BAD_FILE_STATUS
109 'Fatal error BAD FILE STATUS in ',__FILE__,' ',ROUTINE_TYPE,', line', __LINE__
110 call wrf_debug ( FATAL , msg)