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

Open netCDF dimension variable by dimension order . More...

Go to the source code of this file.

Functions/Subroutines

subroutine gdncvaropenbydimord (var, src_var, dimord, err)

Detailed Description

Open netCDF dimension variable by dimension order

.

Author
Yasuhiro MORIKAWA, Eizi TOYODA

Definition in file gdncvaropenbydimord.f90.

Function/Subroutine Documentation

◆ gdncvaropenbydimord()

subroutine gdncvaropenbydimord ( type(gd_nc_variable), intent(out) var,
type(gd_nc_variable), intent(in) src_var,
integer, intent(in) dimord,
logical, intent(out), optional err )

Open the dimension variable at specified position

Opens the variable corresponding to the dimord-th dimension of an already opened variable src_var, and stores it in var.

On error, outputs a message and terminates the program. If err is provided, it returns .true. instead of terminating.

Parameters
[out]varOpened dimension variable
[in]src_varSource variable
[in]dimordDimension order (1-based)
[out]errError flag (optional)

Definition at line 42 of file gdncvaropenbydimord.f90.

46 use netcdf, only: nf90_max_name, nf90_noerr, nf90_einval, nf90_enotvar, &
47 & nf90_inquire_dimension, nf90_inq_varid
48 use dc_error
49 implicit none
50 type(GD_NC_VARIABLE), intent(out):: var
51 type(GD_NC_VARIABLE), intent(in):: src_var
52 integer, intent(in):: dimord
53 logical, intent(out), optional:: err
54 type(GD_NC_VARIABLE_ENTRY):: src_ent
55 type(GD_NC_VARIABLE_SEARCH):: ent
56 character(len = NF90_MAX_NAME):: dimname
57 integer:: stat
58continue
59 stat = vtable_lookup(src_var, src_ent)
60 if (stat /= nf90_noerr) goto 999
61 !
62 if (dimord <= 0) then
63 !
64 ! dimord == 0 の特別扱いは廃止 (gtdata 層でやる)。
65 ! (同じハンドルを返すと参照カウントが増えないので多重クローズが
66 ! 禁止されてしまい、Open のセマンティクスに不適合なため。)
67 !
68 var = src_var
69 stat = nf90_einval
70 goto 999
71 endif
72 if (.not. associated(src_ent%dimids)) then
73 stat = gt_enomoredims
74 goto 999
75 else if (dimord > size(src_ent%dimids)) then
76 stat = gt_enomoredims
77 goto 999
78 endif
79 !
80 ! 決定された次元 id を使って変数 id の確定を試みる
81 !
82 ent%fileid = src_ent%fileid
83 ent%dimid = src_ent%dimids(dimord)
84 stat = nf90_inquire_dimension(ent%fileid, ent%dimid, name = dimname)
85 if (stat /= nf90_noerr) goto 999
86 stat = nf90_inq_varid(ent%fileid, dimname, ent%varid)
87 if (stat == nf90_enotvar) then
88 ! 変数が対応しなければ無視するだけ
89 ent%varid = 0
90 stat = nf90_noerr
91 else if (stat /= nf90_noerr) then
92 goto 999
93 endif
94 !
95 ! 成功しそうなので参照カウント値を増やす
96 call gdncfilereopen(ent%fileid)
97 ! 不適合な変数が開かれている場合は vtable_add が変数部を無視する。
98 stat = vtable_add(var, ent)
99 if (stat /= nf90_noerr) then
100 call gdncfileclose(ent%fileid)
101 goto 999
102 endif
103
104999 continue
105 call storeerror(stat, 'GDNcVarOpenByDimOrd', err, cause_i=dimord)
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_enomoredims
-101 or less: Data structure errors
Definition dc_error.f90:507
integer function, public vtable_add(var, entry)
integer function, public vtable_lookup(var, entry)

References dc_error::gt_enomoredims, dc_error::storeerror(), gtdata_netcdf_internal::vtable_add(), and gtdata_netcdf_internal::vtable_lookup().

Here is the call graph for this function: