Subroutine waterbalance_timestep

251 : 
252 : !+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
253 : !+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
254 : !+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
255 : !*-----CALCULATION OF MAXIMAL TIME STEP SIZE----------------------------
256 : 
257 :       subroutine waterbalance_timestep ()
258 :       use vom_vegwat_mod
259 :       implicit none
260 : 
261 :       REAL*8  :: dtsu
262 :       INTEGER :: jj
263 : 
264 : !!$    INTEGER :: ii
265 : !!$    LOGICAL :: isnand, isinfd
266 : !!$
267 : !!$!*  for debugging in pgf90:
268 : !!$    do ii = 1, wlayer_
269 : !!$      if (isnand(dsu(ii))) then
270 : !!$        print *, "Its a NaN"
271 : !!$      elseif (isinfd(dsu(ii))) then
272 : !!$        print *, "Its a Inf"
273 : !!$      endif
274 : !!$    enddo
275 : 
276 :       dtsu = 999999.d0
277 :       do jj = 1, wlayer_
278 :         if (dsu(jj) .lt. 0.d0) then
279 :           dtsu = MIN(dtsu, -0.1d0 * su__(jj) / dsu(jj))
280 :         endif
281 :         if (dsu(jj) .gt. 0.d0) then
282 :           dtsu = MIN(dtsu, 0.1d0 * su__(jj) / dsu(jj),                 &
283 :      &               (1.d0 - su__(jj)) / dsu(jj))
284 :         endif
285 :       enddo
286 : 
287 : !     * LENGTH OF TIME STEP
288 : 
289 :       dt_ = MAX(0.d0, MIN(dtsu, dtmax))
290 : 
291 :       if (dt_ .eq. dtsu) then
292 :         dtsu_count = dtsu_count + 1
293 :       elseif (dt_ .eq. dtmax) then
294 :         dtmax_count = dtmax_count + 1
295 :       endif
296 : 
297 :       return
298 :       end subroutine waterbalance_timestep