source: LMDZ6/trunk/tools/netcdf95/docs/Detailed_content/groups.md @ 5303

Last change on this file since 5303 was 4918, checked in by Laurent Fairhead, 6 months ago

Reintegrated NetCDF95 in LMDZ so that it is compiled and made available by the makelmdz_fcm script.
The makelmdz_fcm creates the libnetcdf95 library and copies it in the tools/netcdf/lib directory, copying
the mod files in the tools/netcdf/include library.

File size: 4.8 KB
Line 
1# Groups
2
3This page describles procedures handling NetCDF groups.
4
5See the [improvements page](improvements.md) for an
6explanation of the mnemonics \"basic change\", \"interface change\",
7\"functionality change\", \"additional procedure\".
8
9## `nf95_inq_file_ncid`
10
11(additional procedure)
12
13```
14subroutine nf95_inq_file_ncid(ncid_file, grpid, ncerr)
15
16  ! Find the ncid of the file (that is, the root group), knowing the
17  ! ncid of a group in the file.
18
19  integer, intent(out):: ncid_file
20  integer, intent(in):: grpid
21  integer, intent(out), optional:: ncerr
22```
23
24## `nf95_inq_grp_full_ncid`
25
26(basic change)
27
28```
29subroutine nf95_inq_grp_full_ncid(ncid, full_name, grp_ncid, ncerr)
30
31  integer, intent(in):: ncid ! can be the file id or a group id
32
33  character(len = *), intent(in):: full_name
34  ! Should be a path relative to ncid (which can correspond to the
35  ! root group or a subgroup). Can be an immediate subgroup or a
36  ! deeper subgroup.
37
38  integer, intent(out):: grp_ncid
39  integer, intent(out), optional:: ncerr
40```
41
42You know the relative path of a group and you want its ncid.
43
44Reference:
45[`nc_inq_grp_full_ncid`](https://docs.unidata.ucar.edu/netcdf-c/current/group__groups.html#ga41d2e214f1a880493ed8ea3fbddab806)
46
47## `nf95_inq_grpname`
48
49(functionality change)
50
51```
52subroutine nf95_inq_grpname(ncid, name, ncerr)
53
54  integer, intent(in):: ncid ! can be the file id or a group id
55  character(len = :), allocatable, intent(out):: name ! without path
56  integer, intent(out), optional:: ncerr
57```
58
59You know the ncid of a group (which can be the root group) and you
60want the basename of this group. The basename of the group is the last
61part in the absolute path, as in the Unix basename program. The
62basename of the root group is "/".
63
64The functionality change is that the argument `name` has dynamic,
65deferred length.
66
67The problem with the Fortran 90 interface: `name` has assumed length
68in the Fortran 90 interface. Also, there is no way in the Fortran 90
69interface to only inquire about the length of the name. The function
70`nf90_inq_grpname_len` gives the length of the absolute path of the
71group, not the length of the basename of the group.
72
73Reference:
74[`nf90_inq_grpname`](https://docs.unidata.ucar.edu/netcdf-fortran/current/f90_groups.html#f90-find-a-groups-name-nf90_inq_grpname)
75
76## `nf95_inq_grpname_full`
77
78(functionality change)
79
80```
81subroutine nf95_inq_grpname_full(ncid, full_name, ncerr)
82
83  integer, intent(in):: ncid
84  character(len = :), allocatable, intent(out):: full_name ! absolute path
85  integer, intent(out), optional:: ncerr
86```
87
88You know the ncid of a group (which can be the root group) and you
89want the absolute path of the group.
90
91The functionality change is that the argument `full_name` has dynamic,
92deferred length, and there is no length argument. Since `full_name` is
93allocated to the exact length of the path, the length argument is
94useless, you can just query the length of the actual argument after
95the call.
96
97The problem with the Fortran 90 interface: the name argument has assumed length
98in the Fortran 90 interface. You have to call `nf90_inq_grpname_len`
99first to know the length of the actual argument that you will
100associate to name.
101
102Reference:
103[`nf90_inq_grpname_full`](https://docs.unidata.ucar.edu/netcdf-fortran/current/f90_groups.html#f90-find-a-groups-full-name-nf90_inq_grpname_full)
104
105## `nf95_inq_grp_parent`
106
107(basic change)
108
109```
110subroutine nf95_inq_grp_parent(ncid, parent_ncid, ncerr)
111
112  integer, intent(in):: ncid
113  integer, intent(out):: parent_ncid
114  integer, intent(out), optional:: ncerr
115```
116
117You know the ncid of a group and you want the ncid of the parent
118group.
119
120## `nf95_inq_grps`
121
122(functionality change)
123
124```
125subroutine nf95_inq_grps(ncid, ncids, ncerr)
126
127  integer, intent(in):: ncid ! can be the file id or a group id
128  integer, allocatable, intent(out):: ncids(:)
129  integer, intent(out), optional:: ncerr
130```
131
132You know the ncid of a group (which can be the root group) and you
133want the ncids of its immediate subgroups.
134
135The functionality change is that the argument ncids is allocatable and
136there is no argument numgrps. Since ncids is allocated to the number
137of groups, the argument numgrps is useless, you can just query the
138size of the actual argument associated to ncids after the call.
139
140The problem with the Fortran 90 interface: ncids has assumed shape in
141the Fortran 90 interface. Also, there is no way in the Fortran 90
142interface to only inquire about the number of subgroups. The Fortran
14390 interface is dangerous here because it does not check that the size
144of ncids is large enough: a segmentation violation will occur if it is
145not. NetCDF95 solves this by going directly to the C interface.
146
147Reference:
148[`nf90_inq_grps`](https://docs.unidata.ucar.edu/netcdf-fortran/current/f90_groups.html#f90-get-a-list-of-groups-in-a-group-nf90_inq_grps)
149and
150[`nc_inq_grps`](https://docs.unidata.ucar.edu/netcdf-c/current/group__groups.html#ga33eb934cc6810770be78eaa822656a00)
151
Note: See TracBrowser for help on using the repository browser.