File mttroot/mtt/bin/trans/cr_txt2r artifact fd5454f1e3 part of check-in fc177d09e6


#! /bin/sh

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


# Bourne shell script: cr_txt2r

# Label file to constitutive relationship conversion
# P.J.Gawthrop March 1997
# Copyright (c) P.J.Gawthrop, 1997.

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.14  2002/05/09 15:52:09  gawthrop
## Now uses current cr file is its newer than abg.m
##
## Revision 1.13  2002/04/28 18:41:26  geraint
## Fixed [ 549658 ] awk should be gawk.
## Replaced calls to awk with call to gawk.
##
## Revision 1.12  2002/04/08 17:04:21  geraint
## Removed spurious "\n" from output.
##
## Revision 1.11  2000/08/01 07:34:33  peterg
## Replaced printf by echo
##
## Revision 1.10  2000/02/25 09:10:12  peterg
## Changed -e to -f in if [ -f "$crf" ]; then
##  -- cuased probs on SUN
##
## Revision 1.9  2000/02/16 15:58:17  peterg
## Set level='' not $2
##
## Revision 1.8  1998/11/20 09:48:31  peterg
## Remove the _lower stuff -- see idf this works now.
##
## Revision 1.7  1998/04/14 17:46:28  peterg
## To avoid clashes when creating for more thsan one top level file, adds
## _lower attribute to lower lecel constitutive relationship files.
## .constitutive relationship files only in top level _constitutive
## relationship files.
##
## Revision 1.6  1998/04/14 13:54:15  peterg
## Uses the _sub.sh rep to recursively generate and include sub systems.
##
## Revision 1.5  1998/03/09 13:36:00  peterg
## Cosmetic change
##
## Revision 1.4  1998/03/06 15:54:41  peterg
## Put message bcak in in simpler form
##
## Revision 1.3  1998/03/06 15:51:06  peterg
## Zapped the irritating error message
##
## Revision 1.2  1998/03/04 15:32:53  peterg
## Major revision.
## Now just includes cr files using in"";
## Two sorts of CR:
## 	generic (.cr)
## 	tied to a system (_cr.r)
##
## Revision 1.1  1998/03/04 15:31:14  peterg
## Initial revision
##
# Revision 1.3  1997/04/09  12:59:43  peterg
# Looks for .cr file in current directory - copies from library if they
# don't already exist.
#
# Revision 1.2  1997/04/09  09:25:55  peterg
# Now copies .cr files from linrary to here (if they don't exist
# already).
#
# Revision 1.1  1997/04/09  09:08:12  peterg
# Initial revision
#
###############################################################

# The level of the recursion null at top level; _lower at lower levels.

level='' ## Used to be $2 - now set to null.

abgfile=$1_abg.m
crfile=$1_cr.r
CRFILE=$1_cr.r

if [ -f "$crfile" ]; then
    echo "Using    $crfile"
else
    # Inform user
    echo "Creating $crfile"

    echo "% Constitutive relation file for $1 ($crfile)" > $crfile
    echo "% Generated by MTT at `date`" >> $crfile

    echo  >> $crfile

    # Recursively create subsystem CR files -- at lower level
    sh $1_sub.sh 'cr_txt2r ' ' _lower' 
    
    # Include subsystem CR files
    sh $1_sub.sh 'echo ' "_cr.r" |\
    gawk '{
      print "in \"" $1 "\";"
    }'  >> $crfile

##  if [ -z "$level" ]; then

    # Copy .cr files
    gawk '{
	 if (NF>0) {
         print "mtt -q -u crcopy " $1; 
         }
    }' $1_cr.txt  | sh

    # Include the .cr files
#    gawk '{
#	 if (NF>0) {
#         print "in \"" $1 ".cr\";"
#         }
#    }' $1_cr.txt  >> $crfile

    ## list of the crs
    crs=`cat $1_cr.txt`
    for cr in $crs; do
        crf=$cr'_cr.r'
	if [ -f "$crf" ]; then
##	   printf "\045 (%s exists)\n" $crf >> $crfile
	   echo "% ($crf exists)"  >> $crfile
	else
##	   printf 'in "%s.cr";\n' $cr >> $crfile
	   echo 'in "'$cr.cr'";' >> $crfile
	fi
    done
##  fi
echo 'END;' >> $crfile

fi
# Now invoke the standard error handling.
#mtt_error mtt_error.txt




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