Scripts

From HOPR
Jump to: navigation, search


Script to generate Download tar gz

#!/bin/bash
read -p "Username(svn): " username
echo "=== Existing Version tags:"
svn list svn+ssh://$username@iagpc151.iag.uni-stuttgart.de/usr/local/svnroot/HOPR/tags/homepage/
 
read -p " Choose Version tag (format X.Y, without V!): " TAG
 
 
echo "=== delete old files"
rm -rf HOPR_V$TAG HOPR_V$TAG.tar.gz
echo "=== CHECKOUT"
svn export svn+ssh://$username@iagpc151.iag.uni-stuttgart.de/usr/local/svnroot/HOPR/tags/homepage/V$TAG HOPR_V$TAG
echo "=== ADD HEADER TO .f90 FILES"
cd HOPR_V$TAG
echo "=== DELETE Doxygen files"
rm -r doxygen
echo "=== DELETE converter files"
rm -r converter
echo "=== ADD HOPR logo and DELETE doxygen comments in .f90 files"
echo "!===================================================================================================================================
!           _______     _______    ___________________    ___________________   ___________________                         xX    
!          /      /)   /      /)  /                  /)  /                  /) /                  /)     .xXXXXXXXXx.       X     
!         /      //   /      //  /      _____       //  /      _____       // /      _____       //    .XXXXXXXXXXXXXXXx  .XXXXx  
!        /      //   /      //  /      /)___/      //  /      /)___/      // /      /)___/      //   .XXXXXXXXXXXXXXXXXXXXXXXXXXx 
!       /      //___/      //  /      //   /      //  /      //___/      // /      //___/      //  .XXXXXXXXXXXXXXXXXXXXXXXX´     
!      /                  //  /      //   /      //  /                  // /                  //  .XX\`\`XXXXXXXXXXXXXXXXXX´        
!     /      _____       //  /      //   /      //  /      ____________// /      __      ____//   XX\`  \`XXXXX\`      .X´           
!    /      /)___/      //  /      //   /      //  /      /)___________) /      /)_|    |____)   XX     XXX\`       .´             
!   /      //   /      //  /      //___/      //  /      //             /      //  |    |__     ,X\`    XXX´                       
!  /      //   /      //  /                  //  /      //             /      //   |      /)   ,X\`   .XX´                         
! /______//   /______//  /__________________//  /______//             /______//    |_____//   ,X\`   XX´                           
! )______)    )______)   )__________________)   )______)              )______)     )_____)   xX    XXx
!
!  This file is part of HOPR. Version $TAG.
!
!  HOPR (High Order Preprocessor) is an open-source software for the generation of three-dimensional unstructured high-order meshes.
!  These meshes are needed for high-order methods like Discontinuous Galerkin schemes, Spectral Element Methods or pFEM, if boundary
!  conditions have to be applied at curved domain boundaries.
!  
!  The software was developed in the Numerics Research Group of Prof. Claus-Dieter Munz at the Institute of Aerodynamics and 
!  Gasdynamics at the University Stuttgart. Copyright (C) 2015. For documentation and tutorials, see:  http://www.hopr-project.org/
!
!  HOPR is a free software: you can redistribute it and/or modify it under the terms of the GNU General Public License 
!  as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
! 
!  HOPR is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
!  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
!
!  You should have received a copy of the GNU General Public License along with HOPR;
!  if not, you can find it at: http://www.gnu.org/licenses/gpl.txt
!===================================================================================================================================
"> header.txt
FILELIST=`find . -name *.f90`
for file in $FILELIST
do
cat header.txt |cat - $file > /tmp/out && mv /tmp/out $file
grep -rv '!>' $file > /tmp/out && mv /tmp/out $file
perl -pi -e 's/! \?/!  /g' $file
done
 
#header into makefiles with # comment:
FILELIST=`find . -name 'Makefile*'`
cat header.txt |perl -pi -e 's/!/#/g' > /tmp/out && mv /tmp/out header.txt 
for file in $FILELIST
do
  cat header.txt |cat - $file > /tmp/out && mv /tmp/out $file
done
rm header.txt
 
cd ..
echo "=== TAR HOPR FOLDER"
tar cvzf HOPR_V$TAG'.tar.gz' HOPR_V$TAG

