gtool5 Fortran 90/95 Library 1.0.0-rc5
日本語
Loading...
Searching...
No Matches
gtvarclose.f90 File Reference

Variable finalization. More...

Go to the source code of this file.

Functions/Subroutines

subroutine gtvarclose (var, err)

Detailed Description

Variable finalization.

Author
Yasuhiro MORIKAWA, Eizi TOYODA

This subroutine is provided through gtdata_generic.

Definition in file gtvarclose.f90.

Function/Subroutine Documentation

◆ gtvarclose()

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

Finalize variable

Performs finalization for variable var. Variables that have been Opened or Created must be finalized using this subroutine at the end of the program.

If an error occurs during finalization, outputs a message and terminates the program. If err is provided, returns .true. in that argument and program does not terminate.

Parameters
[in]varVariable handle to close
[out]errError flag (optional)

Definition at line 48 of file gtvarclose.f90.

49 use gtdata_types, only: gt_variable
50 use gtdata_internal_map, only: vtb_class_netcdf, &
57 implicit none
58 type(GT_VARIABLE), intent(in), target:: var
59 logical, intent(out), optional:: err
60 integer:: vid, class, cid
61 logical:: action, myerr
62continue
63 call beginsub('gtvarclose', fmt='var=%d', i=(/var%mapid/))
64 call map_lookup(var, vid=vid)
65 call maptabdelete(var, myerr)
66 if (myerr) goto 999
67 ! vid が 0 になるのは dup_dimmap で作られたハンドル
68 if (vid == 0) goto 999
69 call vartablelookup(vid, class, cid)
70 call vartabledelete(vid, action, myerr)
71 if (myerr) goto 999
72 if (.not. action) then
73 call dbgmessage('refcount decrement only, no close internal var')
74 goto 999
75 else if (class == vtb_class_netcdf) then
76 call close(gd_nc_variable(cid), myerr)
77 if (myerr) goto 999
78 else
79 call storeerror(gt_ebadvar, "GTVarClose", err)
80 call endsub('GTVarClose', 'badvar')
81 myerr = .true.
82 endif
83999 continue
84 call endsub('gtvarclose')
85 if (present(err)) err = myerr
Error handling module.
Definition dc_error.f90:454
subroutine, public storeerror(number, where, err, cause_c, cause_i)
Definition dc_error.f90:891
integer, parameter, public gt_ebadvar
Definition dc_error.f90:518
Debug tracing module.
Definition dc_trace.f90:150
subroutine, public dbgmessage(fmt, i, r, d, l, n, c1, c2, c3, ca)
Definition dc_trace.f90:661
subroutine, public beginsub(name, fmt, i, r, d, l, n, c1, c2, c3, ca, version)
Definition dc_trace.f90:457
subroutine, public endsub(name, fmt, i, r, d, l, n, c1, c2, c3, ca)
Definition dc_trace.f90:580
subroutine, public map_lookup(var, vid, map, ndims)
subroutine, public maptabdelete(var, err)
subroutine, public vartabledelete(vid, action, err)
subroutine, public vartablelookup(vid, class, cid)
integer, parameter, public vtb_class_netcdf

References dc_trace::beginsub(), dc_trace::dbgmessage(), 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().

Here is the call graph for this function: