MODULE dvrp_color USE dvrp_variables IMPLICIT NONE CONTAINS SUBROUTINE color_dvrp( value, color ) REAL, INTENT(IN) :: value REAL, INTENT(OUT) :: color(4) REAL :: scale scale = ( value - slicer_range_limits_dvrp(1,islice_dvrp) ) / & ( slicer_range_limits_dvrp(2,islice_dvrp) - & slicer_range_limits_dvrp(1,islice_dvrp) ) scale = MODULO( 180.0 + 180.0 * scale, 360.0 ) color = (/ scale, 0.5, 1.0, 0.0 /) END SUBROUTINE color_dvrp END MODULE dvrp_color RECURSIVE SUBROUTINE data_output_dvrp !------------------------------------------------------------------------------! ! Current revisions: ! ----------------- ! Clipping of dvr-output implemented, ! output of messages replaced by message handling routine. ! TEST: different colours for isosurfaces ! ! Former revisions: ! ----------------- ! $Id: data_output_dvrp.f90 262 2009-03-18 08:32:37Z heinze $ ! ! 210 2008-11-06 08:54:02Z raasch ! DVRP arguments changed to single precision, mode pathlines added ! ! 130 2007-11-13 14:08:40Z letzel ! allow two instead of one digit to specify isosurface and slicer variables ! for unknown variables (CASE DEFAULT) call new subroutine ! user_data_output_dvrp ! ! 82 2007-04-16 15:40:52Z raasch ! Preprocessor strings for different linux clusters changed to "lc", ! routine local_flush is used for buffer flushing ! ! 75 2007-03-22 09:54:05Z raasch ! Particles-package is now part of the default code, ! moisture renamed humidity ! ! RCS Log replace by Id keyword, revision history cleaned up ! ! Revision 1.13 2006/02/23 10:25:12 raasch ! Former routine plot_dvrp renamed data_output_dvrp, ! Only a fraction of the particles may have a tail, ! pl.. replaced by do.., %size renamed %dvrp_psize ! ! Revision 1.1 2000/04/27 06:27:17 raasch ! Initial revision ! ! ! Description: ! ------------ ! Plot of isosurface, particles and slicers with dvrp-software !------------------------------------------------------------------------------! #if defined( __dvrp_graphics ) USE arrays_3d USE cloud_parameters USE constants USE control_parameters USE cpulog USE DVRP USE dvrp_color USE dvrp_variables USE grid_variables USE indices USE interfaces USE particle_attributes USE pegrid IMPLICIT NONE CHARACTER (LEN=2) :: section_chr CHARACTER (LEN=6) :: output_variable INTEGER :: c_mode, c_size_x, c_size_y, c_size_z, dvrp_nop, dvrp_not, & gradient_normals, i, ip, j, jp, k, l, m, n, nn, section_mode, & tv, vn INTEGER, DIMENSION(:), ALLOCATABLE :: p_c, p_t LOGICAL, DIMENSION(:), ALLOCATABLE :: dvrp_mask REAL(4) :: center(3), distance, slicer_position, surface_value, & tmp_alpha, tmp_alpha_w, tmp_b, tmp_c_alpha, tmp_g, tmp_norm, & tmp_pos, tmp_r, tmp_t, tmp_th REAL(4), DIMENSION(:), ALLOCATABLE :: psize, p_x, p_y, p_z REAL(4), DIMENSION(:,:,:), ALLOCATABLE :: local_pf REAL(4), DIMENSION(:,:,:,:), ALLOCATABLE :: local_pfi CALL cpu_log( log_point(27), 'data_output_dvrp', 'start' ) ! !-- Loop over all output modes choosed m = 1 tv = 0 ! threshold counter islice_dvrp = 0 ! slice plane counter DO WHILE ( mode_dvrp(m) /= ' ' ) ! !-- Update of the steering variables IF ( .NOT. lock_steering_update ) THEN ! !-- Set lock to avoid recursive calls of DVRP_STEERING_UPDATE lock_steering_update = .TRUE. ! CALL DVRP_STEERING_UPDATE( m-1, data_output_dvrp ) lock_steering_update = .FALSE. ENDIF ! !-- Determine the variable which shall be plotted (in case of slicers or !-- isosurfaces) IF ( mode_dvrp(m)(1:10) == 'isosurface' ) THEN READ ( mode_dvrp(m), '(10X,I2)' ) vn output_variable = do3d(0,vn) tv = tv + 1 ELSEIF ( mode_dvrp(m)(1:6) == 'slicer' ) THEN READ ( mode_dvrp(m), '(6X,I2)' ) vn output_variable = do2d(0,vn) l = MAX( 2, LEN_TRIM( do2d(0,vn) ) ) section_chr = do2d(0,vn)(l-1:l) SELECT CASE ( section_chr ) CASE ( 'xy' ) section_mode = 2 slicer_position = zu(MIN( slicer_position_dvrp(m), nz_do3d )) CASE ( 'xz' ) section_mode = 1 slicer_position = slicer_position_dvrp(m) * dy CASE ( 'yz' ) section_mode = 0 slicer_position = slicer_position_dvrp(m) * dx END SELECT ENDIF ! !-- Select the plot mode (in case of isosurface or slicer only if user has !-- defined a variable which shall be plotted; otherwise do nothing) IF ( mode_dvrp(m)(1:9) == 'particles' .AND. particle_advection .AND. & simulated_time >= particle_advection_start ) THEN ! !-- DVRP-Calls for plotting particles: CALL cpu_log( log_point_s(28), 'dvrp_particles', 'start' ) ! !-- Definition of characteristics of particle material ! tmp_r = 0.1; tmp_g = 0.7; tmp_b = 0.1; tmp_t = 0.0 tmp_r = 0.0; tmp_g = 0.0; tmp_b = 0.0; tmp_t = 0.0 CALL DVRP_MATERIAL_RGB( m-1, 1, tmp_r, tmp_g, tmp_b, tmp_t ) ! !-- If clipping is active and if this subdomain is clipped, find out the !-- number of particles and tails to be plotted; otherwise, all !-- particles/tails are plotted. dvrp_mask is used to mark the partikles. ! IF ( .NOT. use_particle_tails ) THEN ALLOCATE( dvrp_mask(number_of_particles) ) ! ELSE ! ALLOCATE( dvrp_mask(number_of_tails*maximum_number_of_tailpoints) ) ! ENDIF dvrp_mask = .TRUE. IF ( dvrp_total_overlap ) THEN dvrp_nop = number_of_particles dvrp_not = number_of_tails ELSE dvrp_nop = 0 dvrp_not = 0 IF ( dvrp_overlap ) THEN IF ( .NOT. use_particle_tails ) THEN DO n = 1, number_of_particles ip = particles(n)%x / dx jp = particles(n)%y / dy IF ( ip >= nxl_dvrp .AND. ip <= nxr_dvrp .AND. & jp >= nys_dvrp .AND. jp <= nyn_dvrp ) THEN dvrp_nop = dvrp_nop + 1 ELSE dvrp_mask(n) = .FALSE. ENDIF ENDDO ELSE k = 0 DO n = 1, number_of_particles IF ( particles(n)%tail_id /= 0 ) THEN k = k + 1 ip = particles(n)%x / dx jp = particles(n)%y / dy IF ( ip >= nxl_dvrp .AND. ip <= nxr_dvrp .AND. & jp >= nys_dvrp .AND. jp <= nyn_dvrp ) THEN dvrp_not = dvrp_not + 1 ELSE dvrp_mask(n) = .FALSE. ENDIF ENDIF ENDDO ENDIF ENDIF ENDIF ! !-- Move particle coordinates to one-dimensional arrays IF ( .NOT. use_particle_tails ) THEN ! !-- All particles are output ALLOCATE( psize(dvrp_nop), p_t(dvrp_nop), p_c(dvrp_nop), & p_x(dvrp_nop), p_y(dvrp_nop), p_z(dvrp_nop) ) psize = 0.0; p_t = 0; p_c = 0.0; p_x = 0.0; p_y = 0.0 p_z = 0.0 k = 0 DO n = 1, number_of_particles IF ( dvrp_mask(n) ) THEN k = k + 1 psize(k) = particles(n)%dvrp_psize p_x(k) = particles(n)%x * superelevation_x p_y(k) = particles(n)%y * superelevation_y p_z(k) = particles(n)%z * superelevation p_c(k) = particles(n)%color ENDIF ENDDO ELSE ! !-- Particles have a tail ALLOCATE( psize(dvrp_not), p_t(dvrp_not), & p_c(dvrp_not*maximum_number_of_tailpoints), & p_x(dvrp_not*maximum_number_of_tailpoints), & p_y(dvrp_not*maximum_number_of_tailpoints), & p_z(dvrp_not*maximum_number_of_tailpoints) ) psize = 0.0; p_t = 0; p_c = 0.0; p_x = 0.0; p_y = 0.0 p_z = 0.0; i = 0 k = 0 DO n = 1, number_of_particles nn = particles(n)%tail_id IF ( nn /= 0 .AND. dvrp_mask(n) ) THEN k = k + 1 DO j = 1, particles(n)%tailpoints i = i + 1 p_x(i) = particle_tail_coordinates(j,1,nn) * & superelevation_x p_y(i) = particle_tail_coordinates(j,2,nn) * & superelevation_y p_z(i) = particle_tail_coordinates(j,3,nn) * & superelevation p_c(i) = particle_tail_coordinates(j,4,nn) ENDDO psize(k) = particles(n)%dvrp_psize p_t(k) = particles(n)%tailpoints - 1 ENDIF ENDDO ENDIF ! !-- Compute and plot particles in dvr-format IF ( uniform_particles .AND. .NOT. use_particle_tails ) THEN ! !-- All particles have the same color. Use simple routine to set !-- the particle attributes (produces less output data) CALL DVRP_PARTICLES( m-1, p_x, p_y, p_z, psize ) ELSE ! !-- Set color definitions CALL user_dvrp_coltab( 'particles', 'none' ) CALL DVRP_COLORTABLE_HLS( m-1, 0, interval_values_dvrp, & interval_h_dvrp, interval_l_dvrp, & interval_s_dvrp, interval_a_dvrp ) IF ( .NOT. use_particle_tails ) THEN CALL DVRP_PARTICLES( m-1, dvrp_nop, p_x, p_y, p_z, 3, psize, & p_c, p_t ) ELSE CALL DVRP_PARTICLES( m-1, dvrp_not, p_x, p_y, p_z, 15, psize, & p_c, p_t ) ENDIF ENDIF CALL DVRP_VISUALIZE( m-1, 3, dvrp_filecount ) DEALLOCATE( dvrp_mask, psize, p_c, p_t, p_x, p_y, p_z ) CALL cpu_log( log_point_s(28), 'dvrp_particles', 'stop' ) ELSEIF ( ( mode_dvrp(m)(1:10) == 'isosurface' .OR. & mode_dvrp(m)(1:6) == 'slicer' ) & .AND. output_variable /= ' ' ) THEN ! !-- Create an intermediate array, properly dimensioned for plot-output ALLOCATE( local_pf(nxl_dvrp:nxr_dvrp+1,nys_dvrp:nyn_dvrp+1, & nzb:nz_do3d) ) ! !-- Move original array to intermediate array IF ( dvrp_overlap ) THEN SELECT CASE ( output_variable ) CASE ( 'u', 'u_xy', 'u_xz', 'u_yz' ) DO i = nxl_dvrp, nxr_dvrp+1 DO j = nys_dvrp, nyn_dvrp+1 DO k = nzb, nz_do3d local_pf(i,j,k) = u(k,j,i) ENDDO ENDDO ENDDO ! !-- Replace mirrored values at lower surface by real surface !-- values IF ( output_variable == 'u_xz' .OR. & output_variable == 'u_yz' ) THEN IF ( ibc_uv_b == 0 ) local_pf(:,:,nzb) = 0.0 ENDIF CASE ( 'v', 'v_xy', 'v_xz', 'v_yz' ) DO i = nxl_dvrp, nxr_dvrp+1 DO j = nys_dvrp, nyn_dvrp+1 DO k = nzb, nz_do3d local_pf(i,j,k) = v(k,j,i) ENDDO ENDDO ENDDO ! !-- Replace mirrored values at lower surface by real surface !-- values IF ( output_variable == 'v_xz' .OR. & output_variable == 'v_yz' ) THEN IF ( ibc_uv_b == 0 ) local_pf(:,:,nzb) = 0.0 ENDIF CASE ( 'w', 'w_xy', 'w_xz', 'w_yz' ) DO i = nxl_dvrp, nxr_dvrp+1 DO j = nys_dvrp, nyn_dvrp+1 DO k = nzb, nz_do3d local_pf(i,j,k) = w(k,j,i) ENDDO ENDDO ENDDO ! Averaging for Langmuir circulation ! DO k = nzb, nz_do3d ! DO j = nys_dvrp+1, nyn_dvrp ! DO i = nxl_dvrp, nxr_dvrp+1 ! local_pf(i,j,k) = 0.25 * local_pf(i,j-1,k) + & ! 0.50 * local_pf(i,j,k) + & ! 0.25 * local_pf(i,j+1,k) ! ENDDO ! ENDDO ! ENDDO CASE ( 'p', 'p_xy', 'p_xz', 'p_yz' ) DO i = nxl_dvrp, nxr_dvrp+1 DO j = nys_dvrp, nyn_dvrp+1 DO k = nzb, nz_do3d local_pf(i,j,k) = p(k,j,i) ENDDO ENDDO ENDDO CASE ( 'pt', 'pt_xy', 'pt_xz', 'pt_yz' ) IF ( .NOT. cloud_physics ) THEN DO i = nxl_dvrp, nxr_dvrp+1 DO j = nys_dvrp, nyn_dvrp+1 DO k = nzb, nz_do3d local_pf(i,j,k) = pt(k,j,i) ENDDO ENDDO ENDDO ELSE DO i = nxl_dvrp, nxr_dvrp+1 DO j = nys_dvrp, nyn_dvrp+1 DO k = nzb, nz_do3d local_pf(i,j,k) = pt(k,j,i) + l_d_cp * & pt_d_t(k) * ql(k,j,i) ENDDO ENDDO ENDDO ENDIF CASE ( 'q', 'q_xy', 'q_xz', 'q_yz' ) IF ( humidity .OR. passive_scalar ) THEN DO i = nxl_dvrp, nxr_dvrp+1 DO j = nys_dvrp, nyn_dvrp+1 DO k = nzb, nz_do3d local_pf(i,j,k) = q(k,j,i) ENDDO ENDDO ENDDO ELSE message_string = 'if humidity/passive_scalar = ' // & 'FALSE output of ' // TRIM( output_variable ) // & 'is not provided' CALL message( 'data_output_dvrp', 'PA0183', 0, 0, 0, 6, 0 ) ENDIF CASE ( 'ql', 'ql_xy', 'ql_xz', 'ql_yz' ) IF ( cloud_physics .OR. cloud_droplets ) THEN DO i = nxl_dvrp, nxr_dvrp+1 DO j = nys_dvrp, nyn_dvrp+1 DO k = nzb, nz_do3d local_pf(i,j,k) = ql(k,j,i) ENDDO ENDDO ENDDO ELSE message_string = 'if cloud_physics = FALSE ' // & 'output of ' // TRIM( output_variable) // & 'is not provided' CALL message( 'data_output_dvrp', 'PA0184', 0, 0, 0, 6, 0 ) ENDIF CASE ( 'u*_xy' ) DO i = nxl_dvrp, nxr_dvrp+1 DO j = nys_dvrp, nyn_dvrp+1 local_pf(i,j,nzb+1) = us(j,i) ENDDO ENDDO slicer_position = zu(nzb+1) CASE ( 't*_xy' ) DO i = nxl_dvrp, nxr_dvrp+1 DO j = nys_dvrp, nyn_dvrp+1 local_pf(i,j,nzb+1) = ts(j,i) ENDDO ENDDO slicer_position = zu(nzb+1) CASE DEFAULT ! !-- The DEFAULT case is reached either if output_variable !-- contains unsupported variable or if the user has coded a !-- special case in the user interface. There, the subroutine !-- user_data_output_dvrp checks which of these two conditions !-- applies. CALL user_data_output_dvrp( output_variable, local_pf ) END SELECT ENDIF IF ( mode_dvrp(m)(1:10) == 'isosurface' ) THEN ! !-- DVRP-Calls for plotting isosurfaces: CALL cpu_log( log_point_s(26), 'dvrp_isosurface', 'start' ) ! !-- Definition of characteristics of isosurface material !-- Preliminary settings for w and pt! IF ( output_variable == 'w' ) THEN IF ( tv == 1 ) THEN tmp_r = 0.8; tmp_g = 0.1; tmp_b = 0.1; tmp_t = 0.0 CALL DVRP_MATERIAL_RGB( m-1, 1, tmp_r, tmp_g, tmp_b, tmp_t ) ELSE tmp_r = 0.1; tmp_g = 0.1; tmp_b = 0.8; tmp_t = 0.0 CALL DVRP_MATERIAL_RGB( m-1, 1, tmp_r, tmp_g, tmp_b, tmp_t ) ENDIF ELSEIF ( output_variable == 'pt' ) THEN tmp_r = 0.8; tmp_g = 0.1; tmp_b = 0.1; tmp_t = 0.0 CALL DVRP_MATERIAL_RGB( m-1, 1, tmp_r, tmp_g, tmp_b, tmp_t ) ELSE tmp_r = 0.9; tmp_g = 0.9; tmp_b = 0.9; tmp_t = 0.0 CALL DVRP_MATERIAL_RGB( m-1, 1, tmp_r, tmp_g, tmp_b, tmp_t ) ENDIF ! !-- Compute and plot isosurface in dvr-format CALL DVRP_DATA( m-1, local_pf, 1, nx_dvrp, ny_dvrp, nz_dvrp, & cyclic_dvrp, cyclic_dvrp, cyclic_dvrp ) c_size_x = vc_size_x; c_size_y = vc_size_y; c_size_z = vc_size_z CALL DVRP_CLUSTER_SIZE( m-1, c_size_x, c_size_y, c_size_z ) c_mode = vc_mode CALL DVRP_CLUSTERING_MODE( m-1, c_mode ) gradient_normals = vc_gradient_normals CALL DVRP_GRADIENTNORMALS( m-1, gradient_normals ) ! !-- A seperate procedure for setting vc_alpha will be in the next !-- version of libDVRP tmp_c_alpha = vc_alpha CALL DVRP_THRESHOLD( -(m-1)-1, tmp_c_alpha ) IF ( dvrp_overlap ) THEN tmp_th = threshold(tv) ELSE tmp_th = 1.0 ! nothing is plotted because array values are 0 ENDIF CALL DVRP_THRESHOLD( m-1, tmp_th ) CALL DVRP_VISUALIZE( m-1, 21, dvrp_filecount ) CALL cpu_log( log_point_s(26), 'dvrp_isosurface', 'stop' ) ELSEIF ( mode_dvrp(m)(1:6) == 'slicer' ) THEN ! !-- DVRP-Calls for plotting slicers: CALL cpu_log( log_point_s(27), 'dvrp_slicer', 'start' ) ! !-- Material and color definitions tmp_r = 0.0; tmp_g = 0.0; tmp_b = 0.0; tmp_t = 0.0 CALL DVRP_MATERIAL_RGB( m-1, 1, tmp_r, tmp_g, tmp_b, tmp_t ) islice_dvrp = islice_dvrp + 1 ! CALL DVRP_COLORFUNCTION( m-1, DVRP_CM_HLS, 25, & ! slicer_range_limits_dvrp(:,islice_dvrp), & ! color_dvrp ) CALL user_dvrp_coltab( 'slicer', output_variable ) CALL DVRP_COLORTABLE_HLS( m-1, 1, interval_values_dvrp, & interval_h_dvrp, interval_l_dvrp, & interval_s_dvrp, interval_a_dvrp ) ! !-- Compute and plot slicer in dvr-format CALL DVRP_DATA( m-1, local_pf, 1, nx_dvrp, ny_dvrp, nz_dvrp, & cyclic_dvrp, cyclic_dvrp, cyclic_dvrp ) tmp_pos = slicer_position CALL DVRP_SLICER( m-1, section_mode, tmp_pos ) ! tmp_pos = 1.0 ! CALL DVRP_SLICER( m-1, 2, tmp_pos ) WRITE (9,*) 'nx_dvrp=', nx_dvrp WRITE (9,*) 'ny_dvrp=', ny_dvrp WRITE (9,*) 'nz_dvrp=', nz_dvrp WRITE (9,*) 'section_mode=', section_mode WRITE (9,*) 'slicer_position=', slicer_position CALL local_flush( 9 ) CALL DVRP_VISUALIZE( m-1, 2, dvrp_filecount ) CALL cpu_log( log_point_s(27), 'dvrp_slicer', 'stop' ) ENDIF DEALLOCATE( local_pf ) ELSEIF ( mode_dvrp(m)(1:9) == 'pathlines' ) THEN ALLOCATE( local_pfi(4,nxl:nxr+1,nys:nyn+1,nzb:nz_do3d) ) DO i = nxl, nxr+1 DO j = nys, nyn+1 DO k = nzb, nz_do3d local_pfi(1,i,j,k) = u(k,j,i) local_pfi(2,i,j,k) = v(k,j,i) local_pfi(3,i,j,k) = w(k,j,i) tmp_norm = SQRT( u(k,j,i) * u(k,j,i) + & v(k,j,i) * v(k,j,i) + & w(k,j,i) * w(k,j,i) ) tmp_alpha = ACOS( 0.0 * u(k,j,i) / tmp_norm + & 0.0 * v(k,j,i) / tmp_norm - & 1.0 * w(k,j,i) / tmp_norm ) tmp_alpha_w = tmp_alpha / pi * 180.0 local_pfi(4,i,j,k) = tmp_alpha_w ENDDO ENDDO ENDDO CALL cpu_log( log_point_s(31), 'dvrp_pathlines', 'start' ) CALL DVRP_DATA( m-1, local_pfi, 4, nx_dvrp, ny_dvrp, nz_dvrp, & cyclic_dvrp, cyclic_dvrp, cyclic_dvrp ) CALL DVRP_VISUALIZE( m-1, 20, dvrp_filecount ) CALL cpu_log( log_point_s(31), 'dvrp_pathlines', 'stop' ) DEALLOCATE( local_pfi ) ENDIF m = m + 1 ENDDO dvrp_filecount = dvrp_filecount + 1 CALL cpu_log( log_point(27), 'data_output_dvrp', 'stop' ) #endif END SUBROUTINE data_output_dvrp