#
 
           _______     _______    ___________________    ___________________   ___________________                         xX    
          /      /)   /      /)  /                  /)  /                  /) /                  /)     .xXXXXXXXXx.       X     
         /      //   /      //  /      _____       //  /      _____       // /      _____       //    .XXXXXXXXXXXXXXXx  .XXXXx  
        /      //   /      //  /      /)___/      //  /      /)___/      // /      /)___/      //   .XXXXXXXXXXXXXXXXXXXXXXXXXXx 
       /      //___/      //  /      //   /      //  /      //___/      // /      //___/      //  .XXXXXXXXXXXXXXXXXXXXXXXX´     
      /                  //  /      //   /      //  /                  // /                  //  .XX``XXXXXXXXXXXXXXXXXX´        
     /      _____       //  /      //   /      //  /      ____________// /      __      ____//   XX`  `XXXXX`      .X´           
    /      /)___/      //  /      //   /      //  /      /)___________) /      /)_|    |____)   XX     XXX`       .´             
   /      //   /      //  /      //___/      //  /      //             /      //  |    |__     ,X`    XXX´                       
  /      //   /      //  /                  //  /      //             /      //   |      /)   ,X`   .XX´                         
 /______//   /______//  /__________________//  /______//             /______//    |_____//   ,X`   XX´                           
 )______)    )______)   )__________________)   )______)              )______)     )_____)   xX    XXx


Doxygen

Neues Parameterfile einfügen

  • als Unterkapitel von der tutorial beschreibungsseite
  • in Caterogy Tutorials List (nicht in Tutorials)

Installation

Entweder:

sudo apt-get install doxygen

oder manuell: Offizielle Seite

Getting Started

Nach der Installation muss zunächst die Konfigurationsdatei in dem HOPR Ordner erstellt werden:

doxygen -g doxyconfig

Anschließend wird die Konfigurationsdatei bearbeitet:

Doxygen Tag Name Tag Setting
PROJECT_NAME HOPR
PROJECT_LOGO HOPR_logo.png
OUTPUT_DIRECTORY /doxygen
OPTIMIZE_FOR_FORTRAN YES
LAYOUT_FILE DoxygenLayout.xml
INPUT src src/output src/basis src/mesh src/readin src/search src/sfc
EXCLUDE src/readin/isovaryingstring.f90
FILE_PATTERNS *.txt *.f *.f90
SOURCE_BROWSER YES
HAVE_DOT YES
CALL_GRAPH YES
CALLER_GRAPH YES
MAX_DOT_GRAPH_DEPTH 1
EXTRACT_ALL YES

Alternativ: Download der Konfigurationsdatei: doxyconfig

Hinweis 1: Zur Erstellung des Caller Graphs wird das Paket "graphviz" benötigt.

Im src-Ordner muss abschließend noch eine Textdatei für die Hauptseite angelegt werden: mainpage.txt

Ausgeführt wird Doxygen dann mit:

doxygen doxyconfig

Die HTML-Dokumentation ist dann unter /doxygen/html/index.html zu finden

Kommentierung in Fortran

Für Fortran wird mit "!>" oder "!<" ein Kommentar begonnen. Mit "!!" oder "!>" kann man mehrzeile Kommentare erstellen.

Bespiel für ein Kommentar:

!> Build the restriction matrix for the aggregation
!! method.
!! @param aggr information about the aggregates
!! @todo Handle special case
subroutine intrestbuild(A,aggr,Restrict,A_ghost)
implicit none
Type(spmtx), intent(in) :: a !< our fine level matrix
type(aggrs), intent(in) :: aggr
Type(spmtx), intent(out) :: restrict !< Our restriction matrix
!...
end subroutine

Quelle: Comment blocks in Fortran

In Fortran kann ein Doxygen-Befehl sowohl mit einem @ als auch mit einem Backslash \ gekennzeichnet werden (in .txt Dateien nur mit einem @).

An dieser Stelle ein ganz kurzer Überblick über die gebräuchlichsten Befehle:

  • @brief - kurze Beschreibung des folgenden Codes
  • @param abc - Beschreibung des Parameters abc einer Funktion
  • @return - Beschreibung des Rückgabewertes einer Funktion
  • @class abc - Beschreibung der Klasse abc
  • @file abc.de - Beschreibung der Datei abc.de

Eine Übersicht über alle Befehle findet sich unter http://www.stack.nl/~dimitri/doxygen/commands.html

Beispiel:

!> \brief
!> Kurze Beschreibung in einem Satz
!> \details 
!> Weiterer Text mit ausführlicher Beschreibung, ... <br>
!> Man kann Latex-Formeln einfügen: \f$ \frac{d\lambda}{dt} , \frac{d\phi}{dt},  \frac{dz}{dt} \f$ und... <br>
!> <p>... <b>HTML </b><BLOCKQUOTE> Code </BLOCKQUOTE><em> verwenden</em>.</p>
!> \par Irgendwas 
!> \author Max Mustermann
!> \version   4.1b
!> \date      2014
!> \copyright GNU Public License
!> \param cg_goto_f Beschreibung des Parameters
!> \param[in] inParam      
!> \param[out] outParam      
!> \return returnValue

