integer function GDNcFileDefineMode(fileid) result(result)
  use netcdf_f77, only: nf_redef, NF_EINDEFINE, NF_NOERR
  use dc_trace, only: BeginSub, EndSub, DbgMessage
  integer, intent(in):: fileid
  character(*), parameter:: subname = "GDNcFileDefineMode"
continue
  call DbgMessage(subname // ' %d', i=(/fileid/))
  result = nf_redef(fileid)
  if (result == NF_EINDEFINE) result = NF_NOERR
end function GDNcFileDefineMode
