source: LMDZ6/trunk/tools/netcdf95/Groups/nf95_inq_grpname.f90 @ 5136

Last change on this file since 5136 was 4918, checked in by Laurent Fairhead, 7 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: 1.6 KB
RevLine 
[4918]1module nf95_inq_grpname_m
2
3  implicit none
4
5contains
6
7  subroutine nf95_inq_grpname(ncid, name, ncerr)
8
9    use, intrinsic:: ISO_C_BINDING
10
11    use nc_constants, only: NC_NOERR
12    use nc_inq_grpname_len_m, only: nc_inq_grpname_len
13    use nf95_abort_m, only: nf95_abort
14
15    integer, intent(in):: ncid ! can be the file id or a group id
16    character(len = :), allocatable, intent(out):: name ! without path
17    integer, intent(out), optional:: ncerr
18
19    ! Local:
20
21    Integer(C_INT) cncerr, cncid
22    Integer(C_SIZE_T) lenp
23    integer inull
24
25    Interface
26       Integer(C_INT) Function nc_inq_grpname(ncid, name) BIND(C)
27         import c_int, C_CHAR
28         Integer(C_INT), VALUE, Intent(IN):: ncid
29         CHARACTER(kind=C_CHAR), Intent(OUT):: name(*)
30       End Function nc_inq_grpname
31    End Interface
32
33    !------------------------------------------------------------
34
35    cncid = int(ncid, c_int)
36    cncerr = nc_inq_grpname_len(cncid, lenp)
37    if (cncerr /= nc_noerr) call &
38         nf95_abort("nf95_inq_grpname -- nc_inq_grpname_len", int(cncerr), &
39         ncid)
40    allocate(character(lenp + 1):: name)
41
42    ! We assume that the C character kind is the same as the default
43    ! character kind:
44    cncerr = nc_inq_grpname(cncid, name)
45
46    if (present(ncerr)) then
47       ncerr = cncerr
48    else
49       if (cncerr /= nc_noerr) call &
50            nf95_abort("nf95_inq_grps -- nc_inq_grpname", int(cncerr), ncid)
51    end if
52
53    if (cncerr == nc_noerr) then
54       inull = SCAN(name, C_NULL_CHAR)
55       if (inull /= 0) name = name(:inull - 1)
56    end if
57
58  end subroutine nf95_inq_grpname
59
60end module nf95_inq_grpname_m
Note: See TracBrowser for help on using the repository browser.