From 308c9a9c56ecc59f575126c3b5df3242c73bf12c Mon Sep 17 00:00:00 2001 From: jverdugo-aqclab Date: Tue, 14 Jan 2025 16:27:53 +0100 Subject: [PATCH 1/4] Bugfixes and new rules from collaboration EUMETSAT-AQCLab (#230) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 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 * 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. * Bug fix: a parsing error (IndexOutOfBoundsException) was produced when analyzing files that included sentences like "PROCEDURE(proc_interface), POINTER :: proc" * 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. * 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. * Rule ArgumentsProcedure Rule to check the maximum number of arguments in each procedure, which must be at most 7. * Rule CyclomaticComplexity Rule to check the maximum value of the cyclomatic complexity in each function, which at most must be 15. * Rule LogicUnit Rule to check that only one module or program is declared in each file. * 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. * Rule CommentVar * Rule Header * Change new rules names to RNC rules * Change name in comment * Update fortran77-rules/src/main/resources/lex/COMFLOWCheckArguments.lex Co-authored-by: Diego Rodriguez <63045276+diegorodriguez31@users.noreply.github.com> * Update fortran77-rules/src/main/resources/lex/COMFLOWCheckArguments.lex Co-authored-by: Diego Rodriguez <63045276+diegorodriguez31@users.noreply.github.com> * Update fortran77-rules/src/main/resources/lex/COMMETComplexitySimplified.lex Co-authored-by: Diego Rodriguez <63045276+diegorodriguez31@users.noreply.github.com> * Update fortran77-rules/src/main/resources/lex/COMMETComplexitySimplified.lex Co-authored-by: Diego Rodriguez <63045276+diegorodriguez31@users.noreply.github.com> * Update fortran77-rules/src/main/resources/lex/COMMETLineOfCode.lex Co-authored-by: Diego Rodriguez <63045276+diegorodriguez31@users.noreply.github.com> * Update fortran77-rules/src/main/resources/lex/COMMETLineOfCode.lex Co-authored-by: Diego Rodriguez <63045276+diegorodriguez31@users.noreply.github.com> * Update fortran90-rules/src/main/resources/lex/COMMETLineOfCode.lex Co-authored-by: Diego Rodriguez <63045276+diegorodriguez31@users.noreply.github.com> * Update fortran90-rules/src/main/resources/lex/COMFLOWCheckArguments.lex Co-authored-by: Diego Rodriguez <63045276+diegorodriguez31@users.noreply.github.com> * Update fortran77-rules/src/main/resources/lex/COMMETRatioComment.lex Co-authored-by: Diego Rodriguez <63045276+diegorodriguez31@users.noreply.github.com> * Update fortran77-rules/src/main/resources/lex/COMMETRatioComment.lex Co-authored-by: Diego Rodriguez <63045276+diegorodriguez31@users.noreply.github.com> * Update fortran90-rules/src/main/resources/lex/COMMETRatioComment.lex Co-authored-by: Diego Rodriguez <63045276+diegorodriguez31@users.noreply.github.com> * Update fortran90-rules/src/main/resources/lex/COMMETRatioComment.lex Co-authored-by: Diego Rodriguez <63045276+diegorodriguez31@users.noreply.github.com> * Update fortran90-rules/src/main/resources/lex/COMMETLineOfCode.lex Co-authored-by: Diego Rodriguez <63045276+diegorodriguez31@users.noreply.github.com> * Update fortran90-rules/src/main/resources/lex/COMMETComplexitySimplified.lex Co-authored-by: Diego Rodriguez <63045276+diegorodriguez31@users.noreply.github.com> * Update fortran90-rules/src/main/resources/lex/COMMETComplexitySimplified.lex Co-authored-by: Diego Rodriguez <63045276+diegorodriguez31@users.noreply.github.com> * Update fortran90-rules/src/main/resources/lex/COMFLOWCheckArguments.lex Co-authored-by: Diego Rodriguez <63045276+diegorodriguez31@users.noreply.github.com> * Remove unused variable numTotal * Header updated to reflect this rule is not defined in RNC. * Test cases for new rules --------- Co-authored-by: Ana Díaz Muñoz Co-authored-by: Ana Díaz Muñoz <120630965+adiaz-aqclab@users.noreply.github.com> Co-authored-by: Diego Co-authored-by: Diego Rodriguez <63045276+diegorodriguez31@users.noreply.github.com> --- .../src/main/resources/fortran77-rules.xml | 48 + .../resources/lex/COMFLOWCheckArguments.lex | 163 ++ .../lex/COMMETComplexitySimplified.lex | 154 ++ .../main/resources/lex/COMMETLineOfCode.lex | 176 ++ .../main/resources/lex/COMMETRatioComment.lex | 168 ++ .../main/resources/lex/COMNAMEHomonymy.lex | 11 +- .../src/main/resources/lex/COMPRESData.lex | 166 ++ .../main/resources/lex/COMPRESFileLength.lex | 158 ++ .../main/resources/lex/COMPROJECTHeader.lex | 72 +- .../main/resources/lex/F77DESIGNLogicUnit.lex | 203 +++ .../src/main/resources/lex/F77FILEHeader.lex | 188 +++ .../rules/TestAllFortran77Rules.java | 8 + .../rules/TestFortran77RulesDefinition.java | 2 +- .../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/error.f | 19 + .../test/resources/F77/FILE/Header/noError.f | 29 + .../src/main/resources/fortran90-rules.xml | 50 +- .../resources/lex/COMFLOWCheckArguments.lex | 171 ++ .../src/main/resources/lex/COMINSTBrace.lex | 1 + .../lex/COMMETComplexitySimplified.lex | 158 ++ .../main/resources/lex/COMMETLineOfCode.lex | 175 ++ .../main/resources/lex/COMMETRatioComment.lex | 163 ++ .../main/resources/lex/COMNAMEHomonymy.lex | 6 +- .../src/main/resources/lex/COMPRESData.lex | 162 ++ .../main/resources/lex/COMPRESFileLength.lex | 154 ++ .../main/resources/lex/COMPROJECTHeader.lex | 158 +- .../main/resources/lex/F90DESIGNLogicUnit.lex | 203 +++ .../src/main/resources/lex/F90FILEHeader.lex | 191 +++ .../rules/TestAllFortran90Rules.java | 8 + .../rules/TestFortran90RulesDefinition.java | 2 +- .../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 + 59 files changed, 6572 insertions(+), 126 deletions(-) create mode 100644 fortran77-rules/src/main/resources/lex/COMFLOWCheckArguments.lex create mode 100644 fortran77-rules/src/main/resources/lex/COMMETComplexitySimplified.lex create mode 100644 fortran77-rules/src/main/resources/lex/COMMETLineOfCode.lex create mode 100644 fortran77-rules/src/main/resources/lex/COMMETRatioComment.lex create mode 100644 fortran77-rules/src/main/resources/lex/COMPRESData.lex create mode 100644 fortran77-rules/src/main/resources/lex/COMPRESFileLength.lex create mode 100644 fortran77-rules/src/main/resources/lex/F77DESIGNLogicUnit.lex create mode 100644 fortran77-rules/src/main/resources/lex/F77FILEHeader.lex 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/error.f create mode 100644 fortran77-rules/src/test/resources/F77/FILE/Header/noError.f create mode 100644 fortran90-rules/src/main/resources/lex/COMFLOWCheckArguments.lex create mode 100644 fortran90-rules/src/main/resources/lex/COMMETComplexitySimplified.lex create mode 100644 fortran90-rules/src/main/resources/lex/COMMETLineOfCode.lex create mode 100644 fortran90-rules/src/main/resources/lex/COMMETRatioComment.lex create mode 100644 fortran90-rules/src/main/resources/lex/COMPRESData.lex create mode 100644 fortran90-rules/src/main/resources/lex/COMPRESFileLength.lex create mode 100644 fortran90-rules/src/main/resources/lex/F90DESIGNLogicUnit.lex create mode 100644 fortran90-rules/src/main/resources/lex/F90FILEHeader.lex 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/main/resources/fortran77-rules.xml b/fortran77-rules/src/main/resources/fortran77-rules.xml index 7bb3a48e..2230d73f 100644 --- a/fortran77-rules/src/main/resources/fortran77-rules.xml +++ b/fortran77-rules/src/main/resources/fortran77-rules.xml @@ -342,4 +342,52 @@ fr.cnes.icode.fortran77 F77.TYPE.Hollerith + + fr.cnes.icode.fortran77.rules.COMPRESFileLength + fr.cnes.icode.fortran77.rules.COMPRESFileLength + COM.PRES.FileLength + fr.cnes.icode.fortran77 + + + fr.cnes.icode.fortran77.rules.COMMETLineOfCode + fr.cnes.icode.fortran77.rules.COMMETLineOfCode + COM.MET.LineOfCode + fr.cnes.icode.fortran77 + + + fr.cnes.icode.fortran77.rules.COMFLOWCheckArguments + fr.cnes.icode.fortran77.rules.COMFLOWCheckArguments + COM.FLOW.CheckArguments + fr.cnes.icode.fortran77 + + + fr.cnes.icode.fortran77.rules.COMMETComplexitySimplified + fr.cnes.icode.fortran77.rules.COMMETComplexitySimplified + COM.MET.ComplexitySimplified + fr.cnes.icode.fortran77 + + + fr.cnes.icode.fortran77.rules.F77DESIGNLogicUnit + fr.cnes.icode.fortran77.rules.F77DESIGNLogicUnit + F77.DESIGN.LogicUnit + fr.cnes.icode.fortran77 + + + fr.cnes.icode.fortran77.rules.COMMETRatioComment + fr.cnes.icode.fortran77.rules.COMMETRatioComment + COM.MET.RatioComment + fr.cnes.icode.fortran77 + + + fr.cnes.icode.fortran77.rules.COMPRESData + fr.cnes.icode.fortran77.rules.COMPRESData + COM.PRES.Data + 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/COMFLOWCheckArguments.lex b/fortran77-rules/src/main/resources/lex/COMFLOWCheckArguments.lex new file mode 100644 index 00000000..cc9ec489 --- /dev/null +++ b/fortran77-rules/src/main/resources/lex/COMFLOWCheckArguments.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 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. */ +/* */ +/***************************************************************************************/ +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 COMFLOWCheckArguments +%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 COMFLOWCheckArguments(){ + } + + @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 > 5) { + this.setError(location,"This procedure contains more than 5 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/main/resources/lex/COMMETComplexitySimplified.lex b/fortran77-rules/src/main/resources/lex/COMMETComplexitySimplified.lex new file mode 100644 index 00000000..7f289334 --- /dev/null +++ b/fortran77-rules/src/main/resources/lex/COMMETComplexitySimplified.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 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. */ +/* */ +/********************************************************************************************/ +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 COMMETComplexitySimplified +%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 COMMETComplexitySimplified(){ + } + + @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 > 20 ) { + setError(location,"The cyclomatic complexity of this function is more than 20: " +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/main/resources/lex/COMMETLineOfCode.lex b/fortran77-rules/src/main/resources/lex/COMMETLineOfCode.lex new file mode 100644 index 00000000..56533dd2 --- /dev/null +++ b/fortran77-rules/src/main/resources/lex/COMMETLineOfCode.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 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. */ +/* */ +/***********************************************************************************/ + +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 COMMETLineOfCode +%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 COMMETLineOfCode(){ + } + + @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 > 100 ) { + this.setError(location,"This procedure contains more than 100 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/main/resources/lex/COMMETRatioComment.lex b/fortran77-rules/src/main/resources/lex/COMMETRatioComment.lex new file mode 100644 index 00000000..4e3a0ff1 --- /dev/null +++ b/fortran77-rules/src/main/resources/lex/COMMETRatioComment.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 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. */ +/* */ +/****************************************************************************************/ + +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 COMMETRatioComment +%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 COMMETRatioComment(){ + } + + @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 < 20.00) { + setError(location,"There are less than 20% 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/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/fortran77-rules/src/main/resources/lex/COMPRESData.lex b/fortran77-rules/src/main/resources/lex/COMPRESData.lex new file mode 100644 index 00000000..3b909a78 --- /dev/null +++ b/fortran77-rules/src/main/resources/lex/COMPRESData.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 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. */ +/* */ +/*****************************************************************************/ + +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 COMPRESData +%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 COMPRESData(){ + } + + @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/main/resources/lex/COMPRESFileLength.lex b/fortran77-rules/src/main/resources/lex/COMPRESFileLength.lex new file mode 100644 index 00000000..f1c6f16a --- /dev/null +++ b/fortran77-rules/src/main/resources/lex/COMPRESFileLength.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.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. */ +/* */ +/********************************************************************************/ +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 COMPRESFileLength +%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; + + public COMPRESFileLength(){ + } + + @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 {yybegin(NEW_LINE);} + . {} + } +/*************************/ +/* INLINE_COMMENT STATE */ +/*************************/ + + { + \n {codeLines++; yybegin(NEW_LINE);} + . {} + } +/************************/ +/* AVOID STATE */ +/************************/ + \n {codeLines++; yybegin(NEW_LINE);} + . {} +/************************/ +/* NAMING STATE */ +/************************/ + + { + {VAR} {location = location + " " + yytext(); yybegin(AVOID);} + \n {codeLines++; yybegin(NEW_LINE);} + . {} + } +/************************/ +/* YYINITIAL STATE */ +/************************/ + + { + {COMMENT_WORD} {yybegin(COMMENT);} + {STRING} {yybegin(LINE);} + {TYPE} {location = yytext(); yybegin(NAMING);} + {SPACE} {} + \n {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 {yybegin(NEW_LINE);} + . {yybegin(LINE);} + } +/************************/ +/* LINE STATE */ +/************************/ + + { + {FREE_COMMENT} {yybegin(INLINE_COMMENT);} + {STRING} {} + {TYPE} {location = yytext(); yybegin(NAMING);} + {CLOSING} {} + {END} {yybegin(AVOID);} + {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/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/fortran77-rules/src/main/resources/lex/F77DESIGNLogicUnit.lex b/fortran77-rules/src/main/resources/lex/F77DESIGNLogicUnit.lex new file mode 100644 index 00000000..ca96f5f0 --- /dev/null +++ b/fortran77-rules/src/main/resources/lex/F77DESIGNLogicUnit.lex @@ -0,0 +1,203 @@ +/************************************************************************************************/ +/* 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. */ +/* 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. */ +/* */ +/*****************************************************************************/ + +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/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/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/java/fr/cnes/icode/fortran77/rules/TestFortran77RulesDefinition.java b/fortran77-rules/src/test/java/fr/cnes/icode/fortran77/rules/TestFortran77RulesDefinition.java index 15dff4c2..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(57, rulesDefinition.list().size()); + Assertions.assertEquals(65, rulesDefinition.list().size()); } } 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/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/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/main/resources/fortran90-rules.xml b/fortran90-rules/src/main/resources/fortran90-rules.xml index 6c2918b8..ef6993ad 100644 --- a/fortran90-rules/src/main/resources/fortran90-rules.xml +++ b/fortran90-rules/src/main/resources/fortran90-rules.xml @@ -378,4 +378,52 @@ F90.TYPE.Real fr.cnes.icode.fortran90 - \ No newline at end of file + + fr.cnes.icode.fortran90.rules.COMPRESFileLength + fr.cnes.icode.fortran90.rules.COMPRESFileLength + COM.PRES.FileLength + fr.cnes.icode.fortran90 + + + fr.cnes.icode.fortran90.rules.COMMETLineOfCode + fr.cnes.icode.fortran90.rules.COMMETLineOfCode + COM.MET.LineOfCode + fr.cnes.icode.fortran90 + + + fr.cnes.icode.fortran90.rules.COMFLOWCheckArguments + fr.cnes.icode.fortran90.rules.COMFLOWCheckArguments + COM.FLOW.CheckArguments + fr.cnes.icode.fortran90 + + + fr.cnes.icode.fortran90.rules.COMMETComplexitySimplified + fr.cnes.icode.fortran90.rules.COMMETComplexitySimplified + COM.MET.ComplexitySimplified + fr.cnes.icode.fortran90 + + + fr.cnes.icode.fortran90.rules.F90DESIGNLogicUnit + fr.cnes.icode.fortran90.rules.F90DESIGNLogicUnit + F90.DESIGN.LogicUnit + fr.cnes.icode.fortran90 + + + fr.cnes.icode.fortran90.rules.COMMETRatioComment + fr.cnes.icode.fortran90.rules.COMMETRatioComment + COM.MET.RatioComment + fr.cnes.icode.fortran90 + + + fr.cnes.icode.fortran90.rules.COMPRESData + fr.cnes.icode.fortran90.rules.COMPRESData + COM.PRES.Data + 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/COMFLOWCheckArguments.lex b/fortran90-rules/src/main/resources/lex/COMFLOWCheckArguments.lex new file mode 100644 index 00000000..de5c8482 --- /dev/null +++ b/fortran90-rules/src/main/resources/lex/COMFLOWCheckArguments.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 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. */ +/* */ +/***************************************************************************************/ + +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 COMFLOWCheckArguments +%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 COMFLOWCheckArguments(){ + } + + @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 > 5) { + this.setError(location,"This procedure contains more than 5 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/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);} . {} diff --git a/fortran90-rules/src/main/resources/lex/COMMETComplexitySimplified.lex b/fortran90-rules/src/main/resources/lex/COMMETComplexitySimplified.lex new file mode 100644 index 00000000..59da09dd --- /dev/null +++ b/fortran90-rules/src/main/resources/lex/COMMETComplexitySimplified.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.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. */ +/* */ +/********************************************************************************************/ +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 COMMETComplexitySimplified +%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 COMMETComplexitySimplified(){ + } + + @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 > 20 ) { + setError(location,"The cyclomatic complexity of this function is more than 20: " +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/main/resources/lex/COMMETLineOfCode.lex b/fortran90-rules/src/main/resources/lex/COMMETLineOfCode.lex new file mode 100644 index 00000000..7594e776 --- /dev/null +++ b/fortran90-rules/src/main/resources/lex/COMMETLineOfCode.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 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. */ +/* */ +/***********************************************************************************/ + +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 COMMETLineOfCode +%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 COMMETLineOfCode(){ + } + + @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 > 100 ) { + this.setError(location,"This procedure contains more than 100 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/main/resources/lex/COMMETRatioComment.lex b/fortran90-rules/src/main/resources/lex/COMMETRatioComment.lex new file mode 100644 index 00000000..056da03a --- /dev/null +++ b/fortran90-rules/src/main/resources/lex/COMMETRatioComment.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 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. */ +/* */ +/****************************************************************************************/ + +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 COMMETRatioComment +%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 COMMETRatioComment(){ + } + + @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 < 20.00) { + setError(location,"There are less than 20% 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/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}*")" | diff --git a/fortran90-rules/src/main/resources/lex/COMPRESData.lex b/fortran90-rules/src/main/resources/lex/COMPRESData.lex new file mode 100644 index 00000000..fbdc7d7e --- /dev/null +++ b/fortran90-rules/src/main/resources/lex/COMPRESData.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 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. */ +/* */ +/*****************************************************************************/ + +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 COMPRESData +%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 COMPRESData(){ + } + + @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/main/resources/lex/COMPRESFileLength.lex b/fortran90-rules/src/main/resources/lex/COMPRESFileLength.lex new file mode 100644 index 00000000..dd34aee9 --- /dev/null +++ b/fortran90-rules/src/main/resources/lex/COMPRESFileLength.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 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. */ +/* */ +/********************************************************************************/ +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 COMPRESFileLength +%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; + + public COMPRESFileLength(){ + } + + @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 {yybegin(NEW_LINE);} + . {} + } +/*************************/ +/* INLINE_COMMENT STATE */ +/*************************/ + + { + \n {codeLines++; yybegin(NEW_LINE);} + . {} + } +/************************/ +/* AVOID STATE */ +/************************/ + \n {codeLines++; yybegin(NEW_LINE);} + . {} +/************************/ +/* NAMING STATE */ +/************************/ + + { + {VAR} {location = location + " " + yytext(); yybegin(AVOID);} + \n {codeLines++; yybegin(NEW_LINE);} + . {} + } +/************************/ +/* YYINITIAL STATE */ +/************************/ + + { + {COMMENT_WORD} {yybegin(COMMENT);} + {STRING} {yybegin(LINE);} + {TYPE} {location = yytext(); yybegin(NAMING);} + {SPACE} {} + \n {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 {yybegin(NEW_LINE);} + . {yybegin(LINE);} + } +/************************/ +/* LINE STATE */ +/************************/ + + { + {COMMENT_WORD} {yybegin(INLINE_COMMENT);} + {STRING} {} + {TYPE} {location = yytext(); yybegin(NAMING);} + {CLOSING} {} + {END} {yybegin(AVOID);} + {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/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"); + } + } } %} 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..f0d8d460 --- /dev/null +++ b/fortran90-rules/src/main/resources/lex/F90DESIGNLogicUnit.lex @@ -0,0 +1,203 @@ +/************************************************************************************************/ +/* 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. */ +/* 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. */ +/* */ +/*****************************************************************************/ + +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/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/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/java/fr/cnes/icode/fortran90/rules/TestFortran90RulesDefinition.java b/fortran90-rules/src/test/java/fr/cnes/icode/fortran90/rules/TestFortran90RulesDefinition.java index ead30a86..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(63, rulesDefinition.list().size()); + Assertions.assertEquals(71, rulesDefinition.list().size()); } } 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 From ff95ef2cc3b820a476038206ab64694a0c8351f1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 15 Jan 2025 10:31:32 +0100 Subject: [PATCH 2/4] Bump ant from 1.10.4 to 1.10.11 in /icode-app (#218) Bumps ant from 1.10.4 to 1.10.11. --- updated-dependencies: - dependency-name: org.apache.ant:ant dependency-type: direct:production ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- icode-app/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/icode-app/pom.xml b/icode-app/pom.xml index 3e6bb8d3..0cd0359a 100644 --- a/icode-app/pom.xml +++ b/icode-app/pom.xml @@ -36,7 +36,7 @@ org.apache.ant ant - 1.10.4 + 1.10.11 fr.cnes.icode From c5f663f79407225cbd31ddd87a268e242cd6d0cb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 15 Jan 2025 10:31:45 +0100 Subject: [PATCH 3/4] Bump org.json:json from 20190722 to 20231013 in /icode-core (#241) Bumps [org.json:json](https://github.com/douglascrockford/JSON-java) from 20190722 to 20231013. - [Release notes](https://github.com/douglascrockford/JSON-java/releases) - [Changelog](https://github.com/stleary/JSON-java/blob/master/docs/RELEASES.md) - [Commits](https://github.com/douglascrockford/JSON-java/commits) --- updated-dependencies: - dependency-name: org.json:json dependency-type: direct:production ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- icode-core/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/icode-core/pom.xml b/icode-core/pom.xml index a7cb93f7..0481f3b0 100644 --- a/icode-core/pom.xml +++ b/icode-core/pom.xml @@ -34,7 +34,7 @@ org.json json - 20190722 + 20231013 From 6c840d10da3a02626158345cc967047028166eaa Mon Sep 17 00:00:00 2001 From: Louis MARTIN Date: Wed, 15 Jan 2025 10:37:22 +0100 Subject: [PATCH 4/4] Bump to version 5.1.0 --- README.md | 4 ++++ icode-ide/fr.cnes.analysis.tools.ui/META-INF/MANIFEST.MF | 4 ++-- icode-ide/fr.cnes.analysis.tools.ui/pom.xml | 2 +- icode-ide/fr.cnes.icode.feature.ui/feature.xml | 2 +- icode-ide/fr.cnes.icode.feature.ui/pom.xml | 2 +- icode-ide/fr.cnes.icode.repository/category.xml | 4 ++-- icode-ide/fr.cnes.icode.repository/icode-ide.product | 4 ++-- icode-ide/fr.cnes.icode.repository/pom.xml | 4 ++-- icode-ide/fr.cnes.icode.tp/pom.xml | 2 +- icode-ide/icode-library-feature/feature.xml | 2 +- icode-ide/icode-library-feature/pom.xml | 2 +- icode-ide/icode-library-plugin/META-INF/MANIFEST.MF | 2 +- icode-ide/icode-library-plugin/pom.xml | 2 +- icode-ide/pom.xml | 2 +- pom.xml | 2 +- 15 files changed, 22 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 374f135d..0807e68a 100644 --- a/README.md +++ b/README.md @@ -81,6 +81,10 @@ If you need to add some new feature, the easiest way is to implment your own plu ## Changelog +#### Release 5.1.0 +- Includes fixes from Eumetsat (thanks for your contribution!) +- Includes security fixes from dependabot + #### Release 5.0.0 - Remove shell support diff --git a/icode-ide/fr.cnes.analysis.tools.ui/META-INF/MANIFEST.MF b/icode-ide/fr.cnes.analysis.tools.ui/META-INF/MANIFEST.MF index 6dbc375e..bc49e08e 100755 --- a/icode-ide/fr.cnes.analysis.tools.ui/META-INF/MANIFEST.MF +++ b/icode-ide/fr.cnes.analysis.tools.ui/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: i-Code CNES UI Bundle-SymbolicName: fr.cnes.analysis.tools.ui;singleton:=true -Bundle-Version: 5.0.0 +Bundle-Version: 5.1.0 Bundle-Activator: fr.cnes.analysis.tools.ui.Activator Require-Bundle: org.eclipse.core.runtime;bundle-version="3.11.0", org.eclipse.ui;bundle-version="3.107.0", @@ -16,7 +16,7 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="3.11.0", org.eclipse.ui.editors;bundle-version="3.9.0", org.eclipse.e4.core.di;bundle-version="1.6.0", org.eclipse.jface, - icode.library.plugin;bundle-version="5.0.0" + icode.library.plugin;bundle-version="5.1.0" Bundle-ActivationPolicy: lazy Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Export-Package: fr.cnes.analysis.tools.ui.exception, diff --git a/icode-ide/fr.cnes.analysis.tools.ui/pom.xml b/icode-ide/fr.cnes.analysis.tools.ui/pom.xml index 42f27986..2df1af75 100644 --- a/icode-ide/fr.cnes.analysis.tools.ui/pom.xml +++ b/icode-ide/fr.cnes.analysis.tools.ui/pom.xml @@ -6,7 +6,7 @@ fr.cnes.icode icode-ide - 5.0.0 + 5.1.0 fr.cnes.analysis.tools.ui diff --git a/icode-ide/fr.cnes.icode.feature.ui/feature.xml b/icode-ide/fr.cnes.icode.feature.ui/feature.xml index 43d77d2a..2e3cc2f9 100644 --- a/icode-ide/fr.cnes.icode.feature.ui/feature.xml +++ b/icode-ide/fr.cnes.icode.feature.ui/feature.xml @@ -2,7 +2,7 @@ diff --git a/icode-ide/fr.cnes.icode.feature.ui/pom.xml b/icode-ide/fr.cnes.icode.feature.ui/pom.xml index 0499153b..331392c1 100644 --- a/icode-ide/fr.cnes.icode.feature.ui/pom.xml +++ b/icode-ide/fr.cnes.icode.feature.ui/pom.xml @@ -6,7 +6,7 @@ fr.cnes.icode icode-ide - 5.0.0 + 5.1.0 fr.cnes.icode.feature.ui diff --git a/icode-ide/fr.cnes.icode.repository/category.xml b/icode-ide/fr.cnes.icode.repository/category.xml index 96eba9e8..9ab4b4a9 100755 --- a/icode-ide/fr.cnes.icode.repository/category.xml +++ b/icode-ide/fr.cnes.icode.repository/category.xml @@ -1,7 +1,7 @@ - + diff --git a/icode-ide/fr.cnes.icode.repository/icode-ide.product b/icode-ide/fr.cnes.icode.repository/icode-ide.product index 78bdda8b..881d83a0 100644 --- a/icode-ide/fr.cnes.icode.repository/icode-ide.product +++ b/icode-ide/fr.cnes.icode.repository/icode-ide.product @@ -1,7 +1,7 @@ - + @@ -69,7 +69,7 @@ - + diff --git a/icode-ide/fr.cnes.icode.repository/pom.xml b/icode-ide/fr.cnes.icode.repository/pom.xml index b6638fb0..f4f8b5a9 100644 --- a/icode-ide/fr.cnes.icode.repository/pom.xml +++ b/icode-ide/fr.cnes.icode.repository/pom.xml @@ -6,11 +6,11 @@ fr.cnes.icode icode-ide - 5.0.0 + 5.1.0 fr.cnes.icode.repository - 5.0.0 + 5.1.0 eclipse-repository diff --git a/icode-ide/fr.cnes.icode.tp/pom.xml b/icode-ide/fr.cnes.icode.tp/pom.xml index 042485bf..07757204 100644 --- a/icode-ide/fr.cnes.icode.tp/pom.xml +++ b/icode-ide/fr.cnes.icode.tp/pom.xml @@ -5,7 +5,7 @@ fr.cnes.icode icode-ide - 5.0.0 + 5.1.0 fr.cnes.icode.tp diff --git a/icode-ide/icode-library-feature/feature.xml b/icode-ide/icode-library-feature/feature.xml index 78c7c855..4f1a0b67 100644 --- a/icode-ide/icode-library-feature/feature.xml +++ b/icode-ide/icode-library-feature/feature.xml @@ -2,7 +2,7 @@ diff --git a/icode-ide/icode-library-feature/pom.xml b/icode-ide/icode-library-feature/pom.xml index 02a3d083..5175ffbc 100644 --- a/icode-ide/icode-library-feature/pom.xml +++ b/icode-ide/icode-library-feature/pom.xml @@ -6,7 +6,7 @@ fr.cnes.icode icode-ide - 5.0.0 + 5.1.0 icode.library.feature diff --git a/icode-ide/icode-library-plugin/META-INF/MANIFEST.MF b/icode-ide/icode-library-plugin/META-INF/MANIFEST.MF index b5aa7cf9..9847c953 100644 --- a/icode-ide/icode-library-plugin/META-INF/MANIFEST.MF +++ b/icode-ide/icode-library-plugin/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: i-Code Library Plugin Bundle-SymbolicName: icode.library.plugin;singleton:=true -Bundle-Version: 5.0.0 +Bundle-Version: 5.1.0 Bundle-ClassPath: target/lib/icode-library.jar Bundle-Vendor: CNES Export-Package: com.google.common.annotations, diff --git a/icode-ide/icode-library-plugin/pom.xml b/icode-ide/icode-library-plugin/pom.xml index cb3a47c8..88f90776 100644 --- a/icode-ide/icode-library-plugin/pom.xml +++ b/icode-ide/icode-library-plugin/pom.xml @@ -6,7 +6,7 @@ fr.cnes.icode icode-ide - 5.0.0 + 5.1.0 icode.library.plugin diff --git a/icode-ide/pom.xml b/icode-ide/pom.xml index def89300..78d79661 100644 --- a/icode-ide/pom.xml +++ b/icode-ide/pom.xml @@ -11,7 +11,7 @@ icode-ide - 5.0.0 + 5.1.0 pom i-Code CNES IDE diff --git a/pom.xml b/pom.xml index c35cac38..d8fa66fa 100644 --- a/pom.xml +++ b/pom.xml @@ -66,7 +66,7 @@ - 5.0.0 + 5.1.0 UTF-8 UTF-8 1.8