Newer
Older

WAUTELET Philippe
committed
return
else
cmnhmsg(1) = 'attribute ' // hattname // ' has changed for ' // Trim( hlevel )
Write( cmnhmsg(2), '( I0, " -> ", I0 )' ) iatt, kdata
call Print_msg( NVERB_WARNING, 'IO', 'Write_diachro_nc4' )
end if
end if
istatus = NF90_PUT_ATT( kgrpid, NF90_GLOBAL, hattname, kdata )
if (istatus /= NF90_NOERR ) &

WAUTELET Philippe
committed
call IO_Err_handle_nc4( istatus, 'Write_diachro_nc4', 'NF90_PUT_ATT', Trim( hattname ) // ' for '// Trim( hlevel ) // ' group' )
end subroutine Att_write_i0

WAUTELET Philippe
committed
subroutine Att_write_x0( hlevel, kgrpid, hattname, pdata )
use NETCDF, only: NF90_GET_ATT, NF90_INQUIRE_ATTRIBUTE, NF90_PUT_ATT, NF90_GLOBAL, NF90_NOERR

WAUTELET Philippe
committed
use modd_precision, only: CDFINT, MNHREAL_NF90
use mode_io_tools_nc4, only: IO_Err_handle_nc4

WAUTELET Philippe
committed
character(len=*), intent(in) :: hlevel
integer(kind=CDFINT), intent(in) :: kgrpid
character(len=*), intent(in) :: hattname
real, intent(in) :: pdata

WAUTELET Philippe
committed
integer(kind=CDFINT) :: ilen
integer(kind=CDFINT) :: istatus

WAUTELET Philippe
committed
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
integer(kind=CDFINT) :: itype
real :: zatt
istatus = NF90_INQUIRE_ATTRIBUTE( kgrpid, NF90_GLOBAL, hattname, xtype = itype, len = ilen )
if (istatus == NF90_NOERR ) then
call Print_msg( NVERB_DEBUG, 'IO', 'Write_diachro_nc4', 'attribute ' // hattname // ' already exists for ' // Trim( hlevel ) )
if ( itype /= MNHREAL_NF90 ) then
call Print_msg( NVERB_ERROR, 'IO', 'Write_diachro_nc4', 'type for attribute ' // hattname // &
' has changed for ' // Trim( hlevel ) )
return
end if
if ( ilen /= 1 ) then
call Print_msg( NVERB_ERROR, 'IO', 'Write_diachro_nc4', 'size of attribute ' // hattname // &
' has changed for ' // Trim( hlevel ) )
return
end if
istatus = NF90_GET_ATT( kgrpid, NF90_GLOBAL, hattname, zatt )
if ( zatt == pdata ) then
call Print_msg( NVERB_DEBUG, 'IO', 'Write_diachro_nc4', 'attribute ' // hattname // ' is unchanged for ' // Trim( hlevel ) )
!If unchanged, no need to write it again => return
return
else
cmnhmsg(1) = 'attribute ' // hattname // ' has changed for ' // Trim( hlevel )
Write( cmnhmsg(2), '( F15.7, " -> ", F15.7 )' ) zatt, pdata
call Print_msg( NVERB_WARNING, 'IO', 'Write_diachro_nc4' )
end if
end if
istatus = NF90_PUT_ATT( kgrpid, NF90_GLOBAL, hattname, pdata )
if (istatus /= NF90_NOERR ) &

WAUTELET Philippe
committed
call IO_Err_handle_nc4( istatus, 'Write_diachro_nc4', 'NF90_PUT_ATT', Trim( hattname ) // ' for '// Trim( hlevel ) // ' group' )
end subroutine Att_write_x0

WAUTELET Philippe
committed
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
subroutine Move_to_next_level( kpreviouslevelid, gpreviousleveldefined, oleveluse, hlevelname, gleveldefined, klevelid )
use NETCDF, only: NF90_DEF_GRP, NF90_INQ_NCID, NF90_NOERR
use modd_precision, only: CDFINT
use mode_io_tools_nc4, only: IO_Err_handle_nc4
integer(kind=CDFINT), intent(in) :: kpreviouslevelid
logical, intent(in) :: gpreviousleveldefined
logical, intent(in) :: oleveluse
character(len=*), intent(inout) :: hlevelname
logical, intent(out) :: gleveldefined
integer(kind=CDFINT), intent(out) :: klevelid
integer(kind=CDFINT) :: istatus
if ( oleveluse ) then
istatus = NF90_INQ_NCID( kpreviouslevelid, Trim( hlevelname ), klevelid )
if ( istatus == NF90_NOERR ) then
gleveldefined = .true.
else
gleveldefined = .false.
istatus = NF90_DEF_GRP( kpreviouslevelid, Trim( hlevelname ), klevelid )
if ( istatus /= NF90_NOERR ) &
call IO_Err_handle_nc4( istatus, 'Move_to_next_level', 'NF90_DEF_GRP', 'for ' // Trim( hlevelname ) )
end if
else
gleveldefined = gpreviousleveldefined
if ( Len_trim( hlevelname ) == 0 ) hlevelname = '(unused)'
klevelid = kpreviouslevelid
end if
end subroutine Move_to_next_level
end module mode_write_diachro