integer function GDNcFileDataMode(fileid) result(result)
  use netcdf_f77, only: nf_enddef, NF_ENOTINDEFINE, NF_NOERR
  use dc_trace, only: DbgMessage
  implicit none
  integer, intent(in):: fileid
  character(*), parameter:: subname = "GDNcFileDataMode"
continue
  call DbgMessage(subname)
  result = nf_enddef(fileid)
  if (result == NF_ENOTINDEFINE) result = NF_NOERR
end function GDNcFileDataMode
