415 integer,
intent(in) :: y_flow_index, x_flow_index, y_scalar_index, x_scalar_index, kdof
416 real(kind=DEFAULT_PRECISION),
intent(in) :: dt
417 type(grid_configuration_type),
intent(inout) :: grid_config
418 type(prognostic_field_type),
intent(inout) :: u, w, v, zf
419 type(local_grid_type),
intent(inout) :: local_grid
420 real(kind=DEFAULT_PRECISION),
intent(in),
dimension(:) :: rdz, rdzn, dzn
421 real(kind=DEFAULT_PRECISION),
intent(inout),
dimension(:) :: flux_z
425 real(kind=DEFAULT_PRECISION) :: fgt1, fgt2,& !< Gradient terms
426 fc,& !< Upwinded nodal points in z
427 fcurvs,& !< Curvature of F
428 fd,& !< Downwind nodal points in z
429 fdels,& !< Downwind-upwind difference of F
430 fu,& !< Upwind nodal point
431 rdc,& !< Central 1/grid size
432 rdu,& !< Upwinded 1/grid size
435 k=local_grid%size(z_index)-1
437 if(w%data(k, y_flow_index, x_flow_index) .ge. 0.0_default_precision)
then 438 fu = zf%data(k-1, y_scalar_index, x_scalar_index)
439 fc = zf%data(k, y_scalar_index, x_scalar_index)
440 fd = zf%data(k+1, y_scalar_index, x_scalar_index)
443 fu = 2.0_default_precision*zf%data(k+1, y_scalar_index, x_scalar_index) - zf%data(k, y_scalar_index, x_scalar_index)
444 fc = zf%data(k+1, y_scalar_index, x_scalar_index)
445 fd = zf%data(k, y_scalar_index, x_scalar_index)
447 fcurvs = fd - 2.0_default_precision*fc + fu
449 if(abs(fcurvs) .ge. abs(fdels))
then 452 if(w%data(k, y_flow_index, x_flow_index) .ge. 0.0_default_precision)
then 453 sum_cfl_out=0.0_default_precision
455 sum_cfl_out = sum_cfl_out + rdz(k+kdof)*(w%data(k, y_flow_index, x_flow_index)&
456 +abs(min(0.0_default_precision,w%data(k-1, y_flow_index, x_flow_index))))
459 sum_cfl_out = sum_cfl_out + grid_config%horizontal%cy*(max(0.0_default_precision,v%data(k, y_flow_index, x_flow_index))+&
460 abs(min(0.0_default_precision,v%data(k, y_flow_index-1, x_flow_index))))
463 sum_cfl_out = sum_cfl_out + grid_config%horizontal%cx*(max(0.0_default_precision,u%data(k, y_flow_index, x_flow_index))&
464 +abs(min(0.0_default_precision,u%data(k, y_flow_index, x_flow_index-1))))
466 sum_cfl_out = sum_cfl_out * dt
469 fgt1=0.0_default_precision
471 fgt1=calculate_gradient_term_in_y(k, v, y_flow_index, x_flow_index, grid_config%horizontal%cy, dt, fc, &
472 zf, y_scalar_index, x_scalar_index)
475 fgt2=0.0_default_precision
477 fgt2=calculate_gradient_term_in_x(k, u%data(:, y_flow_index, x_flow_index-1), u%data(:, y_flow_index, &
478 x_flow_index), u%data(:, y_flow_index, x_flow_index-1), u%data(:, y_flow_index, &
479 x_flow_index), grid_config%horizontal%cx, dt, fc, zf%data(k, y_scalar_index, x_scalar_index+1), &
480 zf%data(k, y_scalar_index, x_scalar_index-1), 1)
485 sum_cfl_out=0.0_default_precision
487 sum_cfl_out = sum_cfl_out + (- w%data(k, y_flow_index, x_flow_index)&
488 *rdz(min(local_grid%size(z_index),k+1+kdof)))
491 sum_cfl_out = sum_cfl_out + grid_config%horizontal%cy*(max(0.0_default_precision,&
492 v%data(k+1, y_flow_index, x_flow_index))+&
493 abs(min(0.0_default_precision,v%data(k+1, y_flow_index-1, x_flow_index))))
496 sum_cfl_out = sum_cfl_out + grid_config%horizontal%cx*(max(0.0_default_precision,&
497 u%data(k+1, y_flow_index, x_flow_index))&
498 +abs(min(0.0_default_precision,u%data(k+1, y_flow_index, x_flow_index-1))))
500 sum_cfl_out = sum_cfl_out * dt
503 fgt1=0.0_default_precision
505 fgt1=calculate_gradient_term_in_y(k, v, y_flow_index, x_flow_index, grid_config%horizontal%cy, &
506 dt, fc, zf, y_scalar_index, x_scalar_index, 1)
509 fgt2=0.0_default_precision
511 fgt2=calculate_gradient_term_in_x(k, u%data(:, y_flow_index, x_flow_index-1), u%data(:, y_flow_index, &
512 x_flow_index), u%data(:, y_flow_index, x_flow_index-1), u%data(:, y_flow_index, &
513 x_flow_index), grid_config%horizontal%cx, dt, fc, zf%data(k+1, y_scalar_index, x_scalar_index+1), &
514 zf%data(k+1, y_scalar_index, x_scalar_index-1), 1)
516 rdu=rdzn(local_grid%size(z_index))
517 rdc=rdz(min(local_grid%size(z_index),k+1+kdof))
520 flux_z(k+1) = calculate_flux_in_w(k, w%data(k, y_flow_index, x_flow_index), &
521 dt, sum_cfl_out, rdc, fdels, fd, fc, fu, rdu, fgt1, fgt2, dzn, rdzn)