source: LMDZ6/branches/Amaury_dev/tools/netcdf95/nf95_abort.f90 @ 5411

Last change on this file since 5411 was 5088, checked in by abarral, 5 months ago

Remove all managed netcdf77 usage (excluding external: rrtm, ecrad)
Remove call to netcdf.inc
Replace USE lmdz_netcdf by USE netcdf
Replace lmdz_netcdf.F90 by lmdz_netcdf_format.F90

File size: 1.1 KB
Line 
1module nf95_abort_m
2
3  implicit none
4
5contains
6
7  subroutine nf95_abort(message, ncerr, ncid, varid)
8
9    use, intrinsic:: iso_fortran_env, ONLY: error_unit
10
11    ! Libraries:mod_phys_lmdz_mpi_transfert
12    use netcdf, only: nf90_strerror
13
14    use nf95_close_m, only: nf95_close
15    use nf95_inq_file_ncid_m, only: nf95_inq_file_ncid
16
17    character(len=*), intent(in):: message
18    ! (should include name of calling procedure)
19
20    integer, intent(in):: ncerr
21
22    integer, intent(in), optional :: ncid
23    ! This can be the file ncid or a group ncid. Provide this argument
24    ! if you want nf95_abort to try to close the file.
25
26    integer, intent(in), optional :: varid
27
28    ! Local:
29    integer ncid_local
30
31    !-------------------
32
33    write(error_unit, fmt = *) message, ":"
34    if (present(varid)) write(error_unit, fmt = *) "varid = ", varid
35    write(error_unit, fmt = *) trim(nf90_strerror(ncerr))
36
37    if (present(ncid)) then
38       ! Try to close, to leave the file in a consistent state:
39       call nf95_inq_file_ncid(ncid_local, ncid)
40       call nf95_close(ncid_local)
41    end if
42
43    stop 1
44
45  end subroutine nf95_abort
46
47end module nf95_abort_m
Note: See TracBrowser for help on using the repository browser.