Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

preliminary SC lint rules implementation and some testing #94

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
432 changes: 432 additions & 0 deletions lint_rules/lint_rules/sc.py

Large diffs are not rendered by default.

30 changes: 30 additions & 0 deletions test_sc_1.F90
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
MODULE TEST_SC_1_MOD
CONTAINS
SUBROUTINE TEST_SC_1(KIDIA, KFIDIA, X, Y, Z, NPROMA, KLON, HORIZONTAL, KLEV)

INTEGER, INTENT(IN) :: KIDIA, KFIDIA, NPROMA, KLON, KLEV, HORIZONTAL
REAL, INTENT(INOUT) :: X(NPROMA, KLEV), Y(KLON, KLEV), Z(HORIZONTAL, KLEV)
REAL :: TMP
INTEGER :: JL, JK, JO

DO JK=1,KLEV
DO JL=KIDIA,KFIDIA
X(JL, JK) = 0.0
TMP = X(JL, JK)
Y(JL, JK) = 0.0
TMP = Y(JL, JK)
Z(JL, JK) = 0.0
TMP = Z(JL, JK)
END DO
DO JO=KIDIA,KFIDIA
X(JO, JK) = 0.2
TMP = X(JO, JK)
Y(JO, JK) = 0.2
TMP = Y(JO, JK)
Z(JO, JK) = 0.2
TMP = Z(JO, JK)
END DO
END DO

END SUBROUTINE TEST_SC_1
END MODULE TEST_SC_1_MOD
31 changes: 31 additions & 0 deletions test_sc_2.F90
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
MODULE TEST_SC_2_MOD
CONTAINS
SUBROUTINE TEST_SC_2(KIDIA, KFIDIA, Z, KLON, KLEV)

INTEGER, INTENT(IN) :: KIDIA, KFIDIA, KLON, KLEV
REAL, INTENT(INOUT) :: Z(KLON, KLEV)
REAL :: TMP
INTEGER :: JL, JK, JO

DO JK=1,KLEV
DO JL=KIDIA,KFIDIA
Z(JL, JK) = 0.0
TMP = Z(JL, JK)
END DO
Z(KIDIA:KFIDIA, JK) = 0.2
Z(:, JK) = 0.5
TMP = Z(KIDIA:KFIDIA, JK)
END DO

DO JK=1,KLEV
DO JL=KIDIA,KFIDIA
Z(JL, JK) = 0.0
TMP = Z(JL, JK)
DO JO=1,10
print *, "innermost loop not the horizontal loop"
END DO
END DO
END DO

END SUBROUTINE TEST_SC_2
END MODULE TEST_SC_2_MOD
28 changes: 28 additions & 0 deletions test_sc_3.F90
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
MODULE TEST_SC_3_MOD
CONTAINS
SUBROUTINE TEST_SC_3(KIDIA, KFIDIA, Z, KLON, KLEV)

INTEGER, INTENT(IN) :: KIDIA, KFIDIA, KLON, KLEV, HORIZONTAL
REAL, INTENT(INOUT) :: Z(KLON, KLEV)
REAL :: TMP
INTEGER :: JL, JK, JO

DO JK=1,KLEV
DO JL=KIDIA,KFIDIA
Z(JL, JK) = EXP(0.0)
Z(JL, JK) = 1.0 + EXP(0.0)
TMP = MAX(1.0, 1.3) + MIN(-1.5, -1.7)
CALL SOME_FUNC()
print *, 'intrinsic but probably nothing to allow ...'
END DO
END DO

END SUBROUTINE TEST_SC_3

SUBROUTINE SOME_FUNC(Z, KLON, KLEV)
INTEGER, INTENT(IN) :: KLON, KLEV
REAL, INTENT(INOUT) :: Z(KLON, KLEV)
print *, "not an intrinsic function ..."
END SUBROUTINE SOME_FUNC

END MODULE TEST_SC_3_MOD
60 changes: 60 additions & 0 deletions test_sc_4.F90
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
MODULE TEST_SC_4_MOD
CONTAINS
SUBROUTINE TEST_SC_4(KIDIA, KFIDIA, ZTP1, KLON, KLEV)

