-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLIME.f
85 lines (65 loc) · 2.15 KB
/
LIME.f
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
! KDM [email protected]
! Helper routines
module lime
implicit none
contains
subroutine dbgcsv(msg,val,i,j,root)
! Print "msg,val" statements with ISO8601 date string
! Example usage:
! In rundeck:
! use LIME
! call dbgcsv(msg="float value", val=42.0)
! call dbgcsv(val=42 * 1.0, msg="convert int to float")
! call dbgcsv(msg="IJ supported", val=v i=II, j=JJ)
! call dbgcsv(msg="limited MPI support", val=v, root=.true.)
!
! Off by default. To turn on
! #define dbgcsv ! rundeck
! EXTRA_FFLAGS="-Ddbgcsv" ! make setup
use model_com, only: modelEclock
use BaseTime_mod, only: BaseTime
use Rational_mod, only : Real
Use Domain_decomp_atm, only: AM_I_ROOT
implicit none
character(len=*), intent(in) :: msg
real*8, optional, intent(in) :: val
integer, optional, intent(in) :: i,j
logical, optional, intent(in) :: root
character(len=127) :: tmp_str
character(len=127) :: out_str
integer :: y, m, d, h, mm, s
real*8 rs ! seconds
type (BaseTime) :: t ! time
#ifndef dbgscv
return
#endif
y = modelEclock%getYear()
m = modelEclock%getMonth()
d = modelEclock%getDate()
t = modelEclock%getTimeInSecondsFromDate(y,m,d,0)
rs = Real(t)
h = int(int(rs)/3600)
mm = int((int(rs)-h*3600)/60)
s = int(rs)-(h*3600)-(mm*60)
! iso8601
write(tmp_str,
* '(I0.4,"-",I0.2,"-",I0.2,"T",I0.2,":",I0.2,":",I0.2)')
* y,m,d,h,mm,s
out_str = tmp_str
if (present(i).and.present(j)) then
write(tmp_str, '("i,", I0.3, ",j,", I0.3)') i,j
out_str = trim(out_str)//","//tmp_str
end if
out_str = trim(out_str)//","//msg
write(tmp_str, '(F0.5)') val
out_str = trim(out_str)//","//tmp_str
out_str = "DBGCSV,"//trim(out_str)
out_str = trim(out_str)
if ((present(root) .and. root) .or. am_i_root()) then
print '(a)', trim(out_str)
else
out_str = trim(out_str)//",not-root"
print '(a)', trim(out_str)
endif
end subroutine dbgcsv
end module lime