42
52 use mpi
53 implicit none
54 real, intent(in), optional:: time
55
56
57
58
59
60
61
62
63
64 type(GT_HISTORY), intent(inout), optional, target:: history
65
66
67
68
69
70
71
72 type(DC_DIFFTIME), intent(in), optional:: difftime
73
74
75
76
77
78
79
80
81
82 real(DP), intent(in), optional:: timed
83
84
85
86
87
88
89
90
91
92 type(GT_HISTORY), pointer:: hst =>null()
93 type(GT_VARIABLE):: var
94 real, pointer:: buffer(:) =>null()
95 real(DP):: dt
96
97 real(DP):: timew
98 logical:: err, dbg_mode
99 integer:: err_mpi
100 character(*), parameter:: subname = "HistorySetTime"
101 continue
102 dt = 0.0_dp
103 timew = 0.0_dp
105 if (present(history)) then
106 hst => history
107 else
109 endif
110 call debug( dbg_mode )
111 if ( dbg_mode ) then
112 if ( present(difftime) ) then
113 timew =
evalbyunit( difftime,
'', hst % unlimited_units_symbol )
115 elseif ( present(timed) ) then
117 elseif ( present(time) ) then
119 end if
120 end if
121 if (hst % unlimited_index == 0) then
122 goto 999
123 endif
124 var = hst % dimvars(hst % unlimited_index)
125 hst % dim_value_written(hst % unlimited_index) = .true.
126 if ( present(difftime) ) then
127 dt =
evalbyunit( difftime,
'', hst % unlimited_units_symbol )
128 timew = dt
129 elseif ( present(timed) ) then
130 dt = timed
131
132
133 timew = timed
134 elseif ( present(time) ) then
135 dt = time
136
137
138 timew = time
139 end if
140 if ( dt < hst % oldest &
141 & .or. dt > hst % newest &
142 & .or. hst % count(2) == 0 ) then
143 hst % count(:) = maxval(hst % count(:)) + 1
144 hst % newest =
max(hst % newest, dt)
145 hst % oldest =
min(hst % oldest, dt)
146 if ( .not. hst % mpi_gather &
147 & .or. ( hst % mpi_gather .and. hst % mpi_myrank == 0 ) ) then
148 call slice(var, 1, start=hst % count(1), count=1)
149 timew = dt
150
151 call put(var, (/timew/), 1, err)
152 if (err) call dumperror()
153 end if
154 goto 999
155 endif
156 if ( .not. hst % mpi_gather &
157 & .or. ( hst % mpi_gather .and. hst % mpi_myrank == 0 ) ) then
158 call slice(var, 1, start=1, count=hst % count(2))
159 call get(var, buffer, err)
160 hst % count(1:1) = minloc(abs(buffer - timew))
161 deallocate(buffer)
162 if ( hst % mpi_gather .and. hst % mpi_myrank == 0 ) then
163 call mpi_bcast( hst % count(1:1), 1, mpi_integer, 0, mpi_comm_world, err_mpi )
164 end if
165 elseif ( hst % mpi_gather .and. hst % mpi_myrank /= 0 ) then
166 call mpi_bcast( hst % count(1:1), 1, mpi_integer, 0, mpi_comm_world, err_mpi )
167 end if
168999 continue
Interface declarations for procedures provided from dc_date.
Derived types and parameters for date and time.
subroutine, public dbgmessage(fmt, i, r, d, l, n, c1, c2, c3, ca)
subroutine, public beginsub(name, fmt, i, r, d, l, n, c1, c2, c3, ca, version)
subroutine, public endsub(name, fmt, i, r, d, l, n, c1, c2, c3, ca)
Provides kind type parameter values.
integer, parameter, public dp
Double Precision Real number
type(gt_history), target, save, public default