Loading...
Searching...
No Matches
gtvarclose.f90
Go to the documentation of this file.
1!
2!= 変数の終了処理
3!
4! Authors:: Yasuhiro MORIKAWA, Eizi TOYODA
5! Version:: $Id: gtvarclose.f90,v 1.5 2009-05-25 09:55:58 morikawa Exp $
6! Tag Name:: $Name: $
7! Copyright:: Copyright (C) GFD Dennou Club, 2000-2005. All rights reserved.
8! License:: See COPYRIGHT[link:../../COPYRIGHT]
9!
10! 以下のサブルーチン, 関数は gtdata_generic から提供されます。
11!
12
13subroutine gtvarclose(var, err)
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, &
31 use dc_trace, only: beginsub, endsub, dbgmessage
32 implicit none
33 type(gt_variable), intent(in), target:: var
34 logical, intent(out), optional:: err
35 integer:: vid, class, cid
36 logical:: action, myerr
37continue
38 call beginsub('gtvarclose', fmt='var=%d', i=(/var%mapid/))
39 call map_lookup(var, vid=vid)
40 call maptabdelete(var, myerr)
41 if (myerr) goto 999
42 ! vid が 0 になるのは dup_dimmap で作られたハンドル
43 if (vid == 0) goto 999
44 call vartablelookup(vid, class, cid)
45 call vartabledelete(vid, action, myerr)
46 if (myerr) goto 999
47 if (.not. action) then
48 call dbgmessage('refcount decrement only, no close internal var')
49 goto 999
50 else if (class == vtb_class_netcdf) then
51 call close(gd_nc_variable(cid), myerr)
52 if (myerr) goto 999
53 else
54 call storeerror(gt_ebadvar, "GTVarClose", err)
55 call endsub('GTVarClose', 'badvar')
56 myerr = .true.
57 endif
58999 continue
59 call endsub('gtvarclose')
60 if (present(err)) err = myerr
61end subroutine gtvarclose
subroutine gtvarclose(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 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