diff --git a/.gitignore b/.gitignore index 52f276a..84dde64 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,7 @@ release.properties dependency-reduced-pom.xml buildNumber.properties .mvn/timing.properties +*.log # Avoid ignoring Maven wrapper jar file (.jar files are usually ignored) !/.mvn/wrapper/maven-wrapper.jar @@ -29,4 +30,4 @@ buildNumber.properties # Ignore IntelliJ files .idea *.iml -.vscode \ No newline at end of file +.vscode diff --git a/it/Dockerfile-auditor b/it/Dockerfile-auditor new file mode 100644 index 0000000..e2ef879 --- /dev/null +++ b/it/Dockerfile-auditor @@ -0,0 +1,36 @@ +ARG SCANNER_VERSION=latest +FROM sonarsource/sonar-scanner-cli:${SCANNER_VERSION} AS builder + +FROM eclipse-temurin:21-jre-alpine + +ARG SONAR_SCANNER_HOME=/opt/sonar-scanner +ENV HOME=/tmp \ + SONAR_SCANNER_HOME=${SONAR_SCANNER_HOME} \ + XDG_CONFIG_HOME=/tmp \ + SONAR_USER_HOME=${SONAR_SCANNER_HOME}/.sonar \ + PATH=${SONAR_SCANNER_HOME}/bin:${PATH} \ + SRC_PATH=/usr/src \ + LANG=C.UTF-8 \ + LC_ALL=C.UTF-8 \ + PYTHONUNBUFFERED=1 + +WORKDIR /usr/src/myapp/it + +USER root +# Copy Scanner installation from builder image +COPY --from=builder /opt/sonar-scanner /opt/sonar-scanner + + +RUN apk update --no-cache && \ + apk add --update --no-cache -q curl gcc jq libffi-dev musl-dev openssl-dev python3 py3-requests shellcheck + +RUN set -eux && \ + addgroup --gid 1000 scanner-cli && \ + adduser --uid 1000 --ingroup scanner-cli --disabled-password --no-create-home --gecos "" scanner-cli && \ + mkdir -p "${SRC_PATH}" "${SONAR_USER_HOME}" "${SONAR_USER_HOME}/cache" && \ + chown -R scanner-cli:scanner-cli "${SONAR_SCANNER_HOME}" "${SRC_PATH}" && \ + chmod -R 555 "${SONAR_SCANNER_HOME}" && \ + chmod -R 754 "${SRC_PATH}" "${SONAR_USER_HOME}" + +USER scanner-cli +COPY --chown=scanner-cli:scanner-cli it /usr/src/myapp/it diff --git a/it/audit.sh b/it/audit.sh new file mode 100644 index 0000000..2390de2 --- /dev/null +++ b/it/audit.sh @@ -0,0 +1,90 @@ +#!/bin/sh -e + +# ---------------------------------- +# Colors +# ---------------------------------- +NOCOLOR='\033[0m' +RED='\033[0;31m' +GREEN='\033[0;32m' +ORANGE='\033[0;33m' + +# Function to get value from a property file +# arg 1 = the property +# arg 2 = the file path +function prop { + grep "${1}" ${2} | cut -d'=' -f2 +} + +# Configure sonar-scanner +export SONAR_HOST_URL="http://sonarqube:9000" +export SONAR_ADMIN_LOGIN="admin" +export SONAR_ADMIN_PWD="admin" + +# Generate Analysis token +echo "Generating analysis token..." +# Use an UUID for token name. It's useful to launch the audit several time on the same SonarQube execution +uuid=$(cat /proc/sys/kernel/random/uuid) +export SONAR_TOKEN=$(curl -su "$SONAR_ADMIN_LOGIN:$SONAR_ADMIN_PWD" -XPOST "$SONAR_HOST_URL/api/user_tokens/generate?name=$uuid&type=GLOBAL_ANALYSIS_TOKEN" | jq -r '.token') +echo $SONAR_TOKEN +# Audit code +echo "Launching scanner..." +cd /usr/src/myapp/it +sonar-scanner -X -Dsonar.qualitygate.wait 2>&1 | tee /tmp/scanner.log + +if [ $? -ne 0 ] +then + echo "${RED}Error scanning Shell scripts${NOCOLOR}" >&2 + exit 1 +fi + +# Check for warnings +if grep -q "^WARN: " /tmp/scanner.log +then + echo -e "${ORANGE}Warnings found ${NOCOLOR}" >&2 + exit 1 +fi + +# Sleep a little because SonarQube needs some time to ingest the audit results +sleep 10 + +export SONAR_PROJECT_KEY=$(prop 'sonar.projectKey' sonar-project.properties) +echo "SONAR_PROJECT_KEY: $SONAR_PROJECT_KEY" + +# Check audit result +echo "Checking result..." +python3 << EOF +from __future__ import print_function +import requests +import sys + +r = requests.get('http://sonarqube:9000/api/issues/search?componentKeys=$SONAR_PROJECT_KEY:src/clanhb.f&statuses=OPEN', auth=('$SONAR_ADMIN_LOGIN', '$SONAR_ADMIN_PWD')) +if r.status_code != 200: + print('Invalid server response: ' + str(r.status_code), file=sys.stderr) + sys.exit(1) + +data = r.json() + +if data['total'] != 100: + print('Wrong total number of issues: ' + str(data['total']), file=sys.stderr) + sys.exit(1) + +issues = 0 +if 'f77-rules' in data['issues'][0]['rule'] and data['issues'][0]['line'] == 1: + issues += 1 + +r = requests.get('http://sonarqube:9000/api/issues/search?componentKeys=$SONAR_PROJECT_KEY:src/clanhb.f90&statuses=OPEN', auth=('$SONAR_ADMIN_LOGIN', '$SONAR_ADMIN_PWD')) +if r.status_code != 200: + print('Invalid server response: ' + str(r.status_code), file=sys.stderr) + sys.exit(1) + +data = r.json() + +if data['total'] != 197: + print('Wrong total number of issues: ' + str(data['total']), file=sys.stderr) + sys.exit(1) +if 'f90-rules' in data['issues'][0]['rule'] and data['issues'][0]['line'] == 1: + issues += 1 + + +sys.exit(0 if issues == 2 else 1) +EOF diff --git a/it/docker-compose.yml b/it/docker-compose.yml new file mode 100644 index 0000000..4ed1617 --- /dev/null +++ b/it/docker-compose.yml @@ -0,0 +1,23 @@ +--- +services: + sonarqube: + image: sonarqube:${SONARQUBE_VERSION:-community} + ports: + - "9000:9000" + environment: + ES_JAVA_OPTS: "-Xms750m -Xmx750m" + SONARQUBE_VERSION: ${SONARQUBE_VERSION:-community} + security_opt: + - seccomp:unconfined + auditor: + image: auditor:${SCANNER_VERSION:-latest} + build: + context: .. + dockerfile: it/Dockerfile-auditor + args: + SCANNER_VERSION: ${SCANNER_VERSION:-latest} + links: + - sonarqube + command: /bin/sh -e /usr/src/myapp/it/audit.sh + environment: + SCANNER_VERSION: ${SCANNER_VERSION:-latest} diff --git a/it/it.sh b/it/it.sh new file mode 100755 index 0000000..e2ad0ad --- /dev/null +++ b/it/it.sh @@ -0,0 +1,93 @@ +#!/bin/bash + +usage(){ + echo -e "\nUsage: $0 [sSh] \n" + echo "-h : Display help" + echo "-s [SONAR-SCANNER] : Take Sonar-scanner tag image from https://hub.docker.com/r/sonarsource/sonar-scanner-cli" + echo "-S [SONARQUBE] : Take SonarQube tag image from https://hub.docker.com/_/sonarqube" +} + +OPTSTRING=":s:S:h" + +while getopts ${OPTSTRING} opt; do + case ${opt} in + s) + export SCANNER_VERSION=$OPTARG + ;; + S) + export SONARQUBE_VERSION=$OPTARG + ;; + h) + usage + exit 0 + ;; + :) + echo "Option -${OPTARG} requires an argument." + usage + exit 1 + ;; + ?) + echo "Invalid option: -${OPTARG}." + usage + exit 1 + ;; + esac +done + + +export SCRIPT_DIR=`dirname $0` + +# Clean-up if needed +echo "Cleanup..." +docker-compose -f $SCRIPT_DIR/docker-compose.yml down + +# Start containers +echo "Starting SonarQube..." +docker-compose -f $SCRIPT_DIR/docker-compose.yml up -d sonarqube +CONTAINER_NAME=$(docker ps --format "{{.Names}}" | grep 'it-sonarqube-1.*' | head -1) +# Wait for SonarQube to be up +grep -q "SonarQube is operational" <(docker logs --follow --tail 0 $CONTAINER_NAME) +echo "SonarQube started!" + +# Copy the plugins +MAVEN_VERSION=$(grep '' $SCRIPT_DIR/../pom.xml | head -1 | sed 's/<\/\?version>//g'| awk '{print $1}') +echo "Installing the plugin Icode version $MAVEN_VERSION" +docker cp $SCRIPT_DIR/../target/sonar-icode-cnes-plugin-$MAVEN_VERSION.jar $CONTAINER_NAME:/opt/sonarqube/extensions/plugins +# Restart SonarQube +docker-compose -f $SCRIPT_DIR/docker-compose.yml restart sonarqube +# Wait for SonarQube to be up +grep -q "SonarQube is operational" <(docker logs --follow --tail 0 $CONTAINER_NAME) +# Check plug-in installation +docker exec -u root $CONTAINER_NAME bash -c "if grep -q Alpine /etc/issue; then apk update && apk add -q curl; fi" +docker exec -u root $CONTAINER_NAME bash -c "if grep -q Ubuntu /etc/issue; then apt-get update && apt-get install -y curl; fi" +if ! docker exec $CONTAINER_NAME curl -su admin:admin http://localhost:9000/api/plugins/installed | python -c ' +import sys +import json +plugins_count = 0 +plugins_expected = ["icode"] +data = json.loads(sys.stdin.read()) +if "plugins" in data: + for plugin in data["plugins"]: + if plugin["key"] in plugins_expected: + plugins_count += 1 +if plugins_count == len(plugins_expected): + sys.exit(0) +else: + sys.exit(1) +' +then + echo "Plugin not installed" >&2 + exit 1 +fi +echo "Plugin successfully installed!" + +# Audit code +echo "Audit test scripts..." +docker-compose -f $SCRIPT_DIR/docker-compose.yml up --build --exit-code-from auditor auditor +AUDIT_STATUS=$? + +# Delete containers +echo "Cleanup..." +docker-compose -f $SCRIPT_DIR/docker-compose.yml down + +exit $AUDIT_STATUS diff --git a/it/sonar-project.properties b/it/sonar-project.properties new file mode 100644 index 0000000..a75cfbb --- /dev/null +++ b/it/sonar-project.properties @@ -0,0 +1,5 @@ +sonar.projectKey=icode +sonar.projectName=I-Code +sonar.projectVersion=1.0 +sonar.sources=src +sonar.scm.disabled=True diff --git a/it/src/clanhb.f b/it/src/clanhb.f new file mode 100644 index 0000000..4ee7209 --- /dev/null +++ b/it/src/clanhb.f @@ -0,0 +1,276 @@ +*> \brief \b CLANHB returns the value of the 1-norm, or the Frobenius norm, or the infinity norm, or the element of largest absolute value of a Hermitian band matrix. +* +* =========== DOCUMENTATION =========== +* +* Online html documentation available at +* http://www.netlib.org/lapack/explore-html/ +* +*> \htmlonly +*> Download CLANHB + dependencies +*> +*> [TGZ] +*> +*> [ZIP] +*> +*> [TXT] +*> \endhtmlonly +* +* Definition: +* =========== +* +* REAL FUNCTION CLANHB( NORM, UPLO, N, K, AB, LDAB, +* WORK ) +* +* .. Scalar Arguments .. +* CHARACTER NORM, UPLO +* INTEGER K, LDAB, N +* .. +* .. Array Arguments .. +* REAL WORK( * ) +* COMPLEX AB( LDAB, * ) +* .. +* +* +*> \par Purpose: +* ============= +*> +*> \verbatim +*> +*> CLANHB returns the value of the one norm, or the Frobenius norm, or +*> the infinity norm, or the element of largest absolute value of an +*> n by n hermitian band matrix A, with k super-diagonals. +*> \endverbatim +*> +*> \return CLANHB +*> \verbatim +*> +*> CLANHB = ( max(abs(A(i,j))), NORM = 'M' or 'm' +*> ( +*> ( norm1(A), NORM = '1', 'O' or 'o' +*> ( +*> ( normI(A), NORM = 'I' or 'i' +*> ( +*> ( normF(A), NORM = 'F', 'f', 'E' or 'e' +*> +*> where norm1 denotes the one norm of a matrix (maximum column sum), +*> normI denotes the infinity norm of a matrix (maximum row sum) and +*> normF denotes the Frobenius norm of a matrix (square root of sum of +*> squares). Note that max(abs(A(i,j))) is not a consistent matrix norm. +*> \endverbatim +* +* Arguments: +* ========== +* +*> \param[in] NORM +*> \verbatim +*> NORM is CHARACTER*1 +*> Specifies the value to be returned in CLANHB as described +*> above. +*> \endverbatim +*> +*> \param[in] UPLO +*> \verbatim +*> UPLO is CHARACTER*1 +*> Specifies whether the upper or lower triangular part of the +*> band matrix A is supplied. +*> = 'U': Upper triangular +*> = 'L': Lower triangular +*> \endverbatim +*> +*> \param[in] N +*> \verbatim +*> N is INTEGER +*> The order of the matrix A. N >= 0. When N = 0, CLANHB is +*> set to zero. +*> \endverbatim +*> +*> \param[in] K +*> \verbatim +*> K is INTEGER +*> The number of super-diagonals or sub-diagonals of the +*> band matrix A. K >= 0. +*> \endverbatim +*> +*> \param[in] AB +*> \verbatim +*> AB is COMPLEX array, dimension (LDAB,N) +*> The upper or lower triangle of the hermitian band matrix A, +*> stored in the first K+1 rows of AB. The j-th column of A is +*> stored in the j-th column of the array AB as follows: +*> if UPLO = 'U', AB(k+1+i-j,j) = A(i,j) for max(1,j-k)<=i<=j; +*> if UPLO = 'L', AB(1+i-j,j) = A(i,j) for j<=i<=min(n,j+k). +*> Note that the imaginary parts of the diagonal elements need +*> not be set and are assumed to be zero. +*> \endverbatim +*> +*> \param[in] LDAB +*> \verbatim +*> LDAB is INTEGER +*> The leading dimension of the array AB. LDAB >= K+1. +*> \endverbatim +*> +*> \param[out] WORK +*> \verbatim +*> WORK is REAL array, dimension (MAX(1,LWORK)), +*> where LWORK >= N when NORM = 'I' or '1' or 'O'; otherwise, +*> WORK is not referenced. +*> \endverbatim +* +* Authors: +* ======== +* +*> \author Univ. of Tennessee +*> \author Univ. of California Berkeley +*> \author Univ. of Colorado Denver +*> \author NAG Ltd. +* +*> \date September 2012 +* +*> \ingroup complexOTHERauxiliary +* +* ===================================================================== + REAL FUNCTION CLANHB( NORM, UPLO, N, K, AB, LDAB, + $ WORK ) +* +* -- LAPACK auxiliary routine (version 3.4.2) -- +* -- LAPACK is a software package provided by Univ. of Tennessee, -- +* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- +* September 2012 +* +* .. Scalar Arguments .. + CHARACTER NORM, UPLO + INTEGER K, LDAB, N +* .. +* .. Array Arguments .. + REAL WORK( * ) + COMPLEX AB( LDAB, * ) +* .. +* +* ===================================================================== +* +* .. Parameters .. + REAL ONE, ZERO + PARAMETER ( ONE = 1.0E+0, ZERO = 0.0E+0 ) +* .. +* .. Local Scalars .. + INTEGER I, J, L + REAL ABSA, SCALE, SUM, VALUE +* .. +* .. External Functions .. + LOGICAL LSAME, SISNAN + EXTERNAL LSAME, SISNAN +* .. +* .. External Subroutines .. + EXTERNAL CLASSQ +* .. +* .. Intrinsic Functions .. + INTRINSIC ABS, MAX, MIN, REAL, SQRT +* .. +* .. Executable Statements .. +* + IF( N.EQ.0 ) THEN + VALUE = ZERO + ELSE IF( LSAME( NORM, 'M' ) ) THEN +* +* Find max(abs(A(i,j))). +* + VALUE = ZERO + IF( LSAME( UPLO, 'U' ) ) THEN + DO 20 J = 1, N + DO 10 I = MAX( K+2-J, 1 ), K + SUM = ABS( AB( I, J ) ) + IF( VALUE .LT. SUM .OR. SISNAN( SUM ) ) VALUE = SUM + 10 CONTINUE + SUM = ABS( REAL( AB( K+1, J ) ) ) + IF( VALUE .LT. SUM .OR. SISNAN( SUM ) ) VALUE = SUM + 20 CONTINUE + ELSE + DO 40 J = 1, N + SUM = ABS( REAL( AB( 1, J ) ) ) + IF( VALUE .LT. SUM .OR. SISNAN( SUM ) ) VALUE = SUM + DO 30 I = 2, MIN( N+1-J, K+1 ) + SUM = ABS( AB( I, J ) ) + IF( VALUE .LT. SUM .OR. SISNAN( SUM ) ) VALUE = SUM + 30 CONTINUE + 40 CONTINUE + END IF + ELSE IF( ( LSAME( NORM, 'I' ) ) .OR. ( LSAME( NORM, 'O' ) ) .OR. + $ ( NORM.EQ.'1' ) ) THEN +* +* Find normI(A) ( = norm1(A), since A is hermitian). +* + VALUE = ZERO + IF( LSAME( UPLO, 'U' ) ) THEN + DO 60 J = 1, N + SUM = ZERO + L = K + 1 - J + DO 50 I = MAX( 1, J-K ), J - 1 + ABSA = ABS( AB( L+I, J ) ) + SUM = SUM + ABSA + WORK( I ) = WORK( I ) + ABSA + 50 CONTINUE + WORK( J ) = SUM + ABS( REAL( AB( K+1, J ) ) ) + 60 CONTINUE + DO 70 I = 1, N + SUM = WORK( I ) + IF( VALUE .LT. SUM .OR. SISNAN( SUM ) ) VALUE = SUM + 70 CONTINUE + ELSE + DO 80 I = 1, N + WORK( I ) = ZERO + 80 CONTINUE + DO 100 J = 1, N + SUM = WORK( J ) + ABS( REAL( AB( 1, J ) ) ) + L = 1 - J + DO 90 I = J + 1, MIN( N, J+K ) + ABSA = ABS( AB( L+I, J ) ) + SUM = SUM + ABSA + WORK( I ) = WORK( I ) + ABSA + 90 CONTINUE + IF( VALUE .LT. SUM .OR. SISNAN( SUM ) ) VALUE = SUM + 100 CONTINUE + END IF + ELSE IF( ( LSAME( NORM, 'F' ) ) .OR. ( LSAME( NORM, 'E' ) ) ) THEN +* +* Find normF(A). +* + SCALE = ZERO + SUM = ONE + IF( K.GT.0 ) THEN + IF( LSAME( UPLO, 'U' ) ) THEN + DO 110 J = 2, N + CALL CLASSQ( MIN( J-1, K ), AB( MAX( K+2-J, 1 ), J ), + $ 1, SCALE, SUM ) + 110 CONTINUE + L = K + 1 + ELSE + DO 120 J = 1, N - 1 + CALL CLASSQ( MIN( N-J, K ), AB( 2, J ), 1, SCALE, + $ SUM ) + 120 CONTINUE + L = 1 + END IF + SUM = 2*SUM + ELSE + L = 1 + END IF + DO 130 J = 1, N + IF( REAL( AB( L, J ) ).NE.ZERO ) THEN + ABSA = ABS( REAL( AB( L, J ) ) ) + IF( SCALE.LT.ABSA ) THEN + SUM = ONE + SUM*( SCALE / ABSA )**2 + SCALE = ABSA + ELSE + SUM = SUM + ( ABSA / SCALE )**2 + END IF + END IF + 130 CONTINUE + VALUE = SCALE*SQRT( SUM ) + END IF +* + CLANHB = VALUE + RETURN +* +* End of CLANHB +* + END diff --git a/it/src/clanhb.f90 b/it/src/clanhb.f90 new file mode 100644 index 0000000..4ee7209 --- /dev/null +++ b/it/src/clanhb.f90 @@ -0,0 +1,276 @@ +*> \brief \b CLANHB returns the value of the 1-norm, or the Frobenius norm, or the infinity norm, or the element of largest absolute value of a Hermitian band matrix. +* +* =========== DOCUMENTATION =========== +* +* Online html documentation available at +* http://www.netlib.org/lapack/explore-html/ +* +*> \htmlonly +*> Download CLANHB + dependencies +*> +*> [TGZ] +*> +*> [ZIP] +*> +*> [TXT] +*> \endhtmlonly +* +* Definition: +* =========== +* +* REAL FUNCTION CLANHB( NORM, UPLO, N, K, AB, LDAB, +* WORK ) +* +* .. Scalar Arguments .. +* CHARACTER NORM, UPLO +* INTEGER K, LDAB, N +* .. +* .. Array Arguments .. +* REAL WORK( * ) +* COMPLEX AB( LDAB, * ) +* .. +* +* +*> \par Purpose: +* ============= +*> +*> \verbatim +*> +*> CLANHB returns the value of the one norm, or the Frobenius norm, or +*> the infinity norm, or the element of largest absolute value of an +*> n by n hermitian band matrix A, with k super-diagonals. +*> \endverbatim +*> +*> \return CLANHB +*> \verbatim +*> +*> CLANHB = ( max(abs(A(i,j))), NORM = 'M' or 'm' +*> ( +*> ( norm1(A), NORM = '1', 'O' or 'o' +*> ( +*> ( normI(A), NORM = 'I' or 'i' +*> ( +*> ( normF(A), NORM = 'F', 'f', 'E' or 'e' +*> +*> where norm1 denotes the one norm of a matrix (maximum column sum), +*> normI denotes the infinity norm of a matrix (maximum row sum) and +*> normF denotes the Frobenius norm of a matrix (square root of sum of +*> squares). Note that max(abs(A(i,j))) is not a consistent matrix norm. +*> \endverbatim +* +* Arguments: +* ========== +* +*> \param[in] NORM +*> \verbatim +*> NORM is CHARACTER*1 +*> Specifies the value to be returned in CLANHB as described +*> above. +*> \endverbatim +*> +*> \param[in] UPLO +*> \verbatim +*> UPLO is CHARACTER*1 +*> Specifies whether the upper or lower triangular part of the +*> band matrix A is supplied. +*> = 'U': Upper triangular +*> = 'L': Lower triangular +*> \endverbatim +*> +*> \param[in] N +*> \verbatim +*> N is INTEGER +*> The order of the matrix A. N >= 0. When N = 0, CLANHB is +*> set to zero. +*> \endverbatim +*> +*> \param[in] K +*> \verbatim +*> K is INTEGER +*> The number of super-diagonals or sub-diagonals of the +*> band matrix A. K >= 0. +*> \endverbatim +*> +*> \param[in] AB +*> \verbatim +*> AB is COMPLEX array, dimension (LDAB,N) +*> The upper or lower triangle of the hermitian band matrix A, +*> stored in the first K+1 rows of AB. The j-th column of A is +*> stored in the j-th column of the array AB as follows: +*> if UPLO = 'U', AB(k+1+i-j,j) = A(i,j) for max(1,j-k)<=i<=j; +*> if UPLO = 'L', AB(1+i-j,j) = A(i,j) for j<=i<=min(n,j+k). +*> Note that the imaginary parts of the diagonal elements need +*> not be set and are assumed to be zero. +*> \endverbatim +*> +*> \param[in] LDAB +*> \verbatim +*> LDAB is INTEGER +*> The leading dimension of the array AB. LDAB >= K+1. +*> \endverbatim +*> +*> \param[out] WORK +*> \verbatim +*> WORK is REAL array, dimension (MAX(1,LWORK)), +*> where LWORK >= N when NORM = 'I' or '1' or 'O'; otherwise, +*> WORK is not referenced. +*> \endverbatim +* +* Authors: +* ======== +* +*> \author Univ. of Tennessee +*> \author Univ. of California Berkeley +*> \author Univ. of Colorado Denver +*> \author NAG Ltd. +* +*> \date September 2012 +* +*> \ingroup complexOTHERauxiliary +* +* ===================================================================== + REAL FUNCTION CLANHB( NORM, UPLO, N, K, AB, LDAB, + $ WORK ) +* +* -- LAPACK auxiliary routine (version 3.4.2) -- +* -- LAPACK is a software package provided by Univ. of Tennessee, -- +* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- +* September 2012 +* +* .. Scalar Arguments .. + CHARACTER NORM, UPLO + INTEGER K, LDAB, N +* .. +* .. Array Arguments .. + REAL WORK( * ) + COMPLEX AB( LDAB, * ) +* .. +* +* ===================================================================== +* +* .. Parameters .. + REAL ONE, ZERO + PARAMETER ( ONE = 1.0E+0, ZERO = 0.0E+0 ) +* .. +* .. Local Scalars .. + INTEGER I, J, L + REAL ABSA, SCALE, SUM, VALUE +* .. +* .. External Functions .. + LOGICAL LSAME, SISNAN + EXTERNAL LSAME, SISNAN +* .. +* .. External Subroutines .. + EXTERNAL CLASSQ +* .. +* .. Intrinsic Functions .. + INTRINSIC ABS, MAX, MIN, REAL, SQRT +* .. +* .. Executable Statements .. +* + IF( N.EQ.0 ) THEN + VALUE = ZERO + ELSE IF( LSAME( NORM, 'M' ) ) THEN +* +* Find max(abs(A(i,j))). +* + VALUE = ZERO + IF( LSAME( UPLO, 'U' ) ) THEN + DO 20 J = 1, N + DO 10 I = MAX( K+2-J, 1 ), K + SUM = ABS( AB( I, J ) ) + IF( VALUE .LT. SUM .OR. SISNAN( SUM ) ) VALUE = SUM + 10 CONTINUE + SUM = ABS( REAL( AB( K+1, J ) ) ) + IF( VALUE .LT. SUM .OR. SISNAN( SUM ) ) VALUE = SUM + 20 CONTINUE + ELSE + DO 40 J = 1, N + SUM = ABS( REAL( AB( 1, J ) ) ) + IF( VALUE .LT. SUM .OR. SISNAN( SUM ) ) VALUE = SUM + DO 30 I = 2, MIN( N+1-J, K+1 ) + SUM = ABS( AB( I, J ) ) + IF( VALUE .LT. SUM .OR. SISNAN( SUM ) ) VALUE = SUM + 30 CONTINUE + 40 CONTINUE + END IF + ELSE IF( ( LSAME( NORM, 'I' ) ) .OR. ( LSAME( NORM, 'O' ) ) .OR. + $ ( NORM.EQ.'1' ) ) THEN +* +* Find normI(A) ( = norm1(A), since A is hermitian). +* + VALUE = ZERO + IF( LSAME( UPLO, 'U' ) ) THEN + DO 60 J = 1, N + SUM = ZERO + L = K + 1 - J + DO 50 I = MAX( 1, J-K ), J - 1 + ABSA = ABS( AB( L+I, J ) ) + SUM = SUM + ABSA + WORK( I ) = WORK( I ) + ABSA + 50 CONTINUE + WORK( J ) = SUM + ABS( REAL( AB( K+1, J ) ) ) + 60 CONTINUE + DO 70 I = 1, N + SUM = WORK( I ) + IF( VALUE .LT. SUM .OR. SISNAN( SUM ) ) VALUE = SUM + 70 CONTINUE + ELSE + DO 80 I = 1, N + WORK( I ) = ZERO + 80 CONTINUE + DO 100 J = 1, N + SUM = WORK( J ) + ABS( REAL( AB( 1, J ) ) ) + L = 1 - J + DO 90 I = J + 1, MIN( N, J+K ) + ABSA = ABS( AB( L+I, J ) ) + SUM = SUM + ABSA + WORK( I ) = WORK( I ) + ABSA + 90 CONTINUE + IF( VALUE .LT. SUM .OR. SISNAN( SUM ) ) VALUE = SUM + 100 CONTINUE + END IF + ELSE IF( ( LSAME( NORM, 'F' ) ) .OR. ( LSAME( NORM, 'E' ) ) ) THEN +* +* Find normF(A). +* + SCALE = ZERO + SUM = ONE + IF( K.GT.0 ) THEN + IF( LSAME( UPLO, 'U' ) ) THEN + DO 110 J = 2, N + CALL CLASSQ( MIN( J-1, K ), AB( MAX( K+2-J, 1 ), J ), + $ 1, SCALE, SUM ) + 110 CONTINUE + L = K + 1 + ELSE + DO 120 J = 1, N - 1 + CALL CLASSQ( MIN( N-J, K ), AB( 2, J ), 1, SCALE, + $ SUM ) + 120 CONTINUE + L = 1 + END IF + SUM = 2*SUM + ELSE + L = 1 + END IF + DO 130 J = 1, N + IF( REAL( AB( L, J ) ).NE.ZERO ) THEN + ABSA = ABS( REAL( AB( L, J ) ) ) + IF( SCALE.LT.ABSA ) THEN + SUM = ONE + SUM*( SCALE / ABSA )**2 + SCALE = ABSA + ELSE + SUM = SUM + ( ABSA / SCALE )**2 + END IF + END IF + 130 CONTINUE + VALUE = SCALE*SQRT( SUM ) + END IF +* + CLANHB = VALUE + RETURN +* +* End of CLANHB +* + END diff --git a/pom.xml b/pom.xml index 0e5c0a1..24a24a5 100644 --- a/pom.xml +++ b/pom.xml @@ -1,12 +1,13 @@ - + 4.0.0 fr.cnes.sonar.plugins sonar-icode-cnes-plugin sonar-plugin - 5.1.0 + 5.2.0-SNAPSHOT Sonar i-Code CNES plugin @@ -56,21 +57,13 @@ UTF-8 - 17 - 17 - 17 17 - 17 - 9.8.0.203 - 9.5.0.56709 - 9.9.1.69595 - 2.6.1 - 1.21.0.505 - 3.7 - 2.8.2 - 1.7.25 - 4.13.2 - 0.8.10 + 23 + 17 + 3.5.3 + + 9.14.0.375 + 9.9.0.65466 icode fr.cnes.sonar.plugins.icode.ICodePlugin https://github.com/cnescatlab/sonar-icode-cnes-plugin @@ -98,35 +91,35 @@ org.sonarsource.api.plugin sonar-plugin-api - ${sonar.apiVersion} + ${sonar.plugin.api.version} provided fr.cnes.icode icode-library 5.1.0 - + - commons-lang - commons-lang - 2.6 + org.apache.commons + commons-lang3 + 3.17.0 - + org.sonarsource.sonarqube sonar-plugin-api-impl - ${sonar.apiImplVersion} + ${sonar.version} junit junit - 4.11 + 4.13.2 test @@ -138,48 +131,80 @@ com.thoughtworks.xstream xstream - 1.4.18 + 1.4.21 + + + + org.apache.maven.plugins + maven-clean-plugin + 3.4.1 + + + org.apache.maven.plugins + maven-resources-plugin + 3.3.1 + + + org.apache.maven.plugins + maven-compiler-plugin + 3.14.0 + + + org.apache.maven.plugins + maven-surefire-plugin + ${surefire.version} + + + org.jacoco + jacoco-maven-plugin + 0.8.13 + + + org.apache.maven.plugins + maven-install-plugin + 3.1.4 + + + org.apache.maven.plugins + maven-deploy-plugin + 3.1.4 + + + org.sonarsource.sonar-packaging-maven-plugin + sonar-packaging-maven-plugin + 1.23.0.740 + + + org.apache.maven.plugins + maven-project-info-reports-plugin + 2.9 + + + org.sonarsource.sonar-packaging-maven-plugin sonar-packaging-maven-plugin - ${sonar-packaging-maven-plugin.version} true org.apache.maven.plugins maven-compiler-plugin - 3.10.1 ${jdk.min.version} ${jdk.min.version} - - - org.codehaus.mojo - native2ascii-maven-plugin - 2.0.1 - - - - resources - - - - - org.apache.maven.plugins maven-project-info-reports-plugin - 2.9 false @@ -188,12 +213,11 @@ org.apache.maven.plugins maven-surefire-plugin - 3.0.0-M4 org.apache.maven.surefire surefire-junit47 - 3.0.0-M4 + ${surefire.version} @@ -201,7 +225,6 @@ org.jacoco jacoco-maven-plugin - ${jacoco.version} prepare-agent @@ -234,15 +257,4 @@ - - - - - - junit - junit - ${junit.version} - - -