gtvarclose.f90

Path: src/gtvarclose.f90
Last Update: Wed Jul 20 18:22:24 JST 2005

gtvarclose.f90 Copyright (C) TOYODA Eizi, 2000. All rights reserved.

Methods

Included Modules

gtdata_types gt_map gt_vartable an_generic dc_error dc_trace gt_mem

Public Instance methods

var :type(GT_VARIABLE), intent(in), target
err :logical, intent(out), optional

[Source]

subroutine GTVarClose(var, err)

    implicit none
    type(GT_VARIABLE), intent(in), target:: var
    logical, intent(out), optional:: err
    integer:: vid, class, cid
    logical:: action, myerr
continue
    call beginsub('gtvarclose', fmt='var=%d', i=(/var%mapid/))
    call map_lookup(var, vid=vid)
    call maptabdelete(var, myerr)
    if (myerr) goto 999
    ! vid が 0 になるのは dup_dimmap で作られたハンドル
    if (vid == 0) goto 999
    call vartablelookup(vid, class, cid)
    call vartabledelete(vid, action, myerr)
    if (myerr) goto 999
    if (.not. action) then
        call DbgMessage('refcount decrement only, no close internal var')
        goto 999
    else if (class == vtb_class_netcdf) then
        call ANVarClose(an_variable(cid), myerr)
        if (myerr) goto 999
    else if (class == vtb_class_memory) then
        call Close(mem_variable(cid))
        myerr = .false.
    else
        call StoreError(GT_EBADVAR, "GTVarClose", err)
        call endsub('GTVarClose', 'badvar')
        myerr = .true.
    endif
999 continue
    call endsub('gtvarclose')
    if (present(err)) err = myerr
end subroutine

[Validate]