[4918] | 1 | # Handling of errors |
---|
| 2 | |
---|
| 3 | If you call a NetCDF95 procedure without the optional `ncerr` |
---|
| 4 | argument, and some error occurs, then the NetCDF95 procedure will: |
---|
| 5 | |
---|
| 6 | - write to standard output all the information it has, including the |
---|
| 7 | string produced by `nf90_strerror`; |
---|
| 8 | - try to close the NetCDF file; |
---|
| 9 | - stop the program, with an exit status of 1. |
---|
| 10 | |
---|
| 11 | For example, if some error occurs within a call to `nf95_inq_varid`, |
---|
| 12 | `nf95_inq_varid` will write to standard output: |
---|
| 13 | |
---|
| 14 | nf95_inq_varid, name = < name of the variable you inquired about >: |
---|
| 15 | < string produced by nf90_strerror > |
---|
| 16 | |
---|
| 17 | ## `nf95_abort` |
---|
| 18 | |
---|
| 19 | (additional procedure) |
---|
| 20 | |
---|
| 21 | ``` |
---|
| 22 | subroutine nf95_abort(message, ncerr, ncid, varid) |
---|
| 23 | character(len=*), intent(in):: message |
---|
| 24 | ! (should include name of calling procedure) |
---|
| 25 | |
---|
| 26 | integer, intent(in):: ncerr |
---|
| 27 | |
---|
| 28 | integer, intent(in), optional :: ncid |
---|
| 29 | ! This can be the file ncid or a group ncid. Provide this argument |
---|
| 30 | ! if you want nf95_abort to try to close the file. |
---|
| 31 | |
---|
| 32 | integer, intent(in), optional :: varid |
---|
| 33 | ``` |
---|
| 34 | |
---|
| 35 | This is a public procedure which is also used internally in NetCDF95. |
---|
| 36 | `nf95_abort` prints a message and stops the program. `nf95_abort` may |
---|
| 37 | also be useful after calling procedures of the Fortran 90 interface |
---|
| 38 | that have not been implemented in NetCDF95. |
---|
| 39 | |
---|
| 40 | You should include the name of the calling procedure in the `message` |
---|
| 41 | argument. Provide the `ncid` argument if you want `nf95_abort` to try |
---|
| 42 | to close the file. Provide `varid` if you want `nf95_abort` to print |
---|
| 43 | it. |
---|