Skip to content

Commit ff33f38

Browse files
authored
Fix core uninitialized values causing undefined behavior (wrf-model#2300)
TYPE: bugfix KEYWORDS: uninitialized SOURCE: internal DESCRIPTION OF CHANGES: Problem: The domain type `fieldlist` is a derived type used to store state vars within the `grid`. Thus, this type facilitates many of the read, write, and general control of state variables defined within the registry. Throughout the code, character fields such as `MemoryOrder` are accessed and read to determine branching logic for how a particular state var should be handled. Not all fields are required to be defined within the registry, and this leads to uninitialized values within a newly created instance of `fieldlist`. Solution: Rather than correcting the registry generated code that assigns state vars, a better solution is to fix the upstream type definition to always start with initialized default vales. This fixes sporadic undefined behavior arising from accessing these fields, sometimes resulting in total model crash or indefinite hangs as MPI synchronization calls take different branching logic.
1 parent f315dce commit ff33f38

1 file changed

Lines changed: 11 additions & 11 deletions

File tree

frame/module_domain_type.F

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,17 @@ MODULE module_domain_type
4545
END TYPE tile_zone
4646

4747
TYPE fieldlist
48-
CHARACTER*80 :: VarName
49-
CHARACTER*1 :: Type
50-
CHARACTER*1 :: ProcOrient ! 'X' 'Y' or ' ' (X, Y, or non-transposed)
51-
CHARACTER*80 :: DataName
52-
CHARACTER*80 :: Description
53-
CHARACTER*80 :: Units
54-
CHARACTER*10 :: MemoryOrder
55-
CHARACTER*10 :: Stagger
56-
CHARACTER*80 :: dimname1
57-
CHARACTER*80 :: dimname2
58-
CHARACTER*80 :: dimname3
48+
CHARACTER*80 :: VarName = ''
49+
CHARACTER*1 :: Type = ''
50+
CHARACTER*1 :: ProcOrient = '' ! 'X' 'Y' or ' ' (X, Y, or non-transposed)
51+
CHARACTER*80 :: DataName = ''
52+
CHARACTER*80 :: Description = ''
53+
CHARACTER*80 :: Units = ''
54+
CHARACTER*10 :: MemoryOrder = ''
55+
CHARACTER*10 :: Stagger = ''
56+
CHARACTER*80 :: dimname1 = ''
57+
CHARACTER*80 :: dimname2 = ''
58+
CHARACTER*80 :: dimname3 = ''
5959
LOGICAL :: scalar_array
6060
LOGICAL :: boundary_array
6161
LOGICAL :: restart

0 commit comments

Comments
 (0)