Changeset 4685 for palm


Ignore:
Timestamp:
Sep 18, 2020 11:49:50 AM (5 weeks ago)
Author:
gronemeier
Message:

filter data_output_pr and data_output list for duplicate entries (check_parameters)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • palm/trunk/SOURCE/check_parameters.f90

    r4633 r4685  
    2424! -----------------
    2525! $Id$
     26! filter data_output_pr and data_output list for duplicate entries
     27!
     28! 4633 2020-08-05 14:21:14Z suehring
    2629! todo added
    27 ! 
     30!
    2831! 4565 2020-06-15 08:30:38Z oliver.maas
    2932! added check for pt_surface_heating_rate
    30 ! 
     33!
    3134! 4564 2020-06-12 14:03:36Z raasch
    3235! Vertical nesting method of Huq et al. (2019) removed
    33 ! 
     36!
    3437! 4562 2020-06-12 08:38:47Z raasch
    3538! bugfix: revised error message for exceeding allow number of time series
    36 ! 
     39!
    3740! 4559 2020-06-11 08:51:48Z raasch
    3841! file re-formatted to follow the PALM coding standard
     
    214217    CHARACTER (LEN=40)  ::  coupling_string          !< string containing type of coupling
    215218    CHARACTER (LEN=100) ::  action                   !< flag string
     219
     220    CHARACTER (LEN=varnamelength), DIMENSION(:), ALLOCATABLE ::  data_output_filtered  !< filtered list of output variables
    216221
    217222    INTEGER(iwp) ::  i                               !< loop index
     
    16351640
    16361641!
     1642!-- Check data-output variable list for any duplicates and remove them
     1643    ALLOCATE( data_output_filtered(1:UBOUND( data_output_pr, DIM=1 )) )
     1644    CALL filter_duplicate_strings( varnamelength, data_output_pr, data_output_filtered )
     1645    data_output_pr = data_output_filtered
     1646    DEALLOCATE( data_output_filtered )
     1647!
    16371648!-- Determine the number of output profiles and check whether they are permissible
    16381649    DO  WHILE ( data_output_pr(dopr_n+1) /= '          ' )
     
    22412252       ENDDO
    22422253    ENDIF
    2243 
     2254!
     2255!-- Check data-output variable list for any duplicates and remove them
     2256    ALLOCATE( data_output_filtered(1:UBOUND( data_output, DIM=1 )) )
     2257    CALL filter_duplicate_strings( varnamelength, data_output, data_output_filtered )
     2258    data_output = data_output_filtered
     2259    DEALLOCATE( data_output_filtered )
    22442260!
    22452261!-- Check and set steering parameters for 2d/3d data output and averaging
     
    32123228
    32133229
     3230!--------------------------------------------------------------------------------------------------!
     3231! Description:
     3232! ------------
     3233!> Filter a list of strings for duplicates. The output list is of same length but does not contain
     3234!> any duplicates.
     3235!--------------------------------------------------------------------------------------------------!
     3236
     3237    SUBROUTINE filter_duplicate_strings( string_length, string_list, string_list_filtered )
     3238
     3239       IMPLICIT NONE
     3240
     3241       INTEGER, INTENT(IN) :: string_length  !< length of a single string in list
     3242
     3243       CHARACTER (LEN=*),             DIMENSION(:), INTENT(IN)               ::  string_list           !< non-filtered list
     3244       CHARACTER (LEN=string_length), DIMENSION(:), INTENT(OUT), ALLOCATABLE ::  string_list_filtered  !< filtered list
     3245
     3246       CHARACTER (LEN=string_length) ::  string_to_check  !< string to be check for duplicates
     3247
     3248       INTEGER(iwp) ::  i         !< loop index
     3249       INTEGER(iwp) ::  j         !< loop index
     3250       INTEGER(iwp) ::  k         !< loop index
     3251       INTEGER(iwp) ::  nstrings  !< number of strings in list
     3252
     3253       LOGICAL ::  is_duplicate  !< true if string has duplicates in list
     3254
     3255
     3256       nstrings = UBOUND( string_list, DIM=1 )
     3257       ALLOCATE( string_list_filtered(1:nstrings) )
     3258       string_list_filtered(:) = ' '
     3259
     3260       k = 0
     3261       DO  i = 1, nstrings
     3262          string_to_check = string_list(i)
     3263
     3264          IF ( string_to_check == ' ' )  EXIT
     3265
     3266          is_duplicate = .FALSE.
     3267          DO  j = 1, nstrings
     3268             IF ( string_list_filtered(j) == ' ' )  THEN
     3269                EXIT
     3270             ELSEIF ( string_to_check == string_list_filtered(j) )  THEN
     3271                is_duplicate = .TRUE.
     3272                EXIT
     3273             ENDIF
     3274          ENDDO
     3275
     3276          IF ( .NOT. is_duplicate )  THEN
     3277             k = k + 1
     3278             string_list_filtered(k) = string_to_check
     3279          ENDIF
     3280
     3281       ENDDO
     3282
     3283    END SUBROUTINE filter_duplicate_strings
     3284
     3285
    32143286 END SUBROUTINE check_parameters
Note: See TracChangeset for help on using the changeset viewer.