gtool5 Fortran 90/95 ライブラリ 1.0.0-rc5
English
Loading...
Searching...
No Matches
gdncsearchdim.f90
Go to the documentation of this file.
1!> @file gdncsearchdim.f90
2!>
3!> @author Eizi TOYODA, Yasuhiro MORIKAWA
4!> @copyright Copyright (C) GFD Dennou Club, 2001-2026. All rights reserved. <br/>
5!> License is BSD-2-Clause. See [COPYRIGHT](@ref COPYRIGHT) in detail
6!>
7!> @en
8!> @brief Search for dimension variable ID
9!> @enden
10!>
11!> @ja
12!> @brief 次元変数 ID の検索
13!> @endja
14!>
15
16!>
17!> @en
18!> @brief Get the dimension order for a named dimension
19!>
20!> Returns the position (1-based) of the dimension in the variable's
21!> dimension list.
22!> @enden
23!>
24!> @ja
25!> @brief 次元名から次元順序を取得
26!>
27!> 変数の次元リスト内での次元の位置 (1始まり) を返します。
28!> @endja
29!>
30!> @param[in] var @en Variable handle @enden @ja 変数ハンドル @endja
31!> @param[in] dimname @en Dimension name to search @enden @ja 検索する次元名 @endja
32!> @return @en Dimension order (1-based), or NF90_EBADDIM on error @enden
33!> @ja 次元順序 (1始まり)、エラー時は NF90_EBADDIM @endja
34!>
35integer function gdncsearchdim(var, dimname) result(result)
39 use netcdf, only: nf90_ebaddim, nf90_noerr, nf90_inq_dimid
40 use dc_error
41 use dc_trace, only: beginsub, endsub
42 implicit none
43 type(gd_nc_variable), intent(in):: var
44 character(*), intent(in):: dimname
45 type(gd_nc_variable_entry):: ent
46 integer:: stat, dimid, i
47 character(*), parameter:: subname = 'GDNcSearchDim'
48continue
49 call beginsub(subname, 'var=%d dimname=%c', i=(/var%id/), c1=trim(dimname))
50 result = nf90_ebaddim
51 stat = vtable_lookup(var, ent)
52 if (stat /= nf90_noerr) goto 999
53
54 stat = nf90_inq_dimid(ent%fileid, dimname, dimid)
55 if (stat /= nf90_noerr) goto 999
56
57 if (dimid == ent%dimid) then
58 result = 1
59 goto 999
60 endif
61
62 if (.not. associated(ent%dimids)) then
63 stat = gt_enomoredims
64 goto 999
65 endif
66 do, i = 1, size(ent%dimids)
67 if (ent%dimids(i) == dimid) then
68 result = i
69 goto 999
70 endif
71 enddo
72
73999 continue
74 call endsub(subname, 'result=%d', i=(/result/))
75 return
76end function gdncsearchdim
integer function gdncsearchdim(var, dimname)
エラー処理用モジュール
Definition dc_error.f90:454
integer, parameter, public gt_enomoredims
-101 以下: データ構造のエラー
Definition dc_error.f90:507
デバッグ時の追跡用モジュール
Definition dc_trace.f90:150
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
integer function, public vtable_lookup(var, entry)