INTEGER, INTENT(IN) :: KIDIA, KFIDIA, KLON, KLEV
REAL, INTENT(INOUT) :: ZTP1(KLON, KLEV)
REAL :: SCALAR_TMP, TMP(KLON)
INTEGER :: JL, JK, JO, JN, JM

DO JK=1,KLEV
TMP(JL) = JL + 1
DO JL=KIDIA,KFIDIA
ZTP1(JL, JK) = 0.0
END DO
DO JL=KIDIA,KFIDIA
ZTP1(JL, JK) = 0.2
END DO
END DO

DO JK=1,KLEV-1
DO JL=KIDIA,KFIDIA
IF (JL > 1) THEN
JO = JL - 1
ELSE
JO = JL
END IF
ZTP1(JO + JL, JK) = 1.0
ZTP1(TMP(JL), JK) = 2.0
END DO
END DO

DO JK=1,KLEV
DO JL=KIDIA,KFIDIA
JO = TMP(JL)
ZTP1(JO, JK) = 3.0
END DO
END DO

DO JK=1,KLEV-1
DO JL=KIDIA,KFIDIA
IF (JL > 1) THEN
JN = JL - 1
ELSE
JN = JL
END IF
ZTP1(JN, JK) = 1.0
ZTP1(TMP(JL), JK) = 4.0
END DO
END DO

DO JK=1,KLEV
DO JL=KIDIA,KFIDIA
JO = TMP(JL)
SCALAR_TMP = ZTP1(JO, JK)
ZTP1(JL, JK) = ZTP1(JO, JK)
END DO
END DO

END SUBROUTINE TEST_SC_4
END MODULE TEST_SC_4_MOD
35 changes: 35 additions & 0 deletions test_sc_potential_5.F90
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
SUBROUTINE TEST_SC_POTENTIAL_5(A, B, N)
IMPLICIT NONE
INTEGER, INTENT(IN) :: N
INTEGER, INTENT(INOUT) :: A(N, N), B(N, N)
INTEGER :: RES_SUM, JK, JL
INTEGER :: i_all, i_any, i_count, i_maxval, i_minval, i_product, i_sum
INTEGER :: i2_sum, i2_maxval

DO JK=1,N
DO JL=1,N
A(JL, JK) = 10
B(JL, JK) = 20
END DO
END DO

DO JK=1,N
DO JL=1,N
A(JL, JK) = A(JL, JK) + 1
RES_SUM = RES_SUM + A(JL, JK)*B(JL, JK)
END DO
END DO

i_all = all(A>5)
i_any = any(A>5)
i_count = count(A>5)
i_maxval = maxval(A)
i_minval = minval(A)
i_product = product(A)
i_sum = sum(A)

i2_sum = sum(A(1, :))
i2_sum = sum(A, dim=2)
i2_maxval = maxval(A(1, :))

END SUBROUTINE TEST_SC_POTENTIAL_5
20 changes: 20 additions & 0 deletions test_sc_potential_6.F90
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
MODULE TEST_SC_POTENTIAL_6_MOD
CONTAINS
SUBROUTINE TEST_SC_POTENTIAL_6(KIDIA, KFIDIA, ZTP1, KLON, KLEV)

INTEGER, INTENT(IN) :: KIDIA, KFIDIA, KLON, KLEV
REAL, INTENT(INOUT) :: ZTP1(KLON, KLEV), Z(KLEV)
REAL :: SCALAR_TMP, TMP(KLON)
INTEGER :: JL, JK, JO, JN, JM

DO JK=1,KLEV
DO JL=KIDIA,KFIDIA
Z(JK) = 0.0
ZTP1(JL, JK) = ZTP1(JL-1, JK)
ZTP1(JL, JK) = ZTP1(JL+1, JK)
ZTP1(JL+1, JK) = ZTP1(JL, JK)
END DO
END DO

END SUBROUTINE TEST_SC_POTENTIAL_6
END MODULE TEST_SC_POTENTIAL_6_MOD