gtool5 Fortran 90/95 ライブラリ 1.0.0-rc5
English
Loading...
Searching...
No Matches
gdncfileclose.f90 File Reference

netCDF ファイルを閉じる More...

Go to the source code of this file.

Functions/Subroutines

subroutine gdncfileclose (fileid, err)

Detailed Description

netCDF ファイルを閉じる

Author
Yasuhiro MORIKAWA, Eizi TOYODA

Definition in file gdncfileclose.f90.

Function/Subroutine Documentation

◆ gdncfileclose()

subroutine gdncfileclose ( integer, intent(in) fileid,
logical, intent(out), optional err )

netCDF ファイルを閉じる

指定されたファイル ID の参照カウントを減算します。 参照カウントがゼロになると、nf90_close を使用して実際にファイルを閉じ、 内部ファイルリストから削除します。

Parameters
[in]fileidnetCDF ファイル ID
[out]errエラーフラグ (省略可能)

Definition at line 37 of file gdncfileclose.f90.

40 use netcdf, only: nf90_close, nf90_enotnc, nf90_noerr
41 use dc_error, only: storeerror
43 integer, intent(in):: fileid
44 logical, intent(out), optional:: err
45 type(GD_NC_FILE_ID_ENTRY), pointer:: identptr, prev
46 integer:: stat
47 character(*), parameter:: subname = "GDNcFileClose"
48continue
49 call beginsub(subname)
50 stat = nf90_enotnc
51 if (.not. id_used) goto 999
52 identptr => id_head
53 nullify(prev)
54 do
55 if (.not. associated(identptr)) goto 999
56 if (identptr % id == fileid) exit
57 prev => identptr
58 identptr => identptr % next
59 enddo
60 identptr % count = identptr % count - 1
61 if (identptr % count <= 0) then
62 stat = nf90_close(fileid)
63 if (associated(prev)) then
64 prev%next => identptr % next
65 else
66 id_head => identptr % next
67 if (.not. associated(id_head)) id_used = .false.
68 endif
69 call dbgmessage(subname // ': <%c> closed', c1=trim(identptr % filename))
70 deallocate(identptr)
71 else
72 call dbgmessage(subname // ': %d<%c> skipped for refcount=%d', &
73 & c1=trim(identptr % filename), i=(/fileid, identptr % count/))
74 stat = nf90_noerr
75 endif
76999 continue
77 call endsub(subname)
78 call storeerror(stat, 'GDNcFileClose', err)
エラー処理用モジュール
Definition dc_error.f90:454
subroutine, public storeerror(number, where, err, cause_c, cause_i)
Definition dc_error.f90:891
デバッグ時の追跡用モジュール
Definition dc_trace.f90:150
subroutine, public dbgmessage(fmt, i, r, d, l, n, c1, c2, c3, ca)
Definition dc_trace.f90:680
subroutine, public beginsub(name, fmt, i, r, d, l, n, c1, c2, c3, ca, version)
Definition dc_trace.f90:476
subroutine, public endsub(name, fmt, i, r, d, l, n, c1, c2, c3, ca)
Definition dc_trace.f90:599
logical, save id_used
id_head が初期化済みかを示すフラグ
type(gd_nc_file_id_entry), pointer, save id_head
netCDF ファイルのオープンクローズのための ID テーブル

References dc_trace::beginsub(), dc_trace::dbgmessage(), dc_trace::endsub(), gtdata_netcdf_file_internal::id_head, gtdata_netcdf_file_internal::id_used, and dc_error::storeerror().

Here is the call graph for this function: