Skip to content

Commit

Permalink
Use single variable for string lengths
Browse files Browse the repository at this point in the history
  • Loading branch information
TomGoffrey committed Mar 19, 2021
1 parent 5261eb5 commit bcbfbfc
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/deck/strings.f90
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ END SUBROUTINE integer8_as_string
FUNCTION str_cmp(str_in, str_test)

CHARACTER(*), INTENT(IN) :: str_in, str_test
CHARACTER(LEN=string_length) :: str_trim
CHARACTER(LEN=c_max_string_length) :: str_trim
INTEGER :: test_len, in_len
LOGICAL :: str_cmp

Expand Down
4 changes: 2 additions & 2 deletions src/housekeeping/utilities.f90
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ END SUBROUTINE grow_integer_array

SUBROUTINE grow_string_array(array, idx)

CHARACTER(LEN=string_length), DIMENSION(:), POINTER :: array
CHARACTER(LEN=c_max_string_length), DIMENSION(:), POINTER :: array
INTEGER, INTENT(IN) :: idx
CHARACTER(LEN=string_length), DIMENSION(:), ALLOCATABLE :: tmp_array
CHARACTER(LEN=c_max_string_length), DIMENSION(:), ALLOCATABLE :: tmp_array
INTEGER :: old_size, new_size, i

old_size = SIZE(array)
Expand Down
13 changes: 5 additions & 8 deletions src/shared_data.F90
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,7 @@ MODULE constants
INTEGER, PARAMETER :: c_stagger_max = c_stagger_ex + c_stagger_bx

! Length of a standard string
! TODO Why so many different values here?
INTEGER, PARAMETER :: string_length = 256
INTEGER, PARAMETER :: c_max_string_length = 64
INTEGER, PARAMETER :: c_id_length = 32
INTEGER, PARAMETER :: c_max_string_length = 256

END MODULE constants

Expand All @@ -146,11 +143,11 @@ MODULE shared_data
!----------------------------------------------------------------------------
! string handling
!----------------------------------------------------------------------------
CHARACTER(LEN=string_length) :: blank
CHARACTER(LEN=c_max_string_length) :: blank
TYPE string_type
CHARACTER(string_length) :: value
CHARACTER(c_max_string_length) :: value
END TYPE string_type
CHARACTER(LEN=string_length) :: extended_error_string
CHARACTER(LEN=c_max_string_length) :: extended_error_string

!----------------------------------------------------------------------------
! Choice of problem set-up
Expand Down Expand Up @@ -206,7 +203,7 @@ MODULE shared_data
! Object representing a particle species
TYPE particle_species
! Core properties
CHARACTER(string_length) :: name
CHARACTER(c_max_string_length) :: name
TYPE(particle_species), POINTER :: next, prev
INTEGER :: id
INTEGER :: count_update_step
Expand Down

0 comments on commit bcbfbfc

Please sign in to comment.