source: dynamico_lmdz/simple_physics/bash/replace_keywords.sh @ 4239

Last change on this file since 4239 was 4203, checked in by dubos, 5 years ago

simple_physics : cleanup Mellor & Yamada

  • Property svn:executable set to *
File size: 986 bytes
Line 
1#!/bin/bash
2
3echo <<EOF
4usage : replace_keyword file1 file2 ...
5This script replaces lowercase Fortran keywords by uppercase
6User is asked for confirmation before overwriting original file.
7This script is basic and you should check results as corner cases are not handled.
8EOF
9
10function replace_key()
11{
12    LOW="$1"
13    UP="$2"
14    sed -i -e "s/\b${LOW}\b/${UP}/g" $3
15}
16
17function replace()
18{
19    ORIG=$1
20    NEW=$1.new
21    cp -f $ORIG $NEW
22# enddo => ENDDO
23    replace_key subroutine SUBROUTINE $NEW
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
34    diff $NEW $ORIG
35    cp -i -u $NEW $ORIG
36    rm -f $NEW
37}
38
39for FILE in $* ; do
40    replace $FILE
41done
Note: See TracBrowser for help on using the repository browser.