Skip to content

Commit

Permalink
KAPPA: Prevent segv when using variance in MSTATS.
Browse files Browse the repository at this point in the history
KPS1_MSAGx only processes one array component at a time, so call
separately for DATA and VARIANCE components.  This could be changed,
but adding extra calls with distinct pointers in IPIN does the trick.
  • Loading branch information
MalcolmCurrie committed Aug 14, 2014
1 parent 108b11b commit 0923a21
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions applications/kappa/libkappa/mstats.f
Expand Up @@ -281,8 +281,8 @@ SUBROUTINE MSTATS( STATUS )
* Councils.
* Copyright (C) 2006 Particle Physics & Astronomy Research
* Council.
* Copyright (C) 2008, 2009, 2012 Science & Technology Facilities
* Council.
* Copyright (C) 2008, 2009, 2012, 2014, Science & Technology
* Facilities Council.
* All Rights Reserved.

* Licence:
Expand Down Expand Up @@ -335,6 +335,10 @@ SUBROUTINE MSTATS( STATUS )
* instead (set by the global MSG_FILTER environment variable).
* 2012 August 3 (MJC):
* Added "NGood", "NBad", "FGood", and "FBad" estimators.
* 2014 August 13 (MJC):
* Call KPS1_MSAGx separately for Data and Variance as this
* routine only processes one array component at a time.
* This preserves the pointer to the variance array.
* {enter_further_changes_here}

*-
Expand Down Expand Up @@ -699,11 +703,23 @@ SUBROUTINE MSTATS( STATUS )
* make an array one dimension larger, which is then collapsed.
* The routine returns the pointer to the mapped component.
IF ( ITYPE .EQ. '_DOUBLE' ) THEN
CALL KPS1_MSAGD( NNDF, %VAL( CNF_PVAL( IPNDF ) ), COMP,
: NDIM, IBLSIZ, IBLOCK, IPIN, STATUS )
CALL KPS1_MSAGD( NNDF, %VAL( CNF_PVAL( IPNDF ) ), 'Data',
: NDIM, IBLSIZ, IBLOCK, IPIN( 1 ),
: STATUS )
IF ( PVAR ) THEN
CALL KPS1_MSAGD( NNDF, %VAL( CNF_PVAL( IPNDF ) ),
: 'Variance', NDIM, IBLSIZ, IBLOCK,
: IPIN( 2 ), STATUS )
END IF
ELSE
CALL KPS1_MSAGR( NNDF, %VAL( CNF_PVAL( IPNDF ) ), COMP,
: NDIM, IBLSIZ, IBLOCK, IPIN, STATUS )
CALL KPS1_MSAGR( NNDF, %VAL( CNF_PVAL( IPNDF ) ), 'Data',
: NDIM, IBLSIZ, IBLOCK, IPIN( 1 ),
: STATUS )
IF ( PVAR ) THEN
CALL KPS1_MSAGR( NNDF, %VAL( CNF_PVAL( IPNDF ) ),
: 'Variance', NDIM, IBLSIZ, IBLOCK,
: IPIN( 2 ), STATUS )
END IF
END IF
CALL NDF_BLOCK( ONDF, NDIM, OBLSIZ, IBLOCK, OBL, STATUS )
Expand Down

0 comments on commit 0923a21

Please sign in to comment.