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

Delete dimension. More...

Go to the source code of this file.

Functions/Subroutines

subroutine gtvardeldim (var, dimord, err)
 

Detailed Description

Delete dimension.

Author
Eizi TOYODA, Yasuhiro MORIKAWA

Definition in file gtvardeldim.f90.

Function/Subroutine Documentation

◆ gtvardeldim()

subroutine gtvardeldim ( type(gt_variable), intent(in)  var,
integer, intent(in)  dimord,
logical, intent(out)  err 
)

Delete dimension from variable

Deletes dimension dimord from variable var. Since this only lowers the rank in the dimension correspondence table and decrements the valid dimension count, I/O is still possible after this operation if the dimension is already degenerate.

If an error occurs, outputs a message and terminates the program. If err is provided, returns .true. and program does not terminate.

Note
In NetCDF implementation, variable is not deleted but renamed. This is because netCDF API lacks variable deletion.
Parameters
[in]varVariable handle
[in]dimordDimension order number to delete
[out]errError flag

Definition at line 58 of file gtvardeldim.f90.

59 use gtdata_types, only: gt_variable
62 implicit none
63 type(gt_variable), intent(in):: var
64 integer, intent(in):: dimord
65 logical, intent(out):: err
66 type(gt_dimmap), allocatable:: map(:)
67 type(gt_dimmap):: tmpmap
68 integer:: ndimsp, stat
69 character(*), parameter:: subname = 'GTVarDelDim'
70continue
71 err = .true.
72 call beginsub(subname)
73 if (dimord < 1) then
74 call endsub(subname, "negative dimord=%d invalid", i=(/dimord/))
75 return
76 endif
77 call map_lookup(var, ndims=ndimsp)
78 if (ndimsp <= 0) then
79 call endsub(subname, "variable invalid")
80 return
81 else if (dimord > ndimsp) then
82 call endsub(subname, "dimord=%d not exist", i=(/dimord/))
83 return
84 endif
85
86 allocate(map(ndimsp))
87 call map_lookup(var, map=map)
88 tmpmap = map(dimord)
89 map(dimord: ndimsp-1) = map(dimord+1: ndimsp)
90 map(ndimsp) = tmpmap
91 call map_set(var, map, stat)
92 deallocate(map)
93
94 call map_set_ndims(var, ndims = ndimsp - 1, stat=stat)
95 err = stat /= 0
96 call endsub(subname)
Debug tracing module.
Definition dc_trace.f90:150
subroutine, public dbgmessage(fmt, i, r, d, l, n, c1, c2, c3, ca)
Definition dc_trace.f90:661
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
subroutine, public map_lookup(var, vid, map, ndims)
subroutine map_set_ndims(var, ndims, stat)
subroutine map_set(var, map, stat)

References dc_trace::beginsub(), dc_trace::dbgmessage(), dc_trace::endsub(), gtdata_internal_map::map_lookup(), gtdata_internal_map::map_set(), and gtdata_internal_map::map_set_ndims().

Here is the call graph for this function: