gtvarclose.f90 File Reference

Go to the source code of this file.

Functions/Subroutines

subroutine gtvarclose (var, err)
 

Function/Subroutine Documentation

◆ gtvarclose()

subroutine gtvarclose ( type(gt_variable), intent(in), target  var,
logical, intent(out), optional  err 
)

Definition at line 14 of file gtvarclose.f90.

References dc_trace::beginsub(), dc_trace::dbgmessage(), dc_error::dc_noerr, dc_trace::endsub(), dc_error::gt_ebadvar, gtdata_internal_map::map_lookup(), gtdata_internal_map::maptabdelete(), dc_error::storeerror(), gtdata_internal_vartable::vartabledelete(), and gtdata_internal_vartable::vartablelookup().

14  !
15  !== 変数の終了処理
16  !
17  ! 変数 *var* の終了処理を行います。Open または Create されたものは
18  ! プログラムの最後に必ずこのサブルーチンを用いて終了処理を行ってください。
19  !
20  ! 終了処理の際にエラーが生じた場合、メッセージを出力してプログラムは
21  ! 強制終了します。*err* を与えてある場合にはこの引数に .true.
22  ! が返り、プログラムは終了しません。
23  !
24  use gtdata_types, only: gt_variable
25  use gtdata_internal_map, only: vtb_class_netcdf, vtb_class_memory, &
28  use gtdata_netcdf_generic, only: close
31  use dc_trace, only: beginsub, endsub, dbgmessage
32  use gtdata_memory_generic, only: close
34  implicit none
35  type(gt_variable), intent(in), target:: var
36  logical, intent(out), optional:: err
37  integer:: vid, class, cid
38  logical:: action, myerr
39 continue
40  call beginsub('gtvarclose', fmt='var=%d', i=(/var%mapid/))
41  call map_lookup(var, vid=vid)
42  call maptabdelete(var, myerr)
43  if (myerr) goto 999
44  ! vid が 0 になるのは dup_dimmap で作られたハンドル
45  if (vid == 0) goto 999
46  call vartablelookup(vid, class, cid)
47  call vartabledelete(vid, action, myerr)
48  if (myerr) goto 999
49  if (.not. action) then
50  call dbgmessage('refcount decrement only, no close internal var')
51  goto 999
52  else if (class == vtb_class_netcdf) then
53  call close(gd_nc_variable(cid), myerr)
54  if (myerr) goto 999
55  else if (class == vtb_class_memory) then
56  call close(gd_mem_variable(cid))
57  myerr = .false.
58  else
59  call storeerror(gt_ebadvar, "GTVarClose", err)
60  call endsub('GTVarClose', 'badvar')
61  myerr = .true.
62  endif
63 999 continue
64  call endsub('gtvarclose')
65  if (present(err)) err = myerr
subroutine, public vartabledelete(vid, action, err)
subroutine, public maptabdelete(var, err)
subroutine, public storeerror(number, where, err, cause_c, cause_i)
Definition: dc_error.f90:830
integer, parameter, public gt_ebadvar
Definition: dc_error.f90:539
integer, parameter, public dc_noerr
Definition: dc_error.f90:509
subroutine, public dbgmessage(fmt, i, r, d, L, n, c1, c2, c3, ca)
Definition: dc_trace.f90:509
subroutine, public beginsub(name, fmt, i, r, d, L, n, c1, c2, c3, ca, version)
Definition: dc_trace.f90:351
subroutine, public vartablelookup(vid, class, cid)
subroutine, public map_lookup(var, vid, map, ndims)
subroutine, public endsub(name, fmt, i, r, d, L, n, c1, c2, c3, ca)
Definition: dc_trace.f90:446
Here is the call graph for this function: