source: LMDZ5/trunk/tools/Max_diff_nc_with_lib/NetCDF95/nf95_inquire_variable.f90 @ 1907

Last change on this file since 1907 was 1907, checked in by lguez, 10 years ago

Added a copyright property to every file of the distribution, except
for the fcm files (which have their own copyright). Use svn propget on
a file to see the copyright. For instance:

$ svn propget copyright libf/phylmd/physiq.F90
Name of program: LMDZ
Creation date: 1984
Version: LMDZ5
License: CeCILL version 2
Holder: Laboratoire de m\'et\'eorologie dynamique, CNRS, UMR 8539
See the license file in the root directory

Also added the files defining the CeCILL version 2 license, in French
and English, at the top of the LMDZ tree.

  • Property copyright set to
    Name of program: LMDZ
    Creation date: 1984
    Version: LMDZ5
    License: CeCILL version 2
    Holder: Laboratoire de m\'et\'eorologie dynamique, CNRS, UMR 8539
    See the license file in the root directory
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.