1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
#!/bin/bash
for inputFile in $*
do
outputFile="$(echo ${inputFile} | sed "s/\.txt$/.inc/")"
lines=$(grep --text "^ *[0-9]\+ \+[0-9]\+ \+[-0-9.^*/]\+.\?$" ${inputFile} | sed "s/^ \+//" | sed "s/[^0-9]$//" | grep -v "^[0-9]\+ \+[0-9]\+ \+0\(\.0\+\)\?$" | sed "s/0\+$//" | awk '{print $1+1" "$2+1" "$3}')
[ -e ${outputFile} ] && rm ${outputFile}
touch ${outputFile}
for i in $(echo -ne "${lines}" | cut -d " " -f 1 | sort -nu)
do
echo -ne " felders[${i}].liKo(\n felders[aktuelleFelder]" >> ${outputFile}
echo -ne "${lines}" | grep "^${i} \+" | sed "s/^[0-9]\+ \+\([0-9]\+\) \+[-0-9.*^/]\+$/,\n felders[\1]/" | tr "\n" ";" | sed "s/;,/,/g" | sed "s/;$//" | tr ";" "\n" | sed "s/felders\[1\]/felders[aktuelleFelder]/g" >> ${outputFile}
echo -ne "${lines}" | grep "^${i} \+" | sed "s/^[0-9]\+ \+[0-9]\+ \+\([-0-9.*^/]\+\)$/,\n \1 * dT/" | tr "\n" ";" | sed "s/,;/,\n/g" | sed "s/;,/,/g" | tr ";" " " | sed "s/ $//" | sed "s/\*10^/E/g" >> ${outputFile}
echo -e "\n );" >> ${outputFile}
echo " felders[${i}].berechneAbleitungen(dX,iDX);" >> ${outputFile}
echo >> ${outputFile}
# echo " if pruefeMaxDT(${i},dTMax,dT,dTMin) then" >> ${outputFile}
# echo " continue;" >> ${outputFile}
echo >> ${outputFile}
done
rest=$[$(wc -l ${inputFile} | cut -d " " -f 1)-$(grep --text -n "^ *k\s\+c\[k].\?$" ${inputFile} | cut -d ":" -f 1)]
lines=$(tail -n${rest} ${inputFile} | sed "s/^ \+//" | sed "s/[^0-9]$//" | grep --text "^[0-9]\+ \+[-0-9.^*/]\+$" | grep -v "^[0-9]\+ \+0\(\.0\+\)\?$" | sed "s/0\+$//" | awk '{print $1+1" "$2}')
echo -e " felders[1-aktuelleFelder].liKo(\n felders[aktuelleFelder]," >> ${outputFile}
echo -e "${lines}" | sed "s/^\([0-9]\+\) \+[-0-9.*^/]\+$/ felders[\1],/" | sed "s/felders\[1\]/felders[aktuelleFelder]/g" >> ${outputFile}
echo -ne "${lines}" | sed "s/^[0-9]\+ \+\([-0-9.*^/]\+\)$/ \1 * dT,/" | tr "\n" "," | sed "s/\([^,]\),$/\1\n );\n/" | sed "s/,,/,\n/g" | sed "s/\*10^/E/g" >> ${outputFile}
done
|