Anpassung des Outputs

Um das Layout des HTML Outputs zu ändern, muss zunächst die Datei "DoxygenLayout.xml" erstellt werden:

doxygen -l

Download der angepassten Layout-Datei: DoxygenLayout
In die Konfigurationsdatei wird abschließend der Pfad zu der Layout-Datei eingetragen.

Für tiefergehende Anpassungen im Design und Struktur der Dokumentation müssen die Dateien header.html, footer.html und stylesheet.css erstellt werden:

doxygen -w html header.html footer.html stylesheet.css doxyconfig

Quelle: Customizing the output

Skript zur Erstellung der Doxygen Dokumentation

#!/bin/bash
 
time0=$(date +%s%N | cut -b1-13) #start time
 
#deletes first 2 characters of a line:
cut_it() {
    echo $1 | cut -c 3-
}
 
read -p "Username(svn):" username
 
echo "=== delete old files"
rm -rf HOPR
 
echo "=== CHECKOUT"
svn checkout svn+ssh://$username@iagpc151.iag.uni-stuttgart.de/usr/local/svnroot/preproctool/branches/hopr HOPR
cd HOPR
 
echo "============================================================================================================================" > missing_comment_lines.txt
 
echo "=== delete old version of documentation"
rm -rf documentation/doxygen
 
echo "=== delete INTERFACE/END INTERFACE lines and MODULE PROCEDURE lines"
FILELIST=`find . -name *.f90`
for file in $FILELIST
do
  cp $file $file.bak
  cp $file $file.bak2
  sed '/INTERFACE/Id' $file.bak > $file
  cp $file $file.bak
  sed '/MODULE PROCEDURE/Id' $file.bak > $file
done
 
echo "=== Comments for input and output variables"
 for file in $FILELIST
do
perl -pi -e 's/\(IN\)(.*):: (.*?)! (.*)/\(IN\)$1:: $2! $3\n!> \\param[in] $2\n!> \\verbatim\n!>$3\n!> \\endverbatim/g' $file
perl -pi -e 's/\(OUT\)(.*):: (.*?)! (.*)/\(OUT\)$1:: $2! $3\n!> \\param[out] $2\n!> \\verbatim\n!>$3\n!> \\endverbatim/g' $file
perl -pi -e 's/\(INOUT\)(.*):: (.*?)! (.*)/\(INOUT\)$1:: $2! $3\n!> \\param[inout] $2\n!> \\verbatim\n!>$3\n!> \\endverbatim/g' $file
done
 
echo "=== Comments for MODULE, SUBROUTINE, RECURSIVE SUBROUTINE, FUNCTION, PURE FUNCTION and PROGRAM"
 
