gtool5 Fortran 90/95 ライブラリ 1.0.0-rc5
English
Loading...
Searching...
No Matches
gtvarclose.f90
Go to the documentation of this file.
1!> @file gtvarclose.f90
2!>
3!> @author Yasuhiro MORIKAWA, Eizi TOYODA
4!> @copyright Copyright (C) GFD Dennou Club, 2000-2026. All rights reserved. <br/>
5!> License is BSD-2-Clause. See [COPYRIGHT](@ref COPYRIGHT) in detail
6!>
7!> @en
8!> @brief Variable finalization
9!>
10!> This subroutine is provided through gtdata_generic.
11!> @enden
12!>
13!> @ja
14!> @brief 変数の終了処理
15!>
16!> このサブルーチンは gtdata_generic から提供されます。
17!> @endja
18!>
19
20!>
21!> @en
22!> @brief Finalize variable
23!>
24!> Performs finalization for variable var. Variables that have been
25!> Opened or Created must be finalized using this subroutine at the
26!> end of the program.
27!>
28!> If an error occurs during finalization, outputs a message and
29!> terminates the program. If err is provided, returns .true.
30!> in that argument and program does not terminate.
31!> @param[in] var Variable handle to close
32!> @param[out] err Error flag (optional)
33!> @enden
34!>
35!> @ja
36!> @brief 変数を終了処理
37!>
38!> 変数 var の終了処理を行います。Open または Create されたものは
39!> プログラムの最後に必ずこのサブルーチンを用いて終了処理を行ってください。
40!>
41!> 終了処理の際にエラーが生じた場合、メッセージを出力してプログラムは
42!> 強制終了します。err を与えてある場合にはこの引数に .true.
43!> が返り、プログラムは終了しません。
44!> @param[in] var クローズする変数ハンドル
45!> @param[out] err エラーフラグ (省略可能)
46!> @endja
47!>
48subroutine gtvarclose(var, err)
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
86end subroutine gtvarclose
subroutine gtvarclose(var, err)
エラー処理用モジュール
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
デバッグ時の追跡用モジュール
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