SUBROUTINE read_3d_binary !------------------------------------------------------------------------------! ! Current revisions: ! ----------------- ! ! ! Former revisions: ! ----------------- ! $Id: read_3d_binary.f90 449 2010-02-02 11:23:59Z maronga $ ! ! 410 2009-12-04 17:05:40Z letzel ! format changed in test output from I2 to I4 ! ! 367 2009-08-25 08:35:52Z maronga ! Output of messages replaced by message handling routine. ! +shf_av, qsws_av ! ! 220 2008-12-18 07:00:36Z raasch ! reading mechanism completely revised (subdomain/total domain size can vary ! arbitrarily between current and previous run) ! Bugfix: reading of spectrum_x|y from restart files ignored if total numbers ! of grid points do not match ! ! 150 2008-02-29 08:19:58Z raasch ! Files from which restart data are to be read are determined and subsequently ! opened. The total domain on the restart file is allowed to be smaller than ! the current total domain. In this case it will be periodically mapped on the ! current domain (needed for recycling method). ! +call of user_read_restart_data, -dopr_time_count, ! hom_sum, volume_flow_area, volume_flow_initial moved to read_var_list, ! reading of old profil parameters (cross_..., dopr_crossindex, profile_***) ! removed, initialization of spectrum_x|y removed ! ! 102 2007-07-27 09:09:17Z raasch ! +uswst, uswst_m, vswst, vswst_m ! ! 96 2007-06-04 08:07:41Z raasch ! +rho_av, sa, sa_av, saswsb, saswst ! ! 73 2007-03-20 08:33:14Z raasch ! +precipitation_amount, precipitation_rate_av, rif_wall, u_m_l, u_m_r, etc., ! z0_av ! ! 19 2007-02-23 04:53:48Z raasch ! +qswst, qswst_m, tswst, tswst_m ! ! RCS Log replace by Id keyword, revision history cleaned up ! ! Revision 1.4 2006/08/04 15:02:32 raasch ! +iran, iran_part ! ! Revision 1.1 2004/04/30 12:47:27 raasch ! Initial revision ! ! ! Description: ! ------------ ! Binary input of variables and arrays from restart file !------------------------------------------------------------------------------! USE arrays_3d USE averaging USE cloud_parameters USE control_parameters USE cpulog USE indices USE interfaces USE particle_attributes USE pegrid USE profil_parameter USE random_function_mod USE statistics IMPLICIT NONE CHARACTER (LEN=5) :: myid_char_save CHARACTER (LEN=10) :: binary_version, version_on_file CHARACTER (LEN=20) :: field_chr INTEGER :: files_to_be_opened, i, j, k, myid_on_file, & numprocs_on_file, nxlc, nxlf, nxlpr, nxl_on_file, nxrc, nxrf, & nxrpr, nxr_on_file, nync, nynf, nynpr, nyn_on_file, nysc, & nysf, nyspr, nys_on_file, nzb_on_file, nzt_on_file, offset_x, & offset_y, shift_x, shift_y INTEGER, DIMENSION(numprocs_previous_run) :: file_list, overlap_count INTEGER, DIMENSION(numprocs_previous_run,1000) :: nxlfa, nxrfa, nynfa, & nysfa, offset_xa, & offset_ya REAL :: rdummy REAL, DIMENSION(:,:), ALLOCATABLE :: tmp_2d REAL, DIMENSION(:,:,:), ALLOCATABLE :: tmp_3d, tmp_3dwul, tmp_3dwun, & tmp_3dwur, tmp_3dwus, tmp_3dwvl, & tmp_3dwvn, tmp_3dwvr, tmp_3dwvs, & tmp_3dwwl, tmp_3dwwn, tmp_3dwwr, & tmp_3dwws REAL, DIMENSION(:,:,:,:), ALLOCATABLE :: tmp_4d ! !-- Read data from previous model run. CALL cpu_log( log_point_s(14), 'read_3d_binary', 'start' ) ! !-- Check which of the restart files contain data needed for the subdomain !-- of this PE files_to_be_opened = 0 DO i = 1, numprocs_previous_run ! !-- Store array bounds of the previous run ("pr") in temporary scalars nxlpr = hor_index_bounds_previous_run(1,i-1) nxrpr = hor_index_bounds_previous_run(2,i-1) nyspr = hor_index_bounds_previous_run(3,i-1) nynpr = hor_index_bounds_previous_run(4,i-1) ! !-- Determine the offsets. They may be non-zero in case that the total domain !-- on file is smaller than the current total domain. offset_x = ( nxl / ( nx_on_file + 1 ) ) * ( nx_on_file + 1 ) offset_y = ( nys / ( ny_on_file + 1 ) ) * ( ny_on_file + 1 ) ! !-- Start with this offset and then check, if the subdomain on file !-- matches another time(s) in the current subdomain by shifting it !-- for nx_on_file+1, ny_on_file+1 respectively shift_y = 0 j = 0 ! counter for the number of files to be opened DO WHILE ( nyspr+shift_y <= nyn-offset_y .AND. & nynpr+shift_y >= nys-offset_y ) shift_x = 0 DO WHILE ( nxlpr+shift_x <= nxr-offset_x .AND. & nxrpr+shift_x >= nxl-offset_x ) j = j +1 IF ( j > 1000 ) THEN ! !-- Array bound exceeded message_string = 'data from subdomain of previous' // & ' run mapped more than 1000 times' CALL message( 'read_3d_binary', 'PA0284', 2, 2, -1, 6, 1 ) ENDIF IF ( j == 1 ) THEN files_to_be_opened = files_to_be_opened + 1 file_list(files_to_be_opened) = i-1 ENDIF offset_xa(files_to_be_opened,j) = offset_x + shift_x offset_ya(files_to_be_opened,j) = offset_y + shift_y ! !-- Index bounds of overlapping data nxlfa(files_to_be_opened,j) = MAX( nxl-offset_x-shift_x, nxlpr ) nxrfa(files_to_be_opened,j) = MIN( nxr-offset_x-shift_x, nxrpr ) nysfa(files_to_be_opened,j) = MAX( nys-offset_y, nyspr ) nynfa(files_to_be_opened,j) = MIN( nyn-offset_y, nynpr ) shift_x = shift_x + ( nx_on_file + 1 ) ENDDO shift_y = shift_y + ( ny_on_file + 1 ) ENDDO IF ( j > 0 ) overlap_count(files_to_be_opened) = j ! !-- Test output, to be removed later IF ( j > 0 ) THEN WRITE (9,*) '*** reading from file: ', i, j, ' times' WRITE (9,*) ' nxl = ', nxl, ' nxr = ', nxr, ' nys = ', nys, ' nyn = ', nyn WRITE (9,*) ' ' DO k = 1, j WRITE (9,*) 'k = ', k WRITE (9,'(6(A,I4))') 'nxlfa = ', nxlfa(files_to_be_opened,k), & ' nxrfa = ', nxrfa(files_to_be_opened,k), & ' offset_xa = ', offset_xa(files_to_be_opened,k), & ' nysfa = ', nysfa(files_to_be_opened,k), & ' nynfa = ', nynfa(files_to_be_opened,k), & ' offset_ya = ', offset_ya(files_to_be_opened,k) ENDDO CALL local_flush( 9 ) ENDIF ENDDO ! !-- Save the id-string of the current process, since myid_char may now be used !-- to open files created by PEs with other id. myid_char_save = myid_char ! !-- Test output (remove later) DO i = 1, numprocs_previous_run WRITE (9,*) 'i=',i-1, ' ibs= ',hor_index_bounds_previous_run(1:4,i-1) ENDDO CALL local_flush( 9 ) IF ( files_to_be_opened /= 1 .OR. numprocs /= numprocs_previous_run ) & THEN WRITE( message_string, * ) 'number of PEs or virtual PE-grid changed ', & 'in restart run& PE', myid, ' will read from files ', & file_list(1:files_to_be_opened) CALL message( 'read_3d_binary', 'PA0285', 0, 0, 0, 6, 0 ) ENDIF ! !-- Read data from all restart files determined above DO i = 1, files_to_be_opened j = file_list(i) ! !-- Set the filename (underscore followed by four digit processor id) WRITE (myid_char,'(''_'',I4.4)') j WRITE (9,*) 'myid=',myid,' opening file "',myid_char,'"' CALL local_flush( 9 ) ! !-- Open the restart file. If this file has been created by PE0 (_0000), !-- the global variables at the beginning of the file have to be skipped !-- first. CALL check_open( 13 ) WRITE (9,*) 'before skipping' CALL local_flush( 9 ) IF ( j == 0 ) CALL skip_var_list WRITE (9,*) 'skipping done' CALL local_flush( 9 ) ! !-- First compare the version numbers READ ( 13 ) version_on_file binary_version = '3.1' IF ( TRIM( version_on_file ) /= TRIM( binary_version ) ) THEN WRITE( message_string, * ) 'version mismatch concerning data ', & 'from prior run', & '&version on file = "', TRIM( version_on_file ), '"', & '&version in program = "', TRIM( binary_version ), '"' CALL message( 'read_3d_binary', 'PA0286', 1, 2, 0, 6, 0 ) ENDIF ! !-- Read number of processors, processor-id, and array ranges. !-- Compare the array ranges with those stored in the index bound array. READ ( 13 ) numprocs_on_file, myid_on_file, nxl_on_file, nxr_on_file, & nys_on_file, nyn_on_file, nzb_on_file, nzt_on_file IF ( nxl_on_file /= hor_index_bounds_previous_run(1,j) ) THEN WRITE( message_string, * ) 'problem with index bound nxl on ', & 'restart file "', myid_char, '"', & '&nxl = ', nxl_on_file, ' but it should be', & '&= ', hor_index_bounds_previous_run(1,j), & '&from the index bound information array' CALL message( 'read_3d_binary', 'PA0287', 2, 2, -1, 6, 1 ) ENDIF IF ( nxr_on_file /= hor_index_bounds_previous_run(2,j) ) THEN WRITE( message_string, * ) 'problem with index bound nxr on ', & 'restart file "', myid_char, '"' , & '&nxr = ', nxr_on_file, ' but it should be', & '&= ', hor_index_bounds_previous_run(2,j), & '&from the index bound information array' CALL message( 'read_3d_binary', 'PA0288', 2, 2, -1, 6, 1 ) ENDIF IF ( nys_on_file /= hor_index_bounds_previous_run(3,j) ) THEN WRITE( message_string, * ) 'problem with index bound nys on ', & 'restart file "', myid_char, '"', & '&nys = ', nys_on_file, ' but it should be', & '&= ', hor_index_bounds_previous_run(3,j), & '&from the index bound information array' CALL message( 'read_3d_binary', 'PA0289', 2, 2, -1, 6, 1 ) ENDIF IF ( nyn_on_file /= hor_index_bounds_previous_run(4,j) ) THEN WRITE( message_string, * ) 'problem with index bound nyn on ', & 'restart file "', myid_char, '"', & '&nyn = ', nyn_on_file, ' but it should be', & '&= ', hor_index_bounds_previous_run(4,j), & '&from the index bound information array' CALL message( 'read_3d_binary', 'PA0290', 2, 2, -1, 6, 1 ) ENDIF IF ( nzb_on_file /= nzb ) THEN WRITE( message_string, * ) 'mismatch between actual data and data ', & '&from prior run on PE ', myid, & '&nzb on file = ', nzb_on_file, & '&nzb = ', nzb CALL message( 'read_3d_binary', 'PA0291', 1, 2, 0, 6, 0 ) ENDIF IF ( nzt_on_file /= nzt ) THEN WRITE( message_string, * ) 'mismatch between actual data and data ', & '&from prior run on PE ', myid, & '&nzt on file = ', nzt_on_file, & '&nzt = ', nzt CALL message( 'read_3d_binary', 'PA0292', 1, 2, 0, 6, 0 ) ENDIF ! !-- Allocate temporary arrays sized as the arrays on the restart file ALLOCATE( tmp_2d(nys_on_file-1:nyn_on_file+1, & nxl_on_file-1:nxr_on_file+1), & tmp_3d(nzb:nzt+1,nys_on_file-1:nyn_on_file+1, & nxl_on_file-1:nxr_on_file+1) ) ! !-- Read arrays !-- ATTENTION: If the following read commands have been altered, the !-- ---------- version number of the variable binary_version must be altered, !-- too. Furthermore, the output list of arrays in write_3d_binary !-- must also be altered accordingly. READ ( 13 ) field_chr DO WHILE ( TRIM( field_chr ) /= '*** end ***' ) ! !-- Map data on file as often as needed (data are read only for k=1) DO k = 1, overlap_count(i) ! !-- Get the index range of the subdomain on file which overlap with the !-- current subdomain nxlf = nxlfa(i,k) nxlc = nxlfa(i,k) + offset_xa(i,k) nxrf = nxrfa(i,k) nxrc = nxrfa(i,k) + offset_xa(i,k) nysf = nysfa(i,k) nysc = nysfa(i,k) + offset_ya(i,k) nynf = nynfa(i,k) nync = nynfa(i,k) + offset_ya(i,k) WRITE (9,*) 'var = ', field_chr CALL local_flush( 9 ) SELECT CASE ( TRIM( field_chr ) ) CASE ( 'e' ) IF ( k == 1 ) READ ( 13 ) tmp_3d e(:,nysc-1:nync+1,nxlc-1:nxrc+1) = & tmp_3d(:,nysf-1:nynf+1,nxlf-1:nxrf+1) CASE ( 'e_av' ) IF ( .NOT. ALLOCATED( e_av ) ) THEN ALLOCATE( e_av(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) ) ENDIF IF ( k == 1 ) READ ( 13 ) tmp_3d e_av(:,nysc-1:nync+1,nxlc-1:nxrc+1) = & tmp_3d(:,nysf-1:nynf+1,nxlf-1:nxrf+1) CASE ( 'e_m' ) IF ( k == 1 ) READ ( 13 ) tmp_3d e_m(:,nysc-1:nync+1,nxlc-1:nxrc+1) = & tmp_3d(:,nysf-1:nynf+1,nxlf-1:nxrf+1) CASE ( 'iran' ) ! matching random numbers is still unresolved ! issue IF ( k == 1 ) READ ( 13 ) iran, iran_part CASE ( 'kh' ) IF ( k == 1 ) READ ( 13 ) tmp_3d kh(:,nysc-1:nync+1,nxlc-1:nxrc+1) = & tmp_3d(:,nysf-1:nynf+1,nxlf-1:nxrf+1) CASE ( 'kh_m' ) IF ( k == 1 ) READ ( 13 ) tmp_3d kh_m(:,nysc-1:nync+1,nxlc-1:nxrc+1) = & tmp_3d(:,nysf-1:nynf+1,nxlf-1:nxrf+1) CASE ( 'km' ) IF ( k == 1 ) READ ( 13 ) tmp_3d km(:,nysc-1:nync+1,nxlc-1:nxrc+1) = & tmp_3d(:,nysf-1:nynf+1,nxlf-1:nxrf+1) CASE ( 'km_m' ) IF ( k == 1 ) READ ( 13 ) tmp_3d km_m(:,nysc-1:nync+1,nxlc-1:nxrc+1) = & tmp_3d(:,nysf-1:nynf+1,nxlf-1:nxrf+1) CASE ( 'lwp_av' ) IF ( .NOT. ALLOCATED( lwp_av ) ) THEN ALLOCATE( lwp_av(nys-1:nyn+1,nxl-1:nxr+1) ) ENDIF IF ( k == 1 ) READ ( 13 ) tmp_2d lwp_av(nysc-1:nync+1,nxlc-1:nxrc+1) = & tmp_2d(nysf-1:nynf+1,nxlf-1:nxrf+1) CASE ( 'p' ) IF ( k == 1 ) READ ( 13 ) tmp_3d p(:,nysc-1:nync+1,nxlc-1:nxrc+1) = & tmp_3d(:,nysf-1:nynf+1,nxlf-1:nxrf+1) CASE ( 'p_av' ) IF ( .NOT. ALLOCATED( p_av ) ) THEN ALLOCATE( p_av(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) ) ENDIF IF ( k == 1 ) READ ( 13 ) tmp_3d p_av(:,nysc-1:nync+1,nxlc-1:nxrc+1) = & tmp_3d(:,nysf-1:nynf+1,nxlf-1:nxrf+1) CASE ( 'pc_av' ) IF ( .NOT. ALLOCATED( pc_av ) ) THEN ALLOCATE( pc_av(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) ) ENDIF IF ( k == 1 ) READ ( 13 ) tmp_3d pc_av(:,nysc-1:nync+1,nxlc-1:nxrc+1) = & tmp_3d(:,nysf-1:nynf+1,nxlf-1:nxrf+1) CASE ( 'pr_av' ) IF ( .NOT. ALLOCATED( pr_av ) ) THEN ALLOCATE( pr_av(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) ) ENDIF IF ( k == 1 ) READ ( 13 ) tmp_3d pr_av(:,nysc-1:nync+1,nxlc-1:nxrc+1) = & tmp_3d(:,nysf-1:nynf+1,nxlf-1:nxrf+1) CASE ( 'precipitation_amount' ) IF ( k == 1 ) READ ( 13 ) tmp_2d precipitation_amount(nysc-1:nync+1,nxlc-1:nxrc+1) = & tmp_2d(nysf-1:nynf+1,nxlf-1:nxrf+1) CASE ( 'precipitation_rate_a' ) IF ( .NOT. ALLOCATED( precipitation_rate_av ) ) THEN ALLOCATE( precipitation_rate_av(nys-1:nyn+1,nxl-1:nxr+1) ) ENDIF IF ( k == 1 ) READ ( 13 ) tmp_2d precipitation_rate_av(nysc-1:nync+1,nxlc-1:nxrc+1) = & tmp_2d(nysf-1:nynf+1,nxlf-1:nxrf+1) CASE ( 'pt' ) IF ( k == 1 ) READ ( 13 ) tmp_3d pt(:,nysc-1:nync+1,nxlc-1:nxrc+1) = & tmp_3d(:,nysf-1:nynf+1,nxlf-1:nxrf+1) CASE ( 'pt_av' ) IF ( .NOT. ALLOCATED( pt_av ) ) THEN ALLOCATE( pt_av(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) ) ENDIF IF ( k == 1 ) READ ( 13 ) tmp_3d pt_av(:,nysc-1:nync+1,nxlc-1:nxrc+1) = & tmp_3d(:,nysf-1:nynf+1,nxlf-1:nxrf+1) CASE ( 'pt_m' ) IF ( k == 1 ) READ ( 13 ) tmp_3d pt_m(:,nysc-1:nync+1,nxlc-1:nxrc+1) = & tmp_3d(:,nysf-1:nynf+1,nxlf-1:nxrf+1) CASE ( 'q' ) IF ( k == 1 ) READ ( 13 ) tmp_3d q(:,nysc-1:nync+1,nxlc-1:nxrc+1) = & tmp_3d(:,nysf-1:nynf+1,nxlf-1:nxrf+1) CASE ( 'q_av' ) IF ( .NOT. ALLOCATED( q_av ) ) THEN ALLOCATE( q_av(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) ) ENDIF IF ( k == 1 ) READ ( 13 ) tmp_3d q_av(:,nysc-1:nync+1,nxlc-1:nxrc+1) = & tmp_3d(:,nysf-1:nynf+1,nxlf-1:nxrf+1) CASE ( 'q_m' ) IF ( k == 1 ) READ ( 13 ) tmp_3d q_m(:,nysc-1:nync+1,nxlc-1:nxrc+1) = & tmp_3d(:,nysf-1:nynf+1,nxlf-1:nxrf+1) CASE ( 'ql' ) IF ( k == 1 ) READ ( 13 ) tmp_3d ql(:,nysc-1:nync+1,nxlc-1:nxrc+1) = & tmp_3d(:,nysf-1:nynf+1,nxlf-1:nxrf+1) CASE ( 'ql_av' ) IF ( .NOT. ALLOCATED( ql_av ) ) THEN ALLOCATE( ql_av(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) ) ENDIF IF ( k == 1 ) READ ( 13 ) tmp_3d ql_av(:,nysc-1:nync+1,nxlc-1:nxrc+1) = & tmp_3d(:,nysf-1:nynf+1,nxlf-1:nxrf+1) CASE ( 'ql_c_av' ) IF ( .NOT. ALLOCATED( ql_c_av ) ) THEN ALLOCATE( ql_c_av(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) ) ENDIF IF ( k == 1 ) READ ( 13 ) tmp_3d ql_c_av(:,nysc-1:nync+1,nxlc-1:nxrc+1) = & tmp_3d(:,nysf-1:nynf+1,nxlf-1:nxrf+1) CASE ( 'ql_v_av' ) IF ( .NOT. ALLOCATED( ql_v_av ) ) THEN ALLOCATE( ql_v_av(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) ) ENDIF IF ( k == 1 ) READ ( 13 ) tmp_3d ql_v_av(:,nysc-1:nync+1,nxlc-1:nxrc+1) = & tmp_3d(:,nysf-1:nynf+1,nxlf-1:nxrf+1) CASE ( 'ql_vp_av' ) IF ( .NOT. ALLOCATED( ql_vp_av ) ) THEN ALLOCATE( ql_vp_av(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) ) ENDIF IF ( k == 1 ) READ ( 13 ) tmp_3d ql_vp_av(:,nysc-1:nync+1,nxlc-1:nxrc+1) = & tmp_3d(:,nysf-1:nynf+1,nxlf-1:nxrf+1) CASE ( 'qs' ) IF ( k == 1 ) READ ( 13 ) tmp_2d qs(nysc-1:nync+1,nxlc-1:nxrc+1) = & tmp_2d(nysf-1:nynf+1,nxlf-1:nxrf+1) CASE ( 'qsws' ) IF ( k == 1 ) READ ( 13 ) tmp_2d qsws(nysc-1:nync+1,nxlc-1:nxrc+1) = & tmp_2d(nysf-1:nynf+1,nxlf-1:nxrf+1) CASE ( 'qsws_m' ) IF ( k == 1 ) READ ( 13 ) tmp_2d qsws_m(nysc-1:nync+1,nxlc-1:nxrc+1) = & tmp_2d(nysf-1:nynf+1,nxlf-1:nxrf+1) CASE ( 'qsws_av' ) IF ( .NOT. ALLOCATED( qsws_av ) ) THEN ALLOCATE( qsws_av(nys-1:nyn+1,nxl-1:nxr+1) ) ENDIF IF ( k == 1 ) READ ( 13 ) tmp_2d qsws_av(nysc-1:nync+1,nxlc-1:nxrc+1) = & tmp_2d(nysf-1:nynf+1,nxlf-1:nxrf+1) CASE ( 'qswst' ) IF ( k == 1 ) READ ( 13 ) tmp_2d qswst(nysc-1:nync+1,nxlc-1:nxrc+1) = & tmp_2d(nysf-1:nynf+1,nxlf-1:nxrf+1) CASE ( 'qswst_m' ) IF ( k == 1 ) READ ( 13 ) tmp_2d qswst_m(nysc-1:nync+1,nxlc-1:nxrc+1) = & tmp_2d(nysf-1:nynf+1,nxlf-1:nxrf+1) CASE ( 'qv_av' ) IF ( .NOT. ALLOCATED( qv_av ) ) THEN ALLOCATE( qv_av(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) ) ENDIF IF ( k == 1 ) READ ( 13 ) tmp_3d qv_av(:,nysc-1:nync+1,nxlc-1:nxrc+1) = & tmp_3d(:,nysf-1:nynf+1,nxlf-1:nxrf+1) CASE ( 'random_iv' ) ! still unresolved issue IF ( k == 1 ) READ ( 13 ) random_iv IF ( k == 1 ) READ ( 13 ) random_iy CASE ( 'rho_av' ) IF ( .NOT. ALLOCATED( rho_av ) ) THEN ALLOCATE( rho_av(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) ) ENDIF IF ( k == 1 ) READ ( 13 ) tmp_3d rho_av(:,nysc-1:nync+1,nxlc-1:nxrc+1) = & tmp_3d(:,nysf-1:nynf+1,nxlf-1:nxrf+1) CASE ( 'rif' ) IF ( k == 1 ) READ ( 13 ) tmp_2d rif(nysc-1:nync+1,nxlc-1:nxrc+1) = & tmp_2d(nysf-1:nynf+1,nxlf-1:nxrf+1) CASE ( 'rif_m' ) IF ( k == 1 ) READ ( 13 ) tmp_2d rif_m(nysc-1:nync+1,nxlc-1:nxrc+1) = & tmp_2d(nysf-1:nynf+1,nxlf-1:nxrf+1) CASE ( 'rif_wall' ) IF ( k == 1 ) THEN ALLOCATE( tmp_4d(nzb:nzt+1,nys_on_file-1:nyn_on_file+1, & nxl_on_file-1:nxr_on_file+1,1:4) ) READ ( 13 ) tmp_4d ENDIF rif_wall(:,nysc-1:nync+1,nxlc-1:nxrc+1,:) = & tmp_4d(:,nysf-1:nynf+1,nxlf-1:nxrf+1,:) CASE ( 's_av' ) IF ( .NOT. ALLOCATED( s_av ) ) THEN ALLOCATE( s_av(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) ) ENDIF IF ( k == 1 ) READ ( 13 ) tmp_3d s_av(:,nysc-1:nync+1,nxlc-1:nxrc+1) = & tmp_3d(:,nysf-1:nynf+1,nxlf-1:nxrf+1) CASE ( 'sa' ) IF ( k == 1 ) READ ( 13 ) tmp_3d sa(:,nysc-1:nync+1,nxlc-1:nxrc+1) = & tmp_3d(:,nysf-1:nynf+1,nxlf-1:nxrf+1) CASE ( 'sa_av' ) IF ( .NOT. ALLOCATED( sa_av ) ) THEN ALLOCATE( sa_av(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) ) ENDIF IF ( k == 1 ) READ ( 13 ) tmp_3d sa_av(:,nysc-1:nync+1,nxlc-1:nxrc+1) = & tmp_3d(:,nysf-1:nynf+1,nxlf-1:nxrf+1) CASE ( 'saswsb' ) IF ( k == 1 ) READ ( 13 ) tmp_2d saswsb(nysc-1:nync+1,nxlc-1:nxrc+1) = & tmp_2d(nysf-1:nynf+1,nxlf-1:nxrf+1) CASE ( 'saswst' ) IF ( k == 1 ) READ ( 13 ) tmp_2d saswst(nysc-1:nync+1,nxlc-1:nxrc+1) = & tmp_2d(nysf-1:nynf+1,nxlf-1:nxrf+1) CASE ( 'shf' ) IF ( k == 1 ) READ ( 13 ) tmp_2d shf(nysc-1:nync+1,nxlc-1:nxrc+1) = & tmp_2d(nysf-1:nynf+1,nxlf-1:nxrf+1) CASE ( 'shf_m' ) IF ( k == 1 ) READ ( 13 ) tmp_2d shf_m(nysc-1:nync+1,nxlc-1:nxrc+1) = & tmp_2d(nysf-1:nynf+1,nxlf-1:nxrf+1) CASE ( 'shf_av' ) IF ( .NOT. ALLOCATED( shf_av ) ) THEN ALLOCATE( shf_av(nys-1:nyn+1,nxl-1:nxr+1) ) ENDIF IF ( k == 1 ) READ ( 13 ) tmp_2d shf_av(nysc-1:nync+1,nxlc-1:nxrc+1) = & tmp_2d(nysf-1:nynf+1,nxlf-1:nxrf+1) CASE ( 'spectrum_x' ) IF ( k == 1 ) THEN IF ( nx_on_file /= nx ) THEN message_string = 'read_3d_binary: spectrum_x ' // & 'on restart file ignored because' // & '&total numbers of grid points (nx) ' // & 'do not match' CALL message( 'read_3d_binary', 'PA0293',& 0, 1, 0, 6, 0 ) READ ( 13 ) rdummy ELSE READ ( 13 ) spectrum_x ENDIF ENDIF CASE ( 'spectrum_y' ) IF ( k == 1 ) THEN IF ( ny_on_file /= ny ) THEN message_string = 'read_3d_binary: spectrum_y ' // & 'on restart file ignored because' // & '&total numbers of grid points (ny) '// & 'do not match' CALL message( 'read_3d_binary', 'PA0294', & 0, 1, 0, 6, 0 ) READ ( 13 ) rdummy ELSE READ ( 13 ) spectrum_y ENDIF ENDIF CASE ( 'ts' ) IF ( k == 1 ) READ ( 13 ) tmp_2d ts(nysc-1:nync+1,nxlc-1:nxrc+1) = & tmp_2d(nysf-1:nynf+1,nxlf-1:nxrf+1) CASE ( 'ts_av' ) IF ( .NOT. ALLOCATED( ts_av ) ) THEN ALLOCATE( ts_av(nys-1:nyn+1,nxl-1:nxr+1) ) ENDIF IF ( k == 1 ) READ ( 13 ) tmp_2d ts_av(nysc-1:nync+1,nxlc-1:nxrc+1) = & tmp_2d(nysf-1:nynf+1,nxlf-1:nxrf+1) CASE ( 'tswst' ) IF ( k == 1 ) READ ( 13 ) tmp_2d tswst(nysc-1:nync+1,nxlc-1:nxrc+1) = & tmp_2d(nysf-1:nynf+1,nxlf-1:nxrf+1) CASE ( 'tswst_m' ) IF ( k == 1 ) READ ( 13 ) tmp_2d tswst_m(nysc-1:nync+1,nxlc-1:nxrc+1) = & tmp_2d(nysf-1:nynf+1,nxlf-1:nxrf+1) CASE ( 'u' ) IF ( k == 1 ) READ ( 13 ) tmp_3d u(:,nysc-1:nync+1,nxlc-1:nxrc+1) = & tmp_3d(:,nysf-1:nynf+1,nxlf-1:nxrf+1) CASE ( 'u_av' ) IF ( .NOT. ALLOCATED( u_av ) ) THEN ALLOCATE( u_av(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) ) ENDIF IF ( k == 1 ) READ ( 13 ) tmp_3d u_av(:,nysc-1:nync+1,nxlc-1:nxrc+1) = & tmp_3d(:,nysf-1:nynf+1,nxlf-1:nxrf+1) CASE ( 'u_m' ) IF ( k == 1 ) READ ( 13 ) tmp_3d u_m(:,nysc-1:nync+1,nxlc-1:nxrc+1) = & tmp_3d(:,nysf-1:nynf+1,nxlf-1:nxrf+1) CASE ( 'u_m_l' ) IF ( k == 1 ) THEN ALLOCATE( tmp_3dwul(nzb:nzt+1, & nys_on_file-1:nyn_on_file+1,1:2) ) READ ( 13 ) tmp_3dwul ENDIF IF ( outflow_l ) THEN u_m_l(:,nysc-1:nync+1,:) = tmp_3dwul(:,nysf-1:nynf+1,:) ENDIF CASE ( 'u_m_n' ) IF ( k == 1 ) THEN ALLOCATE( tmp_3dwun(nzb:nzt+1,ny-1:ny, & nxl_on_file-1:nxr_on_file+1) ) READ ( 13 ) tmp_3dwun ENDIF IF ( outflow_n ) THEN u_m_n(:,:,nxlc-1:nxrc+1) = tmp_3dwun(:,:,nxlf-1:nxrf+1) ENDIF CASE ( 'u_m_r' ) IF ( k == 1 ) THEN ALLOCATE( tmp_3dwur(nzb:nzt+1,& nys_on_file-1:nyn_on_file+1,nx-1:nx) ) READ ( 13 ) tmp_3dwur ENDIF IF ( outflow_r ) THEN u_m_r(:,nysc-1:nync+1,:) = tmp_3dwur(:,nysf-1:nynf+1,:) ENDIF CASE ( 'u_m_s' ) IF ( k == 1 ) THEN ALLOCATE( tmp_3dwus(nzb:nzt+1,0:1, & nxl_on_file-1:nxr_on_file+1) ) READ ( 13 ) tmp_3dwus ENDIF IF ( outflow_s ) THEN u_m_s(:,:,nxlc-1:nxrc+1) = tmp_3dwus(:,:,nxlf-1:nxrf+1) ENDIF CASE ( 'us' ) IF ( k == 1 ) READ ( 13 ) tmp_2d us(nysc-1:nync+1,nxlc-1:nxrc+1) = & tmp_2d(nysf-1:nynf+1,nxlf-1:nxrf+1) CASE ( 'usws' ) IF ( k == 1 ) READ ( 13 ) tmp_2d usws(nysc-1:nync+1,nxlc-1:nxrc+1) = & tmp_2d(nysf-1:nynf+1,nxlf-1:nxrf+1) CASE ( 'uswst' ) IF ( k == 1 ) READ ( 13 ) tmp_2d uswst(nysc-1:nync+1,nxlc-1:nxrc+1) = & tmp_2d(nysf-1:nynf+1,nxlf-1:nxrf+1) CASE ( 'usws_m' ) IF ( k == 1 ) READ ( 13 ) tmp_2d usws_m(nysc-1:nync+1,nxlc-1:nxrc+1) = & tmp_2d(nysf-1:nynf+1,nxlf-1:nxrf+1) CASE ( 'uswst_m' ) IF ( k == 1 ) READ ( 13 ) tmp_2d uswst_m(nysc-1:nync+1,nxlc-1:nxrc+1) = & tmp_2d(nysf-1:nynf+1,nxlf-1:nxrf+1) CASE ( 'us_av' ) IF ( .NOT. ALLOCATED( us_av ) ) THEN ALLOCATE( us_av(nys-1:nyn+1,nxl-1:nxr+1) ) ENDIF IF ( k == 1 ) READ ( 13 ) tmp_2d us_av(nysc-1:nync+1,nxlc-1:nxrc+1) = & tmp_2d(nysf-1:nynf+1,nxlf-1:nxrf+1) CASE ( 'v' ) IF ( k == 1 ) READ ( 13 ) tmp_3d v(:,nysc-1:nync+1,nxlc-1:nxrc+1) = & tmp_3d(:,nysf-1:nynf+1,nxlf-1:nxrf+1) CASE ( 'v_av' ) IF ( .NOT. ALLOCATED( v_av ) ) THEN ALLOCATE( v_av(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) ) ENDIF IF ( k == 1 ) READ ( 13 ) tmp_3d v_av(:,nysc-1:nync+1,nxlc-1:nxrc+1) = & tmp_3d(:,nysf-1:nynf+1,nxlf-1:nxrf+1) CASE ( 'v_m' ) IF ( k == 1 ) READ ( 13 ) tmp_3d v_m(:,nysc-1:nync+1,nxlc-1:nxrc+1) = & tmp_3d(:,nysf-1:nynf+1,nxlf-1:nxrf+1) CASE ( 'v_m_l' ) IF ( k == 1 ) THEN ALLOCATE( tmp_3dwvl(nzb:nzt+1,& nys_on_file-1:nyn_on_file+1,0:1) ) READ ( 13 ) tmp_3dwvl ENDIF IF ( outflow_l ) THEN v_m_l(:,nysc-1:nync+1,:) = tmp_3dwvl(:,nysf-1:nynf+1,:) ENDIF CASE ( 'v_m_n' ) IF ( k == 1 ) THEN ALLOCATE( tmp_3dwvn(nzb:nzt+1,ny-1:ny, & nxl_on_file-1:nxr_on_file+1) ) READ ( 13 ) tmp_3dwvn ENDIF IF ( outflow_n ) THEN v_m_n(:,:,nxlc-1:nxrc+1) = tmp_3dwvn(:,:,nxlf-1:nxrf+1) ENDIF CASE ( 'v_m_r' ) IF ( k == 1 ) THEN ALLOCATE( tmp_3dwvr(nzb:nzt+1,& nys_on_file-1:nyn_on_file+1,nx-1:nx) ) READ ( 13 ) tmp_3dwvr ENDIF IF ( outflow_r ) THEN v_m_r(:,nysc-1:nync+1,:) = tmp_3dwvr(:,nysf-1:nynf+1,:) ENDIF CASE ( 'v_m_s' ) IF ( k == 1 ) THEN ALLOCATE( tmp_3dwvs(nzb:nzt+1,1:2, & nxl_on_file-1:nxr_on_file+1) ) READ ( 13 ) tmp_3dwvs ENDIF IF ( outflow_s ) THEN v_m_s(:,:,nxlc-1:nxrc+1) = tmp_3dwvs(:,:,nxlf-1:nxrf+1) ENDIF CASE ( 'vpt' ) IF ( k == 1 ) READ ( 13 ) tmp_3d vpt(:,nysc-1:nync+1,nxlc-1:nxrc+1) = & tmp_3d(:,nysf-1:nynf+1,nxlf-1:nxrf+1) CASE ( 'vpt_av' ) IF ( .NOT. ALLOCATED( vpt_av ) ) THEN ALLOCATE( vpt_av(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) ) ENDIF IF ( k == 1 ) READ ( 13 ) tmp_3d vpt_av(:,nysc-1:nync+1,nxlc-1:nxrc+1) = & tmp_3d(:,nysf-1:nynf+1,nxlf-1:nxrf+1) CASE ( 'vpt_m' ) IF ( k == 1 ) READ ( 13 ) tmp_3d vpt_m(:,nysc-1:nync+1,nxlc-1:nxrc+1) = & tmp_3d(:,nysf-1:nynf+1,nxlf-1:nxrf+1) CASE ( 'vsws' ) IF ( k == 1 ) READ ( 13 ) tmp_2d vsws(nysc-1:nync+1,nxlc-1:nxrc+1) = & tmp_2d(nysf-1:nynf+1,nxlf-1:nxrf+1) CASE ( 'vswst' ) IF ( k == 1 ) READ ( 13 ) tmp_2d vswst(nysc-1:nync+1,nxlc-1:nxrc+1) = & tmp_2d(nysf-1:nynf+1,nxlf-1:nxrf+1) CASE ( 'vsws_m' ) IF ( k == 1 ) READ ( 13 ) tmp_2d vsws_m(nysc-1:nync+1,nxlc-1:nxrc+1) = & tmp_2d(nysf-1:nynf+1,nxlf-1:nxrf+1) CASE ( 'vswst_m' ) IF ( k == 1 ) READ ( 13 ) tmp_2d vswst_m(nysc-1:nync+1,nxlc-1:nxrc+1) = & tmp_2d(nysf-1:nynf+1,nxlf-1:nxrf+1) CASE ( 'w' ) IF ( k == 1 ) READ ( 13 ) tmp_3d w(:,nysc-1:nync+1,nxlc-1:nxrc+1) = & tmp_3d(:,nysf-1:nynf+1,nxlf-1:nxrf+1) CASE ( 'w_av' ) IF ( .NOT. ALLOCATED( w_av ) ) THEN ALLOCATE( w_av(nzb:nzt+1,nys-1:nyn+1,nxl-1:nxr+1) ) ENDIF IF ( k == 1 ) READ ( 13 ) tmp_3d w_av(:,nysc-1:nync+1,nxlc-1:nxrc+1) = & tmp_3d(:,nysf-1:nynf+1,nxlf-1:nxrf+1) CASE ( 'w_m' ) IF ( k == 1 ) READ ( 13 ) tmp_3d w_m(:,nysc-1:nync+1,nxlc-1:nxrc+1) = & tmp_3d(:,nysf-1:nynf+1,nxlf-1:nxrf+1) CASE ( 'w_m_l' ) IF ( k == 1 ) THEN ALLOCATE( tmp_3dwwl(nzb:nzt+1,& nys_on_file-1:nyn_on_file+1,0:1) ) READ ( 13 ) tmp_3dwwl ENDIF IF ( outflow_l ) THEN w_m_l(:,nysc-1:nync+1,:) = tmp_3dwwl(:,nysf-1:nynf+1,:) ENDIF CASE ( 'w_m_n' ) IF ( k == 1 ) THEN ALLOCATE( tmp_3dwwn(nzb:nzt+1,ny-1:ny, & nxl_on_file-1:nxr_on_file+1) ) READ ( 13 ) tmp_3dwwn ENDIF IF ( outflow_n ) THEN w_m_n(:,:,nxlc-1:nxrc+1) = tmp_3dwwn(:,:,nxlf-1:nxrf+1) ENDIF CASE ( 'w_m_r' ) IF ( k == 1 ) THEN ALLOCATE( tmp_3dwwr(nzb:nzt+1,& nys_on_file-1:nyn_on_file+1,nx-1:nx) ) READ ( 13 ) tmp_3dwwr ENDIF IF ( outflow_r ) THEN w_m_r(:,nysc-1:nync+1,:) = tmp_3dwwr(:,nysf-1:nynf+1,:) ENDIF CASE ( 'w_m_s' ) IF ( k == 1 ) THEN ALLOCATE( tmp_3dwws(nzb:nzt+1,0:1, & nxl_on_file-1:nxr_on_file+1) ) READ ( 13 ) tmp_3dwws ENDIF IF ( outflow_s ) THEN w_m_s(:,:,nxlc-1:nxrc+1) = tmp_3dwws(:,:,nxlf-1:nxrf+1) ENDIF DEALLOCATE( tmp_3dwws ) CASE ( 'z0' ) IF ( k == 1 ) READ ( 13 ) tmp_2d z0(nysc-1:nync+1,nxlc-1:nxrc+1) = & tmp_2d(nysf-1:nynf+1,nxlf-1:nxrf+1) CASE ( 'z0_av' ) IF ( .NOT. ALLOCATED( z0_av ) ) THEN ALLOCATE( z0_av(nys-1:nyn+1,nxl-1:nxr+1) ) ENDIF IF ( k == 1 ) READ ( 13 ) tmp_2d z0_av(nysc-1:nync+1,nxlc-1:nxrc+1) = & tmp_2d(nysf-1:nynf+1,nxlf-1:nxrf+1) CASE DEFAULT WRITE( message_string, * ) 'unknown field named "', & TRIM( field_chr ), '" found in', & '&data from prior run on PE ',myid CALL message( 'read_3d_binary', 'PA0295', 1, 2, 0, 6, 0 ) END SELECT ENDDO ! overlap loop ! !-- Deallocate arrays needed for specific variables only IF ( ALLOCATED( tmp_3dwul ) ) DEALLOCATE( tmp_3dwul ) IF ( ALLOCATED( tmp_3dwun ) ) DEALLOCATE( tmp_3dwun ) IF ( ALLOCATED( tmp_3dwur ) ) DEALLOCATE( tmp_3dwur ) IF ( ALLOCATED( tmp_3dwus ) ) DEALLOCATE( tmp_3dwus ) IF ( ALLOCATED( tmp_3dwvl ) ) DEALLOCATE( tmp_3dwvl ) IF ( ALLOCATED( tmp_3dwvn ) ) DEALLOCATE( tmp_3dwvn ) IF ( ALLOCATED( tmp_3dwvr ) ) DEALLOCATE( tmp_3dwvr ) IF ( ALLOCATED( tmp_3dwvs ) ) DEALLOCATE( tmp_3dwvs ) IF ( ALLOCATED( tmp_3dwwl ) ) DEALLOCATE( tmp_3dwwl ) IF ( ALLOCATED( tmp_3dwwn ) ) DEALLOCATE( tmp_3dwwn ) IF ( ALLOCATED( tmp_3dwwr ) ) DEALLOCATE( tmp_3dwwr ) IF ( ALLOCATED( tmp_3dwws ) ) DEALLOCATE( tmp_3dwws ) IF ( ALLOCATED( tmp_4d ) ) DEALLOCATE( tmp_4d ) ! !-- Read next character string READ ( 13 ) field_chr ENDDO ! loop over variables ! !-- Read user-defined restart data CALL user_read_restart_data( i, nxlfa, nxl_on_file, nxrfa, nxr_on_file, & nynfa, nyn_on_file, nysfa, nys_on_file, & offset_xa, offset_ya, overlap_count(i), & tmp_2d, tmp_3d ) ! !-- Close the restart file CALL close_file( 13 ) DEALLOCATE( tmp_2d, tmp_3d ) ENDDO ! loop over restart files ! !-- Restore the original filename for the restart file to be written myid_char = myid_char_save ! !-- End of time measuring for reading binary data CALL cpu_log( log_point_s(14), 'read_3d_binary', 'stop' ) END SUBROUTINE read_3d_binary