name=(SUBROUTINE RECURSIVE MODULE FUNCTION PURE PROGRAM) 
name2=('' ' SUBROUTINE' '' '' ' FUNCTION' '') 
Len_name=${#name[@]} #Number of names
 
#for time calculating:
time_all=0
y=1
z=0
for (( k=0; k<${Len_name}; k++ )); 
do 
	FILELIST2=($(grep -l "^"${name[k]} $FILELIST | sed 's/:.*//')) 
	z=$[$z+${#FILELIST2[@]}]
done
 
for (( k=0; k<${Len_name}; k++ ));
do 
 
echo "=== Comments for "${name[k]}${name2[k]}
echo "====================================================" 
 
FILELIST2=($(grep -l "^"${name[k]} $FILELIST | sed 's/:.*//')) 
Length=${#FILELIST2[@]} #Number of matching files
 
for (( j=0; j<${Length}; j++ ));
do
 
time1=$(date +%s%N | cut -b1-13) #time at begin of loop
 
echo "=== File "$[j+1]" of "$Length" for "${name[k]}${name2[k]}" comments" 
echo "=== Add empty Doxygen comments in "${FILELIST2[j]}" for "${name[k]}${name2[k]}" comments" 
perl -pi -e 's/^'${name[k]}'(.*)\n(.*)/\n!> \\par Purpose:\n!> \\verbatim\n!> ?\n!> \\endverbatim\n'${name[k]}'$1\n/g' ${FILELIST2[j]}
 
echo "=== Read "${FILELIST2[j]}" line by line"
line=()
typeset -i i=0
while read line[$i]
do
  i=i+1
done < ${FILELIST2[j]}
 
Len=${#line[@]} #Number of lines
 
echo "=== Copy "${name[k]}${name2[k]}" comments to doxygen comment lines in "${FILELIST2[j]}
 
for (( i=${Len}; i>=0; i-- ));
do 
if echo ${line[i]} | grep "^"${name[k]} >/dev/null
  then #echo ${name[k]}" in line: "$i
	if echo ${line[i+1]} | grep "!============================================================================================================================" >/dev/null ;then
		if echo ${line[i+2]} | grep "!============================================================================================================================" >/dev/null ;then
		#echo "Missing comment in line "$[i+1]
		echo "Missing comment in line: "$[i+1]". File: "${FILELIST2[j]}"." |cat - missing_comment_lines.txt > /tmp/out && mv /tmp/out missing_comment_lines.txt
		else
		for (( l=3; l<99; l++ ));
		do 	
			if echo ${line[i+l]} | grep "!============================================================================================================================" >/dev/null;then
				if echo ${line[i+l-1]} | grep "^!" >/dev/null;then
					x=0
					for (( m=0; m<(l-3); m++ ));
					do	
						sed -i -e $[i-1]c"!>\n!>" ${FILELIST2[j]} #adds more empty lines if comment is not a one-liner
						x=$[$x+1]
					done
					for (( n=0; n<=(l-3); n++ ));
					do	
						sed -i -e  $[i-1+n]c"!> $(cut_it "${line[i+l+n-1-x]}")" ${FILELIST2[j]} #copies comment to doxygen comment line(s)
					done
				else
					#echo "Missing comment in line "$[i+l-1]
					echo "Missing comment in line: "$[i+l-1]". File: "${FILELIST2[j]}"." |cat - missing_comment_lines.txt > /tmp/out && mv /tmp/out missing_comment_lines.txt
				fi
		break
			else
		continue
			fi
		done	
		fi
	fi
fi
done
 
#for time calculating:
time2=$(date +%s%N | cut -b1-13) #time at end of loop
time_d=$(($time2 - $time1)) 
time_all=$(($time_all+$time_d)) 
time_e=$(($time_all/$y)) 
echo "=== Remaining time:" $((($time_e * ($z - $y))/1000)) "seconds" #time
echo "=== Progress: " $((100*$y / $z))"%" #time
y=$[$y+1] #time
 
echo "====================================================" 
 
done
 
done
 
echo "=== create documentation with modified source files"
doxygen doxyconfig
 
echo "=== undo modification of fortran files"
for file in $FILELIST
do
	cp $file.bak2 $file
	rm $file.bak2
	rm $file.bak
done
 
echo "=== edit files.html and src-html files"
cd documentation/doxygen/html/
 
perl -pi -e 's/class="el" href="headers_8f90.html"/class="el" href="classcgns__header.html"/g' files.html
perl -pi -e 's/<a href="headers_8f90.html"/<a href="classcgns__header.html"/g' headers_8f90_source.html
 
perl -pi -e 's/class="el" href="readin__CGNS__old_8f90.html"/class="el" href="classmod__readin__cgns.html"/g' files.html
perl -pi -e 's/<a href="readin__CGNS__old_8f90.html"/<a href="classmod__readin__cgns.html"/g' readin__CGNS__old_8f90_source.html
 
perl -pi -e 's/class="el" href="(.*)_8f90.html"/class="el" href="classmod__\L$1.html"/g' files.html
 
perl -pi -e 's/class="el" href="classmod__defines.html"/class="el" href="defines_8f90.html"/g' files.html
perl -pi -e 's/class="el" href="classmod__hopr.html"/class="el" href="hopr_8f90.html"/g' files.html
 
cp defines_8f90_source.html defines_8f90_source.html.bak
cp hopr_8f90_source.html hopr_8f90_source.html.bak
 
perl -pi -e 's/<a href="(.*)_8f90.html"/<a href="classmod__\L$1.html"/g' *_8f90_source.html
 
cp defines_8f90_source.html.bak defines_8f90_source.html
cp hopr_8f90_source.html.bak hopr_8f90_source.html
 
rm hopr_8f90_source.html.bak defines_8f90_source.html.bak
 
cd ../../..
 
time3=$(date +%s%N | cut -b1-13) #finish time 
 
echo "=== DONE. TOTAL TIME: "$((($time3 - $time0)/1000))" seconds"
 
line=()
typeset -i i=0
while read line[$i]
do
  i=i+1
done < missing_comment_lines.txt
if echo ${line[0]} | grep "============================================================================================================================" >/dev/null;then
rm missing_comment_lines.txt
else echo "=== Script found missing comment lines!!! Results in HOPR/missing_comment_lines.txt"
fi

Skript zum Auffinden fehlender Kommentare

#!/bin/bash
 
echo "=== Searching for missing comments..."
 
read -p "Name of folder:" folder
cd $folder
 
FILELIST=`find . -name *.f90` 
 
result="comment.txt"
 
echo "============================================================================================================================" > $result
x=0
 
FILELIST_IN=($(grep -l "(IN)" $FILELIST | sed 's/:.*//')) 
Length_IN=${#FILELIST_IN[@]} #Number of files
FILELIST_OUT=($(grep -l "(OUT)" $FILELIST | sed 's/:.*//')) 
Length_OUT=${#FILELIST_OUT[@]} #Number of files
FILELIST_INOUT=($(grep -l "(INOUT)" $FILELIST | sed 's/:.*//')) 
Length_INOUT=${#FILELIST_INOUT[@]} #Number of files
 
echo "====================================================" 
echo "=== input/output variable comments:"
echo "====================================================" 
for (( j=0; j<${Length_INOUT}; j++ ));
	do
	echo "=== File "$[j+1]" of "$Length_INOUT" for input/output variable comments:" 
 
	echo "=== Read "${FILELIST_INOUT[j]}" line by line"
	line=()
	typeset -i i=0
	while read line[$i]
	do
	  i=i+1
	done < ${FILELIST_INOUT[j]}
	Len=${#line[@]} #Number of lines
 
	for (( i=${Len}; i>=0; i-- ));
	do 
	if echo ${line[i]} | grep "(INOUT)" >/dev/null;then
		if echo ${line[i]} | grep "! ?" >/dev/null ;then
			echo ${FILELIST_INOUT[j]}": line "$[i] |cat - $result > /tmp/out && mv /tmp/out $result
			x=$[$x+1]
		fi
	fi
	done
done
echo "Missing input/output variable comments:" |cat - $result > /tmp/out && mv /tmp/out $result
echo "============================================================================================================================"|cat - $result > /tmp/out && mv /tmp/out $result
 
echo "====================================================" 
echo "=== output variable comments:"
echo "====================================================" 
for (( j=0; j<${Length_OUT}; j++ ));
	do
	echo "=== File "$[j+1]" of "$Length_OUT" for output variable comments:" 
 
	echo "=== Read "${FILELIST_OUT[j]}" line by line"
	line=()
	typeset -i i=0
	while read line[$i]
	do
	  i=i+1
	done < ${FILELIST_OUT[j]}
	Len=${#line[@]} #Number of lines
 
	for (( i=${Len}; i>=0; i-- ));
	do 
	if echo ${line[i]} | grep "(OUT)" >/dev/null;then
		if echo ${line[i]} | grep "! ?" >/dev/null ;then
			echo ${FILELIST_OUT[j]}": line "$[i] |cat - $result > /tmp/out && mv /tmp/out $result
			x=$[$x+1]
		fi
	fi
	done
done
echo "Missing output variable comments:" |cat - $result > /tmp/out && mv /tmp/out $result
echo "============================================================================================================================"|cat - $result > /tmp/out && mv /tmp/out $result
 
echo "====================================================" 
echo "=== input variable comments:"
echo "====================================================" 
for (( j=0; j<${Length_IN}; j++ ));
	do
	echo "=== File "$[j+1]" of "$Length_IN" for input variable comments:" 
 
	echo "=== Read "${FILELIST_IN[j]}" line by line"
	line=()
	typeset -i i=0
	while read line[$i]
	do
	  i=i+1
	done < ${FILELIST_IN[j]}
	Len=${#line[@]} #Number of lines
 
	for (( i=${Len}; i>=0; i-- ));
	do 
	if echo ${line[i]} | grep "(IN)" >/dev/null;then
		if echo ${line[i]} | grep "! ?" >/dev/null ;then
			echo ${FILELIST_IN[j]}": line "$[i] |cat - $result > /tmp/out && mv /tmp/out $result
			x=$[$x+1]
		fi
	fi
	done
done
echo "Missing input variable comments:" |cat - $result > /tmp/out && mv /tmp/out $result
echo "============================================================================================================================"|cat - $result > /tmp/out && mv /tmp/out $result
 
 
name=(SUBROUTINE RECURSIVE MODULE FUNCTION PURE PROGRAM) 
name2=('' ' SUBROUTINE' '' '' ' FUNCTION' '') 
Len_name=${#name[@]} #Number of names
 
for (( k=0; k<${Len_name}; k++ ));
do
 
#echo "Missing "${name[k]}${name2[k]}" comments:" |cat - $result > /tmp/out && mv /tmp/out $result
#echo "============================================================================================================================"|cat - $result > /tmp/out && mv /tmp/out $result
 
echo "====================================================" 
echo "=== "${name[k]}${name2[k]}" comments:"
echo "====================================================" 
 
FILELIST2=($(grep -l "^"${name[k]} $FILELIST | sed 's/:.*//')) 
Length=${#FILELIST2[@]} #Number of matching files
 
for (( j=0; j<${Length}; j++ ));
do
 
 
echo "=== File "$[j+1]" of "$Length" for "${name[k]}${name2[k]}" comments" 
 
echo "=== Read "${FILELIST2[j]}" line by line"
line=()
typeset -i i=0
while read line[$i]
do
  i=i+1
done < ${FILELIST2[j]}
 
Len=${#line[@]} #Number of lines
 
for (( i=${Len}; i>=0; i-- ));
do 
if echo ${line[i]} | grep "^"${name[k]} >/dev/null
  then #echo ${name[k]}" in line: "$i
	if echo ${line[i+2]} | grep "^! ?" >/dev/null ;then
		echo ${FILELIST2[j]}": line "$[i+2] |cat - $result > /tmp/out && mv /tmp/out $result
		x=$[$x+1]
	fi
fi
done
 
 
echo "====================================================" 
 
done
 
echo "Missing "${name[k]}${name2[k]}" comments:" |cat - $result > /tmp/out && mv /tmp/out $result
echo "============================================================================================================================"|cat - $result > /tmp/out && mv /tmp/out $result
 
 
done
 
echo "============================================================================================================================"|cat - $result > /tmp/out && mv /tmp/out $result
 
#array=($(grep -ch "! ?" $FILELIST | sed 's/:.*//')) 
#perl -MList::Util=sum -l -e 'print sum(@ARGV)' "${array[@]}" |cat - $result > /tmp/out && mv /tmp/out $result
echo "Total missing comments: "$x |cat - $result > /tmp/out && mv /tmp/out $result
echo "=== Results in $folder/"$result
 
line=()
typeset -i i=0
while read line[$i]
do
  i=i+1
done < $result
Len=${#line[@]} #Number of lines
for (( i=${Len}; i>=0; i-- ));
do 
if echo ${line[i]} | grep "Missing" >/dev/null
  then 
	if echo ${line[i+1]} | grep "============================================================================================================================" >/dev/null ;then
		sed -i -e $[i+2]c"No missing comments :)\n============================================================================================================================" $result
		
	fi
fi
done
 
echo "=== DONE"

Skript zum Auffinden fehlerhafter Variablen

#!/bin/bash
 
#delete spaces in an array
space() {
    echo $1 | tr -d ' '
}
 
#deletes last character of a line:
cut_last() {
    echo $1 | rev | cut -c 2- | rev
}
 
read -p "Name of folder:" folder
cd $folder
 
echo "=== Checking structure..."
 
echo "=== Searching variables..."
 
mv src/readin/isovaryingstring.f90 src/readin/isovaryingstring.bak 
#mv src/readintools/isovaryingstring.f90 src/readintools/isovaryingstring.bak
 
FILELIST=`find . -name *.f90` 
 
result="variables.txt"
 
echo "============================================================================================================================" > $result
x=0
 
name=(SUBROUTINE RECURSIVE FUNCTION PURE) 
name2=('' ' SUBROUTINE' '' ' FUNCTION') 
Len_name=${#name[@]} #Number of names
 
for (( k=0; k<${Len_name}; k++ ));
do
 
 
echo "====================================================" 
echo "=== Variables for "${name[k]}${name2[k]}" :"
echo "====================================================" 
 
FILELIST2=($(grep -l "^"${name[k]} $FILELIST | sed 's/:.*//')) 
Length=${#FILELIST2[@]} #Number of matching files
 
for (( j=0; j<${Length}; j++ ));
do
 
 
echo "=== File "$[j+1]" of "$Length" for "${name[k]}${name2[k]}" variables" 
 
echo "=== Read "${FILELIST2[j]}" line by line"
 
line=()
typeset -i i=0
while read line[$i]
do
  i=i+1
done < ${FILELIST2[j]}
 
Len=${#line[@]} #Number of lines
 
l_max=${Len}
 
for (( i=${Len}; i>=0; i-- ));
do 
if echo ${line[i]} | grep "^"${name[k]} >/dev/null
  then 	echo ${FILELIST2[j]}": line "$[i] 
 
	if echo ${line[i]} | grep "&$" >/dev/null;then
	line[i]=$(cut_last "${line[i]}")$(space "${line[i+1]}")
	fi
 
	#echo ${line[i]%%"("*")"}  
	line[i]=${line[i]#*"("} 
	line[i]=${line[i]%%")"*}
	echo ${line[i]}	 
	needle=","
	number_of_occurrences=$(grep -o "$needle" <<< "${line[i]}" | wc -l)
	number_of_variables=$[$number_of_occurrences+1]
	echo $number_of_variables" variable(s):"
	IFS=', ' read -a variable <<< "${line[i]}"
	okay=0	    
	for (( m=0; m<=${number_of_occurrences}; m++ )); 
	do
	if [[ ! ${variable[m]} ]];then
	echo "no variables"
	break
	else
		echo ${variable[m]}
		for (( l=${l_max}; l>=$i; l-- ));
		do
			if echo ${line[l+3]} | grep -iw ":: "${variable[m]} >/dev/null || echo ${line[l+3]} | grep -iw ":: .*,"${variable[m]} >/dev/null;then
			#echo "okay: "${line[l+3]}
			okay=1
                                if echo ${line[l+3]} | grep "INTENT(IN)" >/dev/null  || echo ${line[l+3]} | grep "INTENT(OUT)" >/dev/null || echo ${line[l+3]} | grep "INTENT(INOUT)" >/dev/null;then
				echo "good" >/dev/null
				else
					echo "==> "${line[l+3]} |cat - $result > /tmp/out && mv /tmp/out $result 
					echo ${FILELIST2[j]}": line: "$[l+4]" Variable "${variable[m]}". Missing (IN) in "${name[k]}${name2[k]}":" |cat - $result > /tmp/out && mv /tmp/out $result 
				x=$[$x+1]
				fi
			fi
		done
		if (($okay==0)) ;then
		echo ${FILELIST2[j]}": line: "$[i+1]" Variable "${variable[m]}" is not used in "${name[k]}${name2[k]} |cat - $result > /tmp/out && mv /tmp/out $result 
		x=$[$x+1]
		fi
		okay=0	    
	fi
	done
	
l_max=$i
 
fi
 
if  echo ${line[i]} | grep "^SUBROUTINE" >/dev/null  ||  echo ${line[i]} | grep "^RECURSIVE" >/dev/null  ||  echo ${line[i]} | grep "^FUNCTION" >/dev/null  || echo ${line[i]} | grep "^PURE" >/dev/null ||  echo ${line[i]} | grep "^PROGRAM" >/dev/null ||  echo ${line[i]} | grep "^MODULE" >/dev/null ;then
l_max=$i
#echo "l_max= "$i
fi
 
done
 
 
 
done
 
 
echo "============================================================================================================================"|cat - $result > /tmp/out && mv /tmp/out $result
echo "Variables for "${name[k]}${name2[k]}" :" |cat - $result > /tmp/out && mv /tmp/out $result
echo "============================================================================================================================"|cat - $result > /tmp/out && mv /tmp/out $result
 
done
 
echo "============================================================================================================================"|cat - $result > /tmp/out && mv /tmp/out $result
 
#array=($(grep -ch "! ?" $FILELIST | sed 's/:.*//')) 
#perl -MList::Util=sum -l -e 'print sum(@ARGV)' "${array[@]}" |cat - $result > /tmp/out && mv /tmp/out $result
echo "You have to fix "$x" variables." |cat - $result > /tmp/out && mv /tmp/out $result
echo "=== Results in "$folder"/"$result
 
mv src/readin/isovaryingstring.bak src/readin/isovaryingstring.f90 
#mv src/readintools/isovaryingstring.bak src/readintools/isovaryingstring.f90
 
echo "=== DONE"

Skript zum Auffinden fehlerhafter Layouts

#!/bin/bash
 
echo "=== Checking structure..."
 
read -p "Name of folder:" folder
cd $folder
 
mv src/readin/isovaryingstring.f90 src/readin/isovaryingstring.bak 
#mv src/readintools/isovaryingstring.f90 src/readintools/isovaryingstring.bak
 
FILELIST=`find . -name *.f90` 
 
result="structure.txt"
 
echo "============================================================================================================================" > $result
x=0
 
name=(SUBROUTINE RECURSIVE FUNCTION PURE) 
name2=('' ' SUBROUTINE' '' ' FUNCTION')  
Len_name=${#name[@]} #Number of names
 
for (( k=0; k<${Len_name}; k++ ));
do
 
 
echo "====================================================" 
echo "=== Checking structure of "${name[k]}${name2[k]}" :"
echo "====================================================" 
 
FILELIST2=($(grep -l "^"${name[k]} $FILELIST | sed 's/:.*//')) 
Length=${#FILELIST2[@]} #Number of matching files
 
for (( j=0; j<${Length}; j++ ));
do
 
 
echo "=== File "$[j+1]" of "$Length" for "${name[k]}${name2[k]}" variables" 
 
echo "=== Read "${FILELIST2[j]}" line by line"
 
local_variables=0
output_variables=0
input_variables=0
impicit_variables=0
impicit_none=0
modules=0
local_variables_divider=0
output_variables_divider=0
input_variables_divider=0
 
line=()
typeset -i i=0
while read line[$i]
do
  i=i+1
done < ${FILELIST2[j]}
 
Len=${#line[@]} #Number of lines
 
l_max=${Len}
 
for (( i=${Len}; i>=0; i-- ));
do 
if echo ${line[i]} | grep "^"${name[k]} >/dev/null
  then 	
	echo ${FILELIST2[j]}": line "$[i+1]":" 
	echo ${line[i]}	
       
	for (( l=${l_max}; l>=$i; l-- ));
		do		
				if echo ${line[l]} | grep "^! LOCAL VARIABLES" >/dev/null;then
					local_variables=1
					if echo ${line[l-1]} | grep "^!-----------------------------------------------------------------------------------------------------------------------------------" >/dev/null;then
						local_variables_divider=1
					fi	
				fi
	done
	for (( l=${l_max}; l>=$i; l-- ));
		do		
				if echo ${line[l]} | grep "^! OUTPUT VARIABLES" >/dev/null || echo ${line[l]} | grep "^! INPUT.*OUTPUT VARIABLES" >/dev/null ;then
					output_variables=1
					if echo ${line[l-1]} | grep "^!-----------------------------------------------------------------------------------------------------------------------------------" >/dev/null;then
						output_variables_divider=1
					fi
				fi
	done
	for (( l=${l_max}; l>=$i; l-- ));
		do
				if echo ${line[l]} | grep "^! INPUT VARIABLES" >/dev/null || echo ${line[l]} | grep "^! INPUT.*OUTPUT VARIABLES" >/dev/null ;then
					input_variables=1
					if echo ${line[l-1]} | grep "^!-----------------------------------------------------------------------------------------------------------------------------------" >/dev/null;then
						input_variables_divider=1
					fi
				fi
	done
	for (( l=${l_max}; l>=$i; l-- ));
		do		
				if echo ${line[l]} | grep "^! IMPLICIT VARIABLE HANDLING" >/dev/null;then
					impicit_variables=1
				fi
	done
	for (( l=${l_max}; l>=$i; l-- ));
		do		
				if echo ${line[l]} | grep "^IMPLICIT NONE" >/dev/null;then
					impicit_none=1
				fi
	done
	for (( l=${l_max}; l>=$i; l-- ));
		do		
				if echo ${line[l]} | grep "^! MODULES" >/dev/null;then
					modules=1
				fi
	done
 
 
		if (($local_variables==0)) || (($output_variables==0)) || (($input_variables==0)) || (($impicit_variables==0)) || (($modules==0)) || (($impicit_none==0)) || (($local_variables_divider==0)) || (($output_variables_divider==0)) || (($input_variables_divider==0));then
		echo ${FILELIST2[j]}": line: "$[i+1]": Structure of "${name[k]}${name2[k]}" is not correct." |cat - $result > /tmp/out && mv /tmp/out $result 
		x=$[$x+1]
		fi
		local_variables=0
		output_variables=0
		input_variables=0
		impicit_variables=0
		impicit_none=0
		modules=0
		local_variables_divider=0
		output_variables_divider=0
		input_variables_divider=0
 
fi
 
if  echo ${line[i]} | grep "^SUBROUTINE" >/dev/null  ||  echo ${line[i]} | grep "^RECURSIVE" >/dev/null  ||  echo ${line[i]} | grep "^FUNCTION" >/dev/null  || echo ${line[i]} | grep "^PURE" >/dev/null ||  echo ${line[i]} | grep "^PROGRAM" >/dev/null ||  echo ${line[i]} | grep "^MODULE" >/dev/null ;then
l_max=$i
#echo "l_max= "$i
fi
 
done
 
done
 
echo "============================================================================================================================"|cat - $result > /tmp/out && mv /tmp/out $result
echo "Structure of "${name[k]}${name2[k]}" :" |cat - $result > /tmp/out && mv /tmp/out $result
echo "============================================================================================================================"|cat - $result > /tmp/out && mv /tmp/out $result
 
done
 
echo "============================================================================================================================"|cat - $result > /tmp/out && mv /tmp/out $result
 
echo "You have to fix "$x" false structures." |cat - $result > /tmp/out && mv /tmp/out $result
echo "=== Results in $folder/"$result
 
#mv src/readin/isovaryingstring.bak src/readin/isovaryingstring.f90 
#mv src/readintools/isovaryingstring.bak src/readintools/isovaryingstring.f90
 
echo "=== DONE"

Skript zum Löschen der Doxygen Kommentare

#!/bin/sh
 
echo "=== delete Doxygen comments"
cd HOPR
FILELIST=`find . -name *.f90`
for file in $FILELIST
do
grep -rv '^!>' $file > /tmp/out && mv /tmp/out $file
done
cd ..
cd ..
echo "=== DONE"

Nützliche Links