1 | ! radiation_io.F90 - Provides logging and abort functionality |
---|
2 | |
---|
3 | ! (C) Copyright 2015- ECMWF. |
---|
4 | |
---|
5 | ! This software is licensed under the terms of the Apache Licence Version 2.0 |
---|
6 | ! which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. |
---|
7 | |
---|
8 | ! In applying this licence, ECMWF does not waive the privileges and immunities |
---|
9 | ! granted to it by virtue of its status as an intergovernmental organisation |
---|
10 | ! nor does it submit to any jurisdiction. |
---|
11 | |
---|
12 | ! Author: Robin Hogan |
---|
13 | ! Email: r.j.hogan@ecmwf.int |
---|
14 | |
---|
15 | ! This file provides an interface to the provision of file units used |
---|
16 | ! for logging (nulout and nulerr) and for reading data files |
---|
17 | ! (nulrad), as well as an abort routine that should do clean-up |
---|
18 | ! appropriate for the environment in which the radiation scheme is |
---|
19 | ! embedded. |
---|
20 | |
---|
21 | ! Rewrite this file as appropriate if the radiation scheme is to be |
---|
22 | ! embedded into a model other than the ECMWF Integrated Forecasting |
---|
23 | ! System. |
---|
24 | |
---|
25 | module radiation_io |
---|
26 | |
---|
27 | ! In the IFS, nulout is equivalent to standard output but only |
---|
28 | ! output from the primary node will be logged, while nulerr is |
---|
29 | ! equivalent to standard error, and text sent to this unit from any |
---|
30 | ! node will be logged. Normally, nulerr should only be used before |
---|
31 | ! calling radiation_abort. |
---|
32 | use yomlun_ifsaux, only : nulout, nulerr |
---|
33 | |
---|
34 | implicit none |
---|
35 | public |
---|
36 | |
---|
37 | ! This unit may be used for reading radiation configuration files, |
---|
38 | ! but should be closed as soon as the file is read |
---|
39 | integer :: nulrad = 25 |
---|
40 | |
---|
41 | contains |
---|
42 | |
---|
43 | ! Abort the program with optional error message. Normally you would |
---|
44 | ! log details of the error to nulerr before calling this subroutine. |
---|
45 | subroutine radiation_abort(text) |
---|
46 | character(len=*), intent(in), optional :: text |
---|
47 | if (present(text)) then |
---|
48 | write(nulerr,'(a)') text |
---|
49 | #ifdef __PGI |
---|
50 | stop 1 |
---|
51 | #else |
---|
52 | error stop 1 |
---|
53 | #endif |
---|
54 | else |
---|
55 | #ifdef __PGI |
---|
56 | stop 'Error in radiation scheme' |
---|
57 | #else |
---|
58 | error stop 'Error in radiation scheme' |
---|
59 | #endif |
---|
60 | end if |
---|
61 | end subroutine radiation_abort |
---|
62 | |
---|
63 | end module radiation_io |
---|