-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlog_mod.F90
64 lines (43 loc) · 1.61 KB
/
log_mod.F90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
!-------------------------------------------------------------------------------
! Copyright (c) 2017, Met Office, on behalf of HMSO and Queen's Printer
! For further details please refer to the file LICENCE.original which you
! should have received as part of this distribution.
!-------------------------------------------------------------------------------
module log_mod
use constants_mod, only : str_long, str_max_filename
implicit none
integer, public, parameter :: LOG_LEVEL_ERROR = 200
integer, public, parameter :: LOG_LEVEL_WARNING = 150
integer, public, parameter :: LOG_LEVEL_INFO = 100
integer, public, parameter :: LOG_LEVEL_DEBUG = 50
integer, public, parameter :: LOG_LEVEL_TRACE = 0
character( str_long + str_max_filename ), public :: log_scratch_space
integer, private :: logging_level = LOG_LEVEL_INFO
integer, private :: funit
contains
subroutine init_log()
implicit none
funit=12
!open the file
open(unit=funit,file="bug_test.dat",status="unknown")
call log_set_level(LOG_LEVEL_INFO)
end subroutine init_log
subroutine log_set_level(level)
implicit none
integer, intent( in ) :: level
logging_level = level
end subroutine log_set_level
subroutine log_event(message, level)
implicit none
character (*), intent(in) :: message
integer, intent(in) :: level
write(funit,'(A)') trim(message)
if(level>=LOG_LEVEL_ERROR) then
stop
end if
end subroutine log_event
subroutine finalise_log()
implicit none
close(funit)
end subroutine finalise_log
end module log_mod