! Copyright (C) GFD Dennou Club, 2000-2001.  All rights reserved.

subroutine gtvarputreal(var, value, nvalue, err)
    use gtdata_types, only: gt_variable
    use gt_map, only: var_class, vtb_class_netcdf, &
        & map_to_internal_specs
    use an_generic, only: put, an_variable
    use dc_error
    use dc_trace, only: beginsub, endsub
    implicit none
    type(gt_variable), intent(in):: var
    integer, intent(in):: nvalue
    real, intent(in):: value(nvalue)
    logical, intent(out), optional:: err
    integer:: class, cid, stat, ndims
    integer, pointer:: specs(:, :)
    character(len = *), parameter:: subname = "gtvarputreal"
continue
    call beginsub(subname, 'var.mapid=%d', i=(/var%mapid/))
    call var_class(var, class, cid)
    call map_to_internal_specs(var, specs, ndims)
    if (class == vtb_class_netcdf) then
        call put(an_variable(cid), start=specs(:, 1), count=specs(:, 2), &
            & stride=specs(:, 3), imap=specs(:, 4), value=value, &
            & siz=nvalue, iostat=stat)
    else
        stat = gt_efake
    endif
    call storeerror(stat, "gtvarputreal", err=err)
    deallocate(specs)
    call endsub(subname)
end subroutine
