Overview
Comment:Initial revision
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | origin/master | trunk
Files: files | file ages | folders
SHA3-256: 3da332b509ad7f296ee4df0c7c5805577f4029579243c66dc3afc2261e6f4a3d
User & Date: gawthrop@users.sourceforge.net on 1996-08-24 13:34:48
Other Links: branch diff | manifest | tags
Context
1996-08-24
14:02:39
Included glabal parameter passing.
Proper error handling.
check-in: 5ca9342409 user: gawthrop@users.sourceforge.net tags: origin/master, trunk
13:34:48
Initial revision check-in: 3da332b509 user: gawthrop@users.sourceforge.net tags: origin/master, trunk
1996-08-22
18:31:06
Fixed comment bug. check-in: c72ea864d8 user: gawthrop@users.sourceforge.net tags: origin/master, trunk
Changes

Added mttroot/mtt/bin/trans/awk/lbl2sympar.awk version [0eda038fdf].



















































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
###################################### 
##### Model Transformation Tools #####
######################################

# gawk script: lbl2sympar.awk
# Label file to symbolic parameters conversion
# P.J.Gawthrop August 1996
# Copyright (c) P.J.Gawthrop, 1996.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################



function exact_match(name1, name2) {
  return ((match(name1,name2)>0)&&(length(name1)==length(name2)))
    }

function matches(name, names) {
  n = split(names,match_name);
  matched = 0;
  for (i = 1; i <= n; i++) {
    if ( exact_match(name,match_name[i]) ) {
      matched = 1;
      break;
    }
  }
  return matched;
    }


BEGIN {
comment = "%";
arg_delimiter = ",";
not_an_arg = "effort flow internal external zero";
numeric = "[0-9]";
symbol_count = 0;
symbols = "";
}
{
  if ( (match($1,comment)==0) && (NF>=3) ) {
    args = $3;
    n_args = split(args,arg,arg_delimiter);
    for (i = 1; i <= n_args; i++) {
      first_char = substr(arg[i],1,1);
      if ( (matches(not_an_arg,arg[i])==0) \
	   && (match(first_char,numeric)==0) \
	   && (length(arg[i])>0) \
	   && (matches(symbols,arg[i]) ==0) ) {
	symbol_count++;
	symbols = sprintf("%s %s", symbols, arg[i]);
	  }
    }
  }
}
END {
# print the _sympar file
printf("%% Symbolic parameter file - generated by MTT\n\n");
printf("MTTNVar := %1.0f;\n", symbol_count);

if (symbol_count>0) {
  printf("MATRIX MTTVar(MTTNVar,1);\n");
  split(symbols,symbol);
  for (i = 1; i <= symbol_count; i++) {
    printf("MTTVar(%1.0f,1) := %s;\n", i, symbol[i]);
  }
}

}

Added mttroot/mtt/bin/trans/lbl2sympar_txt2r version [371f9991bf].



















































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
34
35
36
37
38
39
40
41
#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

# Bourne shell script: lbl2sympar_txt2r

# Label file to symbolic parameters conversion
# P.J.Gawthrop August 1996
# Copyright (c) P.J.Gawthrop, 1996.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
###############################################################


# Inform user
echo "Creating $1_sympar.r"

rm -f mtt_error

# This is the main transformation using gawk
gawk -f $MTTPATH/lbl2sympar.awk $1_lbl.txt > $1_sympar.r 2>mtt_error

err_length=$(wc -c <mtt_error)

# Test for errors and print if any
if [ $err_length != "0" ]
then
  echo lbl2sympar_txt2 $1 failed '...'
  cat mtt_error
  exit 1
else
  exit 0
fi



MTT: Model Transformation Tools
GitHub | SourceHut | Sourceforge | Fossil RSS ]