-
Notifications
You must be signed in to change notification settings - Fork 69
Expand file tree
/
Copy pathgen_events.F90
More file actions
124 lines (108 loc) · 3.61 KB
/
gen_events.F90
File metadata and controls
124 lines (108 loc) · 3.61 KB
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
!
!--------------------------------------------------------------------------------------------
!
subroutine annual_event(do_output, N)
!decides whether it's time to do output
use g_clock
implicit none
logical, intent(inout) :: do_output
integer, intent(in) :: N
integer :: elapsed_years
logical, save :: debug_printed = .false.
elapsed_years = yearnew - yearstart + 1
if (mod(elapsed_years, N)==0 .and. (daynew == ndpyr) .and. (timenew==86400.)) then
do_output=.true.
! Debug output when restart event triggers
write(*,'(A,I5,A,I5,A,I4,A,I4,A,L1)') &
' annual_event TRIGGERED: yearstart=', yearstart, ' yearnew=', yearnew, &
' elapsed=', elapsed_years, ' N=', N, ' do_output=', do_output
else
do_output=.false.
! Debug: print once per year at end of year to show why event didn't trigger
if ((daynew == ndpyr) .and. (timenew==86400.) .and. .not. debug_printed) then
write(*,'(A,I5,A,I5,A,I4,A,I4,A,I4,A,L1)') &
' annual_event NOT triggered: yearstart=', yearstart, ' yearnew=', yearnew, &
' elapsed=', elapsed_years, ' mod=', mod(elapsed_years,N), ' N=', N, ' do_output=', do_output
debug_printed = .true.
endif
if (daynew == 1) debug_printed = .false. ! Reset at start of new year
endif
end subroutine annual_event
!
!--------------------------------------------------------------------------------------------
!
subroutine monthly_event(do_output, N)
!decides whether it's time to do output
use g_clock
implicit none
logical, intent(inout) :: do_output
integer, intent(in) :: N
if (mod(month, N)==0 .and. day_in_month==num_day_in_month(fleapyear,month) .and. timenew==86400.) then
do_output=.true.
else
do_output=.false.
end if
end subroutine monthly_event
!
!--------------------------------------------------------------------------------------------
!
subroutine daily_event(do_output, N)
!decides whether it's time to do output
use g_clock
implicit none
logical, intent(inout) :: do_output
integer, intent(in) :: N
if (mod(daynew, N)==0 .and. timenew==86400.) then
do_output=.true.
else
do_output=.false.
endif
end subroutine daily_event
!
!--------------------------------------------------------------------------------------------
!
subroutine hourly_event(do_output, N)
!decides whether it's time to do output
use g_clock
implicit none
logical, intent(inout) :: do_output
integer, intent(in) :: N
if (mod(timenew, 3600.*N)==0) then
do_output=.true.
else
do_output=.false.
endif
end subroutine hourly_event
!
!--------------------------------------------------------------------------------------------
!
subroutine step_event(do_output,istep, N)
!decides whether it's time to do output
use g_config
implicit none
logical, intent(inout) :: do_output
integer :: istep
integer, intent(in) :: N
if (mod(istep, N)==0) then
do_output=.true.
else
do_output=.false.
endif
end subroutine step_event
!
!--------------------------------------------------------------------------------------------
!
subroutine handle_err(errcode, partit)
USE MOD_PARTIT
USE MOD_PARSUP
implicit none
#include "netcdf.inc"
type(t_partit), intent(inout) :: partit
integer :: errcode
write(*,*) 'Error: ', nf_strerror(errcode)
call par_ex(partit%MPI_COMM_FESOM, partit%mype, 1)
stop
end subroutine handle_err
!
!--------------------------------------------------------------------------------------------
!