1 | #define __MYFILE__ 'nctools.F90' |
---|
2 | MODULE nctools |
---|
3 | |
---|
4 | ! Utility subroutines for netCDF access |
---|
5 | ! Modified : MAB (nf90, handle_error, LINE&FILE) |
---|
6 | ! Modifled : KSM (new shorter name) |
---|
7 | |
---|
8 | USE netcdf |
---|
9 | |
---|
10 | PUBLIC ldebug_netcdf, nchdlerr |
---|
11 | LOGICAL :: ldebug_netcdf = .FALSE. ! Debug switch for netcdf |
---|
12 | |
---|
13 | CONTAINS |
---|
14 | |
---|
15 | SUBROUTINE nchdlerr(status,lineno,filename) |
---|
16 | |
---|
17 | ! Error handler for netCDF access |
---|
18 | IMPLICIT NONE |
---|
19 | |
---|
20 | |
---|
21 | INTEGER :: status ! netCDF return status |
---|
22 | INTEGER :: lineno ! Line number (usually obtained from |
---|
23 | ! preprocessing __LINE__,__MYFILE__) |
---|
24 | CHARACTER(len=*),OPTIONAL :: filename |
---|
25 | |
---|
26 | IF (status/=nf90_noerr) THEN |
---|
27 | WRITE(*,*)'Netcdf error, code ',status |
---|
28 | IF (PRESENT(filename)) THEN |
---|
29 | WRITE(*,*)'In file ',filename,' in line ',lineno |
---|
30 | ELSE |
---|
31 | WRITE(*,*)'In line ',lineno |
---|
32 | END IF |
---|
33 | WRITE(*,'(2A)')' Error message : ',nf90_strerror(status) |
---|
34 | CALL abort |
---|
35 | ENDIF |
---|
36 | |
---|
37 | END SUBROUTINE nchdlerr |
---|
38 | |
---|
39 | !---------------------------------------------------------------------- |
---|
40 | END MODULE nctools |
---|