Last change
on this file since 4235 was
4203,
checked in by dubos, 6 years ago
|
simple_physics : cleanup Mellor & Yamada
|
-
Property svn:executable set to
*
|
File size:
986 bytes
|
Rev | Line | |
---|
[4202] | 1 | #!/bin/bash |
---|
| 2 | |
---|
| 3 | echo <<EOF |
---|
| 4 | usage : replace_keyword file1 file2 ... |
---|
| 5 | This script replaces lowercase Fortran keywords by uppercase |
---|
| 6 | User is asked for confirmation before overwriting original file. |
---|
| 7 | This script is basic and you should check results as corner cases are not handled. |
---|
| 8 | EOF |
---|
| 9 | |
---|
| 10 | function replace_key() |
---|
| 11 | { |
---|
[4203] | 12 | LOW="$1" |
---|
| 13 | UP="$2" |
---|
[4202] | 14 | sed -i -e "s/\b${LOW}\b/${UP}/g" $3 |
---|
| 15 | } |
---|
| 16 | |
---|
| 17 | function replace() |
---|
| 18 | { |
---|
| 19 | ORIG=$1 |
---|
| 20 | NEW=$1.new |
---|
| 21 | cp -f $ORIG $NEW |
---|
| 22 | # enddo => ENDDO |
---|
| 23 | replace_key subroutine SUBROUTINE $NEW |
---|
[4203] | 24 | replace_key 'do i=' 'DO i=' $NEW |
---|
| 25 | replace_key 'do k=' 'DO k=' $NEW |
---|
| 26 | replace_key 'end do' 'END DO' $NEW |
---|
| 27 | replace_key 'parameter' 'PARAMETER' $NEW |
---|
| 28 | replace_key 'integer' 'INTEGER' $NEW |
---|
| 29 | replace_key 'real' 'REAL' $NEW |
---|
| 30 | replace_key 'then' 'THEN' $NEW |
---|
| 31 | replace_key 'else' 'ELSE' $NEW |
---|
| 32 | replace_key 'endif' 'END IF' $NEW |
---|
| 33 | replace_key 'end if' 'END IF' $NEW |
---|
[4202] | 34 | diff $NEW $ORIG |
---|
| 35 | cp -i -u $NEW $ORIG |
---|
| 36 | rm -f $NEW |
---|
| 37 | } |
---|
| 38 | |
---|
| 39 | for FILE in $* ; do |
---|
| 40 | replace $FILE |
---|
| 41 | done |
---|
Note: See
TracBrowser
for help on using the repository browser.