New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
DoMacro_rename.sh on Ticket #2366 – Attachment – NEMO

Ticket #2366: DoMacro_rename.sh

File DoMacro_rename.sh, 2.4 KB (added by acc, 4 years ago)

Corrected script to replace DO loop macros with Italo's macro function versions.

Line 
1#!/bin/bash
2#
3#
4 INVARS=( DO_2D_00_00      DO_2D_00_01      DO_2D_00_10      DO_2D_00_11     \
5          DO_2D_01_00      DO_2D_01_01      DO_2D_01_10      DO_2D_01_11     \
6          DO_2D_10_00      DO_2D_10_01      DO_2D_10_10      DO_2D_10_11     \
7          DO_2D_11_00      DO_2D_11_01      DO_2D_11_10      DO_2D_11_11     \
8         'DO_3D_00_00\('  'DO_3D_00_01\('  'DO_3D_00_10\('  'DO_3D_00_11\('  \
9         'DO_3D_01_00\('  'DO_3D_01_01\('  'DO_3D_01_10\('  'DO_3D_01_11\('  \
10         'DO_3D_10_00\('  'DO_3D_10_01\('  'DO_3D_10_10\('  'DO_3D_10_11\('  \
11         'DO_3D_11_00\('  'DO_3D_11_01\('  'DO_3D_11_10\('  'DO_3D_11_11\('  \
12         'DO_3DS_00_00\(' 'DO_3DS_00_01\(' 'DO_3DS_00_10\(' 'DO_3DS_00_11\(' \
13         'DO_3DS_01_00\(' 'DO_3DS_01_01\(' 'DO_3DS_01_10\(' 'DO_3DS_01_11\(' \
14         'DO_3DS_10_00\(' 'DO_3DS_10_01\(' 'DO_3DS_10_10\(' 'DO_3DS_10_11\(' \
15         'DO_3DS_11_00\(' 'DO_3DS_11_01\(' 'DO_3DS_11_10\(' 'DO_3DS_11_11\(' \
16         )
17 OUTVARS=( 'DO_2D( 0, 0, 0, 0 )' 'DO_2D( 0, 0, 0, 1 )' 'DO_2D( 0, 0, 1, 0 )' 'DO_2D( 0, 0, 1, 1 )' \
18           'DO_2D( 0, 1, 0, 0 )' 'DO_2D( 0, 1, 0, 1 )' 'DO_2D( 0, 1, 1, 0 )' 'DO_2D( 0, 1, 1, 1 )' \
19           'DO_2D( 1, 0, 0, 0 )' 'DO_2D( 1, 0, 0, 1 )' 'DO_2D( 1, 0, 1, 0 )' 'DO_2D( 1, 0, 1, 1 )' \
20           'DO_2D( 1, 1, 0, 0 )' 'DO_2D( 1, 1, 0, 1 )' 'DO_2D( 1, 1, 1, 0 )' 'DO_2D( 1, 1, 1, 1 )' \
21           'DO_3D( 0, 0, 0, 0,'  'DO_3D( 0, 0, 0, 1,'  'DO_3D( 0, 0, 1, 0,'  'DO_3D( 0, 0, 1, 1,'  \
22           'DO_3D( 0, 1, 0, 0,'  'DO_3D( 0, 1, 0, 1,'  'DO_3D( 0, 1, 1, 0,'  'DO_3D( 0, 1, 1, 1,'  \
23           'DO_3D( 1, 0, 0, 0,'  'DO_3D( 1, 0, 0, 1,'  'DO_3D( 1, 0, 1, 0,'  'DO_3D( 1, 0, 1, 1,'  \
24           'DO_3D( 1, 1, 0, 0,'  'DO_3D( 1, 1, 0, 1,'  'DO_3D( 1, 1, 1, 0,'  'DO_3D( 1, 1, 1, 1,'  \
25           'DO_3DS( 0, 0, 0, 0,' 'DO_3DS( 0, 0, 0, 1,' 'DO_3DS( 0, 0, 1, 0,' 'DO_3DS( 0, 0, 1, 1,' \
26           'DO_3DS( 0, 1, 0, 0,' 'DO_3DS( 0, 1, 0, 1,' 'DO_3DS( 0, 1, 1, 0,' 'DO_3DS( 0, 1, 1, 1,' \
27           'DO_3DS( 1, 0, 0, 0,' 'DO_3DS( 1, 0, 0, 1,' 'DO_3DS( 1, 0, 1, 0,' 'DO_3DS( 1, 0, 1, 1,' \
28           'DO_3DS( 1, 1, 0, 0,' 'DO_3DS( 1, 1, 0, 1,' 'DO_3DS( 1, 1, 1, 0,' 'DO_3DS( 1, 1, 1, 1,' \
29           )
30#
31for file in $*
32do
33  echo "Working on file $file"
34  n=0
35  for n in `seq 0 1 $(( ${#INVARS[*]} - 1 ))`
36  do
37    export IN=${INVARS[$n]}
38    export OUT=${OUTVARS[$n]}
39    perl -0777 -pi -e 's@(\s*)$ENV{'IN'}@\1$ENV{'OUT'}@g'  $file
40  done
41done
42
43exit 0