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

subroutine GTVarSync(var, stat)
    use gtdata_types, only: GT_VARIABLE
    use gt_map, only: var_class, vtb_class_netcdf, vtb_class_memory
    use an_generic, only: ANVarSync, an_variable
    type(GT_VARIABLE), intent(inout), optional:: var
    integer, intent(out), optional:: stat
    integer:: class, cid
    if (.not. present(var)) then
        call ANVarSync(stat=stat)
    else
        call var_class(var, class, cid)
        select case (class)
        case(vtb_class_netcdf)
            call ANVarSync(an_variable(cid), stat=stat)
        end select
    endif
end subroutine
