source: LMDZ5/branches/IPSLCM6.0.12/tools/Max_diff_nc_with_lib/NetCDF95/handle_err.f90

Last change on this file was 1907, checked in by lguez, 11 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.1 KB
Line 
1module handle_err_m
2
3  implicit none
4
5contains
6
7  subroutine handle_err(message, ncerr, ncid, varid)
8
9    use netcdf, only: nf90_strerror, nf90_noerr, nf90_close
10
11    character(len=*), intent(in):: message
12    ! (should include name of calling procedure)
13
14    integer, intent(in):: ncerr
15
16    integer, intent(in), optional :: ncid
17    ! (Provide this argument if you want "handle_err" to try to close
18    ! the file.)
19
20    integer, intent(in), optional :: varid
21
22    ! Variable local to the procedure:
23    integer ncerr_close
24
25    !-------------------
26
27    if (ncerr /= nf90_noerr) then
28       print *, message, ":"
29       if (present(varid)) print *, "varid = ", varid
30       print *, trim(nf90_strerror(ncerr))
31       if (present(ncid)) then
32          ! Try to close, to leave the file in a consistent state:
33          ncerr_close = nf90_close(ncid)
34          ! (do not call "nf95_close", we do not want to recurse)
35          if (ncerr_close /= nf90_noerr) then
36             print *, "nf90_close:"
37             print *, trim(nf90_strerror(ncerr_close))
38          end if
39       end if
40       stop 1
41    end if
42
43  end subroutine handle_err
44
45end module handle_err_m
Note: See TracBrowser for help on using the repository browser.