Skip to content

Commit

Permalink
maint: globalized size of the VAR_TYPE string
Browse files Browse the repository at this point in the history
Now one can initialize the size of the var_type to VAR_TYPE_LENGTH

Signed-off-by: Nick Papior <[email protected]>
  • Loading branch information
zerothi committed Nov 29, 2018
1 parent c99d857 commit 00b7199
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/dictionary_pp.F90
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ module dictionary
! We could consider changing this to a variable size string
! However, that will increase the dependencies and will most likely not yield
! a better interface.
!> Maximum character length of the keys in the dictionary, no
!> Maximum character length of the keys in the dictionary, no
!! index/key can be longer than this.
integer, parameter, public :: DICT_KEY_LENGTH = 48

Expand Down Expand Up @@ -957,7 +957,7 @@ end function dict_kvp_var
function dict_key_which(this,key) result(t)
type(dict), intent(in) :: this
character(len=*), optional, intent(in) :: key
character(len=2) :: t
character(len=VAR_TYPE_LENGTH) :: t
type(dict) :: ld
integer :: hash, lhash

Expand Down
13 changes: 9 additions & 4 deletions src/variable_pp.F90
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,12 @@ module variable
! To create a constant transfer data-type of the
! pointer methods
character(len=1) :: local_enc_type(1)


! Internal variable to hold the size of the "type" switch
!> Maximum character length of the type specifier in the variable, no
!! unique identifier may be longer than this.
integer, parameter, public :: VAR_TYPE_LENGTH = 4

type :: var
!! Container for _any_ fortran data-type, intrinsically handles all
!! from fortran and any external type may be added via external routines.
Expand All @@ -51,14 +56,14 @@ module variable
!! This enables one to retrieve the pointer position later and thus enables
!! pointer assignments and easy copying of data.

character(len=4) :: t = ' '
character(len=VAR_TYPE_LENGTH) :: t = ' '
! The encoding placement of all data
character(len=1), dimension(:), allocatable :: enc
end type var
public :: var

interface which
!! Type of content stored in the variable (`character(len=4)`)
!! Type of content stored in the variable (`character(len=VAR_TYPE_LENGTH)`)
module procedure which_
end interface
public :: which
Expand Down Expand Up @@ -158,7 +163,7 @@ end subroutine print_

elemental function which_(this) result(t)
type(var), intent(in) :: this
character(len=4) :: t
character(len=VAR_TYPE_LENGTH) :: t
t = this%t
end function which_

Expand Down

0 comments on commit 00b7199

Please sign in to comment.