From f06ee241c6f510d673d1a51846da3e8851b5e4f8 Mon Sep 17 00:00:00 2001 From: jverdugo Date: Wed, 14 Dec 2022 16:42:15 +0100 Subject: [PATCH 01/32] Bug fix: parsing errors (COM.NAME.Homonymy: Location unreachable or IndexOutOfBoundsException) were produced when analyzed files contained declaration of functions or subroutines with modifiers Recursive, Elemental or Pure --- .../src/main/resources/lex/COMNAMEHomonymy.lex | 11 ++++++++--- .../src/main/resources/lex/COMNAMEHomonymy.lex | 6 +++++- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/fortran77-rules/src/main/resources/lex/COMNAMEHomonymy.lex b/fortran77-rules/src/main/resources/lex/COMNAMEHomonymy.lex index b5fc2059..8c352774 100755 --- a/fortran77-rules/src/main/resources/lex/COMNAMEHomonymy.lex +++ b/fortran77-rules/src/main/resources/lex/COMNAMEHomonymy.lex @@ -53,11 +53,16 @@ PROC = PROCEDURE | procedure SUB = SUBROUTINE | subroutine PROG = PROGRAM | program MOD = MODULE | module +REC = RECURSIVE | recursive +ELE = ELEMENTAL | elemental +PUR = PURE | pure +MODIF = {REC} | {ELE} | {PUR} TYPE = {FUNC} | {PROC} | {SUB} | {PROG} | {MOD} | - {DATA_TYPE}[\ ]+{FUNC} | "RECURSIVE SUBROUTINE" + {DATA_TYPE}[\ ]+{FUNC} | ({MODIF}{SPACE})*({SUB} | {FUNC}) DATA_TYPE = INTEGER |integer | LOGICAL | logical | CHARACTER | character | - REAL | real | COMPLEX | complex | DOUBLE[\ ]+PRECISION | double[\ ]+precision | - CHARACTER{SPACE}*"\*"{SPACE}*"("{SPACE}*{VAR}{SPACE}*")" | character{SPACE}*"\*"{SPACE}*"("{SPACE}*{VAR}{SPACE}*")" + REAL | real | COMPLEX | complex | DOUBLE[\ ]+PRECISION | + double[\ ]+precision| CHARACTER{SPACE}*"\*"{SPACE}*"("{SPACE}*{VAR}{SPACE}*")" | + character{SPACE}*"\*"{SPACE}*"("{SPACE}*{VAR}{SPACE}*")" END = END | end END_TYPE = {END} [\ ]* {TYPE} STRUCT = TYPE | type diff --git a/fortran90-rules/src/main/resources/lex/COMNAMEHomonymy.lex b/fortran90-rules/src/main/resources/lex/COMNAMEHomonymy.lex index e306f0e0..66dde9f8 100755 --- a/fortran90-rules/src/main/resources/lex/COMNAMEHomonymy.lex +++ b/fortran90-rules/src/main/resources/lex/COMNAMEHomonymy.lex @@ -53,8 +53,12 @@ PROC = PROCEDURE | procedure SUB = SUBROUTINE | subroutine PROG = PROGRAM | program MOD = MODULE | module +REC = RECURSIVE | recursive +ELE = ELEMENTAL | elemental +PUR = PURE | pure +MODIF = {REC} | {ELE} | {PUR} TYPE = {FUNC} | {PROC} | {SUB} | {PROG} | {MOD} | - {DATA_TYPE}[\ ]+{FUNC} | "RECURSIVE SUBROUTINE" + {DATA_TYPE}[\ ]+{FUNC} | ({MODIF}{SPACE})*({SUB} | {FUNC}) DATA_TYPE = INTEGER |integer | LOGICAL | logical | CHARACTER | character | REAL | real | COMPLEX | complex | DOUBLE[\ ]+PRECISION | double[\ ]+precision| CHARACTER{SPACE}*"\*"{SPACE}*"("{SPACE}*{VAR}{SPACE}*")" | From 729b1e6a1886f3b59d18f7d5c5cc084fc2d87f6f Mon Sep 17 00:00:00 2001 From: jverdugo Date: Wed, 14 Dec 2022 16:55:35 +0100 Subject: [PATCH 02/32] Bug fix: Parsing error (IndexOutOfBoundsException) was produced when a file only contains comments, no source code. Also a JFlexException was thrown in the case of a file without code nor comments. The throw for this Exception has been removed to avoid parsing errors in the results. --- .../main/resources/lex/COMPROJECTHeader.lex | 72 ++++---- .../main/resources/lex/COMPROJECTHeader.lex | 158 +++++++++--------- 2 files changed, 111 insertions(+), 119 deletions(-) diff --git a/fortran77-rules/src/main/resources/lex/COMPROJECTHeader.lex b/fortran77-rules/src/main/resources/lex/COMPROJECTHeader.lex index 48775d21..5cbf4829 100755 --- a/fortran77-rules/src/main/resources/lex/COMPROJECTHeader.lex +++ b/fortran77-rules/src/main/resources/lex/COMPROJECTHeader.lex @@ -109,47 +109,43 @@ STRING = \'[^\']*\' | \"[^\"]*\" private void raiseErrors() throws JFlexException { LOGGER.finest("begin method raiseErrors"); - if(linesType.isEmpty()){ + if(!linesType.isEmpty()){ + if (!linesType.get(0).equals("comment") && !linesType.get(1).equals("comment")){ + LOGGER.fine("Setting error line 0 because no file header (file name not found). This module/function should have a header with a brief description.."); + this.setError("No file header existing.","This module/function should have a header with a brief description.", 0); + } else if (linesType.get(0).equals("comment") && !locations.get(0).toString().toLowerCase() + .contains(super.getInputFile().getName().replaceFirst("[.][^.]+$", "").toLowerCase())){ + LOGGER.fine("Setting error line "+(lines.get(0))+" because no file header (file name not found). This module/function should have a header with a brief description.."); + this.setError("No file header (file name not found)."," This module/function should have a header with a brief description.", lines.get(0)); + } else if (linesType.size() > 1 && linesType.get(1).equals("comment") && !locations.get(1).toString().toLowerCase() + .contains(super.getInputFile().getName().replaceFirst("[.][^.]+$", "").toLowerCase())){ + LOGGER.fine("Setting error line "+(lines.get(1))+" because no file header (file name not found). This module/function should have a header with a brief description.."); + this.setError("No file header (file name not found)."," This module/function should have a header with a brief description.", lines.get(1)); + } - final String errorMessage = "Analysis failure : Raising violation failed. Line type unreachable."; - throw new JFlexException(this.getClass().getName(), parsedFileName, - errorMessage, yytext(), yyline, yycolumn); - } - if (!linesType.get(0).equals("comment") && !linesType.get(1).equals("comment")){ - LOGGER.fine("Setting error line 0 because no file header (file name not found). This module/function should have a header with a brief description.."); - this.setError("No file header existing.","This module/function should have a header with a brief description.", 0); - } else if (linesType.get(0).equals("comment") && !locations.get(0).toString().toLowerCase() - .contains(super.getInputFile().getName().replaceFirst("[.][^.]+$", "").toLowerCase())){ - LOGGER.fine("Setting error line "+(lines.get(0))+" because no file header (file name not found). This module/function should have a header with a brief description.."); - this.setError("No file header (file name not found)."," This module/function should have a header with a brief description.", lines.get(0)); - } else if (linesType.get(1).equals("comment") && !locations.get(1).toString().toLowerCase() - .contains(super.getInputFile().getName().replaceFirst("[.][^.]+$", "").toLowerCase())){ - LOGGER.fine("Setting error line "+(lines.get(1))+" because no file header (file name not found). This module/function should have a header with a brief description.."); - this.setError("No file header (file name not found)."," This module/function should have a header with a brief description.", lines.get(1)); - } - - int index = linesType.indexOf("function"); - while(index != -1){ - int prevIndex = index - 1; - int nextIndex = index + 1; - boolean prevIndexNoHead = prevIndex < 0 || !linesType.get(prevIndex).equals("comment") - || !locations.get(prevIndex).toString().toLowerCase().contains( - locations.get(index).substring(locations.get(index).indexOf(" ")+1).toLowerCase()); - boolean nextIndexNoHead = nextIndex >= linesType.size() || !linesType.get(nextIndex).equals("comment") - || !locations.get(nextIndex).toString().toLowerCase().contains( - locations.get(index).substring(locations.get(index).indexOf(" ")+1).toLowerCase()); - - if (prevIndexNoHead && nextIndexNoHead){ - LOGGER.fine("Setting error line "+(lines.get(index))+" because the module/function should have a header with a brief description."); - this.setError(locations.get(index).toString(),"This module/function should have a header with a brief description.", lines.get(index)); + int index = linesType.indexOf("function"); + while(index != -1){ + int prevIndex = index - 1; + int nextIndex = index + 1; + boolean prevIndexNoHead = prevIndex < 0 || !linesType.get(prevIndex).equals("comment") + || !locations.get(prevIndex).toString().toLowerCase().contains( + locations.get(index).substring(locations.get(index).indexOf(" ")+1).toLowerCase()); + boolean nextIndexNoHead = nextIndex >= linesType.size() || !linesType.get(nextIndex).equals("comment") + || !locations.get(nextIndex).toString().toLowerCase().contains( + locations.get(index).substring(locations.get(index).indexOf(" ")+1).toLowerCase()); + + if (prevIndexNoHead && nextIndexNoHead){ + LOGGER.fine("Setting error line "+(lines.get(index))+" because the module/function should have a header with a brief description."); + this.setError(locations.get(index).toString(),"This module/function should have a header with a brief description.", lines.get(index)); + } + + linesType.remove(index); + locations.remove(index); + lines.remove(index); + index = linesType.indexOf("function"); } - - linesType.remove(index); - locations.remove(index); - lines.remove(index); - index = linesType.indexOf("function"); + LOGGER.finest("end method raiseErrors"); } - LOGGER.finest("end method raiseErrors"); } %} diff --git a/fortran90-rules/src/main/resources/lex/COMPROJECTHeader.lex b/fortran90-rules/src/main/resources/lex/COMPROJECTHeader.lex index 6800a733..302d0da0 100755 --- a/fortran90-rules/src/main/resources/lex/COMPROJECTHeader.lex +++ b/fortran90-rules/src/main/resources/lex/COMPROJECTHeader.lex @@ -104,90 +104,86 @@ STRING = \'[^\']*\' | \"[^\"]*\" } private void raiseErrors() throws JFlexException { - if(this.linesType.isEmpty()){ - - final String errorMessage = "Analysis failure : Line type unreachable."; - throw new JFlexException(this.getClass().getName(), parsedFileName, - errorMessage, yytext(), yyline, yycolumn); - } - if (!this.linesType.get(0).equals("comment") - && !this.linesType.get(1).equals("comment")) { - this.setError("No file header existing.","This module/function should have a header with a brief description.", 0); - } else if (this.linesType.get(0).equals("comment") - && !this.locations - .get(0) - .toString() - .toLowerCase() - .contains( - super.getInputFile() - .getName() - .replaceFirst("[.][^.]+$", "") - .toLowerCase())) { - this.setError("No file header (file name not found)","This module/function should have a header with a brief description.", - this.lines.get(0)); - } else if (this.linesType.get(1).equals("comment") - && !this.locations - .get(1) - .toString() - .toLowerCase() - .contains( - super.getInputFile() - .getName() - .replaceFirst("[.][^.]+$", "") - .toLowerCase())) { - this.setError("No file header (file name not found)"," This module/function should have a header with a brief description.", - this.lines.get(1)); - } + if(!this.linesType.isEmpty()){ + if (!this.linesType.get(0).equals("comment") + && !this.linesType.get(1).equals("comment")) { + this.setError("No file header existing.","This module/function should have a header with a brief description.", 0); + } else if (this.linesType.get(0).equals("comment") + && !this.locations + .get(0) + .toString() + .toLowerCase() + .contains( + super.getInputFile() + .getName() + .replaceFirst("[.][^.]+$", "") + .toLowerCase())) { + this.setError("No file header (file name not found)","This module/function should have a header with a brief description.", + this.lines.get(0)); + } else if (linesType.size() > 1 && this.linesType.get(1).equals("comment") + && !this.locations + .get(1) + .toString() + .toLowerCase() + .contains( + super.getInputFile() + .getName() + .replaceFirst("[.][^.]+$", "") + .toLowerCase())) { + this.setError("No file header (file name not found)"," This module/function should have a header with a brief description.", + this.lines.get(1)); + } - int index = this.linesType.indexOf("function"); - while (index != -1) { - final int prevIndex = index - 1; - final int nextIndex = index + 1; - final boolean prevIndexNoHead = - prevIndex < 0 - || !this.linesType.get(prevIndex) - .equals("comment") - || !this.locations - .get(prevIndex) - .toString() - .toLowerCase() - .contains( - this.locations - .get(index) - .substring( - this.locations - .get(index) - .indexOf( - " ") + 1) - .toLowerCase()); - final boolean nextIndexNoHead = - nextIndex >= this.linesType.size() - || !this.linesType.get(nextIndex) - .equals("comment") - || !this.locations - .get(nextIndex) - .toString() - .toLowerCase() - .contains( - this.locations - .get(index) - .substring( - this.locations - .get(index) - .indexOf( - " ") + 1) - .toLowerCase()); + int index = this.linesType.indexOf("function"); + while (index != -1) { + final int prevIndex = index - 1; + final int nextIndex = index + 1; + final boolean prevIndexNoHead = + prevIndex < 0 + || !this.linesType.get(prevIndex) + .equals("comment") + || !this.locations + .get(prevIndex) + .toString() + .toLowerCase() + .contains( + this.locations + .get(index) + .substring( + this.locations + .get(index) + .indexOf( + " ") + 1) + .toLowerCase()); + final boolean nextIndexNoHead = + nextIndex >= this.linesType.size() + || !this.linesType.get(nextIndex) + .equals("comment") + || !this.locations + .get(nextIndex) + .toString() + .toLowerCase() + .contains( + this.locations + .get(index) + .substring( + this.locations + .get(index) + .indexOf( + " ") + 1) + .toLowerCase()); - if (prevIndexNoHead && nextIndexNoHead) { - this.setError(this.locations.get(index).toString(),"This module/function should have a header with a brief description.", - this.lines.get(index)); - } + if (prevIndexNoHead && nextIndexNoHead) { + this.setError(this.locations.get(index).toString(),"This module/function should have a header with a brief description.", + this.lines.get(index)); + } - this.linesType.remove(index); - this.locations.remove(index); - this.lines.remove(index); - index = this.linesType.indexOf("function"); - } + this.linesType.remove(index); + this.locations.remove(index); + this.lines.remove(index); + index = this.linesType.indexOf("function"); + } + } } %} From 50108d9db4207e4132321182d4dbf783f1c15772 Mon Sep 17 00:00:00 2001 From: jverdugo Date: Wed, 14 Dec 2022 17:00:21 +0100 Subject: [PATCH 03/32] Bug fix: a parsing error (IndexOutOfBoundsException) was produced when analyzing files that included sentences like "PROCEDURE(proc_interface), POINTER :: proc" --- fortran90-rules/src/main/resources/lex/COMINSTBrace.lex | 1 + 1 file changed, 1 insertion(+) diff --git a/fortran90-rules/src/main/resources/lex/COMINSTBrace.lex b/fortran90-rules/src/main/resources/lex/COMINSTBrace.lex index 7ebc812d..bc0c8312 100755 --- a/fortran90-rules/src/main/resources/lex/COMINSTBrace.lex +++ b/fortran90-rules/src/main/resources/lex/COMINSTBrace.lex @@ -160,6 +160,7 @@ SPACE = [\ \r\t\f] /* NAMING STATE */ /************************/ {VAR} {location = location + " " + yytext(); yybegin(LINE);} + \( {yybegin(AVOID);} \n {yybegin(NEW_LINE);} . {} From 8104472127c3c9b978c5f495e68feebbd8c758b4 Mon Sep 17 00:00:00 2001 From: jverdugo Date: Wed, 14 Dec 2022 19:26:20 +0100 Subject: [PATCH 04/32] Rule for checking that lines of code in a file don't exceed a threshold of LOC (set at 1000). Only lines of code are taken into account, comments and blank lines are ignored. --- .../src/main/resources/fortran77-rules.xml | 6 + .../main/resources/lex/COMPRESCodeLines.lex | 158 ++++++++++++++++++ .../rules/TestFortran77RulesDefinition.java | 2 +- .../src/main/resources/fortran90-rules.xml | 6 + .../main/resources/lex/COMPRESCodeLines.lex | 155 +++++++++++++++++ .../rules/TestFortran90RulesDefinition.java | 2 +- 6 files changed, 327 insertions(+), 2 deletions(-) create mode 100644 fortran77-rules/src/main/resources/lex/COMPRESCodeLines.lex create mode 100644 fortran90-rules/src/main/resources/lex/COMPRESCodeLines.lex diff --git a/fortran77-rules/src/main/resources/fortran77-rules.xml b/fortran77-rules/src/main/resources/fortran77-rules.xml index 7bb3a48e..35347125 100644 --- a/fortran77-rules/src/main/resources/fortran77-rules.xml +++ b/fortran77-rules/src/main/resources/fortran77-rules.xml @@ -342,4 +342,10 @@ fr.cnes.icode.fortran77 F77.TYPE.Hollerith + + fr.cnes.icode.fortran77.rules.COMPRESCodeLines + fr.cnes.icode.fortran77.rules.COMPRESCodeLines + COM.PRES.CodeLines + fr.cnes.icode.fortran77 + diff --git a/fortran77-rules/src/main/resources/lex/COMPRESCodeLines.lex b/fortran77-rules/src/main/resources/lex/COMPRESCodeLines.lex new file mode 100644 index 00000000..f1a48904 --- /dev/null +++ b/fortran77-rules/src/main/resources/lex/COMPRESCodeLines.lex @@ -0,0 +1,158 @@ +/************************************************************************************************/ +/* i-Code CNES is a static code analyzer. */ +/* This software is a free software, under the terms of the Eclipse Public License version 1.0. */ +/* http://www.eclipse.org/legal/epl-v10.html */ +/************************************************************************************************/ +/********************************************************************************/ +/* This file is used to generate a rule checker for COM.PRES.CodeLines rule. */ +/* For further information on this, we advise you to refer to RNC manuals. */ +/* As many comments have been done on the ExampleRule.lex file, this file */ +/* will restrain its comments on modifications. */ +/* */ +/********************************************************************************/ +package fr.cnes.icode.fortran77.rules; +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.File; +import java.util.List; +import java.util.LinkedList; +import fr.cnes.icode.data.AbstractChecker; +import fr.cnes.icode.data.CheckResult; +import fr.cnes.icode.exception.JFlexException; +%% +%class COMPRESCodeLines +%extends AbstractChecker +%public +%column +%line +%function run +%yylexthrow JFlexException +%type List +%state COMMENT, NAMING, NEW_LINE, LINE, AVOID, INLINE_COMMENT +COMMENT_WORD = \! | c | C | \* +FREE_COMMENT = \! +FUNC = FUNCTION | function +PROC = PROCEDURE | procedure +SUB = SUBROUTINE | subroutine +PROG = PROGRAM | program +MOD = MODULE | module +INTER = INTERFACE | interface +TYPE = {FUNC} | {PROC} | {SUB} | {PROG} | {MOD} | {INTER} +VAR = [a-zA-Z][a-zA-Z0-9\_]* +CLOSING = END[\ ]*IF | end[\ ]*if | END[\ ]*DO | end[\ ]*do +END = END | end +STRING = \'[^\']*\' | \"[^\"]*\" +SPACE = [\ \r\t\f] +BLANK_LINE = {SPACE}*\R + +%{ + String location = "MAIN PROGRAM"; + private String parsedFileName; + int codeLines = 0; + int numTotal = 1; + + public COMPRESCodeLines(){ + } + + @Override + public void setInputFile(final File file) throws FileNotFoundException { + super.setInputFile(file); + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new File(file.getAbsolutePath())); + } + + private void checkTotalCodeLines() { + if(codeLines > 1000) { + setError(location,"There are more than 1000 lines of code in this file: " + codeLines, yyline+1); + } + } + +%} +%eofval{ + checkTotalCodeLines(); + return getCheckResults(); +%eofval} +%eofclose +%% +/************************/ + +/************************/ +/* COMMENT STATE */ +/************************/ + + { + \n {numTotal++; yybegin(NEW_LINE);} + . {} + } +/*************************/ +/* INLINE_COMMENT STATE */ +/*************************/ + + { + \n {numTotal++; codeLines++; yybegin(NEW_LINE);} + . {} + } +/************************/ +/* AVOID STATE */ +/************************/ + \n {numTotal++; codeLines++; yybegin(NEW_LINE);} + . {} +/************************/ +/* NAMING STATE */ +/************************/ + + { + {VAR} {location = location + " " + yytext(); yybegin(AVOID);} + \n {numTotal++; codeLines++; yybegin(NEW_LINE);} + . {} + } +/************************/ +/* YYINITIAL STATE */ +/************************/ + + { + {COMMENT_WORD} {yybegin(COMMENT);} + {STRING} {yybegin(LINE);} + {TYPE} {location = yytext(); yybegin(NAMING);} + {SPACE} {} + \n {numTotal++; yybegin(NEW_LINE);} + . {yybegin(LINE);} + } +/************************/ +/* NEW_LINE STATE */ +/************************/ + + { + {COMMENT_WORD} {yybegin(COMMENT);} + {STRING} {yybegin(LINE);} + {TYPE} {location = yytext(); yybegin(NAMING);} + {CLOSING} {yybegin(LINE);} + {END} {yybegin(AVOID);} + {BLANK_LINE} {} + {SPACE} {yybegin(LINE);} + \n {numTotal++; yybegin(NEW_LINE);} + . {yybegin(LINE);} + } +/************************/ +/* LINE STATE */ +/************************/ + + { + {FREE_COMMENT} {yybegin(INLINE_COMMENT);} + {STRING} {} + {TYPE} {location = yytext(); yybegin(NAMING);} + {CLOSING} {} + {END} {yybegin(AVOID);} + {VAR} {} + \n {numTotal++; codeLines++; yybegin(NEW_LINE);} + . {} + } +/************************/ +/* ERROR STATE */ +/************************/ + [^] { + + final String errorMessage = "Analysis failure : Your file could not be analyzed. Please verify that it was encoded in an UNIX format."; + throw new JFlexException(this.getClass().getName(), parsedFileName, + errorMessage, yytext(), yyline, yycolumn); + } \ No newline at end of file diff --git a/fortran77-rules/src/test/java/fr/cnes/icode/fortran77/rules/TestFortran77RulesDefinition.java b/fortran77-rules/src/test/java/fr/cnes/icode/fortran77/rules/TestFortran77RulesDefinition.java index 15dff4c2..807b5b7f 100644 --- a/fortran77-rules/src/test/java/fr/cnes/icode/fortran77/rules/TestFortran77RulesDefinition.java +++ b/fortran77-rules/src/test/java/fr/cnes/icode/fortran77/rules/TestFortran77RulesDefinition.java @@ -16,7 +16,7 @@ public void testDefinitionOfDefaultRules() { rulesDefinition.define(); - Assertions.assertEquals(57, rulesDefinition.list().size()); + Assertions.assertEquals(58, rulesDefinition.list().size()); } } diff --git a/fortran90-rules/src/main/resources/fortran90-rules.xml b/fortran90-rules/src/main/resources/fortran90-rules.xml index 6c2918b8..df608c21 100644 --- a/fortran90-rules/src/main/resources/fortran90-rules.xml +++ b/fortran90-rules/src/main/resources/fortran90-rules.xml @@ -378,4 +378,10 @@ F90.TYPE.Real fr.cnes.icode.fortran90 + + fr.cnes.icode.fortran90.rules.COMPRESCodeLines + fr.cnes.icode.fortran90.rules.COMPRESCodeLines + COM.PRES.CodeLines + fr.cnes.icode.fortran90 + \ No newline at end of file diff --git a/fortran90-rules/src/main/resources/lex/COMPRESCodeLines.lex b/fortran90-rules/src/main/resources/lex/COMPRESCodeLines.lex new file mode 100644 index 00000000..672bcb7c --- /dev/null +++ b/fortran90-rules/src/main/resources/lex/COMPRESCodeLines.lex @@ -0,0 +1,155 @@ +/************************************************************************************************/ +/* i-Code CNES is a static code analyzer. */ +/* This software is a free software, under the terms of the Eclipse Public License version 1.0. */ +/* http://www.eclipse.org/legal/epl-v10.html */ +/************************************************************************************************/ +/********************************************************************************/ +/* This file is used to generate a rule checker for COM.PRES.CodeLines rule. */ +/* For further information on this, we advise you to refer to RNC manuals. */ +/* As many comments have been done on the ExampleRule.lex file, this file */ +/* will restrain its comments on modifications. */ +/* */ +/********************************************************************************/ +package fr.cnes.icode.fortran90.rules; +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.File; +import java.util.List; +import java.util.LinkedList; +import fr.cnes.icode.data.AbstractChecker; +import fr.cnes.icode.data.CheckResult; +import fr.cnes.icode.exception.JFlexException; +%% +%class COMPRESCodeLines +%extends AbstractChecker +%public +%column +%line +%function run +%yylexthrow JFlexException +%type List +%state COMMENT, NAMING, NEW_LINE, LINE, AVOID, INLINE_COMMENT +COMMENT_WORD = \! +FUNC = FUNCTION | function +PROC = PROCEDURE | procedure +SUB = SUBROUTINE | subroutine +PROG = PROGRAM | program +MOD = MODULE | module +INTER = INTERFACE | interface +TYPE = {FUNC} | {PROC} | {SUB} | {PROG} | {MOD} | {INTER} +VAR = [a-zA-Z][a-zA-Z0-9\_]* +CLOSING = END[\ ]*IF | end[\ ]*if | END[\ ]*DO | end[\ ]*do +END = END | end +STRING = \'[^\']*\' | \"[^\"]*\" +SPACE = [\ \r\t\f] + +%{ + String location = "MAIN PROGRAM"; + private String parsedFileName; + int codeLines = 0; + int numTotal = 1; + + public COMPRESCodeLines(){ + } + + @Override + public void setInputFile(final File file) throws FileNotFoundException { + super.setInputFile(file); + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new File(file.getAbsolutePath())); + } + + private void checkTotalCodeLines() { + if(codeLines > 1000 ) { + setError(location,"There are more than 1000 lines of code in this file: " + codeLines, yyline+1); + } + } + +%} +%eofval{ + checkTotalCodeLines(); + return getCheckResults(); +%eofval} +%eofclose +%% +/************************/ + +/************************/ +/* COMMENT STATE */ +/************************/ + + { + \n {numTotal++; yybegin(NEW_LINE);} + . {} + } +/*************************/ +/* INLINE_COMMENT STATE */ +/*************************/ + + { + \n {numTotal++; codeLines++; yybegin(NEW_LINE);} + . {} + } +/************************/ +/* AVOID STATE */ +/************************/ + \n {numTotal++; codeLines++; yybegin(NEW_LINE);} + . {} +/************************/ +/* NAMING STATE */ +/************************/ + + { + {VAR} {location = location + " " + yytext(); yybegin(AVOID);} + \n {numTotal++; codeLines++; yybegin(NEW_LINE);} + . {} + } +/************************/ +/* YYINITIAL STATE */ +/************************/ + + { + {COMMENT_WORD} {yybegin(COMMENT);} + {STRING} {yybegin(LINE);} + {TYPE} {location = yytext(); yybegin(NAMING);} + {SPACE} {} + \n {numTotal++; yybegin(NEW_LINE);} + . {yybegin(LINE);} + } +/************************/ +/* NEW_LINE STATE */ +/************************/ + + { + {COMMENT_WORD} {yybegin(COMMENT);} + {STRING} {yybegin(LINE);} + {TYPE} {location = yytext(); yybegin(NAMING);} + {CLOSING} {yybegin(LINE);} + {END} {yybegin(AVOID);} + {SPACE} {} + \n {numTotal++; yybegin(NEW_LINE);} + . {yybegin(LINE);} + } +/************************/ +/* LINE STATE */ +/************************/ + + { + {COMMENT_WORD} {yybegin(INLINE_COMMENT);} + {STRING} {} + {TYPE} {location = yytext(); yybegin(NAMING);} + {CLOSING} {} + {END} {yybegin(AVOID);} + {VAR} {} + \n {numTotal++; codeLines++; yybegin(NEW_LINE);} + . {} + } +/************************/ +/* ERROR STATE */ +/************************/ + [^] { + + final String errorMessage = "Analysis failure : Your file could not be analyzed. Please verify that it was encoded in an UNIX format."; + throw new JFlexException(this.getClass().getName(), parsedFileName, + errorMessage, yytext(), yyline, yycolumn); + } \ No newline at end of file diff --git a/fortran90-rules/src/test/java/fr/cnes/icode/fortran90/rules/TestFortran90RulesDefinition.java b/fortran90-rules/src/test/java/fr/cnes/icode/fortran90/rules/TestFortran90RulesDefinition.java index ead30a86..0737d8c5 100644 --- a/fortran90-rules/src/test/java/fr/cnes/icode/fortran90/rules/TestFortran90RulesDefinition.java +++ b/fortran90-rules/src/test/java/fr/cnes/icode/fortran90/rules/TestFortran90RulesDefinition.java @@ -16,7 +16,7 @@ public void testDefinitionOfDefaultRules() { rulesDefinition.define(); - Assertions.assertEquals(63, rulesDefinition.list().size()); + Assertions.assertEquals(64, rulesDefinition.list().size()); } } From 8178b61847cf84495df2236d3a885e8ce27a9fa3 Mon Sep 17 00:00:00 2001 From: jverdugo Date: Thu, 15 Dec 2022 08:57:55 +0100 Subject: [PATCH 05/32] Rule for checking that lines of code in procedures don't exceed a threshold of LOC (set at 150). Only lines of code are taken into account, comments and blank lines are ignored. --- .../src/main/resources/fortran77-rules.xml | 6 + .../resources/lex/F77DESIGNProcedureLines.lex | 176 ++++++++++++++++++ .../rules/TestFortran77RulesDefinition.java | 2 +- .../src/main/resources/fortran90-rules.xml | 6 + .../resources/lex/F90DESIGNProcedureLines.lex | 175 +++++++++++++++++ .../rules/TestFortran90RulesDefinition.java | 2 +- 6 files changed, 365 insertions(+), 2 deletions(-) create mode 100644 fortran77-rules/src/main/resources/lex/F77DESIGNProcedureLines.lex create mode 100644 fortran90-rules/src/main/resources/lex/F90DESIGNProcedureLines.lex diff --git a/fortran77-rules/src/main/resources/fortran77-rules.xml b/fortran77-rules/src/main/resources/fortran77-rules.xml index 35347125..26e7b167 100644 --- a/fortran77-rules/src/main/resources/fortran77-rules.xml +++ b/fortran77-rules/src/main/resources/fortran77-rules.xml @@ -348,4 +348,10 @@ COM.PRES.CodeLines fr.cnes.icode.fortran77 + + fr.cnes.icode.fortran77.rules.F77DESIGNProcedureLines + fr.cnes.icode.fortran77.rules.F77DESIGNProcedureLines + F77.DESIGN.ProcedureLines + fr.cnes.icode.fortran77 + diff --git a/fortran77-rules/src/main/resources/lex/F77DESIGNProcedureLines.lex b/fortran77-rules/src/main/resources/lex/F77DESIGNProcedureLines.lex new file mode 100644 index 00000000..c77a5e35 --- /dev/null +++ b/fortran77-rules/src/main/resources/lex/F77DESIGNProcedureLines.lex @@ -0,0 +1,176 @@ +/************************************************************************************************/ +/* i-Code CNES is a static code analyzer. */ +/* This software is a free software, under the terms of the Eclipse Public License version 1.0. */ +/* http://www.eclipse.org/legal/epl-v10.html */ +/************************************************************************************************/ +/***********************************************************************************/ +/* This file is used to generate a rule checker for F77.DESIGN.ProcedureLines rule.*/ +/* For further information on this, we advise you to refer to RNC manuals. */ +/* As many comments have been done on the ExampleRule.lex file, this file */ +/* will restrain its comments on modifications. */ +/* */ +/***********************************************************************************/ + +package fr.cnes.icode.fortran77.rules; + +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.File; +import java.util.List; +import java.util.LinkedList; + +import fr.cnes.icode.data.AbstractChecker; +import fr.cnes.icode.data.CheckResult; +import fr.cnes.icode.exception.JFlexException; + +%% + +%class F77DESIGNProcedureLines +%extends AbstractChecker +%public +%column +%line +%ignorecase + +%function run +%yylexthrow JFlexException +%type List +%state COMMENT, NAMING, NEW_LINE, LINE, AVOID, INLINE_COMMENT, PROCEDURES_DEF + +COMMENT_WORD = \! | c | C | \* +FREE_COMMENT = \! +PROCEDURES = PROCEDURE | procedure | SUBROUTINE | subroutine | FUNCTION | function +PROG = PROGRAM | program +MOD = MODULE | module +INTER = INTERFACE | interface +TYPE = {PROG} | {MOD} | {INTER} +VAR = [a-zA-Z][a-zA-Z0-9\_]* +CLOSING = END[\ ]*IF | end[\ ]*if | END[\ ]*DO | end[\ ]*do +END = END | end +STRING = \'[^\']*\' | \"[^\"]*\" +SPACE = [\ \r\t\f] +BLANK_LINE = {SPACE}*\R + +%{ + String location = "MAIN PROGRAM"; + private String parsedFileName; + int codeLines = 0; + boolean procStarted = false; + + public F77DESIGNProcedureLines(){ + } + + @Override + public void setInputFile(final File file) throws FileNotFoundException { + super.setInputFile(file); + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new File(file.getAbsolutePath())); + } + + private void checkProcedureCodeLines() { + if(procStarted && codeLines > 150 ) { + this.setError(location,"This procedure contains more than 150 lines of code: " + codeLines, yyline+1); + } + } + +%} +%eofval{ + return getCheckResults(); +%eofval} +%eofclose +%% +/************************/ + +/************************/ +/* COMMENT STATE */ +/************************/ + + { + \n {yybegin(NEW_LINE);} + . {} + } +/*************************/ +/* INLINE_COMMENT STATE */ +/*************************/ + + { + \n {codeLines++; yybegin(NEW_LINE);} + . {} + } +/************************/ +/* AVOID STATE */ +/************************/ + \n {codeLines++; yybegin(NEW_LINE);} + . {} +/************************/ +/* NAMING STATE */ +/************************/ + + { + {VAR} {yybegin(AVOID);} + \n {codeLines++; yybegin(NEW_LINE);} + . {} + } +/************************/ +/* YYINITIAL STATE */ +/************************/ + + { + {COMMENT_WORD} {yybegin(COMMENT);} + {STRING} {yybegin(LINE);} + {TYPE} {yybegin(NAMING);} + {SPACE} {yybegin(LINE);} + \n {yybegin(NEW_LINE);} + . {yybegin(LINE);} + } +/************************/ +/* PROCEDURES_DEF STATE */ +/************************/ + + { + {VAR} {location = location + " " + yytext(); codeLines--; yybegin(AVOID);} + \n {yybegin(NEW_LINE);} + . {} + } +/************************/ +/* NEW_LINE STATE */ +/************************/ + + { + {COMMENT_WORD} {yybegin(COMMENT);} + {STRING} {yybegin(LINE);} + {TYPE} { yybegin(NAMING);} + {PROCEDURES} {codeLines = 0; location = yytext(); procStarted = true; + yybegin(PROCEDURES_DEF);} + {CLOSING} {yybegin(LINE);} + {END} {checkProcedureCodeLines(); procStarted = false;} + {BLANK_LINE} {} + {SPACE} {yybegin(LINE);} + \n {yybegin(NEW_LINE);} + . {yybegin(LINE);} + } +/************************/ +/* LINE STATE */ +/************************/ + + { + {FREE_COMMENT} {yybegin(INLINE_COMMENT);} + {STRING} {} + {TYPE} {yybegin(NAMING);} + {PROCEDURES} {codeLines = 0; location = yytext(); procStarted = true; + yybegin(PROCEDURES_DEF);} + {CLOSING} {} + {END} {checkProcedureCodeLines(); procStarted = false;} + {VAR} {} + \n {codeLines++; yybegin(NEW_LINE);} + . {} + } +/************************/ +/* ERROR STATE */ +/************************/ + [^] { + + final String errorMessage = "Analysis failure : Your file could not be analyzed. Please verify that it was encoded in an UNIX format."; + throw new JFlexException(this.getClass().getName(), parsedFileName, + errorMessage, yytext(), yyline, yycolumn); + } \ No newline at end of file diff --git a/fortran77-rules/src/test/java/fr/cnes/icode/fortran77/rules/TestFortran77RulesDefinition.java b/fortran77-rules/src/test/java/fr/cnes/icode/fortran77/rules/TestFortran77RulesDefinition.java index 807b5b7f..0698979e 100644 --- a/fortran77-rules/src/test/java/fr/cnes/icode/fortran77/rules/TestFortran77RulesDefinition.java +++ b/fortran77-rules/src/test/java/fr/cnes/icode/fortran77/rules/TestFortran77RulesDefinition.java @@ -16,7 +16,7 @@ public void testDefinitionOfDefaultRules() { rulesDefinition.define(); - Assertions.assertEquals(58, rulesDefinition.list().size()); + Assertions.assertEquals(59, rulesDefinition.list().size()); } } diff --git a/fortran90-rules/src/main/resources/fortran90-rules.xml b/fortran90-rules/src/main/resources/fortran90-rules.xml index df608c21..db0d2ba2 100644 --- a/fortran90-rules/src/main/resources/fortran90-rules.xml +++ b/fortran90-rules/src/main/resources/fortran90-rules.xml @@ -384,4 +384,10 @@ COM.PRES.CodeLines fr.cnes.icode.fortran90 + + fr.cnes.icode.fortran90.rules.F90DESIGNProcedureLines + fr.cnes.icode.fortran90.rules.F90DESIGNProcedureLines + F90.DESIGN.ProcedureLines + fr.cnes.icode.fortran90 + \ No newline at end of file diff --git a/fortran90-rules/src/main/resources/lex/F90DESIGNProcedureLines.lex b/fortran90-rules/src/main/resources/lex/F90DESIGNProcedureLines.lex new file mode 100644 index 00000000..e69c3586 --- /dev/null +++ b/fortran90-rules/src/main/resources/lex/F90DESIGNProcedureLines.lex @@ -0,0 +1,175 @@ +/************************************************************************************************/ +/* i-Code CNES is a static code analyzer. */ +/* This software is a free software, under the terms of the Eclipse Public License version 1.0. */ +/* http://www.eclipse.org/legal/epl-v10.html */ +/************************************************************************************************/ +/***********************************************************************************/ +/* This file is used to generate a rule checker for F90.DESIGN.ProcedureLines rule.*/ +/* For further information on this, we advise you to refer to RNC manuals. */ +/* As many comments have been done on the ExampleRule.lex file, this file */ +/* will restrain its comments on modifications. */ +/* */ +/***********************************************************************************/ + +package fr.cnes.icode.fortran90.rules; + +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.File; +import java.util.List; +import java.util.LinkedList; + +import fr.cnes.icode.data.AbstractChecker; +import fr.cnes.icode.data.CheckResult; +import fr.cnes.icode.exception.JFlexException; + +%% + +%class F90DESIGNProcedureLines +%extends AbstractChecker +%public +%column +%line +%ignorecase + +%function run +%yylexthrow JFlexException +%type List +%state COMMENT, NAMING, NEW_LINE, LINE, AVOID, INLINE_COMMENT, PROCEDURES_DEF + +COMMENT_WORD = \! +PROCEDURES = PROCEDURE | procedure | SUBROUTINE | subroutine | FUNCTION | function +PROG = PROGRAM | program +MOD = MODULE | module +INTER = INTERFACE | interface +TYPE = {PROG} | {MOD} | {INTER} +VAR = [a-zA-Z][a-zA-Z0-9\_]* +CLOSING = END[\ ]*IF | end[\ ]*if | END[\ ]*DO | end[\ ]*do +END = END[\ ]*{PROCEDURES} | end[\ ]*{PROCEDURES} +STRING = \'[^\']*\' | \"[^\"]*\" +SPACE = [\ \r\t\f] + +%{ + String location = "MAIN PROGRAM"; + private String parsedFileName; + int codeLines = 0; + boolean procStarted = false; + + public F90DESIGNProcedureLines(){ + } + + @Override + public void setInputFile(final File file) throws FileNotFoundException { + super.setInputFile(file); + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new File(file.getAbsolutePath())); + } + + private void checkProcedureCodeLines() { + if(procStarted && codeLines > 150 ) { + this.setError(location,"This procedure contains more than 150 lines of code: " + codeLines, yyline+1); + } + } + +%} +%eofval{ + return getCheckResults(); +%eofval} +%eofclose +%% +/************************/ + +/************************/ +/* COMMENT STATE */ +/************************/ + + { + \n {yybegin(NEW_LINE);} + . {} + } +/*************************/ +/* INLINE_COMMENT STATE */ +/*************************/ + + { + \n {codeLines++; yybegin(NEW_LINE);} + . {} + } +/************************/ +/* AVOID STATE */ +/************************/ + \n {codeLines++; yybegin(NEW_LINE);} + . {} +/************************/ +/* NAMING STATE */ +/************************/ + + { + {VAR} {yybegin(AVOID);} + \n {codeLines++; yybegin(NEW_LINE);} + . {} + } +/************************/ +/* YYINITIAL STATE */ +/************************/ + + { + {COMMENT_WORD} {yybegin(COMMENT);} + {STRING} {yybegin(LINE);} + {TYPE} {yybegin(NAMING);} + {PROCEDURES} {codeLines = 0; location = yytext(); procStarted = true; + yybegin(PROCEDURES_DEF);} + {SPACE} {} + \n {yybegin(NEW_LINE);} + . {yybegin(LINE);} + } +/************************/ +/* PROCEDURES_DEF STATE */ +/************************/ + + { + {VAR} {location = location + " " + yytext(); codeLines--; yybegin(AVOID);} + \n {yybegin(NEW_LINE);} + . {} + } +/************************/ +/* NEW_LINE STATE */ +/************************/ + + { + {COMMENT_WORD} {yybegin(COMMENT);} + {STRING} {yybegin(LINE);} + {TYPE} {yybegin(NAMING);} + {PROCEDURES} {codeLines = 0; location = yytext(); procStarted = true; + yybegin(PROCEDURES_DEF);} + {CLOSING} {yybegin(LINE);} + {END} {checkProcedureCodeLines(); procStarted = false;} + {SPACE} {} + \n {yybegin(NEW_LINE);} + . {yybegin(LINE);} + } +/************************/ +/* LINE STATE */ +/************************/ + + { + {COMMENT_WORD} {yybegin(INLINE_COMMENT);} + {STRING} {} + {TYPE} { yybegin(NAMING);} + {PROCEDURES} {codeLines = 0; location = yytext(); + yybegin(PROCEDURES_DEF);} + {CLOSING} {} + {END} {checkProcedureCodeLines(); procStarted = false;} + {VAR} {} + \n {codeLines++; yybegin(NEW_LINE);} + . {} + } +/************************/ +/* ERROR STATE */ +/************************/ + [^] { + + final String errorMessage = "Analysis failure : Your file could not be analyzed. Please verify that it was encoded in an UNIX format."; + throw new JFlexException(this.getClass().getName(), parsedFileName, + errorMessage, yytext(), yyline, yycolumn); + } \ No newline at end of file diff --git a/fortran90-rules/src/test/java/fr/cnes/icode/fortran90/rules/TestFortran90RulesDefinition.java b/fortran90-rules/src/test/java/fr/cnes/icode/fortran90/rules/TestFortran90RulesDefinition.java index 0737d8c5..e530d4da 100644 --- a/fortran90-rules/src/test/java/fr/cnes/icode/fortran90/rules/TestFortran90RulesDefinition.java +++ b/fortran90-rules/src/test/java/fr/cnes/icode/fortran90/rules/TestFortran90RulesDefinition.java @@ -16,7 +16,7 @@ public void testDefinitionOfDefaultRules() { rulesDefinition.define(); - Assertions.assertEquals(64, rulesDefinition.list().size()); + Assertions.assertEquals(65, rulesDefinition.list().size()); } } From 53bcf92b983c43dd89913462bc79099c59d0167f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ana=20D=C3=ADaz=20Mu=C3=B1oz?= Date: Thu, 15 Dec 2022 16:42:40 +0100 Subject: [PATCH 06/32] Rule ArgumentsProcedure Rule to check the maximum number of arguments in each procedure, which must be at most 7. --- .../src/main/resources/fortran77-rules.xml | 6 + .../lex/F77DESIGNArgumentsProcedure.lex | 163 +++++++++++++++++ .../rules/TestFortran77RulesDefinition.java | 2 +- .../src/main/resources/fortran90-rules.xml | 8 +- .../lex/F90DESIGNArgumentsProcedure.lex | 171 ++++++++++++++++++ .../rules/TestFortran90RulesDefinition.java | 2 +- 6 files changed, 349 insertions(+), 3 deletions(-) create mode 100644 fortran77-rules/src/main/resources/lex/F77DESIGNArgumentsProcedure.lex create mode 100644 fortran90-rules/src/main/resources/lex/F90DESIGNArgumentsProcedure.lex diff --git a/fortran77-rules/src/main/resources/fortran77-rules.xml b/fortran77-rules/src/main/resources/fortran77-rules.xml index 26e7b167..e5621934 100644 --- a/fortran77-rules/src/main/resources/fortran77-rules.xml +++ b/fortran77-rules/src/main/resources/fortran77-rules.xml @@ -354,4 +354,10 @@ F77.DESIGN.ProcedureLines fr.cnes.icode.fortran77 + + fr.cnes.icode.fortran77.rules.F77DESIGNArgumentsProcedure + fr.cnes.icode.fortran77.rules.F77DESIGNArgumentsProcedure + F77.DESIGN.ArgumentsProcedure + fr.cnes.icode.fortran77 + diff --git a/fortran77-rules/src/main/resources/lex/F77DESIGNArgumentsProcedure.lex b/fortran77-rules/src/main/resources/lex/F77DESIGNArgumentsProcedure.lex new file mode 100644 index 00000000..3a26f3cc --- /dev/null +++ b/fortran77-rules/src/main/resources/lex/F77DESIGNArgumentsProcedure.lex @@ -0,0 +1,163 @@ +/************************************************************************************************/ +/* i-Code CNES is a static code analyzer. */ +/* This software is a free software, under the terms of the Eclipse Public License version 1.0. */ +/* http://www.eclipse.org/legal/epl-v10.html */ +/************************************************************************************************/ +/***************************************************************************************/ +/* This file is used to generate a rule checker for F77.DESIGN.ArgumentsProcedure rule.*/ +/* For further information on this, we advise you to refer to RNC manuals. */ +/* As many comments have been done on the ExampleRule.lex file, this file */ +/* will restrain its comments on modifications. */ +/* */ +/***************************************************************************************/ +package fr.cnes.icode.fortran77.rules; +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.File; +import java.util.List; +import java.util.LinkedList; +import fr.cnes.icode.data.AbstractChecker; +import fr.cnes.icode.data.CheckResult; +import fr.cnes.icode.exception.JFlexException; +%% +%class F77DESIGNArgumentsProcedure +%extends AbstractChecker +%public +%column +%line +%ignorecase +%function run +%yylexthrow JFlexException +%type List +%state COMMENT, NAMING, NEW_LINE, LINE, AVOID, YYINITIAL, ARGUMENTS_DEF +COMMENT_WORD = \! | c | C | \* +PROCEDURES = PROCEDURE | procedure | SUBROUTINE | subroutine | FUNCTION | function +PROG = PROGRAM | program +MOD = MODULE | module +INTER = INTERFACE | interface +TYPE = {PROG} | {MOD} | {INTER} +VAR = [a-zA-Z][a-zA-Z0-9\_]* +STRING = \'[^\']*\' | \"[^\"]*\" +SPACE = [\ \r\t\f] +END = END | end +INITARG = \( +FINARG = \) +COMA = \, + +%{ + String location = "MAIN PROGRAM"; + private String parsedFileName; + int arguments = 1; + boolean procStarted = false; + boolean nameRead = false; + + public F77DESIGNArgumentsProcedure(){ + } + + @Override + public void setInputFile(final File file) throws FileNotFoundException { + super.setInputFile(file); + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new File(file.getAbsolutePath())); + } + + private void checkArgumentsProcedure() { + if(procStarted && arguments > 7) { + this.setError(location,"This procedure contains more than 7 arguments: " + arguments, yyline+1); + } + procStarted = false; + nameRead = false; + } + +%} +%eofval{ + return getCheckResults(); +%eofval} +%eofclose +%% +/************************/ + +/************************/ +/* COMMENT STATE */ +/************************/ + + { + \n {yybegin(NEW_LINE);} + . {} + } +/************************/ +/* AVOID STATE */ +/************************/ + \n {yybegin(NEW_LINE);} + . {} +/************************/ +/* NAMING STATE */ +/************************/ + + { + {VAR} {yybegin(AVOID);} + \n {yybegin(NEW_LINE);} + . {} + } +/************************/ +/* YYINITIAL STATE */ +/************************/ + + { + {COMMENT_WORD} {yybegin(COMMENT);} + {STRING} {yybegin(LINE);} + {TYPE} {yybegin(NAMING);} + {END} {yybegin(AVOID);} + {PROCEDURES} {location = yytext(); procStarted = true; yybegin(ARGUMENTS_DEF);} + {SPACE} {} + \n {yybegin(NEW_LINE);} + . {yybegin(LINE);} + } +/************************/ +/* ARGUMENTS_DEF STATE */ +/************************/ + + { + {VAR} {if(!nameRead) {location = location + " " + yytext(); nameRead = true;}} + {INITARG} {arguments = 1;} + {COMA} {arguments++;} + {FINARG} {checkArgumentsProcedure(); yybegin(AVOID);} + \n {if(procStarted == false) yybegin(NEW_LINE);} + . {} + } +/************************/ +/* NEW_LINE STATE */ +/************************/ + + { + {COMMENT_WORD} {yybegin(COMMENT);} + {STRING} {yybegin(LINE);} + {TYPE} {yybegin(NAMING);} + {END} {yybegin(AVOID);} + {PROCEDURES} {location = yytext(); procStarted = true; yybegin(ARGUMENTS_DEF);} + {SPACE} {} + \n {yybegin(NEW_LINE);} + . {yybegin(LINE);} + } +/************************/ +/* LINE STATE */ +/************************/ + + { + {COMMENT_WORD} {} + {STRING} {} + {TYPE} {yybegin(NAMING);} + {END} {yybegin(AVOID);} + {PROCEDURES} {location = yytext(); procStarted = true; yybegin(ARGUMENTS_DEF);} + {VAR} {} + \n {yybegin(NEW_LINE);} + . {} + } +/************************/ +/* ERROR STATE */ +/************************/ + [^] { + + final String errorMessage = "Analysis failure : Your file could not be analyzed. Please verify that it was encoded in an UNIX format."; + throw new JFlexException(this.getClass().getName(), parsedFileName, errorMessage, yytext(), yyline, yycolumn); + } diff --git a/fortran77-rules/src/test/java/fr/cnes/icode/fortran77/rules/TestFortran77RulesDefinition.java b/fortran77-rules/src/test/java/fr/cnes/icode/fortran77/rules/TestFortran77RulesDefinition.java index 0698979e..fce8b053 100644 --- a/fortran77-rules/src/test/java/fr/cnes/icode/fortran77/rules/TestFortran77RulesDefinition.java +++ b/fortran77-rules/src/test/java/fr/cnes/icode/fortran77/rules/TestFortran77RulesDefinition.java @@ -16,7 +16,7 @@ public void testDefinitionOfDefaultRules() { rulesDefinition.define(); - Assertions.assertEquals(59, rulesDefinition.list().size()); + Assertions.assertEquals(60, rulesDefinition.list().size()); } } diff --git a/fortran90-rules/src/main/resources/fortran90-rules.xml b/fortran90-rules/src/main/resources/fortran90-rules.xml index db0d2ba2..30f8ec03 100644 --- a/fortran90-rules/src/main/resources/fortran90-rules.xml +++ b/fortran90-rules/src/main/resources/fortran90-rules.xml @@ -390,4 +390,10 @@ F90.DESIGN.ProcedureLines fr.cnes.icode.fortran90 - \ No newline at end of file + + fr.cnes.icode.fortran90.rules.F90DESIGNArgumentsProcedure + fr.cnes.icode.fortran90.rules.F90DESIGNArgumentsProcedure + F90.DESIGN.ArgumentsProcedure + fr.cnes.icode.fortran90 + + diff --git a/fortran90-rules/src/main/resources/lex/F90DESIGNArgumentsProcedure.lex b/fortran90-rules/src/main/resources/lex/F90DESIGNArgumentsProcedure.lex new file mode 100644 index 00000000..ec654db5 --- /dev/null +++ b/fortran90-rules/src/main/resources/lex/F90DESIGNArgumentsProcedure.lex @@ -0,0 +1,171 @@ +/************************************************************************************************/ +/* i-Code CNES is a static code analyzer. */ +/* This software is a free software, under the terms of the Eclipse Public License version 1.0. */ +/* http://www.eclipse.org/legal/epl-v10.html */ +/************************************************************************************************/ +/***************************************************************************************/ +/* This file is used to generate a rule checker for F90.DESIGN.ArgumentsProcedure rule.*/ +/* For further information on this, we advise you to refer to RNC manuals. */ +/* As many comments have been done on the ExampleRule.lex file, this file */ +/* will restrain its comments on modifications. */ +/* */ +/***************************************************************************************/ + +package fr.cnes.icode.fortran90.rules; + +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.File; +import java.util.List; +import java.util.LinkedList; + +import fr.cnes.icode.data.AbstractChecker; +import fr.cnes.icode.data.CheckResult; +import fr.cnes.icode.exception.JFlexException; + +%% + +%class F90DESIGNArgumentsProcedure +%extends AbstractChecker +%public +%column +%line +%ignorecase + +%function run +%yylexthrow JFlexException +%type List +%state COMMENT, NAMING, NEW_LINE, LINE, AVOID, YYINITIAL, ARGUMENTS_DEF + +COMMENT_WORD = \! +PROCEDURES = PROCEDURE | procedure | SUBROUTINE | subroutine | FUNCTION | function +PROG = PROGRAM | program +MOD = MODULE | module +INTER = INTERFACE | interface +TYPE = {PROG} | {MOD} | {INTER} +VAR = [a-zA-Z][a-zA-Z0-9\_]* +STRING = \'[^\']*\' | \"[^\"]*\" +SPACE = [\ \r\t\f] +END = END[\ ]*{PROCEDURES} | end[\ ]*{PROCEDURES} +INITARG = \( +FINARG = \) +COMA = \, + + +%{ + String location = "MAIN PROGRAM"; + private String parsedFileName; + int arguments = 1; + boolean procStarted = false; + boolean nameRead = false; + + public F90DESIGNArgumentsProcedure(){ + } + + @Override + public void setInputFile(final File file) throws FileNotFoundException { + super.setInputFile(file); + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new File(file.getAbsolutePath())); + } + + private void checkArgumentsProcedure() { + if(procStarted && arguments > 7) { + this.setError(location,"This procedure contains more than 7 arguments: " + arguments, yyline+1); + } + procStarted = false; + nameRead = false; + } + +%} +%eofval{ + return getCheckResults(); +%eofval} +%eofclose +%% +/************************/ + +/************************/ +/* COMMENT STATE */ +/************************/ + + { + \n {yybegin(NEW_LINE);} + . {} + } +/************************/ +/* AVOID STATE */ +/************************/ + \n {yybegin(NEW_LINE);} + . {} +/************************/ +/* NAMING STATE */ +/************************/ + + { + {VAR} {yybegin(AVOID);} + \n {yybegin(NEW_LINE);} + . {} + } +/************************/ +/* YYINITIAL STATE */ +/************************/ + + { + {COMMENT_WORD} {yybegin(COMMENT);} + {STRING} {yybegin(LINE);} + {TYPE} {yybegin(NAMING);} + {END} {yybegin(AVOID);} + {PROCEDURES} {location = yytext(); procStarted = true; yybegin(ARGUMENTS_DEF);} + {SPACE} {} + \n {yybegin(NEW_LINE);} + . {yybegin(LINE);} + } +/************************/ +/* ARGUMENTS_DEF STATE */ +/************************/ + + { + {VAR} {if(!nameRead) {location = location + " " + yytext(); nameRead = true;}} + {INITARG} {arguments = 1;} + {COMA} {arguments++;} + {FINARG} {checkArgumentsProcedure(); yybegin(AVOID);} + \n {if(procStarted == false) yybegin(NEW_LINE);} + . {} + } +/************************/ +/* NEW_LINE STATE */ +/************************/ + + { + {COMMENT_WORD} {yybegin(COMMENT);} + {STRING} {yybegin(LINE);} + {TYPE} {yybegin(NAMING);} + {END} {yybegin(AVOID);} + {PROCEDURES} {location = yytext(); procStarted = true; yybegin(ARGUMENTS_DEF);} + {SPACE} {} + \n {yybegin(NEW_LINE);} + . {yybegin(LINE);} + } +/************************/ +/* LINE STATE */ +/************************/ + + { + {COMMENT_WORD} {yybegin(COMMENT);} + {STRING} {} + {TYPE} {yybegin(NAMING);} + {END} {yybegin(AVOID);} + {PROCEDURES} {location = yytext(); procStarted = true; yybegin(ARGUMENTS_DEF);} + {VAR} {} + \n {yybegin(NEW_LINE);} + . {} + } +/************************/ +/* ERROR STATE */ +/************************/ + [^] { + + final String errorMessage = "Analysis failure : Your file could not be analyzed. Please verify that it was encoded in an UNIX format."; + throw new JFlexException(this.getClass().getName(), parsedFileName, errorMessage, yytext(), yyline, yycolumn); + } diff --git a/fortran90-rules/src/test/java/fr/cnes/icode/fortran90/rules/TestFortran90RulesDefinition.java b/fortran90-rules/src/test/java/fr/cnes/icode/fortran90/rules/TestFortran90RulesDefinition.java index e530d4da..1c80f2f6 100644 --- a/fortran90-rules/src/test/java/fr/cnes/icode/fortran90/rules/TestFortran90RulesDefinition.java +++ b/fortran90-rules/src/test/java/fr/cnes/icode/fortran90/rules/TestFortran90RulesDefinition.java @@ -16,7 +16,7 @@ public void testDefinitionOfDefaultRules() { rulesDefinition.define(); - Assertions.assertEquals(65, rulesDefinition.list().size()); + Assertions.assertEquals(66, rulesDefinition.list().size()); } } From fd38d56072fa9d17980cf0a5eaf5a796cc1d022a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ana=20D=C3=ADaz=20Mu=C3=B1oz?= Date: Thu, 15 Dec 2022 17:12:31 +0100 Subject: [PATCH 07/32] Rule CyclomaticComplexity Rule to check the maximum value of the cyclomatic complexity in each function, which at most must be 15. --- .../src/main/resources/fortran77-rules.xml | 6 + .../lex/F77DESIGNCyclomaticComplexity.lex | 154 +++++++++++++++++ .../rules/TestFortran77RulesDefinition.java | 2 +- .../src/main/resources/fortran90-rules.xml | 6 + .../lex/F90DESIGNCyclomaticComplexity.lex | 158 ++++++++++++++++++ .../rules/TestFortran90RulesDefinition.java | 2 +- 6 files changed, 326 insertions(+), 2 deletions(-) create mode 100644 fortran77-rules/src/main/resources/lex/F77DESIGNCyclomaticComplexity.lex create mode 100644 fortran90-rules/src/main/resources/lex/F90DESIGNCyclomaticComplexity.lex diff --git a/fortran77-rules/src/main/resources/fortran77-rules.xml b/fortran77-rules/src/main/resources/fortran77-rules.xml index e5621934..64c23614 100644 --- a/fortran77-rules/src/main/resources/fortran77-rules.xml +++ b/fortran77-rules/src/main/resources/fortran77-rules.xml @@ -360,4 +360,10 @@ F77.DESIGN.ArgumentsProcedure fr.cnes.icode.fortran77 + + fr.cnes.icode.fortran77.rules.F77DESIGNCyclomaticComplexity + fr.cnes.icode.fortran77.rules.F77DESIGNCyclomaticComplexity + F77.DESIGN.CyclomaticComplexity + fr.cnes.icode.fortran77 + diff --git a/fortran77-rules/src/main/resources/lex/F77DESIGNCyclomaticComplexity.lex b/fortran77-rules/src/main/resources/lex/F77DESIGNCyclomaticComplexity.lex new file mode 100644 index 00000000..388ea3e1 --- /dev/null +++ b/fortran77-rules/src/main/resources/lex/F77DESIGNCyclomaticComplexity.lex @@ -0,0 +1,154 @@ +/************************************************************************************************/ +/* i-Code CNES is a static code analyzer. */ +/* This software is a free software, under the terms of the Eclipse Public License version 1.0. */ +/* http://www.eclipse.org/legal/epl-v10.html */ +/************************************************************************************************/ +/********************************************************************************************/ +/* This file is used to generate a rule checker for F77.DESIGN.CyclomaticComplexity rule. */ +/* For further information on this, we advise you to refer to RNC manuals. */ +/* As many comments have been done on the ExampleRule.lex file, this file */ +/* will restrain its comments on modifications. */ +/* */ +/********************************************************************************************/ +package fr.cnes.icode.fortran77.rules; +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.File; +import java.util.List; +import java.util.LinkedList; +import fr.cnes.icode.data.AbstractChecker; +import fr.cnes.icode.data.CheckResult; +import fr.cnes.icode.exception.JFlexException; +%% +%class F77DESIGNCyclomaticComplexity +%extends AbstractChecker +%public +%column +%line +%function run +%yylexthrow JFlexException +%type List +%state COMMENT, NAMING, NEW_LINE, LINE, AVOID +COMMENT_WORD = \! | c | C | \* +FUNC = FUNCTION | function +PROC = PROCEDURE | procedure +SUB = SUBROUTINE | subroutine +PROG = PROGRAM | program +MOD = MODULE | module +INTER = INTERFACE | interface +TYPE = {PROG} | {MOD} | {INTER} +PROCEDURES = {FUNC} | {PROC} | {SUB} +UNION = \.AND\. | \.and\. | \.OR\. | \.or\. +CICLO = DO | do | IF | if | ELSE[\ ]*IF | else[\ ]*if +CLOSING = END[\ ]*IF | end[\ ]*if | END[\ ]*DO | end[\ ]*do +VAR = [a-zA-Z][a-zA-Z0-9\_]* +END = END | end +STRING = \'[^\']*\' | \"[^\"]*\" + +%{ + String location = "MAIN PROGRAM"; + private String parsedFileName; + int numCyclomatic = 1; + int procedureLine = 0; + + public F77DESIGNCyclomaticComplexity(){ + } + + @Override + public void setInputFile(final File file) throws FileNotFoundException { + super.setInputFile(file); + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new File(file.getAbsolutePath())); + } + + private void checkTotalComplexity() { + if(numCyclomatic > 15 ) { + setError(location,"The cyclomatic complexity of this function is more than 15: " +numCyclomatic, procedureLine+1); + } + } + +%} +%eofval{ + return getCheckResults(); +%eofval} +%eofclose +%% +/************************/ + +/************************/ +/* COMMENT STATE */ +/************************/ + + { + \n {yybegin(NEW_LINE);} + . {} + } +/************************/ +/* AVOID STATE */ +/************************/ + \n {yybegin(NEW_LINE);} + . {} +/************************/ +/* NAMING STATE */ +/************************/ + + { + {VAR} {location = location + " " + yytext(); yybegin(AVOID);} + \n {yybegin(NEW_LINE);} + . {} + } +/************************/ +/* YYINITIAL STATE */ +/************************/ + + { + {COMMENT_WORD} {yybegin(COMMENT);} + {STRING} {yybegin(LINE);} + {TYPE} {yybegin(AVOID);} + {PROCEDURES} {numCyclomatic = 1; location = yytext(); procedureLine = yyline; yybegin(NAMING);} + \n {yybegin(NEW_LINE);} + . {yybegin(LINE);} + } +/************************/ +/* NEW_LINE STATE */ +/************************/ + + { + {COMMENT_WORD} {yybegin(COMMENT);} + {STRING} {yybegin(LINE);} + {TYPE} {yybegin(AVOID);} + {PROCEDURES} {numCyclomatic = 1; location = yytext(); procedureLine = yyline; yybegin(NAMING);} + {CICLO} {numCyclomatic++; yybegin(LINE);} + {UNION} {numCyclomatic++; yybegin(LINE);} + {CLOSING} {yybegin(LINE);} + {END} {checkTotalComplexity();} + {VAR} {yybegin(LINE);} + \n {} + . {yybegin(LINE);} + } +/************************/ +/* LINE STATE */ +/************************/ + + { + {COMMENT_WORD} {yybegin(COMMENT);} + {STRING} {} + {TYPE} {yybegin(AVOID);} + {PROCEDURES} {numCyclomatic = 1; location = yytext(); procedureLine = yyline; yybegin(NAMING);} + {CICLO} {numCyclomatic++;} + {UNION} {numCyclomatic++;} + {CLOSING} {} + {END} {checkTotalComplexity();} + {VAR} {} + \n {yybegin(NEW_LINE);} + . {} + } +/************************/ +/* ERROR STATE */ +/************************/ + [^] { + + final String errorMessage = "Analysis failure : Your file could not be analyzed. Please verify that it was encoded in an UNIX format."; + throw new JFlexException(this.getClass().getName(), parsedFileName, + errorMessage, yytext(), yyline, yycolumn); + } diff --git a/fortran77-rules/src/test/java/fr/cnes/icode/fortran77/rules/TestFortran77RulesDefinition.java b/fortran77-rules/src/test/java/fr/cnes/icode/fortran77/rules/TestFortran77RulesDefinition.java index fce8b053..38df21a3 100644 --- a/fortran77-rules/src/test/java/fr/cnes/icode/fortran77/rules/TestFortran77RulesDefinition.java +++ b/fortran77-rules/src/test/java/fr/cnes/icode/fortran77/rules/TestFortran77RulesDefinition.java @@ -16,7 +16,7 @@ public void testDefinitionOfDefaultRules() { rulesDefinition.define(); - Assertions.assertEquals(60, rulesDefinition.list().size()); + Assertions.assertEquals(61, rulesDefinition.list().size()); } } diff --git a/fortran90-rules/src/main/resources/fortran90-rules.xml b/fortran90-rules/src/main/resources/fortran90-rules.xml index 30f8ec03..ac76112b 100644 --- a/fortran90-rules/src/main/resources/fortran90-rules.xml +++ b/fortran90-rules/src/main/resources/fortran90-rules.xml @@ -396,4 +396,10 @@ F90.DESIGN.ArgumentsProcedure fr.cnes.icode.fortran90 + + fr.cnes.icode.fortran90.rules.F90DESIGNCyclomaticComplexity + fr.cnes.icode.fortran90.rules.F90DESIGNCyclomaticComplexity + F90.DESIGN.CyclomaticComplexity + fr.cnes.icode.fortran90 + diff --git a/fortran90-rules/src/main/resources/lex/F90DESIGNCyclomaticComplexity.lex b/fortran90-rules/src/main/resources/lex/F90DESIGNCyclomaticComplexity.lex new file mode 100644 index 00000000..2e26613d --- /dev/null +++ b/fortran90-rules/src/main/resources/lex/F90DESIGNCyclomaticComplexity.lex @@ -0,0 +1,158 @@ +/************************************************************************************************/ +/* i-Code CNES is a static code analyzer. */ +/* This software is a free software, under the terms of the Eclipse Public License version 1.0. */ +/* http://www.eclipse.org/legal/epl-v10.html */ +/************************************************************************************************/ +/********************************************************************************************/ +/* This file is used to generate a rule checker for F90.DESIGN.CyclomaticComplexity rule. */ +/* For further information on this, we advise you to refer to RNC manuals. */ +/* As many comments have been done on the ExampleRule.lex file, this file */ +/* will restrain its comments on modifications. */ +/* */ +/********************************************************************************************/ +package fr.cnes.icode.fortran90.rules; +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.File; +import java.util.List; +import java.util.LinkedList; +import fr.cnes.icode.data.AbstractChecker; +import fr.cnes.icode.data.CheckResult; +import fr.cnes.icode.exception.JFlexException; +%% +%class F90DESIGNCyclomaticComplexity +%extends AbstractChecker +%public +%column +%line +%function run +%yylexthrow JFlexException +%type List +%state COMMENT, NAMING, NEW_LINE, LINE, AVOID +COMMENT_WORD = \! +FUNC = FUNCTION | function +PROC = PROCEDURE | procedure +SUB = SUBROUTINE | subroutine +PROG = PROGRAM | program +MOD = MODULE | module +INTER = INTERFACE | interface +TYPE = {PROG} | {MOD} | {INTER} +PROCEDURES = {FUNC} | {PROC} | {SUB} +UNION = \.AND\. | \.and\. | \.OR\. | \.or\. +CICLO = DO | do | IF | if | ELSE[\ ]*IF | else[\ ]*if | SELECT | select | + DO [\ ]+ WHILE | do [\ ]+ while | WHILE [\ ]* \( [^\)]* \) [\ ]* DO | + while [\ ]* \( [^\)]* \) [\ ]* do | WHILE | while | WHERE | where | + ELSEWHERE | elsewhere +CLOSING = END[\ ]*IF | end[\ ]*if | END[\ ]*DO | end[\ ]*do | + END[\ ]*WHERE | end[\ ]*where | END[\ ]*SELECT | end[\ ]*select +VAR = [a-zA-Z][a-zA-Z0-9\_]* +END = END[\ ]*{PROCEDURES} | end[\ ]*{PROCEDURES} +STRING = \'[^\']*\' | \"[^\"]*\" + +%{ + String location = "MAIN PROGRAM"; + private String parsedFileName; + int numCyclomatic = 1; + int procedureLine = 0; + + public F90DESIGNCyclomaticComplexity(){ + } + + @Override + public void setInputFile(final File file) throws FileNotFoundException { + super.setInputFile(file); + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new File(file.getAbsolutePath())); + } + + private void checkTotalComplexity() { + if(numCyclomatic > 15 ) { + setError(location,"The cyclomatic complexity of this function is more than 15: " +numCyclomatic, procedureLine+1); + } + } + +%} +%eofval{ + return getCheckResults(); +%eofval} +%eofclose +%% +/************************/ + +/************************/ +/* COMMENT STATE */ +/************************/ + + { + \n {yybegin(NEW_LINE);} + . {} + } +/************************/ +/* AVOID STATE */ +/************************/ + \n {yybegin(NEW_LINE);} + . {} +/************************/ +/* NAMING STATE */ +/************************/ + + { + {VAR} {location = location + " " + yytext(); yybegin(AVOID);} + \n {yybegin(NEW_LINE);} + . {} + } +/************************/ +/* YYINITIAL STATE */ +/************************/ + + { + {COMMENT_WORD} {yybegin(COMMENT);} + {STRING} {yybegin(LINE);} + {TYPE} {yybegin(AVOID);} + {PROCEDURES} {numCyclomatic = 1; location = yytext(); procedureLine = yyline; yybegin(NAMING);} + \n {yybegin(NEW_LINE);} + . {yybegin(LINE);} + } +/************************/ +/* NEW_LINE STATE */ +/************************/ + + { + {COMMENT_WORD} {yybegin(COMMENT);} + {STRING} {yybegin(LINE);} + {TYPE} {yybegin(AVOID);} + {PROCEDURES} {numCyclomatic = 1; location = yytext(); procedureLine = yyline; yybegin(NAMING);} + {CICLO} {numCyclomatic++; yybegin(LINE);} + {UNION} {numCyclomatic++; yybegin(LINE);} + {CLOSING} {yybegin(LINE);} + {END} {checkTotalComplexity();} + {VAR} {yybegin(LINE);} + \n {} + . {yybegin(LINE);} + } +/************************/ +/* LINE STATE */ +/************************/ + + { + {COMMENT_WORD} {yybegin(COMMENT);} + {STRING} {} + {TYPE} {yybegin(AVOID);} + {PROCEDURES} {numCyclomatic = 1; location = yytext(); procedureLine = yyline; yybegin(NAMING);} + {CICLO} {numCyclomatic++;} + {UNION} {numCyclomatic++;} + {CLOSING} {} + {END} {checkTotalComplexity();} + {VAR} {} + \n {yybegin(NEW_LINE);} + . {} + } +/************************/ +/* ERROR STATE */ +/************************/ + [^] { + + final String errorMessage = "Analysis failure : Your file could not be analyzed. Please verify that it was encoded in an UNIX format."; + throw new JFlexException(this.getClass().getName(), parsedFileName, + errorMessage, yytext(), yyline, yycolumn); + } diff --git a/fortran90-rules/src/test/java/fr/cnes/icode/fortran90/rules/TestFortran90RulesDefinition.java b/fortran90-rules/src/test/java/fr/cnes/icode/fortran90/rules/TestFortran90RulesDefinition.java index 1c80f2f6..4b54ce13 100644 --- a/fortran90-rules/src/test/java/fr/cnes/icode/fortran90/rules/TestFortran90RulesDefinition.java +++ b/fortran90-rules/src/test/java/fr/cnes/icode/fortran90/rules/TestFortran90RulesDefinition.java @@ -16,7 +16,7 @@ public void testDefinitionOfDefaultRules() { rulesDefinition.define(); - Assertions.assertEquals(66, rulesDefinition.list().size()); + Assertions.assertEquals(67, rulesDefinition.list().size()); } } From a35a601d5a27ce8c2d2dfafed8b4fd255a79f9e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ana=20D=C3=ADaz=20Mu=C3=B1oz?= Date: Thu, 15 Dec 2022 17:17:48 +0100 Subject: [PATCH 08/32] Rule LogicUnit Rule to check that only one module or program is declared in each file. --- .../src/main/resources/fortran77-rules.xml | 6 + .../main/resources/lex/F77DESIGNLogicUnit.lex | 202 ++++++++++++++++++ .../rules/TestFortran77RulesDefinition.java | 2 +- .../src/main/resources/fortran90-rules.xml | 6 + .../main/resources/lex/F90DESIGNLogicUnit.lex | 202 ++++++++++++++++++ .../rules/TestFortran90RulesDefinition.java | 2 +- 6 files changed, 418 insertions(+), 2 deletions(-) create mode 100644 fortran77-rules/src/main/resources/lex/F77DESIGNLogicUnit.lex create mode 100644 fortran90-rules/src/main/resources/lex/F90DESIGNLogicUnit.lex diff --git a/fortran77-rules/src/main/resources/fortran77-rules.xml b/fortran77-rules/src/main/resources/fortran77-rules.xml index 64c23614..a3a6fc25 100644 --- a/fortran77-rules/src/main/resources/fortran77-rules.xml +++ b/fortran77-rules/src/main/resources/fortran77-rules.xml @@ -366,4 +366,10 @@ F77.DESIGN.CyclomaticComplexity fr.cnes.icode.fortran77 + + fr.cnes.icode.fortran77.rules.F77DESIGNLogicUnit + fr.cnes.icode.fortran77.rules.F77DESIGNLogicUnit + F77.DESIGN.LogicUnit + fr.cnes.icode.fortran77 + diff --git a/fortran77-rules/src/main/resources/lex/F77DESIGNLogicUnit.lex b/fortran77-rules/src/main/resources/lex/F77DESIGNLogicUnit.lex new file mode 100644 index 00000000..85882666 --- /dev/null +++ b/fortran77-rules/src/main/resources/lex/F77DESIGNLogicUnit.lex @@ -0,0 +1,202 @@ +/************************************************************************************************/ +/* i-Code CNES is a static code analyzer. */ +/* This software is a free software, under the terms of the Eclipse Public License version 1.0. */ +/* http://www.eclipse.org/legal/epl-v10.html */ +/************************************************************************************************/ + +/*****************************************************************************/ +/* This file is used to generate a rule checker for F77.DESIGN.Interface rule. */ +/* For further information on this, we advise you to refer to RNC manuals. */ +/* As many comments have been done on the ExampleRule.lex file, this file */ +/* will restrain its comments on modifications. */ +/* */ +/*****************************************************************************/ + +package fr.cnes.icode.fortran77.rules; + +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.File; +import java.util.List; +import java.util.LinkedList; + +import fr.cnes.icode.data.AbstractChecker; +import fr.cnes.icode.data.CheckResult; +import fr.cnes.icode.exception.JFlexException; + +%% + +%class F77DESIGNLogicUnit +%extends AbstractChecker +%public +%column +%line +%ignorecase + +%function run +%yylexthrow JFlexException +%type List + +%state COMMENT, NAMING, NEW_LINE, LINE, AVOID, MODULE_DEF, PROGRAM_DEF + + +COMMENT_WORD = \! | c | C | \* +FUNC = FUNCTION | function +PROC = PROCEDURE | procedure +SUB = SUBROUTINE | subroutine +PROG = PROGRAM | program +MOD = MODULE | module +TYPE = {FUNC} | {PROC} | {SUB} +SPACE = [\ \t\f] +VAR = [a-zA-Z][a-zA-Z0-9\_]* +STRING = \'[^\']*\' | \"[^\"]*\" +END = end | END + + + +%{ + String location = "MAIN PROGRAM"; + private String parsedFileName; + List errors = new LinkedList(); + int numUnits = 0; + + public F77DESIGNLogicUnit(){ + } + + @Override + public void setInputFile(final File file) throws FileNotFoundException { + super.setInputFile(file); + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new File(file.getAbsolutePath())); + } + +%} + +%eofval{ + return getCheckResults(); +%eofval} + +%eofclose +%% + + + +/************************/ + + {COMMENT_WORD} {yybegin(COMMENT);} + + +/************************/ +/* COMMENT STATE */ +/************************/ + + { + \n {yybegin(NEW_LINE);} + . {} + } + +/************************/ +/* AVOID STATE */ +/************************/ + \n|\r {yybegin(NEW_LINE);} + . {} + + +/************************/ +/* NAMING STATE */ +/************************/ + + { + {VAR} {location = location + " " + yytext(); + yybegin(COMMENT);} + \n {yybegin(NEW_LINE);} + . {} + } + + +/************************/ +/* YYINITIAL STATE */ +/************************/ + + { + {MOD} {location = yytext(); yybegin(MODULE_DEF);} + {PROG} {location = yytext(); yybegin(PROGRAM_DEF);} + \n {yybegin(NEW_LINE);} + . {yybegin(LINE);} + } + +/************************/ +/* MODULE_DEF STATE */ +/************************/ + + { + {PROC} {yybegin(AVOID);} + {VAR} {location = location + " " + yytext(); + numUnits++; + if(numUnits > 1) { + this.setError(location,"This file contains more than one logical unit (program/module).", yyline+1); + } + } + \n {yybegin(NEW_LINE);} + . {} + } + + +/************************/ +/* PROGRAM_DEF STATE */ +/************************/ + + { + {VAR} {location = location + " " + yytext(); + numUnits++; + if(numUnits > 1) { + this.setError(location,"This file contains more than one logical unit (program/module).", yyline+1); + } + } + \n {yybegin(NEW_LINE);} + . {} + } + + +/************************/ +/* NEW_LINE STATE */ +/************************/ + + { + {COMMENT_WORD} {yybegin(COMMENT);} + {STRING} {yybegin(LINE);} + {MOD} {location = yytext(); yybegin(MODULE_DEF);} + {PROG} {location = yytext(); yybegin(PROGRAM_DEF);} + {TYPE} {yybegin(LINE);} + {END} {yybegin(AVOID);} + {VAR} {yybegin(LINE);} + \n {} + . {yybegin(LINE);} + } + + +/************************/ +/* LINE STATE */ +/************************/ + + { + {STRING} {} + {MOD} {location = yytext(); yybegin(MODULE_DEF);} + {PROG} {location = yytext(); yybegin(PROGRAM_DEF);} + {TYPE} {yybegin(AVOID);} + {END} {yybegin(AVOID);} + {VAR} {} + \n {yybegin(NEW_LINE);} + . {} + } + + +/************************/ +/* ERROR STATE */ +/************************/ + [^] { + + final String errorMessage = "Analysis failure : Your file could not be analyzed. Please verify that it was encoded in an UNIX format."; + throw new JFlexException(this.getClass().getName(), parsedFileName, + errorMessage, yytext(), yyline, yycolumn); + } diff --git a/fortran77-rules/src/test/java/fr/cnes/icode/fortran77/rules/TestFortran77RulesDefinition.java b/fortran77-rules/src/test/java/fr/cnes/icode/fortran77/rules/TestFortran77RulesDefinition.java index 38df21a3..251daa28 100644 --- a/fortran77-rules/src/test/java/fr/cnes/icode/fortran77/rules/TestFortran77RulesDefinition.java +++ b/fortran77-rules/src/test/java/fr/cnes/icode/fortran77/rules/TestFortran77RulesDefinition.java @@ -16,7 +16,7 @@ public void testDefinitionOfDefaultRules() { rulesDefinition.define(); - Assertions.assertEquals(61, rulesDefinition.list().size()); + Assertions.assertEquals(62, rulesDefinition.list().size()); } } diff --git a/fortran90-rules/src/main/resources/fortran90-rules.xml b/fortran90-rules/src/main/resources/fortran90-rules.xml index ac76112b..c70481cb 100644 --- a/fortran90-rules/src/main/resources/fortran90-rules.xml +++ b/fortran90-rules/src/main/resources/fortran90-rules.xml @@ -402,4 +402,10 @@ F90.DESIGN.CyclomaticComplexity fr.cnes.icode.fortran90 + + fr.cnes.icode.fortran90.rules.F90DESIGNLogicUnit + fr.cnes.icode.fortran90.rules.F90DESIGNLogicUnit + F90.DESIGN.LogicUnit + fr.cnes.icode.fortran90 + diff --git a/fortran90-rules/src/main/resources/lex/F90DESIGNLogicUnit.lex b/fortran90-rules/src/main/resources/lex/F90DESIGNLogicUnit.lex new file mode 100644 index 00000000..9a09674a --- /dev/null +++ b/fortran90-rules/src/main/resources/lex/F90DESIGNLogicUnit.lex @@ -0,0 +1,202 @@ +/************************************************************************************************/ +/* i-Code CNES is a static code analyzer. */ +/* This software is a free software, under the terms of the Eclipse Public License version 1.0. */ +/* http://www.eclipse.org/legal/epl-v10.html */ +/************************************************************************************************/ + +/*****************************************************************************/ +/* This file is used to generate a rule checker for F90.DESIGN.Interface rule. */ +/* For further information on this, we advise you to refer to RNC manuals. */ +/* As many comments have been done on the ExampleRule.lex file, this file */ +/* will restrain its comments on modifications. */ +/* */ +/*****************************************************************************/ + +package fr.cnes.icode.fortran90.rules; + +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.File; +import java.util.List; +import java.util.LinkedList; + +import fr.cnes.icode.data.AbstractChecker; +import fr.cnes.icode.data.CheckResult; +import fr.cnes.icode.exception.JFlexException; + +%% + +%class F90DESIGNLogicUnit +%extends AbstractChecker +%public +%column +%line +%ignorecase + +%function run +%yylexthrow JFlexException +%type List + +%state COMMENT, NAMING, NEW_LINE, LINE, AVOID, MODULE_DEF, PROGRAM_DEF + + +COMMENT_WORD = \! +FUNC = FUNCTION | function +PROC = PROCEDURE | procedure +SUB = SUBROUTINE | subroutine +PROG = PROGRAM | program +MOD = MODULE | module +TYPE = {FUNC} | {PROC} | {SUB} +SPACE = [\ \t\f] +VAR = [a-zA-Z][a-zA-Z0-9\_]* +STRING = \'[^\']*\' | \"[^\"]*\" +END = end | END + + + +%{ + String location = "MAIN PROGRAM"; + private String parsedFileName; + List errors = new LinkedList(); + int numUnits = 0; + + + public F90DESIGNLogicUnit(){ + } + + @Override + public void setInputFile(final File file) throws FileNotFoundException { + super.setInputFile(file); + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new File(file.getAbsolutePath())); + } + +%} + +%eofval{ + return getCheckResults(); +%eofval} + +%eofclose +%% + + + +/************************/ + + {COMMENT_WORD} {yybegin(COMMENT);} + + +/************************/ +/* COMMENT STATE */ +/************************/ + + { + \n {yybegin(NEW_LINE);} + . {} + } + +/************************/ +/* AVOID STATE */ +/************************/ + \n|\r {yybegin(NEW_LINE);} + . {} + + +/************************/ +/* NAMING STATE */ +/************************/ + + { + {VAR} {location = location + " " + yytext(); + yybegin(COMMENT);} + \n {yybegin(NEW_LINE);} + . {} + } + + +/************************/ +/* YYINITIAL STATE */ +/************************/ + + { + {MOD} {location = yytext(); yybegin(MODULE_DEF);} + {PROG} {location = yytext(); yybegin(PROGRAM_DEF);} + \n {yybegin(NEW_LINE);} + . {yybegin(LINE);} + } + +/************************/ +/* MODULE_DEF STATE */ +/************************/ + + { + {PROC} {yybegin(AVOID);} + {VAR} {location = location + " " + yytext(); + numUnits++; + if(numUnits>1) { + this.setError(location,"This file contains more than one logical unit (program/module).", yyline+1); + } + } + \n {yybegin(NEW_LINE);} + . {} + } + + +/************************/ +/* PROGRAM_DEF STATE */ +/************************/ + + { + {VAR} {location = location + " " + yytext(); + numUnits++; + if(numUnits > 1) { + this.setError(location,"This file contains more than one logical unit (program/module).", yyline+1); + } + } + \n {yybegin(NEW_LINE);} + . {} + } + + +/************************/ +/* NEW_LINE STATE */ +/************************/ + + { + {STRING} {yybegin(LINE);} + {MOD} {location = yytext(); yybegin(MODULE_DEF);} + {PROG} {location = yytext(); yybegin(PROGRAM_DEF);} + {TYPE} {yybegin(LINE);} + {END} {yybegin(AVOID);} + {VAR} {yybegin(LINE);} + \n {} + . {yybegin(LINE);} + } + + +/************************/ +/* LINE STATE */ +/************************/ + + { + {STRING} {} + {MOD} {location = yytext(); yybegin(MODULE_DEF);} + {PROG} {location = yytext(); yybegin(PROGRAM_DEF);} + {TYPE} {yybegin(AVOID);} + {END} {yybegin(AVOID);} + {VAR} {} + \n {yybegin(NEW_LINE);} + . {} + } + + +/************************/ +/* ERROR STATE */ +/************************/ + [^] { + + final String errorMessage = "Analysis failure : Your file could not be analyzed. Please verify that it was encoded in an UNIX format."; + throw new JFlexException(this.getClass().getName(), parsedFileName, + errorMessage, yytext(), yyline, yycolumn); + } diff --git a/fortran90-rules/src/test/java/fr/cnes/icode/fortran90/rules/TestFortran90RulesDefinition.java b/fortran90-rules/src/test/java/fr/cnes/icode/fortran90/rules/TestFortran90RulesDefinition.java index 4b54ce13..51b645cc 100644 --- a/fortran90-rules/src/test/java/fr/cnes/icode/fortran90/rules/TestFortran90RulesDefinition.java +++ b/fortran90-rules/src/test/java/fr/cnes/icode/fortran90/rules/TestFortran90RulesDefinition.java @@ -16,7 +16,7 @@ public void testDefinitionOfDefaultRules() { rulesDefinition.define(); - Assertions.assertEquals(67, rulesDefinition.list().size()); + Assertions.assertEquals(68, rulesDefinition.list().size()); } } From f3fe8308403a89e301203496c116864a78de0008 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ana=20D=C3=ADaz=20Mu=C3=B1oz?= Date: Thu, 15 Dec 2022 17:25:46 +0100 Subject: [PATCH 09/32] Rule PercentageComment Rule to check that in each file there are at least 30% of lines of comments with respect to the total number of lines. --- .../src/main/resources/fortran77-rules.xml | 6 + .../lex/F77INSTPercentageComment.lex | 168 ++++++++++++++++++ .../rules/TestFortran77RulesDefinition.java | 2 +- .../src/main/resources/fortran90-rules.xml | 6 + .../lex/F90INSTPercentageComment.lex | 163 +++++++++++++++++ .../rules/TestFortran90RulesDefinition.java | 2 +- 6 files changed, 345 insertions(+), 2 deletions(-) create mode 100644 fortran77-rules/src/main/resources/lex/F77INSTPercentageComment.lex create mode 100644 fortran90-rules/src/main/resources/lex/F90INSTPercentageComment.lex diff --git a/fortran77-rules/src/main/resources/fortran77-rules.xml b/fortran77-rules/src/main/resources/fortran77-rules.xml index a3a6fc25..23118ae0 100644 --- a/fortran77-rules/src/main/resources/fortran77-rules.xml +++ b/fortran77-rules/src/main/resources/fortran77-rules.xml @@ -372,4 +372,10 @@ F77.DESIGN.LogicUnit fr.cnes.icode.fortran77 + + fr.cnes.icode.fortran77.rules.F77INSTPercentageComment + fr.cnes.icode.fortran77.rules.F77INSTPercentageComment + F77.INST.PercentageComment + fr.cnes.icode.fortran77 + diff --git a/fortran77-rules/src/main/resources/lex/F77INSTPercentageComment.lex b/fortran77-rules/src/main/resources/lex/F77INSTPercentageComment.lex new file mode 100644 index 00000000..dbb62228 --- /dev/null +++ b/fortran77-rules/src/main/resources/lex/F77INSTPercentageComment.lex @@ -0,0 +1,168 @@ +/************************************************************************************************/ +/* i-Code CNES is a static code analyzer. */ +/* This software is a free software, under the terms of the Eclipse Public License version 1.0. */ +/* http://www.eclipse.org/legal/epl-v10.html */ +/************************************************************************************************/ + +/****************************************************************************************/ +/* This file is used to generate a rule checker for F77.INST.PercentageComment rule. */ +/* For further information on this, we advise you to refer to RNC manuals. */ +/* As many comments have been done on the ExampleRule.lex file, this file */ +/* will restrain its comments on modifications. */ +/* */ +/****************************************************************************************/ + +package fr.cnes.icode.fortran77.rules; + +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.File; +import java.util.LinkedList; +import java.util.List; + +import fr.cnes.icode.data.AbstractChecker; +import fr.cnes.icode.data.CheckResult; +import fr.cnes.icode.exception.JFlexException; + +%% + +%class F77INSTPercentageComment +%extends AbstractChecker +%public +%column +%line + +%ignorecase + +%function run +%yylexthrow JFlexException +%type List + +%state COMMENT, NAMING, NEW_LINE, LINE, AVOID, INLINE_COMMENT +COMMENT_WORD = \! | c | C | \* +FREE_COMMENT = \! +FUNC = FUNCTION | function +PROC = PROCEDURE | procedure +SUB = SUBROUTINE | subroutine +PROG = PROGRAM | program +MOD = MODULE | module +INTER = INTERFACE | interface +TYPE = {FUNC} | {PROC} | {SUB} | {INTER} | {MOD} | {PROG} +VAR = [a-zA-Z][a-zA-Z0-9\_]* +CLOSING = END[\ ]*IF | end[\ ]*if | END[\ ]*DO | end[\ ]*do +END = END | end +STRING = \'[^\']*\' | \"[^\"]*\" +SPACE = [\ \r\t\f] + +%{ + String location = "MAIN PROGRAM"; + private String parsedFileName; + int commentsLines = 0; + int numTotal = 0; + double commentsPercent = 0; + + public F77INSTPercentageComment(){ + } + + @Override + public void setInputFile(final File file) throws FileNotFoundException { + super.setInputFile(file); + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new File(file.getAbsolutePath())); + } + + private void checkPercentageComment() { + commentsPercent = (double)commentsLines / numTotal * 100; + if(commentsPercent < 30.00) { + setError(location,"There are less than 30% lines of comments in this file: " + String.format("%,.2f", commentsPercent) + "% (" + commentsLines + " / " + numTotal + ")", yyline+1); + } + } + +%} +%eofval{ + checkPercentageComment(); + return getCheckResults(); +%eofval} +%eofclose +%% +/************************/ + +/************************/ +/* COMMENT STATE */ +/************************/ + + { + \n {numTotal++; commentsLines++; yybegin(NEW_LINE);} + . {} + } +/*************************/ +/* INLINE_COMMENT STATE */ +/*************************/ + + { + \n {numTotal++; commentsLines++; yybegin(NEW_LINE);} + . {} + } +/************************/ +/* AVOID STATE */ +/************************/ + \n {numTotal++; yybegin(NEW_LINE);} + . {} +/************************/ +/* NAMING STATE */ +/************************/ + + { + {VAR} {yybegin(AVOID);} + \n {numTotal++; yybegin(NEW_LINE);} + . {} + } +/************************/ +/* YYINITIAL STATE */ +/************************/ + + { + {COMMENT_WORD} {yybegin(COMMENT);} + {STRING} {yybegin(LINE);} + {TYPE} {yybegin(NAMING);} + {SPACE} {} + \n {numTotal++; yybegin(NEW_LINE);} + . {yybegin(LINE);} + } +/************************/ +/* NEW_LINE STATE */ +/************************/ + + { + {COMMENT_WORD} {yybegin(COMMENT);} + {STRING} {yybegin(LINE);} + {TYPE} {yybegin(NAMING);} + {CLOSING} {yybegin(LINE);} + {END} {yybegin(AVOID);} + {SPACE} {yybegin(LINE);} + \n {numTotal++; yybegin(NEW_LINE);} + . {yybegin(LINE);} + } +/************************/ +/* LINE STATE */ +/************************/ + + { + {FREE_COMMENT} {yybegin(INLINE_COMMENT);} + {STRING} {} + {TYPE} {yybegin(NAMING);} + {CLOSING} {} + {END} {yybegin(AVOID);} + {VAR} {} + \n {numTotal++; yybegin(NEW_LINE);} + . {} + } +/************************/ +/* ERROR STATE */ +/************************/ + [^] { + + final String errorMessage = "Analysis failure : Your file could not be analyzed. Please verify that it was encoded in an UNIX format."; + throw new JFlexException(this.getClass().getName(), parsedFileName, + errorMessage, yytext(), yyline, yycolumn); + } diff --git a/fortran77-rules/src/test/java/fr/cnes/icode/fortran77/rules/TestFortran77RulesDefinition.java b/fortran77-rules/src/test/java/fr/cnes/icode/fortran77/rules/TestFortran77RulesDefinition.java index 251daa28..3c59e2a1 100644 --- a/fortran77-rules/src/test/java/fr/cnes/icode/fortran77/rules/TestFortran77RulesDefinition.java +++ b/fortran77-rules/src/test/java/fr/cnes/icode/fortran77/rules/TestFortran77RulesDefinition.java @@ -16,7 +16,7 @@ public void testDefinitionOfDefaultRules() { rulesDefinition.define(); - Assertions.assertEquals(62, rulesDefinition.list().size()); + Assertions.assertEquals(63, rulesDefinition.list().size()); } } diff --git a/fortran90-rules/src/main/resources/fortran90-rules.xml b/fortran90-rules/src/main/resources/fortran90-rules.xml index c70481cb..35d944a2 100644 --- a/fortran90-rules/src/main/resources/fortran90-rules.xml +++ b/fortran90-rules/src/main/resources/fortran90-rules.xml @@ -408,4 +408,10 @@ F90.DESIGN.LogicUnit fr.cnes.icode.fortran90 + + fr.cnes.icode.fortran90.rules.F90INSTPercentageComment + fr.cnes.icode.fortran90.rules.F90INSTPercentageComment + F90.INST.PercentageComment + fr.cnes.icode.fortran90 + diff --git a/fortran90-rules/src/main/resources/lex/F90INSTPercentageComment.lex b/fortran90-rules/src/main/resources/lex/F90INSTPercentageComment.lex new file mode 100644 index 00000000..bdd66b9b --- /dev/null +++ b/fortran90-rules/src/main/resources/lex/F90INSTPercentageComment.lex @@ -0,0 +1,163 @@ +/************************************************************************************************/ +/* i-Code CNES is a static code analyzer. */ +/* This software is a free software, under the terms of the Eclipse Public License version 1.0. */ +/* http://www.eclipse.org/legal/epl-v10.html */ +/************************************************************************************************/ + +/****************************************************************************************/ +/* This file is used to generate a rule checker for F90.INST.PercentageComment rule. */ +/* For further information on this, we advise you to refer to RNC manuals. */ +/* As many comments have been done on the ExampleRule.lex file, this file */ +/* will restrain its comments on modifications. */ +/* */ +/****************************************************************************************/ + +package fr.cnes.icode.fortran90.rules; + +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.File; +import java.util.LinkedList; +import java.util.List; + +import fr.cnes.icode.data.AbstractChecker; +import fr.cnes.icode.data.CheckResult; +import fr.cnes.icode.exception.JFlexException; + +%% + +%class F90INSTPercentageComment +%extends AbstractChecker +%public +%column +%line + +%ignorecase + +%function run +%yylexthrow JFlexException +%type List + +%state COMMENT, NAMING, NEW_LINE, LINE, AVOID, INLINE_COMMENT +COMMENT_WORD = \! +FUNC = FUNCTION | function +PROC = PROCEDURE | procedure +SUB = SUBROUTINE | subroutine +PROG = PROGRAM | program +MOD = MODULE | module +INTER = INTERFACE | interface +TYPE = {FUNC} | {PROC} | {SUB} | {INTER} | {MOD} | {PROG} +VAR = [a-zA-Z][a-zA-Z0-9\_]* +CLOSING = END[\ ]*IF | end[\ ]*if | END[\ ]*DO | end[\ ]*do +END = END | end +STRING = \'[^\']*\' | \"[^\"]*\" +SPACE = [\ \r\t\f] + +%{ + String location = "MAIN PROGRAM"; + private String parsedFileName; + int commentsLines = 0; + int numTotal = 0; + double commentsPercent = 0; + + public F90INSTPercentageComment(){ + } + + @Override + public void setInputFile(final File file) throws FileNotFoundException { + super.setInputFile(file); + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new File(file.getAbsolutePath())); + } + + private void checkPercentageComment() { + commentsPercent = (double)commentsLines / numTotal * 100; + if(commentsPercent < 30.00) { + setError(location,"There are less than 30% lines of comments in this file: " + String.format("%,.2f", commentsPercent) + "% (" + commentsLines + " / " + numTotal + ")", yyline+1); + } + } + +%} +%eofval{ + checkPercentageComment(); + return getCheckResults(); +%eofval} +%eofclose +%% +/************************/ + +/************************/ +/* COMMENT STATE */ +/************************/ + + { + \n {numTotal++; commentsLines++; yybegin(NEW_LINE);} + . {} + } +/*************************/ +/* INLINE_COMMENT STATE */ +/*************************/ + + { + \n {numTotal++; commentsLines++; yybegin(NEW_LINE);} + . {} + } +/************************/ +/* AVOID STATE */ +/************************/ + \n {numTotal++; yybegin(NEW_LINE);} + . {} +/************************/ +/* NAMING STATE */ +/************************/ + + { + {VAR} {yybegin(AVOID);} + \n {numTotal++; yybegin(NEW_LINE);} + . {} + } +/************************/ +/* YYINITIAL STATE */ +/************************/ + + { + {COMMENT_WORD} {yybegin(COMMENT);} + {STRING} {yybegin(LINE);} + {TYPE} {yybegin(NAMING);} + {SPACE} {} + \n {yybegin(NEW_LINE);} + . {yybegin(LINE);} + } +/************************/ +/* NEW_LINE STATE */ +/************************/ + + { + {COMMENT_WORD} {yybegin(COMMENT);} + {STRING} {yybegin(LINE);} + {TYPE} {yybegin(NAMING);} + {SPACE} {} + \n {yybegin(NEW_LINE);} + . {yybegin(LINE);} + } +/************************/ +/* LINE STATE */ +/************************/ + + { + {COMMENT_WORD} {yybegin(INLINE_COMMENT);} + {STRING} {} + {TYPE} {yybegin(NAMING);} + {VAR} {} + \n {numTotal++; yybegin(NEW_LINE);} + . {} + } +/************************/ +/* ERROR STATE */ +/************************/ + [^] { + + final String errorMessage = "Analysis failure : Your file could not be analyzed. Please verify that it was encoded in an UNIX format."; + throw new JFlexException(this.getClass().getName(), parsedFileName, + errorMessage, yytext(), yyline, yycolumn); + } diff --git a/fortran90-rules/src/test/java/fr/cnes/icode/fortran90/rules/TestFortran90RulesDefinition.java b/fortran90-rules/src/test/java/fr/cnes/icode/fortran90/rules/TestFortran90RulesDefinition.java index 51b645cc..b7163804 100644 --- a/fortran90-rules/src/test/java/fr/cnes/icode/fortran90/rules/TestFortran90RulesDefinition.java +++ b/fortran90-rules/src/test/java/fr/cnes/icode/fortran90/rules/TestFortran90RulesDefinition.java @@ -16,7 +16,7 @@ public void testDefinitionOfDefaultRules() { rulesDefinition.define(); - Assertions.assertEquals(68, rulesDefinition.list().size()); + Assertions.assertEquals(69, rulesDefinition.list().size()); } } From 363f5600ec38f1784a9960605c02e6b7dee697a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ana=20D=C3=ADaz=20Mu=C3=B1oz?= <120630965+adiaz-aqclab@users.noreply.github.com> Date: Tue, 20 Dec 2022 10:57:21 +0100 Subject: [PATCH 10/32] Rule CommentVar --- .../src/main/resources/fortran77-rules.xml | 6 + .../main/resources/lex/F77DATACommentVar.lex | 166 ++++++++++++++++++ .../rules/TestFortran77RulesDefinition.java | 2 +- .../src/main/resources/fortran90-rules.xml | 6 + .../main/resources/lex/F90DATACommentVar.lex | 162 +++++++++++++++++ .../rules/TestFortran90RulesDefinition.java | 2 +- 6 files changed, 342 insertions(+), 2 deletions(-) create mode 100644 fortran77-rules/src/main/resources/lex/F77DATACommentVar.lex create mode 100644 fortran90-rules/src/main/resources/lex/F90DATACommentVar.lex diff --git a/fortran77-rules/src/main/resources/fortran77-rules.xml b/fortran77-rules/src/main/resources/fortran77-rules.xml index 23118ae0..1789e0f7 100644 --- a/fortran77-rules/src/main/resources/fortran77-rules.xml +++ b/fortran77-rules/src/main/resources/fortran77-rules.xml @@ -378,4 +378,10 @@ F77.INST.PercentageComment fr.cnes.icode.fortran77 + + fr.cnes.icode.fortran77.rules.F77DATACommentVar + fr.cnes.icode.fortran77.rules.F77DATACommentVar + F77.DATA.CommentVar + fr.cnes.icode.fortran77 + diff --git a/fortran77-rules/src/main/resources/lex/F77DATACommentVar.lex b/fortran77-rules/src/main/resources/lex/F77DATACommentVar.lex new file mode 100644 index 00000000..7e6f53ef --- /dev/null +++ b/fortran77-rules/src/main/resources/lex/F77DATACommentVar.lex @@ -0,0 +1,166 @@ +/************************************************************************************************/ +/* i-Code CNES is a static code analyzer. */ +/* This software is a free software, under the terms of the Eclipse Public License version 1.0. */ +/* http://www.eclipse.org/legal/epl-v10.html */ +/************************************************************************************************/ + +/*****************************************************************************/ +/* This file is used to generate a rule checker for F77.DATA.CommentVar rule. */ +/* For further information on this, we advise you to refer to RNC manuals. */ +/* As many comments have been done on the ExampleRule.lex file, this file */ +/* will restrain its comments on modifications. */ +/* */ +/*****************************************************************************/ + +package fr.cnes.icode.fortran77.rules; + +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.File; +import java.util.LinkedList; +import java.util.List; + +import fr.cnes.icode.data.AbstractChecker; +import fr.cnes.icode.data.CheckResult; +import fr.cnes.icode.exception.JFlexException; + +%% + +%class F77DATACommentVar +%extends AbstractChecker +%public +%column +%line +%ignorecase + +%function run +%yylexthrow JFlexException +%type List +%state COMMENT, NAMING, NEW_LINE, LINE, AVOID, YYINITIAL, VARCOMMENT_DEF + +COMMENT_WORD = \! | c | C | \* +PROG = PROGRAM | program +MOD = MODULE | module +INTER = INTERFACE | interface +TYPE = {PROG} | {MOD} | {INTER} +VAR = [a-zA-Z][a-zA-Z0-9\_]* +STRING = \'[^\']*\' | \"[^\"]*\" +SPACE = [\ \r\t\f] +VAR_T = INTEGER |integer | LOGICAL | logical | CHARACTER | character | + REAL | real | COMPLEX | complex | DOUBLE[\ ]+PRECISION | + double[\ ]+precision +VARIABLE = {VAR_T}({SPACE}*"\*"{SPACE}*([:digit:]+ | \(\*\)))? +WORD = ([:letter:] | [:digit:])+ +IMPL = implicit | IMPLICIT + + +%{ + String location = "MAIN PROGRAM"; + private String parsedFileName; + int lineComment = 0; + int lineVar = 0; + + public F77DATACommentVar(){ + } + + @Override + public void setInputFile(final File file) throws FileNotFoundException { + super.setInputFile(file); + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new File(file.getAbsolutePath())); + } + + private void checkCommentVar() { + if(lineComment!=lineVar-1){ + this.setError(location, "This variable is not commented", yyline+1); + } + } + +%} +%eofval{ + return getCheckResults(); +%eofval} +%eofclose +%% +/************************/ + +/************************/ +/* COMMENT STATE */ +/************************/ + + { + {WORD} {lineComment=yyline;} + \n {yybegin(NEW_LINE);} + . {} + } +/************************/ +/* AVOID STATE */ +/************************/ + \n {yybegin(NEW_LINE);} + . {} +/************************/ +/* NAMING STATE */ +/************************/ + + { + {VAR} {yybegin(AVOID);} + \n {yybegin(NEW_LINE);} + . {} + } +/************************/ +/* YYINITIAL STATE */ +/************************/ + + { + {COMMENT_WORD} {yybegin(COMMENT);} + {STRING} {yybegin(LINE);} + {TYPE} {yybegin(NAMING);} + {SPACE} {} + \n {yybegin(NEW_LINE);} + . {yybegin(LINE);} + } +/************************/ +/* VARCOMMENT_DEF STATE */ +/************************/ + + { + \({VAR}\) {} + {VAR} {location=yytext(); checkCommentVar();} + \R{SPACE}*(\* | \&) {} + \n {yybegin(NEW_LINE);} + . {} + } +/************************/ +/* NEW_LINE STATE */ +/************************/ + + { + {COMMENT_WORD} {yybegin(COMMENT);} + {VARIABLE} {lineVar=yyline; yybegin(VARCOMMENT_DEF);} + {STRING} {yybegin(LINE);} + {IMPL} {yybegin(AVOID);} + {TYPE} {yybegin(NAMING);} + {SPACE} {} + \n {yybegin(NEW_LINE);} + . {yybegin(LINE);} + } +/************************/ +/* LINE STATE */ +/************************/ + + { + {VARIABLE} {lineVar=yyline; yybegin(VARCOMMENT_DEF);} + {STRING} {} + {TYPE} {yybegin(NAMING);} + {VAR} {} + \n {yybegin(NEW_LINE);} + . {} + } +/************************/ +/* ERROR STATE */ +/************************/ + [^] { + + final String errorMessage = "Analysis failure : Your file could not be analyzed. Please verify that it was encoded in an UNIX format."; + throw new JFlexException(this.getClass().getName(), parsedFileName, errorMessage, yytext(), yyline, yycolumn); + } \ No newline at end of file diff --git a/fortran77-rules/src/test/java/fr/cnes/icode/fortran77/rules/TestFortran77RulesDefinition.java b/fortran77-rules/src/test/java/fr/cnes/icode/fortran77/rules/TestFortran77RulesDefinition.java index 3c59e2a1..3732c684 100644 --- a/fortran77-rules/src/test/java/fr/cnes/icode/fortran77/rules/TestFortran77RulesDefinition.java +++ b/fortran77-rules/src/test/java/fr/cnes/icode/fortran77/rules/TestFortran77RulesDefinition.java @@ -16,7 +16,7 @@ public void testDefinitionOfDefaultRules() { rulesDefinition.define(); - Assertions.assertEquals(63, rulesDefinition.list().size()); + Assertions.assertEquals(64, rulesDefinition.list().size()); } } diff --git a/fortran90-rules/src/main/resources/fortran90-rules.xml b/fortran90-rules/src/main/resources/fortran90-rules.xml index 35d944a2..520c3d5f 100644 --- a/fortran90-rules/src/main/resources/fortran90-rules.xml +++ b/fortran90-rules/src/main/resources/fortran90-rules.xml @@ -414,4 +414,10 @@ F90.INST.PercentageComment fr.cnes.icode.fortran90 + + fr.cnes.icode.fortran90.rules.F90DATACommentVar + fr.cnes.icode.fortran90.rules.F90DATACommentVar + F90.DATA.CommentVar + fr.cnes.icode.fortran90 + diff --git a/fortran90-rules/src/main/resources/lex/F90DATACommentVar.lex b/fortran90-rules/src/main/resources/lex/F90DATACommentVar.lex new file mode 100644 index 00000000..d18785b2 --- /dev/null +++ b/fortran90-rules/src/main/resources/lex/F90DATACommentVar.lex @@ -0,0 +1,162 @@ +/************************************************************************************************/ +/* i-Code CNES is a static code analyzer. */ +/* This software is a free software, under the terms of the Eclipse Public License version 1.0. */ +/* http://www.eclipse.org/legal/epl-v10.html */ +/************************************************************************************************/ + +/*****************************************************************************/ +/* This file is used to generate a rule checker for F90.DATA.CommentVar rule. */ +/* For further information on this, we advise you to refer to RNC manuals. */ +/* As many comments have been done on the ExampleRule.lex file, this file */ +/* will restrain its comments on modifications. */ +/* */ +/*****************************************************************************/ + +package fr.cnes.icode.fortran90.rules; + +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.File; +import java.util.LinkedList; +import java.util.List; + +import fr.cnes.icode.data.AbstractChecker; +import fr.cnes.icode.data.CheckResult; +import fr.cnes.icode.exception.JFlexException; + +%% + +%class F90DATACommentVar +%extends AbstractChecker +%public +%column +%line +%ignorecase + +%function run +%yylexthrow JFlexException +%type List +%state COMMENT, NAMING, NEW_LINE, LINE, AVOID, YYINITIAL, VARCOMMENT_DEF + +COMMENT_WORD = \! +PROG = PROGRAM | program +MOD = MODULE | module +INTER = INTERFACE | interface +TYPE = {PROG} | {MOD} | {INTER} +VAR = [a-zA-Z][a-zA-Z0-9\_]* +STRING = \'[^\']*\' | \"[^\"]*\" +SPACE = [\ \r\t\f] +VARIABLE = \:: +WORD = ([:letter:] | [:digit:])+ +EQUAL = \= + + +%{ + String location = "MAIN PROGRAM"; + private String parsedFileName; + int lineComment = 0; + int lineVar = 0; + + public F90DATACommentVar(){ + } + + @Override + public void setInputFile(final File file) throws FileNotFoundException { + super.setInputFile(file); + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new File(file.getAbsolutePath())); + } + + private void checkCommentVar() { + if(lineComment!=lineVar-1){ + this.setError(location, "This variable is not commented", yyline+1); + } + } + +%} +%eofval{ + return getCheckResults(); +%eofval} +%eofclose +%% +/************************/ + +/************************/ +/* COMMENT STATE */ +/************************/ + + { + {WORD} {lineComment=yyline;} + \n {yybegin(NEW_LINE);} + . {} + } +/************************/ +/* AVOID STATE */ +/************************/ + \n {yybegin(NEW_LINE);} + . {} +/************************/ +/* NAMING STATE */ +/************************/ + + { + {VAR} {yybegin(AVOID);} + \n {yybegin(NEW_LINE);} + . {} + } +/************************/ +/* YYINITIAL STATE */ +/************************/ + + { + {COMMENT_WORD} {yybegin(COMMENT);} + {STRING} {yybegin(LINE);} + {TYPE} {yybegin(NAMING);} + {SPACE} {} + \n {yybegin(NEW_LINE);} + . {yybegin(LINE);} + } +/************************/ +/* VARCOMMENT_DEF STATE */ +/************************/ + + { + {COMMENT_WORD} {yybegin(AVOID);} + {EQUAL} {yybegin(AVOID);} + {VAR} {location=yytext(); checkCommentVar();} + \n {yybegin(NEW_LINE);} + . {} + } +/************************/ +/* NEW_LINE STATE */ +/************************/ + + { + {COMMENT_WORD} {yybegin(COMMENT);} + {STRING} {yybegin(LINE);} + {TYPE} {yybegin(NAMING);} + {SPACE} {} + \n {yybegin(NEW_LINE);} + . {yybegin(LINE);} + } +/************************/ +/* LINE STATE */ +/************************/ + + { + {VARIABLE} {lineVar=yyline; yybegin(VARCOMMENT_DEF);} + {COMMENT_WORD} {yybegin(COMMENT);} + {STRING} {} + {TYPE} {yybegin(NAMING);} + {VAR} {} + \n {yybegin(NEW_LINE);} + . {} + } +/************************/ +/* ERROR STATE */ +/************************/ + [^] { + + final String errorMessage = "Analysis failure : Your file could not be analyzed. Please verify that it was encoded in an UNIX format."; + throw new JFlexException(this.getClass().getName(), parsedFileName, errorMessage, yytext(), yyline, yycolumn); + } \ No newline at end of file diff --git a/fortran90-rules/src/test/java/fr/cnes/icode/fortran90/rules/TestFortran90RulesDefinition.java b/fortran90-rules/src/test/java/fr/cnes/icode/fortran90/rules/TestFortran90RulesDefinition.java index b7163804..858d96f9 100644 --- a/fortran90-rules/src/test/java/fr/cnes/icode/fortran90/rules/TestFortran90RulesDefinition.java +++ b/fortran90-rules/src/test/java/fr/cnes/icode/fortran90/rules/TestFortran90RulesDefinition.java @@ -16,7 +16,7 @@ public void testDefinitionOfDefaultRules() { rulesDefinition.define(); - Assertions.assertEquals(69, rulesDefinition.list().size()); + Assertions.assertEquals(70, rulesDefinition.list().size()); } } From fd9331dc716caacf69ed3b2d591c7dd5dd9d83e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ana=20D=C3=ADaz=20Mu=C3=B1oz?= <120630965+adiaz-aqclab@users.noreply.github.com> Date: Tue, 20 Dec 2022 11:13:51 +0100 Subject: [PATCH 11/32] Rule Header --- .../src/main/resources/fortran77-rules.xml | 6 + .../src/main/resources/lex/F77FILEHeader.lex | 188 +++++++++++++++++ .../rules/TestFortran77RulesDefinition.java | 2 +- .../src/main/resources/fortran90-rules.xml | 6 + .../src/main/resources/lex/F90FILEHeader.lex | 191 ++++++++++++++++++ .../rules/TestFortran90RulesDefinition.java | 2 +- 6 files changed, 393 insertions(+), 2 deletions(-) create mode 100644 fortran77-rules/src/main/resources/lex/F77FILEHeader.lex create mode 100644 fortran90-rules/src/main/resources/lex/F90FILEHeader.lex diff --git a/fortran77-rules/src/main/resources/fortran77-rules.xml b/fortran77-rules/src/main/resources/fortran77-rules.xml index 1789e0f7..422ad3a3 100644 --- a/fortran77-rules/src/main/resources/fortran77-rules.xml +++ b/fortran77-rules/src/main/resources/fortran77-rules.xml @@ -384,4 +384,10 @@ F77.DATA.CommentVar fr.cnes.icode.fortran77 + + fr.cnes.icode.fortran77.rules.F77FILEHeader + fr.cnes.icode.fortran77.rules.F77FILEHeader + F77.FILE.Header + fr.cnes.icode.fortran77 + diff --git a/fortran77-rules/src/main/resources/lex/F77FILEHeader.lex b/fortran77-rules/src/main/resources/lex/F77FILEHeader.lex new file mode 100644 index 00000000..d1f83663 --- /dev/null +++ b/fortran77-rules/src/main/resources/lex/F77FILEHeader.lex @@ -0,0 +1,188 @@ +/************************************************************************************************/ +/* i-Code CNES is a static code analyzer. */ +/* This software is a free software, under the terms of the Eclipse Public License version 1.0. */ +/* http://www.eclipse.org/legal/epl-v10.html */ +/************************************************************************************************/ + +/*****************************************************************************/ +/* This file is used to generate a rule checker for F77.FILE.Header rule. */ +/* For further information on this, we advise you to refer to RNC manuals. */ +/* As many comments have been done on the ExampleRule.lex file, this file */ +/* will restrain its comments on modifications. */ +/* */ +/*****************************************************************************/ + +package fr.cnes.icode.fortran77.rules; + +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.File; +import java.util.LinkedList; +import java.util.List; + +import fr.cnes.icode.data.AbstractChecker; +import fr.cnes.icode.data.CheckResult; +import fr.cnes.icode.exception.JFlexException; + +%% + +%class F77FILEHeader +%extends AbstractChecker +%public +%column +%line +%ignorecase + +%function run +%yylexthrow JFlexException +%type List +%state COMMENT, NAMING, NEW_LINE, LINE, AVOID, YYINITIAL, HEADER + +COMMENT_WORD = \! |c |C |\* +PROG = PROGRAM | program +MOD = MODULE | module +MODPROG = {PROG} | {MOD} +VAR = [a-zA-Z][a-zA-Z0-9\_]* +STRING = \'[^\']*\' | \"[^\"]*\" +SPACE = [\ \r\t\f] +END = END| end +COMPONENT = "COMPONENT NAME" | "Component Name" | "Component name" +FILE = FILE | File +AUTHOR = AUTHOR | Author +COPYRIGHT = COPYRIGHT | Copyright +DESCRIPTION = DESCRIPTION | Description +ENDHEADER = implicit | IMPLICIT +ELEM_DESC = {SPACE}*":"{SPACE}*(\R{COMMENT_WORD})?[\(\)\{\}\[\]\<\>\.\*\+\?\/\"\!,-_:\ \r\t\f]*(\w{SPACE}*)+ + +%{ + String location = "MAIN PROGRAM"; + private String parsedFileName; + boolean hasComponent = false; + boolean hasFile = false; + boolean hasAuthor = false; + boolean hasCopyright = false; + boolean hasDescription = false; + boolean startProgMod = false; + int line = 0; + String[] missingData = new String[5]; + int pos = 0; + + public F77FILEHeader(){ + } + + @Override + public void setInputFile(final File file) throws FileNotFoundException { + super.setInputFile(file); + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new File(file.getAbsolutePath())); + } + + private void checkFileHeader() { + if(startProgMod == true && hasComponent == false && hasFile == false && hasAuthor == false && hasCopyright == false && hasDescription == false){ + this.setError(location, "This PROGRAM or MODULE must have a header with: component name, file, author, copyright and description.", line); + } + else if(startProgMod == true && (hasComponent == false || hasFile == false || hasAuthor == false || hasCopyright == false || hasDescription == false)){ + String message = "Missing data in the header of this PROGRAM or MODULE: "; + if(!hasComponent) {missingData[pos] = "component name"; pos++;} + if(!hasFile) {missingData[pos] = "file name"; pos++;} + if(!hasAuthor) {missingData[pos] = "author"; pos++;} + if(!hasCopyright) {missingData[pos] = "copyright information"; pos++;} + if(!hasDescription) {missingData[pos] = "description"; pos++;} + for(int i = 0; i < pos-1; i++) message += missingData[i] + ", "; + message += missingData[pos-1] + "."; + this.setError(location, message, line); + } + pos = 0; + hasComponent = false; + hasFile = false; + hasAuthor = false; + hasCopyright = false; + hasDescription = false; + startProgMod = false; + } + +%} +%eofval{ + return getCheckResults(); +%eofval} +%eofclose +%% +/************************/ + +/************************/ +/* COMMENT STATE */ +/************************/ + + { + \n {yybegin(NEW_LINE);} + . {} + } +/************************/ +/* AVOID STATE */ +/************************/ + \n {if(startProgMod == true) yybegin(HEADER); if(startProgMod == false) yybegin(NEW_LINE);} + . {} +/************************/ +/* NAMING STATE */ +/************************/ + + { + {VAR} {yybegin(AVOID);} + \n {yybegin(NEW_LINE);} + . {} + } +/************************/ +/* YYINITIAL STATE */ +/************************/ + + { + {COMMENT_WORD} {yybegin(COMMENT);} + {MODPROG} {location=yytext(); line=yyline+1; startProgMod = true; yybegin(NEW_LINE);} + \n {yybegin(NEW_LINE);} + . {yybegin(LINE);} + } +/************************/ +/* HEADER STATE */ +/************************/ +
+ { + {COMPONENT}{ELEM_DESC} {hasComponent = true;} + {FILE}{ELEM_DESC} {hasFile = true;} + {AUTHOR}{ELEM_DESC} {hasAuthor = true;} + {COPYRIGHT}{ELEM_DESC} {hasCopyright = true;} + {DESCRIPTION}{ELEM_DESC} {hasDescription = true;} + \n {yybegin(NEW_LINE);} + . {} + } +/************************/ +/* NEW_LINE STATE */ +/************************/ + + { + {COMMENT_WORD} {if(startProgMod == true) yybegin(HEADER); if(startProgMod == false) yybegin(COMMENT);} + {ENDHEADER} {if(startProgMod == true) checkFileHeader();} + {END} {yybegin(AVOID);} + {MODPROG} {location=yytext(); line=yyline+1; startProgMod = true; yybegin(NEW_LINE);} + \n {yybegin(NEW_LINE);} + . {yybegin(LINE);} + } +/************************/ +/* LINE STATE */ +/************************/ + + { + {COMMENT_WORD} {if(startProgMod == true) yybegin(HEADER); if(startProgMod == false) yybegin(COMMENT);} + {ENDHEADER} {if(startProgMod == true) checkFileHeader();} + {END} {yybegin(AVOID);} + {MODPROG} {location=yytext(); line=yyline+1; startProgMod = true; yybegin(NEW_LINE);} + \n {yybegin(NEW_LINE);} + . {yybegin(LINE);} + } +/************************/ +/* ERROR STATE */ +/************************/ + [^] { + + final String errorMessage = "Analysis failure : Your file could not be analyzed. Please verify that it was encoded in an UNIX format."; + throw new JFlexException(this.getClass().getName(), parsedFileName, errorMessage, yytext(), yyline, yycolumn); + } diff --git a/fortran77-rules/src/test/java/fr/cnes/icode/fortran77/rules/TestFortran77RulesDefinition.java b/fortran77-rules/src/test/java/fr/cnes/icode/fortran77/rules/TestFortran77RulesDefinition.java index 3732c684..a28bd862 100644 --- a/fortran77-rules/src/test/java/fr/cnes/icode/fortran77/rules/TestFortran77RulesDefinition.java +++ b/fortran77-rules/src/test/java/fr/cnes/icode/fortran77/rules/TestFortran77RulesDefinition.java @@ -16,7 +16,7 @@ public void testDefinitionOfDefaultRules() { rulesDefinition.define(); - Assertions.assertEquals(64, rulesDefinition.list().size()); + Assertions.assertEquals(65, rulesDefinition.list().size()); } } diff --git a/fortran90-rules/src/main/resources/fortran90-rules.xml b/fortran90-rules/src/main/resources/fortran90-rules.xml index 520c3d5f..2a9dea58 100644 --- a/fortran90-rules/src/main/resources/fortran90-rules.xml +++ b/fortran90-rules/src/main/resources/fortran90-rules.xml @@ -420,4 +420,10 @@ F90.DATA.CommentVar fr.cnes.icode.fortran90 + + fr.cnes.icode.fortran90.rules.F90FILEHeader + fr.cnes.icode.fortran90.rules.F90FILEHeader + F90.FILE.Header + fr.cnes.icode.fortran90 + diff --git a/fortran90-rules/src/main/resources/lex/F90FILEHeader.lex b/fortran90-rules/src/main/resources/lex/F90FILEHeader.lex new file mode 100644 index 00000000..9fbb7d6d --- /dev/null +++ b/fortran90-rules/src/main/resources/lex/F90FILEHeader.lex @@ -0,0 +1,191 @@ +/************************************************************************************************/ +/* i-Code CNES is a static code analyzer. */ +/* This software is a free software, under the terms of the Eclipse Public License version 1.0. */ +/* http://www.eclipse.org/legal/epl-v10.html */ +/************************************************************************************************/ + +/*****************************************************************************/ +/* This file is used to generate a rule checker for F90.FILE.Header rule. */ +/* For further information on this, we advise you to refer to RNC manuals. */ +/* As many comments have been done on the ExampleRule.lex file, this file */ +/* will restrain its comments on modifications. */ +/* */ +/*****************************************************************************/ + +package fr.cnes.icode.fortran90.rules; + +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.File; +import java.util.LinkedList; +import java.util.List; + +import fr.cnes.icode.data.AbstractChecker; +import fr.cnes.icode.data.CheckResult; +import fr.cnes.icode.exception.JFlexException; + +%% + +%class F90FILEHeader +%extends AbstractChecker +%public +%column +%line +%ignorecase + +%function run +%yylexthrow JFlexException +%type List +%state COMMENT, NAMING, NEW_LINE, LINE, AVOID, YYINITIAL, HEADER + +COMMENT_WORD = \! +PROG = PROGRAM | program +MOD = MODULE | module +MODPROG = {PROG} | {MOD} +VAR = [a-zA-Z][a-zA-Z0-9\_]* +STRING = \'[^\']*\' | \"[^\"]*\" +SPACE = [\ \r\t\f] +END = END| end +COMPONENT = "COMPONENT NAME" | "Component Name" | "Component name" +FILE = FILE | File +AUTHOR = AUTHOR | Author +COPYRIGHT = COPYRIGHT | Copyright +DESCRIPTION = DESCRIPTION | Description +ENDHEADER = use | USE | implicit | IMPLICIT +ELEM_DESC = {SPACE}*":"{SPACE}*\R?[\(\)\{\}\[\]\<\>\.\*\+\?\/\"\!,-_:\ \r\t\f]*(\w{SPACE}*)+ + + +%{ + String location = "MAIN PROGRAM"; + private String parsedFileName; + boolean hasComponent = false; + boolean hasFile = false; + boolean hasAuthor = false; + boolean hasCopyright = false; + boolean hasDescription = false; + boolean startProgMod = false; + int line = 0; + String[] missingData = new String[5]; + int pos = 0; + + public F90FILEHeader(){ + } + + @Override + public void setInputFile(final File file) throws FileNotFoundException { + super.setInputFile(file); + this.parsedFileName = file.toString(); + this.zzReader = new FileReader(new File(file.getAbsolutePath())); + } + + private void checkFileHeader() { + if(startProgMod == true && hasComponent == false && hasFile == false && hasAuthor == false && hasCopyright == false && hasDescription == false){ + this.setError(location, "This PROGRAM or MODULE must have a header with: component name, file, author, copyright and description.", line); + } + else if(startProgMod == true && (hasComponent == false || hasFile == false || hasAuthor == false || hasCopyright == false || hasDescription == false)){ + String message = "Missing data in the header of this PROGRAM or MODULE: "; + if(!hasComponent) {missingData[pos] = "component name"; pos++;} + if(!hasFile) {missingData[pos] = "file name"; pos++;} + if(!hasAuthor) {missingData[pos] = "author"; pos++;} + if(!hasCopyright) {missingData[pos] = "copyright information"; pos++;} + if(!hasDescription) {missingData[pos] = "description"; pos++;} + for(int i = 0; i < pos-1; i++) message += missingData[i] + ", "; + message += missingData[pos-1] + "."; + this.setError(location, message, line); + } + pos = 0; + hasComponent = false; + hasFile = false; + hasAuthor = false; + hasCopyright = false; + hasDescription = false; + startProgMod = false; + } + +%} +%eofval{ + return getCheckResults(); +%eofval} +%eofclose +%% +/************************/ + +/************************/ +/* COMMENT STATE */ +/************************/ + + { + \n {yybegin(NEW_LINE);} + . {} + } +/************************/ +/* AVOID STATE */ +/************************/ + \n {if(startProgMod == true) yybegin(HEADER); if(startProgMod == false) yybegin(NEW_LINE);} + . {} +/************************/ +/* NAMING STATE */ +/************************/ + + { + {VAR} {yybegin(AVOID);} + \n {yybegin(NEW_LINE);} + . {} + } +/************************/ +/* YYINITIAL STATE */ +/************************/ + + { + {COMMENT_WORD} {yybegin(COMMENT);} + {MODPROG} {location=yytext(); line=yyline+1; startProgMod = true; yybegin(NEW_LINE);} + \n {yybegin(NEW_LINE);} + . {yybegin(LINE);} + } +/************************/ +/* HEADER STATE */ +/************************/ +
+ { + {COMPONENT}{ELEM_DESC} {hasComponent = true;} + {FILE}{ELEM_DESC} {hasFile = true;} + {AUTHOR}{ELEM_DESC} {hasAuthor = true;} + {COPYRIGHT}{ELEM_DESC} {hasCopyright = true;} + {DESCRIPTION}{ELEM_DESC} {hasDescription = true;} + \n {yybegin(NEW_LINE);} + . {} + } +/************************/ +/* NEW_LINE STATE */ +/************************/ + + { + {COMMENT_WORD} {if(startProgMod == true) yybegin(HEADER); + else yybegin(COMMENT);} + {ENDHEADER} {if(startProgMod == true) checkFileHeader();} + {END} {yybegin(AVOID);} + {SPACE} {} + {MODPROG} {location=yytext(); line=yyline+1; startProgMod = true; yybegin(NEW_LINE);} + \n {yybegin(NEW_LINE);} + . {yybegin(LINE);} + } +/************************/ +/* LINE STATE */ +/************************/ + + { + {COMMENT_WORD} {if(startProgMod == true) yybegin(HEADER); + else yybegin(COMMENT);} + {ENDHEADER} {if(startProgMod == true) checkFileHeader();} + {END} {yybegin(AVOID);} + \n {yybegin(NEW_LINE);} + . {yybegin(LINE);} + } +/************************/ +/* ERROR STATE */ +/************************/ + [^] { + + final String errorMessage = "Analysis failure : Your file could not be analyzed. Please verify that it was encoded in an UNIX format."; + throw new JFlexException(this.getClass().getName(), parsedFileName, errorMessage, yytext(), yyline, yycolumn); + } \ No newline at end of file diff --git a/fortran90-rules/src/test/java/fr/cnes/icode/fortran90/rules/TestFortran90RulesDefinition.java b/fortran90-rules/src/test/java/fr/cnes/icode/fortran90/rules/TestFortran90RulesDefinition.java index 858d96f9..786e2aad 100644 --- a/fortran90-rules/src/test/java/fr/cnes/icode/fortran90/rules/TestFortran90RulesDefinition.java +++ b/fortran90-rules/src/test/java/fr/cnes/icode/fortran90/rules/TestFortran90RulesDefinition.java @@ -16,7 +16,7 @@ public void testDefinitionOfDefaultRules() { rulesDefinition.define(); - Assertions.assertEquals(70, rulesDefinition.list().size()); + Assertions.assertEquals(71, rulesDefinition.list().size()); } } From c73b57411330055a6e1c4f549d947fe5104c8289 Mon Sep 17 00:00:00 2001 From: Diego Date: Tue, 28 Mar 2023 13:30:37 +0200 Subject: [PATCH 12/32] Change new rules names to RNC rules --- .../src/main/resources/fortran77-rules.xml | 36 +++++++++---------- ...rocedure.lex => COMFLOWCheckArguments.lex} | 4 +-- ...ity.lex => COMMETComplexitySimplified.lex} | 4 +-- ...rocedureLines.lex => COMMETLineOfCode.lex} | 4 +-- ...tageComment.lex => COMMETRatioComment.lex} | 4 +-- ...{F77DATACommentVar.lex => COMPRESData.lex} | 4 +-- ...RESCodeLines.lex => COMPRESFileLength.lex} | 4 +-- .../src/main/resources/fortran90-rules.xml | 36 +++++++++---------- ...rocedure.lex => COMFLOWCheckArguments.lex} | 4 +-- ...ity.lex => COMMETComplexitySimplified.lex} | 4 +-- ...rocedureLines.lex => COMMETLineOfCode.lex} | 4 +-- ...tageComment.lex => COMMETRatioComment.lex} | 4 +-- ...{F90DATACommentVar.lex => COMPRESData.lex} | 4 +-- ...RESCodeLines.lex => COMPRESFileLength.lex} | 4 +-- 14 files changed, 60 insertions(+), 60 deletions(-) rename fortran77-rules/src/main/resources/lex/{F77DESIGNArgumentsProcedure.lex => COMFLOWCheckArguments.lex} (98%) rename fortran77-rules/src/main/resources/lex/{F77DESIGNCyclomaticComplexity.lex => COMMETComplexitySimplified.lex} (98%) rename fortran77-rules/src/main/resources/lex/{F77DESIGNProcedureLines.lex => COMMETLineOfCode.lex} (98%) rename fortran77-rules/src/main/resources/lex/{F77INSTPercentageComment.lex => COMMETRatioComment.lex} (98%) rename fortran77-rules/src/main/resources/lex/{F77DATACommentVar.lex => COMPRESData.lex} (98%) rename fortran77-rules/src/main/resources/lex/{COMPRESCodeLines.lex => COMPRESFileLength.lex} (99%) rename fortran90-rules/src/main/resources/lex/{F90DESIGNArgumentsProcedure.lex => COMFLOWCheckArguments.lex} (98%) rename fortran90-rules/src/main/resources/lex/{F90DESIGNCyclomaticComplexity.lex => COMMETComplexitySimplified.lex} (98%) rename fortran90-rules/src/main/resources/lex/{F90DESIGNProcedureLines.lex => COMMETLineOfCode.lex} (98%) rename fortran90-rules/src/main/resources/lex/{F90INSTPercentageComment.lex => COMMETRatioComment.lex} (98%) rename fortran90-rules/src/main/resources/lex/{F90DATACommentVar.lex => COMPRESData.lex} (98%) rename fortran90-rules/src/main/resources/lex/{COMPRESCodeLines.lex => COMPRESFileLength.lex} (99%) diff --git a/fortran77-rules/src/main/resources/fortran77-rules.xml b/fortran77-rules/src/main/resources/fortran77-rules.xml index 422ad3a3..2230d73f 100644 --- a/fortran77-rules/src/main/resources/fortran77-rules.xml +++ b/fortran77-rules/src/main/resources/fortran77-rules.xml @@ -343,27 +343,27 @@ F77.TYPE.Hollerith - fr.cnes.icode.fortran77.rules.COMPRESCodeLines - fr.cnes.icode.fortran77.rules.COMPRESCodeLines - COM.PRES.CodeLines + fr.cnes.icode.fortran77.rules.COMPRESFileLength + fr.cnes.icode.fortran77.rules.COMPRESFileLength + COM.PRES.FileLength fr.cnes.icode.fortran77 - fr.cnes.icode.fortran77.rules.F77DESIGNProcedureLines - fr.cnes.icode.fortran77.rules.F77DESIGNProcedureLines - F77.DESIGN.ProcedureLines + fr.cnes.icode.fortran77.rules.COMMETLineOfCode + fr.cnes.icode.fortran77.rules.COMMETLineOfCode + COM.MET.LineOfCode fr.cnes.icode.fortran77 - fr.cnes.icode.fortran77.rules.F77DESIGNArgumentsProcedure - fr.cnes.icode.fortran77.rules.F77DESIGNArgumentsProcedure - F77.DESIGN.ArgumentsProcedure + fr.cnes.icode.fortran77.rules.COMFLOWCheckArguments + fr.cnes.icode.fortran77.rules.COMFLOWCheckArguments + COM.FLOW.CheckArguments fr.cnes.icode.fortran77 - fr.cnes.icode.fortran77.rules.F77DESIGNCyclomaticComplexity - fr.cnes.icode.fortran77.rules.F77DESIGNCyclomaticComplexity - F77.DESIGN.CyclomaticComplexity + fr.cnes.icode.fortran77.rules.COMMETComplexitySimplified + fr.cnes.icode.fortran77.rules.COMMETComplexitySimplified + COM.MET.ComplexitySimplified fr.cnes.icode.fortran77 @@ -373,15 +373,15 @@ fr.cnes.icode.fortran77 - fr.cnes.icode.fortran77.rules.F77INSTPercentageComment - fr.cnes.icode.fortran77.rules.F77INSTPercentageComment - F77.INST.PercentageComment + fr.cnes.icode.fortran77.rules.COMMETRatioComment + fr.cnes.icode.fortran77.rules.COMMETRatioComment + COM.MET.RatioComment fr.cnes.icode.fortran77 - fr.cnes.icode.fortran77.rules.F77DATACommentVar - fr.cnes.icode.fortran77.rules.F77DATACommentVar - F77.DATA.CommentVar + fr.cnes.icode.fortran77.rules.COMPRESData + fr.cnes.icode.fortran77.rules.COMPRESData + COM.PRES.Data fr.cnes.icode.fortran77 diff --git a/fortran77-rules/src/main/resources/lex/F77DESIGNArgumentsProcedure.lex b/fortran77-rules/src/main/resources/lex/COMFLOWCheckArguments.lex similarity index 98% rename from fortran77-rules/src/main/resources/lex/F77DESIGNArgumentsProcedure.lex rename to fortran77-rules/src/main/resources/lex/COMFLOWCheckArguments.lex index 3a26f3cc..d673635b 100644 --- a/fortran77-rules/src/main/resources/lex/F77DESIGNArgumentsProcedure.lex +++ b/fortran77-rules/src/main/resources/lex/COMFLOWCheckArguments.lex @@ -20,7 +20,7 @@ import fr.cnes.icode.data.AbstractChecker; import fr.cnes.icode.data.CheckResult; import fr.cnes.icode.exception.JFlexException; %% -%class F77DESIGNArgumentsProcedure +%class COMFLOWCheckArguments %extends AbstractChecker %public %column @@ -51,7 +51,7 @@ COMA = \, boolean procStarted = false; boolean nameRead = false; - public F77DESIGNArgumentsProcedure(){ + public COMFLOWCheckArguments(){ } @Override diff --git a/fortran77-rules/src/main/resources/lex/F77DESIGNCyclomaticComplexity.lex b/fortran77-rules/src/main/resources/lex/COMMETComplexitySimplified.lex similarity index 98% rename from fortran77-rules/src/main/resources/lex/F77DESIGNCyclomaticComplexity.lex rename to fortran77-rules/src/main/resources/lex/COMMETComplexitySimplified.lex index 388ea3e1..111cd6ba 100644 --- a/fortran77-rules/src/main/resources/lex/F77DESIGNCyclomaticComplexity.lex +++ b/fortran77-rules/src/main/resources/lex/COMMETComplexitySimplified.lex @@ -20,7 +20,7 @@ import fr.cnes.icode.data.AbstractChecker; import fr.cnes.icode.data.CheckResult; import fr.cnes.icode.exception.JFlexException; %% -%class F77DESIGNCyclomaticComplexity +%class COMMETComplexitySimplified %extends AbstractChecker %public %column @@ -51,7 +51,7 @@ STRING = \'[^\']*\' | \"[^\"]*\" int numCyclomatic = 1; int procedureLine = 0; - public F77DESIGNCyclomaticComplexity(){ + public COMMETComplexitySimplified(){ } @Override diff --git a/fortran77-rules/src/main/resources/lex/F77DESIGNProcedureLines.lex b/fortran77-rules/src/main/resources/lex/COMMETLineOfCode.lex similarity index 98% rename from fortran77-rules/src/main/resources/lex/F77DESIGNProcedureLines.lex rename to fortran77-rules/src/main/resources/lex/COMMETLineOfCode.lex index c77a5e35..5e41a988 100644 --- a/fortran77-rules/src/main/resources/lex/F77DESIGNProcedureLines.lex +++ b/fortran77-rules/src/main/resources/lex/COMMETLineOfCode.lex @@ -25,7 +25,7 @@ import fr.cnes.icode.exception.JFlexException; %% -%class F77DESIGNProcedureLines +%class COMMETLineOfCode %extends AbstractChecker %public %column @@ -57,7 +57,7 @@ BLANK_LINE = {SPACE}*\R int codeLines = 0; boolean procStarted = false; - public F77DESIGNProcedureLines(){ + public COMMETLineOfCode(){ } @Override diff --git a/fortran77-rules/src/main/resources/lex/F77INSTPercentageComment.lex b/fortran77-rules/src/main/resources/lex/COMMETRatioComment.lex similarity index 98% rename from fortran77-rules/src/main/resources/lex/F77INSTPercentageComment.lex rename to fortran77-rules/src/main/resources/lex/COMMETRatioComment.lex index dbb62228..f391ba49 100644 --- a/fortran77-rules/src/main/resources/lex/F77INSTPercentageComment.lex +++ b/fortran77-rules/src/main/resources/lex/COMMETRatioComment.lex @@ -26,7 +26,7 @@ import fr.cnes.icode.exception.JFlexException; %% -%class F77INSTPercentageComment +%class COMMETRatioComment %extends AbstractChecker %public %column @@ -61,7 +61,7 @@ SPACE = [\ \r\t\f] int numTotal = 0; double commentsPercent = 0; - public F77INSTPercentageComment(){ + public COMMETRatioComment(){ } @Override diff --git a/fortran77-rules/src/main/resources/lex/F77DATACommentVar.lex b/fortran77-rules/src/main/resources/lex/COMPRESData.lex similarity index 98% rename from fortran77-rules/src/main/resources/lex/F77DATACommentVar.lex rename to fortran77-rules/src/main/resources/lex/COMPRESData.lex index 7e6f53ef..fd91cce9 100644 --- a/fortran77-rules/src/main/resources/lex/F77DATACommentVar.lex +++ b/fortran77-rules/src/main/resources/lex/COMPRESData.lex @@ -26,7 +26,7 @@ import fr.cnes.icode.exception.JFlexException; %% -%class F77DATACommentVar +%class COMPRESData %extends AbstractChecker %public %column @@ -60,7 +60,7 @@ IMPL = implicit | IMPLICIT int lineComment = 0; int lineVar = 0; - public F77DATACommentVar(){ + public COMPRESData(){ } @Override diff --git a/fortran77-rules/src/main/resources/lex/COMPRESCodeLines.lex b/fortran77-rules/src/main/resources/lex/COMPRESFileLength.lex similarity index 99% rename from fortran77-rules/src/main/resources/lex/COMPRESCodeLines.lex rename to fortran77-rules/src/main/resources/lex/COMPRESFileLength.lex index f1a48904..a8638b36 100644 --- a/fortran77-rules/src/main/resources/lex/COMPRESCodeLines.lex +++ b/fortran77-rules/src/main/resources/lex/COMPRESFileLength.lex @@ -20,7 +20,7 @@ import fr.cnes.icode.data.AbstractChecker; import fr.cnes.icode.data.CheckResult; import fr.cnes.icode.exception.JFlexException; %% -%class COMPRESCodeLines +%class COMPRESFileLength %extends AbstractChecker %public %column @@ -51,7 +51,7 @@ BLANK_LINE = {SPACE}*\R int codeLines = 0; int numTotal = 1; - public COMPRESCodeLines(){ + public COMPRESFileLength(){ } @Override diff --git a/fortran90-rules/src/main/resources/fortran90-rules.xml b/fortran90-rules/src/main/resources/fortran90-rules.xml index 2a9dea58..ef6993ad 100644 --- a/fortran90-rules/src/main/resources/fortran90-rules.xml +++ b/fortran90-rules/src/main/resources/fortran90-rules.xml @@ -379,27 +379,27 @@ fr.cnes.icode.fortran90 - fr.cnes.icode.fortran90.rules.COMPRESCodeLines - fr.cnes.icode.fortran90.rules.COMPRESCodeLines - COM.PRES.CodeLines + fr.cnes.icode.fortran90.rules.COMPRESFileLength + fr.cnes.icode.fortran90.rules.COMPRESFileLength + COM.PRES.FileLength fr.cnes.icode.fortran90 - fr.cnes.icode.fortran90.rules.F90DESIGNProcedureLines - fr.cnes.icode.fortran90.rules.F90DESIGNProcedureLines - F90.DESIGN.ProcedureLines + fr.cnes.icode.fortran90.rules.COMMETLineOfCode + fr.cnes.icode.fortran90.rules.COMMETLineOfCode + COM.MET.LineOfCode fr.cnes.icode.fortran90 - fr.cnes.icode.fortran90.rules.F90DESIGNArgumentsProcedure - fr.cnes.icode.fortran90.rules.F90DESIGNArgumentsProcedure - F90.DESIGN.ArgumentsProcedure + fr.cnes.icode.fortran90.rules.COMFLOWCheckArguments + fr.cnes.icode.fortran90.rules.COMFLOWCheckArguments + COM.FLOW.CheckArguments fr.cnes.icode.fortran90 - fr.cnes.icode.fortran90.rules.F90DESIGNCyclomaticComplexity - fr.cnes.icode.fortran90.rules.F90DESIGNCyclomaticComplexity - F90.DESIGN.CyclomaticComplexity + fr.cnes.icode.fortran90.rules.COMMETComplexitySimplified + fr.cnes.icode.fortran90.rules.COMMETComplexitySimplified + COM.MET.ComplexitySimplified fr.cnes.icode.fortran90 @@ -409,15 +409,15 @@ fr.cnes.icode.fortran90 - fr.cnes.icode.fortran90.rules.F90INSTPercentageComment - fr.cnes.icode.fortran90.rules.F90INSTPercentageComment - F90.INST.PercentageComment + fr.cnes.icode.fortran90.rules.COMMETRatioComment + fr.cnes.icode.fortran90.rules.COMMETRatioComment + COM.MET.RatioComment fr.cnes.icode.fortran90 - fr.cnes.icode.fortran90.rules.F90DATACommentVar - fr.cnes.icode.fortran90.rules.F90DATACommentVar - F90.DATA.CommentVar + fr.cnes.icode.fortran90.rules.COMPRESData + fr.cnes.icode.fortran90.rules.COMPRESData + COM.PRES.Data fr.cnes.icode.fortran90 diff --git a/fortran90-rules/src/main/resources/lex/F90DESIGNArgumentsProcedure.lex b/fortran90-rules/src/main/resources/lex/COMFLOWCheckArguments.lex similarity index 98% rename from fortran90-rules/src/main/resources/lex/F90DESIGNArgumentsProcedure.lex rename to fortran90-rules/src/main/resources/lex/COMFLOWCheckArguments.lex index ec654db5..04035664 100644 --- a/fortran90-rules/src/main/resources/lex/F90DESIGNArgumentsProcedure.lex +++ b/fortran90-rules/src/main/resources/lex/COMFLOWCheckArguments.lex @@ -25,7 +25,7 @@ import fr.cnes.icode.exception.JFlexException; %% -%class F90DESIGNArgumentsProcedure +%class COMFLOWCheckArguments %extends AbstractChecker %public %column @@ -59,7 +59,7 @@ COMA = \, boolean procStarted = false; boolean nameRead = false; - public F90DESIGNArgumentsProcedure(){ + public COMFLOWCheckArguments(){ } @Override diff --git a/fortran90-rules/src/main/resources/lex/F90DESIGNCyclomaticComplexity.lex b/fortran90-rules/src/main/resources/lex/COMMETComplexitySimplified.lex similarity index 98% rename from fortran90-rules/src/main/resources/lex/F90DESIGNCyclomaticComplexity.lex rename to fortran90-rules/src/main/resources/lex/COMMETComplexitySimplified.lex index 2e26613d..9d38f33c 100644 --- a/fortran90-rules/src/main/resources/lex/F90DESIGNCyclomaticComplexity.lex +++ b/fortran90-rules/src/main/resources/lex/COMMETComplexitySimplified.lex @@ -20,7 +20,7 @@ import fr.cnes.icode.data.AbstractChecker; import fr.cnes.icode.data.CheckResult; import fr.cnes.icode.exception.JFlexException; %% -%class F90DESIGNCyclomaticComplexity +%class COMMETComplexitySimplified %extends AbstractChecker %public %column @@ -55,7 +55,7 @@ STRING = \'[^\']*\' | \"[^\"]*\" int numCyclomatic = 1; int procedureLine = 0; - public F90DESIGNCyclomaticComplexity(){ + public COMMETComplexitySimplified(){ } @Override diff --git a/fortran90-rules/src/main/resources/lex/F90DESIGNProcedureLines.lex b/fortran90-rules/src/main/resources/lex/COMMETLineOfCode.lex similarity index 98% rename from fortran90-rules/src/main/resources/lex/F90DESIGNProcedureLines.lex rename to fortran90-rules/src/main/resources/lex/COMMETLineOfCode.lex index e69c3586..aff8e2c5 100644 --- a/fortran90-rules/src/main/resources/lex/F90DESIGNProcedureLines.lex +++ b/fortran90-rules/src/main/resources/lex/COMMETLineOfCode.lex @@ -25,7 +25,7 @@ import fr.cnes.icode.exception.JFlexException; %% -%class F90DESIGNProcedureLines +%class COMMETLineOfCode %extends AbstractChecker %public %column @@ -55,7 +55,7 @@ SPACE = [\ \r\t\f] int codeLines = 0; boolean procStarted = false; - public F90DESIGNProcedureLines(){ + public COMMETLineOfCode(){ } @Override diff --git a/fortran90-rules/src/main/resources/lex/F90INSTPercentageComment.lex b/fortran90-rules/src/main/resources/lex/COMMETRatioComment.lex similarity index 98% rename from fortran90-rules/src/main/resources/lex/F90INSTPercentageComment.lex rename to fortran90-rules/src/main/resources/lex/COMMETRatioComment.lex index bdd66b9b..31294392 100644 --- a/fortran90-rules/src/main/resources/lex/F90INSTPercentageComment.lex +++ b/fortran90-rules/src/main/resources/lex/COMMETRatioComment.lex @@ -26,7 +26,7 @@ import fr.cnes.icode.exception.JFlexException; %% -%class F90INSTPercentageComment +%class COMMETRatioComment %extends AbstractChecker %public %column @@ -60,7 +60,7 @@ SPACE = [\ \r\t\f] int numTotal = 0; double commentsPercent = 0; - public F90INSTPercentageComment(){ + public COMMETRatioComment(){ } @Override diff --git a/fortran90-rules/src/main/resources/lex/F90DATACommentVar.lex b/fortran90-rules/src/main/resources/lex/COMPRESData.lex similarity index 98% rename from fortran90-rules/src/main/resources/lex/F90DATACommentVar.lex rename to fortran90-rules/src/main/resources/lex/COMPRESData.lex index d18785b2..2841f192 100644 --- a/fortran90-rules/src/main/resources/lex/F90DATACommentVar.lex +++ b/fortran90-rules/src/main/resources/lex/COMPRESData.lex @@ -26,7 +26,7 @@ import fr.cnes.icode.exception.JFlexException; %% -%class F90DATACommentVar +%class COMPRESData %extends AbstractChecker %public %column @@ -57,7 +57,7 @@ EQUAL = \= int lineComment = 0; int lineVar = 0; - public F90DATACommentVar(){ + public COMPRESData(){ } @Override diff --git a/fortran90-rules/src/main/resources/lex/COMPRESCodeLines.lex b/fortran90-rules/src/main/resources/lex/COMPRESFileLength.lex similarity index 99% rename from fortran90-rules/src/main/resources/lex/COMPRESCodeLines.lex rename to fortran90-rules/src/main/resources/lex/COMPRESFileLength.lex index 672bcb7c..16285fdb 100644 --- a/fortran90-rules/src/main/resources/lex/COMPRESCodeLines.lex +++ b/fortran90-rules/src/main/resources/lex/COMPRESFileLength.lex @@ -20,7 +20,7 @@ import fr.cnes.icode.data.AbstractChecker; import fr.cnes.icode.data.CheckResult; import fr.cnes.icode.exception.JFlexException; %% -%class COMPRESCodeLines +%class COMPRESFileLength %extends AbstractChecker %public %column @@ -49,7 +49,7 @@ SPACE = [\ \r\t\f] int codeLines = 0; int numTotal = 1; - public COMPRESCodeLines(){ + public COMPRESFileLength(){ } @Override From 1b2592e560467c33b7fa3c8d957abdc655ae0226 Mon Sep 17 00:00:00 2001 From: Diego Date: Tue, 28 Mar 2023 13:39:42 +0200 Subject: [PATCH 13/32] Change name in comment --- .../src/main/resources/lex/COMFLOWCheckArguments.lex | 2 +- .../src/main/resources/lex/COMMETComplexitySimplified.lex | 2 +- fortran77-rules/src/main/resources/lex/COMMETLineOfCode.lex | 2 +- fortran77-rules/src/main/resources/lex/COMMETRatioComment.lex | 2 +- fortran77-rules/src/main/resources/lex/COMPRESData.lex | 2 +- fortran77-rules/src/main/resources/lex/COMPRESFileLength.lex | 3 ++- .../src/main/resources/lex/COMFLOWCheckArguments.lex | 2 +- .../src/main/resources/lex/COMMETComplexitySimplified.lex | 2 +- fortran90-rules/src/main/resources/lex/COMMETLineOfCode.lex | 2 +- fortran90-rules/src/main/resources/lex/COMMETRatioComment.lex | 2 +- fortran90-rules/src/main/resources/lex/COMPRESData.lex | 2 +- fortran90-rules/src/main/resources/lex/COMPRESFileLength.lex | 2 +- 12 files changed, 13 insertions(+), 12 deletions(-) diff --git a/fortran77-rules/src/main/resources/lex/COMFLOWCheckArguments.lex b/fortran77-rules/src/main/resources/lex/COMFLOWCheckArguments.lex index d673635b..77442fbe 100644 --- a/fortran77-rules/src/main/resources/lex/COMFLOWCheckArguments.lex +++ b/fortran77-rules/src/main/resources/lex/COMFLOWCheckArguments.lex @@ -4,7 +4,7 @@ /* http://www.eclipse.org/legal/epl-v10.html */ /************************************************************************************************/ /***************************************************************************************/ -/* This file is used to generate a rule checker for F77.DESIGN.ArgumentsProcedure rule.*/ +/* This file is used to generate a rule checker for COM.FLOW.CheckArguments rule.*/ /* For further information on this, we advise you to refer to RNC manuals. */ /* As many comments have been done on the ExampleRule.lex file, this file */ /* will restrain its comments on modifications. */ diff --git a/fortran77-rules/src/main/resources/lex/COMMETComplexitySimplified.lex b/fortran77-rules/src/main/resources/lex/COMMETComplexitySimplified.lex index 111cd6ba..8e23ea82 100644 --- a/fortran77-rules/src/main/resources/lex/COMMETComplexitySimplified.lex +++ b/fortran77-rules/src/main/resources/lex/COMMETComplexitySimplified.lex @@ -4,7 +4,7 @@ /* http://www.eclipse.org/legal/epl-v10.html */ /************************************************************************************************/ /********************************************************************************************/ -/* This file is used to generate a rule checker for F77.DESIGN.CyclomaticComplexity rule. */ +/* This file is used to generate a rule checker for COM.MET.ComplexitySimplified rule. */ /* For further information on this, we advise you to refer to RNC manuals. */ /* As many comments have been done on the ExampleRule.lex file, this file */ /* will restrain its comments on modifications. */ diff --git a/fortran77-rules/src/main/resources/lex/COMMETLineOfCode.lex b/fortran77-rules/src/main/resources/lex/COMMETLineOfCode.lex index 5e41a988..8d28e1b4 100644 --- a/fortran77-rules/src/main/resources/lex/COMMETLineOfCode.lex +++ b/fortran77-rules/src/main/resources/lex/COMMETLineOfCode.lex @@ -4,7 +4,7 @@ /* http://www.eclipse.org/legal/epl-v10.html */ /************************************************************************************************/ /***********************************************************************************/ -/* This file is used to generate a rule checker for F77.DESIGN.ProcedureLines rule.*/ +/* This file is used to generate a rule checker for COM.MET.LineOfCode rule.*/ /* For further information on this, we advise you to refer to RNC manuals. */ /* As many comments have been done on the ExampleRule.lex file, this file */ /* will restrain its comments on modifications. */ diff --git a/fortran77-rules/src/main/resources/lex/COMMETRatioComment.lex b/fortran77-rules/src/main/resources/lex/COMMETRatioComment.lex index f391ba49..5827361c 100644 --- a/fortran77-rules/src/main/resources/lex/COMMETRatioComment.lex +++ b/fortran77-rules/src/main/resources/lex/COMMETRatioComment.lex @@ -5,7 +5,7 @@ /************************************************************************************************/ /****************************************************************************************/ -/* This file is used to generate a rule checker for F77.INST.PercentageComment rule. */ +/* This file is used to generate a rule checker for COM.MET.RatioComment rule. */ /* For further information on this, we advise you to refer to RNC manuals. */ /* As many comments have been done on the ExampleRule.lex file, this file */ /* will restrain its comments on modifications. */ diff --git a/fortran77-rules/src/main/resources/lex/COMPRESData.lex b/fortran77-rules/src/main/resources/lex/COMPRESData.lex index fd91cce9..3b909a78 100644 --- a/fortran77-rules/src/main/resources/lex/COMPRESData.lex +++ b/fortran77-rules/src/main/resources/lex/COMPRESData.lex @@ -5,7 +5,7 @@ /************************************************************************************************/ /*****************************************************************************/ -/* This file is used to generate a rule checker for F77.DATA.CommentVar rule. */ +/* This file is used to generate a rule checker for COM.PRES.Data rule. */ /* For further information on this, we advise you to refer to RNC manuals. */ /* As many comments have been done on the ExampleRule.lex file, this file */ /* will restrain its comments on modifications. */ diff --git a/fortran77-rules/src/main/resources/lex/COMPRESFileLength.lex b/fortran77-rules/src/main/resources/lex/COMPRESFileLength.lex index a8638b36..dd4cf1ae 100644 --- a/fortran77-rules/src/main/resources/lex/COMPRESFileLength.lex +++ b/fortran77-rules/src/main/resources/lex/COMPRESFileLength.lex @@ -3,8 +3,9 @@ /* This software is a free software, under the terms of the Eclipse Public License version 1.0. */ /* http://www.eclipse.org/legal/epl-v10.html */ /************************************************************************************************/ + /********************************************************************************/ -/* This file is used to generate a rule checker for COM.PRES.CodeLines rule. */ +/* This file is used to generate a rule checker for COM.PRES.FileLength rule. */ /* For further information on this, we advise you to refer to RNC manuals. */ /* As many comments have been done on the ExampleRule.lex file, this file */ /* will restrain its comments on modifications. */ diff --git a/fortran90-rules/src/main/resources/lex/COMFLOWCheckArguments.lex b/fortran90-rules/src/main/resources/lex/COMFLOWCheckArguments.lex index 04035664..05f0644f 100644 --- a/fortran90-rules/src/main/resources/lex/COMFLOWCheckArguments.lex +++ b/fortran90-rules/src/main/resources/lex/COMFLOWCheckArguments.lex @@ -4,7 +4,7 @@ /* http://www.eclipse.org/legal/epl-v10.html */ /************************************************************************************************/ /***************************************************************************************/ -/* This file is used to generate a rule checker for F90.DESIGN.ArgumentsProcedure rule.*/ +/* This file is used to generate a rule checker for COM.FLOW.CheckArguments rule.*/ /* For further information on this, we advise you to refer to RNC manuals. */ /* As many comments have been done on the ExampleRule.lex file, this file */ /* will restrain its comments on modifications. */ diff --git a/fortran90-rules/src/main/resources/lex/COMMETComplexitySimplified.lex b/fortran90-rules/src/main/resources/lex/COMMETComplexitySimplified.lex index 9d38f33c..7d92af8b 100644 --- a/fortran90-rules/src/main/resources/lex/COMMETComplexitySimplified.lex +++ b/fortran90-rules/src/main/resources/lex/COMMETComplexitySimplified.lex @@ -4,7 +4,7 @@ /* http://www.eclipse.org/legal/epl-v10.html */ /************************************************************************************************/ /********************************************************************************************/ -/* This file is used to generate a rule checker for F90.DESIGN.CyclomaticComplexity rule. */ +/* This file is used to generate a rule checker for COM.MET.ComplexitySimplified rule. */ /* For further information on this, we advise you to refer to RNC manuals. */ /* As many comments have been done on the ExampleRule.lex file, this file */ /* will restrain its comments on modifications. */ diff --git a/fortran90-rules/src/main/resources/lex/COMMETLineOfCode.lex b/fortran90-rules/src/main/resources/lex/COMMETLineOfCode.lex index aff8e2c5..0eb1ccd2 100644 --- a/fortran90-rules/src/main/resources/lex/COMMETLineOfCode.lex +++ b/fortran90-rules/src/main/resources/lex/COMMETLineOfCode.lex @@ -4,7 +4,7 @@ /* http://www.eclipse.org/legal/epl-v10.html */ /************************************************************************************************/ /***********************************************************************************/ -/* This file is used to generate a rule checker for F90.DESIGN.ProcedureLines rule.*/ +/* This file is used to generate a rule checker for COM.MET.LineOfCode rule.*/ /* For further information on this, we advise you to refer to RNC manuals. */ /* As many comments have been done on the ExampleRule.lex file, this file */ /* will restrain its comments on modifications. */ diff --git a/fortran90-rules/src/main/resources/lex/COMMETRatioComment.lex b/fortran90-rules/src/main/resources/lex/COMMETRatioComment.lex index 31294392..b2b71647 100644 --- a/fortran90-rules/src/main/resources/lex/COMMETRatioComment.lex +++ b/fortran90-rules/src/main/resources/lex/COMMETRatioComment.lex @@ -5,7 +5,7 @@ /************************************************************************************************/ /****************************************************************************************/ -/* This file is used to generate a rule checker for F90.INST.PercentageComment rule. */ +/* This file is used to generate a rule checker for COM.MET.RatioComment rule. */ /* For further information on this, we advise you to refer to RNC manuals. */ /* As many comments have been done on the ExampleRule.lex file, this file */ /* will restrain its comments on modifications. */ diff --git a/fortran90-rules/src/main/resources/lex/COMPRESData.lex b/fortran90-rules/src/main/resources/lex/COMPRESData.lex index 2841f192..fbdc7d7e 100644 --- a/fortran90-rules/src/main/resources/lex/COMPRESData.lex +++ b/fortran90-rules/src/main/resources/lex/COMPRESData.lex @@ -5,7 +5,7 @@ /************************************************************************************************/ /*****************************************************************************/ -/* This file is used to generate a rule checker for F90.DATA.CommentVar rule. */ +/* This file is used to generate a rule checker for COM.PRES.Data rule. */ /* For further information on this, we advise you to refer to RNC manuals. */ /* As many comments have been done on the ExampleRule.lex file, this file */ /* will restrain its comments on modifications. */ diff --git a/fortran90-rules/src/main/resources/lex/COMPRESFileLength.lex b/fortran90-rules/src/main/resources/lex/COMPRESFileLength.lex index 16285fdb..fceb7d38 100644 --- a/fortran90-rules/src/main/resources/lex/COMPRESFileLength.lex +++ b/fortran90-rules/src/main/resources/lex/COMPRESFileLength.lex @@ -4,7 +4,7 @@ /* http://www.eclipse.org/legal/epl-v10.html */ /************************************************************************************************/ /********************************************************************************/ -/* This file is used to generate a rule checker for COM.PRES.CodeLines rule. */ +/* This file is used to generate a rule checker for COM.PRES.FileLength rule. */ /* For further information on this, we advise you to refer to RNC manuals. */ /* As many comments have been done on the ExampleRule.lex file, this file */ /* will restrain its comments on modifications. */ From 8d81c1e88429729658eb92584187005e4ee9429d Mon Sep 17 00:00:00 2001 From: jverdugo-aqclab Date: Fri, 2 Jun 2023 11:27:39 +0200 Subject: [PATCH 14/32] Update fortran77-rules/src/main/resources/lex/COMFLOWCheckArguments.lex Co-authored-by: Diego Rodriguez <63045276+diegorodriguez31@users.noreply.github.com> --- .../src/main/resources/lex/COMFLOWCheckArguments.lex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fortran77-rules/src/main/resources/lex/COMFLOWCheckArguments.lex b/fortran77-rules/src/main/resources/lex/COMFLOWCheckArguments.lex index 77442fbe..26eae9a6 100644 --- a/fortran77-rules/src/main/resources/lex/COMFLOWCheckArguments.lex +++ b/fortran77-rules/src/main/resources/lex/COMFLOWCheckArguments.lex @@ -62,7 +62,7 @@ COMA = \, } private void checkArgumentsProcedure() { - if(procStarted && arguments > 7) { + if(procStarted && arguments > 5) { this.setError(location,"This procedure contains more than 7 arguments: " + arguments, yyline+1); } procStarted = false; From 081584c6905a2589d16b2508aba5e58f2a2c373e Mon Sep 17 00:00:00 2001 From: jverdugo-aqclab Date: Fri, 2 Jun 2023 11:27:50 +0200 Subject: [PATCH 15/32] Update fortran77-rules/src/main/resources/lex/COMFLOWCheckArguments.lex Co-authored-by: Diego Rodriguez <63045276+diegorodriguez31@users.noreply.github.com> --- .../src/main/resources/lex/COMFLOWCheckArguments.lex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fortran77-rules/src/main/resources/lex/COMFLOWCheckArguments.lex b/fortran77-rules/src/main/resources/lex/COMFLOWCheckArguments.lex index 26eae9a6..cc9ec489 100644 --- a/fortran77-rules/src/main/resources/lex/COMFLOWCheckArguments.lex +++ b/fortran77-rules/src/main/resources/lex/COMFLOWCheckArguments.lex @@ -63,7 +63,7 @@ COMA = \, private void checkArgumentsProcedure() { if(procStarted && arguments > 5) { - this.setError(location,"This procedure contains more than 7 arguments: " + arguments, yyline+1); + this.setError(location,"This procedure contains more than 5 arguments: " + arguments, yyline+1); } procStarted = false; nameRead = false; From 93dbf7757d1f3c5f1444393e98b10f58fa8910f2 Mon Sep 17 00:00:00 2001 From: jverdugo-aqclab Date: Fri, 2 Jun 2023 11:28:01 +0200 Subject: [PATCH 16/32] Update fortran77-rules/src/main/resources/lex/COMMETComplexitySimplified.lex Co-authored-by: Diego Rodriguez <63045276+diegorodriguez31@users.noreply.github.com> --- .../src/main/resources/lex/COMMETComplexitySimplified.lex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fortran77-rules/src/main/resources/lex/COMMETComplexitySimplified.lex b/fortran77-rules/src/main/resources/lex/COMMETComplexitySimplified.lex index 8e23ea82..97ab0607 100644 --- a/fortran77-rules/src/main/resources/lex/COMMETComplexitySimplified.lex +++ b/fortran77-rules/src/main/resources/lex/COMMETComplexitySimplified.lex @@ -62,7 +62,7 @@ STRING = \'[^\']*\' | \"[^\"]*\" } private void checkTotalComplexity() { - if(numCyclomatic > 15 ) { + if(numCyclomatic > 20 ) { setError(location,"The cyclomatic complexity of this function is more than 15: " +numCyclomatic, procedureLine+1); } } From 0ff42525726ce38d8c683bd69637a802ce67961d Mon Sep 17 00:00:00 2001 From: jverdugo-aqclab Date: Fri, 2 Jun 2023 11:37:17 +0200 Subject: [PATCH 17/32] Update fortran77-rules/src/main/resources/lex/COMMETComplexitySimplified.lex Co-authored-by: Diego Rodriguez <63045276+diegorodriguez31@users.noreply.github.com> --- .../src/main/resources/lex/COMMETComplexitySimplified.lex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fortran77-rules/src/main/resources/lex/COMMETComplexitySimplified.lex b/fortran77-rules/src/main/resources/lex/COMMETComplexitySimplified.lex index 97ab0607..7f289334 100644 --- a/fortran77-rules/src/main/resources/lex/COMMETComplexitySimplified.lex +++ b/fortran77-rules/src/main/resources/lex/COMMETComplexitySimplified.lex @@ -63,7 +63,7 @@ STRING = \'[^\']*\' | \"[^\"]*\" private void checkTotalComplexity() { if(numCyclomatic > 20 ) { - setError(location,"The cyclomatic complexity of this function is more than 15: " +numCyclomatic, procedureLine+1); + setError(location,"The cyclomatic complexity of this function is more than 20: " +numCyclomatic, procedureLine+1); } } From a733ffdb3125666db1ac1e17a76531cfb00b6372 Mon Sep 17 00:00:00 2001 From: jverdugo-aqclab Date: Fri, 2 Jun 2023 11:37:25 +0200 Subject: [PATCH 18/32] Update fortran77-rules/src/main/resources/lex/COMMETLineOfCode.lex Co-authored-by: Diego Rodriguez <63045276+diegorodriguez31@users.noreply.github.com> --- fortran77-rules/src/main/resources/lex/COMMETLineOfCode.lex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fortran77-rules/src/main/resources/lex/COMMETLineOfCode.lex b/fortran77-rules/src/main/resources/lex/COMMETLineOfCode.lex index 8d28e1b4..74ee1ea0 100644 --- a/fortran77-rules/src/main/resources/lex/COMMETLineOfCode.lex +++ b/fortran77-rules/src/main/resources/lex/COMMETLineOfCode.lex @@ -68,7 +68,7 @@ BLANK_LINE = {SPACE}*\R } private void checkProcedureCodeLines() { - if(procStarted && codeLines > 150 ) { + if(procStarted && codeLines > 100 ) { this.setError(location,"This procedure contains more than 150 lines of code: " + codeLines, yyline+1); } } From 446f106df3a8d08b287239b4d6001b11b28430eb Mon Sep 17 00:00:00 2001 From: jverdugo-aqclab Date: Fri, 2 Jun 2023 11:37:43 +0200 Subject: [PATCH 19/32] Update fortran77-rules/src/main/resources/lex/COMMETLineOfCode.lex Co-authored-by: Diego Rodriguez <63045276+diegorodriguez31@users.noreply.github.com> --- fortran77-rules/src/main/resources/lex/COMMETLineOfCode.lex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fortran77-rules/src/main/resources/lex/COMMETLineOfCode.lex b/fortran77-rules/src/main/resources/lex/COMMETLineOfCode.lex index 74ee1ea0..56533dd2 100644 --- a/fortran77-rules/src/main/resources/lex/COMMETLineOfCode.lex +++ b/fortran77-rules/src/main/resources/lex/COMMETLineOfCode.lex @@ -69,7 +69,7 @@ BLANK_LINE = {SPACE}*\R private void checkProcedureCodeLines() { if(procStarted && codeLines > 100 ) { - this.setError(location,"This procedure contains more than 150 lines of code: " + codeLines, yyline+1); + this.setError(location,"This procedure contains more than 100 lines of code: " + codeLines, yyline+1); } } From 3bf3c3360fdc205fd14844f1cf2db1220bb3ad3c Mon Sep 17 00:00:00 2001 From: jverdugo-aqclab Date: Fri, 2 Jun 2023 11:38:04 +0200 Subject: [PATCH 20/32] Update fortran90-rules/src/main/resources/lex/COMMETLineOfCode.lex Co-authored-by: Diego Rodriguez <63045276+diegorodriguez31@users.noreply.github.com> --- fortran90-rules/src/main/resources/lex/COMMETLineOfCode.lex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fortran90-rules/src/main/resources/lex/COMMETLineOfCode.lex b/fortran90-rules/src/main/resources/lex/COMMETLineOfCode.lex index 0eb1ccd2..26b60bf5 100644 --- a/fortran90-rules/src/main/resources/lex/COMMETLineOfCode.lex +++ b/fortran90-rules/src/main/resources/lex/COMMETLineOfCode.lex @@ -66,7 +66,7 @@ SPACE = [\ \r\t\f] } private void checkProcedureCodeLines() { - if(procStarted && codeLines > 150 ) { + if(procStarted && codeLines > 100 ) { this.setError(location,"This procedure contains more than 150 lines of code: " + codeLines, yyline+1); } } From 23ac9c718bb87f8670ce29985fc5db476cc19712 Mon Sep 17 00:00:00 2001 From: jverdugo-aqclab Date: Fri, 2 Jun 2023 11:38:13 +0200 Subject: [PATCH 21/32] Update fortran90-rules/src/main/resources/lex/COMFLOWCheckArguments.lex Co-authored-by: Diego Rodriguez <63045276+diegorodriguez31@users.noreply.github.com> --- .../src/main/resources/lex/COMFLOWCheckArguments.lex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fortran90-rules/src/main/resources/lex/COMFLOWCheckArguments.lex b/fortran90-rules/src/main/resources/lex/COMFLOWCheckArguments.lex index 05f0644f..a65c21cd 100644 --- a/fortran90-rules/src/main/resources/lex/COMFLOWCheckArguments.lex +++ b/fortran90-rules/src/main/resources/lex/COMFLOWCheckArguments.lex @@ -71,7 +71,7 @@ COMA = \, private void checkArgumentsProcedure() { if(procStarted && arguments > 7) { - this.setError(location,"This procedure contains more than 7 arguments: " + arguments, yyline+1); + this.setError(location,"This procedure contains more than 5 arguments: " + arguments, yyline+1); } procStarted = false; nameRead = false; From 290cd74e8d3ddf93dc0e04c4f937f0baed46e06c Mon Sep 17 00:00:00 2001 From: jverdugo-aqclab Date: Fri, 2 Jun 2023 11:38:24 +0200 Subject: [PATCH 22/32] Update fortran77-rules/src/main/resources/lex/COMMETRatioComment.lex Co-authored-by: Diego Rodriguez <63045276+diegorodriguez31@users.noreply.github.com> --- fortran77-rules/src/main/resources/lex/COMMETRatioComment.lex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fortran77-rules/src/main/resources/lex/COMMETRatioComment.lex b/fortran77-rules/src/main/resources/lex/COMMETRatioComment.lex index 5827361c..472348c4 100644 --- a/fortran77-rules/src/main/resources/lex/COMMETRatioComment.lex +++ b/fortran77-rules/src/main/resources/lex/COMMETRatioComment.lex @@ -73,7 +73,7 @@ SPACE = [\ \r\t\f] private void checkPercentageComment() { commentsPercent = (double)commentsLines / numTotal * 100; - if(commentsPercent < 30.00) { + if(commentsPercent < 20.00) { setError(location,"There are less than 30% lines of comments in this file: " + String.format("%,.2f", commentsPercent) + "% (" + commentsLines + " / " + numTotal + ")", yyline+1); } } From 8e43b0cacee1655340fe1ecd23bf6f3dd1d8025d Mon Sep 17 00:00:00 2001 From: jverdugo-aqclab Date: Fri, 2 Jun 2023 11:38:35 +0200 Subject: [PATCH 23/32] Update fortran77-rules/src/main/resources/lex/COMMETRatioComment.lex Co-authored-by: Diego Rodriguez <63045276+diegorodriguez31@users.noreply.github.com> --- fortran77-rules/src/main/resources/lex/COMMETRatioComment.lex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fortran77-rules/src/main/resources/lex/COMMETRatioComment.lex b/fortran77-rules/src/main/resources/lex/COMMETRatioComment.lex index 472348c4..4e3a0ff1 100644 --- a/fortran77-rules/src/main/resources/lex/COMMETRatioComment.lex +++ b/fortran77-rules/src/main/resources/lex/COMMETRatioComment.lex @@ -74,7 +74,7 @@ SPACE = [\ \r\t\f] private void checkPercentageComment() { commentsPercent = (double)commentsLines / numTotal * 100; if(commentsPercent < 20.00) { - setError(location,"There are less than 30% lines of comments in this file: " + String.format("%,.2f", commentsPercent) + "% (" + commentsLines + " / " + numTotal + ")", yyline+1); + setError(location,"There are less than 20% lines of comments in this file: " + String.format("%,.2f", commentsPercent) + "% (" + commentsLines + " / " + numTotal + ")", yyline+1); } } From dd56e54d03103c1a233b321ab9e19dfe1d6ebb4a Mon Sep 17 00:00:00 2001 From: jverdugo-aqclab Date: Fri, 2 Jun 2023 11:38:44 +0200 Subject: [PATCH 24/32] Update fortran90-rules/src/main/resources/lex/COMMETRatioComment.lex Co-authored-by: Diego Rodriguez <63045276+diegorodriguez31@users.noreply.github.com> --- fortran90-rules/src/main/resources/lex/COMMETRatioComment.lex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fortran90-rules/src/main/resources/lex/COMMETRatioComment.lex b/fortran90-rules/src/main/resources/lex/COMMETRatioComment.lex index b2b71647..402a972e 100644 --- a/fortran90-rules/src/main/resources/lex/COMMETRatioComment.lex +++ b/fortran90-rules/src/main/resources/lex/COMMETRatioComment.lex @@ -72,7 +72,7 @@ SPACE = [\ \r\t\f] private void checkPercentageComment() { commentsPercent = (double)commentsLines / numTotal * 100; - if(commentsPercent < 30.00) { + if(commentsPercent < 20.00) { setError(location,"There are less than 30% lines of comments in this file: " + String.format("%,.2f", commentsPercent) + "% (" + commentsLines + " / " + numTotal + ")", yyline+1); } } From 217f47e4d80aee52454e238da937554201e3200e Mon Sep 17 00:00:00 2001 From: jverdugo-aqclab Date: Fri, 2 Jun 2023 11:38:55 +0200 Subject: [PATCH 25/32] Update fortran90-rules/src/main/resources/lex/COMMETRatioComment.lex Co-authored-by: Diego Rodriguez <63045276+diegorodriguez31@users.noreply.github.com> --- fortran90-rules/src/main/resources/lex/COMMETRatioComment.lex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fortran90-rules/src/main/resources/lex/COMMETRatioComment.lex b/fortran90-rules/src/main/resources/lex/COMMETRatioComment.lex index 402a972e..056da03a 100644 --- a/fortran90-rules/src/main/resources/lex/COMMETRatioComment.lex +++ b/fortran90-rules/src/main/resources/lex/COMMETRatioComment.lex @@ -73,7 +73,7 @@ SPACE = [\ \r\t\f] private void checkPercentageComment() { commentsPercent = (double)commentsLines / numTotal * 100; if(commentsPercent < 20.00) { - setError(location,"There are less than 30% lines of comments in this file: " + String.format("%,.2f", commentsPercent) + "% (" + commentsLines + " / " + numTotal + ")", yyline+1); + setError(location,"There are less than 20% lines of comments in this file: " + String.format("%,.2f", commentsPercent) + "% (" + commentsLines + " / " + numTotal + ")", yyline+1); } } From 8502935d373ae5bfa1e8ac9308ef5802005799e2 Mon Sep 17 00:00:00 2001 From: jverdugo-aqclab Date: Fri, 2 Jun 2023 11:39:55 +0200 Subject: [PATCH 26/32] Update fortran90-rules/src/main/resources/lex/COMMETLineOfCode.lex Co-authored-by: Diego Rodriguez <63045276+diegorodriguez31@users.noreply.github.com> --- fortran90-rules/src/main/resources/lex/COMMETLineOfCode.lex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fortran90-rules/src/main/resources/lex/COMMETLineOfCode.lex b/fortran90-rules/src/main/resources/lex/COMMETLineOfCode.lex index 26b60bf5..7594e776 100644 --- a/fortran90-rules/src/main/resources/lex/COMMETLineOfCode.lex +++ b/fortran90-rules/src/main/resources/lex/COMMETLineOfCode.lex @@ -67,7 +67,7 @@ SPACE = [\ \r\t\f] private void checkProcedureCodeLines() { if(procStarted && codeLines > 100 ) { - this.setError(location,"This procedure contains more than 150 lines of code: " + codeLines, yyline+1); + this.setError(location,"This procedure contains more than 100 lines of code: " + codeLines, yyline+1); } } From 849784b7f27ad9ff610b0541ab5013225a9addd1 Mon Sep 17 00:00:00 2001 From: jverdugo-aqclab Date: Fri, 2 Jun 2023 11:40:31 +0200 Subject: [PATCH 27/32] Update fortran90-rules/src/main/resources/lex/COMMETComplexitySimplified.lex Co-authored-by: Diego Rodriguez <63045276+diegorodriguez31@users.noreply.github.com> --- .../src/main/resources/lex/COMMETComplexitySimplified.lex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fortran90-rules/src/main/resources/lex/COMMETComplexitySimplified.lex b/fortran90-rules/src/main/resources/lex/COMMETComplexitySimplified.lex index 7d92af8b..7882e2aa 100644 --- a/fortran90-rules/src/main/resources/lex/COMMETComplexitySimplified.lex +++ b/fortran90-rules/src/main/resources/lex/COMMETComplexitySimplified.lex @@ -66,7 +66,7 @@ STRING = \'[^\']*\' | \"[^\"]*\" } private void checkTotalComplexity() { - if(numCyclomatic > 15 ) { + if(numCyclomatic > 20 ) { setError(location,"The cyclomatic complexity of this function is more than 15: " +numCyclomatic, procedureLine+1); } } From af8085a454b2061bea2ecb3929306cf292d2dee3 Mon Sep 17 00:00:00 2001 From: jverdugo-aqclab Date: Fri, 2 Jun 2023 11:41:34 +0200 Subject: [PATCH 28/32] Update fortran90-rules/src/main/resources/lex/COMMETComplexitySimplified.lex Co-authored-by: Diego Rodriguez <63045276+diegorodriguez31@users.noreply.github.com> --- .../src/main/resources/lex/COMMETComplexitySimplified.lex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fortran90-rules/src/main/resources/lex/COMMETComplexitySimplified.lex b/fortran90-rules/src/main/resources/lex/COMMETComplexitySimplified.lex index 7882e2aa..59da09dd 100644 --- a/fortran90-rules/src/main/resources/lex/COMMETComplexitySimplified.lex +++ b/fortran90-rules/src/main/resources/lex/COMMETComplexitySimplified.lex @@ -67,7 +67,7 @@ STRING = \'[^\']*\' | \"[^\"]*\" private void checkTotalComplexity() { if(numCyclomatic > 20 ) { - setError(location,"The cyclomatic complexity of this function is more than 15: " +numCyclomatic, procedureLine+1); + setError(location,"The cyclomatic complexity of this function is more than 20: " +numCyclomatic, procedureLine+1); } } From ed18b31ec422926d05b282dd9e2c0fa56dd3f8d8 Mon Sep 17 00:00:00 2001 From: jverdugo-aqclab Date: Fri, 2 Jun 2023 11:42:00 +0200 Subject: [PATCH 29/32] Update fortran90-rules/src/main/resources/lex/COMFLOWCheckArguments.lex Co-authored-by: Diego Rodriguez <63045276+diegorodriguez31@users.noreply.github.com> --- .../src/main/resources/lex/COMFLOWCheckArguments.lex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fortran90-rules/src/main/resources/lex/COMFLOWCheckArguments.lex b/fortran90-rules/src/main/resources/lex/COMFLOWCheckArguments.lex index a65c21cd..de5c8482 100644 --- a/fortran90-rules/src/main/resources/lex/COMFLOWCheckArguments.lex +++ b/fortran90-rules/src/main/resources/lex/COMFLOWCheckArguments.lex @@ -70,7 +70,7 @@ COMA = \, } private void checkArgumentsProcedure() { - if(procStarted && arguments > 7) { + if(procStarted && arguments > 5) { this.setError(location,"This procedure contains more than 5 arguments: " + arguments, yyline+1); } procStarted = false; From a66e8849581caed115ccb3d61bc9ce460942092f Mon Sep 17 00:00:00 2001 From: jverdugo Date: Fri, 2 Jun 2023 12:08:36 +0200 Subject: [PATCH 30/32] Remove unused variable numTotal --- .../main/resources/lex/COMPRESFileLength.lex | 15 +++++++-------- .../test/resources/F77/FILE/Header/error.f | 19 +++++++++++++++++++ .../main/resources/lex/COMPRESFileLength.lex | 15 +++++++-------- 3 files changed, 33 insertions(+), 16 deletions(-) create mode 100644 fortran77-rules/src/test/resources/F77/FILE/Header/error.f diff --git a/fortran77-rules/src/main/resources/lex/COMPRESFileLength.lex b/fortran77-rules/src/main/resources/lex/COMPRESFileLength.lex index dd4cf1ae..f1c6f16a 100644 --- a/fortran77-rules/src/main/resources/lex/COMPRESFileLength.lex +++ b/fortran77-rules/src/main/resources/lex/COMPRESFileLength.lex @@ -50,7 +50,6 @@ BLANK_LINE = {SPACE}*\R String location = "MAIN PROGRAM"; private String parsedFileName; int codeLines = 0; - int numTotal = 1; public COMPRESFileLength(){ } @@ -82,7 +81,7 @@ BLANK_LINE = {SPACE}*\R /************************/ { - \n {numTotal++; yybegin(NEW_LINE);} + \n {yybegin(NEW_LINE);} . {} } /*************************/ @@ -90,13 +89,13 @@ BLANK_LINE = {SPACE}*\R /*************************/ { - \n {numTotal++; codeLines++; yybegin(NEW_LINE);} + \n {codeLines++; yybegin(NEW_LINE);} . {} } /************************/ /* AVOID STATE */ /************************/ - \n {numTotal++; codeLines++; yybegin(NEW_LINE);} + \n {codeLines++; yybegin(NEW_LINE);} . {} /************************/ /* NAMING STATE */ @@ -104,7 +103,7 @@ BLANK_LINE = {SPACE}*\R { {VAR} {location = location + " " + yytext(); yybegin(AVOID);} - \n {numTotal++; codeLines++; yybegin(NEW_LINE);} + \n {codeLines++; yybegin(NEW_LINE);} . {} } /************************/ @@ -116,7 +115,7 @@ BLANK_LINE = {SPACE}*\R {STRING} {yybegin(LINE);} {TYPE} {location = yytext(); yybegin(NAMING);} {SPACE} {} - \n {numTotal++; yybegin(NEW_LINE);} + \n {yybegin(NEW_LINE);} . {yybegin(LINE);} } /************************/ @@ -131,7 +130,7 @@ BLANK_LINE = {SPACE}*\R {END} {yybegin(AVOID);} {BLANK_LINE} {} {SPACE} {yybegin(LINE);} - \n {numTotal++; yybegin(NEW_LINE);} + \n {yybegin(NEW_LINE);} . {yybegin(LINE);} } /************************/ @@ -145,7 +144,7 @@ BLANK_LINE = {SPACE}*\R {CLOSING} {} {END} {yybegin(AVOID);} {VAR} {} - \n {numTotal++; codeLines++; yybegin(NEW_LINE);} + \n {codeLines++; yybegin(NEW_LINE);} . {} } /************************/ diff --git a/fortran77-rules/src/test/resources/F77/FILE/Header/error.f b/fortran77-rules/src/test/resources/F77/FILE/Header/error.f new file mode 100644 index 00000000..d3a48826 --- /dev/null +++ b/fortran77-rules/src/test/resources/F77/FILE/Header/error.f @@ -0,0 +1,19 @@ + MODULE ESSAI + + IMPLICIT NONE + + REAL :: Tc + REAL :: Tf + REAL :: C_To_F + REAL :: F_To_C + + WRITE(*, '(3X,"Temperature en Celsius:")') + READ(*,*) Tc + WRITE(*, '(3X,"->Conversion en Fahrenheit:",F8.3)') C_To_F(Tc) + + WRITE(*, '(" ")') + WRITE(*, '(3X,"Temperature en Fahrenheit:")') + READ(*,*) Tf + WRITE(*, '(3X,"->Conversion en Celsius:",F8.3)') F_To_C(Tf) + + END MODULE ESSAI \ No newline at end of file diff --git a/fortran90-rules/src/main/resources/lex/COMPRESFileLength.lex b/fortran90-rules/src/main/resources/lex/COMPRESFileLength.lex index fceb7d38..dd34aee9 100644 --- a/fortran90-rules/src/main/resources/lex/COMPRESFileLength.lex +++ b/fortran90-rules/src/main/resources/lex/COMPRESFileLength.lex @@ -47,7 +47,6 @@ SPACE = [\ \r\t\f] String location = "MAIN PROGRAM"; private String parsedFileName; int codeLines = 0; - int numTotal = 1; public COMPRESFileLength(){ } @@ -79,7 +78,7 @@ SPACE = [\ \r\t\f] /************************/ { - \n {numTotal++; yybegin(NEW_LINE);} + \n {yybegin(NEW_LINE);} . {} } /*************************/ @@ -87,13 +86,13 @@ SPACE = [\ \r\t\f] /*************************/ { - \n {numTotal++; codeLines++; yybegin(NEW_LINE);} + \n {codeLines++; yybegin(NEW_LINE);} . {} } /************************/ /* AVOID STATE */ /************************/ - \n {numTotal++; codeLines++; yybegin(NEW_LINE);} + \n {codeLines++; yybegin(NEW_LINE);} . {} /************************/ /* NAMING STATE */ @@ -101,7 +100,7 @@ SPACE = [\ \r\t\f] { {VAR} {location = location + " " + yytext(); yybegin(AVOID);} - \n {numTotal++; codeLines++; yybegin(NEW_LINE);} + \n {codeLines++; yybegin(NEW_LINE);} . {} } /************************/ @@ -113,7 +112,7 @@ SPACE = [\ \r\t\f] {STRING} {yybegin(LINE);} {TYPE} {location = yytext(); yybegin(NAMING);} {SPACE} {} - \n {numTotal++; yybegin(NEW_LINE);} + \n {yybegin(NEW_LINE);} . {yybegin(LINE);} } /************************/ @@ -127,7 +126,7 @@ SPACE = [\ \r\t\f] {CLOSING} {yybegin(LINE);} {END} {yybegin(AVOID);} {SPACE} {} - \n {numTotal++; yybegin(NEW_LINE);} + \n {yybegin(NEW_LINE);} . {yybegin(LINE);} } /************************/ @@ -141,7 +140,7 @@ SPACE = [\ \r\t\f] {CLOSING} {} {END} {yybegin(AVOID);} {VAR} {} - \n {numTotal++; codeLines++; yybegin(NEW_LINE);} + \n {codeLines++; yybegin(NEW_LINE);} . {} } /************************/ From 5e8cac9afde7098a2bf6f9476c42a200e6e34cc0 Mon Sep 17 00:00:00 2001 From: jverdugo Date: Fri, 2 Jun 2023 12:18:58 +0200 Subject: [PATCH 31/32] Header updated to reflect this rule is not defined in RNC. --- fortran77-rules/src/main/resources/lex/F77DESIGNLogicUnit.lex | 3 ++- fortran90-rules/src/main/resources/lex/F90DESIGNLogicUnit.lex | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/fortran77-rules/src/main/resources/lex/F77DESIGNLogicUnit.lex b/fortran77-rules/src/main/resources/lex/F77DESIGNLogicUnit.lex index 85882666..ca96f5f0 100644 --- a/fortran77-rules/src/main/resources/lex/F77DESIGNLogicUnit.lex +++ b/fortran77-rules/src/main/resources/lex/F77DESIGNLogicUnit.lex @@ -6,7 +6,8 @@ /*****************************************************************************/ /* This file is used to generate a rule checker for F77.DESIGN.Interface rule. */ -/* For further information on this, we advise you to refer to RNC manuals. */ +/* This rule is not defined in RNC. */ +/* This rule checks files where there is more han one PROGRAM or MODULE. */ /* As many comments have been done on the ExampleRule.lex file, this file */ /* will restrain its comments on modifications. */ /* */ diff --git a/fortran90-rules/src/main/resources/lex/F90DESIGNLogicUnit.lex b/fortran90-rules/src/main/resources/lex/F90DESIGNLogicUnit.lex index 9a09674a..f0d8d460 100644 --- a/fortran90-rules/src/main/resources/lex/F90DESIGNLogicUnit.lex +++ b/fortran90-rules/src/main/resources/lex/F90DESIGNLogicUnit.lex @@ -6,7 +6,8 @@ /*****************************************************************************/ /* This file is used to generate a rule checker for F90.DESIGN.Interface rule. */ -/* For further information on this, we advise you to refer to RNC manuals. */ +/* This rule is not defined in RNC. */ +/* This rule checks files where there is more han one PROGRAM or MODULE. */ /* As many comments have been done on the ExampleRule.lex file, this file */ /* will restrain its comments on modifications. */ /* */ From 8b510ac3f30f4def1d9346019ff4d2ce9abe3c2a Mon Sep 17 00:00:00 2001 From: jverdugo Date: Mon, 5 Jun 2023 08:24:16 +0200 Subject: [PATCH 32/32] Test cases for new rules --- .../rules/TestAllFortran77Rules.java | 8 + .../resources/COM/FLOW/CheckArguments/error.f | 4 + .../COM/FLOW/CheckArguments/noError.f | 3 + .../COM/MET/ComplexitySimplified/error.f | 52 + .../COM/MET/ComplexitySimplified/noError.f | 13 + .../test/resources/COM/MET/LineOfCode/error.f | 170 ++ .../resources/COM/MET/LineOfCode/noError.f | 19 + .../resources/COM/MET/RatioComment/error.f | 15 + .../resources/COM/MET/RatioComment/noError.f | 69 + .../src/test/resources/COM/PRES/Data/error.f | 8 + .../test/resources/COM/PRES/Data/noError.f | 9 + .../resources/COM/PRES/FileLength/error.f | 1052 ++++++++++++ .../resources/COM/PRES/FileLength/noError.f | 28 + .../resources/F77/DESIGN/LogicUnit/error.f | 39 + .../resources/F77/DESIGN/LogicUnit/noError.f | 25 + .../test/resources/F77/FILE/Header/noError.f | 29 + .../rules/TestAllFortran90Rules.java | 8 + .../resources/COM/FLOW/CheckArguments/error.f | 4 + .../COM/FLOW/CheckArguments/noError.f | 3 + .../COM/MET/ComplexitySimplified/error.f | 52 + .../COM/MET/ComplexitySimplified/noError.f | 13 + .../resources/COM/MET/LineOfCode/error.f90 | 170 ++ .../resources/COM/MET/LineOfCode/noError.f90 | 19 + .../resources/COM/MET/RatioComment/error.f | 15 + .../resources/COM/MET/RatioComment/noError.f | 72 + .../test/resources/COM/PRES/Data/error.f90 | 5 + .../test/resources/COM/PRES/Data/noError.f90 | 6 + .../resources/COM/PRES/FileLength/error.f | 1502 +++++++++++++++++ .../resources/COM/PRES/FileLength/noError.f | 58 + .../resources/F90/DESIGN/LogicUnit/error.f90 | 39 + .../F90/DESIGN/LogicUnit/noError.f90 | 19 + .../test/resources/F90/FILE/Header/error.f90 | 19 + .../resources/F90/FILE/Header/noError.f90 | 29 + 33 files changed, 3576 insertions(+) create mode 100644 fortran77-rules/src/test/resources/COM/FLOW/CheckArguments/error.f create mode 100644 fortran77-rules/src/test/resources/COM/FLOW/CheckArguments/noError.f create mode 100644 fortran77-rules/src/test/resources/COM/MET/ComplexitySimplified/error.f create mode 100644 fortran77-rules/src/test/resources/COM/MET/ComplexitySimplified/noError.f create mode 100644 fortran77-rules/src/test/resources/COM/MET/LineOfCode/error.f create mode 100644 fortran77-rules/src/test/resources/COM/MET/LineOfCode/noError.f create mode 100644 fortran77-rules/src/test/resources/COM/MET/RatioComment/error.f create mode 100644 fortran77-rules/src/test/resources/COM/MET/RatioComment/noError.f create mode 100644 fortran77-rules/src/test/resources/COM/PRES/Data/error.f create mode 100644 fortran77-rules/src/test/resources/COM/PRES/Data/noError.f create mode 100644 fortran77-rules/src/test/resources/COM/PRES/FileLength/error.f create mode 100644 fortran77-rules/src/test/resources/COM/PRES/FileLength/noError.f create mode 100644 fortran77-rules/src/test/resources/F77/DESIGN/LogicUnit/error.f create mode 100644 fortran77-rules/src/test/resources/F77/DESIGN/LogicUnit/noError.f create mode 100644 fortran77-rules/src/test/resources/F77/FILE/Header/noError.f create mode 100644 fortran90-rules/src/test/resources/COM/FLOW/CheckArguments/error.f create mode 100644 fortran90-rules/src/test/resources/COM/FLOW/CheckArguments/noError.f create mode 100644 fortran90-rules/src/test/resources/COM/MET/ComplexitySimplified/error.f create mode 100644 fortran90-rules/src/test/resources/COM/MET/ComplexitySimplified/noError.f create mode 100644 fortran90-rules/src/test/resources/COM/MET/LineOfCode/error.f90 create mode 100644 fortran90-rules/src/test/resources/COM/MET/LineOfCode/noError.f90 create mode 100644 fortran90-rules/src/test/resources/COM/MET/RatioComment/error.f create mode 100644 fortran90-rules/src/test/resources/COM/MET/RatioComment/noError.f create mode 100644 fortran90-rules/src/test/resources/COM/PRES/Data/error.f90 create mode 100644 fortran90-rules/src/test/resources/COM/PRES/Data/noError.f90 create mode 100644 fortran90-rules/src/test/resources/COM/PRES/FileLength/error.f create mode 100644 fortran90-rules/src/test/resources/COM/PRES/FileLength/noError.f create mode 100644 fortran90-rules/src/test/resources/F90/DESIGN/LogicUnit/error.f90 create mode 100644 fortran90-rules/src/test/resources/F90/DESIGN/LogicUnit/noError.f90 create mode 100644 fortran90-rules/src/test/resources/F90/FILE/Header/error.f90 create mode 100644 fortran90-rules/src/test/resources/F90/FILE/Header/noError.f90 diff --git a/fortran77-rules/src/test/java/fr/cnes/icode/fortran77/rules/TestAllFortran77Rules.java b/fortran77-rules/src/test/java/fr/cnes/icode/fortran77/rules/TestAllFortran77Rules.java index 9aa1b17e..c02579eb 100644 --- a/fortran77-rules/src/test/java/fr/cnes/icode/fortran77/rules/TestAllFortran77Rules.java +++ b/fortran77-rules/src/test/java/fr/cnes/icode/fortran77/rules/TestAllFortran77Rules.java @@ -38,6 +38,7 @@ public static Object[][] data() { {"/COM/DESIGN/Alloc/error.f", "/COM/DESIGN/Alloc/noError.f", new int[]{12, 17}, new String[]{"function f1", "subroutine s2"}, COMDESIGNAlloc.class}, {"/COM/FLOW/Abort/error.f", "/COM/FLOW/Abort/noError.f", new int[]{11}, new String[]{"MAIN PROGRAM ESSAI"}, COMFLOWAbort.class}, {"/COM/FLOW/BooleanExpression/error.f", "/COM/FLOW/BooleanExpression/noError.f", new int[]{11, 15}, new String[]{"PROGRAM ESSAI", "PROGRAM ESSAI"}, COMFLOWBooleanExpression.class}, + {"/COM/FLOW/CheckArguments/error.f", "/COM/FLOW/CheckArguments/noError.f", new int[]{1}, new String[]{"SUBROUTINE C3BODY"}, COMFLOWCheckArguments.class}, {"/COM/FLOW/CheckCodeReturn/error.f", "/COM/FLOW/CheckCodeReturn/noError.f", new int[]{7}, new String[]{"PROGRAM MAIN"}, COMFLOWCheckCodeReturn.class}, {"/COM/FLOW/CheckUser/error.f", "/COM/FLOW/CheckUser/noError.f", new int[]{1}, new String[]{"PROGRAM MAIN"}, COMFLOWCheckUser.class}, {"/COM/FLOW/Exit/error.f", "/COM/FLOW/Exit/noError.f", new int[]{12}, new String[]{"function f1"}, COMFLOWExit.class}, @@ -49,7 +50,12 @@ public static Object[][] data() { {"/COM/INST/CodeComment/error.f", "/COM/INST/CodeComment/noError.f", new int[]{14, 17}, new String[]{"subroutine mpi_IO_e_us76", "subroutine mpi_IO_e_us76"}, COMINSTCodeComment.class}, {"/COM/INST/GoTo/error.f", "/COM/INST/GoTo/noError.f", new int[]{5}, new String[]{"PROGRAM ESSAI"}, COMINSTGoTo.class}, {"/COM/INST/LoopCondition/error.f", "/COM/INST/LoopCondition/noError.f", new int[]{5}, new String[]{"PROGRAM ESSAI"}, COMINSTLoopCondition.class}, + {"/COM/MET/ComplexitySimplified/error.f", "/COM/MET/ComplexitySimplified/noError.f", new int[]{1}, new String[]{"SUBROUTINE CALBED"}, COMMETComplexitySimplified.class}, + {"/COM/MET/LineOfCode/error.f", "/COM/MET/LineOfCode/noError.f", new int[]{170}, new String[]{"PROCEDURE ESSAI"}, COMMETLineOfCode.class}, + {"/COM/MET/RatioComment/error.f", "/COM/MET/RatioComment/noError.f", new int[]{15}, new String[]{"MAIN PROGRAM"}, COMMETRatioComment.class}, {"/COM/NAME/Homonymy/error.f", "/COM/NAME/Homonymy/noError.f", new int[]{7, 25, 29}, new String[]{"function f1", "subroutine s1", "function f3"}, COMNAMEHomonymy.class}, + {"/COM/PRES/Data/error.f", "/COM/PRES/Data/noError.f", new int[]{6}, new String[]{"r"}, COMPRESData.class}, + {"/COM/PRES/FileLength/error.f", "/COM/PRES/FileLength/noError.f", new int[]{1052}, new String[]{"SUBROUTINE MY_SUB1"}, COMPRESFileLength.class}, {"/COM/PRES/Indent/error.f", "/COM/PRES/Indent/noError.f", new int[]{6}, new String[]{"PROGRAM ESSAI"}, COMPRESIndent.class}, {"/COM/PRES/LengthLine/error.f", "/COM/PRES/LengthLine/noError.f", new int[]{7, 9, 18}, new String[]{"MAIN PROGRAM ESSAI", "MAIN PROGRAM ESSAI", "MAIN PROGRAM ESSAI"}, COMPRESLengthLine.class}, {"/COM/PROJECT/Header/error.f", "/COM/PROJECT/Header/noError.f", new int[]{0, 11}, new String[]{"No file header existing.", "FUNCTION F"}, COMPROJECTHeader.class}, @@ -65,6 +71,8 @@ public static Object[][] data() { {"/F77/DATA/IO/error.f", "/F77/DATA/IO/noError.f", new int[]{17, 18}, new String[]{"PROGRAM ESSAI", "PROGRAM ESSAI"}, F77REFIO.class}, {"/F77/DATA/LoopDO/error.f", "/F77/DATA/LoopDO/noError.f", new int[]{11}, new String[]{"PROGRAM ESSAI"}, F77DATALoopDO.class}, {"/F77/DATA/Parameter/error.f", "/F77/DATA/Parameter/noError.f", new int[]{8}, new String[]{"PROGRAM ESSAI"}, F77DATAParameter.class}, + {"/F77/DESIGN/LogicUnit/error.f", "/F77/DESIGN/LogicUnit/noError.f", new int[]{21}, new String[]{"MODULE ESSAI2"}, F77DESIGNLogicUnit.class}, + {"/F77/FILE/Header/error.f", "/F77/FILE/Header/noError.f", new int[]{1}, new String[]{"MODULE"}, F77FILEHeader.class}, {"/F77/INST/Assign/error.f", "/F77/INST/Assign/noError.f", new int[]{16, 29, 31, 33, 35}, new String[]{"PROGRAM ESSAI", "PROGRAM ESSAI", "PROGRAM ESSAI", "PROGRAM ESSAI", "PROGRAM ESSAI"}, F77INSTAssign.class}, {"/F77/INST/Dimension/error.f", "/F77/INST/Dimension/noError.f", new int[]{8}, new String[]{"PROGRAM ESSAI"}, F77INSTDimension.class}, {"/F77/INST/Equivalence/error.f", "/F77/INST/Equivalence/noError.f", new int[]{5}, new String[]{"PROGRAM ESSAI"}, F77INSTEquivalence.class}, diff --git a/fortran77-rules/src/test/resources/COM/FLOW/CheckArguments/error.f b/fortran77-rules/src/test/resources/COM/FLOW/CheckArguments/error.f new file mode 100644 index 00000000..8ba72735 --- /dev/null +++ b/fortran77-rules/src/test/resources/COM/FLOW/CheckArguments/error.f @@ -0,0 +1,4 @@ + SUBROUTINE C3BODY(GD, RCD, CDUV, RXD, XDUV, ACC, ACCUV, ARG8) + + + END SUBROUTINE diff --git a/fortran77-rules/src/test/resources/COM/FLOW/CheckArguments/noError.f b/fortran77-rules/src/test/resources/COM/FLOW/CheckArguments/noError.f new file mode 100644 index 00000000..f9770b9d --- /dev/null +++ b/fortran77-rules/src/test/resources/COM/FLOW/CheckArguments/noError.f @@ -0,0 +1,3 @@ + SUBROUTINE C3BODY(GD, RCD, CDUV, RXD) + + END SUBROUTINE \ No newline at end of file diff --git a/fortran77-rules/src/test/resources/COM/MET/ComplexitySimplified/error.f b/fortran77-rules/src/test/resources/COM/MET/ComplexitySimplified/error.f new file mode 100644 index 00000000..0702a249 --- /dev/null +++ b/fortran77-rules/src/test/resources/COM/MET/ComplexitySimplified/error.f @@ -0,0 +1,52 @@ + SUBROUTINE CALBED + + IF (BARYC .NE. 10) THEN + IF (BARYC .NE. 12) THEN + IF (BARYC .NE. 12) THEN + IF (BARYC .NE. 12) THEN + IF (BARYC .NE. 12) THEN + IF (BARYC .NE. 12) THEN + IF (BARYC .NE. 12) THEN + IF (BARYC .NE. 12) THEN + IF (BARYC .NE. 12) THEN + IF (BARYC .NE. 12) THEN + IF (BARYC .NE. 12) THEN + IF (BARYC .NE. 12) THEN + IF (BARYC .NE. 12) THEN + IF (BARYC .NE. 12) THEN + IF (BARYC .NE. 12) THEN + IF (BARYC .NE. 12) THEN + IF (BARYC .NE. 12) THEN + IF (BARYC .NE. 12) THEN + IF (BARYC .NE. 12) THEN + IF (BARYC .NE. 12) THEN + IF (BARYC .NE. 12) THEN + + + K=1 + + + END IF + END IF + END IF + END IF + END IF + END IF + END IF + END IF + END IF + END DO + END IF + END IF + END IF + END IF + END IF + END IF + END IF + END IF + END IF + END IF + END IF + + + END SUBROUTINE diff --git a/fortran77-rules/src/test/resources/COM/MET/ComplexitySimplified/noError.f b/fortran77-rules/src/test/resources/COM/MET/ComplexitySimplified/noError.f new file mode 100644 index 00000000..d99e244c --- /dev/null +++ b/fortran77-rules/src/test/resources/COM/MET/ComplexitySimplified/noError.f @@ -0,0 +1,13 @@ + SUBROUTINE C3BODY(GD, RCD, CDUV, RXD, XDUV, ACC, ACCUV) + + IF (BARYC .NE. 10) THEN + +C Check that BARYC as index does not exceed PEQUR array + IF (BARYC .NE. 12) THEN + RADIUS = PEQUR(BARYC) + ELSE + RADIUS = CSM_RADIUS + END IF + END IF + + END SUBROUTINE \ No newline at end of file diff --git a/fortran77-rules/src/test/resources/COM/MET/LineOfCode/error.f b/fortran77-rules/src/test/resources/COM/MET/LineOfCode/error.f new file mode 100644 index 00000000..7c35d368 --- /dev/null +++ b/fortran77-rules/src/test/resources/COM/MET/LineOfCode/error.f @@ -0,0 +1,170 @@ + PROCEDURE ESSAI + IMPLICIT NONE + REAL :: Tc + REAL :: Tf + REAL :: C_To_F + REAL :: F_To_C + WRITE(*, '(3X,"Temperature en Celsius:")') + READ(*,*) Tc + WRITE(*, '(3X,"->Conversion en Fahrenheit:",F8.3)') C_To_F(Tc) + WRITE(*, '(" ")') + WRITE(*, '(3X,"Temperature en Fahrenheit:")') + READ(*,*) Tf + WRITE(*, '(3X,"->Conversion en Celsius:",F8.3)') F_To_C(Tf) + IMPLICIT NONE + REAL :: Tc + REAL :: Tf + REAL :: C_To_F + REAL :: F_To_C + WRITE(*, '(3X,"Temperature en Celsius:")') + READ(*,*) Tc + WRITE(*, '(3X,"->Conversion en Fahrenheit:",F8.3)') C_To_F(Tc) + WRITE(*, '(" ")') + WRITE(*, '(3X,"Temperature en Fahrenheit:")') + READ(*,*) Tf + WRITE(*, '(3X,"->Conversion en Celsius:",F8.3)') F_To_C(Tf) + IMPLICIT NONE + REAL :: Tc + REAL :: Tf + REAL :: C_To_F + REAL :: F_To_C + WRITE(*, '(3X,"Temperature en Celsius:")') + READ(*,*) Tc + WRITE(*, '(3X,"->Conversion en Fahrenheit:",F8.3)') C_To_F(Tc) + WRITE(*, '(" ")') + WRITE(*, '(3X,"Temperature en Fahrenheit:")') + READ(*,*) Tf + WRITE(*, '(3X,"->Conversion en Celsius:",F8.3)') F_To_C(Tf) + IMPLICIT NONE + REAL :: Tc + REAL :: Tf + REAL :: C_To_F + REAL :: F_To_C + WRITE(*, '(3X,"Temperature en Celsius:")') + READ(*,*) Tc + WRITE(*, '(3X,"->Conversion en Fahrenheit:",F8.3)') C_To_F(Tc) + WRITE(*, '(" ")') + WRITE(*, '(3X,"Temperature en Fahrenheit:")') + READ(*,*) Tf + WRITE(*, '(3X,"->Conversion en Celsius:",F8.3)') F_To_C(Tf) + IMPLICIT NONE + REAL :: Tc + REAL :: Tf + REAL :: C_To_F + REAL :: F_To_C + WRITE(*, '(3X,"Temperature en Celsius:")') + READ(*,*) Tc + WRITE(*, '(3X,"->Conversion en Fahrenheit:",F8.3)') C_To_F(Tc) + WRITE(*, '(" ")') + WRITE(*, '(3X,"Temperature en Fahrenheit:")') + READ(*,*) Tf + WRITE(*, '(3X,"->Conversion en Celsius:",F8.3)') F_To_C(Tf) + IMPLICIT NONE + REAL :: Tc + REAL :: Tf + REAL :: C_To_F + REAL :: F_To_C + WRITE(*, '(3X,"Temperature en Celsius:")') + READ(*,*) Tc + WRITE(*, '(3X,"->Conversion en Fahrenheit:",F8.3)') C_To_F(Tc) + WRITE(*, '(" ")') + WRITE(*, '(3X,"Temperature en Fahrenheit:")') + READ(*,*) Tf + WRITE(*, '(3X,"->Conversion en Celsius:",F8.3)') F_To_C(Tf) + IMPLICIT NONE + REAL :: Tc + REAL :: Tf + REAL :: C_To_F + REAL :: F_To_C + WRITE(*, '(3X,"Temperature en Celsius:")') + READ(*,*) Tc + WRITE(*, '(3X,"->Conversion en Fahrenheit:",F8.3)') C_To_F(Tc) + WRITE(*, '(" ")') + WRITE(*, '(3X,"Temperature en Fahrenheit:")') + READ(*,*) Tf + WRITE(*, '(3X,"->Conversion en Celsius:",F8.3)') F_To_C(Tf) + IMPLICIT NONE + REAL :: Tc + REAL :: Tf + REAL :: C_To_F + REAL :: F_To_C + WRITE(*, '(3X,"Temperature en Celsius:")') + READ(*,*) Tc + WRITE(*, '(3X,"->Conversion en Fahrenheit:",F8.3)') C_To_F(Tc) + WRITE(*, '(" ")') + WRITE(*, '(3X,"Temperature en Fahrenheit:")') + READ(*,*) Tf + WRITE(*, '(3X,"->Conversion en Celsius:",F8.3)') F_To_C(Tf) + IMPLICIT NONE + REAL :: Tc + REAL :: Tf + REAL :: C_To_F + REAL :: F_To_C + WRITE(*, '(3X,"Temperature en Celsius:")') + READ(*,*) Tc + WRITE(*, '(3X,"->Conversion en Fahrenheit:",F8.3)') C_To_F(Tc) + WRITE(*, '(" ")') + WRITE(*, '(3X,"Temperature en Fahrenheit:")') + READ(*,*) Tf + WRITE(*, '(3X,"->Conversion en Celsius:",F8.3)') F_To_C(Tf) + IMPLICIT NONE + REAL :: Tc + REAL :: Tf + REAL :: C_To_F + REAL :: F_To_C + WRITE(*, '(3X,"Temperature en Celsius:")') + READ(*,*) Tc + WRITE(*, '(3X,"->Conversion en Fahrenheit:",F8.3)') C_To_F(Tc) + WRITE(*, '(" ")') + WRITE(*, '(3X,"Temperature en Fahrenheit:")') + READ(*,*) Tf + WRITE(*, '(3X,"->Conversion en Celsius:",F8.3)') F_To_C(Tf) + IMPLICIT NONE + REAL :: Tc + REAL :: Tf + REAL :: C_To_F + REAL :: F_To_C + WRITE(*, '(3X,"Temperature en Celsius:")') + READ(*,*) Tc + WRITE(*, '(3X,"->Conversion en Fahrenheit:",F8.3)') C_To_F(Tc) + WRITE(*, '(" ")') + WRITE(*, '(3X,"Temperature en Fahrenheit:")') + READ(*,*) Tf + WRITE(*, '(3X,"->Conversion en Celsius:",F8.3)') F_To_C(Tf) + IMPLICIT NONE + REAL :: Tc + REAL :: Tf + REAL :: C_To_F + REAL :: F_To_C + WRITE(*, '(3X,"Temperature en Celsius:")') + READ(*,*) Tc + WRITE(*, '(3X,"->Conversion en Fahrenheit:",F8.3)') C_To_F(Tc) + WRITE(*, '(" ")') + WRITE(*, '(3X,"Temperature en Fahrenheit:")') + READ(*,*) Tf + WRITE(*, '(3X,"->Conversion en Celsius:",F8.3)') F_To_C(Tf) + IMPLICIT NONE + REAL :: Tc + REAL :: Tf + REAL :: C_To_F + REAL :: F_To_C + WRITE(*, '(3X,"Temperature en Celsius:")') + READ(*,*) Tc + WRITE(*, '(3X,"->Conversion en Fahrenheit:",F8.3)') C_To_F(Tc) + WRITE(*, '(" ")') + WRITE(*, '(3X,"Temperature en Fahrenheit:")') + READ(*,*) Tf + WRITE(*, '(3X,"->Conversion en Celsius:",F8.3)') F_To_C(Tf) + IMPLICIT NONE + REAL :: Tc + REAL :: Tf + REAL :: C_To_F + REAL :: F_To_C + WRITE(*, '(3X,"Temperature en Celsius:")') + READ(*,*) Tc + WRITE(*, '(3X,"->Conversion en Fahrenheit:",F8.3)') C_To_F(Tc) + WRITE(*, '(" ")') + WRITE(*, '(3X,"Temperature en Fahrenheit:")') + READ(*,*) Tf + WRITE(*, '(3X,"->Conversion en Celsius:",F8.3)') F_To_C(Tf) + END PROCEDURE \ No newline at end of file diff --git a/fortran77-rules/src/test/resources/COM/MET/LineOfCode/noError.f b/fortran77-rules/src/test/resources/COM/MET/LineOfCode/noError.f new file mode 100644 index 00000000..f0bac97e --- /dev/null +++ b/fortran77-rules/src/test/resources/COM/MET/LineOfCode/noError.f @@ -0,0 +1,19 @@ + PROCEDURE ESSAI + + IMPLICIT NONE + + REAL :: Tc + REAL :: Tf + REAL :: C_To_F + REAL :: F_To_C + + WRITE(*, '(3X,"Temperature en Celsius:")') + READ(*,*) Tc + WRITE(*, '(3X,"->Conversion en Fahrenheit:",F8.3)') C_To_F(Tc) + + WRITE(*, '(" ")') + WRITE(*, '(3X,"Temperature en Fahrenheit:")') + READ(*,*) Tf + WRITE(*, '(3X,"->Conversion en Celsius:",F8.3)') F_To_C(Tf) + + END PROCEDURE \ No newline at end of file diff --git a/fortran77-rules/src/test/resources/COM/MET/RatioComment/error.f b/fortran77-rules/src/test/resources/COM/MET/RatioComment/error.f new file mode 100644 index 00000000..fb5dde26 --- /dev/null +++ b/fortran77-rules/src/test/resources/COM/MET/RatioComment/error.f @@ -0,0 +1,15 @@ + SUBROUTINE CEARSAT +! Calculates the velocity in equatorial system if satellite orbits around Earth + IF (BARYC .EQ. 3) THEN + VECT(1) = CBXVELX + VECT(2) = CBXVELY + VECT(3) = CBXVELZ + CALL CSYSCHANGE(VECT, VECT1, 1) + CVELX = VECT1(1) + CVELY = VECT1(2) + CVELZ = VECT1(3) + CALL SVUNIT(VECT1, CVELUV, CVELR) + END IF + RETURN + + END \ No newline at end of file diff --git a/fortran77-rules/src/test/resources/COM/MET/RatioComment/noError.f b/fortran77-rules/src/test/resources/COM/MET/RatioComment/noError.f new file mode 100644 index 00000000..d2d3fe87 --- /dev/null +++ b/fortran77-rules/src/test/resources/COM/MET/RatioComment/noError.f @@ -0,0 +1,69 @@ +C----------------------------------------------------------------------- +C +C Title : CEARSAT +C +C Function : Give the Earth-sat position in the Earth Equatorial CS +C +C Author : Christelle Crozat +C +C Date : 27/OCT/1998 +C +C Update record : +C +! Date Name Sar No. Change made +!----------------------------------------------------------------------- +! 12/04/00 M.Rodenhuis --- Made CPOS calculation more precise +! xx-Nov-07 S.Kranz PEM V4.0 Merged PEM V3.0.2 with PEM KT +!----------------------------------------------------------------------- +! + SUBROUTINE CEARSAT + + IMPLICIT REAL*8(A-H,O-Z) + +! COMMON DATA + INCLUDE 'SM_PEM_COMMON.LC' ! Position/Environment data +! Calculates common block data: +! CPOSX, CPOSY, CPOSZ, CPOSR, CPOSUV +! CVELX, CVELY, CVELZ, CVELR, CVELUV + +! LOCAL DATA + REAL*8 VECT(3) + REAL*8 VECT1(3) + +C BEGIN +! MR: Changed the way CPOS is calculated. If the orbit is around the Earth, +! it is more precise to calculate CPOS directly from CBXUV: + IF (BARYC .EQ. 3) THEN + VECT(1) = CBXDIST*CBXUV(1) + VECT(2) = CBXDIST*CBXUV(2) + VECT(3) = CBXDIST*CBXUV(3) + ELSE + DO J=1,3 + VECT(J) = -(SUN_PLANET(J,3) + SAT_SUN(J)) + END DO + END IF + +! Give the vector from the ecliptic frame to the equatorial frame + CALL CSYSCHANGE(VECT, VECT1, 1) + + CPOSX = VECT1(1) + CPOSY = VECT1(2) + CPOSZ = VECT1(3) + +! Give the unit vector in the Earth Equatorial frame of Earth-Sat vector + CALL SVUNIT(VECT1, CPOSUV, CPOSR) + +! Calculates the velocity in equatorial system if satellite orbits around Earth + IF (BARYC .EQ. 3) THEN + VECT(1) = CBXVELX + VECT(2) = CBXVELY + VECT(3) = CBXVELZ + CALL CSYSCHANGE(VECT, VECT1, 1) + CVELX = VECT1(1) + CVELY = VECT1(2) + CVELZ = VECT1(3) + CALL SVUNIT(VECT1, CVELUV, CVELR) + END IF + RETURN + + END \ No newline at end of file diff --git a/fortran77-rules/src/test/resources/COM/PRES/Data/error.f b/fortran77-rules/src/test/resources/COM/PRES/Data/error.f new file mode 100644 index 00000000..fea2e7da --- /dev/null +++ b/fortran77-rules/src/test/resources/COM/PRES/Data/error.f @@ -0,0 +1,8 @@ +C +C --- Main +C + PROGRAM ESSAI + + real r + + END PROGRAM ESSAI diff --git a/fortran77-rules/src/test/resources/COM/PRES/Data/noError.f b/fortran77-rules/src/test/resources/COM/PRES/Data/noError.f new file mode 100644 index 00000000..c6f209e6 --- /dev/null +++ b/fortran77-rules/src/test/resources/COM/PRES/Data/noError.f @@ -0,0 +1,9 @@ +C +C --- Main +C + PROGRAM ESSAI + +C --- real r comment + real r + + END PROGRAM ESSAI \ No newline at end of file diff --git a/fortran77-rules/src/test/resources/COM/PRES/FileLength/error.f b/fortran77-rules/src/test/resources/COM/PRES/FileLength/error.f new file mode 100644 index 00000000..8e3be3d8 --- /dev/null +++ b/fortran77-rules/src/test/resources/COM/PRES/FileLength/error.f @@ -0,0 +1,1052 @@ + PROGRAM ESSAI + BLOCK DATA ABCD_VAL + COMMON /CONTROL/ A, B, C, D + DATA A,B,C,D / 1.0, 2.0, 3.0, 4.0 / + END + STOP + SUBROUTINE MY_SUB1 + COMMON /CONTROL/ A, B, C, D + WRITE(*,*) 'C=', C, 'D=', D + RETURN + END + BLOCK DATA ABCD_VAL + COMMON /CONTROL/ A, B, C, D + DATA A,B,C,D / 1.0, 2.0, 3.0, 4.0 / + END + STOP + SUBROUTINE MY_SUB1 + COMMON /CONTROL/ A, B, C, D + WRITE(*,*) 'C=', C, 'D=', D + RETURN + END + BLOCK DATA ABCD_VAL + COMMON /CONTROL/ A, B, C, D + DATA A,B,C,D / 1.0, 2.0, 3.0, 4.0 / + END + STOP + SUBROUTINE MY_SUB1 + COMMON /CONTROL/ A, B, C, D + WRITE(*,*) 'C=', C, 'D=', D + RETURN + END + BLOCK DATA ABCD_VAL + COMMON /CONTROL/ A, B, C, D + DATA A,B,C,D / 1.0, 2.0, 3.0, 4.0 / + END + STOP + SUBROUTINE MY_SUB1 + COMMON /CONTROL/ A, B, C, D + WRITE(*,*) 'C=', C, 'D=', D + RETURN + END + BLOCK DATA ABCD_VAL + COMMON /CONTROL/ A, B, C, D + DATA A,B,C,D / 1.0, 2.0, 3.0, 4.0 / + END + STOP + SUBROUTINE MY_SUB1 + COMMON /CONTROL/ A, B, C, D + WRITE(*,*) 'C=', C, 'D=', D + RETURN + END + BLOCK DATA ABCD_VAL + COMMON /CONTROL/ A, B, C, D + DATA A,B,C,D / 1.0, 2.0, 3.0, 4.0 / + END + STOP + SUBROUTINE MY_SUB1 + COMMON /CONTROL/ A, B, C, D + WRITE(*,*) 'C=', C, 'D=', D + RETURN + END + BLOCK DATA ABCD_VAL + COMMON /CONTROL/ A, B, C, D + DATA A,B,C,D / 1.0, 2.0, 3.0, 4.0 / + END + STOP + SUBROUTINE MY_SUB1 + COMMON /CONTROL/ A, B, C, D + WRITE(*,*) 'C=', C, 'D=', D + RETURN + END + BLOCK DATA ABCD_VAL + COMMON /CONTROL/ A, B, C, D + DATA A,B,C,D / 1.0, 2.0, 3.0, 4.0 / + END + STOP + SUBROUTINE MY_SUB1 + COMMON /CONTROL/ A, B, C, D + WRITE(*,*) 'C=', C, 'D=', D + RETURN + END + BLOCK DATA ABCD_VAL + COMMON /CONTROL/ A, B, C, D + DATA A,B,C,D / 1.0, 2.0, 3.0, 4.0 / + END + STOP + SUBROUTINE MY_SUB1 + COMMON /CONTROL/ A, B, C, D + WRITE(*,*) 'C=', C, 'D=', D + RETURN + END + BLOCK DATA ABCD_VAL + COMMON /CONTROL/ A, B, C, D + DATA A,B,C,D / 1.0, 2.0, 3.0, 4.0 / + END + STOP + SUBROUTINE MY_SUB1 + COMMON /CONTROL/ A, B, C, D + WRITE(*,*) 'C=', C, 'D=', D + RETURN + END + BLOCK DATA ABCD_VAL + COMMON /CONTROL/ A, B, C, D + DATA A,B,C,D / 1.0, 2.0, 3.0, 4.0 / + END + STOP + SUBROUTINE MY_SUB1 + COMMON /CONTROL/ A, B, C, D + WRITE(*,*) 'C=', C, 'D=', D + RETURN + END + BLOCK DATA ABCD_VAL + COMMON /CONTROL/ A, B, C, D + DATA A,B,C,D / 1.0, 2.0, 3.0, 4.0 / + END + STOP + SUBROUTINE MY_SUB1 + COMMON /CONTROL/ A, B, C, D + WRITE(*,*) 'C=', C, 'D=', D + RETURN + END + BLOCK DATA ABCD_VAL + COMMON /CONTROL/ A, B, C, D + DATA A,B,C,D / 1.0, 2.0, 3.0, 4.0 / + END + STOP + SUBROUTINE MY_SUB1 + COMMON /CONTROL/ A, B, C, D + WRITE(*,*) 'C=', C, 'D=', D + RETURN + END + BLOCK DATA ABCD_VAL + COMMON /CONTROL/ A, B, C, D + DATA A,B,C,D / 1.0, 2.0, 3.0, 4.0 / + END + STOP + SUBROUTINE MY_SUB1 + COMMON /CONTROL/ A, B, C, D + WRITE(*,*) 'C=', C, 'D=', D + RETURN + END + BLOCK DATA ABCD_VAL + COMMON /CONTROL/ A, B, C, D + DATA A,B,C,D / 1.0, 2.0, 3.0, 4.0 / + END + STOP + SUBROUTINE MY_SUB1 + COMMON /CONTROL/ A, B, C, D + WRITE(*,*) 'C=', C, 'D=', D + RETURN + END + BLOCK DATA ABCD_VAL + COMMON /CONTROL/ A, B, C, D + DATA A,B,C,D / 1.0, 2.0, 3.0, 4.0 / + END + STOP + SUBROUTINE MY_SUB1 + COMMON /CONTROL/ A, B, C, D + WRITE(*,*) 'C=', C, 'D=', D + RETURN + END + BLOCK DATA ABCD_VAL + COMMON /CONTROL/ A, B, C, D + DATA A,B,C,D / 1.0, 2.0, 3.0, 4.0 / + END + STOP + SUBROUTINE MY_SUB1 + COMMON /CONTROL/ A, B, C, D + WRITE(*,*) 'C=', C, 'D=', D + RETURN + END + BLOCK DATA ABCD_VAL + COMMON /CONTROL/ A, B, C, D + DATA A,B,C,D / 1.0, 2.0, 3.0, 4.0 / + END + STOP + SUBROUTINE MY_SUB1 + COMMON /CONTROL/ A, B, C, D + WRITE(*,*) 'C=', C, 'D=', D + RETURN + END + BLOCK DATA ABCD_VAL + COMMON /CONTROL/ A, B, C, D + DATA A,B,C,D / 1.0, 2.0, 3.0, 4.0 / + END + STOP + SUBROUTINE MY_SUB1 + COMMON /CONTROL/ A, B, C, D + WRITE(*,*) 'C=', C, 'D=', D + RETURN + END + BLOCK DATA ABCD_VAL + COMMON /CONTROL/ A, B, C, D + DATA A,B,C,D / 1.0, 2.0, 3.0, 4.0 / + END + STOP + SUBROUTINE MY_SUB1 + COMMON /CONTROL/ A, B, C, D + WRITE(*,*) 'C=', C, 'D=', D + RETURN + END + BLOCK DATA ABCD_VAL + COMMON /CONTROL/ A, B, C, D + DATA A,B,C,D / 1.0, 2.0, 3.0, 4.0 / + END + STOP + SUBROUTINE MY_SUB1 + COMMON /CONTROL/ A, B, C, D + WRITE(*,*) 'C=', C, 'D=', D + RETURN + END + BLOCK DATA ABCD_VAL + COMMON /CONTROL/ A, B, C, D + DATA A,B,C,D / 1.0, 2.0, 3.0, 4.0 / + END + STOP + SUBROUTINE MY_SUB1 + COMMON /CONTROL/ A, B, C, D + WRITE(*,*) 'C=', C, 'D=', D + RETURN + END + BLOCK DATA ABCD_VAL + COMMON /CONTROL/ A, B, C, D + DATA A,B,C,D / 1.0, 2.0, 3.0, 4.0 / + END + STOP + SUBROUTINE MY_SUB1 + COMMON /CONTROL/ A, B, C, D + WRITE(*,*) 'C=', C, 'D=', D + RETURN + END + BLOCK DATA ABCD_VAL + COMMON /CONTROL/ A, B, C, D + DATA A,B,C,D / 1.0, 2.0, 3.0, 4.0 / + END + STOP + SUBROUTINE MY_SUB1 + COMMON /CONTROL/ A, B, C, D + WRITE(*,*) 'C=', C, 'D=', D + RETURN + END + BLOCK DATA ABCD_VAL + COMMON /CONTROL/ A, B, C, D + DATA A,B,C,D / 1.0, 2.0, 3.0, 4.0 / + END + STOP + SUBROUTINE MY_SUB1 + COMMON /CONTROL/ A, B, C, D + WRITE(*,*) 'C=', C, 'D=', D + RETURN + END + BLOCK DATA ABCD_VAL + COMMON /CONTROL/ A, B, C, D + DATA A,B,C,D / 1.0, 2.0, 3.0, 4.0 / + END + STOP + SUBROUTINE MY_SUB1 + COMMON /CONTROL/ A, B, C, D + WRITE(*,*) 'C=', C, 'D=', D + RETURN + END + BLOCK DATA ABCD_VAL + COMMON /CONTROL/ A, B, C, D + DATA A,B,C,D / 1.0, 2.0, 3.0, 4.0 / + END + STOP + SUBROUTINE MY_SUB1 + COMMON /CONTROL/ A, B, C, D + WRITE(*,*) 'C=', C, 'D=', D + RETURN + END + BLOCK DATA ABCD_VAL + COMMON /CONTROL/ A, B, C, D + DATA A,B,C,D / 1.0, 2.0, 3.0, 4.0 / + END + STOP + SUBROUTINE MY_SUB1 + COMMON /CONTROL/ A, B, C, D + WRITE(*,*) 'C=', C, 'D=', D + RETURN + END + BLOCK DATA ABCD_VAL + COMMON /CONTROL/ A, B, C, D + DATA A,B,C,D / 1.0, 2.0, 3.0, 4.0 / + END + STOP + SUBROUTINE MY_SUB1 + COMMON /CONTROL/ A, B, C, D + WRITE(*,*) 'C=', C, 'D=', D + RETURN + END + BLOCK DATA ABCD_VAL + COMMON /CONTROL/ A, B, C, D + DATA A,B,C,D / 1.0, 2.0, 3.0, 4.0 / + END + STOP + SUBROUTINE MY_SUB1 + COMMON /CONTROL/ A, B, C, D + WRITE(*,*) 'C=', C, 'D=', D + RETURN + END + BLOCK DATA ABCD_VAL + COMMON /CONTROL/ A, B, C, D + DATA A,B,C,D / 1.0, 2.0, 3.0, 4.0 / + END + STOP + SUBROUTINE MY_SUB1 + COMMON /CONTROL/ A, B, C, D + WRITE(*,*) 'C=', C, 'D=', D + RETURN + END + BLOCK DATA ABCD_VAL + COMMON /CONTROL/ A, B, C, D + DATA A,B,C,D / 1.0, 2.0, 3.0, 4.0 / + END + STOP + SUBROUTINE MY_SUB1 + COMMON /CONTROL/ A, B, C, D + WRITE(*,*) 'C=', C, 'D=', D + RETURN + END + BLOCK DATA ABCD_VAL + COMMON /CONTROL/ A, B, C, D + DATA A,B,C,D / 1.0, 2.0, 3.0, 4.0 / + END + STOP + SUBROUTINE MY_SUB1 + COMMON /CONTROL/ A, B, C, D + WRITE(*,*) 'C=', C, 'D=', D + RETURN + END + BLOCK DATA ABCD_VAL + COMMON /CONTROL/ A, B, C, D + DATA A,B,C,D / 1.0, 2.0, 3.0, 4.0 / + END + STOP + SUBROUTINE MY_SUB1 + COMMON /CONTROL/ A, B, C, D + WRITE(*,*) 'C=', C, 'D=', D + RETURN + END + BLOCK DATA ABCD_VAL + COMMON /CONTROL/ A, B, C, D + DATA A,B,C,D / 1.0, 2.0, 3.0, 4.0 / + END + STOP + SUBROUTINE MY_SUB1 + COMMON /CONTROL/ A, B, C, D + WRITE(*,*) 'C=', C, 'D=', D + RETURN + END + BLOCK DATA ABCD_VAL + COMMON /CONTROL/ A, B, C, D + DATA A,B,C,D / 1.0, 2.0, 3.0, 4.0 / + END + STOP + SUBROUTINE MY_SUB1 + COMMON /CONTROL/ A, B, C, D + WRITE(*,*) 'C=', C, 'D=', D + RETURN + END + BLOCK DATA ABCD_VAL + COMMON /CONTROL/ A, B, C, D + DATA A,B,C,D / 1.0, 2.0, 3.0, 4.0 / + END + STOP + SUBROUTINE MY_SUB1 + COMMON /CONTROL/ A, B, C, D + WRITE(*,*) 'C=', C, 'D=', D + RETURN + END + BLOCK DATA ABCD_VAL + COMMON /CONTROL/ A, B, C, D + DATA A,B,C,D / 1.0, 2.0, 3.0, 4.0 / + END + STOP + SUBROUTINE MY_SUB1 + COMMON /CONTROL/ A, B, C, D + WRITE(*,*) 'C=', C, 'D=', D + RETURN + END + BLOCK DATA ABCD_VAL + COMMON /CONTROL/ A, B, C, D + DATA A,B,C,D / 1.0, 2.0, 3.0, 4.0 / + END + STOP + SUBROUTINE MY_SUB1 + COMMON /CONTROL/ A, B, C, D + WRITE(*,*) 'C=', C, 'D=', D + RETURN + END + BLOCK DATA ABCD_VAL + COMMON /CONTROL/ A, B, C, D + DATA A,B,C,D / 1.0, 2.0, 3.0, 4.0 / + END + STOP + SUBROUTINE MY_SUB1 + COMMON /CONTROL/ A, B, C, D + WRITE(*,*) 'C=', C, 'D=', D + RETURN + END + BLOCK DATA ABCD_VAL + COMMON /CONTROL/ A, B, C, D + DATA A,B,C,D / 1.0, 2.0, 3.0, 4.0 / + END + STOP + SUBROUTINE MY_SUB1 + COMMON /CONTROL/ A, B, C, D + WRITE(*,*) 'C=', C, 'D=', D + RETURN + END + BLOCK DATA ABCD_VAL + COMMON /CONTROL/ A, B, C, D + DATA A,B,C,D / 1.0, 2.0, 3.0, 4.0 / + END + STOP + SUBROUTINE MY_SUB1 + COMMON /CONTROL/ A, B, C, D + WRITE(*,*) 'C=', C, 'D=', D + RETURN + END + BLOCK DATA ABCD_VAL + COMMON /CONTROL/ A, B, C, D + DATA A,B,C,D / 1.0, 2.0, 3.0, 4.0 / + END + STOP + SUBROUTINE MY_SUB1 + COMMON /CONTROL/ A, B, C, D + WRITE(*,*) 'C=', C, 'D=', D + RETURN + END + BLOCK DATA ABCD_VAL + COMMON /CONTROL/ A, B, C, D + DATA A,B,C,D / 1.0, 2.0, 3.0, 4.0 / + END + STOP + SUBROUTINE MY_SUB1 + COMMON /CONTROL/ A, B, C, D + WRITE(*,*) 'C=', C, 'D=', D + RETURN + END + BLOCK DATA ABCD_VAL + COMMON /CONTROL/ A, B, C, D + DATA A,B,C,D / 1.0, 2.0, 3.0, 4.0 / + END + STOP + SUBROUTINE MY_SUB1 + COMMON /CONTROL/ A, B, C, D + WRITE(*,*) 'C=', C, 'D=', D + RETURN + END + BLOCK DATA ABCD_VAL + COMMON /CONTROL/ A, B, C, D + DATA A,B,C,D / 1.0, 2.0, 3.0, 4.0 / + END + STOP + SUBROUTINE MY_SUB1 + COMMON /CONTROL/ A, B, C, D + WRITE(*,*) 'C=', C, 'D=', D + RETURN + END + BLOCK DATA ABCD_VAL + COMMON /CONTROL/ A, B, C, D + DATA A,B,C,D / 1.0, 2.0, 3.0, 4.0 / + END + STOP + SUBROUTINE MY_SUB1 + COMMON /CONTROL/ A, B, C, D + WRITE(*,*) 'C=', C, 'D=', D + RETURN + END + BLOCK DATA ABCD_VAL + COMMON /CONTROL/ A, B, C, D + DATA A,B,C,D / 1.0, 2.0, 3.0, 4.0 / + END + STOP + SUBROUTINE MY_SUB1 + COMMON /CONTROL/ A, B, C, D + WRITE(*,*) 'C=', C, 'D=', D + RETURN + END + BLOCK DATA ABCD_VAL + COMMON /CONTROL/ A, B, C, D + DATA A,B,C,D / 1.0, 2.0, 3.0, 4.0 / + END + STOP + SUBROUTINE MY_SUB1 + COMMON /CONTROL/ A, B, C, D + WRITE(*,*) 'C=', C, 'D=', D + RETURN + END + BLOCK DATA ABCD_VAL + COMMON /CONTROL/ A, B, C, D + DATA A,B,C,D / 1.0, 2.0, 3.0, 4.0 / + END + STOP + SUBROUTINE MY_SUB1 + COMMON /CONTROL/ A, B, C, D + WRITE(*,*) 'C=', C, 'D=', D + RETURN + END + BLOCK DATA ABCD_VAL + COMMON /CONTROL/ A, B, C, D + DATA A,B,C,D / 1.0, 2.0, 3.0, 4.0 / + END + STOP + SUBROUTINE MY_SUB1 + COMMON /CONTROL/ A, B, C, D + WRITE(*,*) 'C=', C, 'D=', D + RETURN + END + BLOCK DATA ABCD_VAL + COMMON /CONTROL/ A, B, C, D + DATA A,B,C,D / 1.0, 2.0, 3.0, 4.0 / + END + STOP + SUBROUTINE MY_SUB1 + COMMON /CONTROL/ A, B, C, D + WRITE(*,*) 'C=', C, 'D=', D + RETURN + END + BLOCK DATA ABCD_VAL + COMMON /CONTROL/ A, B, C, D + DATA A,B,C,D / 1.0, 2.0, 3.0, 4.0 / + END + STOP + SUBROUTINE MY_SUB1 + COMMON /CONTROL/ A, B, C, D + WRITE(*,*) 'C=', C, 'D=', D + RETURN + END + BLOCK DATA ABCD_VAL + COMMON /CONTROL/ A, B, C, D + DATA A,B,C,D / 1.0, 2.0, 3.0, 4.0 / + END + STOP + SUBROUTINE MY_SUB1 + COMMON /CONTROL/ A, B, C, D + WRITE(*,*) 'C=', C, 'D=', D + RETURN + END + BLOCK DATA ABCD_VAL + COMMON /CONTROL/ A, B, C, D + DATA A,B,C,D / 1.0, 2.0, 3.0, 4.0 / + END + STOP + SUBROUTINE MY_SUB1 + COMMON /CONTROL/ A, B, C, D + WRITE(*,*) 'C=', C, 'D=', D + RETURN + END + BLOCK DATA ABCD_VAL + COMMON /CONTROL/ A, B, C, D + DATA A,B,C,D / 1.0, 2.0, 3.0, 4.0 / + END + STOP + SUBROUTINE MY_SUB1 + COMMON /CONTROL/ A, B, C, D + WRITE(*,*) 'C=', C, 'D=', D + RETURN + END + BLOCK DATA ABCD_VAL + COMMON /CONTROL/ A, B, C, D + DATA A,B,C,D / 1.0, 2.0, 3.0, 4.0 / + END + STOP + SUBROUTINE MY_SUB1 + COMMON /CONTROL/ A, B, C, D + WRITE(*,*) 'C=', C, 'D=', D + RETURN + END + BLOCK DATA ABCD_VAL + COMMON /CONTROL/ A, B, C, D + DATA A,B,C,D / 1.0, 2.0, 3.0, 4.0 / + END + STOP + SUBROUTINE MY_SUB1 + COMMON /CONTROL/ A, B, C, D + WRITE(*,*) 'C=', C, 'D=', D + RETURN + END + BLOCK DATA ABCD_VAL + COMMON /CONTROL/ A, B, C, D + DATA A,B,C,D / 1.0, 2.0, 3.0, 4.0 / + END + STOP + SUBROUTINE MY_SUB1 + COMMON /CONTROL/ A, B, C, D + WRITE(*,*) 'C=', C, 'D=', D + RETURN + END + BLOCK DATA ABCD_VAL + COMMON /CONTROL/ A, B, C, D + DATA A,B,C,D / 1.0, 2.0, 3.0, 4.0 / + END + STOP + SUBROUTINE MY_SUB1 + COMMON /CONTROL/ A, B, C, D + WRITE(*,*) 'C=', C, 'D=', D + RETURN + END + BLOCK DATA ABCD_VAL + COMMON /CONTROL/ A, B, C, D + DATA A,B,C,D / 1.0, 2.0, 3.0, 4.0 / + END + STOP + SUBROUTINE MY_SUB1 + COMMON /CONTROL/ A, B, C, D + WRITE(*,*) 'C=', C, 'D=', D + RETURN + END + BLOCK DATA ABCD_VAL + COMMON /CONTROL/ A, B, C, D + DATA A,B,C,D / 1.0, 2.0, 3.0, 4.0 / + END + STOP + SUBROUTINE MY_SUB1 + COMMON /CONTROL/ A, B, C, D + WRITE(*,*) 'C=', C, 'D=', D + RETURN + END + BLOCK DATA ABCD_VAL + COMMON /CONTROL/ A, B, C, D + DATA A,B,C,D / 1.0, 2.0, 3.0, 4.0 / + END + STOP + SUBROUTINE MY_SUB1 + COMMON /CONTROL/ A, B, C, D + WRITE(*,*) 'C=', C, 'D=', D + RETURN + END + BLOCK DATA ABCD_VAL + COMMON /CONTROL/ A, B, C, D + DATA A,B,C,D / 1.0, 2.0, 3.0, 4.0 / + END + STOP + SUBROUTINE MY_SUB1 + COMMON /CONTROL/ A, B, C, D + WRITE(*,*) 'C=', C, 'D=', D + RETURN + END + BLOCK DATA ABCD_VAL + COMMON /CONTROL/ A, B, C, D + DATA A,B,C,D / 1.0, 2.0, 3.0, 4.0 / + END + STOP + SUBROUTINE MY_SUB1 + COMMON /CONTROL/ A, B, C, D + WRITE(*,*) 'C=', C, 'D=', D + RETURN + END + BLOCK DATA ABCD_VAL + COMMON /CONTROL/ A, B, C, D + DATA A,B,C,D / 1.0, 2.0, 3.0, 4.0 / + END + STOP + SUBROUTINE MY_SUB1 + COMMON /CONTROL/ A, B, C, D + WRITE(*,*) 'C=', C, 'D=', D + RETURN + END + BLOCK DATA ABCD_VAL + COMMON /CONTROL/ A, B, C, D + DATA A,B,C,D / 1.0, 2.0, 3.0, 4.0 / + END + STOP + SUBROUTINE MY_SUB1 + COMMON /CONTROL/ A, B, C, D + WRITE(*,*) 'C=', C, 'D=', D + RETURN + END + BLOCK DATA ABCD_VAL + COMMON /CONTROL/ A, B, C, D + DATA A,B,C,D / 1.0, 2.0, 3.0, 4.0 / + END + STOP + SUBROUTINE MY_SUB1 + COMMON /CONTROL/ A, B, C, D + WRITE(*,*) 'C=', C, 'D=', D + RETURN + END + BLOCK DATA ABCD_VAL + COMMON /CONTROL/ A, B, C, D + DATA A,B,C,D / 1.0, 2.0, 3.0, 4.0 / + END + STOP + SUBROUTINE MY_SUB1 + COMMON /CONTROL/ A, B, C, D + WRITE(*,*) 'C=', C, 'D=', D + RETURN + END + BLOCK DATA ABCD_VAL + COMMON /CONTROL/ A, B, C, D + DATA A,B,C,D / 1.0, 2.0, 3.0, 4.0 / + END + STOP + SUBROUTINE MY_SUB1 + COMMON /CONTROL/ A, B, C, D + WRITE(*,*) 'C=', C, 'D=', D + RETURN + END + BLOCK DATA ABCD_VAL + COMMON /CONTROL/ A, B, C, D + DATA A,B,C,D / 1.0, 2.0, 3.0, 4.0 / + END + STOP + SUBROUTINE MY_SUB1 + COMMON /CONTROL/ A, B, C, D + WRITE(*,*) 'C=', C, 'D=', D + RETURN + END + BLOCK DATA ABCD_VAL + COMMON /CONTROL/ A, B, C, D + DATA A,B,C,D / 1.0, 2.0, 3.0, 4.0 / + END + STOP + SUBROUTINE MY_SUB1 + COMMON /CONTROL/ A, B, C, D + WRITE(*,*) 'C=', C, 'D=', D + RETURN + END + BLOCK DATA ABCD_VAL + COMMON /CONTROL/ A, B, C, D + DATA A,B,C,D / 1.0, 2.0, 3.0, 4.0 / + END + STOP + SUBROUTINE MY_SUB1 + COMMON /CONTROL/ A, B, C, D + WRITE(*,*) 'C=', C, 'D=', D + RETURN + END + BLOCK DATA ABCD_VAL + COMMON /CONTROL/ A, B, C, D + DATA A,B,C,D / 1.0, 2.0, 3.0, 4.0 / + END + STOP + SUBROUTINE MY_SUB1 + COMMON /CONTROL/ A, B, C, D + WRITE(*,*) 'C=', C, 'D=', D + RETURN + END + BLOCK DATA ABCD_VAL + COMMON /CONTROL/ A, B, C, D + DATA A,B,C,D / 1.0, 2.0, 3.0, 4.0 / + END + STOP + SUBROUTINE MY_SUB1 + COMMON /CONTROL/ A, B, C, D + WRITE(*,*) 'C=', C, 'D=', D + RETURN + END + BLOCK DATA ABCD_VAL + COMMON /CONTROL/ A, B, C, D + DATA A,B,C,D / 1.0, 2.0, 3.0, 4.0 / + END + STOP + SUBROUTINE MY_SUB1 + COMMON /CONTROL/ A, B, C, D + WRITE(*,*) 'C=', C, 'D=', D + RETURN + END + BLOCK DATA ABCD_VAL + COMMON /CONTROL/ A, B, C, D + DATA A,B,C,D / 1.0, 2.0, 3.0, 4.0 / + END + STOP + SUBROUTINE MY_SUB1 + COMMON /CONTROL/ A, B, C, D + WRITE(*,*) 'C=', C, 'D=', D + RETURN + END + BLOCK DATA ABCD_VAL + COMMON /CONTROL/ A, B, C, D + DATA A,B,C,D / 1.0, 2.0, 3.0, 4.0 / + END + STOP + SUBROUTINE MY_SUB1 + COMMON /CONTROL/ A, B, C, D + WRITE(*,*) 'C=', C, 'D=', D + RETURN + END + BLOCK DATA ABCD_VAL + COMMON /CONTROL/ A, B, C, D + DATA A,B,C,D / 1.0, 2.0, 3.0, 4.0 / + END + STOP + SUBROUTINE MY_SUB1 + COMMON /CONTROL/ A, B, C, D + WRITE(*,*) 'C=', C, 'D=', D + RETURN + END + BLOCK DATA ABCD_VAL + COMMON /CONTROL/ A, B, C, D + DATA A,B,C,D / 1.0, 2.0, 3.0, 4.0 / + END + STOP + SUBROUTINE MY_SUB1 + COMMON /CONTROL/ A, B, C, D + WRITE(*,*) 'C=', C, 'D=', D + RETURN + END + BLOCK DATA ABCD_VAL + COMMON /CONTROL/ A, B, C, D + DATA A,B,C,D / 1.0, 2.0, 3.0, 4.0 / + END + STOP + SUBROUTINE MY_SUB1 + COMMON /CONTROL/ A, B, C, D + WRITE(*,*) 'C=', C, 'D=', D + RETURN + END + BLOCK DATA ABCD_VAL + COMMON /CONTROL/ A, B, C, D + DATA A,B,C,D / 1.0, 2.0, 3.0, 4.0 / + END + STOP + SUBROUTINE MY_SUB1 + COMMON /CONTROL/ A, B, C, D + WRITE(*,*) 'C=', C, 'D=', D + RETURN + END + BLOCK DATA ABCD_VAL + COMMON /CONTROL/ A, B, C, D + DATA A,B,C,D / 1.0, 2.0, 3.0, 4.0 / + END + STOP + SUBROUTINE MY_SUB1 + COMMON /CONTROL/ A, B, C, D + WRITE(*,*) 'C=', C, 'D=', D + RETURN + END + BLOCK DATA ABCD_VAL + COMMON /CONTROL/ A, B, C, D + DATA A,B,C,D / 1.0, 2.0, 3.0, 4.0 / + END + STOP + SUBROUTINE MY_SUB1 + COMMON /CONTROL/ A, B, C, D + WRITE(*,*) 'C=', C, 'D=', D + RETURN + END + BLOCK DATA ABCD_VAL + COMMON /CONTROL/ A, B, C, D + DATA A,B,C,D / 1.0, 2.0, 3.0, 4.0 / + END + STOP + SUBROUTINE MY_SUB1 + COMMON /CONTROL/ A, B, C, D + WRITE(*,*) 'C=', C, 'D=', D + RETURN + END + BLOCK DATA ABCD_VAL + COMMON /CONTROL/ A, B, C, D + DATA A,B,C,D / 1.0, 2.0, 3.0, 4.0 / + END + STOP + SUBROUTINE MY_SUB1 + COMMON /CONTROL/ A, B, C, D + WRITE(*,*) 'C=', C, 'D=', D + RETURN + END + BLOCK DATA ABCD_VAL + COMMON /CONTROL/ A, B, C, D + DATA A,B,C,D / 1.0, 2.0, 3.0, 4.0 / + END + STOP + SUBROUTINE MY_SUB1 + COMMON /CONTROL/ A, B, C, D + WRITE(*,*) 'C=', C, 'D=', D + RETURN + END + BLOCK DATA ABCD_VAL + COMMON /CONTROL/ A, B, C, D + DATA A,B,C,D / 1.0, 2.0, 3.0, 4.0 / + END + STOP + SUBROUTINE MY_SUB1 + COMMON /CONTROL/ A, B, C, D + WRITE(*,*) 'C=', C, 'D=', D + RETURN + END + BLOCK DATA ABCD_VAL + COMMON /CONTROL/ A, B, C, D + DATA A,B,C,D / 1.0, 2.0, 3.0, 4.0 / + END + STOP + SUBROUTINE MY_SUB1 + COMMON /CONTROL/ A, B, C, D + WRITE(*,*) 'C=', C, 'D=', D + RETURN + END + BLOCK DATA ABCD_VAL + COMMON /CONTROL/ A, B, C, D + DATA A,B,C,D / 1.0, 2.0, 3.0, 4.0 / + END + STOP + SUBROUTINE MY_SUB1 + COMMON /CONTROL/ A, B, C, D + WRITE(*,*) 'C=', C, 'D=', D + RETURN + END + BLOCK DATA ABCD_VAL + COMMON /CONTROL/ A, B, C, D + DATA A,B,C,D / 1.0, 2.0, 3.0, 4.0 / + END + STOP + SUBROUTINE MY_SUB1 + COMMON /CONTROL/ A, B, C, D + WRITE(*,*) 'C=', C, 'D=', D + RETURN + END + BLOCK DATA ABCD_VAL + COMMON /CONTROL/ A, B, C, D + DATA A,B,C,D / 1.0, 2.0, 3.0, 4.0 / + END + STOP + SUBROUTINE MY_SUB1 + COMMON /CONTROL/ A, B, C, D + WRITE(*,*) 'C=', C, 'D=', D + RETURN + END + BLOCK DATA ABCD_VAL + COMMON /CONTROL/ A, B, C, D + DATA A,B,C,D / 1.0, 2.0, 3.0, 4.0 / + END + STOP + SUBROUTINE MY_SUB1 + COMMON /CONTROL/ A, B, C, D + WRITE(*,*) 'C=', C, 'D=', D + RETURN + END + BLOCK DATA ABCD_VAL + COMMON /CONTROL/ A, B, C, D + DATA A,B,C,D / 1.0, 2.0, 3.0, 4.0 / + END + STOP + SUBROUTINE MY_SUB1 + COMMON /CONTROL/ A, B, C, D + WRITE(*,*) 'C=', C, 'D=', D + RETURN + END + BLOCK DATA ABCD_VAL + COMMON /CONTROL/ A, B, C, D + DATA A,B,C,D / 1.0, 2.0, 3.0, 4.0 / + END + STOP + SUBROUTINE MY_SUB1 + COMMON /CONTROL/ A, B, C, D + WRITE(*,*) 'C=', C, 'D=', D + RETURN + END + BLOCK DATA ABCD_VAL + COMMON /CONTROL/ A, B, C, D + DATA A,B,C,D / 1.0, 2.0, 3.0, 4.0 / + END + STOP + SUBROUTINE MY_SUB1 + COMMON /CONTROL/ A, B, C, D + WRITE(*,*) 'C=', C, 'D=', D + RETURN + END + BLOCK DATA ABCD_VAL + COMMON /CONTROL/ A, B, C, D + DATA A,B,C,D / 1.0, 2.0, 3.0, 4.0 / + END + STOP + SUBROUTINE MY_SUB1 + COMMON /CONTROL/ A, B, C, D + WRITE(*,*) 'C=', C, 'D=', D + RETURN + END + BLOCK DATA ABCD_VAL + COMMON /CONTROL/ A, B, C, D + DATA A,B,C,D / 1.0, 2.0, 3.0, 4.0 / + END + STOP + SUBROUTINE MY_SUB1 + COMMON /CONTROL/ A, B, C, D + WRITE(*,*) 'C=', C, 'D=', D + RETURN + END + BLOCK DATA ABCD_VAL + COMMON /CONTROL/ A, B, C, D + DATA A,B,C,D / 1.0, 2.0, 3.0, 4.0 / + END + STOP + SUBROUTINE MY_SUB1 + COMMON /CONTROL/ A, B, C, D + WRITE(*,*) 'C=', C, 'D=', D + RETURN + END + BLOCK DATA ABCD_VAL + COMMON /CONTROL/ A, B, C, D + DATA A,B,C,D / 1.0, 2.0, 3.0, 4.0 / + END + STOP + SUBROUTINE MY_SUB1 + COMMON /CONTROL/ A, B, C, D + WRITE(*,*) 'C=', C, 'D=', D + RETURN + END + BLOCK DATA ABCD_VAL + COMMON /CONTROL/ A, B, C, D + DATA A,B,C,D / 1.0, 2.0, 3.0, 4.0 / + END + STOP + SUBROUTINE MY_SUB1 + COMMON /CONTROL/ A, B, C, D + WRITE(*,*) 'C=', C, 'D=', D + RETURN + END + BLOCK DATA ABCD_VAL + COMMON /CONTROL/ A, B, C, D + DATA A,B,C,D / 1.0, 2.0, 3.0, 4.0 / + END + STOP + SUBROUTINE MY_SUB1 + COMMON /CONTROL/ A, B, C, D + WRITE(*,*) 'C=', C, 'D=', D + RETURN + END + BLOCK DATA ABCD_VAL + COMMON /CONTROL/ A, B, C, D + DATA A,B,C,D / 1.0, 2.0, 3.0, 4.0 / + END + STOP + SUBROUTINE MY_SUB1 + COMMON /CONTROL/ A, B, C, D + WRITE(*,*) 'C=', C, 'D=', D + RETURN + END + BLOCK DATA ABCD_VAL + COMMON /CONTROL/ A, B, C, D + DATA A,B,C,D / 1.0, 2.0, 3.0, 4.0 / + END + STOP + SUBROUTINE MY_SUB1 + COMMON /CONTROL/ A, B, C, D + WRITE(*,*) 'C=', C, 'D=', D + RETURN + END + BLOCK DATA ABCD_VAL + COMMON /CONTROL/ A, B, C, D + DATA A,B,C,D / 1.0, 2.0, 3.0, 4.0 / + END + STOP + SUBROUTINE MY_SUB1 + COMMON /CONTROL/ A, B, C, D + WRITE(*,*) 'C=', C, 'D=', D + RETURN + END + END PROGRAM ESSAI \ No newline at end of file diff --git a/fortran77-rules/src/test/resources/COM/PRES/FileLength/noError.f b/fortran77-rules/src/test/resources/COM/PRES/FileLength/noError.f new file mode 100644 index 00000000..08a0a017 --- /dev/null +++ b/fortran77-rules/src/test/resources/COM/PRES/FileLength/noError.f @@ -0,0 +1,28 @@ +C +C --- Le common 'CONTROL' defini ici contient 4 REAL +C + BLOCK DATA ABCD_VAL + COMMON /CONTROL/ A, B, C, D + DATA A,B,C,D / 1.0, 2.0, 3.0, 4.0 / + END +C +C --- Main +C + PROGRAM ESSAI + CALL MY_SUB1 + STOP + END PROGRAM ESSAI +C +C --- Subroutine +C + SUBROUTINE MY_SUB1 +C +C --- Dans la definition du common nomme, il faut veiller au type des variables et a +C --- leur ordre de definition : l'utilisation dans un INCLUDE est recommandee +C --- On ne le fait pas ici, afin que l'exemple soit explicite +C + COMMON /CONTROL/ A, B, C, D +C + WRITE(*,*) 'C=', C, 'D=', D + RETURN + END diff --git a/fortran77-rules/src/test/resources/F77/DESIGN/LogicUnit/error.f b/fortran77-rules/src/test/resources/F77/DESIGN/LogicUnit/error.f new file mode 100644 index 00000000..476954cb --- /dev/null +++ b/fortran77-rules/src/test/resources/F77/DESIGN/LogicUnit/error.f @@ -0,0 +1,39 @@ + MODULE ESSAI + + INTEGER I_UID + INTEGER I_STDOUT + + I_STDOUT = 6 + + WRITE(I_STDOUT, 10) +C +C --- En ne mettant pas de parentheses a MY_GETUID, le compilateur comprend que +C --- c'est la variable MY_GETUID qui est adressee . Par defaut, cette variable n'ayant +C --- pas ete declaree explicitement (elle est bien de type INTEGER car commence par lettre M) +C --- mais n'ayant pas ete initialisee, elle a un contenu indefini . +C --- Le resultat est que I_UID a lui aussi un contenu indefini . +C + I_UID = MY_GETUID + WRITE(I_STDOUT, *) 'UID =', I_UID + + END MODULE + + MODULE ESSAI2 + + INTEGER I_UID + INTEGER I_STDOUT + + I_STDOUT = 6 + + WRITE(I_STDOUT, 10) +C +C --- En ne mettant pas de parentheses a MY_GETUID, le compilateur comprend que +C --- c'est la variable MY_GETUID qui est adressee . Par defaut, cette variable n'ayant +C --- pas ete declaree explicitement (elle est bien de type INTEGER car commence par lettre M) +C --- mais n'ayant pas ete initialisee, elle a un contenu indefini . +C --- Le resultat est que I_UID a lui aussi un contenu indefini . +C + I_UID = MY_GETUID + WRITE(I_STDOUT, *) 'UID =', I_UID + + END MODULE \ No newline at end of file diff --git a/fortran77-rules/src/test/resources/F77/DESIGN/LogicUnit/noError.f b/fortran77-rules/src/test/resources/F77/DESIGN/LogicUnit/noError.f new file mode 100644 index 00000000..e30d008f --- /dev/null +++ b/fortran77-rules/src/test/resources/F77/DESIGN/LogicUnit/noError.f @@ -0,0 +1,25 @@ + PROGRAM ESSAI + + INTEGER I_UID + INTEGER I_STDOUT + + I_STDOUT = 6 + + WRITE(I_STDOUT, 10) +C +C --- En ne mettant pas de parentheses a MY_GETUID, le compilateur comprend que +C --- c'est la variable MY_GETUID qui est adressee . Par defaut, cette variable n'ayant +C --- pas ete declaree explicitement (elle est bien de type INTEGER car commence par lettre M) +C --- mais n'ayant pas ete initialisee, elle a un contenu indefini . +C --- Le resultat est que I_UID a lui aussi un contenu indefini . +C + I_UID = MY_GETUID + WRITE(I_STDOUT, *) 'UID =', I_UID +C +C -------------------------------------------------------------------------- +C F O R M A T S +C -------------------------------------------------------------------------- +C +10 FORMAT(1X, '--- Recuperer le User Id ---') + + END PROGRAM \ No newline at end of file diff --git a/fortran77-rules/src/test/resources/F77/FILE/Header/noError.f b/fortran77-rules/src/test/resources/F77/FILE/Header/noError.f new file mode 100644 index 00000000..b96464df --- /dev/null +++ b/fortran77-rules/src/test/resources/F77/FILE/Header/noError.f @@ -0,0 +1,29 @@ + MODULE ESSAI + +C------------------------------------------------------------------------------- +C Component Name: component name +C File: file name (it may be automatically inserted by the code management tool) +C Author: author name +C Copyright: EUMETSAT 2015 +C Description: brief description of the purpose of the file content (e.g. class +C description) +C------------------------------------------------------------------------------- + + + IMPLICIT NONE + + REAL :: Tc + REAL :: Tf + REAL :: C_To_F + REAL :: F_To_C + + WRITE(*, '(3X,"Temperature en Celsius:")') + READ(*,*) Tc + WRITE(*, '(3X,"->Conversion en Fahrenheit:",F8.3)') C_To_F(Tc) + + WRITE(*, '(" ")') + WRITE(*, '(3X,"Temperature en Fahrenheit:")') + READ(*,*) Tf + WRITE(*, '(3X,"->Conversion en Celsius:",F8.3)') F_To_C(Tf) + + END MODULE ESSAI diff --git a/fortran90-rules/src/test/java/fr/cnes/icode/fortran90/rules/TestAllFortran90Rules.java b/fortran90-rules/src/test/java/fr/cnes/icode/fortran90/rules/TestAllFortran90Rules.java index caeadb89..02eab5f4 100644 --- a/fortran90-rules/src/test/java/fr/cnes/icode/fortran90/rules/TestAllFortran90Rules.java +++ b/fortran90-rules/src/test/java/fr/cnes/icode/fortran90/rules/TestAllFortran90Rules.java @@ -39,6 +39,7 @@ public static Object[][] data() { {"/COM/FLOW/Abort/error.f", "/COM/FLOW/Abort/noError.f", new int[]{15}, new String[]{"PROGRAM ESSAI"}, COMFLOWAbort.class}, {"/COM/FLOW/BooleanExpression/error.f", "/COM/FLOW/BooleanExpression/noError.f", new int[]{11}, new String[]{"PROGRAM ESSAI"}, COMFLOWBooleanExpression.class}, {"/COM/FLOW/CaseSwitch/error.f", "/COM/FLOW/CaseSwitch/noError.f", new int[]{3}, new String[]{"PROGRAM ESSAI"}, COMFLOWCaseSwitch.class}, + {"/COM/FLOW/CheckArguments/error.f", "/COM/FLOW/CheckArguments/noError.f", new int[]{1}, new String[]{"SUBROUTINE C3BODY"}, COMFLOWCheckArguments.class}, {"/COM/FLOW/CheckCodeReturn/error.f90", "/COM/FLOW/CheckCodeReturn/noError.f90", new int[]{7}, new String[]{"PROGRAM MAIN"}, COMFLOWCheckCodeReturn.class}, {"/COM/FLOW/CheckUser/error.f90", "/COM/FLOW/CheckUser/noError.f90", new int[]{1}, new String[]{"PROGRAM MAIN"}, COMFLOWCheckUser.class}, {"/COM/FLOW/Exit/error.f", "/COM/FLOW/Exit/noError.f", new int[]{12}, new String[]{"function f1"}, COMFLOWExit.class}, @@ -52,9 +53,14 @@ public static Object[][] data() { {"/COM/INST/GoTo/error.f", "/COM/INST/GoTo/noError.f", new int[]{5}, new String[]{"PROGRAM ESSAI"}, COMINSTGoTo.class}, {"/COM/INST/Line/error.f", "/COM/INST/Line/noError.f", new int[]{2}, new String[]{"PROGRAM ESSAI"}, COMINSTLine.class}, {"/COM/INST/LoopCondition/error.f", "/COM/INST/LoopCondition/noError.f", new int[]{5, 11}, new String[]{"PROGRAM ESSAI", "PROGRAM ESSAI"}, COMINSTLoopCondition.class}, + {"/COM/MET/ComplexitySimplified/error.f", "/COM/MET/ComplexitySimplified/noError.f", new int[]{1}, new String[]{"SUBROUTINE CALBED"}, COMMETComplexitySimplified.class}, + {"/COM/MET/LineOfCode/error.f90", "/COM/MET/LineOfCode/noError.f90", new int[]{170}, new String[]{"PROCEDURE ESSAI"}, COMMETLineOfCode.class}, + {"/COM/MET/RatioComment/error.f", "/COM/MET/RatioComment/noError.f", new int[]{15}, new String[]{"MAIN PROGRAM"}, COMMETRatioComment.class}, {"/COM/NAME/Homonymy/error.f", "/COM/NAME/Homonymy/noError.f", new int[]{24, 42, 46}, new String[]{"function f1", "subroutine s2", "function f3"}, COMNAMEHomonymy.class}, + {"/COM/PRES/Data/error.f90", "/COM/PRES/Data/noError.f90", new int[]{3}, new String[]{"daMatTr"}, COMPRESData.class}, {"/COM/PRES/Indent/error.f", "/COM/PRES/Indent/noError.f", new int[]{5, 6}, new String[]{"PROGRAM ESSAI", "PROGRAM ESSAI"}, COMPRESIndent.class}, {"/COM/PRES/LengthLine/error.f", "/COM/PRES/LengthLine/noError.f", new int[]{7, 9, 18}, new String[]{"PROGRAM ESSAI", "PROGRAM ESSAI", "PROGRAM ESSAI"}, COMPRESLengthLine.class}, + {"/COM/PRES/FileLength/error.f", "/COM/PRES/FileLength/noError.f", new int[]{1502}, new String[]{"subroutine ncdf_getvar_2D_FourByteInt"}, COMPRESFileLength.class}, {"/COM/PROJECT/Header/error.f90", "/COM/PROJECT/Header/noError.f90", new int[]{0, 11}, new String[]{"No file header existing.", "FUNCTION F"}, COMPROJECTHeader.class}, {"/COM/TYPE/Expression/error.f", "/COM/TYPE/Expression/noError.f", new int[]{20, 21, 23, 48}, new String[]{"PROGRAM ESSAI", "PROGRAM ESSAI", "PROGRAM ESSAI", "SUBROUTINE GS_calcul_ecart_echt"}, COMTYPEExpression.class}, {"/F90/BLOC/File/error.f", "/F90/BLOC/File/noError.f", new int[]{20}, new String[]{"PROGRAM ESSAI"}, F90BLOCFile.class}, @@ -69,9 +75,11 @@ public static Object[][] data() { {"/F90/DESIGN/Include/error.f", "/F90/DESIGN/Include/noError.f", new int[]{1}, new String[]{"MAIN PROGRAM"}, F90DESIGNInclude.class}, {"/F90/DESIGN/Interface/error.f90", "/F90/DESIGN/Interface/noError.f90", new int[]{50}, new String[]{"module PLUSIEURS_USAGES"}, F90DESIGNInterface.class}, {"/F90/DESIGN/IO/error.f90", "/F90/DESIGN/IO/noError.f90", new int[]{12, 14, 16, 20}, new String[]{"PROGRAM ESSAI", "PROGRAM ESSAI", "PROGRAM ESSAI", "PROGRAM ESSAI"}, F90DESIGNIO.class}, + {"/F90/DESIGN/LogicUnit/error.f90", "/F90/DESIGN/LogicUnit/noError.f90", new int[]{21}, new String[]{"MODULE ESSAI2"}, F90DESIGNLogicUnit.class}, {"/F90/DESIGN/Obsolete/error.f", "/F90/DESIGN/Obsolete/noError.f", new int[]{8, 78, 79, 92, 115, 123, 124, 176, 183, 191}, new String[]{"function RETOURNE", "PROGRAM ESSAI", "PROGRAM ESSAI", "PROGRAM ESSAI", "PROGRAM ESSAI", "PROGRAM ESSAI", "function RETOURNE", "PROGRAM ESSAI", "PROGRAM ESSAI", "PROGRAM ESSAI"}, F90DESIGNObsolete.class}, {"/F90/ERR/Allocate/error.f", "/F90/ERR/Allocate/noError.f", new int[]{26, 30, 59, 65}, new String[]{"PROGRAM ESSAI", "PROGRAM ESSAI", "PROGRAM ESSAI", "PROGRAM ESSAI"}, F90ERRAllocate.class}, {"/F90/ERR/OpenRead/error.f", "/F90/ERR/OpenRead/noError.f", new int[]{27, 32, 39, 42}, new String[]{"PROGRAM ESSAI", "PROGRAM ESSAI", "PROGRAM ESSAI", "PROGRAM ESSAI"}, F90ERROpenRead.class}, + {"/F90/FILE/Header/error.f90", "/F90/FILE/Header/noError.f90", new int[]{1}, new String[]{"MODULE"}, F90FILEHeader.class}, {"/F90/INST/Associated/error.f90", "/F90/INST/Associated/noError.f90", new int[]{44, 52}, new String[]{"PROGRAM ESSAI", "PROGRAM ESSAI"}, F90INSTAssociated.class}, {"/F90/INST/Entry/error.f", "/F90/INST/Entry/noError.f", new int[]{10, 16}, new String[]{"SUBROUTINE FIN", "SUBROUTINE FIN"}, F90INSTEntry.class}, {"/F90/INST/Equivalence/error.f90", "/F90/INST/Equivalence/noError.f90", new int[]{10}, new String[]{"program ESSAI"}, F90INSTEquivalence.class}, diff --git a/fortran90-rules/src/test/resources/COM/FLOW/CheckArguments/error.f b/fortran90-rules/src/test/resources/COM/FLOW/CheckArguments/error.f new file mode 100644 index 00000000..8ba72735 --- /dev/null +++ b/fortran90-rules/src/test/resources/COM/FLOW/CheckArguments/error.f @@ -0,0 +1,4 @@ + SUBROUTINE C3BODY(GD, RCD, CDUV, RXD, XDUV, ACC, ACCUV, ARG8) + + + END SUBROUTINE diff --git a/fortran90-rules/src/test/resources/COM/FLOW/CheckArguments/noError.f b/fortran90-rules/src/test/resources/COM/FLOW/CheckArguments/noError.f new file mode 100644 index 00000000..f9770b9d --- /dev/null +++ b/fortran90-rules/src/test/resources/COM/FLOW/CheckArguments/noError.f @@ -0,0 +1,3 @@ + SUBROUTINE C3BODY(GD, RCD, CDUV, RXD) + + END SUBROUTINE \ No newline at end of file diff --git a/fortran90-rules/src/test/resources/COM/MET/ComplexitySimplified/error.f b/fortran90-rules/src/test/resources/COM/MET/ComplexitySimplified/error.f new file mode 100644 index 00000000..0702a249 --- /dev/null +++ b/fortran90-rules/src/test/resources/COM/MET/ComplexitySimplified/error.f @@ -0,0 +1,52 @@ + SUBROUTINE CALBED + + IF (BARYC .NE. 10) THEN + IF (BARYC .NE. 12) THEN + IF (BARYC .NE. 12) THEN + IF (BARYC .NE. 12) THEN + IF (BARYC .NE. 12) THEN + IF (BARYC .NE. 12) THEN + IF (BARYC .NE. 12) THEN + IF (BARYC .NE. 12) THEN + IF (BARYC .NE. 12) THEN + IF (BARYC .NE. 12) THEN + IF (BARYC .NE. 12) THEN + IF (BARYC .NE. 12) THEN + IF (BARYC .NE. 12) THEN + IF (BARYC .NE. 12) THEN + IF (BARYC .NE. 12) THEN + IF (BARYC .NE. 12) THEN + IF (BARYC .NE. 12) THEN + IF (BARYC .NE. 12) THEN + IF (BARYC .NE. 12) THEN + IF (BARYC .NE. 12) THEN + IF (BARYC .NE. 12) THEN + + + K=1 + + + END IF + END IF + END IF + END IF + END IF + END IF + END IF + END IF + END IF + END DO + END IF + END IF + END IF + END IF + END IF + END IF + END IF + END IF + END IF + END IF + END IF + + + END SUBROUTINE diff --git a/fortran90-rules/src/test/resources/COM/MET/ComplexitySimplified/noError.f b/fortran90-rules/src/test/resources/COM/MET/ComplexitySimplified/noError.f new file mode 100644 index 00000000..d99e244c --- /dev/null +++ b/fortran90-rules/src/test/resources/COM/MET/ComplexitySimplified/noError.f @@ -0,0 +1,13 @@ + SUBROUTINE C3BODY(GD, RCD, CDUV, RXD, XDUV, ACC, ACCUV) + + IF (BARYC .NE. 10) THEN + +C Check that BARYC as index does not exceed PEQUR array + IF (BARYC .NE. 12) THEN + RADIUS = PEQUR(BARYC) + ELSE + RADIUS = CSM_RADIUS + END IF + END IF + + END SUBROUTINE \ No newline at end of file diff --git a/fortran90-rules/src/test/resources/COM/MET/LineOfCode/error.f90 b/fortran90-rules/src/test/resources/COM/MET/LineOfCode/error.f90 new file mode 100644 index 00000000..ca8968c4 --- /dev/null +++ b/fortran90-rules/src/test/resources/COM/MET/LineOfCode/error.f90 @@ -0,0 +1,170 @@ +PROCEDURE ESSAI + IMPLICIT NONE + REAL :: Tc + REAL :: Tf + REAL :: C_To_F + REAL :: F_To_C + WRITE(*, '(3X,"Temperature en Celsius:")') + READ(*,*) Tc + WRITE(*, '(3X,"->Conversion en Fahrenheit:",F8.3)') C_To_F(Tc) + WRITE(*, '(" ")') + WRITE(*, '(3X,"Temperature en Fahrenheit:")') + READ(*,*) Tf + WRITE(*, '(3X,"->Conversion en Celsius:",F8.3)') F_To_C(Tf) + IMPLICIT NONE + REAL :: Tc + REAL :: Tf + REAL :: C_To_F + REAL :: F_To_C + WRITE(*, '(3X,"Temperature en Celsius:")') + READ(*,*) Tc + WRITE(*, '(3X,"->Conversion en Fahrenheit:",F8.3)') C_To_F(Tc) + WRITE(*, '(" ")') + WRITE(*, '(3X,"Temperature en Fahrenheit:")') + READ(*,*) Tf + WRITE(*, '(3X,"->Conversion en Celsius:",F8.3)') F_To_C(Tf) + IMPLICIT NONE + REAL :: Tc + REAL :: Tf + REAL :: C_To_F + REAL :: F_To_C + WRITE(*, '(3X,"Temperature en Celsius:")') + READ(*,*) Tc + WRITE(*, '(3X,"->Conversion en Fahrenheit:",F8.3)') C_To_F(Tc) + WRITE(*, '(" ")') + WRITE(*, '(3X,"Temperature en Fahrenheit:")') + READ(*,*) Tf + WRITE(*, '(3X,"->Conversion en Celsius:",F8.3)') F_To_C(Tf) + IMPLICIT NONE + REAL :: Tc + REAL :: Tf + REAL :: C_To_F + REAL :: F_To_C + WRITE(*, '(3X,"Temperature en Celsius:")') + READ(*,*) Tc + WRITE(*, '(3X,"->Conversion en Fahrenheit:",F8.3)') C_To_F(Tc) + WRITE(*, '(" ")') + WRITE(*, '(3X,"Temperature en Fahrenheit:")') + READ(*,*) Tf + WRITE(*, '(3X,"->Conversion en Celsius:",F8.3)') F_To_C(Tf) + IMPLICIT NONE + REAL :: Tc + REAL :: Tf + REAL :: C_To_F + REAL :: F_To_C + WRITE(*, '(3X,"Temperature en Celsius:")') + READ(*,*) Tc + WRITE(*, '(3X,"->Conversion en Fahrenheit:",F8.3)') C_To_F(Tc) + WRITE(*, '(" ")') + WRITE(*, '(3X,"Temperature en Fahrenheit:")') + READ(*,*) Tf + WRITE(*, '(3X,"->Conversion en Celsius:",F8.3)') F_To_C(Tf) + IMPLICIT NONE + REAL :: Tc + REAL :: Tf + REAL :: C_To_F + REAL :: F_To_C + WRITE(*, '(3X,"Temperature en Celsius:")') + READ(*,*) Tc + WRITE(*, '(3X,"->Conversion en Fahrenheit:",F8.3)') C_To_F(Tc) + WRITE(*, '(" ")') + WRITE(*, '(3X,"Temperature en Fahrenheit:")') + READ(*,*) Tf + WRITE(*, '(3X,"->Conversion en Celsius:",F8.3)') F_To_C(Tf) + IMPLICIT NONE + REAL :: Tc + REAL :: Tf + REAL :: C_To_F + REAL :: F_To_C + WRITE(*, '(3X,"Temperature en Celsius:")') + READ(*,*) Tc + WRITE(*, '(3X,"->Conversion en Fahrenheit:",F8.3)') C_To_F(Tc) + WRITE(*, '(" ")') + WRITE(*, '(3X,"Temperature en Fahrenheit:")') + READ(*,*) Tf + WRITE(*, '(3X,"->Conversion en Celsius:",F8.3)') F_To_C(Tf) + IMPLICIT NONE + REAL :: Tc + REAL :: Tf + REAL :: C_To_F + REAL :: F_To_C + WRITE(*, '(3X,"Temperature en Celsius:")') + READ(*,*) Tc + WRITE(*, '(3X,"->Conversion en Fahrenheit:",F8.3)') C_To_F(Tc) + WRITE(*, '(" ")') + WRITE(*, '(3X,"Temperature en Fahrenheit:")') + READ(*,*) Tf + WRITE(*, '(3X,"->Conversion en Celsius:",F8.3)') F_To_C(Tf) + IMPLICIT NONE + REAL :: Tc + REAL :: Tf + REAL :: C_To_F + REAL :: F_To_C + WRITE(*, '(3X,"Temperature en Celsius:")') + READ(*,*) Tc + WRITE(*, '(3X,"->Conversion en Fahrenheit:",F8.3)') C_To_F(Tc) + WRITE(*, '(" ")') + WRITE(*, '(3X,"Temperature en Fahrenheit:")') + READ(*,*) Tf + WRITE(*, '(3X,"->Conversion en Celsius:",F8.3)') F_To_C(Tf) + IMPLICIT NONE + REAL :: Tc + REAL :: Tf + REAL :: C_To_F + REAL :: F_To_C + WRITE(*, '(3X,"Temperature en Celsius:")') + READ(*,*) Tc + WRITE(*, '(3X,"->Conversion en Fahrenheit:",F8.3)') C_To_F(Tc) + WRITE(*, '(" ")') + WRITE(*, '(3X,"Temperature en Fahrenheit:")') + READ(*,*) Tf + WRITE(*, '(3X,"->Conversion en Celsius:",F8.3)') F_To_C(Tf) + IMPLICIT NONE + REAL :: Tc + REAL :: Tf + REAL :: C_To_F + REAL :: F_To_C + WRITE(*, '(3X,"Temperature en Celsius:")') + READ(*,*) Tc + WRITE(*, '(3X,"->Conversion en Fahrenheit:",F8.3)') C_To_F(Tc) + WRITE(*, '(" ")') + WRITE(*, '(3X,"Temperature en Fahrenheit:")') + READ(*,*) Tf + WRITE(*, '(3X,"->Conversion en Celsius:",F8.3)') F_To_C(Tf) + IMPLICIT NONE + REAL :: Tc + REAL :: Tf + REAL :: C_To_F + REAL :: F_To_C + WRITE(*, '(3X,"Temperature en Celsius:")') + READ(*,*) Tc + WRITE(*, '(3X,"->Conversion en Fahrenheit:",F8.3)') C_To_F(Tc) + WRITE(*, '(" ")') + WRITE(*, '(3X,"Temperature en Fahrenheit:")') + READ(*,*) Tf + WRITE(*, '(3X,"->Conversion en Celsius:",F8.3)') F_To_C(Tf) + IMPLICIT NONE + REAL :: Tc + REAL :: Tf + REAL :: C_To_F + REAL :: F_To_C + WRITE(*, '(3X,"Temperature en Celsius:")') + READ(*,*) Tc + WRITE(*, '(3X,"->Conversion en Fahrenheit:",F8.3)') C_To_F(Tc) + WRITE(*, '(" ")') + WRITE(*, '(3X,"Temperature en Fahrenheit:")') + READ(*,*) Tf + WRITE(*, '(3X,"->Conversion en Celsius:",F8.3)') F_To_C(Tf) + IMPLICIT NONE + REAL :: Tc + REAL :: Tf + REAL :: C_To_F + REAL :: F_To_C + WRITE(*, '(3X,"Temperature en Celsius:")') + READ(*,*) Tc + WRITE(*, '(3X,"->Conversion en Fahrenheit:",F8.3)') C_To_F(Tc) + WRITE(*, '(" ")') + WRITE(*, '(3X,"Temperature en Fahrenheit:")') + READ(*,*) Tf + WRITE(*, '(3X,"->Conversion en Celsius:",F8.3)') F_To_C(Tf) +END PROCEDURE \ No newline at end of file diff --git a/fortran90-rules/src/test/resources/COM/MET/LineOfCode/noError.f90 b/fortran90-rules/src/test/resources/COM/MET/LineOfCode/noError.f90 new file mode 100644 index 00000000..54895e8e --- /dev/null +++ b/fortran90-rules/src/test/resources/COM/MET/LineOfCode/noError.f90 @@ -0,0 +1,19 @@ +PROCEDURE ESSAI + + IMPLICIT NONE + + REAL :: Tc + REAL :: Tf + REAL :: C_To_F + REAL :: F_To_C + + WRITE(*, '(3X,"Temperature en Celsius:")') + READ(*,*) Tc + WRITE(*, '(3X,"->Conversion en Fahrenheit:",F8.3)') C_To_F(Tc) + + WRITE(*, '(" ")') + WRITE(*, '(3X,"Temperature en Fahrenheit:")') + READ(*,*) Tf + WRITE(*, '(3X,"->Conversion en Celsius:",F8.3)') F_To_C(Tf) + +END PROCEDURE \ No newline at end of file diff --git a/fortran90-rules/src/test/resources/COM/MET/RatioComment/error.f b/fortran90-rules/src/test/resources/COM/MET/RatioComment/error.f new file mode 100644 index 00000000..fb5dde26 --- /dev/null +++ b/fortran90-rules/src/test/resources/COM/MET/RatioComment/error.f @@ -0,0 +1,15 @@ + SUBROUTINE CEARSAT +! Calculates the velocity in equatorial system if satellite orbits around Earth + IF (BARYC .EQ. 3) THEN + VECT(1) = CBXVELX + VECT(2) = CBXVELY + VECT(3) = CBXVELZ + CALL CSYSCHANGE(VECT, VECT1, 1) + CVELX = VECT1(1) + CVELY = VECT1(2) + CVELZ = VECT1(3) + CALL SVUNIT(VECT1, CVELUV, CVELR) + END IF + RETURN + + END \ No newline at end of file diff --git a/fortran90-rules/src/test/resources/COM/MET/RatioComment/noError.f b/fortran90-rules/src/test/resources/COM/MET/RatioComment/noError.f new file mode 100644 index 00000000..52abc97c --- /dev/null +++ b/fortran90-rules/src/test/resources/COM/MET/RatioComment/noError.f @@ -0,0 +1,72 @@ +C----------------------------------------------------------------------- +C +C Title : CEARSAT +C +C Function : Give the Earth-sat position in the Earth Equatorial CS +C +C Author : Christelle Crozat +C +C Date : 27/OCT/1998 +C +C Update record : +C +! Date Name Sar No. Change made +!----------------------------------------------------------------------- +! 12/04/00 M.Rodenhuis --- Made CPOS calculation more precise +! xx-Nov-07 S.Kranz PEM V4.0 Merged PEM V3.0.2 with PEM KT +!----------------------------------------------------------------------- +! + SUBROUTINE CEARSAT +!----------------------------------------------------------------------- + IMPLICIT REAL*8(A-H,O-Z) +!----------------------------------------------------------------------- +! COMMON DATA + INCLUDE 'SM_PEM_COMMON.LC' ! Position/Environment data +! Calculates common block data: +! CPOSX, CPOSY, CPOSZ, CPOSR, CPOSUV +! CVELX, CVELY, CVELZ, CVELR, CVELUV +!----------------------------------------------------------------------- +! LOCAL DATA + REAL*8 VECT(3) + REAL*8 VECT1(3) +!----------------------------------------------------------------------- +C BEGIN +! MR: Changed the way CPOS is calculated. If the orbit is around the Earth, +! it is more precise to calculate CPOS directly from CBXUV: + IF (BARYC .EQ. 3) THEN + VECT(1) = CBXDIST*CBXUV(1) + VECT(2) = CBXDIST*CBXUV(2) + VECT(3) = CBXDIST*CBXUV(3) + ELSE + DO J=1,3 + VECT(J) = -(SUN_PLANET(J,3) + SAT_SUN(J)) + END DO + END IF +!----------------------------------------------------------------------- +! Give the vector from the ecliptic frame to the equatorial frame + CALL CSYSCHANGE(VECT, VECT1, 1) +!----------------------------------------------------------------------- + CPOSX = VECT1(1) + CPOSY = VECT1(2) + CPOSZ = VECT1(3) +!----------------------------------------------------------------------- +! Give the unit vector in the Earth Equatorial frame of Earth-Sat vector + CALL SVUNIT(VECT1, CPOSUV, CPOSR) +!----------------------------------------------------------------------- +! Calculates the velocity in equatorial system if satellite orbits around Earth + IF (BARYC .EQ. 3) THEN + VECT(1) = CBXVELX + VECT(2) = CBXVELY + VECT(3) = CBXVELZ +!----------------------------------------------------------------------- + CALL CSYSCHANGE(VECT, VECT1, 1) + CVELX = VECT1(1) + CVELY = VECT1(2) + CVELZ = VECT1(3) +!----------------------------------------------------------------------- + CALL SVUNIT(VECT1, CVELUV, CVELR) + END IF +!----------------------------------------------------------------------- + RETURN +!----------------------------------------------------------------------- + END \ No newline at end of file diff --git a/fortran90-rules/src/test/resources/COM/PRES/Data/error.f90 b/fortran90-rules/src/test/resources/COM/PRES/Data/error.f90 new file mode 100644 index 00000000..d762966d --- /dev/null +++ b/fortran90-rules/src/test/resources/COM/PRES/Data/error.f90 @@ -0,0 +1,5 @@ +MODULE ma_precision + + DOUBLE PRECISION, DIMENSION(3,3) :: daMatTr + +END MODULE ma_precision diff --git a/fortran90-rules/src/test/resources/COM/PRES/Data/noError.f90 b/fortran90-rules/src/test/resources/COM/PRES/Data/noError.f90 new file mode 100644 index 00000000..17192c61 --- /dev/null +++ b/fortran90-rules/src/test/resources/COM/PRES/Data/noError.f90 @@ -0,0 +1,6 @@ +MODULE ma_precision + + ! Matrix tranformation from Rs to SunSensor + DOUBLE PRECISION, DIMENSION(3,3) :: daMatTr + +END MODULE ma_precision diff --git a/fortran90-rules/src/test/resources/COM/PRES/FileLength/error.f b/fortran90-rules/src/test/resources/COM/PRES/FileLength/error.f new file mode 100644 index 00000000..2a93b8b2 --- /dev/null +++ b/fortran90-rules/src/test/resources/COM/PRES/FileLength/error.f @@ -0,0 +1,1502 @@ +! $Id: $ +module ncdf +!****m* Interface/Modules +! +! SYNOPSIS +! use ncdf +! +! DESCRIPTION +! Access to the routines in the ncdf library is provided by various +! Fortran 90 modules. +! +! SEE ALSO +! ncdf +! +! AUTHOR +! C. Marquardt, Darmstadt, Germany +! +! COPYRIGHT +! +! Copyright (c) 2005 Christian Marquardt +! +! All rights reserved. +! +! Permission is hereby granted, free of charge, to any person obtaining +! a copy of this software and associated documentation files (the +! "Software"), to deal in the Software without restriction, including +! without limitation the rights to use, copy, modify, merge, publish, +! distribute, sublicense, and/or sell copies of the Software, and to +! permit persons to whom the Software is furnished to do so, subject to +! the following conditions: +! +! The above copyright notice and this permission notice shall be +! included in all copies or substantial portions of the Software as well +! as in supporting documentation. +! +! THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +! EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +! MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +! NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +! LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +! OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +! WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +! +!**** +!****m* Modules/ncdf +! +! NAME +! ncdf - A simple interface to read and write netCDF data. +! +! SYNOPSIS +! use ncdf +! +! DESCRIPTION +! This module provides a simple interface to the netCDF library and +! allows for easy creation, writing and reading of netCDF data files. +! +! NOTES +! For reading data from netCDF files, the ncdf_open, read_variable +! and ncdf_close routines should be sufficient. For writing netCDF +! data files, it is probably neecessary to write a 'ncf_create_mystuff' +! subroutine that handles the creation of the netCDF file using both +! ncdf and native netCDF calls; ncdf currently only provides little +! for this task. +! +! EXAMPLE +! Assume that you have written a subroutine ncdf_create_alpha which +! creates a netCDF data file for a scalar 'R_curve' and array variables +! namd 'lon', 'lat' and 'alpha_o' (along with several others). From a +! Fortran 90 program, ncdf routines might then be called as follows: +! +! use ncdf +! ... +! integer, parameter :: n_levels = +! ... +! real(dp) :: alpha(n_levels), impact(n_levels) +! ... +! call ncdf_create_alpha('test.nc', n_levels) +! call ncdf_putvar('alpha_b', alpha) +! call ncdf_putvar('impact', impact) +! ... +! call ncdf_close() +! +! To read these variables from another Fortran 90 program, try this: +! +! use ncdf +! ... +! integer, parameter :: n_levels = +! ... +! real(dp) :: alpha(n_levels), impact(n_levels) +! ... +! call ncdf_open('test.nc') +! call ncdf_getvar('alpha_b', alpha) +! call ncdf_getvar('impact', impact) +! ... +! call ncdf_close() +! +! SEE ALSO +! High level routines: +! +! ncdf_open - Open an (already existing) netCDF data file. +! ncdf_close - Close a netCDF data file. +! ncdf_putvar - Write data into an (already defined) variable of +! the current netCDF data file.. +! ncdf_getvar - Read data from a variable in the current netCDF +! data file. +! +! Low level routines (mainly used for the creation of new netCDF data files) +! +! ncdf_create - Create a new netCDF data file. +! ncdf_defvar - Create a new variable in a netCDF data file. +! +! AUTHOR +! C. Marquardt, Darmstadt, Germany +! +!**** +!------------------------------------------------------------------------------ +! 1. Global variables +!------------------------------------------------------------------------------ +!****iv* netCDF/ncdf_ncname +! +! NAME +! ncdf_ncname - Name of the current netCDF data file. +! +! SYNOPSIS +! use ncdf +! +! DESCRIPTION +! The name (including the path) of the current netCDF data file; it is +! known to all ncdf routines. +! +! AUTHOR +! C. Marquardt, Darmstadt, Germany +! +!**** +!****iv* netCDF/ncdf_ncid +! +! NAME +! ncdf_ncid - NetCDF id of the current netCDF data file. +! +! SYNOPSIS +! use ncdf +! +! DESCRIPTION +! The netCDF id of the current opened netCDF data file; it is known to all +! ncdf routines. +! +! AUTHOR +! C. Marquardt, Darmstadt, Germany +! +!**** + use typeSizes + use netcdf + character(len = 1024), save, public :: ncdf_ncname = '' + integer, save, public :: ncdf_ncid = -1 + integer, save, public :: ncdf_nvars = 0 + logical, dimension(:), pointer, save, public :: ncdf_read => null() + logical, save, public :: ncdf_delete_on_error = .false. +!------------------------------------------------------------------------------ +! 2. Interfaces - Files +!------------------------------------------------------------------------------ +!****m* netCDF/Files +! +! DESCRIPTION +! Routines for handling netCDF data files. +! +! SEE ALSO +! is_netcdf +! ncdf_create +! ncdf_open +! ncdf_close +! ncdf_sync +! +! AUTHOR +! C. Marquardt, Darmstadt, Germany +! +!**** + interface is_netcdf + function is_netcdf(file) result(it_is) + character(len = *), intent(in) :: file + logical :: it_is + end function is_netcdf + end interface + interface ncdf_create + subroutine ncdf_create(ncfile, cmode, ncid) + character (len = *), intent(in) :: ncfile + integer, optional :: cmode + integer, optional :: ncid + end subroutine ncdf_create + end interface + interface ncdf_open + subroutine ncdf_open(ncfile, ncid, mode, append) + character (len = *), intent(in) :: ncfile + integer, optional :: ncid + integer, optional :: mode + logical, optional :: append + end subroutine ncdf_open + end interface + interface ncdf_close + subroutine ncdf_close(ncfile, ncid) + character (len = *), optional :: ncfile + integer, optional :: ncid + end subroutine ncdf_close + end interface + interface ncdf_sync + subroutine ncdf_sync(ncfile, ncid) + character (len = *), optional :: ncfile + integer, optional :: ncid + end subroutine ncdf_sync + end interface +!------------------------------------------------------------------------------ +! 3. Interfaces - Query +!------------------------------------------------------------------------------ +!****m* netCDF/Query +! +! DESCRIPTION +! Routines for obtaining information about the contents of a netCDF data +! file. +! +! SEE ALSO +! ncdf_getshape +! ncdf_getsize +! ncdf_getnrec +! +! AUTHOR +! C. Marquardt, Darmstadt, Germany +! +!**** + interface ncdf_getshape + subroutine ncdf_getshape(name, shape, ncfile, ncid) + character(len = *), intent(in) :: name + integer, intent(out) :: shape + character(len = *), optional :: ncfile + integer, optional :: ncid + end subroutine ncdf_getshape + end interface + interface ncdf_getsize + subroutine ncdf_sgetsize(name, size, dim, ncfile, ncid) + character(len = *), intent(in) :: name + integer, intent(out) :: size + integer, optional :: dim + character(len = *), optional :: ncfile + integer, optional :: ncid + end subroutine ncdf_sgetsize + subroutine ncdf_agetsize(name, size, ncfile, ncid) + character(len = *), intent(in) :: name + integer, dimension(:), intent(out) :: size + character(len = *), optional :: ncfile + integer, optional :: ncid + end subroutine ncdf_agetsize + end interface + interface ncdf_getnrec + function ncdf_getnrec(ncfile, ncid) result(n_unlimited) + character(len = *), optional :: ncfile + integer, optional :: ncid + integer :: n_unlimited + end function ncdf_getnrec + end interface +!------------------------------------------------------------------------------ +! 4. Interfaces - attributes +!------------------------------------------------------------------------------ +!****m* netCDF/Attributes +! +! DESCRIPTION +! Routines to deal with attributes, both global and variable specific, in +! a netCDF data file. +! +! SEE ALSO +! +! AUTHOR +! C. Marquardt, Darmstadt, Germany +! +!**** + interface ncdf_isatt + function ncdf_isatt(attname, varname, ncfile, ncid, xtype, len, attnum) result(it_is) + character (len = *), intent(in) :: attname + character (len = *), intent(in), optional :: varname + character (len = *), intent(in), optional :: ncfile + integer, intent(in), optional :: ncid + integer, intent(out), optional :: xtype, len, attnum + logical :: it_is + end function ncdf_isatt + end interface + interface ncdf_putatt + subroutine ncdf_putatt_OneByteInt (attname, value, varname, ncfile, ncid) + use typeSizes + character(len = *), intent(in ) :: attname + integer(kind = OneByteInt), & + intent(in ) :: value + character(len = *), optional :: varname + character(len = *), optional :: ncfile + integer, optional :: ncid + end subroutine ncdf_putatt_OneByteInt + subroutine ncdf_putatt_TwoByteInt (attname, value, varname, ncfile, ncid) + use typeSizes + character(len = *), intent(in ) :: attname + integer(kind = TwoByteInt), & + intent(in ) :: value + character(len = *), optional :: varname + character(len = *), optional :: ncfile + integer, optional :: ncid + end subroutine ncdf_putatt_TwoByteInt + subroutine ncdf_putatt_FourByteInt (attname, value, varname, ncfile, ncid) + use typeSizes + character(len = *), intent(in ) :: attname + integer(kind = FourByteInt), & + intent(in ) :: value + character(len = *), optional :: varname + character(len = *), optional :: ncfile + integer, optional :: ncid + end subroutine ncdf_putatt_FourByteInt + subroutine ncdf_putatt_EightByteInt (attname, value, varname, ncfile, ncid) + use typeSizes + character(len = *), intent(in ) :: attname + integer(kind = EightByteInt), & + intent(in ) :: value + character(len = *), optional :: varname + character(len = *), optional :: ncfile + integer, optional :: ncid + end subroutine ncdf_putatt_EightByteInt + subroutine ncdf_putatt_FourByteReal (attname, value, varname, ncfile, ncid) + use typeSizes + character(len = *), intent(in ) :: attname + real(kind = FourByteReal), & + intent(in ) :: value + character(len = *), optional :: varname + character(len = *), optional :: ncfile + integer, optional :: ncid + end subroutine ncdf_putatt_FourByteReal + subroutine ncdf_putatt_EightByteReal (attname, value, varname, ncfile, ncid) + use typeSizes + character(len = *), intent(in ) :: attname + real(kind = EightByteReal), & + intent(in ) :: value + character(len = *), optional :: varname + character(len = *), optional :: ncfile + integer, optional :: ncid + end subroutine ncdf_putatt_EightByteReal + subroutine ncdf_putatt_text (attname, value, varname, ncfile, ncid) + use typeSizes + character(len = *), intent(in ) :: attname + character (len = *), & + intent(in ) :: value + character(len = *), optional :: varname + character(len = *), optional :: ncfile + integer, optional :: ncid + end subroutine ncdf_putatt_text + subroutine ncdf_putatt_1D_OneByteInt (attname, values, varname, ncfile, ncid) + use typeSizes + character(len = *), intent(in) :: attname + integer(kind = OneByteInt), dimension(:), & + intent(in ) :: values + character(len = *), optional :: varname + character(len = *), optional :: ncfile + integer, optional :: ncid + end subroutine ncdf_putatt_1D_OneByteInt + subroutine ncdf_putatt_1D_TwoByteInt (attname, values, varname, ncfile, ncid) + use typeSizes + character(len = *), intent(in) :: attname + integer(kind = TwoByteInt), dimension(:), & + intent(in ) :: values + character(len = *), optional :: varname + character(len = *), optional :: ncfile + integer, optional :: ncid + end subroutine ncdf_putatt_1D_TwoByteInt + subroutine ncdf_putatt_1D_FourByteInt (attname, values, varname, ncfile, ncid) + use typeSizes + character(len = *), intent(in) :: attname + integer(kind = FourByteInt), dimension(:), & + intent(in ) :: values + character(len = *), optional :: varname + character(len = *), optional :: ncfile + integer, optional :: ncid + end subroutine ncdf_putatt_1D_FourByteInt + subroutine ncdf_putatt_1D_EightByteInt (attname, values, varname, ncfile, ncid) + use typeSizes + character(len = *), intent(in) :: attname + integer(kind = EightByteInt), dimension(:), & + intent(in ) :: values + character(len = *), optional :: varname + character(len = *), optional :: ncfile + integer, optional :: ncid + end subroutine ncdf_putatt_1D_EightByteInt + subroutine ncdf_putatt_1D_FourByteReal (attname, values, varname, ncfile, ncid) + use typeSizes + character(len = *), intent(in) :: attname + real(kind = FourByteReal), dimension(:), & + intent(in ) :: values + character(len = *), optional :: varname + character(len = *), optional :: ncfile + integer, optional :: ncid + end subroutine ncdf_putatt_1D_FourByteReal + subroutine ncdf_putatt_1D_EightByteReal (attname, values, varname, ncfile, ncid) + use typeSizes + character(len = *), intent(in) :: attname + real(kind = EightByteReal), dimension(:), & + intent(in ) :: values + character(len = *), optional :: varname + character(len = *), optional :: ncfile + integer, optional :: ncid + end subroutine ncdf_putatt_1D_EightByteReal + end interface + interface ncdf_getatt + subroutine ncdf_getatt_OneByteInt (attname, value, varname, ncfile, ncid) + use typeSizes + character(len = *), intent(in ) :: attname + integer(kind = OneByteInt), & + intent(out) :: value + character(len = *), optional :: varname + character(len = *), optional :: ncfile + integer, optional :: ncid + end subroutine ncdf_getatt_OneByteInt + subroutine ncdf_getatt_TwoByteInt (attname, value, varname, ncfile, ncid) + use typeSizes + character(len = *), intent(in ) :: attname + integer(kind = TwoByteInt), & + intent(out) :: value + character(len = *), optional :: varname + character(len = *), optional :: ncfile + integer, optional :: ncid + end subroutine ncdf_getatt_TwoByteInt + subroutine ncdf_getatt_FourByteInt (attname, value, varname, ncfile, ncid) + use typeSizes + character(len = *), intent(in ) :: attname + integer(kind = FourByteInt), & + intent(out) :: value + character(len = *), optional :: varname + character(len = *), optional :: ncfile + integer, optional :: ncid + end subroutine ncdf_getatt_FourByteInt + subroutine ncdf_getatt_EightByteInt (attname, value, varname, ncfile, ncid) + use typeSizes + character(len = *), intent(in ) :: attname + integer(kind = EightByteInt), & + intent(out) :: value + character(len = *), optional :: varname + character(len = *), optional :: ncfile + integer, optional :: ncid + end subroutine ncdf_getatt_EightByteInt + subroutine ncdf_getatt_FourByteReal (attname, value, varname, ncfile, ncid) + use typeSizes + character(len = *), intent(in ) :: attname + real(kind = FourByteReal), & + intent(out) :: value + character(len = *), optional :: varname + character(len = *), optional :: ncfile + integer, optional :: ncid + end subroutine ncdf_getatt_FourByteReal + subroutine ncdf_getatt_EightByteReal (attname, value, varname, ncfile, ncid) + use typeSizes + character(len = *), intent(in ) :: attname + real(kind = EightByteReal), & + intent(out) :: value + character(len = *), optional :: varname + character(len = *), optional :: ncfile + integer, optional :: ncid + end subroutine ncdf_getatt_EightByteReal + subroutine ncdf_getatt_text (attname, value, varname, ncfile, ncid) + use typeSizes + character(len = *), intent(in ) :: attname + character (len = *), & + intent(out) :: value + character(len = *), optional :: varname + character(len = *), optional :: ncfile + integer, optional :: ncid + end subroutine ncdf_getatt_text + subroutine ncdf_getatt_1D_OneByteInt (attname, values, varname, ncfile, ncid) + use typeSizes + character(len = *), intent(in) :: attname + integer(kind = OneByteInt), dimension(:), & + intent(out) :: values + character(len = *), optional :: varname + character(len = *), optional :: ncfile + integer, optional :: ncid + end subroutine ncdf_getatt_1D_OneByteInt + subroutine ncdf_getatt_1D_TwoByteInt (attname, values, varname, ncfile, ncid) + use typeSizes + character(len = *), intent(in) :: attname + integer(kind = TwoByteInt), dimension(:), & + intent(out) :: values + character(len = *), optional :: varname + character(len = *), optional :: ncfile + integer, optional :: ncid + end subroutine ncdf_getatt_1D_TwoByteInt + subroutine ncdf_getatt_1D_FourByteInt (attname, values, varname, ncfile, ncid) + use typeSizes + character(len = *), intent(in) :: attname + integer(kind = FourByteInt), dimension(:), & + intent(out) :: values + character(len = *), optional :: varname + character(len = *), optional :: ncfile + integer, optional :: ncid + end subroutine ncdf_getatt_1D_FourByteInt + subroutine ncdf_getatt_1D_EightByteInt (attname, values, varname, ncfile, ncid) + use typeSizes + character(len = *), intent(in) :: attname + integer(kind = EightByteInt), dimension(:), & + intent(out) :: values + character(len = *), optional :: varname + character(len = *), optional :: ncfile + integer, optional :: ncid + end subroutine ncdf_getatt_1D_EightByteInt + subroutine ncdf_getatt_1D_FourByteReal (attname, values, varname, ncfile, ncid) + use typeSizes + character(len = *), intent(in) :: attname + real(kind = FourByteReal), dimension(:), & + intent(out) :: values + character(len = *), optional :: varname + character(len = *), optional :: ncfile + integer, optional :: ncid + end subroutine ncdf_getatt_1D_FourByteReal + subroutine ncdf_getatt_1D_EightByteReal (attname, values, varname, ncfile, ncid) + use typeSizes + character(len = *), intent(in) :: attname + real(kind = EightByteReal), dimension(:), & + intent(out) :: values + character(len = *), optional :: varname + character(len = *), optional :: ncfile + integer, optional :: ncid + end subroutine ncdf_getatt_1D_EightByteReal + end interface + interface ncdf_getatt_alloc + subroutine ncdf_getatl_1D_OneByteInt (attname, values, varname, ncfile, ncid) + use typeSizes + character(len = *), intent(in) :: attname + integer(kind = OneByteInt), dimension(:), & + pointer :: values + character(len = *), optional :: varname + character(len = *), optional :: ncfile + integer, optional :: ncid + end subroutine ncdf_getatl_1D_OneByteInt + subroutine ncdf_getatl_1D_TwoByteInt (attname, values, varname, ncfile, ncid) + use typeSizes + character(len = *), intent(in) :: attname + integer(kind = TwoByteInt), dimension(:), & + pointer :: values + character(len = *), optional :: varname + character(len = *), optional :: ncfile + integer, optional :: ncid + end subroutine ncdf_getatl_1D_TwoByteInt + subroutine ncdf_getatl_1D_FourByteInt (attname, values, varname, ncfile, ncid) + use typeSizes + character(len = *), intent(in) :: attname + integer(kind = FourByteInt), dimension(:), & + pointer :: values + character(len = *), optional :: varname + character(len = *), optional :: ncfile + integer, optional :: ncid + end subroutine ncdf_getatl_1D_FourByteInt + subroutine ncdf_getatl_1D_EightByteInt (attname, values, varname, ncfile, ncid) + use typeSizes + character(len = *), intent(in) :: attname + integer(kind = EightByteInt), dimension(:), & + pointer :: values + character(len = *), optional :: varname + character(len = *), optional :: ncfile + integer, optional :: ncid + end subroutine ncdf_getatl_1D_EightByteInt + subroutine ncdf_getatl_1D_FourByteReal (attname, values, varname, ncfile, ncid) + use typeSizes + character(len = *), intent(in) :: attname + real(kind = FourByteReal), dimension(:), & + pointer :: values + character(len = *), optional :: varname + character(len = *), optional :: ncfile + integer, optional :: ncid + end subroutine ncdf_getatl_1D_FourByteReal + subroutine ncdf_getatl_1D_EightByteReal (attname, values, varname, ncfile, ncid) + use typeSizes + character(len = *), intent(in) :: attname + real(kind = EightByteReal), dimension(:), & + pointer :: values + character(len = *), optional :: varname + character(len = *), optional :: ncfile + integer, optional :: ncid + end subroutine ncdf_getatl_1D_EightByteReal + end interface +!------------------------------------------------------------------------------ +! 5. Interfaces - dimensions +!------------------------------------------------------------------------------ +!****m* netCDF/Dimensions +! +! DESCRIPTION +! Routines to deal with dimensions within a netCDF data file, including +! defining them. +! +! SEE ALSO +! ncdf_defdim +! +! AUTHOR +! C. Marquardt, Darmstadt, Germany +! +!**** + interface ncdf_defdim + function ncdf_defdim(name, n, ncid) result(dimid) + character(len = *), intent(in) :: name + integer, intent(in) :: n + integer, optional :: ncid + integer :: dimid + end function ncdf_defdim + end interface +!------------------------------------------------------------------------------ +! 6. Interfaces - variables +!------------------------------------------------------------------------------ +!****m* netCDF/Variables +! +! DESCRIPTION +! Routines to deal with variables within a netCDF data file, including +! defining, writing and reading them. +! +! SEE ALSO +! ncdf_isvar +! ncdf_renvar +! ncdf_defvar +! +! AUTHOR +! C. Marquardt, Darmstadt, Germany +! +!**** + interface ncdf_isvar + function ncdf_isvar(name, ncfile, ncid) result(it_is) + character(len = *), intent(in) :: name + character(len = *), optional :: ncfile + integer, optional :: ncid + logical :: it_is + end function ncdf_isvar + end interface + interface ncdf_renvar + subroutine ncdf_renvar(old_name, new_name, ncfile, ncid) + character(len = *), intent(in) :: old_name + character(len = *), intent(in) :: new_name + character(len = *), optional :: ncfile + integer, optional :: ncid + end subroutine ncdf_renvar + end interface + interface ncdf_defvar + function ncdf_defvar_sca(name, long_name, units, type, ncid, & + standard_name, positive, formula_terms, & + calendar, coordinates) & + result(varid) + character(len = *), intent(in) :: name, long_name, units + integer, optional :: type + integer, optional :: ncid + character(len = *), optional :: standard_name + character(len = *), optional :: positive + character(len = *), optional :: formula_terms + character(len = *), optional :: calendar + character(len = *), optional :: coordinates + integer :: varid + end function ncdf_defvar_sca + function ncdf_defvar_arr(name, long_name, units, dimids, type, ncid, & + standard_name, positive, formula_terms, & + calendar, coordinates) & + result(varid) + character(len = *), intent(in) :: name, long_name, units + integer, dimension(:), intent(in) :: dimids + integer, optional :: type + integer, optional :: ncid + character(len = *), optional :: standard_name + character(len = *), optional :: positive + character(len = *), optional :: formula_terms + character(len = *), optional :: calendar + character(len = *), optional :: coordinates + integer :: varid + end function ncdf_defvar_arr + end interface + interface ncdf_putvar + subroutine ncdf_putvar_OneByteInt (name, values, ncfile, ncid, rec, start, units, range) + use typeSizes + character(len = *), intent( in) :: name + integer(kind = OneByteInt), & + intent(in ) :: values + integer(kind = OneByteInt), dimension(2), optional :: range + character(len = *), optional :: ncfile + integer, optional :: ncid + integer, optional :: rec + integer, dimension(:), optional :: start + character(len = *), optional :: units + end subroutine ncdf_putvar_OneByteInt + subroutine ncdf_putvar_TwoByteInt (name, values, ncfile, ncid, rec, start, units, range) + use typeSizes + character(len = *), intent( in) :: name + integer(kind = TwoByteInt), & + intent(in ) :: values + integer(kind = TwoByteInt), dimension(2), optional :: range + character(len = *), optional :: ncfile + integer, optional :: ncid + integer, optional :: rec + integer, dimension(:), optional :: start + character(len = *), optional :: units + end subroutine ncdf_putvar_TwoByteInt + subroutine ncdf_putvar_FourByteInt (name, values, ncfile, ncid, rec, start, units, range) + use typeSizes + character(len = *), intent( in) :: name + integer(kind = FourByteInt), & + intent(in ) :: values + integer(kind = FourByteInt), dimension(2), optional :: range + character(len = *), optional :: ncfile + integer, optional :: ncid + integer, optional :: rec + integer, dimension(:), optional :: start + character(len = *), optional :: units + end subroutine ncdf_putvar_FourByteInt + subroutine ncdf_putvar_EightByteInt (name, values, ncfile, ncid, rec, start, units, range) + use typeSizes + character(len = *), intent( in) :: name + integer(kind = EightByteInt), & + intent(in ) :: values + integer(kind = EightByteInt), dimension(2), optional :: range + character(len = *), optional :: ncfile + integer, optional :: ncid + integer, optional :: rec + integer, dimension(:), optional :: start + character(len = *), optional :: units + end subroutine ncdf_putvar_EightByteInt + subroutine ncdf_putvar_FourByteReal (name, values, ncfile, ncid, rec, start, units, range) + use typeSizes + character(len = *), intent( in) :: name + real(kind = FourByteReal), & + intent(in ) :: values + real(kind = FourByteReal), dimension(2), optional :: range + character(len = *), optional :: ncfile + integer, optional :: ncid + integer, optional :: rec + integer, dimension(:), optional :: start + character(len = *), optional :: units + end subroutine ncdf_putvar_FourByteReal + subroutine ncdf_putvar_EightByteReal (name, values, ncfile, ncid, rec, start, units, range) + use typeSizes + character(len = *), intent( in) :: name + real(kind = EightByteReal), & + intent(in ) :: values + real(kind = EightByteReal), dimension(2), optional :: range + character(len = *), optional :: ncfile + integer, optional :: ncid + integer, optional :: rec + integer, dimension(:), optional :: start + character(len = *), optional :: units + end subroutine ncdf_putvar_EightByteReal + subroutine ncdf_putvar_text (name, values, ncfile, ncid, rec, start, units, range) + use typeSizes + character(len = *), intent( in) :: name + character (len = *), & + intent(in ) :: values + character (len = *), dimension(2), optional :: range + character(len = *), optional :: ncfile + integer, optional :: ncid + integer, optional :: rec + integer, dimension(:), optional :: start + character(len = *), optional :: units + end subroutine ncdf_putvar_text + subroutine ncdf_putvar_1D_OneByteInt (name, values, ncfile, ncid, rec, start, count, units, range) + use typeSizes + character(len = *), intent(in) :: name + integer(kind = OneByteInt), dimension(:), & + intent(in ) :: values + integer(kind = OneByteInt), dimension(2), optional :: range + character(len = *), optional :: ncfile + integer, optional :: ncid + integer, optional :: rec + integer, dimension(:), optional :: start + integer, dimension(:), optional :: count + character(len = *), optional :: units + end subroutine ncdf_putvar_1D_OneByteInt + subroutine ncdf_putvar_1D_TwoByteInt (name, values, ncfile, ncid, rec, start, count, units, range) + use typeSizes + character(len = *), intent(in) :: name + integer(kind = TwoByteInt), dimension(:), & + intent(in ) :: values + integer(kind = TwoByteInt), dimension(2), optional :: range + character(len = *), optional :: ncfile + integer, optional :: ncid + integer, optional :: rec + integer, dimension(:), optional :: start + integer, dimension(:), optional :: count + character(len = *), optional :: units + end subroutine ncdf_putvar_1D_TwoByteInt + subroutine ncdf_putvar_1D_FourByteInt (name, values, ncfile, ncid, rec, start, count, units, range) + use typeSizes + character(len = *), intent(in) :: name + integer(kind = FourByteInt), dimension(:), & + intent(in ) :: values + integer(kind = FourByteInt), dimension(2), optional :: range + character(len = *), optional :: ncfile + integer, optional :: ncid + integer, optional :: rec + integer, dimension(:), optional :: start + integer, dimension(:), optional :: count + character(len = *), optional :: units + end subroutine ncdf_putvar_1D_FourByteInt + subroutine ncdf_putvar_1D_EightByteInt (name, values, ncfile, ncid, rec, start, count, units, range) + use typeSizes + character(len = *), intent(in) :: name + integer(kind = EightByteInt), dimension(:), & + intent(in ) :: values + integer(kind = EightByteInt), dimension(2), optional :: range + character(len = *), optional :: ncfile + integer, optional :: ncid + integer, optional :: rec + integer, dimension(:), optional :: start + integer, dimension(:), optional :: count + character(len = *), optional :: units + end subroutine ncdf_putvar_1D_EightByteInt + subroutine ncdf_putvar_1D_FourByteReal (name, values, ncfile, ncid, rec, start, count, units, range) + use typeSizes + character(len = *), intent(in) :: name + real(kind = FourByteReal), dimension(:), & + intent(in ) :: values + real(kind = FourByteReal), dimension(2), optional :: range + character(len = *), optional :: ncfile + integer, optional :: ncid + integer, optional :: rec + integer, dimension(:), optional :: start + integer, dimension(:), optional :: count + character(len = *), optional :: units + end subroutine ncdf_putvar_1D_FourByteReal + subroutine ncdf_putvar_1D_EightByteReal (name, values, ncfile, ncid, rec, start, count, units, range) + use typeSizes + character(len = *), intent(in) :: name + real(kind = EightByteReal), dimension(:), & + intent(in ) :: values + real(kind = EightByteReal), dimension(2), optional :: range + character(len = *), optional :: ncfile + integer, optional :: ncid + integer, optional :: rec + integer, dimension(:), optional :: start + integer, dimension(:), optional :: count + character(len = *), optional :: units + end subroutine ncdf_putvar_1D_EightByteReal + subroutine ncdf_putvar_2D_OneByteInt (name, values, ncfile, ncid, rec, start, count, units, range) + use typeSizes + character(len = *), intent(in) :: name + integer(kind = OneByteInt), dimension(:, :), & + intent(in ) :: values + integer(kind = OneByteInt), dimension(2), optional :: range + character(len = *), optional :: ncfile + integer, optional :: ncid + integer, optional :: rec + integer, dimension(:), optional :: start + integer, dimension(:), optional :: count + character(len = *), optional :: units + end subroutine ncdf_putvar_2D_OneByteInt + subroutine ncdf_putvar_2D_TwoByteInt (name, values, ncfile, ncid, rec, start, count, units, range) + use typeSizes + character(len = *), intent(in) :: name + integer(kind = TwoByteInt), dimension(:, :), & + intent(in ) :: values + integer(kind = TwoByteInt), dimension(2), optional :: range + character(len = *), optional :: ncfile + integer, optional :: ncid + integer, optional :: rec + integer, dimension(:), optional :: start + integer, dimension(:), optional :: count + character(len = *), optional :: units + end subroutine ncdf_putvar_2D_TwoByteInt + subroutine ncdf_putvar_2D_FourByteInt (name, values, ncfile, ncid, rec, start, count, units, range) + use typeSizes + character(len = *), intent(in) :: name + integer(kind = FourByteInt), dimension(:, :), & + intent(in ) :: values + integer(kind = FourByteInt), dimension(2), optional :: range + character(len = *), optional :: ncfile + integer, optional :: ncid + integer, optional :: rec + integer, dimension(:), optional :: start + integer, dimension(:), optional :: count + character(len = *), optional :: units + end subroutine ncdf_putvar_2D_FourByteInt + subroutine ncdf_putvar_2D_EightByteInt (name, values, ncfile, ncid, rec, start, count, units, range) + use typeSizes + character(len = *), intent(in) :: name + integer(kind = EightByteInt), dimension(:, :), & + intent(in ) :: values + integer(kind = EightByteInt), dimension(2), optional :: range + character(len = *), optional :: ncfile + integer, optional :: ncid + integer, optional :: rec + integer, dimension(:), optional :: start + integer, dimension(:), optional :: count + character(len = *), optional :: units + end subroutine ncdf_putvar_2D_EightByteInt + subroutine ncdf_putvar_2D_FourByteReal (name, values, ncfile, ncid, rec, start, count, units, range) + use typeSizes + character(len = *), intent(in) :: name + real(kind = FourByteReal), dimension(:, :), & + intent(in ) :: values + real(kind = FourByteReal), dimension(2), optional :: range + character(len = *), optional :: ncfile + integer, optional :: ncid + integer, optional :: rec + integer, dimension(:), optional :: start + integer, dimension(:), optional :: count + character(len = *), optional :: units + end subroutine ncdf_putvar_2D_FourByteReal + subroutine ncdf_putvar_2D_EightByteReal (name, values, ncfile, ncid, rec, start, count, units, range) + use typeSizes + character(len = *), intent(in) :: name + real(kind = EightByteReal), dimension(:, :), & + intent(in ) :: values + real(kind = EightByteReal), dimension(2), optional :: range + character(len = *), optional :: ncfile + integer, optional :: ncid + integer, optional :: rec + integer, dimension(:), optional :: start + integer, dimension(:), optional :: count + character(len = *), optional :: units + end subroutine ncdf_putvar_2D_EightByteReal + subroutine ncdf_putvar_3D_OneByteInt (name, values, ncfile, ncid, rec, start, count, units, range) + use typeSizes + character(len = *), intent(in) :: name + integer(kind = OneByteInt), dimension(:, :, :), & + intent(in ) :: values + integer(kind = OneByteInt), dimension(2), optional :: range + character(len = *), optional :: ncfile + integer, optional :: ncid + integer, optional :: rec + integer, dimension(:), optional :: start + integer, dimension(:), optional :: count + character(len = *), optional :: units + end subroutine ncdf_putvar_3D_OneByteInt + subroutine ncdf_putvar_3D_TwoByteInt (name, values, ncfile, ncid, rec, start, count, units, range) + use typeSizes + character(len = *), intent(in) :: name + integer(kind = TwoByteInt), dimension(:, :, :), & + intent(in ) :: values + integer(kind = TwoByteInt), dimension(2), optional :: range + character(len = *), optional :: ncfile + integer, optional :: ncid + integer, optional :: rec + integer, dimension(:), optional :: start + integer, dimension(:), optional :: count + character(len = *), optional :: units + end subroutine ncdf_putvar_3D_TwoByteInt + subroutine ncdf_putvar_3D_FourByteInt (name, values, ncfile, ncid, rec, start, count, units, range) + use typeSizes + character(len = *), intent(in) :: name + integer(kind = FourByteInt), dimension(:, :, :), & + intent(in ) :: values + integer(kind = FourByteInt), dimension(2), optional :: range + character(len = *), optional :: ncfile + integer, optional :: ncid + integer, optional :: rec + integer, dimension(:), optional :: start + integer, dimension(:), optional :: count + character(len = *), optional :: units + end subroutine ncdf_putvar_3D_FourByteInt + subroutine ncdf_putvar_3D_EightByteInt (name, values, ncfile, ncid, rec, start, count, units, range) + use typeSizes + character(len = *), intent(in) :: name + integer(kind = EightByteInt), dimension(:, :, :), & + intent(in ) :: values + integer(kind = EightByteInt), dimension(2), optional :: range + character(len = *), optional :: ncfile + integer, optional :: ncid + integer, optional :: rec + integer, dimension(:), optional :: start + integer, dimension(:), optional :: count + character(len = *), optional :: units + end subroutine ncdf_putvar_3D_EightByteInt + subroutine ncdf_putvar_3D_FourByteReal (name, values, ncfile, ncid, rec, start, count, units, range) + use typeSizes + character(len = *), intent(in) :: name + real(kind = FourByteReal), dimension(:, :, :), & + intent(in ) :: values + real(kind = FourByteReal), dimension(2), optional :: range + character(len = *), optional :: ncfile + integer, optional :: ncid + integer, optional :: rec + integer, dimension(:), optional :: start + integer, dimension(:), optional :: count + character(len = *), optional :: units + end subroutine ncdf_putvar_3D_FourByteReal + subroutine ncdf_putvar_3D_EightByteReal (name, values, ncfile, ncid, rec, start, count, units, range) + use typeSizes + character(len = *), intent(in) :: name + real(kind = EightByteReal), dimension(:, :, :), & + intent(in ) :: values + real(kind = EightByteReal), dimension(2), optional :: range + character(len = *), optional :: ncfile + integer, optional :: ncid + integer, optional :: rec + integer, dimension(:), optional :: start + integer, dimension(:), optional :: count + character(len = *), optional :: units + end subroutine ncdf_putvar_3D_EightByteReal + subroutine ncdf_putvar_4D_OneByteInt (name, values, ncfile, ncid, rec, start, count, units, range) + use typeSizes + character(len = *), intent(in) :: name + integer(kind = OneByteInt), dimension(:, :, :, :), & + intent(in ) :: values + integer(kind = OneByteInt), dimension(2), optional :: range + character(len = *), optional :: ncfile + integer, optional :: ncid + integer, optional :: rec + integer, dimension(:), optional :: start + integer, dimension(:), optional :: count + character(len = *), optional :: units + end subroutine ncdf_putvar_4D_OneByteInt + subroutine ncdf_putvar_4D_TwoByteInt (name, values, ncfile, ncid, rec, start, count, units, range) + use typeSizes + character(len = *), intent(in) :: name + integer(kind = TwoByteInt), dimension(:, :, :, :), & + intent(in ) :: values + integer(kind = TwoByteInt), dimension(2), optional :: range + character(len = *), optional :: ncfile + integer, optional :: ncid + integer, optional :: rec + integer, dimension(:), optional :: start + integer, dimension(:), optional :: count + character(len = *), optional :: units + end subroutine ncdf_putvar_4D_TwoByteInt + subroutine ncdf_putvar_4D_FourByteInt (name, values, ncfile, ncid, rec, start, count, units, range) + use typeSizes + character(len = *), intent(in) :: name + integer(kind = FourByteInt), dimension(:, :, :, :), & + intent(in ) :: values + integer(kind = FourByteInt), dimension(2), optional :: range + character(len = *), optional :: ncfile + integer, optional :: ncid + integer, optional :: rec + integer, dimension(:), optional :: start + integer, dimension(:), optional :: count + character(len = *), optional :: units + end subroutine ncdf_putvar_4D_FourByteInt + subroutine ncdf_putvar_4D_EightByteInt (name, values, ncfile, ncid, rec, start, count, units, range) + use typeSizes + character(len = *), intent(in) :: name + integer(kind = EightByteInt), dimension(:, :, :, :), & + intent(in ) :: values + integer(kind = EightByteInt), dimension(2), optional :: range + character(len = *), optional :: ncfile + integer, optional :: ncid + integer, optional :: rec + integer, dimension(:), optional :: start + integer, dimension(:), optional :: count + character(len = *), optional :: units + end subroutine ncdf_putvar_4D_EightByteInt + subroutine ncdf_putvar_4D_FourByteReal (name, values, ncfile, ncid, rec, start, count, units, range) + use typeSizes + character(len = *), intent(in) :: name + real(kind = FourByteReal), dimension(:, :, :, :), & + intent(in ) :: values + real(kind = FourByteReal), dimension(2), optional :: range + character(len = *), optional :: ncfile + integer, optional :: ncid + integer, optional :: rec + integer, dimension(:), optional :: start + integer, dimension(:), optional :: count + character(len = *), optional :: units + end subroutine ncdf_putvar_4D_FourByteReal + subroutine ncdf_putvar_4D_EightByteReal (name, values, ncfile, ncid, rec, start, count, units, range) + use typeSizes + character(len = *), intent(in) :: name + real(kind = EightByteReal), dimension(:, :, :, :), & + intent(in ) :: values + real(kind = EightByteReal), dimension(2), optional :: range + character(len = *), optional :: ncfile + integer, optional :: ncid + integer, optional :: rec + integer, dimension(:), optional :: start + integer, dimension(:), optional :: count + character(len = *), optional :: units + end subroutine ncdf_putvar_4D_EightByteReal + subroutine ncdf_putvar_5D_OneByteInt (name, values, ncfile, ncid, rec, start, count, units, range) + use typeSizes + character(len = *), intent(in) :: name + integer(kind = OneByteInt), dimension(:, :, :, :, :), & + intent(in ) :: values + integer(kind = OneByteInt), dimension(2), optional :: range + character(len = *), optional :: ncfile + integer, optional :: ncid + integer, optional :: rec + integer, dimension(:), optional :: start + integer, dimension(:), optional :: count + character(len = *), optional :: units + end subroutine ncdf_putvar_5D_OneByteInt + subroutine ncdf_putvar_5D_TwoByteInt (name, values, ncfile, ncid, rec, start, count, units, range) + use typeSizes + character(len = *), intent(in) :: name + integer(kind = TwoByteInt), dimension(:, :, :, :, :), & + intent(in ) :: values + integer(kind = TwoByteInt), dimension(2), optional :: range + character(len = *), optional :: ncfile + integer, optional :: ncid + integer, optional :: rec + integer, dimension(:), optional :: start + integer, dimension(:), optional :: count + character(len = *), optional :: units + end subroutine ncdf_putvar_5D_TwoByteInt + subroutine ncdf_putvar_5D_FourByteInt (name, values, ncfile, ncid, rec, start, count, units, range) + use typeSizes + character(len = *), intent(in) :: name + integer(kind = FourByteInt), dimension(:, :, :, :, :), & + intent(in ) :: values + integer(kind = FourByteInt), dimension(2), optional :: range + character(len = *), optional :: ncfile + integer, optional :: ncid + integer, optional :: rec + integer, dimension(:), optional :: start + integer, dimension(:), optional :: count + character(len = *), optional :: units + end subroutine ncdf_putvar_5D_FourByteInt + subroutine ncdf_putvar_5D_EightByteInt (name, values, ncfile, ncid, rec, start, count, units, range) + use typeSizes + character(len = *), intent(in) :: name + integer(kind = EightByteInt), dimension(:, :, :, :, :), & + intent(in ) :: values + integer(kind = EightByteInt), dimension(2), optional :: range + character(len = *), optional :: ncfile + integer, optional :: ncid + integer, optional :: rec + integer, dimension(:), optional :: start + integer, dimension(:), optional :: count + character(len = *), optional :: units + end subroutine ncdf_putvar_5D_EightByteInt + subroutine ncdf_putvar_5D_FourByteReal (name, values, ncfile, ncid, rec, start, count, units, range) + use typeSizes + character(len = *), intent(in) :: name + real(kind = FourByteReal), dimension(:, :, :, :, :), & + intent(in ) :: values + real(kind = FourByteReal), dimension(2), optional :: range + character(len = *), optional :: ncfile + integer, optional :: ncid + integer, optional :: rec + integer, dimension(:), optional :: start + integer, dimension(:), optional :: count + character(len = *), optional :: units + end subroutine ncdf_putvar_5D_FourByteReal + subroutine ncdf_putvar_5D_EightByteReal (name, values, ncfile, ncid, rec, start, count, units, range) + use typeSizes + character(len = *), intent(in) :: name + real(kind = EightByteReal), dimension(:, :, :, :, :), & + intent(in ) :: values + real(kind = EightByteReal), dimension(2), optional :: range + character(len = *), optional :: ncfile + integer, optional :: ncid + integer, optional :: rec + integer, dimension(:), optional :: start + integer, dimension(:), optional :: count + character(len = *), optional :: units + end subroutine ncdf_putvar_5D_EightByteReal + subroutine ncdf_putvar_6D_OneByteInt (name, values, ncfile, ncid, rec, start, count, units, range) + use typeSizes + character(len = *), intent(in) :: name + integer(kind = OneByteInt), dimension(:, :, :, :, :, :), & + intent(in ) :: values + integer(kind = OneByteInt), dimension(2), optional :: range + character(len = *), optional :: ncfile + integer, optional :: ncid + integer, optional :: rec + integer, dimension(:), optional :: start + integer, dimension(:), optional :: count + character(len = *), optional :: units + end subroutine ncdf_putvar_6D_OneByteInt + subroutine ncdf_putvar_6D_TwoByteInt (name, values, ncfile, ncid, rec, start, count, units, range) + use typeSizes + character(len = *), intent(in) :: name + integer(kind = TwoByteInt), dimension(:, :, :, :, :, :), & + intent(in ) :: values + integer(kind = TwoByteInt), dimension(2), optional :: range + character(len = *), optional :: ncfile + integer, optional :: ncid + integer, optional :: rec + integer, dimension(:), optional :: start + integer, dimension(:), optional :: count + character(len = *), optional :: units + end subroutine ncdf_putvar_6D_TwoByteInt + subroutine ncdf_putvar_6D_FourByteInt (name, values, ncfile, ncid, rec, start, count, units, range) + use typeSizes + character(len = *), intent(in) :: name + integer(kind = FourByteInt), dimension(:, :, :, :, :, :), & + intent(in ) :: values + integer(kind = FourByteInt), dimension(2), optional :: range + character(len = *), optional :: ncfile + integer, optional :: ncid + integer, optional :: rec + integer, dimension(:), optional :: start + integer, dimension(:), optional :: count + character(len = *), optional :: units + end subroutine ncdf_putvar_6D_FourByteInt + subroutine ncdf_putvar_6D_EightByteInt (name, values, ncfile, ncid, rec, start, count, units, range) + use typeSizes + character(len = *), intent(in) :: name + integer(kind = EightByteInt), dimension(:, :, :, :, :, :), & + intent(in ) :: values + integer(kind = EightByteInt), dimension(2), optional :: range + character(len = *), optional :: ncfile + integer, optional :: ncid + integer, optional :: rec + integer, dimension(:), optional :: start + integer, dimension(:), optional :: count + character(len = *), optional :: units + end subroutine ncdf_putvar_6D_EightByteInt + subroutine ncdf_putvar_6D_FourByteReal (name, values, ncfile, ncid, rec, start, count, units, range) + use typeSizes + character(len = *), intent(in) :: name + real(kind = FourByteReal), dimension(:, :, :, :, :, :), & + intent(in ) :: values + real(kind = FourByteReal), dimension(2), optional :: range + character(len = *), optional :: ncfile + integer, optional :: ncid + integer, optional :: rec + integer, dimension(:), optional :: start + integer, dimension(:), optional :: count + character(len = *), optional :: units + end subroutine ncdf_putvar_6D_FourByteReal + subroutine ncdf_putvar_6D_EightByteReal (name, values, ncfile, ncid, rec, start, count, units, range) + use typeSizes + character(len = *), intent(in) :: name + real(kind = EightByteReal), dimension(:, :, :, :, :, :), & + intent(in ) :: values + real(kind = EightByteReal), dimension(2), optional :: range + character(len = *), optional :: ncfile + integer, optional :: ncid + integer, optional :: rec + integer, dimension(:), optional :: start + integer, dimension(:), optional :: count + character(len = *), optional :: units + end subroutine ncdf_putvar_6D_EightByteReal + subroutine ncdf_putvar_7D_OneByteInt (name, values, ncfile, ncid, rec, start, count, units, range) + use typeSizes + character(len = *), intent(in) :: name + integer(kind = OneByteInt), dimension(:, :, :, :, :, :, :), & + intent(in ) :: values + integer(kind = OneByteInt), dimension(2), optional :: range + character(len = *), optional :: ncfile + integer, optional :: ncid + integer, optional :: rec + integer, dimension(:), optional :: start + integer, dimension(:), optional :: count + character(len = *), optional :: units + end subroutine ncdf_putvar_7D_OneByteInt + subroutine ncdf_putvar_7D_TwoByteInt (name, values, ncfile, ncid, rec, start, count, units, range) + use typeSizes + character(len = *), intent(in) :: name + integer(kind = TwoByteInt), dimension(:, :, :, :, :, :, :), & + intent(in ) :: values + integer(kind = TwoByteInt), dimension(2), optional :: range + character(len = *), optional :: ncfile + integer, optional :: ncid + integer, optional :: rec + integer, dimension(:), optional :: start + integer, dimension(:), optional :: count + character(len = *), optional :: units + end subroutine ncdf_putvar_7D_TwoByteInt + subroutine ncdf_putvar_7D_FourByteInt (name, values, ncfile, ncid, rec, start, count, units, range) + use typeSizes + character(len = *), intent(in) :: name + integer(kind = FourByteInt), dimension(:, :, :, :, :, :, :), & + intent(in ) :: values + integer(kind = FourByteInt), dimension(2), optional :: range + character(len = *), optional :: ncfile + integer, optional :: ncid + integer, optional :: rec + integer, dimension(:), optional :: start + integer, dimension(:), optional :: count + character(len = *), optional :: units + end subroutine ncdf_putvar_7D_FourByteInt + subroutine ncdf_putvar_7D_EightByteInt (name, values, ncfile, ncid, rec, start, count, units, range) + use typeSizes + character(len = *), intent(in) :: name + integer(kind = EightByteInt), dimension(:, :, :, :, :, :, :), & + intent(in ) :: values + integer(kind = EightByteInt), dimension(2), optional :: range + character(len = *), optional :: ncfile + integer, optional :: ncid + integer, optional :: rec + integer, dimension(:), optional :: start + integer, dimension(:), optional :: count + character(len = *), optional :: units + end subroutine ncdf_putvar_7D_EightByteInt + subroutine ncdf_putvar_7D_FourByteReal (name, values, ncfile, ncid, rec, start, count, units, range) + use typeSizes + character(len = *), intent(in) :: name + real(kind = FourByteReal), dimension(:, :, :, :, :, :, :), & + intent(in ) :: values + real(kind = FourByteReal), dimension(2), optional :: range + character(len = *), optional :: ncfile + integer, optional :: ncid + integer, optional :: rec + integer, dimension(:), optional :: start + integer, dimension(:), optional :: count + character(len = *), optional :: units + end subroutine ncdf_putvar_7D_FourByteReal + subroutine ncdf_putvar_7D_EightByteReal (name, values, ncfile, ncid, rec, start, count, units, range) + use typeSizes + character(len = *), intent(in) :: name + real(kind = EightByteReal), dimension(:, :, :, :, :, :, :), & + intent(in ) :: values + real(kind = EightByteReal), dimension(2), optional :: range + character(len = *), optional :: ncfile + integer, optional :: ncid + integer, optional :: rec + integer, dimension(:), optional :: start + integer, dimension(:), optional :: count + character(len = *), optional :: units + end subroutine ncdf_putvar_7D_EightByteReal + end interface + interface ncdf_getvar + subroutine ncdf_getvar_OneByteInt (name, values, ncfile, ncid, rec, start, units, range) + use typeSizes + character(len = *), intent( in) :: name + integer(kind = OneByteInt), & + intent(out) :: values + integer(kind = OneByteInt), dimension(2), optional :: range + character(len = *), optional :: ncfile + integer, optional :: ncid + integer, optional :: rec + integer, dimension(:), optional :: start + character(len = *), optional :: units + end subroutine ncdf_getvar_OneByteInt + subroutine ncdf_getvar_TwoByteInt (name, values, ncfile, ncid, rec, start, units, range) + use typeSizes + character(len = *), intent( in) :: name + integer(kind = TwoByteInt), & + intent(out) :: values + integer(kind = TwoByteInt), dimension(2), optional :: range + character(len = *), optional :: ncfile + integer, optional :: ncid + integer, optional :: rec + integer, dimension(:), optional :: start + character(len = *), optional :: units + end subroutine ncdf_getvar_TwoByteInt + subroutine ncdf_getvar_FourByteInt (name, values, ncfile, ncid, rec, start, units, range) + use typeSizes + character(len = *), intent( in) :: name + integer(kind = FourByteInt), & + intent(out) :: values + integer(kind = FourByteInt), dimension(2), optional :: range + character(len = *), optional :: ncfile + integer, optional :: ncid + integer, optional :: rec + integer, dimension(:), optional :: start + character(len = *), optional :: units + end subroutine ncdf_getvar_FourByteInt + subroutine ncdf_getvar_EightByteInt (name, values, ncfile, ncid, rec, start, units, range) + use typeSizes + character(len = *), intent( in) :: name + integer(kind = EightByteInt), & + intent(out) :: values + integer(kind = EightByteInt), dimension(2), optional :: range + character(len = *), optional :: ncfile + integer, optional :: ncid + integer, optional :: rec + integer, dimension(:), optional :: start + character(len = *), optional :: units + end subroutine ncdf_getvar_EightByteInt + subroutine ncdf_getvar_FourByteReal (name, values, ncfile, ncid, rec, start, units, range) + use typeSizes + character(len = *), intent( in) :: name + real(kind = FourByteReal), & + intent(out) :: values + real(kind = FourByteReal), dimension(2), optional :: range + character(len = *), optional :: ncfile + integer, optional :: ncid + integer, optional :: rec + integer, dimension(:), optional :: start + character(len = *), optional :: units + end subroutine ncdf_getvar_FourByteReal + subroutine ncdf_getvar_EightByteReal (name, values, ncfile, ncid, rec, start, units, range) + use typeSizes + character(len = *), intent( in) :: name + real(kind = EightByteReal), & + intent(out) :: values + real(kind = EightByteReal), dimension(2), optional :: range + character(len = *), optional :: ncfile + integer, optional :: ncid + integer, optional :: rec + integer, dimension(:), optional :: start + character(len = *), optional :: units + end subroutine ncdf_getvar_EightByteReal + subroutine ncdf_getvar_text (name, values, ncfile, ncid, rec, start, units, range) + use typeSizes + character(len = *), intent( in) :: name + character (len = *), & + intent(out) :: values + character (len = *), dimension(2), optional :: range + character(len = *), optional :: ncfile + integer, optional :: ncid + integer, optional :: rec + integer, dimension(:), optional :: start + character(len = *), optional :: units + end subroutine ncdf_getvar_text + subroutine ncdf_getvar_1D_OneByteInt (name, values, ncfile, ncid, rec, start, count, units, range) + use typeSizes + character(len = *), intent(in) :: name + integer(kind = OneByteInt), dimension(:), & + intent(out) :: values + integer(kind = OneByteInt), dimension(2), optional :: range + character(len = *), optional :: ncfile + integer, optional :: ncid + integer, optional :: rec + integer, dimension(:), optional :: start + integer, dimension(:), optional :: count + character(len = *), optional :: units + end subroutine ncdf_getvar_1D_OneByteInt + subroutine ncdf_getvar_1D_TwoByteInt (name, values, ncfile, ncid, rec, start, count, units, range) + use typeSizes + character(len = *), intent(in) :: name + integer(kind = TwoByteInt), dimension(:), & + intent(out) :: values + integer(kind = TwoByteInt), dimension(2), optional :: range + character(len = *), optional :: ncfile + integer, optional :: ncid + integer, optional :: rec + integer, dimension(:), optional :: start + integer, dimension(:), optional :: count + character(len = *), optional :: units + end subroutine ncdf_getvar_1D_TwoByteInt + subroutine ncdf_getvar_1D_FourByteInt (name, values, ncfile, ncid, rec, start, count, units, range) + use typeSizes + character(len = *), intent(in) :: name + integer(kind = FourByteInt), dimension(:), & + intent(out) :: values + integer(kind = FourByteInt), dimension(2), optional :: range + character(len = *), optional :: ncfile + integer, optional :: ncid + integer, optional :: rec + integer, dimension(:), optional :: start + integer, dimension(:), optional :: count + character(len = *), optional :: units + end subroutine ncdf_getvar_1D_FourByteInt + subroutine ncdf_getvar_1D_EightByteInt (name, values, ncfile, ncid, rec, start, count, units, range) + use typeSizes + character(len = *), intent(in) :: name + integer(kind = EightByteInt), dimension(:), & + intent(out) :: values + integer(kind = EightByteInt), dimension(2), optional :: range + character(len = *), optional :: ncfile + integer, optional :: ncid + integer, optional :: rec + integer, dimension(:), optional :: start + integer, dimension(:), optional :: count + character(len = *), optional :: units + end subroutine ncdf_getvar_1D_EightByteInt + subroutine ncdf_getvar_1D_FourByteReal (name, values, ncfile, ncid, rec, start, count, units, range) + use typeSizes + character(len = *), intent(in) :: name + real(kind = FourByteReal), dimension(:), & + intent(out) :: values + real(kind = FourByteReal), dimension(2), optional :: range + character(len = *), optional :: ncfile + integer, optional :: ncid + integer, optional :: rec + integer, dimension(:), optional :: start + integer, dimension(:), optional :: count + character(len = *), optional :: units + end subroutine ncdf_getvar_1D_FourByteReal + subroutine ncdf_getvar_1D_EightByteReal (name, values, ncfile, ncid, rec, start, count, units, range) + use typeSizes + character(len = *), intent(in) :: name + real(kind = EightByteReal), dimension(:), & + intent(out) :: values + real(kind = EightByteReal), dimension(2), optional :: range + character(len = *), optional :: ncfile + integer, optional :: ncid + integer, optional :: rec + integer, dimension(:), optional :: start + integer, dimension(:), optional :: count + character(len = *), optional :: units + end subroutine ncdf_getvar_1D_EightByteReal + subroutine ncdf_getvar_2D_OneByteInt (name, values, ncfile, ncid, rec, start, count, units, range) + use typeSizes + character(len = *), intent(in) :: name + integer(kind = OneByteInt), dimension(:, :), & + intent(out) :: values + integer(kind = OneByteInt), dimension(2), optional :: range + character(len = *), optional :: ncfile + integer, optional :: ncid + integer, optional :: rec + integer, dimension(:), optional :: start + integer, dimension(:), optional :: count + character(len = *), optional :: units + end subroutine ncdf_getvar_2D_OneByteInt + subroutine ncdf_getvar_2D_TwoByteInt (name, values, ncfile, ncid, rec, start, count, units, range) + use typeSizes + character(len = *), intent(in) :: name + integer(kind = TwoByteInt), dimension(:, :), & + intent(out) :: values + integer(kind = TwoByteInt), dimension(2), optional :: range + character(len = *), optional :: ncfile + integer, optional :: ncid + integer, optional :: rec + integer, dimension(:), optional :: start + integer, dimension(:), optional :: count + character(len = *), optional :: units + end subroutine ncdf_getvar_2D_TwoByteInt + subroutine ncdf_getvar_2D_FourByteInt (name, values, ncfile, ncid, rec, start, count, units, range) + use typeSizes + character(len = *), intent(in) :: name + integer(kind = FourByteInt), dimension(:, :), & + intent(out) :: values + integer(kind = FourByteInt), dimension(2), optional :: range + character(len = *), optional :: ncfile + integer, optional :: ncid + integer, optional :: rec + integer, dimension(:), optional :: start + integer, dimension(:), optional :: count + character(len = *), optional :: units + + end subroutine ncdf_getvar_2D_FourByteInt + +end module ncdf \ No newline at end of file diff --git a/fortran90-rules/src/test/resources/COM/PRES/FileLength/noError.f b/fortran90-rules/src/test/resources/COM/PRES/FileLength/noError.f new file mode 100644 index 00000000..89bfafa7 --- /dev/null +++ b/fortran90-rules/src/test/resources/COM/PRES/FileLength/noError.f @@ -0,0 +1,58 @@ +! $Id: ropp_1dvar_iono.f90 4010 2014-01-10 11:07:40Z idculv $ +!****m* Modules/ropp_1dvar_iono * +! +! NAME +! ropp_1dvar_iono - Interface module for the ropp_1dvar direct_ion feature. +! +! SYNOPSIS +! USE ropp_1dvar_iono +! +! DESCRIPTION +! This module provides interfaces for some "ionospheric" routines contained +! in the ROPP 1DVar library. +! +! NOTES +! +! SEE ALSO +! +! AUTHOR +! Met Office, Exeter, UK. +! Any comments on this software should be given via the ROM SAF +! Helpdesk at http://www.romsaf.org +! +! COPYRIGHT +! (c) EUMETSAT. All rights reserved. +! For further details please refer to the file COPYRIGHT +! which you should have received as part of this distribution. +! +!**** +MODULE ropp_1dvar_iono +!------------------------------------------------------------------------------- +! 1. Repacking routines +!------------------------------------------------------------------------------- + INTERFACE ropp_1dvar_iono_repack + SUBROUTINE ropp_1dvar_iono_repack_bangle(obs_data, obs, config) + USE ropp_io_types + USE ropp_1dvar_types + TYPE(ROprof), INTENT(inout) :: obs_data + TYPE(Obs1dBangle), INTENT(inout) :: obs + TYPE(VarConfig), INTENT(in) :: config + END SUBROUTINE ropp_1dvar_iono_repack_bangle + SUBROUTINE ropp_1dvar_iono_repack_bg(bg_data, bg, config) + USE ropp_io_types + USE ropp_1dvar_types + TYPE(ROprof), INTENT(inout) :: bg_data + TYPE(State1dFM), INTENT(inout) :: bg + TYPE(VarConfig), INTENT(in) :: config + END SUBROUTINE ropp_1dvar_iono_repack_bg + END INTERFACE +!------------------------------------------------------------------------------- +! 2. Unpacking routines +!------------------------------------------------------------------------------- + INTERFACE ropp_1dvar_iono_unpack + SUBROUTINE ropp_1dvar_iono_unpack_bangle(res_data) + USE ropp_io_types + TYPE(ROprof), INTENT(inout) :: res_data + END SUBROUTINE ropp_1dvar_iono_unpack_bangle + END INTERFACE +END MODULE ropp_1dvar_iono diff --git a/fortran90-rules/src/test/resources/F90/DESIGN/LogicUnit/error.f90 b/fortran90-rules/src/test/resources/F90/DESIGN/LogicUnit/error.f90 new file mode 100644 index 00000000..c25768ac --- /dev/null +++ b/fortran90-rules/src/test/resources/F90/DESIGN/LogicUnit/error.f90 @@ -0,0 +1,39 @@ +MODULE ESSAI + + IMPLICIT NONE + + REAL :: Tc + REAL :: Tf + REAL :: C_To_F + REAL :: F_To_C + + WRITE(*, '(3X,"Temperature en Celsius:")') + READ(*,*) Tc + WRITE(*, '(3X,"->Conversion en Fahrenheit:",F8.3)') C_To_F(Tc) + + WRITE(*, '(" ")') + WRITE(*, '(3X,"Temperature en Fahrenheit:")') + READ(*,*) Tf + WRITE(*, '(3X,"->Conversion en Celsius:",F8.3)') F_To_C(Tf) + +END MODULE ESSAI + +MODULE ESSAI2 + + IMPLICIT NONE + + REAL :: Tc + REAL :: Tf + REAL :: C_To_F + REAL :: F_To_C + + WRITE(*, '(3X,"Temperature en Celsius:")') + READ(*,*) Tc + WRITE(*, '(3X,"->Conversion en Fahrenheit:",F8.3)') C_To_F(Tc) + + WRITE(*, '(" ")') + WRITE(*, '(3X,"Temperature en Fahrenheit:")') + READ(*,*) Tf + WRITE(*, '(3X,"->Conversion en Celsius:",F8.3)') F_To_C(Tf) + +END MODULE ESSAI2 diff --git a/fortran90-rules/src/test/resources/F90/DESIGN/LogicUnit/noError.f90 b/fortran90-rules/src/test/resources/F90/DESIGN/LogicUnit/noError.f90 new file mode 100644 index 00000000..b96e4586 --- /dev/null +++ b/fortran90-rules/src/test/resources/F90/DESIGN/LogicUnit/noError.f90 @@ -0,0 +1,19 @@ +MODULE ESSAI + + IMPLICIT NONE + + REAL :: Tc + REAL :: Tf + REAL :: C_To_F + REAL :: F_To_C + + WRITE(*, '(3X,"Temperature en Celsius:")') + READ(*,*) Tc + WRITE(*, '(3X,"->Conversion en Fahrenheit:",F8.3)') C_To_F(Tc) + + WRITE(*, '(" ")') + WRITE(*, '(3X,"Temperature en Fahrenheit:")') + READ(*,*) Tf + WRITE(*, '(3X,"->Conversion en Celsius:",F8.3)') F_To_C(Tf) + +END MODULE ESSAI diff --git a/fortran90-rules/src/test/resources/F90/FILE/Header/error.f90 b/fortran90-rules/src/test/resources/F90/FILE/Header/error.f90 new file mode 100644 index 00000000..c243368a --- /dev/null +++ b/fortran90-rules/src/test/resources/F90/FILE/Header/error.f90 @@ -0,0 +1,19 @@ +MODULE ESSAI + + IMPLICIT NONE + + REAL :: Tc + REAL :: Tf + REAL :: C_To_F + REAL :: F_To_C + + WRITE(*, '(3X,"Temperature en Celsius:")') + READ(*,*) Tc + WRITE(*, '(3X,"->Conversion en Fahrenheit:",F8.3)') C_To_F(Tc) + + WRITE(*, '(" ")') + WRITE(*, '(3X,"Temperature en Fahrenheit:")') + READ(*,*) Tf + WRITE(*, '(3X,"->Conversion en Celsius:",F8.3)') F_To_C(Tf) + +END MODULE ESSAI \ No newline at end of file diff --git a/fortran90-rules/src/test/resources/F90/FILE/Header/noError.f90 b/fortran90-rules/src/test/resources/F90/FILE/Header/noError.f90 new file mode 100644 index 00000000..1375a4a0 --- /dev/null +++ b/fortran90-rules/src/test/resources/F90/FILE/Header/noError.f90 @@ -0,0 +1,29 @@ +MODULE ESSAI + + !------------------------------------------------------------------------------- + ! Component Name: component name + ! File: file name (it may be automatically inserted by the code management tool) + ! Author: author name + ! Copyright: EUMETSAT 2015 + ! Description: brief description of the purpose of the file content (e.g. class + ! description) + !------------------------------------------------------------------------------- + + + IMPLICIT NONE + + REAL :: Tc + REAL :: Tf + REAL :: C_To_F + REAL :: F_To_C + + WRITE(*, '(3X,"Temperature en Celsius:")') + READ(*,*) Tc + WRITE(*, '(3X,"->Conversion en Fahrenheit:",F8.3)') C_To_F(Tc) + + WRITE(*, '(" ")') + WRITE(*, '(3X,"Temperature en Fahrenheit:")') + READ(*,*) Tf + WRITE(*, '(3X,"->Conversion en Celsius:",F8.3)') F_To_C(Tf) + +END MODULE ESSAI