source: LMDZ6/trunk/tools/netcdf95/Groups/nf95_inq_grpname_full.f90 @ 5445

Last change on this file since 5445 was 4918, checked in by Laurent Fairhead, 8 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: 2.0 KB
Line 
1module nf95_inq_grpname_full_m
2
3  implicit none
4
5contains
6
7  subroutine nf95_inq_grpname_full(ncid, full_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    use nf95_constants, only: nf95_noerr
15
16    integer, intent(in):: ncid
17    character(len = :), allocatable, intent(out):: full_name ! absolute path
18    integer, intent(out), optional:: ncerr
19
20    ! Local:
21
22    integer(C_INT) cncerr, cncid
23    integer(C_SIZE_T) lenp
24    integer inull
25
26    Interface
27       Integer(C_INT) Function nc_inq_grpname_full(ncid, lenp, full_name) &
28            BIND(C)
29         import C_INT, C_SIZE_T, C_CHAR
30         Integer(C_INT), VALUE, intent(in):: ncid
31         Integer(C_SIZE_T), Intent(OUT):: lenp
32         Character(KIND=C_CHAR), Intent(OUT):: full_name(*)
33       End Function nc_inq_grpname_full
34    End Interface
35
36    !-------------------------------------------------------------------
37
38    cncid = int(ncid, c_int)
39    cncerr = Nc_INQ_GRPNAME_LEN(cncid, lenp)
40
41    if (cncerr == nc_noerr) then
42       allocate(character(len = lenp + 1):: full_name)
43
44       ! We assume that the C character kind is the same as the default
45       ! character kind:
46       cncerr = nc_inq_grpname_full(cncid, lenp, full_name)
47
48       if (cncerr == nc_noerr) then
49          inull = SCAN(full_name, C_NULL_CHAR)
50          if (inull /= 0) full_name = full_name(:inull - 1)
51          if (present(ncerr)) ncerr = nf95_noerr
52       else
53          if (present(ncerr)) then
54             ncerr = cncerr
55          else
56             call nf95_abort("nf95_inq_grpname_full", int(cncerr), ncid)
57          end if
58       end if
59    else
60       if (present(ncerr)) then
61          ncerr = cncerr
62       else
63          call nf95_abort("nf95_inq_grpname_full -- Nc_INQ_GRPNAME_LEN", &
64               int(cncerr), ncid)
65       end if
66    end if
67
68  end subroutine nf95_inq_grpname_full
69
70end module nf95_inq_grpname_full_m
Note: See TracBrowser for help on using the repository browser.