SUBROUTINE swap_timelevel !------------------------------------------------------------------------------! ! Actual revisions: ! ----------------- ! moisture renamed humidity ! ! Former revisions: ! ----------------- ! $Id: swap_timelevel.f90 75 2007-03-22 09:54:05Z raasch $ ! ! 19 2007-02-23 04:53:48Z raasch ! Swaping of top fluxes ! ! RCS Log replace by Id keyword, revision history cleaned up ! ! Revision 1.8 2004/01/28 15:28:18 raasch ! Swaping for Runge-Kutta schemes implemented ! ! Revision 1.1 2000/01/10 10:08:58 10:08:58 raasch (Siegfried Raasch) ! Initial revision ! ! ! Description: ! ------------ ! Swap of timelevels of variables after each timestep !------------------------------------------------------------------------------! USE arrays_3d USE cpulog USE interfaces USE control_parameters IMPLICIT NONE CALL cpu_log( log_point(28), 'swap_timelevel', 'start' ) ! !-- Incrementing timestep counter timestep_count = timestep_count + 1 ! !-- Swap of 3-level variables IF ( timestep_scheme(1:5) /= 'runge' ) THEN SELECT CASE ( MOD( timestep_count, 3 ) ) CASE ( 0 ) u_m => u_1; u => u_2; u_p => u_3 v_m => v_1; v => v_2; v_p => v_3 w_m => w_1; w => w_2; w_p => w_3 pt_m => pt_1; pt => pt_2; pt_p => pt_3 IF ( .NOT. constant_diffusion ) THEN e_m => e_1; e => e_2; e_p => e_3 ENDIF IF ( humidity .OR. passive_scalar ) THEN q_m => q_1; q => q_2; q_p => q_3 ENDIF CASE ( 1 ) u_m => u_2; u => u_3; u_p => u_1 v_m => v_2; v => v_3; v_p => v_1 w_m => w_2; w => w_3; w_p => w_1 pt_m => pt_2; pt => pt_3; pt_p => pt_1 IF ( .NOT. constant_diffusion ) THEN e_m => e_2; e => e_3; e_p => e_1 ENDIF IF ( humidity .OR. passive_scalar ) THEN q_m => q_2; q => q_3; q_p => q_1 ENDIF CASE ( 2 ) u_m => u_3; u => u_1; u_p => u_2 v_m => v_3; v => v_1; v_p => v_2 w_m => w_3; w => w_1; w_p => w_2 pt_m => pt_3; pt => pt_1; pt_p => pt_2 IF ( .NOT. constant_diffusion ) THEN e_m => e_3; e => e_1; e_p => e_2 ENDIF IF ( humidity .OR. passive_scalar ) THEN q_m => q_3; q => q_1; q_p => q_2 ENDIF END SELECT ENDIF ! !-- Swap of 2-level variables SELECT CASE ( MOD( timestep_count, 2 ) ) CASE ( 0 ) IF ( timestep_scheme(1:5) == 'runge' ) THEN u => u_1; u_p => u_2 v => v_1; v_p => v_2 w => w_1; w_p => w_2 pt => pt_1; pt_p => pt_2 IF ( .NOT. constant_diffusion ) THEN e => e_1; e_p => e_2 ENDIF IF ( humidity .OR. passive_scalar ) THEN q => q_1; q_p => q_2 ENDIF ELSE ! !-- Old timelevels are needed for explicit diffusion within leapfrog IF ( .NOT. constant_diffusion ) THEN kh_m => kh_1; kh => kh_2 km_m => km_1; km => km_2 IF ( use_surface_fluxes ) THEN usws_m => usws_1; usws => usws_2 vsws_m => vsws_1; vsws => vsws_2 shf_m => shf_1; shf => shf_2 IF ( humidity .OR. passive_scalar ) THEN qsws_m => qsws_1; qsws => qsws_2 ENDIF ENDIF IF ( prandtl_layer ) THEN rif_m => rif_1; rif => rif_2 ENDIF IF ( use_top_fluxes ) THEN tswst_m => tswst_1; tswst => tswst_2 IF ( humidity .OR. passive_scalar ) THEN qswst_m => qswst_1; qswst => qswst_2 ENDIF ENDIF ENDIF IF ( humidity ) THEN vpt_m => vpt_1; vpt => vpt_2 ENDIF ENDIF CASE ( 1 ) IF ( timestep_scheme(1:5) == 'runge' ) THEN u => u_2; u_p => u_1 v => v_2; v_p => v_1 w => w_2; w_p => w_1 pt => pt_2; pt_p => pt_1 IF ( .NOT. constant_diffusion ) THEN e => e_2; e_p => e_1 ENDIF IF ( humidity .OR. passive_scalar ) THEN q => q_2; q_p => q_1 ENDIF ELSE IF ( .NOT. constant_diffusion ) THEN kh_m => kh_2; kh => kh_1 km_m => km_2; km => km_1 IF ( use_surface_fluxes ) THEN usws_m => usws_2; usws => usws_1 vsws_m => vsws_2; vsws => vsws_1 shf_m => shf_2; shf => shf_1 IF ( humidity .OR. passive_scalar ) THEN qsws_m => qsws_2; qsws => qsws_1 ENDIF ENDIF IF ( prandtl_layer ) THEN rif_m => rif_2; rif => rif_1 ENDIF IF ( use_top_fluxes ) THEN tswst_m => tswst_2; tswst => tswst_1 IF ( humidity .OR. passive_scalar ) THEN qswst_m => qswst_2; qswst => qswst_1 ENDIF ENDIF ENDIF IF ( humidity ) THEN vpt_m => vpt_2; vpt => vpt_1 ENDIF ENDIF END SELECT CALL cpu_log( log_point(28), 'swap_timelevel', 'stop' ) END SUBROUTINE swap_timelevel