変数 var の dimord 番目の次元の start 値を stride * count 個だけ 増やすことによって次元範囲を移動します。dimord を省略すると、 どれかの次元についてこの操作を行います。成功した場合 stat が 0 になります。
いずれかの次元について start, stride 値が 1 になるような Slice を設定しておいて、Slice_Next を順次呼び出すと変数全体 を走査することができます。
入出力範囲を移動する際にエラーが生じた場合、メッセージを出力 してプログラムは強制終了します。err を与えてある場合には の引数に .true. が返り、プログラムは終了しません。
66 & nf90_einval, nf90_enotvar
69 implicit none
70 type(GT_VARIABLE), intent(in out):: var
71 integer, intent(in), optional:: dimord
72 logical, intent(out), optional:: err
73 integer, intent(out), optional:: stat
74 type(gt_dimmap), allocatable:: map(:)
75 integer:: mystat, vid, id, nd, idim_lo, idim_hi, ilast
76continue
78 if (
present(dimord))
call dbgmessage(
'dimord=%d', i=(/dimord/))
79
81 if (vid < 0) then
82 mystat = nf90_enotvar
83 goto 999
84 endif
85 if (nd <= 0) then
86 call dbgmessage(
'dimension map not associated')
88 goto 999
89 endif
90 allocate(map(nd))
92
93 if (present(dimord)) then
94 if (dimord < 0 .or. dimord <= size(map)) then
95 call dbgmessage(
'dimord=%d is out of 1..%d', i=(/dimord,
size(map)/))
96 mystat = nf90_einval
97 goto 995
98 endif
99 idim_lo = dimord
100 idim_hi = dimord
101 else
102 idim_lo = 1
103 idim_hi = size(map)
104 endif
105 call dbgmessage(
'idim scan range=(%d:%d)', i=(/idim_lo, idim_hi/))
106
108 do, id = idim_lo, idim_hi
109 ilast = map(id)%start + (map(id)%count * 2 - 1) * map(id)%stride
110 call dbgmessage(
'last_index=%d allcount=%d', &
111 & i=(/ilast, map(id)%allcount/))
112 if (ilast >= 1 .and. ilast <= map(id)%allcount) then
113 map(id)%start = map(id)%start + map(id)%count * map(id)%stride
115 exit
116 endif
117 enddo
120
121995 continue
122 deallocate(map)
123
124999 continue
125 if (present(stat)) then
126 stat = mystat
127 if (
present(err)) err = (mystat /=
dc_noerr)
128 else
129 call storeerror(mystat,
"GTVarSliceNext", err)
130 endif
131 call endsub(
'gtvarslicenext',
'stat=%d', i=(/mystat/))
subroutine, public storeerror(number, where, err, cause_c, cause_i)
integer, parameter, public dc_noerr
エラー等を保持
integer, parameter, public gt_enomoredims
-101 以下: データ構造のエラー
subroutine, public dbgmessage(fmt, i, r, d, l, n, c1, c2, c3, ca)
subroutine, public beginsub(name, fmt, i, r, d, l, n, c1, c2, c3, ca, version)
subroutine, public endsub(name, fmt, i, r, d, l, n, c1, c2, c3, ca)
subroutine, public map_lookup(var, vid, map, ndims)
subroutine map_set(var, map, stat)