Skip to content
Snippets Groups Projects
Commit 5a6c47be authored by WAUTELET Philippe's avatar WAUTELET Philippe
Browse files

Philippe 22/09/2023: sensors: Compute_vertical_interp_coeff: better treatment...

Philippe 22/09/2023: sensors: Compute_vertical_interp_coeff: better treatment of too high positions (could access out of bound arrays in some cases)
parent 7fddd50e
No related branches found
No related tags found
No related merge requests found
...@@ -380,7 +380,6 @@ MODULE MODD_SENSOR ...@@ -380,7 +380,6 @@ MODULE MODD_SENSOR
INTEGER :: IK00, IK01, IK10, IK11 INTEGER :: IK00, IK01, IK10, IK11
INTEGER :: IKB, IKE, IKU INTEGER :: IKB, IKE, IKU
INTEGER :: JI, JJ INTEGER :: JI, JJ
LOGICAL :: GCHANGE ! set to true if at least an index has been forced to change
LOGICAL :: GDONE ! set to true if coefficient computation has been done LOGICAL :: GDONE ! set to true if coefficient computation has been done
LOGICAL :: GDONOLOWCRASH LOGICAL :: GDONOLOWCRASH
REAL :: ZZCOEF00, ZZCOEF01, ZZCOEF10, ZZCOEF11 REAL :: ZZCOEF00, ZZCOEF01, ZZCOEF10, ZZCOEF11
...@@ -388,7 +387,6 @@ MODULE MODD_SENSOR ...@@ -388,7 +387,6 @@ MODULE MODD_SENSOR
OLOW = .FALSE. OLOW = .FALSE.
OHIGH = .FALSE. OHIGH = .FALSE.
GCHANGE = .FALSE.
GDONE = .FALSE. GDONE = .FALSE.
IKB = 1 + JPVEXT IKB = 1 + JPVEXT
...@@ -419,9 +417,9 @@ MODULE MODD_SENSOR ...@@ -419,9 +417,9 @@ MODULE MODD_SENSOR
IF ( ANY( [ IK00, IK01, IK10, IK11 ] < IKB ) ) THEN IF ( ANY( [ IK00, IK01, IK10, IK11 ] < IKB ) ) THEN
! Sensor is low (too near the ground or below it) ! Sensor is low (too near the ground or below it)
OLOW = .TRUE. OLOW = .TRUE.
IF ( GDONOLOWCRASH ) THEN IF ( GDONOLOWCRASH ) THEN
! Do not allow crash on the ground: set position on the ground if too low ! Do not allow crash on the ground: set position on the ground if too low
GCHANGE = .TRUE.
!Minimum altitude is on the ground at ikb (no crash if too low) !Minimum altitude is on the ground at ikb (no crash if too low)
IK00 = MAX ( IK00, IKB ) IK00 = MAX ( IK00, IKB )
IK01 = MAX ( IK01, IKB ) IK01 = MAX ( IK01, IKB )
...@@ -454,25 +452,20 @@ MODULE MODD_SENSOR ...@@ -454,25 +452,20 @@ MODULE MODD_SENSOR
OHIGH = .TRUE. OHIGH = .TRUE.
! Limit ik?? indices to prevent out of bound accesses ! Limit ik?? indices to prevent out of bound accesses
IF ( IK00 > IKU-1) THEN IK00 = MIN( IK00, IKE )
IK00 = IKU-1 IK01 = MIN( IK01, IKE )
GCHANGE = .TRUE. IK10 = MIN( IK10, IKE )
END IF IK11 = MIN( IK11, IKE )
IF ( IK01 > IKU-1) THEN
IK01 = IKU-1
GCHANGE = .TRUE.
END IF
IF ( IK10 > IKU-1) THEN
IK10 = IKU-1
GCHANGE = .TRUE.
END IF
IF ( IK11 > IKU-1) THEN
IK11 = IKU-1
GCHANGE = .TRUE.
END IF
CALL PRINT_MSG( NVERB_WARNING, 'GEN', 'Compute_vertical_interp_coeff', & CALL PRINT_MSG( NVERB_WARNING, 'GEN', 'Compute_vertical_interp_coeff', &
'sensor ' // TRIM( TPSENSOR%CNAME ) // ' is too high', OLOCAL = .TRUE. ) 'sensor ' // TRIM( TPSENSOR%CNAME ) // ' is too high', OLOCAL = .TRUE. )
ZZCOEF00 = XUNDEF
ZZCOEF01 = XUNDEF
ZZCOEF10 = XUNDEF
ZZCOEF11 = XUNDEF
GDONE = .TRUE.
END IF END IF
IF ( .NOT. GDONE ) THEN IF ( .NOT. GDONE ) THEN
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment