I have a bash script with some functions as below and am wondering if I can use the variables declared in setup in the other functions and in the rest of the bash script.
setup(){
none=0; low=1; medium=2; high=3; debug=4
var1="red"
var2="fred"
}
create_basemap() {
xminBse=$(( $xmin - 2.0 ))
xmaxBse=$(( $xmax + 2.0 ))
zminBse=$(( $zmin - 2.0 ))
zmaxBse=$(( $zmax + 2.0 ))
xpos=0
ypos=0
xpos=$xmin
ypos=$(( $zmax + 1.5 ))
title="Sound speed, c, Mm/min"
xDesc="Distance, x, Mm"
yDesc="Depth, z, Mm"
# Scale attributes xpos=$(( $wtimap + 0.5 ))
ypos=$(( $htimap / 2.0 ))
sclen=$htimap scwid=0.4
# Create the grid
xyz2grd $f.xzc -G$f.grd -I$vdx/$vdz -R$xmin/$xmax/$zmin/$zmax # Create the color palette makecpt -C$color -T$cmin/$cmax/0.005 -Z > $f.cpt
# Create the basemap
wtbmap=$(( $wtimap + 6 ))
htbmap=$(( $htimap + 5 ))
psbasemap -JX$wtbmap/$htbmap -R0/$wtbmap/0/$htbmap -B0 -K > $f.ps
}
create_contour() {
textPosx=`echo $xminBse | awk '{print $1 + 1.2}'`
textPosy=`echo $zmaxBse | awk '{print $1 - 1.2}'`
txt="$textPosx $textPosy 12 0.0 0 BL $fullname"
echo $txt | pstext -JX$wtbmap/$htbmap -R$xminBse/$xmaxBse/$zminBse/$zmaxBse -Wwhite -O -K >> $f.ps
# Display the image
grdimage $f.grd -JX$wtimap/$htimap -R$xmin/$xmax/$zmin/$zmax -C$f.cpt -B$ax:"$xDesc":/$az:"$yDesc"::."$title":WSne -X2.5 -Y2 -O -K >> $f.ps
# Can use units on the contours if needed
units="Mm/min"
units=""
# Annotate contour lines every ${labeldistx} cm
contLabelDist=`echo $wtimap | awk '{print $1/2}'`
contLabelDist="d${contLabelDist}c"
# Include contour lines with annotations
grdcontour $f.grd -C$ctc -JX -A$cta+v+u$units -G$contLabelDist -B -R -O -K >> $f.ps
}