source: LMDZ5/branches/testing/tools/Max_diff_nc_with_lib/NetCDF95/nf95_inquire_variable.f90 @ 1795

Last change on this file since 1795 was 1795, checked in by Ehouarn Millour, 11 years ago

Version testing basee sur la r1794


Testing release based on r1794

File size: 1.7 KB
Line 
1module nf95_inquire_variable_m
2
3  implicit none
4
5contains
6
7  subroutine nf95_inquire_variable(ncid, varid, name, xtype, ndims, dimids, &
8       nAtts, ncerr)
9
10    ! In "nf90_inquire_variable", "dimids" is an assumed-size array.
11    ! This is not optimal.
12    ! We are in the classical case of an array the size of which is
13    ! unknown in the calling procedure, before the call.
14    ! Here we use a better solution: a pointer argument array.
15    ! This procedure associates and defines "dimids" if it is present.
16
17    use handle_err_m, only: handle_err
18    use netcdf, only: nf90_inquire_variable, nf90_max_var_dims
19
20    integer, intent(in):: ncid, varid
21    character(len = *), optional, intent(out):: name
22    integer, optional, intent(out) :: xtype, ndims
23    integer, dimension(:), optional, pointer :: dimids
24    integer, optional, intent(out) :: nAtts
25    integer, intent(out), optional :: ncerr
26
27    ! Variable local to the procedure:
28    integer ncerr_not_opt
29    integer dimids_local(nf90_max_var_dims)
30    integer ndims_not_opt
31
32    !-------------------
33
34    if (present(dimids)) then
35       ncerr_not_opt = nf90_inquire_variable(ncid, varid, name, xtype, &
36            ndims_not_opt, dimids_local, nAtts)
37       allocate(dimids(ndims_not_opt)) ! also works if ndims_not_opt == 0
38       dimids = dimids_local(:ndims_not_opt)
39       if (present(ndims)) ndims = ndims_not_opt
40    else
41       ncerr_not_opt = nf90_inquire_variable(ncid, varid, name, xtype, ndims, &
42            nAtts=nAtts)
43    end if
44
45    if (present(ncerr)) then
46       ncerr = ncerr_not_opt
47    else
48       call handle_err("nf95_inquire_variable", ncerr_not_opt, ncid, varid)
49    end if
50
51  end subroutine nf95_inquire_variable
52
53end module nf95_inquire_variable_m
Note: See TracBrowser for help on using the repository browser.