#line 1 "pmtexb2.f"
/* pmtexb2.f -- translated by f2c (version 19940615).
   You must link the resulting object file with the libraries:
	f2c.lib math=standard   (in that order)
*/

#include "f2c.h"

#line 1 "pmtexb2.f"
/* Common Block Declarations */

struct {
    integer mult[1000]	/* was [5][200] */, iv, list[800]	/* was [4][
	    200] */, nnl[5], nv, ibar, ipl[1000]	/* was [5][200] */, 
	    ibm1[40]	/* was [5][8] */, ibm2[40]	/* was [5][8] */, 
	    nolev[1000]	/* was [5][200] */, ibmcnt[5], nodur[1000]	/* 
	    was [5][200] */, ncmid[5], jn, lenbar, iccount, nbars, itsofar[5],
	     nib[75]	/* was [5][15] */, nn[5];
    logical rest[1000]	/* was [5][200] */, beamon[5];
    integer lenbar0, lenbar1;
    logical firstline;
    real slfac;
    integer musicsize;
    real stemmax, stemmin, stemlen;
    char acc[1000]	/* was [5][200] */, ul[40]	/* was [5][8] */, hb[
	    40]	/* was [5][8] */, orn[1000]	/* was [5][200] */, fig[1200],
	     sepsym[1], s[1];
} all_;

#define all_1 all_

struct {
    integer ifigdrop[50], iline;
    logical figbass;
} comfig_;

#define comfig_1 comfig_

struct {
    logical lastchar;
} comget_;

#define comget_1 comget_

struct {
    integer lenbeam;
} combeam_;

#define combeam_1 combeam_

struct {
    integer itopfacteur, ibotfacteur, interfacteur, isig;
    real fracindent;
    integer imeter, mtrnum, mtrden, iwaskpt;
    real widthpt, height;
    char iname[120];
} comtop_;

#define comtop_1 comtop_

/* Table of constant values */

static integer c__1 = 1;
static integer c__3 = 3;
static integer c__2 = 2;
static integer c__4 = 4;
static integer c__8 = 8;
static integer c__9 = 9;
static integer c__5 = 5;
static integer c__6 = 6;
static integer c__0 = 0;
static integer c__7 = 7;
static integer c__10 = 10;
static doublereal c_b763 = 2.;

/* cccccccccccccccccccccccccccccc */
/* c                           cc */
/* c  pmtexb.for Version 1.0   cc */
/* c                           cc */
/* cccccccccccccccccccccccccccccc */
/* c */
/* c  file pmtex.inc */
/* c */
/* c      common /all/ mult(5,200),iv,list(4,200),nnl(5),nv,ibar, */
/* c     *   ipl(5,200),ibm1(5,8),ibm2(5,8),nolev(5,200),ibmcnt(5), */
/* c     *   nodur(5,200),ncmid(5),jn,lenbar,iccount,nbars,itsofar(5), */
/* c     *   nib(5,15),nn(5), */
/* c     *   rest(5,200),beamon(5) ,lenbar0,lenbar1,firstline, */
/* c     *   slfac,musicsize,stemmax,stemmin,stemlen */
/* c      common /all/ acc(5,200),ul(5,8),hb(5,8),orn(5,200), */
/* c     *   fig(200),sepsym,s */
/* c      character*6 fig */
/* c      character*1 acc,ul,hb,orn,sepsym,s */
/* c      logical beamon,rest,firstline */
/* c */
/* ccccccccccccccccccccccccccccc */
/* ccccccccccc */
/* c */
/* c  pmtex.inc */
/* c */
/* ccccccccccc */
/* Main program */ MAIN__(void)
{
    /* System generated locals */
    address a__1[2], a__2[3], a__3[8], a__4[4], a__5[4];
    integer i__1[2], i__2, i__3[3], i__4[8], i__5[4], i__6, i__7[4], i__8;
    char ch__1[28], ch__2[68], ch__3[27], ch__4[20], ch__5[6], ch__6[16], 
	    ch__7[10], ch__8[11], ch__9[80];
    olist o__1;
    cllist cl__1;

    /* Builtin functions */
    integer f_open(olist *), s_rsfe(cilist *), do_fio(integer *, char *, 
	    ftnlen), e_rsfe(void), s_rsle(cilist *), do_lio(integer *, 
	    integer *, char *, ftnlen), e_rsle(void);
    /* Subroutine */ int s_cat(char *, char **, integer *, integer *, ftnlen);
    integer i_indx(char *, char *, ftnlen, ftnlen), s_wsfe(cilist *), e_wsfe(
	    void);
    /* Subroutine */ int s_copy(char *, char *, ftnlen, ftnlen);
    integer s_wsle(cilist *), e_wsle(void), s_rsfi(icilist *), e_rsfi(void), 
	    f_clos(cllist *);

    /* Local variables */
    static char clef[1*5];
    static integer ifig;
    extern /* Subroutine */ int makeabar_(void);
    static integer ioff;
    static char line[80], basename[24];
    static logical loop;
    static real xmtrnum0;
    static char pathname[40], autoline[24];
    static integer j, lbase, lpath, iauto, ielperbar, ibarperln;
    static real slfac1;
    static integer ibcoff, ip;
    extern integer ncmidf_(char *, ftnlen);
    static integer noinst, lenbeat, lpp, ibarcnt;
    extern /* Subroutine */ int topfile_(char *, integer *, integer *, char *,
	     integer *, integer *, logical *, ftnlen, ftnlen), getnote_(
	    logical *);
    extern integer ifnodur_(integer *, char *, ftnlen);
    static integer nstaves;

    /* Fortran I/O blocks */
    static cilist io___2 = { 0, 12, 0, "(a)", 0 };
    static cilist io___4 = { 0, 12, 0, 0, 0 };
    static cilist io___6 = { 0, 12, 0, 0, 0 };
    static cilist io___8 = { 0, 10, 0, 0, 0 };
    static cilist io___13 = { 0, 10, 0, "(a24)", 0 };
    static cilist io___14 = { 0, 10, 0, "(a80)", 0 };
    static cilist io___17 = { 0, 10, 0, "(a)", 0 };
    static cilist io___20 = { 0, 13, 0, 0, 0 };
    static cilist io___22 = { 0, 14, 0, "(a)", 0 };
    static cilist io___25 = { 0, 11, 0, "(a)", 0 };
    static cilist io___29 = { 0, 6, 0, 0, 0 };
    static cilist io___30 = { 0, 11, 0, "(a5,i3)", 0 };
    static cilist io___31 = { 0, 11, 0, "(a6)", 0 };
    static cilist io___32 = { 0, 14, 0, "(a16,i2,a10)", 0 };
    static cilist io___33 = { 0, 12, 0, "(a24)", 0 };
    static icilist io___35 = { 0, autoline, 0, "(7x,i2,2x,i2)", 24, 1 };
    static cilist io___38 = { 0, 11, 0, "(a24)", 0 };
    static cilist io___39 = { 0, 12, 0, 0, 0 };
    static cilist io___42 = { 0, 14, 0, "(a16,i2,a10)", 0 };
    static cilist io___43 = { 0, 6, 0, 0, 0 };



/* iccount: pointer in string from input file.  Just before calling getcha
r,*/
/*          it points to the last character retrieved. */
/*  nnl    : # of notes in a line (//) */
/*  itsofar: time in current line from start of line */

#line 40 "pmtexb2.f"
    comtop_1.widthpt = 524.f;
#line 41 "pmtexb2.f"
    comtop_1.iwaskpt = 3;
#line 42 "pmtexb2.f"
    comtop_1.height = 770.f;
#line 43 "pmtexb2.f"
    slfac1 = .00569f;
#line 44 "pmtexb2.f"
    all_1.stemmax = 8.2f;
#line 45 "pmtexb2.f"
    all_1.stemmin = 3.9f;
#line 46 "pmtexb2.f"
    all_1.stemlen = 6.f;
/*  Platform-independent backslash */
#line 48 "pmtexb2.f"
    *all_1.s = '\\';
#line 49 "pmtexb2.f"
    o__1.oerr = 0;
#line 49 "pmtexb2.f"
    o__1.ounit = 12;
#line 49 "pmtexb2.f"
    o__1.ofnmlen = 9;
#line 49 "pmtexb2.f"
    o__1.ofnm = "pmtex.dat";
#line 49 "pmtexb2.f"
    o__1.orl = 0;
#line 49 "pmtexb2.f"
    o__1.osta = 0;
#line 49 "pmtexb2.f"
    o__1.oacc = 0;
#line 49 "pmtexb2.f"
    o__1.ofm = 0;
#line 49 "pmtexb2.f"
    o__1.oblnk = 0;
#line 49 "pmtexb2.f"
    f_open(&o__1);
#line 50 "pmtexb2.f"
    s_rsfe(&io___2);
#line 50 "pmtexb2.f"
    do_fio(&c__1, basename, 24L);
#line 50 "pmtexb2.f"
    e_rsfe();
#line 51 "pmtexb2.f"
    s_rsle(&io___4);
#line 51 "pmtexb2.f"
    do_lio(&c__3, &c__1, (char *)&lbase, (ftnlen)sizeof(integer));
#line 51 "pmtexb2.f"
    e_rsle();
#line 52 "pmtexb2.f"
    s_rsle(&io___6);
#line 52 "pmtexb2.f"
    do_lio(&c__3, &c__1, (char *)&comtop_1.itopfacteur, (ftnlen)sizeof(
#line 52 "pmtexb2.f"
	    integer));
#line 52 "pmtexb2.f"
    do_lio(&c__3, &c__1, (char *)&comtop_1.ibotfacteur, (ftnlen)sizeof(
#line 52 "pmtexb2.f"
	    integer));
#line 52 "pmtexb2.f"
    do_lio(&c__3, &c__1, (char *)&comtop_1.interfacteur, (ftnlen)sizeof(
#line 52 "pmtexb2.f"
	    integer));
#line 52 "pmtexb2.f"
    do_lio(&c__3, &c__1, (char *)&iauto, (ftnlen)sizeof(integer));
#line 52 "pmtexb2.f"
    e_rsle();
#line 53 "pmtexb2.f"
    o__1.oerr = 0;
#line 53 "pmtexb2.f"
    o__1.ounit = 10;
#line 53 "pmtexb2.f"
    o__1.ofnmlen = lbase + 4;
/* Writing concatenation */
#line 53 "pmtexb2.f"
    i__1[0] = lbase, a__1[0] = basename;
#line 53 "pmtexb2.f"
    i__1[1] = 4, a__1[1] = ".inp";
#line 53 "pmtexb2.f"
    s_cat(ch__1, a__1, i__1, &c__2, 28L);
#line 53 "pmtexb2.f"
    o__1.ofnm = ch__1;
#line 53 "pmtexb2.f"
    o__1.orl = 0;
#line 53 "pmtexb2.f"
    o__1.osta = 0;
#line 53 "pmtexb2.f"
    o__1.oacc = 0;
#line 53 "pmtexb2.f"
    o__1.ofm = 0;
#line 53 "pmtexb2.f"
    o__1.oblnk = 0;
#line 53 "pmtexb2.f"
    f_open(&o__1);
#line 54 "pmtexb2.f"
    s_rsle(&io___8);
#line 54 "pmtexb2.f"
    do_lio(&c__3, &c__1, (char *)&all_1.nv, (ftnlen)sizeof(integer));
#line 54 "pmtexb2.f"
    do_lio(&c__3, &c__1, (char *)&noinst, (ftnlen)sizeof(integer));
#line 54 "pmtexb2.f"
    do_lio(&c__3, &c__1, (char *)&comtop_1.mtrnum, (ftnlen)sizeof(integer));
#line 54 "pmtexb2.f"
    do_lio(&c__3, &c__1, (char *)&comtop_1.mtrden, (ftnlen)sizeof(integer));
#line 54 "pmtexb2.f"
    do_lio(&c__3, &c__1, (char *)&comtop_1.imeter, (ftnlen)sizeof(integer));
#line 54 "pmtexb2.f"
    do_lio(&c__4, &c__1, (char *)&xmtrnum0, (ftnlen)sizeof(real));
#line 54 "pmtexb2.f"
    do_lio(&c__3, &c__1, (char *)&comtop_1.isig, (ftnlen)sizeof(integer));
#line 54 "pmtexb2.f"
    do_lio(&c__3, &c__1, (char *)&lpp, (ftnlen)sizeof(integer));
#line 54 "pmtexb2.f"
    do_lio(&c__3, &c__1, (char *)&nstaves, (ftnlen)sizeof(integer));
#line 54 "pmtexb2.f"
    do_lio(&c__3, &c__1, (char *)&all_1.musicsize, (ftnlen)sizeof(integer));
#line 54 "pmtexb2.f"
    do_lio(&c__4, &c__1, (char *)&comtop_1.fracindent, (ftnlen)sizeof(real));
#line 54 "pmtexb2.f"
    e_rsle();

/* imeter = 0 for fraction        noinst = 0  if several voices, 1 inst */
/*          2,3,4  single-digit            nv if separate inst's */
/*          5 for cut time */
/*          6 for common time */

#line 62 "pmtexb2.f"
    i__2 = all_1.nv;
#line 62 "pmtexb2.f"
    for (all_1.iv = 1; all_1.iv <= i__2; ++all_1.iv) {
#line 63 "pmtexb2.f"
	s_rsfe(&io___13);
#line 63 "pmtexb2.f"
	do_fio(&c__1, comtop_1.iname + (all_1.iv - 1) * 24, 24L);
#line 63 "pmtexb2.f"
	e_rsfe();
#line 64 "pmtexb2.f"
/* L6: */
#line 64 "pmtexb2.f"
    }
#line 65 "pmtexb2.f"
    s_rsfe(&io___14);
#line 65 "pmtexb2.f"
    do_fio(&c__1, line, 80L);
#line 65 "pmtexb2.f"
    e_rsfe();
#line 66 "pmtexb2.f"
    i__2 = all_1.nv;
#line 66 "pmtexb2.f"
    for (all_1.iv = 1; all_1.iv <= i__2; ++all_1.iv) {
#line 67 "pmtexb2.f"
	clef[all_1.iv - 1] = line[all_1.iv - 1];
#line 68 "pmtexb2.f"
/* L7: */
#line 68 "pmtexb2.f"
    }
#line 69 "pmtexb2.f"
    s_rsfe(&io___17);
#line 69 "pmtexb2.f"
    do_fio(&c__1, pathname, 40L);
#line 69 "pmtexb2.f"
    e_rsfe();
#line 70 "pmtexb2.f"
    lpath = i_indx(pathname, " ", 40L, 1L) - 1;
#line 71 "pmtexb2.f"
    o__1.oerr = 0;
#line 71 "pmtexb2.f"
    o__1.ounit = 13;
#line 71 "pmtexb2.f"
    o__1.ofnmlen = 9;
#line 71 "pmtexb2.f"
    o__1.ofnm = "pmtex.fig";
#line 71 "pmtexb2.f"
    o__1.orl = 0;
#line 71 "pmtexb2.f"
    o__1.osta = 0;
#line 71 "pmtexb2.f"
    o__1.oacc = 0;
#line 71 "pmtexb2.f"
    o__1.ofm = 0;
#line 71 "pmtexb2.f"
    o__1.oblnk = 0;
#line 71 "pmtexb2.f"
    f_open(&o__1);
#line 72 "pmtexb2.f"
    comfig_1.figbass = FALSE_;
#line 73 "pmtexb2.f"
    s_rsle(&io___20);
#line 73 "pmtexb2.f"
    do_lio(&c__3, &c__1, (char *)&ifig, (ftnlen)sizeof(integer));
#line 73 "pmtexb2.f"
    e_rsle();
#line 74 "pmtexb2.f"
    if (ifig == 1) {
#line 75 "pmtexb2.f"
	comfig_1.figbass = TRUE_;
#line 76 "pmtexb2.f"
	comfig_1.iline = 1;
#line 77 "pmtexb2.f"
	comfig_1.ifigdrop[0] = 4;
#line 78 "pmtexb2.f"
	o__1.oerr = 0;
#line 78 "pmtexb2.f"
	o__1.ounit = 14;
#line 78 "pmtexb2.f"
	o__1.ofnmlen = lpath + lbase + 4;
/* Writing concatenation */
#line 78 "pmtexb2.f"
	i__3[0] = lpath, a__2[0] = pathname;
#line 78 "pmtexb2.f"
	i__3[1] = lbase, a__2[1] = basename;
#line 78 "pmtexb2.f"
	i__3[2] = 4, a__2[2] = ".fig";
#line 78 "pmtexb2.f"
	s_cat(ch__2, a__2, i__3, &c__3, 68L);
#line 78 "pmtexb2.f"
	o__1.ofnm = ch__2;
#line 78 "pmtexb2.f"
	o__1.orl = 0;
#line 78 "pmtexb2.f"
	o__1.osta = 0;
#line 78 "pmtexb2.f"
	o__1.oacc = 0;
#line 78 "pmtexb2.f"
	o__1.ofm = 0;
#line 78 "pmtexb2.f"
	o__1.oblnk = 0;
#line 78 "pmtexb2.f"
	f_open(&o__1);
#line 79 "pmtexb2.f"
	s_wsfe(&io___22);
/* Writing concatenation */
#line 79 "pmtexb2.f"
	i__4[0] = 1, a__3[0] = all_1.s;
#line 79 "pmtexb2.f"
	i__4[1] = 3, a__3[1] = "def";
#line 79 "pmtexb2.f"
	i__4[2] = 1, a__3[2] = all_1.s;
#line 79 "pmtexb2.f"
	i__4[3] = 8, a__3[3] = "fixdrop{";
#line 79 "pmtexb2.f"
	i__4[4] = 1, a__3[4] = all_1.s;
#line 79 "pmtexb2.f"
	i__4[5] = 6, a__3[5] = "ifcase";
#line 79 "pmtexb2.f"
	i__4[6] = 1, a__3[6] = all_1.s;
#line 79 "pmtexb2.f"
	i__4[7] = 6, a__3[7] = "sysno%";
#line 79 "pmtexb2.f"
	s_cat(ch__3, a__3, i__4, &c__8, 27L);
#line 79 "pmtexb2.f"
	do_fio(&c__1, ch__3, 27L);
#line 79 "pmtexb2.f"
	e_wsfe();
#line 81 "pmtexb2.f"
    }
#line 82 "pmtexb2.f"
    comget_1.lastchar = FALSE_;
/*  Bar count offset */
#line 84 "pmtexb2.f"
    ibcoff = 0;
#line 85 "pmtexb2.f"
    if (xmtrnum0 > 0.f) {
#line 85 "pmtexb2.f"
	ibcoff = -1;
#line 85 "pmtexb2.f"
    }
#line 86 "pmtexb2.f"
    o__1.oerr = 0;
#line 86 "pmtexb2.f"
    o__1.ounit = 11;
#line 86 "pmtexb2.f"
    o__1.ofnmlen = lpath + lbase + 4;
/* Writing concatenation */
#line 86 "pmtexb2.f"
    i__3[0] = lpath, a__2[0] = pathname;
#line 86 "pmtexb2.f"
    i__3[1] = lbase, a__2[1] = basename;
#line 86 "pmtexb2.f"
    i__3[2] = 4, a__2[2] = ".tex";
#line 86 "pmtexb2.f"
    s_cat(ch__2, a__2, i__3, &c__3, 68L);
#line 86 "pmtexb2.f"
    o__1.ofnm = ch__2;
#line 86 "pmtexb2.f"
    o__1.orl = 0;
#line 86 "pmtexb2.f"
    o__1.osta = 0;
#line 86 "pmtexb2.f"
    o__1.oacc = 0;
#line 86 "pmtexb2.f"
    o__1.ofm = 0;
#line 86 "pmtexb2.f"
    o__1.oblnk = 0;
#line 86 "pmtexb2.f"
    f_open(&o__1);
#line 87 "pmtexb2.f"
    *all_1.sepsym = '|';
#line 88 "pmtexb2.f"
    if (noinst > 1) {
#line 88 "pmtexb2.f"
	*all_1.sepsym = '&';
#line 88 "pmtexb2.f"
    }
#line 89 "pmtexb2.f"
    topfile_(basename, &lbase, &all_1.nv, clef, &noinst, &all_1.musicsize, &
#line 89 "pmtexb2.f"
	    comfig_1.figbass, 24L, 1L);
#line 90 "pmtexb2.f"
    lenbeat = ifnodur_(&comtop_1.mtrden, "x", 1L);
#line 91 "pmtexb2.f"
    all_1.lenbar = comtop_1.mtrnum * lenbeat;
#line 92 "pmtexb2.f"
    all_1.lenbar1 = comtop_1.mtrnum * lenbeat;
#line 93 "pmtexb2.f"
    all_1.lenbar0 = xmtrnum0 * lenbeat + .5f;
#line 94 "pmtexb2.f"
    if (all_1.lenbar0 != 0) {
#line 95 "pmtexb2.f"
	s_wsfe(&io___25);
/* Writing concatenation */
#line 95 "pmtexb2.f"
	i__5[0] = 1, a__4[0] = all_1.s;
#line 95 "pmtexb2.f"
	i__5[1] = 7, a__4[1] = "advance";
#line 95 "pmtexb2.f"
	i__5[2] = 1, a__4[2] = all_1.s;
#line 95 "pmtexb2.f"
	i__5[3] = 11, a__4[3] = "barno by -1";
#line 95 "pmtexb2.f"
	s_cat(ch__4, a__4, i__5, &c__4, 20L);
#line 95 "pmtexb2.f"
	do_fio(&c__1, ch__4, 20L);
#line 95 "pmtexb2.f"
	e_wsfe();
#line 96 "pmtexb2.f"
	all_1.lenbar = all_1.lenbar0;
#line 97 "pmtexb2.f"
    } else {
#line 98 "pmtexb2.f"
	all_1.lenbar = all_1.lenbar1;
#line 99 "pmtexb2.f"
    }
/* ### The following may need revision for different time sig's. */
#line 101 "pmtexb2.f"
    if (comtop_1.mtrden == 4) {
#line 102 "pmtexb2.f"
	combeam_1.lenbeam = 24;
#line 103 "pmtexb2.f"
    } else if (comtop_1.mtrden == 8) {
#line 104 "pmtexb2.f"
	combeam_1.lenbeam = 36;
#line 105 "pmtexb2.f"
    }
#line 106 "pmtexb2.f"
    ibarcnt = 0;
#line 107 "pmtexb2.f"
    all_1.iccount = 80;
#line 108 "pmtexb2.f"
    i__2 = all_1.nv;
#line 108 "pmtexb2.f"
    for (all_1.iv = 1; all_1.iv <= i__2; ++all_1.iv) {
#line 109 "pmtexb2.f"
	all_1.ncmid[all_1.iv - 1] = ncmidf_(clef + (all_1.iv - 1), 1L);
#line 110 "pmtexb2.f"
/* L1: */
#line 110 "pmtexb2.f"
    }

/*  Initialize for loop over lines */

#line 114 "pmtexb2.f"
    all_1.firstline = TRUE_;
#line 115 "pmtexb2.f"
L30:
#line 115 "pmtexb2.f"
    loop = TRUE_;
#line 116 "pmtexb2.f"
    all_1.nbars = 0;
#line 117 "pmtexb2.f"
/* L3: */
#line 117 "pmtexb2.f"
    i__2 = all_1.nv;
#line 117 "pmtexb2.f"
    for (all_1.iv = 1; all_1.iv <= i__2; ++all_1.iv) {
#line 118 "pmtexb2.f"
	all_1.itsofar[all_1.iv - 1] = 0;
#line 119 "pmtexb2.f"
	all_1.nnl[all_1.iv - 1] = 0;
#line 120 "pmtexb2.f"
	for (j = 1; j <= 200; ++j) {
#line 121 "pmtexb2.f"
	    all_1.rest[all_1.iv + j * 5 - 6] = FALSE_;
#line 122 "pmtexb2.f"
	    all_1.acc[all_1.iv + j * 5 - 6] = 'x';
#line 123 "pmtexb2.f"
	    all_1.orn[all_1.iv + j * 5 - 6] = 'x';
#line 124 "pmtexb2.f"
	    if (all_1.iv == 1) {
#line 124 "pmtexb2.f"
		s_copy(all_1.fig + (j - 1) * 6, "x", 6L, 1L);
#line 124 "pmtexb2.f"
	    }
#line 125 "pmtexb2.f"
/* L5: */
#line 125 "pmtexb2.f"
	}
#line 126 "pmtexb2.f"
/* L4: */
#line 126 "pmtexb2.f"
    }
#line 127 "pmtexb2.f"
    all_1.iv = 1;
#line 128 "pmtexb2.f"
L2:
#line 128 "pmtexb2.f"
    if (loop) {

/* Within this loop, nv voices are filled up for the duration of the l
ine.*/
/*  On exit (loop=.false.) the following are set: nnl(nv),itsofar(nv) 
*/
/*  nolev(nv,nnl(nv)),nodur(..),acc(..),rest(..).  nnl will later be 
*/
/*  increased and things slid around as accidental skips are added. */

#line 135 "pmtexb2.f"
	getnote_(&loop);
#line 136 "pmtexb2.f"
	if (comget_1.lastchar) {
#line 136 "pmtexb2.f"
	    goto L40;
#line 136 "pmtexb2.f"
	}
#line 137 "pmtexb2.f"
	goto L2;
#line 138 "pmtexb2.f"
    }
#line 139 "pmtexb2.f"
    all_1.firstline = FALSE_;
#line 140 "pmtexb2.f"
    i__2 = all_1.nbars;
#line 140 "pmtexb2.f"
    for (all_1.ibar = 1; all_1.ibar <= i__2; ++all_1.ibar) {
#line 141 "pmtexb2.f"
	++ibarcnt;
#line 142 "pmtexb2.f"
	s_wsle(&io___29);
#line 142 "pmtexb2.f"
	do_lio(&c__9, &c__1, "Now processing bar #", 20L);
#line 142 "pmtexb2.f"
	i__6 = ibarcnt + ibcoff;
#line 142 "pmtexb2.f"
	do_lio(&c__3, &c__1, (char *)&i__6, (ftnlen)sizeof(integer));
#line 142 "pmtexb2.f"
	e_wsle();
#line 143 "pmtexb2.f"
	s_wsfe(&io___30);
#line 143 "pmtexb2.f"
	do_fio(&c__1, "% bar", 5L);
#line 143 "pmtexb2.f"
	i__6 = ibarcnt + ibcoff;
#line 143 "pmtexb2.f"
	do_fio(&c__1, (char *)&i__6, (ftnlen)sizeof(integer));
#line 143 "pmtexb2.f"
	e_wsfe();
#line 144 "pmtexb2.f"
	if (ibarcnt > 1) {
#line 145 "pmtexb2.f"
	    s_wsfe(&io___31);
/* Writing concatenation */
#line 145 "pmtexb2.f"
	    i__1[0] = 1, a__1[0] = all_1.s;
#line 145 "pmtexb2.f"
	    i__1[1] = 5, a__1[1] = "barre";
#line 145 "pmtexb2.f"
	    s_cat(ch__5, a__1, i__1, &c__2, 6L);
#line 145 "pmtexb2.f"
	    do_fio(&c__1, ch__5, 6L);
#line 145 "pmtexb2.f"
	    e_wsfe();
#line 146 "pmtexb2.f"
	    if (ibarcnt == iauto && comfig_1.figbass) {
#line 147 "pmtexb2.f"
		s_wsfe(&io___32);
/* Writing concatenation */
#line 147 "pmtexb2.f"
		i__5[0] = 1, a__4[0] = all_1.s;
#line 147 "pmtexb2.f"
		i__5[1] = 6, a__4[1] = "global";
#line 147 "pmtexb2.f"
		i__5[2] = 1, a__4[2] = all_1.s;
#line 147 "pmtexb2.f"
		i__5[3] = 8, a__4[3] = "figdrop=";
#line 147 "pmtexb2.f"
		s_cat(ch__6, a__4, i__5, &c__4, 16L);
#line 147 "pmtexb2.f"
		do_fio(&c__1, ch__6, 16L);
#line 147 "pmtexb2.f"
		do_fio(&c__1, (char *)&comfig_1.ifigdrop[comfig_1.iline - 1], 
#line 147 "pmtexb2.f"
			(ftnlen)sizeof(integer));
/* Writing concatenation */
#line 147 "pmtexb2.f"
		i__7[0] = 1, a__5[0] = all_1.s;
#line 147 "pmtexb2.f"
		i__7[1] = 5, a__5[1] = "relax";
#line 147 "pmtexb2.f"
		i__7[2] = 1, a__5[2] = all_1.s;
#line 147 "pmtexb2.f"
		i__7[3] = 3, a__5[3] = "or%";
#line 147 "pmtexb2.f"
		s_cat(ch__7, a__5, i__7, &c__4, 10L);
#line 147 "pmtexb2.f"
		do_fio(&c__1, ch__7, 10L);
#line 147 "pmtexb2.f"
		e_wsfe();
#line 150 "pmtexb2.f"
		++comfig_1.iline;
#line 151 "pmtexb2.f"
		comfig_1.ifigdrop[comfig_1.iline - 1] = 4;
#line 152 "pmtexb2.f"
	    }
#line 153 "pmtexb2.f"
	}
#line 154 "pmtexb2.f"
	if (ibarcnt == iauto) {
#line 155 "pmtexb2.f"
	    s_rsfe(&io___33);
#line 155 "pmtexb2.f"
	    do_fio(&c__1, autoline, 24L);
#line 155 "pmtexb2.f"
	    e_rsfe();
#line 156 "pmtexb2.f"
	    s_rsfi(&io___35);
#line 156 "pmtexb2.f"
	    do_fio(&c__1, (char *)&ielperbar, (ftnlen)sizeof(integer));
#line 156 "pmtexb2.f"
	    do_fio(&c__1, (char *)&ibarperln, (ftnlen)sizeof(integer));
#line 156 "pmtexb2.f"
	    e_rsfi();
#line 157 "pmtexb2.f"
	    all_1.slfac = slfac1 * all_1.musicsize * ielperbar * ibarperln;
#line 158 "pmtexb2.f"
	    s_wsfe(&io___38);
#line 158 "pmtexb2.f"
	    do_fio(&c__1, autoline, 24L);
#line 158 "pmtexb2.f"
	    e_wsfe();
#line 159 "pmtexb2.f"
	    s_rsle(&io___39);
#line 159 "pmtexb2.f"
	    do_lio(&c__3, &c__1, (char *)&iauto, (ftnlen)sizeof(integer));
#line 159 "pmtexb2.f"
	    e_rsle();
#line 160 "pmtexb2.f"
	}
#line 161 "pmtexb2.f"
	if (all_1.ibar > 1) {

/*  For bars after first, slide all stuff down to beginning of arr
ays */

#line 165 "pmtexb2.f"
	    i__6 = all_1.nv;
#line 165 "pmtexb2.f"
	    for (all_1.iv = 1; all_1.iv <= i__6; ++all_1.iv) {
#line 166 "pmtexb2.f"
		ioff = all_1.nib[all_1.iv + (all_1.ibar - 1) * 5 - 6];
#line 167 "pmtexb2.f"
		i__8 = all_1.nib[all_1.iv + all_1.ibar * 5 - 6] - ioff;
#line 167 "pmtexb2.f"
		for (ip = 1; ip <= i__8; ++ip) {
#line 168 "pmtexb2.f"
		    all_1.nolev[all_1.iv + ip * 5 - 6] = all_1.nolev[all_1.iv 
#line 168 "pmtexb2.f"
			    + (ip + ioff) * 5 - 6];
#line 169 "pmtexb2.f"
		    all_1.nodur[all_1.iv + ip * 5 - 6] = all_1.nodur[all_1.iv 
#line 169 "pmtexb2.f"
			    + (ip + ioff) * 5 - 6];
#line 170 "pmtexb2.f"
		    all_1.acc[all_1.iv + ip * 5 - 6] = all_1.acc[all_1.iv + (
#line 170 "pmtexb2.f"
			    ip + ioff) * 5 - 6];
#line 171 "pmtexb2.f"
		    all_1.rest[all_1.iv + ip * 5 - 6] = all_1.rest[all_1.iv + 
#line 171 "pmtexb2.f"
			    (ip + ioff) * 5 - 6];
#line 172 "pmtexb2.f"
		    all_1.orn[all_1.iv + ip * 5 - 6] = all_1.orn[all_1.iv + (
#line 172 "pmtexb2.f"
			    ip + ioff) * 5 - 6];
#line 173 "pmtexb2.f"
		    if (all_1.iv == 1) {
#line 173 "pmtexb2.f"
			s_copy(all_1.fig + (ip - 1) * 6, all_1.fig + (ip + 
#line 173 "pmtexb2.f"
				ioff - 1) * 6, 6L, 6L);
#line 173 "pmtexb2.f"
		    }
#line 174 "pmtexb2.f"
/* L12: */
#line 174 "pmtexb2.f"
		}
#line 175 "pmtexb2.f"
/* L11: */
#line 175 "pmtexb2.f"
	    }
#line 176 "pmtexb2.f"
	}
#line 177 "pmtexb2.f"
	makeabar_();
#line 178 "pmtexb2.f"
/* L10: */
#line 178 "pmtexb2.f"
    }
#line 179 "pmtexb2.f"
    goto L30;
#line 180 "pmtexb2.f"
L40:
#line 180 "pmtexb2.f"
    cl__1.cerr = 0;
#line 180 "pmtexb2.f"
    cl__1.cunit = 12;
#line 180 "pmtexb2.f"
    cl__1.csta = 0;
#line 180 "pmtexb2.f"
    f_clos(&cl__1);
#line 181 "pmtexb2.f"
    cl__1.cerr = 0;
#line 181 "pmtexb2.f"
    cl__1.cunit = 13;
#line 181 "pmtexb2.f"
    cl__1.csta = 0;
#line 181 "pmtexb2.f"
    f_clos(&cl__1);
#line 182 "pmtexb2.f"
    cl__1.cerr = 0;
#line 182 "pmtexb2.f"
    cl__1.cunit = 10;
#line 182 "pmtexb2.f"
    cl__1.csta = 0;
#line 182 "pmtexb2.f"
    f_clos(&cl__1);
#line 183 "pmtexb2.f"
    cl__1.cerr = 0;
#line 183 "pmtexb2.f"
    cl__1.cunit = 11;
#line 183 "pmtexb2.f"
    cl__1.csta = 0;
#line 183 "pmtexb2.f"
    f_clos(&cl__1);
#line 184 "pmtexb2.f"
    if (comfig_1.figbass) {
#line 185 "pmtexb2.f"
	s_wsfe(&io___42);
/* Writing concatenation */
#line 185 "pmtexb2.f"
	i__5[0] = 1, a__4[0] = all_1.s;
#line 185 "pmtexb2.f"
	i__5[1] = 6, a__4[1] = "global";
#line 185 "pmtexb2.f"
	i__5[2] = 1, a__4[2] = all_1.s;
#line 185 "pmtexb2.f"
	i__5[3] = 8, a__4[3] = "figdrop=";
#line 185 "pmtexb2.f"
	s_cat(ch__6, a__4, i__5, &c__4, 16L);
#line 185 "pmtexb2.f"
	do_fio(&c__1, ch__6, 16L);
#line 185 "pmtexb2.f"
	do_fio(&c__1, (char *)&comfig_1.ifigdrop[comfig_1.iline - 1], (ftnlen)
#line 185 "pmtexb2.f"
		sizeof(integer));
/* Writing concatenation */
#line 185 "pmtexb2.f"
	i__7[0] = 1, a__5[0] = all_1.s;
#line 185 "pmtexb2.f"
	i__7[1] = 5, a__5[1] = "relax";
#line 185 "pmtexb2.f"
	i__7[2] = 1, a__5[2] = all_1.s;
#line 185 "pmtexb2.f"
	i__7[3] = 4, a__5[3] = "fi}%";
#line 185 "pmtexb2.f"
	s_cat(ch__8, a__5, i__7, &c__4, 11L);
#line 185 "pmtexb2.f"
	do_fio(&c__1, ch__8, 11L);
#line 185 "pmtexb2.f"
	e_wsfe();
#line 188 "pmtexb2.f"
	cl__1.cerr = 0;
#line 188 "pmtexb2.f"
	cl__1.cunit = 14;
#line 188 "pmtexb2.f"
	cl__1.csta = 0;
#line 188 "pmtexb2.f"
	f_clos(&cl__1);
#line 189 "pmtexb2.f"
    }
#line 190 "pmtexb2.f"
    s_wsle(&io___43);
#line 190 "pmtexb2.f"
    do_lio(&c__9, &c__1, "Writing ", 8L);
/* Writing concatenation */
#line 190 "pmtexb2.f"
    i__5[0] = lpath, a__4[0] = pathname;
#line 190 "pmtexb2.f"
    i__5[1] = lbase, a__4[1] = basename;
#line 190 "pmtexb2.f"
    i__5[2] = 5, a__4[2] = ".tex ";
#line 190 "pmtexb2.f"
    i__5[3] = 11, a__4[3] = "and exiting";
#line 190 "pmtexb2.f"
    s_cat(ch__9, a__4, i__5, &c__4, 80L);
#line 190 "pmtexb2.f"
    do_lio(&c__9, &c__1, ch__9, lpath + lbase + 16);
#line 190 "pmtexb2.f"
    e_wsle();
#line 192 "pmtexb2.f"
    return 0;
} /* MAIN__ */

/* Subroutine */ int getnote_(logical *loop)
{
    /* System generated locals */
    address a__1[2];
    integer i__1[2];

    /* Builtin functions */
    integer s_rsfi(icilist *), do_fio(integer *, char *, ftnlen), e_rsfi(void)
	    ;
    /* Subroutine */ int s_copy(char *, char *, ftnlen, ftnlen), s_cat(char *,
	     char **, integer *, integer *, ftnlen);

    /* Local variables */
    static char char_[1];
    static integer lfig;
    static char line[80];
    static integer ioct, inodur;
    static char oct[1], dot[1];
    extern /* Subroutine */ int getchar_(char *, integer *, char *, ftnlen, 
	    ftnlen);
    extern integer ifnolev_(char *, integer *, ftnlen), ifnodur_(integer *, 
	    char *, ftnlen);

    /* Fortran I/O blocks */
    static icilist io___48 = { 0, oct, 0, "(i1)", 1, 1 };
    static icilist io___50 = { 0, char_, 0, "(i1)", 1, 1 };
    static icilist io___53 = { 0, char_, 0, "(i1)", 1, 1 };


/* ccccccccccc */
/* c */
/* c  pmtex.inc */
/* c */
/* ccccccccccc */
#line 199 "pmtexb2.f"
L1:
#line 199 "pmtexb2.f"
    getchar_(line, &all_1.iccount, char_, 80L, 1L);
#line 200 "pmtexb2.f"
    if (comget_1.lastchar) {
#line 200 "pmtexb2.f"
	return 0;
#line 200 "pmtexb2.f"
    }
#line 201 "pmtexb2.f"
    if (*char_ == ' ') {
#line 202 "pmtexb2.f"
	goto L1;
#line 203 "pmtexb2.f"
    } else if (*char_ == '%') {
#line 204 "pmtexb2.f"
	all_1.iccount = 80;
#line 205 "pmtexb2.f"
	goto L1;
#line 206 "pmtexb2.f"
    } else if (*char_ >= 97 && *char_ <= 103) {

/* This is a note.  Increase note count, get octave & basic duration. 
*/

#line 210 "pmtexb2.f"
	++all_1.nnl[all_1.iv - 1];
#line 211 "pmtexb2.f"
	getchar_(line, &all_1.iccount, oct, 80L, 1L);
#line 212 "pmtexb2.f"
	if (comget_1.lastchar) {
#line 212 "pmtexb2.f"
	    return 0;
#line 212 "pmtexb2.f"
	}
#line 213 "pmtexb2.f"
	*dot = 'x';
#line 214 "pmtexb2.f"
	if (*oct != ' ') {
#line 215 "pmtexb2.f"
	    s_rsfi(&io___48);
#line 215 "pmtexb2.f"
	    do_fio(&c__1, (char *)&ioct, (ftnlen)sizeof(integer));
#line 215 "pmtexb2.f"
	    e_rsfi();
#line 216 "pmtexb2.f"
	    all_1.nolev[all_1.iv + all_1.nnl[all_1.iv - 1] * 5 - 6] = 
#line 216 "pmtexb2.f"
		    ifnolev_(char_, &ioct, 1L);
#line 217 "pmtexb2.f"
	    getchar_(line, &all_1.iccount, char_, 80L, 1L);
#line 218 "pmtexb2.f"
	    if (comget_1.lastchar) {
#line 218 "pmtexb2.f"
		return 0;
#line 218 "pmtexb2.f"
	    }
#line 219 "pmtexb2.f"
	} else {
/* #### Get octave from previous one */
#line 221 "pmtexb2.f"
	    all_1.nolev[all_1.iv + all_1.nnl[all_1.iv - 1] * 5 - 6] = 
#line 221 "pmtexb2.f"
		    ifnolev_(char_, &ioct, 1L);
#line 222 "pmtexb2.f"
	    if (all_1.nolev[all_1.iv + all_1.nnl[all_1.iv - 1] * 5 - 6] > 
#line 222 "pmtexb2.f"
		    all_1.nolev[all_1.iv + (all_1.nnl[all_1.iv - 1] - 1) * 5 
#line 222 "pmtexb2.f"
		    - 6] + 3) {
#line 223 "pmtexb2.f"
		all_1.nolev[all_1.iv + all_1.nnl[all_1.iv - 1] * 5 - 6] += -7;
#line 224 "pmtexb2.f"
	    } else if (all_1.nolev[all_1.iv + all_1.nnl[all_1.iv - 1] * 5 - 6]
#line 224 "pmtexb2.f"
		     < all_1.nolev[all_1.iv + (all_1.nnl[all_1.iv - 1] - 1) * 
#line 224 "pmtexb2.f"
		    5 - 6] - 3) {
#line 225 "pmtexb2.f"
		all_1.nolev[all_1.iv + all_1.nnl[all_1.iv - 1] * 5 - 6] += 7;
#line 226 "pmtexb2.f"
	    }
#line 227 "pmtexb2.f"
	    *char_ = ' ';
#line 228 "pmtexb2.f"
	}
#line 229 "pmtexb2.f"
	if (*char_ == ' ') {
#line 230 "pmtexb2.f"
	    all_1.nodur[all_1.iv + all_1.nnl[all_1.iv - 1] * 5 - 6] = 
#line 230 "pmtexb2.f"
		    all_1.nodur[all_1.iv + (all_1.nnl[all_1.iv - 1] - 1) * 5 
#line 230 "pmtexb2.f"
		    - 6];
#line 231 "pmtexb2.f"
	    goto L4;
#line 232 "pmtexb2.f"
	}
#line 233 "pmtexb2.f"
	s_rsfi(&io___50);
#line 233 "pmtexb2.f"
	do_fio(&c__1, (char *)&inodur, (ftnlen)sizeof(integer));
#line 233 "pmtexb2.f"
	e_rsfi();
#line 234 "pmtexb2.f"
L2:
#line 234 "pmtexb2.f"
	getchar_(line, &all_1.iccount, char_, 80L, 1L);
#line 235 "pmtexb2.f"
	if (comget_1.lastchar) {
#line 235 "pmtexb2.f"
	    return 0;
#line 235 "pmtexb2.f"
	}
#line 236 "pmtexb2.f"
	if (*char_ != ' ') {
#line 237 "pmtexb2.f"
	    if (*char_ == 'd') {
#line 238 "pmtexb2.f"
		*dot = *char_;
#line 239 "pmtexb2.f"
	    } else if (*char_ == '/') {
#line 241 "pmtexb2.f"
	    } else {

/*  Only other possibility is an accidental */

#line 245 "pmtexb2.f"
		all_1.acc[all_1.iv + all_1.nnl[all_1.iv - 1] * 5 - 6] = *
#line 245 "pmtexb2.f"
			char_;
#line 246 "pmtexb2.f"
	    }
#line 247 "pmtexb2.f"
	    if (*char_ != '/') {
#line 247 "pmtexb2.f"
		goto L2;
#line 247 "pmtexb2.f"
	    }
#line 248 "pmtexb2.f"
	}
#line 249 "pmtexb2.f"
	all_1.nodur[all_1.iv + all_1.nnl[all_1.iv - 1] * 5 - 6] = ifnodur_(&
#line 249 "pmtexb2.f"
		inodur, dot, 1L);
#line 250 "pmtexb2.f"
L4:
#line 250 "pmtexb2.f"
	all_1.itsofar[all_1.iv - 1] += all_1.nodur[all_1.iv + all_1.nnl[
#line 250 "pmtexb2.f"
		all_1.iv - 1] * 5 - 6];
#line 251 "pmtexb2.f"
	if (all_1.itsofar[all_1.iv - 1] % all_1.lenbar == 0) {
#line 252 "pmtexb2.f"
	    ++all_1.nbars;
#line 253 "pmtexb2.f"
	    all_1.nib[all_1.iv + all_1.nbars * 5 - 6] = all_1.nnl[all_1.iv - 
#line 253 "pmtexb2.f"
		    1];
#line 254 "pmtexb2.f"
	    if (all_1.lenbar != all_1.lenbar1) {

/* ###  Just finished the pickup bar for this voice. */

#line 258 "pmtexb2.f"
		all_1.lenbar = all_1.lenbar1;
#line 259 "pmtexb2.f"
		all_1.itsofar[all_1.iv - 1] = 0;
#line 260 "pmtexb2.f"
	    }
#line 261 "pmtexb2.f"
	}
#line 262 "pmtexb2.f"
    } else if (*char_ == 'o') {
/* ###             "o" symbol must come AFTER the affected note */
#line 264 "pmtexb2.f"
	getchar_(line, &all_1.iccount, all_1.orn + (all_1.iv + all_1.nnl[
#line 264 "pmtexb2.f"
		all_1.iv - 1] * 5 - 6), 80L, 1L);
#line 265 "pmtexb2.f"
	if (comget_1.lastchar) {
#line 265 "pmtexb2.f"
	    return 0;
#line 265 "pmtexb2.f"
	}
#line 266 "pmtexb2.f"
    } else if (*char_ >= 49 && *char_ <= 57 || *char_ == '#' || *char_ == '-' 
#line 266 "pmtexb2.f"
	    || *char_ == 'n' || *char_ == '_') {
/*###            We have a figure.  Must come AFTER the note it goes u
nder*/
#line 270 "pmtexb2.f"
	lfig = 1;
#line 271 "pmtexb2.f"
	s_copy(all_1.fig + (all_1.nnl[all_1.iv - 1] - 1) * 6, char_, 6L, 1L);
#line 272 "pmtexb2.f"
L5:
#line 272 "pmtexb2.f"
	getchar_(line, &all_1.iccount, char_, 80L, 1L);
#line 273 "pmtexb2.f"
	if (comget_1.lastchar) {
#line 273 "pmtexb2.f"
	    return 0;
#line 273 "pmtexb2.f"
	}
#line 274 "pmtexb2.f"
	if (*char_ != ' ') {
/* Writing concatenation */
#line 275 "pmtexb2.f"
	    i__1[0] = lfig, a__1[0] = all_1.fig + (all_1.nnl[all_1.iv - 1] - 
#line 275 "pmtexb2.f"
		    1) * 6;
#line 275 "pmtexb2.f"
	    i__1[1] = 1, a__1[1] = char_;
#line 275 "pmtexb2.f"
	    s_cat(all_1.fig + (all_1.nnl[all_1.iv - 1] - 1) * 6, a__1, i__1, &
#line 275 "pmtexb2.f"
		    c__2, 6L);
#line 276 "pmtexb2.f"
	    ++lfig;
#line 277 "pmtexb2.f"
	    goto L5;
#line 278 "pmtexb2.f"
	}
#line 279 "pmtexb2.f"
    } else if (*char_ == 'r') {

/*  We have a rest, so get inodur and dot */

#line 283 "pmtexb2.f"
	++all_1.nnl[all_1.iv - 1];
#line 284 "pmtexb2.f"
	all_1.rest[all_1.iv + all_1.nnl[all_1.iv - 1] * 5 - 6] = TRUE_;
#line 285 "pmtexb2.f"
	getchar_(line, &all_1.iccount, char_, 80L, 1L);
#line 286 "pmtexb2.f"
	if (comget_1.lastchar) {
#line 286 "pmtexb2.f"
	    return 0;
#line 286 "pmtexb2.f"
	}
#line 287 "pmtexb2.f"
	s_rsfi(&io___53);
#line 287 "pmtexb2.f"
	do_fio(&c__1, (char *)&inodur, (ftnlen)sizeof(integer));
#line 287 "pmtexb2.f"
	e_rsfi();
#line 288 "pmtexb2.f"
	*dot = 'x';
#line 289 "pmtexb2.f"
	getchar_(line, &all_1.iccount, char_, 80L, 1L);
#line 290 "pmtexb2.f"
	if (comget_1.lastchar) {
#line 290 "pmtexb2.f"
	    return 0;
#line 290 "pmtexb2.f"
	}
#line 291 "pmtexb2.f"
	if (*char_ == 'd') {
#line 292 "pmtexb2.f"
	    *dot = *char_;
#line 293 "pmtexb2.f"
	}
#line 294 "pmtexb2.f"
	all_1.nodur[all_1.iv + all_1.nnl[all_1.iv - 1] * 5 - 6] = ifnodur_(&
#line 294 "pmtexb2.f"
		inodur, dot, 1L);
#line 295 "pmtexb2.f"
	all_1.itsofar[all_1.iv - 1] += all_1.nodur[all_1.iv + all_1.nnl[
#line 295 "pmtexb2.f"
		all_1.iv - 1] * 5 - 6];
#line 296 "pmtexb2.f"
	if (all_1.itsofar[all_1.iv - 1] % all_1.lenbar == 0) {
#line 297 "pmtexb2.f"
	    ++all_1.nbars;
#line 298 "pmtexb2.f"
	    all_1.nib[all_1.iv + all_1.nbars * 5 - 6] = all_1.nnl[all_1.iv - 
#line 298 "pmtexb2.f"
		    1];
#line 299 "pmtexb2.f"
	    if (all_1.lenbar != all_1.lenbar1) {

/* ###  Just finished the pickup bar for this voice. */

#line 303 "pmtexb2.f"
		all_1.lenbar = all_1.lenbar1;
#line 304 "pmtexb2.f"
		all_1.itsofar[all_1.iv - 1] = 0;
#line 305 "pmtexb2.f"
	    }
#line 306 "pmtexb2.f"
	}
#line 307 "pmtexb2.f"
    }
#line 308 "pmtexb2.f"
/* L3: */
#line 308 "pmtexb2.f"
    if (*char_ == '/') {

/*  Start a new voice for this line */

#line 312 "pmtexb2.f"
	if (all_1.iv == all_1.nv) {
#line 313 "pmtexb2.f"
	    *loop = FALSE_;
#line 314 "pmtexb2.f"
	} else {
#line 315 "pmtexb2.f"
	    if (all_1.lenbar0 != 0 && all_1.firstline) {
#line 315 "pmtexb2.f"
		all_1.lenbar = all_1.lenbar0;
#line 315 "pmtexb2.f"
	    }
#line 316 "pmtexb2.f"
	    all_1.nbars = 0;
#line 317 "pmtexb2.f"
	    ++all_1.iv;
#line 318 "pmtexb2.f"
	}
#line 319 "pmtexb2.f"
    }
#line 320 "pmtexb2.f"
    return 0;
} /* getnote_ */

/* Subroutine */ int getchar_(char *line, integer *iccount, char *mychar, 
	ftnlen line_len, ftnlen mychar_len)
{
    /* System generated locals */
    address a__1[4];
    integer i__1, i__2[4];
    char ch__1[15];

    /* Builtin functions */
    integer s_rsfe(cilist *), do_fio(integer *, char *, ftnlen), e_rsfe(void),
	     s_wsfe(cilist *);
    /* Subroutine */ int s_cat(char *, char **, integer *, integer *, ftnlen);
    integer e_wsfe(void);

    /* Local variables */
    static char s[1];

    /* Fortran I/O blocks */
    static cilist io___55 = { 0, 10, 1, "(a80)", 0 };
    static cilist io___56 = { 0, 11, 0, "(a)", 0 };



/* Gets the next character out of line*80.  If pointer iccount=80 on entry
,*/
/* then reads in a new line.  Resets iccount.  Ends program if no more inp
ut.*/

/*  Platform-independent backslash */
#line 332 "pmtexb2.f"
    *s = '\\';
#line 333 "pmtexb2.f"
    if (*iccount == 80) {
#line 334 "pmtexb2.f"
	i__1 = s_rsfe(&io___55);
#line 334 "pmtexb2.f"
	if (i__1 != 0) {
#line 334 "pmtexb2.f"
	    goto L999;
#line 334 "pmtexb2.f"
	}
#line 334 "pmtexb2.f"
	i__1 = do_fio(&c__1, line, 80L);
#line 334 "pmtexb2.f"
	if (i__1 != 0) {
#line 334 "pmtexb2.f"
	    goto L999;
#line 334 "pmtexb2.f"
	}
#line 334 "pmtexb2.f"
	i__1 = e_rsfe();
#line 334 "pmtexb2.f"
	if (i__1 != 0) {
#line 334 "pmtexb2.f"
	    goto L999;
#line 334 "pmtexb2.f"
	}
#line 335 "pmtexb2.f"
	*iccount = 0;
#line 336 "pmtexb2.f"
    }
#line 337 "pmtexb2.f"
    ++(*iccount);
#line 338 "pmtexb2.f"
    *mychar = line[*iccount - 1];
#line 339 "pmtexb2.f"
    return 0;
#line 340 "pmtexb2.f"
L999:
#line 341 "pmtexb2.f"
    s_wsfe(&io___56);
/* Writing concatenation */
#line 341 "pmtexb2.f"
    i__2[0] = 1, a__1[0] = s;
#line 341 "pmtexb2.f"
    i__2[1] = 10, a__1[1] = "finmorceau";
#line 341 "pmtexb2.f"
    i__2[2] = 1, a__1[2] = s;
#line 341 "pmtexb2.f"
    i__2[3] = 3, a__1[3] = "bye";
#line 341 "pmtexb2.f"
    s_cat(ch__1, a__1, i__2, &c__4, 15L);
#line 341 "pmtexb2.f"
    do_fio(&c__1, ch__1, 15L);
#line 341 "pmtexb2.f"
    e_wsfe();
#line 342 "pmtexb2.f"
    comget_1.lastchar = TRUE_;
#line 343 "pmtexb2.f"
    return 0;
} /* getchar_ */

integer log2_(integer *n)
{
    /* System generated locals */
    integer ret_val;

    /* Builtin functions */
    double log(doublereal);

#line 346 "pmtexb2.f"
    ret_val = log(*n * 1.f) / .69315f + .01f;
#line 347 "pmtexb2.f"
    return ret_val;
} /* log2_ */

integer ifnolev_(char *no, integer *oct, ftnlen no_len)
{
    /* System generated locals */
    integer ret_val;

#line 352 "pmtexb2.f"
    ret_val = *oct * 7 + (*no - 92) % 7 + 1;
#line 353 "pmtexb2.f"
    return ret_val;
} /* ifnolev_ */

integer ifnodur_(integer *idur, char *dot, ftnlen dot_len)
{
    /* System generated locals */
    integer ret_val;

    /* Builtin functions */
    integer s_wsle(cilist *), do_lio(integer *, integer *, char *, ftnlen), 
	    e_wsle(void);
    /* Subroutine */ int s_stop(char *, ftnlen);

    /* Fortran I/O blocks */
    static cilist io___57 = { 0, 6, 0, 0, 0 };


#line 357 "pmtexb2.f"
    if (*idur == 3) {
#line 358 "pmtexb2.f"
	ret_val = 3;
#line 359 "pmtexb2.f"
    } else if (*idur == 1) {
#line 360 "pmtexb2.f"
	ret_val = 6;
#line 361 "pmtexb2.f"
    } else if (*idur == 8) {
#line 362 "pmtexb2.f"
	ret_val = 12;
#line 363 "pmtexb2.f"
    } else if (*idur == 4) {
#line 364 "pmtexb2.f"
	ret_val = 24;
#line 365 "pmtexb2.f"
    } else if (*idur == 2) {
#line 366 "pmtexb2.f"
	ret_val = 48;
#line 367 "pmtexb2.f"
    } else if (*idur == 0) {
#line 368 "pmtexb2.f"
	ret_val = 96;
#line 369 "pmtexb2.f"
    } else {
#line 370 "pmtexb2.f"
	s_wsle(&io___57);
#line 370 "pmtexb2.f"
	do_lio(&c__9, &c__1, "You entered an invalid note value", 33L);
#line 370 "pmtexb2.f"
	e_wsle();
#line 371 "pmtexb2.f"
	s_stop("", 0L);
#line 372 "pmtexb2.f"
    }
#line 373 "pmtexb2.f"
    if (*dot == 'd') {
#line 373 "pmtexb2.f"
	ret_val = ret_val * 1.5f + .5f;
#line 373 "pmtexb2.f"
    }
#line 374 "pmtexb2.f"
    return ret_val;
} /* ifnodur_ */

integer ncmidf_(char *clef, ftnlen clef_len)
{
    /* System generated locals */
    integer ret_val;

#line 378 "pmtexb2.f"
    if (*clef == 't') {
#line 379 "pmtexb2.f"
	ret_val = 35;
#line 380 "pmtexb2.f"
    } else if (*clef == 'b') {
#line 381 "pmtexb2.f"
	ret_val = 23;
#line 382 "pmtexb2.f"
    } else if (*clef == 'a') {
#line 383 "pmtexb2.f"
	ret_val = 29;
#line 384 "pmtexb2.f"
    }
#line 385 "pmtexb2.f"
    return ret_val;
} /* ncmidf_ */

/* Subroutine */ int beamend_(char *notex, integer *lnote, ftnlen notex_len)
{
    /* System generated locals */
    address a__1[2], a__2[3], a__3[4];
    integer i__1[2], i__2, i__3[3], i__4[4];
    char ch__1[1];
    icilist ici__1;

    /* Builtin functions */
    /* Subroutine */ int s_copy(char *, char *, ftnlen, ftnlen), s_cat(char *,
	     char **, integer *, integer *, ftnlen);
    integer s_wsfi(icilist *), do_fio(integer *, char *, ftnlen), e_wsfi(void)
	    ;

    /* Local variables */
    extern /* Character */ VOID notef_(char *, ftnlen, integer *);
    static integer im, ip, mp;

/* ccccccccccc */
/* c */
/* c  pmtex.inc */
/* c */
/* ccccccccccc */
#line 391 "pmtexb2.f"
    ip = all_1.list[(all_1.jn << 2) - 3];
#line 392 "pmtexb2.f"
    s_copy(notex, all_1.s, 25L, 1L);
#line 393 "pmtexb2.f"
    *lnote = 1;

/* First check if multiplicity has increased */

#line 397 "pmtexb2.f"
    if (all_1.acc[all_1.iv + (ip - 1) * 5 - 6] != 'a') {
#line 398 "pmtexb2.f"
	mp = all_1.mult[all_1.iv + (ip - 1) * 5 - 6];
#line 399 "pmtexb2.f"
    } else {
#line 400 "pmtexb2.f"
	mp = all_1.mult[all_1.iv + (ip - 2) * 5 - 6];
#line 401 "pmtexb2.f"
    }
#line 402 "pmtexb2.f"
    if (all_1.mult[all_1.iv + ip * 5 - 6] > mp) {
/* Writing concatenation */
#line 403 "pmtexb2.f"
	i__1[0] = 1, a__1[0] = notex;
#line 403 "pmtexb2.f"
	i__1[1] = 1, a__1[1] = "t";
#line 403 "pmtexb2.f"
	s_cat(notex, a__1, i__1, &c__2, 25L);
#line 404 "pmtexb2.f"
	++(*lnote);
#line 405 "pmtexb2.f"
	i__2 = all_1.mult[all_1.iv + ip * 5 - 6];
#line 405 "pmtexb2.f"
	for (im = 1; im <= i__2; ++im) {
/* Writing concatenation */
#line 406 "pmtexb2.f"
	    i__1[0] = *lnote, a__1[0] = notex;
#line 406 "pmtexb2.f"
	    i__1[1] = 1, a__1[1] = "b";
#line 406 "pmtexb2.f"
	    s_cat(notex, a__1, i__1, &c__2, 25L);
#line 407 "pmtexb2.f"
	    ++(*lnote);
#line 408 "pmtexb2.f"
/* L1: */
#line 408 "pmtexb2.f"
	}
/* Writing concatenation */
#line 409 "pmtexb2.f"
	i__1[0] = *lnote, a__1[0] = notex;
#line 409 "pmtexb2.f"
	i__1[1] = 1, a__1[1] = all_1.ul + (all_1.iv + all_1.ibmcnt[all_1.iv - 
#line 409 "pmtexb2.f"
		1] * 5 - 6);
#line 409 "pmtexb2.f"
	s_cat(notex, a__1, i__1, &c__2, 25L);
#line 410 "pmtexb2.f"
	*lnote += 2;
#line 411 "pmtexb2.f"
	ici__1.icierr = 0;
#line 411 "pmtexb2.f"
	ici__1.icirnum = 1;
#line 411 "pmtexb2.f"
	ici__1.icirlen = 1;
#line 411 "pmtexb2.f"
	ici__1.iciunit = notex + (*lnote - 1);
#line 411 "pmtexb2.f"
	ici__1.icifmt = "(i1)";
#line 411 "pmtexb2.f"
	s_wsfi(&ici__1);
#line 411 "pmtexb2.f"
	do_fio(&c__1, (char *)&all_1.iv, (ftnlen)sizeof(integer));
#line 411 "pmtexb2.f"
	e_wsfi();
/* Writing concatenation */
#line 412 "pmtexb2.f"
	i__1[0] = *lnote, a__1[0] = notex;
#line 412 "pmtexb2.f"
	i__1[1] = 1, a__1[1] = all_1.s;
#line 412 "pmtexb2.f"
	s_cat(notex, a__1, i__1, &c__2, 25L);
#line 413 "pmtexb2.f"
	++(*lnote);
#line 414 "pmtexb2.f"
    }

/* Now the normal beam termination */

/* Writing concatenation */
#line 418 "pmtexb2.f"
    i__3[0] = *lnote, a__2[0] = notex;
#line 418 "pmtexb2.f"
    i__3[1] = 2, a__2[1] = "tb";
#line 418 "pmtexb2.f"
    i__3[2] = 1, a__2[2] = all_1.ul + (all_1.iv + all_1.ibmcnt[all_1.iv - 1] *
#line 418 "pmtexb2.f"
	     5 - 6);
#line 418 "pmtexb2.f"
    s_cat(notex, a__2, i__3, &c__3, 25L);
#line 419 "pmtexb2.f"
    *lnote += 4;
#line 420 "pmtexb2.f"
    ici__1.icierr = 0;
#line 420 "pmtexb2.f"
    ici__1.icirnum = 1;
#line 420 "pmtexb2.f"
    ici__1.icirlen = 1;
#line 420 "pmtexb2.f"
    ici__1.iciunit = notex + (*lnote - 1);
#line 420 "pmtexb2.f"
    ici__1.icifmt = "(i1)";
#line 420 "pmtexb2.f"
    s_wsfi(&ici__1);
#line 420 "pmtexb2.f"
    do_fio(&c__1, (char *)&all_1.iv, (ftnlen)sizeof(integer));
#line 420 "pmtexb2.f"
    e_wsfi();

/*  And now the note */

/* Writing concatenation */
#line 424 "pmtexb2.f"
    i__4[0] = *lnote, a__3[0] = notex;
#line 424 "pmtexb2.f"
    i__4[1] = 1, a__3[1] = all_1.s;
#line 424 "pmtexb2.f"
    i__4[2] = 1, a__3[2] = "q";
#line 424 "pmtexb2.f"
    i__4[3] = 1, a__3[3] = all_1.hb + (all_1.iv + all_1.ibmcnt[all_1.iv - 1] *
#line 424 "pmtexb2.f"
	     5 - 6);
#line 424 "pmtexb2.f"
    s_cat(notex, a__3, i__4, &c__4, 25L);
#line 425 "pmtexb2.f"
    *lnote += 4;
#line 426 "pmtexb2.f"
    ici__1.icierr = 0;
#line 426 "pmtexb2.f"
    ici__1.icirnum = 1;
#line 426 "pmtexb2.f"
    ici__1.icirlen = 1;
#line 426 "pmtexb2.f"
    ici__1.iciunit = notex + (*lnote - 1);
#line 426 "pmtexb2.f"
    ici__1.icifmt = "(i1)";
#line 426 "pmtexb2.f"
    s_wsfi(&ici__1);
#line 426 "pmtexb2.f"
    do_fio(&c__1, (char *)&all_1.iv, (ftnlen)sizeof(integer));
#line 426 "pmtexb2.f"
    e_wsfi();
/* Writing concatenation */
#line 427 "pmtexb2.f"
    i__1[0] = *lnote, a__1[0] = notex;
#line 427 "pmtexb2.f"
    notef_(ch__1, 1L, &all_1.nolev[all_1.iv + ip * 5 - 6]);
#line 427 "pmtexb2.f"
    i__1[1] = 1, a__1[1] = ch__1;
#line 427 "pmtexb2.f"
    s_cat(notex, a__1, i__1, &c__2, 25L);
#line 428 "pmtexb2.f"
    ++(*lnote);
#line 429 "pmtexb2.f"
    return 0;
} /* beamend_ */

/* Subroutine */ int beamid_(char *notex, integer *lnote, ftnlen notex_len)
{
    /* System generated locals */
    address a__1[2], a__2[3];
    integer i__1[2], i__2, i__3[3], i__4;
    char ch__1[1];
    icilist ici__1;

    /* Builtin functions */
    /* Subroutine */ int s_copy(char *, char *, ftnlen, ftnlen), s_cat(char *,
	     char **, integer *, integer *, ftnlen);
    integer s_wsfi(icilist *), do_fio(integer *, char *, ftnlen), e_wsfi(void)
	    , pow_ii(integer *, integer *);

    /* Local variables */
    extern /* Character */ VOID notef_(char *, ftnlen, integer *);
    static integer im, ip, mua, mub;
    extern integer log2_(integer *);

/* ccccccccccc */
/* c */
/* c  pmtex.inc */
/* c */
/* ccccccccccc */
#line 435 "pmtexb2.f"
    *lnote = 1;
#line 436 "pmtexb2.f"
    s_copy(notex, all_1.s, 25L, 1L);
#line 437 "pmtexb2.f"
    ip = all_1.list[(all_1.jn << 2) - 3];

/* Check if multiplicity changes in a way requiring action */

#line 441 "pmtexb2.f"
    mub = all_1.mult[all_1.iv + ip * 5 - 6] - all_1.mult[all_1.iv + (ip - 1) *
#line 441 "pmtexb2.f"
	     5 - 6];
#line 442 "pmtexb2.f"
    if (all_1.acc[all_1.iv + (ip - 1) * 5 - 6] == 'a') {
#line 442 "pmtexb2.f"
	mub = all_1.mult[all_1.iv + ip * 5 - 6] - all_1.mult[all_1.iv + (ip - 
#line 442 "pmtexb2.f"
		2) * 5 - 6];
#line 442 "pmtexb2.f"
    }
#line 443 "pmtexb2.f"
    mua = all_1.mult[all_1.iv + (ip + 1) * 5 - 6] - all_1.mult[all_1.iv + ip *
#line 443 "pmtexb2.f"
	     5 - 6];
#line 444 "pmtexb2.f"
    if (all_1.acc[all_1.iv + (ip + 1) * 5 - 6] == 'a') {
#line 444 "pmtexb2.f"
	mua = all_1.mult[all_1.iv + (ip + 2) * 5 - 6] - all_1.mult[all_1.iv + 
#line 444 "pmtexb2.f"
		ip * 5 - 6];
#line 444 "pmtexb2.f"
    }
#line 445 "pmtexb2.f"
    if (mub > 0 || mua < 0) {

/*  Multiplicity has changed. */

#line 449 "pmtexb2.f"
	*lnote = 2;
#line 450 "pmtexb2.f"
	if (mua >= 0) {
/* Writing concatenation */
#line 451 "pmtexb2.f"
	    i__1[0] = 1, a__1[0] = all_1.s;
#line 451 "pmtexb2.f"
	    i__1[1] = 1, a__1[1] = "n";
#line 451 "pmtexb2.f"
	    s_cat(notex, a__1, i__1, &c__2, 25L);
#line 452 "pmtexb2.f"
	} else {
/* Writing concatenation */
#line 453 "pmtexb2.f"
	    i__1[0] = 1, a__1[0] = all_1.s;
#line 453 "pmtexb2.f"
	    i__1[1] = 1, a__1[1] = "t";
#line 453 "pmtexb2.f"
	    s_cat(notex, a__1, i__1, &c__2, 25L);
#line 454 "pmtexb2.f"
	}
#line 455 "pmtexb2.f"
	i__2 = all_1.mult[all_1.iv + ip * 5 - 6];
#line 455 "pmtexb2.f"
	for (im = 1; im <= i__2; ++im) {
/* Writing concatenation */
#line 456 "pmtexb2.f"
	    i__1[0] = *lnote, a__1[0] = notex;
#line 456 "pmtexb2.f"
	    i__1[1] = 1, a__1[1] = "b";
#line 456 "pmtexb2.f"
	    s_cat(notex, a__1, i__1, &c__2, 25L);
#line 457 "pmtexb2.f"
	    ++(*lnote);
#line 458 "pmtexb2.f"
/* L1: */
#line 458 "pmtexb2.f"
	}
/* Writing concatenation */
#line 459 "pmtexb2.f"
	i__1[0] = *lnote, a__1[0] = notex;
#line 459 "pmtexb2.f"
	i__1[1] = 1, a__1[1] = all_1.ul + (all_1.iv + all_1.ibmcnt[all_1.iv - 
#line 459 "pmtexb2.f"
		1] * 5 - 6);
#line 459 "pmtexb2.f"
	s_cat(notex, a__1, i__1, &c__2, 25L);
#line 460 "pmtexb2.f"
	*lnote += 2;
#line 461 "pmtexb2.f"
	ici__1.icierr = 0;
#line 461 "pmtexb2.f"
	ici__1.icirnum = 1;
#line 461 "pmtexb2.f"
	ici__1.icirlen = 1;
#line 461 "pmtexb2.f"
	ici__1.iciunit = notex + (*lnote - 1);
#line 461 "pmtexb2.f"
	ici__1.icifmt = "(i1)";
#line 461 "pmtexb2.f"
	s_wsfi(&ici__1);
#line 461 "pmtexb2.f"
	do_fio(&c__1, (char *)&all_1.iv, (ftnlen)sizeof(integer));
#line 461 "pmtexb2.f"
	e_wsfi();
/* Writing concatenation */
#line 462 "pmtexb2.f"
	i__1[0] = *lnote, a__1[0] = notex;
#line 462 "pmtexb2.f"
	i__1[1] = 1, a__1[1] = all_1.s;
#line 462 "pmtexb2.f"
	s_cat(notex, a__1, i__1, &c__2, 25L);
#line 463 "pmtexb2.f"
	++(*lnote);
#line 464 "pmtexb2.f"
    }

/* Now put in the note */

/* Writing concatenation */
#line 468 "pmtexb2.f"
    i__3[0] = *lnote, a__2[0] = notex;
#line 468 "pmtexb2.f"
    i__3[1] = 1, a__2[1] = "q";
#line 468 "pmtexb2.f"
    i__3[2] = 1, a__2[2] = all_1.hb + (all_1.iv + all_1.ibmcnt[all_1.iv - 1] *
#line 468 "pmtexb2.f"
	     5 - 6);
#line 468 "pmtexb2.f"
    s_cat(notex, a__2, i__3, &c__3, 25L);
#line 469 "pmtexb2.f"
    *lnote += 2;
#line 470 "pmtexb2.f"
    i__4 = (integer) (all_1.nodur[all_1.iv + ip * 5 - 6] / 3.f + .1f);
#line 470 "pmtexb2.f"
    i__2 = log2_(&i__4);
#line 470 "pmtexb2.f"
    if (all_1.acc[all_1.iv + ip * 5 - 6] != 'a' && pow_ii(&c__2, &i__2) != (
#line 470 "pmtexb2.f"
	    integer) (all_1.nodur[all_1.iv + ip * 5 - 6] / 3.f + .1f)) {
/* Writing concatenation */
#line 472 "pmtexb2.f"
	i__1[0] = *lnote, a__1[0] = notex;
#line 472 "pmtexb2.f"
	i__1[1] = 1, a__1[1] = "p";
#line 472 "pmtexb2.f"
	s_cat(notex, a__1, i__1, &c__2, 25L);
#line 473 "pmtexb2.f"
	++(*lnote);
#line 474 "pmtexb2.f"
    }
#line 475 "pmtexb2.f"
    ++(*lnote);
#line 476 "pmtexb2.f"
    ici__1.icierr = 0;
#line 476 "pmtexb2.f"
    ici__1.icirnum = 1;
#line 476 "pmtexb2.f"
    ici__1.icirlen = 1;
#line 476 "pmtexb2.f"
    ici__1.iciunit = notex + (*lnote - 1);
#line 476 "pmtexb2.f"
    ici__1.icifmt = "(i1)";
#line 476 "pmtexb2.f"
    s_wsfi(&ici__1);
#line 476 "pmtexb2.f"
    do_fio(&c__1, (char *)&all_1.iv, (ftnlen)sizeof(integer));
#line 476 "pmtexb2.f"
    e_wsfi();
/* Writing concatenation */
#line 477 "pmtexb2.f"
    i__1[0] = *lnote, a__1[0] = notex;
#line 477 "pmtexb2.f"
    notef_(ch__1, 1L, &all_1.nolev[all_1.iv + ip * 5 - 6]);
#line 477 "pmtexb2.f"
    i__1[1] = 1, a__1[1] = ch__1;
#line 477 "pmtexb2.f"
    s_cat(notex, a__1, i__1, &c__2, 25L);
#line 478 "pmtexb2.f"
    ++(*lnote);
#line 479 "pmtexb2.f"
    return 0;
} /* beamid_ */

/* Subroutine */ int beamstrt_(char *notex, integer *lnote, integer *nornb, 
	integer *ihornb, ftnlen notex_len)
{
    /* System generated locals */
    address a__1[2], a__2[3];
    integer i__1[2], i__2, i__3[3], i__4;
    real r__1;
    char ch__1[1];
    icilist ici__1;

    /* Builtin functions */
    /* Subroutine */ int s_cat(char *, char **, integer *, integer *, ftnlen);
    integer s_wsfi(icilist *), do_fio(integer *, char *, ftnlen), e_wsfi(void)
	    , s_cmp(char *, char *, ftnlen, ftnlen);

    /* Local variables */
    static integer iorn;
    static real ymin, ybot, sumx, sumy, ybeam;
    extern /* Character */ VOID notef_(char *, ftnlen, integer *);
    static integer multb;
    static real xelsk[16];
    static integer n1, n2;
    static real zmult;
    static integer nomornlev, nolev1, im;
    extern integer ni_(real *);
    static integer islope;
    extern /* Subroutine */ int setupb_(real *, integer *, real *, real *, 
	    integer *, integer *, integer *, integer *);
    static integer ibc, inb, ipb[16], nnb, maxdrop;

/* ccccccccccc */
/* c */
/* c  pmtex.inc */
/* c */
/* ccccccccccc */
#line 489 "pmtexb2.f"
    /* Parameter adjustments */
#line 489 "pmtexb2.f"
    ihornb -= 6;
#line 489 "pmtexb2.f"
    --nornb;
#line 489 "pmtexb2.f"

#line 489 "pmtexb2.f"
    /* Function Body */
#line 489 "pmtexb2.f"
    ibc = all_1.ibmcnt[all_1.iv - 1];
#line 490 "pmtexb2.f"
    n1 = all_1.ipl[all_1.iv + all_1.ibm1[all_1.iv + ibc * 5 - 6] * 5 - 6];
#line 491 "pmtexb2.f"
    n2 = all_1.ipl[all_1.iv + all_1.ibm2[all_1.iv + ibc * 5 - 6] * 5 - 6];
/* Writing concatenation */
#line 492 "pmtexb2.f"
    i__1[0] = 1, a__1[0] = all_1.s;
#line 492 "pmtexb2.f"
    i__1[1] = 1, a__1[1] = "i";
#line 492 "pmtexb2.f"
    s_cat(notex, a__1, i__1, &c__2, 25L);
#line 493 "pmtexb2.f"
    *lnote = 2;
#line 494 "pmtexb2.f"
    multb = all_1.mult[all_1.iv + all_1.ibm1[all_1.iv + ibc * 5 - 6] * 5 - 6];
#line 495 "pmtexb2.f"
    i__2 = multb;
#line 495 "pmtexb2.f"
    for (im = 1; im <= i__2; ++im) {
/* Writing concatenation */
#line 496 "pmtexb2.f"
	i__1[0] = *lnote, a__1[0] = notex;
#line 496 "pmtexb2.f"
	i__1[1] = 1, a__1[1] = "b";
#line 496 "pmtexb2.f"
	s_cat(notex, a__1, i__1, &c__2, 25L);
#line 497 "pmtexb2.f"
	++(*lnote);
#line 498 "pmtexb2.f"
/* L1: */
#line 498 "pmtexb2.f"
    }
/* Writing concatenation */
#line 499 "pmtexb2.f"
    i__1[0] = *lnote, a__1[0] = notex;
#line 499 "pmtexb2.f"
    i__1[1] = 1, a__1[1] = all_1.ul + (all_1.iv + ibc * 5 - 6);
#line 499 "pmtexb2.f"
    s_cat(notex, a__1, i__1, &c__2, 25L);
#line 500 "pmtexb2.f"
    *lnote += 2;

/*  Put in index for the beam */

#line 504 "pmtexb2.f"
    ici__1.icierr = 0;
#line 504 "pmtexb2.f"
    ici__1.icirnum = 1;
#line 504 "pmtexb2.f"
    ici__1.icirlen = 1;
#line 504 "pmtexb2.f"
    ici__1.iciunit = notex + (*lnote - 1);
#line 504 "pmtexb2.f"
    ici__1.icifmt = "(i1)";
#line 504 "pmtexb2.f"
    s_wsfi(&ici__1);
#line 504 "pmtexb2.f"
    do_fio(&c__1, (char *)&all_1.iv, (ftnlen)sizeof(integer));
#line 504 "pmtexb2.f"
    e_wsfi();
#line 505 "pmtexb2.f"
    setupb_(xelsk, &nnb, &sumx, &sumy, ipb, &islope, &nolev1, &nornb[1]);
/* #### Get 'floor' zmin for figures */
#line 507 "pmtexb2.f"
    if (comfig_1.figbass && all_1.iv == 1) {
#line 508 "pmtexb2.f"
	zmult = (multb - 1) * 1.2f;
#line 509 "pmtexb2.f"
	ymin = 100.f;
#line 510 "pmtexb2.f"
	i__2 = nnb;
#line 510 "pmtexb2.f"
	for (inb = 1; inb <= i__2; ++inb) {
#line 511 "pmtexb2.f"
	    if (s_cmp(all_1.fig + (ipb[inb - 1] - 1) * 6, "x", 6L, 1L) != 0) {
#line 512 "pmtexb2.f"
		if (all_1.ul[ibc * 5 - 5] == 'u') {
#line 513 "pmtexb2.f"
		    ybot = (real) all_1.nolev[ipb[inb - 1] * 5 - 5];
#line 514 "pmtexb2.f"
		} else {
#line 515 "pmtexb2.f"
		    ybot = islope / all_1.slfac * xelsk[inb - 1] + nolev1 - 
#line 515 "pmtexb2.f"
			    all_1.stemlen - zmult;
#line 516 "pmtexb2.f"
		}
#line 517 "pmtexb2.f"
		ymin = dmin(ymin,ybot);
#line 518 "pmtexb2.f"
	    }
#line 519 "pmtexb2.f"
/* L3: */
#line 519 "pmtexb2.f"
	}
#line 520 "pmtexb2.f"
	maxdrop = all_1.ncmid[0] - 4 - ymin + 5.01f;
/* Computing MAX */
#line 521 "pmtexb2.f"
	i__2 = comfig_1.ifigdrop[comfig_1.iline - 1];
#line 521 "pmtexb2.f"
	comfig_1.ifigdrop[comfig_1.iline - 1] = max(i__2,maxdrop);
#line 522 "pmtexb2.f"
    }
/* #### Slope & height analysis done.  Put in name start level and slope 
*/
/* Writing concatenation */
#line 524 "pmtexb2.f"
    i__3[0] = *lnote, a__2[0] = notex;
#line 524 "pmtexb2.f"
    notef_(ch__1, 1L, &nolev1);
#line 524 "pmtexb2.f"
    i__3[1] = 1, a__2[1] = ch__1;
#line 524 "pmtexb2.f"
    i__3[2] = 1, a__2[2] = "{";
#line 524 "pmtexb2.f"
    s_cat(notex, a__2, i__3, &c__3, 25L);
#line 525 "pmtexb2.f"
    *lnote += 5;
#line 526 "pmtexb2.f"
    i__2 = *lnote - 3;
#line 526 "pmtexb2.f"
    ici__1.icierr = 0;
#line 526 "pmtexb2.f"
    ici__1.icirnum = 1;
#line 526 "pmtexb2.f"
    ici__1.icirlen = *lnote - i__2;
#line 526 "pmtexb2.f"
    ici__1.iciunit = notex + i__2;
#line 526 "pmtexb2.f"
    ici__1.icifmt = "(i2,a1)";
#line 526 "pmtexb2.f"
    s_wsfi(&ici__1);
#line 526 "pmtexb2.f"
    do_fio(&c__1, (char *)&islope, (ftnlen)sizeof(integer));
#line 526 "pmtexb2.f"
    do_fio(&c__1, "}", 1L);
#line 526 "pmtexb2.f"
    e_wsfi();
/* #### Compute ornament levels if needed */
#line 528 "pmtexb2.f"
    if (nornb[all_1.iv] > 0) {
#line 529 "pmtexb2.f"
	nomornlev = all_1.ncmid[all_1.iv - 1] + 5;
#line 530 "pmtexb2.f"
	iorn = 0;
#line 531 "pmtexb2.f"
	i__2 = nnb;
#line 531 "pmtexb2.f"
	for (inb = 1; inb <= i__2; ++inb) {
#line 532 "pmtexb2.f"
	    if (all_1.orn[all_1.iv + ipb[inb - 1] * 5 - 6] != 'x') {
#line 533 "pmtexb2.f"
		++iorn;
#line 534 "pmtexb2.f"
		if (all_1.ul[all_1.iv + ibc * 5 - 6] == 'l') {
/* Computing MAX */
#line 535 "pmtexb2.f"
		    i__4 = all_1.nolev[all_1.iv + ipb[inb - 1] * 5 - 6] + 2;
#line 535 "pmtexb2.f"
		    ihornb[all_1.iv + iorn * 5] = max(i__4,nomornlev);
#line 536 "pmtexb2.f"
		} else {
#line 537 "pmtexb2.f"
		    ybeam = nolev1 + all_1.stemlen + islope * xelsk[inb - 1] /
#line 537 "pmtexb2.f"
			     all_1.slfac - 1 + (multb - 1) * 1.2f;
/* Computing MAX */
#line 539 "pmtexb2.f"
		    r__1 = ybeam + 3.5f;
#line 539 "pmtexb2.f"
		    i__4 = ni_(&r__1);
#line 539 "pmtexb2.f"
		    ihornb[all_1.iv + iorn * 5] = max(i__4,nomornlev);
#line 540 "pmtexb2.f"
		}
#line 541 "pmtexb2.f"
	    }
#line 542 "pmtexb2.f"
/* L8: */
#line 542 "pmtexb2.f"
	}
/*#### Henceforth norn(iv) will be a counter.  Be sure to zero it out 
when*/
/*     beam is finished */
#line 545 "pmtexb2.f"
	nornb[all_1.iv] = 1;
#line 546 "pmtexb2.f"
    }
#line 547 "pmtexb2.f"
    return 0;
} /* beamstrt_ */

/* Subroutine */ int beamn1_(char *notex, integer *lnote, ftnlen notex_len)
{
    /* System generated locals */
    address a__1[3], a__2[2];
    integer i__1[3], i__2, i__3, i__4[2];
    char ch__1[1];
    icilist ici__1;

    /* Builtin functions */
    /* Subroutine */ int s_cat(char *, char **, integer *, integer *, ftnlen);
    integer pow_ii(integer *, integer *), s_wsfi(icilist *), do_fio(integer *,
	     char *, ftnlen), e_wsfi(void);

    /* Local variables */
    extern /* Character */ VOID notef_(char *, ftnlen, integer *);
    static integer n1, nd;
    extern integer log2_(integer *);

/* ccccccccccc */
/* c */
/* c  pmtex.inc */
/* c */
/* ccccccccccc */
/*     real*4 xelsk(16) */
/*     integer ipb(16) */
#line 555 "pmtexb2.f"
    *lnote = 3;
/* Writing concatenation */
#line 556 "pmtexb2.f"
    i__1[0] = 1, a__1[0] = all_1.s;
#line 556 "pmtexb2.f"
    i__1[1] = 1, a__1[1] = "q";
#line 556 "pmtexb2.f"
    i__1[2] = 1, a__1[2] = all_1.hb + (all_1.iv + all_1.ibmcnt[all_1.iv - 1] *
#line 556 "pmtexb2.f"
	     5 - 6);
#line 556 "pmtexb2.f"
    s_cat(notex, a__1, i__1, &c__3, 25L);

/*  Check for dot */

#line 560 "pmtexb2.f"
    n1 = all_1.ipl[all_1.iv + all_1.ibm1[all_1.iv + all_1.ibmcnt[all_1.iv - 1]
#line 560 "pmtexb2.f"
	     * 5 - 6] * 5 - 6];
#line 561 "pmtexb2.f"
    nd = all_1.nodur[all_1.iv + all_1.list[(n1 << 2) - 3] * 5 - 6];
#line 562 "pmtexb2.f"
    i__3 = (integer) (nd / 3.f + .1f);
#line 562 "pmtexb2.f"
    i__2 = log2_(&i__3);
#line 562 "pmtexb2.f"
    if (nd != 0 && pow_ii(&c__2, &i__2) != (integer) (nd / 3.f + .1f)) {
/* Writing concatenation */
#line 563 "pmtexb2.f"
	i__4[0] = *lnote, a__2[0] = notex;
#line 563 "pmtexb2.f"
	i__4[1] = 1, a__2[1] = "p";
#line 563 "pmtexb2.f"
	s_cat(notex, a__2, i__4, &c__2, 25L);
#line 564 "pmtexb2.f"
	++(*lnote);
#line 565 "pmtexb2.f"
    }
#line 566 "pmtexb2.f"
    ++(*lnote);
#line 567 "pmtexb2.f"
    ici__1.icierr = 0;
#line 567 "pmtexb2.f"
    ici__1.icirnum = 1;
#line 567 "pmtexb2.f"
    ici__1.icirlen = 1;
#line 567 "pmtexb2.f"
    ici__1.iciunit = notex + (*lnote - 1);
#line 567 "pmtexb2.f"
    ici__1.icifmt = "(i1)";
#line 567 "pmtexb2.f"
    s_wsfi(&ici__1);
#line 567 "pmtexb2.f"
    do_fio(&c__1, (char *)&all_1.iv, (ftnlen)sizeof(integer));
#line 567 "pmtexb2.f"
    e_wsfi();
/* Writing concatenation */
#line 568 "pmtexb2.f"
    i__4[0] = *lnote, a__2[0] = notex;
#line 568 "pmtexb2.f"
    notef_(ch__1, 1L, &all_1.nolev[all_1.iv + all_1.list[(n1 << 2) - 3] * 5 - 
#line 568 "pmtexb2.f"
	    6]);
#line 568 "pmtexb2.f"
    i__4[1] = 1, a__2[1] = ch__1;
#line 568 "pmtexb2.f"
    s_cat(notex, a__2, i__4, &c__2, 25L);
#line 569 "pmtexb2.f"
    ++(*lnote);
#line 570 "pmtexb2.f"
    return 0;
} /* beamn1_ */

/* Subroutine */ int addstr_(char *notex, integer *lnote, char *sout, integer 
	*lsout, ftnlen notex_len, ftnlen sout_len)
{
    /* System generated locals */
    address a__1[2];
    integer i__1[2];
    char ch__1[81];

    /* Builtin functions */
    integer s_wsfe(cilist *);
    /* Subroutine */ int s_cat(char *, char **, integer *, integer *, ftnlen);
    integer do_fio(integer *, char *, ftnlen), e_wsfe(void);
    /* Subroutine */ int s_copy(char *, char *, ftnlen, ftnlen);

    /* Fortran I/O blocks */
    static cilist io___87 = { 0, 11, 0, "(a)", 0 };


#line 575 "pmtexb2.f"
    if (*lsout + *lnote > 72) {
#line 576 "pmtexb2.f"
	s_wsfe(&io___87);
/* Writing concatenation */
#line 576 "pmtexb2.f"
	i__1[0] = *lsout, a__1[0] = sout;
#line 576 "pmtexb2.f"
	i__1[1] = 1, a__1[1] = "%";
#line 576 "pmtexb2.f"
	s_cat(ch__1, a__1, i__1, &c__2, 81L);
#line 576 "pmtexb2.f"
	do_fio(&c__1, ch__1, *lsout + 1);
#line 576 "pmtexb2.f"
	e_wsfe();
#line 577 "pmtexb2.f"
	*lsout = 0;
#line 578 "pmtexb2.f"
    }
#line 579 "pmtexb2.f"
    if (*lsout > 0) {
/* Writing concatenation */
#line 580 "pmtexb2.f"
	i__1[0] = *lsout, a__1[0] = sout;
#line 580 "pmtexb2.f"
	i__1[1] = *lnote, a__1[1] = notex;
#line 580 "pmtexb2.f"
	s_cat(sout, a__1, i__1, &c__2, 80L);
#line 581 "pmtexb2.f"
    } else {
#line 582 "pmtexb2.f"
	s_copy(sout, notex, 80L, (*lnote));
#line 583 "pmtexb2.f"
    }
#line 584 "pmtexb2.f"
    *lsout += *lnote;
#line 585 "pmtexb2.f"
    return 0;
} /* addstr_ */

/* Character */ VOID notef_(char *ret_val, ftnlen ret_val_len, integer *nolev)
{
#line 588 "pmtexb2.f"
    if (*nolev <= 26) {
#line 589 "pmtexb2.f"
	*ret_val = (char) (*nolev + 52);
#line 590 "pmtexb2.f"
    } else {
#line 591 "pmtexb2.f"
	*ret_val = (char) (*nolev + 70);
#line 592 "pmtexb2.f"
    }
#line 593 "pmtexb2.f"
    return ;
} /* notef_ */

/* Subroutine */ int notex_(char *mynotex, integer *lnote, ftnlen mynotex_len)
{
    /* System generated locals */
    address a__1[5], a__2[4], a__3[6], a__4[2];
    integer i__1, i__2, i__3[5], i__4[4], i__5[6], i__6[2];
    real r__1;
    char ch__1[1];

    /* Builtin functions */
    integer s_cmp(char *, char *, ftnlen, ftnlen), pow_ii(integer *, integer *
	    );
    /* Subroutine */ int s_cat(char *, char **, integer *, integer *, ftnlen);

    /* Local variables */
    static integer nole;
    static char note[1];
    static integer nodu;
    static real zmin, fnole;
    extern /* Character */ VOID notef_(char *, ftnlen, integer *);
    static char ud[1];
    extern /* Character */ VOID ulf_(char *, ftnlen, real *);
    extern integer log2_(integer *);

/* ccccccccccc */
/* c */
/* c  pmtex.inc */
/* c */
/* ccccccccccc */
#line 602 "pmtexb2.f"
    nole = all_1.nolev[all_1.iv + all_1.list[(all_1.jn << 2) - 3] * 5 - 6];
#line 603 "pmtexb2.f"
    nodu = all_1.nodur[all_1.iv + all_1.list[(all_1.jn << 2) - 3] * 5 - 6];
#line 604 "pmtexb2.f"
    r__1 = (nole - all_1.ncmid[all_1.iv - 1]) * 1.f;
#line 604 "pmtexb2.f"
    ulf_(ch__1, 1L, &r__1);
#line 604 "pmtexb2.f"
    *ud = ch__1[0];
/* ####  Check figure level */
#line 606 "pmtexb2.f"
    if (comfig_1.figbass && all_1.iv == 1 && s_cmp(all_1.fig + (all_1.list[(
#line 606 "pmtexb2.f"
	    all_1.jn << 2) - 3] - 1) * 6, "x", 6L, 1L) != 0) {
#line 608 "pmtexb2.f"
	if (*ud == 'u') {
/* #### Upper stem, fnole (in noleunits) set by notehead */
#line 610 "pmtexb2.f"
	    fnole = (real) nole;
#line 611 "pmtexb2.f"
	} else {
/* ##### Lower stem, fnole set by bottom of stem */
#line 613 "pmtexb2.f"
	    fnole = nole - all_1.stemlen;
#line 614 "pmtexb2.f"
	}
#line 615 "pmtexb2.f"
	zmin = fnole - all_1.ncmid[0] + 4;
/* Computing MAX */
#line 616 "pmtexb2.f"
	i__1 = comfig_1.ifigdrop[comfig_1.iline - 1], i__2 = (integer) (4 - 
#line 616 "pmtexb2.f"
		zmin + .5f);
#line 616 "pmtexb2.f"
	comfig_1.ifigdrop[comfig_1.iline - 1] = max(i__1,i__2);
#line 617 "pmtexb2.f"
    }
#line 618 "pmtexb2.f"
    if (! all_1.rest[all_1.iv + all_1.list[(all_1.jn << 2) - 3] * 5 - 6]) {
#line 619 "pmtexb2.f"
	*lnote = 5;
#line 620 "pmtexb2.f"
	notef_(ch__1, 1L, &nole);
#line 620 "pmtexb2.f"
	*note = ch__1[0];
#line 621 "pmtexb2.f"
	i__2 = (integer) (nodu / 3.f + .1f);
#line 621 "pmtexb2.f"
	i__1 = log2_(&i__2);
#line 621 "pmtexb2.f"
	if ((integer) (nodu / 3.f + .1f) == pow_ii(&c__2, &i__1)) {
#line 622 "pmtexb2.f"
	    if (nodu == 3) {
/* Writing concatenation */
#line 623 "pmtexb2.f"
		i__3[0] = 1, a__1[0] = all_1.s;
#line 623 "pmtexb2.f"
		i__3[1] = 3, a__1[1] = "ccc";
#line 623 "pmtexb2.f"
		i__3[2] = 1, a__1[2] = ud;
#line 623 "pmtexb2.f"
		i__3[3] = 1, a__1[3] = " ";
#line 623 "pmtexb2.f"
		i__3[4] = 1, a__1[4] = note;
#line 623 "pmtexb2.f"
		s_cat(mynotex, a__1, i__3, &c__5, 25L);
#line 624 "pmtexb2.f"
		*lnote = 7;
#line 625 "pmtexb2.f"
	    } else if (nodu == 6) {
/* Writing concatenation */
#line 626 "pmtexb2.f"
		i__3[0] = 1, a__1[0] = all_1.s;
#line 626 "pmtexb2.f"
		i__3[1] = 2, a__1[1] = "cc";
#line 626 "pmtexb2.f"
		i__3[2] = 1, a__1[2] = ud;
#line 626 "pmtexb2.f"
		i__3[3] = 1, a__1[3] = " ";
#line 626 "pmtexb2.f"
		i__3[4] = 1, a__1[4] = note;
#line 626 "pmtexb2.f"
		s_cat(mynotex, a__1, i__3, &c__5, 25L);
#line 627 "pmtexb2.f"
		*lnote = 6;
#line 628 "pmtexb2.f"
	    } else if (nodu == 12) {
/* Writing concatenation */
#line 629 "pmtexb2.f"
		i__3[0] = 1, a__1[0] = all_1.s;
#line 629 "pmtexb2.f"
		i__3[1] = 1, a__1[1] = "c";
#line 629 "pmtexb2.f"
		i__3[2] = 1, a__1[2] = ud;
#line 629 "pmtexb2.f"
		i__3[3] = 1, a__1[3] = " ";
#line 629 "pmtexb2.f"
		i__3[4] = 1, a__1[4] = note;
#line 629 "pmtexb2.f"
		s_cat(mynotex, a__1, i__3, &c__5, 25L);
#line 630 "pmtexb2.f"
	    } else if (nodu == 24) {
/* Writing concatenation */
#line 631 "pmtexb2.f"
		i__3[0] = 1, a__1[0] = all_1.s;
#line 631 "pmtexb2.f"
		i__3[1] = 1, a__1[1] = "q";
#line 631 "pmtexb2.f"
		i__3[2] = 1, a__1[2] = ud;
#line 631 "pmtexb2.f"
		i__3[3] = 1, a__1[3] = " ";
#line 631 "pmtexb2.f"
		i__3[4] = 1, a__1[4] = note;
#line 631 "pmtexb2.f"
		s_cat(mynotex, a__1, i__3, &c__5, 25L);
#line 632 "pmtexb2.f"
	    } else if (nodu == 48) {
/* Writing concatenation */
#line 633 "pmtexb2.f"
		i__3[0] = 1, a__1[0] = all_1.s;
#line 633 "pmtexb2.f"
		i__3[1] = 1, a__1[1] = "h";
#line 633 "pmtexb2.f"
		i__3[2] = 1, a__1[2] = ud;
#line 633 "pmtexb2.f"
		i__3[3] = 1, a__1[3] = " ";
#line 633 "pmtexb2.f"
		i__3[4] = 1, a__1[4] = note;
#line 633 "pmtexb2.f"
		s_cat(mynotex, a__1, i__3, &c__5, 25L);
#line 634 "pmtexb2.f"
	    } else if (nodu == 96) {
/* Writing concatenation */
#line 635 "pmtexb2.f"
		i__4[0] = 1, a__2[0] = all_1.s;
#line 635 "pmtexb2.f"
		i__4[1] = 2, a__2[1] = "wh";
#line 635 "pmtexb2.f"
		i__4[2] = 1, a__2[2] = " ";
#line 635 "pmtexb2.f"
		i__4[3] = 1, a__2[3] = note;
#line 635 "pmtexb2.f"
		s_cat(mynotex, a__2, i__4, &c__4, 25L);
#line 636 "pmtexb2.f"
	    }
#line 637 "pmtexb2.f"
	} else {
#line 638 "pmtexb2.f"
	    *lnote = 6;
#line 639 "pmtexb2.f"
	    if (nodu == 18) {
/* Writing concatenation */
#line 640 "pmtexb2.f"
		i__5[0] = 1, a__3[0] = all_1.s;
#line 640 "pmtexb2.f"
		i__5[1] = 1, a__3[1] = "c";
#line 640 "pmtexb2.f"
		i__5[2] = 1, a__3[2] = ud;
#line 640 "pmtexb2.f"
		i__5[3] = 1, a__3[3] = "p";
#line 640 "pmtexb2.f"
		i__5[4] = 1, a__3[4] = " ";
#line 640 "pmtexb2.f"
		i__5[5] = 1, a__3[5] = note;
#line 640 "pmtexb2.f"
		s_cat(mynotex, a__3, i__5, &c__6, 25L);
#line 641 "pmtexb2.f"
	    } else if (nodu == 36) {
/* Writing concatenation */
#line 642 "pmtexb2.f"
		i__5[0] = 1, a__3[0] = all_1.s;
#line 642 "pmtexb2.f"
		i__5[1] = 1, a__3[1] = "q";
#line 642 "pmtexb2.f"
		i__5[2] = 1, a__3[2] = ud;
#line 642 "pmtexb2.f"
		i__5[3] = 1, a__3[3] = "p";
#line 642 "pmtexb2.f"
		i__5[4] = 1, a__3[4] = " ";
#line 642 "pmtexb2.f"
		i__5[5] = 1, a__3[5] = note;
#line 642 "pmtexb2.f"
		s_cat(mynotex, a__3, i__5, &c__6, 25L);
#line 643 "pmtexb2.f"
	    } else if (nodu == 72) {
/* Writing concatenation */
#line 644 "pmtexb2.f"
		i__5[0] = 1, a__3[0] = all_1.s;
#line 644 "pmtexb2.f"
		i__5[1] = 1, a__3[1] = "h";
#line 644 "pmtexb2.f"
		i__5[2] = 1, a__3[2] = ud;
#line 644 "pmtexb2.f"
		i__5[3] = 1, a__3[3] = "p";
#line 644 "pmtexb2.f"
		i__5[4] = 1, a__3[4] = " ";
#line 644 "pmtexb2.f"
		i__5[5] = 1, a__3[5] = note;
#line 644 "pmtexb2.f"
		s_cat(mynotex, a__3, i__5, &c__6, 25L);
#line 645 "pmtexb2.f"
	    } else if (nodu == 9) {
/* Writing concatenation */
#line 646 "pmtexb2.f"
		i__5[0] = 1, a__3[0] = all_1.s;
#line 646 "pmtexb2.f"
		i__5[1] = 1, a__3[1] = "c";
#line 646 "pmtexb2.f"
		i__5[2] = 1, a__3[2] = ud;
#line 646 "pmtexb2.f"
		i__5[3] = 1, a__3[3] = "p";
#line 646 "pmtexb2.f"
		i__5[4] = 1, a__3[4] = " ";
#line 646 "pmtexb2.f"
		i__5[5] = 1, a__3[5] = note;
#line 646 "pmtexb2.f"
		s_cat(mynotex, a__3, i__5, &c__6, 25L);
#line 647 "pmtexb2.f"
		*lnote = 7;
#line 648 "pmtexb2.f"
	    }
#line 649 "pmtexb2.f"
	}
#line 650 "pmtexb2.f"
    } else {

/*  "rest" (real, whole-bar, or accidental gap) */

#line 654 "pmtexb2.f"
	*lnote = 3;

/*  First check for whole-bar rest. */

#line 658 "pmtexb2.f"
	if (all_1.acc[all_1.iv + all_1.list[(all_1.jn << 2) - 3] * 5 - 6] == 
#line 658 "pmtexb2.f"
		'b') {
/* Writing concatenation */
#line 659 "pmtexb2.f"
	    i__6[0] = 1, a__4[0] = all_1.s;
#line 659 "pmtexb2.f"
	    i__6[1] = 2, a__4[1] = "sk";
#line 659 "pmtexb2.f"
	    s_cat(mynotex, a__4, i__6, &c__2, 25L);
#line 660 "pmtexb2.f"
	} else if (all_1.acc[all_1.iv + all_1.list[(all_1.jn << 2) - 3] * 5 - 
#line 660 "pmtexb2.f"
		6] == 'w') {
/* Writing concatenation */
#line 661 "pmtexb2.f"
	    i__5[0] = 1, a__3[0] = all_1.s;
#line 661 "pmtexb2.f"
	    i__5[1] = 5, a__3[1] = "rlap{";
#line 661 "pmtexb2.f"
	    i__5[2] = 1, a__3[2] = all_1.s;
#line 661 "pmtexb2.f"
	    i__5[3] = 3, a__3[3] = "qsk";
#line 661 "pmtexb2.f"
	    i__5[4] = 1, a__3[4] = all_1.s;
#line 661 "pmtexb2.f"
	    i__5[5] = 6, a__3[5] = "pause}";
#line 661 "pmtexb2.f"
	    s_cat(mynotex, a__3, i__5, &c__6, 25L);
#line 662 "pmtexb2.f"
	    *lnote = 17;

/*  Now check for accidental gap */

#line 666 "pmtexb2.f"
	} else if (all_1.acc[all_1.iv + all_1.list[(all_1.jn << 2) - 3] * 5 - 
#line 666 "pmtexb2.f"
		6] == 'a') {
/* Writing concatenation */
#line 667 "pmtexb2.f"
	    i__6[0] = 1, a__4[0] = all_1.s;
#line 667 "pmtexb2.f"
	    i__6[1] = 3, a__4[1] = "ask";
#line 667 "pmtexb2.f"
	    s_cat(mynotex, a__4, i__6, &c__2, 25L);
#line 668 "pmtexb2.f"
	    *lnote = 4;
#line 669 "pmtexb2.f"
	} else if (nodu == 3) {
/* Writing concatenation */
#line 670 "pmtexb2.f"
	    i__6[0] = 1, a__4[0] = all_1.s;
#line 670 "pmtexb2.f"
	    i__6[1] = 2, a__4[1] = "hs";
#line 670 "pmtexb2.f"
	    s_cat(mynotex, a__4, i__6, &c__2, 25L);
#line 671 "pmtexb2.f"
	} else if (nodu == 6) {
/* Writing concatenation */
#line 672 "pmtexb2.f"
	    i__6[0] = 1, a__4[0] = all_1.s;
#line 672 "pmtexb2.f"
	    i__6[1] = 2, a__4[1] = "qs";
#line 672 "pmtexb2.f"
	    s_cat(mynotex, a__4, i__6, &c__2, 25L);
#line 673 "pmtexb2.f"
	} else if (nodu == 12) {
/* Writing concatenation */
#line 674 "pmtexb2.f"
	    i__6[0] = 1, a__4[0] = all_1.s;
#line 674 "pmtexb2.f"
	    i__6[1] = 2, a__4[1] = "ds";
#line 674 "pmtexb2.f"
	    s_cat(mynotex, a__4, i__6, &c__2, 25L);
#line 675 "pmtexb2.f"
	} else if (nodu == 24) {
/* Writing concatenation */
#line 676 "pmtexb2.f"
	    i__6[0] = 1, a__4[0] = all_1.s;
#line 676 "pmtexb2.f"
	    i__6[1] = 2, a__4[1] = "qp";
#line 676 "pmtexb2.f"
	    s_cat(mynotex, a__4, i__6, &c__2, 25L);
#line 677 "pmtexb2.f"
	} else if (nodu == 48) {
/* Writing concatenation */
#line 678 "pmtexb2.f"
	    i__6[0] = 1, a__4[0] = all_1.s;
#line 678 "pmtexb2.f"
	    i__6[1] = 6, a__4[1] = "hpause";
#line 678 "pmtexb2.f"
	    s_cat(mynotex, a__4, i__6, &c__2, 25L);
#line 679 "pmtexb2.f"
	    *lnote = 7;
#line 680 "pmtexb2.f"
	} else if (nodu == 96) {
/* Writing concatenation */
#line 681 "pmtexb2.f"
	    i__6[0] = 1, a__4[0] = all_1.s;
#line 681 "pmtexb2.f"
	    i__6[1] = 5, a__4[1] = "pause";
#line 681 "pmtexb2.f"
	    s_cat(mynotex, a__4, i__6, &c__2, 25L);
#line 682 "pmtexb2.f"
	    *lnote = 6;
#line 683 "pmtexb2.f"
	}
#line 684 "pmtexb2.f"
    }
#line 685 "pmtexb2.f"
    return 0;
} /* notex_ */

/* Subroutine */ int fillbeat_(integer *lenbeam, integer *ip1, integer *
	numbms)
{
    /* System generated locals */
    integer i__1, i__2, i__3;
    real r__1;
    char ch__1[1];

    /* Builtin functions */
    integer s_wsle(cilist *), do_lio(integer *, integer *, char *, ftnlen), 
	    e_wsle(void);
    /* Subroutine */ int s_stop(char *, ftnlen);

    /* Local variables */
    static integer nask, itend, ixtra, l2, ip, jp;
    static real elskbm;
    static integer in1, ip2, it1, it2;
    extern /* Character */ VOID hbf_(char *, ftnlen, real *);
    static integer iip;
    extern /* Character */ VOID ulf_(char *, ftnlen, real *);
    static real sum;
    extern integer log2_(integer *);

    /* Fortran I/O blocks */
    static cilist io___107 = { 0, 6, 0, 0, 0 };


/* ccccccccccc */
/* c */
/* c  pmtex.inc */
/* c */
/* ccccccccccc */
#line 691 "pmtexb2.f"
    /* Parameter adjustments */
#line 691 "pmtexb2.f"
    --numbms;
#line 691 "pmtexb2.f"

#line 691 "pmtexb2.f"
    /* Function Body */
#line 691 "pmtexb2.f"
    in1 = all_1.ipl[all_1.iv + *ip1 * 5 - 6];
#line 692 "pmtexb2.f"
    it1 = all_1.list[(in1 << 2) - 2];
#line 693 "pmtexb2.f"
    it2 = it1 + *lenbeam;
#line 694 "pmtexb2.f"
    itend = it1 + all_1.nodur[all_1.iv + *ip1 * 5 - 6];
/* ### Bounce out if (a) starting time not on an even beat, */
/*                  (b) rest */
/*                  (c) a single note fills the beat */
/*                  (d) too close to the end of the bar */
/*                  (e) note is quarter or longer */
#line 700 "pmtexb2.f"
    if (it1 % *lenbeam != 0 || all_1.rest[all_1.iv + *ip1 * 5 - 6] || 
#line 700 "pmtexb2.f"
	    all_1.nodur[all_1.iv + *ip1 * 5 - 6] == *lenbeam || itend >= it2 
#line 700 "pmtexb2.f"
	    || all_1.nodur[all_1.iv + *ip1 * 5 - 6] >= 24) {
#line 700 "pmtexb2.f"
	return 0;
#line 700 "pmtexb2.f"
    }

/* In the previous line, "if ... rest" makes beams starting with spaced */
/* accidentals begin on the note rather than the accidental. */

#line 707 "pmtexb2.f"
    i__1 = all_1.nn[all_1.iv - 1];
#line 707 "pmtexb2.f"
    for (ip = *ip1 + 1; ip <= i__1; ++ip) {
/* Add new note */
#line 709 "pmtexb2.f"
	itend += all_1.nodur[all_1.iv + ip * 5 - 6];
/*### Check for real rest or gone past end of potential beam or note 
>= quarter*/
#line 711 "pmtexb2.f"
	if (all_1.rest[all_1.iv + ip * 5 - 6] && all_1.acc[all_1.iv + ip * 5 
#line 711 "pmtexb2.f"
		- 6] != 'a' || itend > it2 || all_1.nodur[all_1.iv + ip * 5 - 
#line 711 "pmtexb2.f"
		6] >= 24) {
#line 711 "pmtexb2.f"
	    return 0;
#line 711 "pmtexb2.f"
	}

/* If "rest" at this point, it has to be an accidental skip */

#line 716 "pmtexb2.f"
	if (itend < it2 || itend == it2 && all_1.rest[all_1.iv + ip * 5 - 6]) 
#line 716 "pmtexb2.f"
		{
#line 716 "pmtexb2.f"
	    goto L1;
#line 716 "pmtexb2.f"
	}

/*  AHA beams */

#line 720 "pmtexb2.f"
	++numbms[all_1.iv];
#line 721 "pmtexb2.f"
	all_1.ibm1[all_1.iv + numbms[all_1.iv] * 5 - 6] = *ip1;
#line 722 "pmtexb2.f"
	ip2 = ip;

/*  Special check for 4 eighth notes or 3 8ths + 8th rest */

/*       if (mod(it1,48).eq.0 .and. nodur(iv,ip1).eq.12 */
/*    *      .and. nodur(iv,ip2).eq.12 .and. lenbar.eq.96 .and. */
/*    *      nn(iv).ge.ip2+2 .and. nodur(iv,ip2+1).eq.12 */
/*    *      .and. nodur(iv,ip2+2).eq.12 .and. .not.rest(iv,ip2+1)) */
/*    *      then */
/*         if (rest(iv,ip2+2)) then */
/*           ip2 = ip2+1 */
/*         else */
/*           ip2 = ip2+2 */
/*         end if */
/*       end if */
#line 737 "pmtexb2.f"
	if (it1 % 48 == 0 && all_1.nodur[all_1.iv + *ip1 * 5 - 6] == 12 && 
#line 737 "pmtexb2.f"
		all_1.nodur[all_1.iv + ip2 * 5 - 6] == 12 && all_1.lenbar == 
#line 737 "pmtexb2.f"
		96 && all_1.nn[all_1.iv - 1] >= ip2 + 2) {
/* #### We have 2 1/8th notes.  Look for third and fourth. */
#line 741 "pmtexb2.f"
	    ixtra = 0;
#line 742 "pmtexb2.f"
	    i__2 = all_1.nn[all_1.iv - 1];
#line 742 "pmtexb2.f"
	    for (jp = ip2 + 1; jp <= i__2; ++jp) {
#line 743 "pmtexb2.f"
		if (all_1.nodur[all_1.iv + jp * 5 - 6] != 12 && all_1.acc[
#line 743 "pmtexb2.f"
			all_1.iv + jp * 5 - 6] != 'a' || ixtra == 0 && 
#line 743 "pmtexb2.f"
			all_1.rest[all_1.iv + jp * 5 - 6]) {
#line 743 "pmtexb2.f"
		    goto L4;
#line 743 "pmtexb2.f"
		}
#line 745 "pmtexb2.f"
		if (all_1.acc[all_1.iv + jp * 5 - 6] == 'a') {
#line 745 "pmtexb2.f"
		    goto L3;
#line 745 "pmtexb2.f"
		}
#line 746 "pmtexb2.f"
		++ixtra;
#line 747 "pmtexb2.f"
		if (ixtra == 2) {
#line 748 "pmtexb2.f"
		    if (all_1.rest[all_1.iv + jp * 5 - 6]) {
/* #### 3-1/8th note beam.  Back up to note */
#line 750 "pmtexb2.f"
			ip2 = jp - 1;
#line 751 "pmtexb2.f"
L5:
#line 751 "pmtexb2.f"
			if (all_1.rest[all_1.iv + ip2 * 5 - 6]) {
#line 752 "pmtexb2.f"
			    --ip2;
#line 753 "pmtexb2.f"
			    goto L5;
#line 754 "pmtexb2.f"
			}
#line 755 "pmtexb2.f"
		    } else {
#line 756 "pmtexb2.f"
			ip2 = jp;
#line 757 "pmtexb2.f"
		    }
#line 758 "pmtexb2.f"
		    goto L4;
#line 759 "pmtexb2.f"
		}
#line 760 "pmtexb2.f"
L3:
#line 760 "pmtexb2.f"
		;
#line 760 "pmtexb2.f"
	    }
#line 761 "pmtexb2.f"
	}
#line 762 "pmtexb2.f"
L4:
#line 763 "pmtexb2.f"
	all_1.ibm2[all_1.iv + numbms[all_1.iv] * 5 - 6] = ip2;
#line 764 "pmtexb2.f"
	sum = 0.f;
#line 765 "pmtexb2.f"
	elskbm = 0.f;
#line 766 "pmtexb2.f"
	nask = 0;
#line 767 "pmtexb2.f"
	i__2 = ip2;
#line 767 "pmtexb2.f"
	for (iip = *ip1; iip <= i__2; ++iip) {
#line 768 "pmtexb2.f"
	    if (all_1.rest[all_1.iv + iip * 5 - 6]) {
#line 769 "pmtexb2.f"
		all_1.mult[all_1.iv + iip * 5 - 6] = 0;
#line 770 "pmtexb2.f"
		++nask;
#line 771 "pmtexb2.f"
	    } else {
#line 772 "pmtexb2.f"
		i__3 = (integer) (all_1.nodur[all_1.iv + iip * 5 - 6] / 3.f + 
#line 772 "pmtexb2.f"
			.1f);
#line 772 "pmtexb2.f"
		l2 = log2_(&i__3);
#line 773 "pmtexb2.f"
		sum += all_1.nolev[all_1.iv + iip * 5 - 6];
#line 774 "pmtexb2.f"
		all_1.mult[all_1.iv + iip * 5 - 6] = 3 - l2;
#line 775 "pmtexb2.f"
	    }
#line 776 "pmtexb2.f"
/* L2: */
#line 776 "pmtexb2.f"
	}
#line 777 "pmtexb2.f"
	r__1 = sum / (ip2 - *ip1 + 1 - nask) - all_1.ncmid[all_1.iv - 1];
#line 777 "pmtexb2.f"
	ulf_(ch__1, 1L, &r__1);
#line 777 "pmtexb2.f"
	all_1.ul[all_1.iv + numbms[all_1.iv] * 5 - 6] = ch__1[0];
#line 778 "pmtexb2.f"
	r__1 = sum / (ip2 - *ip1 + 1 - nask) - all_1.ncmid[all_1.iv - 1];
#line 778 "pmtexb2.f"
	hbf_(ch__1, 1L, &r__1);
#line 778 "pmtexb2.f"
	all_1.hb[all_1.iv + numbms[all_1.iv] * 5 - 6] = ch__1[0];
#line 779 "pmtexb2.f"
	return 0;
#line 780 "pmtexb2.f"
L1:
#line 780 "pmtexb2.f"
	;
#line 780 "pmtexb2.f"
    }
#line 781 "pmtexb2.f"
    s_wsle(&io___107);
#line 781 "pmtexb2.f"
    do_lio(&c__9, &c__1, "You should not be here in fillbeat", 34L);
#line 781 "pmtexb2.f"
    e_wsle();
#line 782 "pmtexb2.f"
    s_stop("", 0L);
#line 783 "pmtexb2.f"
    return 0;
} /* fillbeat_ */

/* Character */ VOID ulf_(char *ret_val, ftnlen ret_val_len, real *xnolev)
{
#line 785 "pmtexb2.f"
    if (*xnolev >= 0.f) {
#line 786 "pmtexb2.f"
	*ret_val = 'l';
#line 787 "pmtexb2.f"
    } else {
#line 788 "pmtexb2.f"
	*ret_val = 'u';
#line 789 "pmtexb2.f"
    }
#line 790 "pmtexb2.f"
    return ;
} /* ulf_ */

/* Character */ VOID hbf_(char *ret_val, ftnlen ret_val_len, real *xnolev)
{
#line 793 "pmtexb2.f"
    if (*xnolev >= 0.f) {
#line 794 "pmtexb2.f"
	*ret_val = 'b';
#line 795 "pmtexb2.f"
    } else {
#line 796 "pmtexb2.f"
	*ret_val = 'h';
#line 797 "pmtexb2.f"
    }
#line 798 "pmtexb2.f"
    return ;
} /* hbf_ */

/* Subroutine */ int makeabar_(void)
{
    /* Initialized data */

    static char nstart[5*6] = "notes" "Notes" "NOtes" "NOTes" "NOTEs" "NOTES";

    /* System generated locals */
    address a__1[2], a__2[3];
    integer i__1, i__2, i__3, i__4, i__5[2], i__6[3], i__7;
    real r__1;
    char ch__1[3], ch__2[4], ch__3[6], ch__4[1], ch__5[26], ch__6[7], ch__7[
	    81];

    /* Builtin functions */
    integer s_wsle(cilist *), do_lio(integer *, integer *, char *, ftnlen), 
	    e_wsle(void);
    /* Subroutine */ int s_stop(char *, ftnlen), s_cat(char *, char **, 
	    integer *, integer *, ftnlen);
    integer s_cmp(char *, char *, ftnlen, ftnlen), s_wsfe(cilist *), do_fio(
	    integer *, char *, ftnlen), e_wsfe(void);

    /* Local variables */
    static integer ilnc, infr;
    extern /* Subroutine */ int fillbeat_(integer *, integer *, integer *);
    static integer itim, ntot;
    static char sout[80];
    extern /* Subroutine */ int beamstrt_(char *, integer *, integer *, 
	    integer *, ftnlen);
    static integer itendnow, nbold;
    extern /* Character */ VOID notef_(char *, ftnlen, integer *);
    static integer iitim, nornb[5], ihorn, itmin, lnote;
    extern /* Subroutine */ int notex_(char *, integer *, ftnlen);
    static integer istop[20], itnow;
    extern /* Subroutine */ int beamn1_(char *, integer *, ftnlen);
    static integer lsout, ib, nb;
    extern /* Subroutine */ int beamid_(char *, integer *, ftnlen);
    static integer in, ip;
    extern integer ni_(real *);
    static integer it[5], jv, nspace[20];
    static logical bspend;
    static integer ihornb[80]	/* was [5][16] */;
    extern /* Subroutine */ int addstr_(char *, integer *, char *, integer *, 
	    ftnlen, ftnlen);
    static integer nindex[20], itminn;
    extern /* Subroutine */ int putfig_(char *, char *, integer *, ftnlen, 
	    ftnlen);
    static integer numbms[5], ittemp, istart[20], ivnext;
    extern /* Subroutine */ int beamend_(char *, integer *, ftnlen);
    static integer cnn[5], iin, iip;
    extern integer log2_(integer *);
    static integer itstart[20], itwrest;
    static char mynotex[25];
    extern /* Subroutine */ int add2list_(integer *, integer *, integer *, 
	    integer *, char *, logical *, integer *, integer *, integer *, 
	    integer *, ftnlen);

    /* Fortran I/O blocks */
    static cilist io___117 = { 0, 6, 0, 0, 0 };
    static cilist io___120 = { 0, 6, 0, 0, 0 };
    static cilist io___132 = { 0, 6, 0, 0, 0 };
    static cilist io___148 = { 0, 11, 0, "(a)", 0 };


/* ccccccccccc */
/* c */
/* c  pmtex.inc */
/* c */
/* ccccccccccc */
#line 812 "pmtexb2.f"
    i__1 = all_1.nv;
#line 812 "pmtexb2.f"
    for (all_1.iv = 1; all_1.iv <= i__1; ++all_1.iv) {
#line 813 "pmtexb2.f"
	if (all_1.ibar > 1) {
#line 814 "pmtexb2.f"
	    all_1.nn[all_1.iv - 1] = all_1.nib[all_1.iv + all_1.ibar * 5 - 6] 
#line 814 "pmtexb2.f"
		    - all_1.nib[all_1.iv + (all_1.ibar - 1) * 5 - 6];
#line 815 "pmtexb2.f"
	} else {
#line 816 "pmtexb2.f"
	    all_1.nn[all_1.iv - 1] = all_1.nib[all_1.iv + all_1.ibar * 5 - 6];
#line 817 "pmtexb2.f"
	}
#line 818 "pmtexb2.f"
/* L1: */
#line 818 "pmtexb2.f"
    }

/* initialize list note counter, time(iv), curr. note(iv) */

#line 822 "pmtexb2.f"
    ilnc = 1;
#line 823 "pmtexb2.f"
    i__1 = all_1.nv;
#line 823 "pmtexb2.f"
    for (all_1.iv = 1; all_1.iv <= i__1; ++all_1.iv) {
#line 824 "pmtexb2.f"
	if (all_1.nn[all_1.iv - 1] > 1) {
#line 825 "pmtexb2.f"
	    it[all_1.iv - 1] = all_1.nodur[all_1.iv - 1];
#line 826 "pmtexb2.f"
	} else {
#line 827 "pmtexb2.f"
	    it[all_1.iv - 1] = 1000;
#line 828 "pmtexb2.f"
	}
#line 829 "pmtexb2.f"
	cnn[all_1.iv - 1] = 1;
#line 830 "pmtexb2.f"
	all_1.list[(ilnc << 2) - 4] = all_1.iv;
#line 831 "pmtexb2.f"
	all_1.list[(ilnc << 2) - 3] = 1;
#line 832 "pmtexb2.f"
	++ilnc;
#line 833 "pmtexb2.f"
/* L4: */
#line 833 "pmtexb2.f"
    }

/*  Build the list */

#line 837 "pmtexb2.f"
L5:

/*  Determine which voice comes next from end of notes done so far. */
/*  itmin is the earliest ending time of notes done so far */

#line 842 "pmtexb2.f"
    itmin = 1000;
#line 843 "pmtexb2.f"
    i__1 = all_1.nv;
#line 843 "pmtexb2.f"
    for (all_1.iv = 1; all_1.iv <= i__1; ++all_1.iv) {
/* Computing MIN */
#line 844 "pmtexb2.f"
	i__2 = itmin, i__3 = it[all_1.iv - 1];
#line 844 "pmtexb2.f"
	itminn = min(i__2,i__3);
#line 845 "pmtexb2.f"
	if (itminn < itmin) {
#line 846 "pmtexb2.f"
	    itmin = itminn;
#line 847 "pmtexb2.f"
	    ivnext = all_1.iv;
#line 848 "pmtexb2.f"
	}
#line 849 "pmtexb2.f"
/* L6: */
#line 849 "pmtexb2.f"
    }
#line 850 "pmtexb2.f"
    if (itmin == 1000) {
#line 850 "pmtexb2.f"
	goto L7;
#line 850 "pmtexb2.f"
    }
#line 851 "pmtexb2.f"
    all_1.list[(ilnc << 2) - 4] = ivnext;
#line 852 "pmtexb2.f"
    ++cnn[ivnext - 1];
#line 853 "pmtexb2.f"
    all_1.list[(ilnc << 2) - 3] = cnn[ivnext - 1];
#line 854 "pmtexb2.f"
    all_1.list[(ilnc << 2) - 2] = itmin;

/*  Check if this voice is done */

#line 858 "pmtexb2.f"
    if (cnn[ivnext - 1] == all_1.nn[ivnext - 1]) {
#line 859 "pmtexb2.f"
	it[ivnext - 1] = 1000;
#line 860 "pmtexb2.f"
    } else {
#line 861 "pmtexb2.f"
	it[ivnext - 1] += all_1.nodur[ivnext + cnn[ivnext - 1] * 5 - 6];
#line 862 "pmtexb2.f"
    }
#line 863 "pmtexb2.f"
    ++ilnc;
#line 864 "pmtexb2.f"
    goto L5;
#line 865 "pmtexb2.f"
L7:
#line 866 "pmtexb2.f"
    ntot = ilnc - 1;
#line 867 "pmtexb2.f"
    i__1 = ntot - 1;
#line 867 "pmtexb2.f"
    for (in = 1; in <= i__1; ++in) {
#line 868 "pmtexb2.f"
	all_1.list[(in << 2) - 1] = all_1.list[(in + 1 << 2) - 2] - 
#line 868 "pmtexb2.f"
		all_1.list[(in << 2) - 2];
#line 869 "pmtexb2.f"
/* L8: */
#line 869 "pmtexb2.f"
    }
#line 870 "pmtexb2.f"
    all_1.list[(ntot << 2) - 1] = all_1.nodur[all_1.list[(ntot << 2) - 4] + 
#line 870 "pmtexb2.f"
	    all_1.list[(ntot << 2) - 3] * 5 - 6];

/*  Done w/ list, but for special checks. First, for full-bar rests */

#line 874 "pmtexb2.f"
    i__1 = all_1.nv;
#line 874 "pmtexb2.f"
    for (all_1.iv = 1; all_1.iv <= i__1; ++all_1.iv) {
#line 875 "pmtexb2.f"
	if (all_1.nodur[all_1.iv - 1] == all_1.lenbar && all_1.rest[all_1.iv 
#line 875 "pmtexb2.f"
		- 1] && ntot > all_1.nv) {

/*  Find the last list position (in) before the half-bar */

#line 879 "pmtexb2.f"
	    i__2 = ntot - 1;
#line 879 "pmtexb2.f"
	    for (in = 1; in <= i__2; ++in) {
#line 880 "pmtexb2.f"
		if (all_1.list[(in + 1 << 2) - 2] >= all_1.lenbar / 2) {
#line 880 "pmtexb2.f"
		    goto L32;
#line 880 "pmtexb2.f"
		}
#line 881 "pmtexb2.f"
/* L31: */
#line 881 "pmtexb2.f"
	    }
#line 882 "pmtexb2.f"
	    s_wsle(&io___117);
#line 882 "pmtexb2.f"
	    do_lio(&c__9, &c__1, "Mess-up looking for half-bar", 28L);
#line 882 "pmtexb2.f"
	    e_wsle();
#line 883 "pmtexb2.f"
	    s_stop("", 0L);
#line 884 "pmtexb2.f"
L32:
#line 884 "pmtexb2.f"
	    itwrest = all_1.list[(in << 2) - 2];

/*  Backup to spot for inserting rest marker, i.e., one to the rig
ht of */
/*  the first place where either list(1)<iv or list(3)<itwrest */

#line 889 "pmtexb2.f"
	    for (iin = in - 1; iin >= 1; --iin) {
#line 890 "pmtexb2.f"
		if (all_1.list[(iin << 2) - 4] < all_1.iv || all_1.list[(iin 
#line 890 "pmtexb2.f"
			<< 2) - 2] < itwrest) {
#line 890 "pmtexb2.f"
		    goto L34;
#line 890 "pmtexb2.f"
		}
#line 891 "pmtexb2.f"
/* L33: */
#line 891 "pmtexb2.f"
	    }
#line 892 "pmtexb2.f"
	    s_wsle(&io___120);
#line 892 "pmtexb2.f"
	    do_lio(&c__9, &c__1, "Problem backing up from half bar", 32L);
#line 892 "pmtexb2.f"
	    e_wsle();
/*         stop */
#line 894 "pmtexb2.f"
L34:
#line 894 "pmtexb2.f"
	    infr = iin + 1;
#line 895 "pmtexb2.f"
	    i__2 = all_1.lenbar - itwrest;
#line 895 "pmtexb2.f"
	    add2list_(&infr, &c__2, &itwrest, &i__2, "w", (logical*)&c__1, &
#line 895 "pmtexb2.f"
		    ntot, istart, istop, &nb, 1L);
#line 897 "pmtexb2.f"
	    all_1.nodur[all_1.iv - 1] = itwrest;
#line 898 "pmtexb2.f"
	    all_1.acc[all_1.iv - 1] = 'b';
#line 899 "pmtexb2.f"
	}
#line 900 "pmtexb2.f"
/* L30: */
#line 900 "pmtexb2.f"
    }

/*  A kluged up loop for building note blocks: */

#line 904 "pmtexb2.f"
    ib = 1;
#line 905 "pmtexb2.f"
    istart[0] = 1;
#line 906 "pmtexb2.f"
    nspace[0] = 0;
#line 907 "pmtexb2.f"
    in = 1;
#line 908 "pmtexb2.f"
L9:
#line 909 "pmtexb2.f"
    if (in == ntot) {
#line 910 "pmtexb2.f"
	if (nspace[ib - 1] == 0) {
#line 910 "pmtexb2.f"
	    nspace[ib - 1] = all_1.list[(in << 2) - 1];
#line 910 "pmtexb2.f"
	}
#line 911 "pmtexb2.f"
	istop[ib - 1] = ntot;
/* Now we flow out of this if and into block-building */
#line 913 "pmtexb2.f"
    } else if (nspace[ib - 1] == 0) {
/* nspace hasn't been set yet, so */
/* and tentatively set: */
#line 916 "pmtexb2.f"
	nspace[ib - 1] = all_1.list[(in << 2) - 1];
#line 917 "pmtexb2.f"
	if (nspace[ib - 1] == 0) {
#line 918 "pmtexb2.f"
	    ++in;
#line 919 "pmtexb2.f"
	} else {
#line 920 "pmtexb2.f"
	    istop[ib - 1] = in;
#line 921 "pmtexb2.f"
	}
#line 922 "pmtexb2.f"
	goto L9;
#line 923 "pmtexb2.f"
    } else if (all_1.list[(in + 1 << 2) - 1] == 0) {
/* This is not the last note in the group, so */
#line 925 "pmtexb2.f"
	++in;
#line 926 "pmtexb2.f"
	goto L9;
#line 927 "pmtexb2.f"
    } else if (all_1.list[(in + 1 << 2) - 1] == nspace[ib - 1]) {
/* Keep spacing the same, update tentative stop point */
#line 929 "pmtexb2.f"
	++in;
#line 930 "pmtexb2.f"
	istop[ib - 1] = in;
#line 931 "pmtexb2.f"
	goto L9;
#line 932 "pmtexb2.f"
    }

/* At this point istart and istop are good, so on to next block */

#line 936 "pmtexb2.f"
    itstart[ib - 1] = all_1.list[(istart[ib - 1] << 2) - 2];
#line 937 "pmtexb2.f"
    i__1 = nspace[ib - 1] / 2;
#line 937 "pmtexb2.f"
    nindex[ib - 1] = log2_(&i__1) + 1;
#line 938 "pmtexb2.f"
    if (istop[ib - 1] == ntot) {
#line 938 "pmtexb2.f"
	goto L15;
#line 938 "pmtexb2.f"
    }
#line 939 "pmtexb2.f"
    ++ib;
#line 940 "pmtexb2.f"
    istart[ib - 1] = istop[ib - 2] + 1;
#line 941 "pmtexb2.f"
    in = istart[ib - 1];

/* Set tentative block space for new block */

#line 945 "pmtexb2.f"
    nspace[ib - 1] = all_1.list[(in << 2) - 1];
#line 946 "pmtexb2.f"
    istop[ib - 1] = in;
#line 947 "pmtexb2.f"
    goto L9;
#line 948 "pmtexb2.f"
L15:
#line 949 "pmtexb2.f"
    nb = ib;

/*  Now add to list special codes for accidental skips.  This is a loop on
 */
/* in up to ntot, but ntot increases when a skip is added, so loop manuall
y*/
/*  Must bypass this loop if all there are are whole rests. */
#line 954 "pmtexb2.f"
    if (ntot == all_1.nv) {
#line 954 "pmtexb2.f"
	goto L40;
#line 954 "pmtexb2.f"
    }
#line 955 "pmtexb2.f"
    in = 2;
#line 956 "pmtexb2.f"
L39:
#line 957 "pmtexb2.f"
    jv = all_1.list[(in << 2) - 4];
#line 958 "pmtexb2.f"
    ip = all_1.list[(in << 2) - 3];
#line 959 "pmtexb2.f"
    itim = all_1.list[(in << 2) - 2];
#line 960 "pmtexb2.f"
    if ((all_1.acc[jv + ip * 5 - 6] == 'f' || all_1.acc[jv + ip * 5 - 6] == 
#line 960 "pmtexb2.f"
	    'n' || all_1.acc[jv + ip * 5 - 6] == 's') && all_1.nodur[jv + (ip 
#line 960 "pmtexb2.f"
	    - 1) * 5 - 6] <= 6 && ip >= 2 && all_1.acc[jv + (ip - 1) * 5 - 6] 
#line 960 "pmtexb2.f"
	    != 'a') {

/*  Need accidental skip. Find block # for list position "in". */

#line 966 "pmtexb2.f"
	i__1 = nb;
#line 966 "pmtexb2.f"
	for (ib = 1; ib <= i__1; ++ib) {
#line 967 "pmtexb2.f"
	    if (istop[ib - 1] >= in) {
#line 967 "pmtexb2.f"
		goto L46;
#line 967 "pmtexb2.f"
	    }
#line 968 "pmtexb2.f"
/* L45: */
#line 968 "pmtexb2.f"
	}
#line 969 "pmtexb2.f"
	s_wsle(&io___132);
#line 969 "pmtexb2.f"
	do_lio(&c__9, &c__1, "Got lost looking for ib!!", 25L);
#line 969 "pmtexb2.f"
	e_wsle();
#line 970 "pmtexb2.f"
L46:
#line 971 "pmtexb2.f"
	for (all_1.iv = all_1.nv; all_1.iv >= 1; --all_1.iv) {
#line 972 "pmtexb2.f"
	    if (all_1.iv == jv) {
#line 973 "pmtexb2.f"
		iip = ip;
#line 974 "pmtexb2.f"
		iin = in;
#line 975 "pmtexb2.f"
		iitim = itim;
#line 976 "pmtexb2.f"
	    } else if (all_1.nn[all_1.iv - 1] == 1) {
#line 977 "pmtexb2.f"
		goto L42;
#line 978 "pmtexb2.f"
	    } else {

/*  Find ip# for this voice at this itim !!! */

#line 982 "pmtexb2.f"
		i__1 = ntot;
#line 982 "pmtexb2.f"
		for (iin = 2; iin <= i__1; ++iin) {
#line 983 "pmtexb2.f"
		    if (all_1.list[(iin << 2) - 4] == all_1.iv && all_1.list[(
#line 983 "pmtexb2.f"
			    iin << 2) - 2] >= itim) {

/*  Check if in the same block as the offending accide
ntal */

#line 987 "pmtexb2.f"
			if (istop[ib - 1] >= iin) {
#line 987 "pmtexb2.f"
			    goto L44;
#line 987 "pmtexb2.f"
			}

/*  Note is in next block, so no skip needed. */

#line 991 "pmtexb2.f"
			goto L42;
#line 992 "pmtexb2.f"
		    }
#line 993 "pmtexb2.f"
/* L43: */
#line 993 "pmtexb2.f"
		}

/* No skip needed, since no new notes after the one in questio
n, so */

#line 997 "pmtexb2.f"
		goto L42;
#line 998 "pmtexb2.f"
L44:
#line 998 "pmtexb2.f"
		iip = all_1.list[(iin << 2) - 3];
#line 999 "pmtexb2.f"
		iitim = all_1.list[(iin << 2) - 2];
#line 1000 "pmtexb2.f"
	    }
#line 1001 "pmtexb2.f"
	    add2list_(&iin, &iip, &iitim, &c__0, "a", (logical*)&c__1, &ntot, 
#line 1001 "pmtexb2.f"
		    istart, istop, &nb, 1L);
#line 1003 "pmtexb2.f"
L42:
#line 1003 "pmtexb2.f"
	    ;
#line 1003 "pmtexb2.f"
	}
#line 1004 "pmtexb2.f"
    }
#line 1005 "pmtexb2.f"
    if (in == ntot) {
#line 1005 "pmtexb2.f"
	goto L40;
#line 1005 "pmtexb2.f"
    }
#line 1006 "pmtexb2.f"
    ++in;
#line 1007 "pmtexb2.f"
    goto L39;
#line 1008 "pmtexb2.f"
L40:

/*  Invert the list of places, to make it easier to analyze a voice */

#line 1012 "pmtexb2.f"
    i__1 = ntot;
#line 1012 "pmtexb2.f"
    for (in = 1; in <= i__1; ++in) {
#line 1013 "pmtexb2.f"
	all_1.ipl[all_1.list[(in << 2) - 4] + all_1.list[(in << 2) - 3] * 5 - 
#line 1013 "pmtexb2.f"
		6] = in;
#line 1014 "pmtexb2.f"
/* L13: */
#line 1014 "pmtexb2.f"
    }

/* Now before writing output, analyze for beams */

#line 1018 "pmtexb2.f"
    i__1 = all_1.nv;
#line 1018 "pmtexb2.f"
    for (all_1.iv = 1; all_1.iv <= i__1; ++all_1.iv) {
#line 1019 "pmtexb2.f"
	numbms[all_1.iv - 1] = 0;
#line 1020 "pmtexb2.f"
	i__2 = all_1.nn[all_1.iv - 1];
#line 1020 "pmtexb2.f"
	for (ip = 1; ip <= i__2; ++ip) {
#line 1021 "pmtexb2.f"
	    nbold = numbms[all_1.iv - 1];
/* ### For each ip beyond the end of the last beam, see if a quart
er note */
/* ### starting here is filled up with notes: */
#line 1024 "pmtexb2.f"
	    if (numbms[all_1.iv - 1] == 0 || ip > all_1.ibm2[all_1.iv + 
#line 1024 "pmtexb2.f"
		    numbms[all_1.iv - 1] * 5 - 6]) {
#line 1025 "pmtexb2.f"
		fillbeat_(&combeam_1.lenbeam, &ip, numbms);
/* ### If no new quarter-note beam starts here, check for eigh
th-note beam */
#line 1027 "pmtexb2.f"
		if (numbms[all_1.iv - 1] == nbold && all_1.acc[all_1.iv + ip *
#line 1027 "pmtexb2.f"
			 5 - 6] != 'a' && combeam_1.lenbeam % 24 == 0) {
/* ### Starting time */
#line 1030 "pmtexb2.f"
		    ittemp = all_1.list[(all_1.ipl[all_1.iv + ip * 5 - 6] << 
#line 1030 "pmtexb2.f"
			    2) - 2];
#line 1031 "pmtexb2.f"
		    i__3 = all_1.nn[all_1.iv - 1];
#line 1031 "pmtexb2.f"
		    for (iip = ip; iip <= i__3; ++iip) {
#line 1032 "pmtexb2.f"
			i__4 = combeam_1.lenbeam / 2;
#line 1032 "pmtexb2.f"
			fillbeat_(&i__4, &iip, numbms);
#line 1033 "pmtexb2.f"
			itendnow = all_1.list[(all_1.ipl[all_1.iv + iip * 5 - 
#line 1033 "pmtexb2.f"
				6] << 2) - 2] + all_1.nodur[all_1.iv + iip * 
#line 1033 "pmtexb2.f"
				5 - 6];
#line 1034 "pmtexb2.f"
			if (ittemp + combeam_1.lenbeam <= itendnow || 
#line 1034 "pmtexb2.f"
				itendnow % combeam_1.lenbeam == 0) {
#line 1034 "pmtexb2.f"
			    goto L21;
#line 1034 "pmtexb2.f"
			}
#line 1036 "pmtexb2.f"
/* L22: */
#line 1036 "pmtexb2.f"
		    }
#line 1037 "pmtexb2.f"
		}
#line 1038 "pmtexb2.f"
	    }
#line 1039 "pmtexb2.f"
L21:
#line 1039 "pmtexb2.f"
	    ;
#line 1039 "pmtexb2.f"
	}
#line 1040 "pmtexb2.f"
/* L20: */
#line 1040 "pmtexb2.f"
    }

/*  Finally ready to write output */

#line 1044 "pmtexb2.f"
    i__1 = all_1.nv;
#line 1044 "pmtexb2.f"
    for (all_1.iv = 1; all_1.iv <= i__1; ++all_1.iv) {
#line 1045 "pmtexb2.f"
	all_1.ibmcnt[all_1.iv - 1] = 1;
#line 1046 "pmtexb2.f"
	all_1.beamon[all_1.iv - 1] = FALSE_;
#line 1047 "pmtexb2.f"
	nornb[all_1.iv - 1] = 0;
#line 1048 "pmtexb2.f"
/* L25: */
#line 1048 "pmtexb2.f"
    }
#line 1049 "pmtexb2.f"
    bspend = FALSE_;
#line 1050 "pmtexb2.f"
    i__1 = nb;
#line 1050 "pmtexb2.f"
    for (ib = 1; ib <= i__1; ++ib) {
/* Writing concatenation */
#line 1051 "pmtexb2.f"
	i__5[0] = 1, a__1[0] = all_1.s;
#line 1051 "pmtexb2.f"
	i__5[1] = 5, a__1[1] = nstart + (nindex[ib - 1] - 1) * 5;
#line 1051 "pmtexb2.f"
	s_cat(sout, a__1, i__5, &c__2, 80L);
#line 1052 "pmtexb2.f"
	lsout = 6;
#line 1053 "pmtexb2.f"
	i__2 = all_1.nv;
#line 1053 "pmtexb2.f"
	for (all_1.iv = 1; all_1.iv <= i__2; ++all_1.iv) {
#line 1054 "pmtexb2.f"
	    if (all_1.iv > 1) {
#line 1054 "pmtexb2.f"
		addstr_(all_1.sepsym, &c__1, sout, &lsout, 1L, 80L);
#line 1054 "pmtexb2.f"
	    }
#line 1055 "pmtexb2.f"
	    itnow = itstart[ib - 1];
#line 1056 "pmtexb2.f"
	    i__3 = istop[ib - 1];
#line 1056 "pmtexb2.f"
	    for (all_1.jn = istart[ib - 1]; all_1.jn <= i__3; ++all_1.jn) {
#line 1057 "pmtexb2.f"
		if (all_1.list[(all_1.jn << 2) - 4] != all_1.iv) {
#line 1057 "pmtexb2.f"
		    goto L10;
#line 1057 "pmtexb2.f"
		}
#line 1058 "pmtexb2.f"
		ip = all_1.list[(all_1.jn << 2) - 3];
#line 1059 "pmtexb2.f"
L12:
#line 1059 "pmtexb2.f"
		if (all_1.list[(all_1.jn << 2) - 2] > itnow) {
/* Need skips */
/* Writing concatenation */
#line 1061 "pmtexb2.f"
		    i__5[0] = 1, a__1[0] = all_1.s;
#line 1061 "pmtexb2.f"
		    i__5[1] = 2, a__1[1] = "sk";
#line 1061 "pmtexb2.f"
		    s_cat(ch__1, a__1, i__5, &c__2, 3L);
#line 1061 "pmtexb2.f"
		    addstr_(ch__1, &c__3, sout, &lsout, 3L, 80L);
#line 1062 "pmtexb2.f"
		    itnow += nspace[ib - 1];
#line 1063 "pmtexb2.f"
		    goto L12;
#line 1064 "pmtexb2.f"
		}

/*  Skip space for accidentals */

#line 1068 "pmtexb2.f"
		if (all_1.acc[all_1.iv + ip * 5 - 6] == 'a') {
/* Writing concatenation */
#line 1069 "pmtexb2.f"
		    i__5[0] = 1, a__1[0] = all_1.s;
#line 1069 "pmtexb2.f"
		    i__5[1] = 3, a__1[1] = "ask";
#line 1069 "pmtexb2.f"
		    s_cat(ch__2, a__1, i__5, &c__2, 4L);
#line 1069 "pmtexb2.f"
		    addstr_(ch__2, &c__4, sout, &lsout, 4L, 80L);
#line 1070 "pmtexb2.f"
		    goto L10;
#line 1071 "pmtexb2.f"
		}

/*  Accidentals */

#line 1075 "pmtexb2.f"
		if (all_1.acc[all_1.iv + ip * 5 - 6] == 's') {
/* Writing concatenation */
#line 1076 "pmtexb2.f"
		    i__6[0] = 1, a__2[0] = all_1.s;
#line 1076 "pmtexb2.f"
		    i__6[1] = 4, a__2[1] = "xsh ";
#line 1076 "pmtexb2.f"
		    notef_(ch__4, 1L, &all_1.nolev[all_1.iv + ip * 5 - 6]);
#line 1076 "pmtexb2.f"
		    i__6[2] = 1, a__2[2] = ch__4;
#line 1076 "pmtexb2.f"
		    s_cat(ch__3, a__2, i__6, &c__3, 6L);
#line 1076 "pmtexb2.f"
		    addstr_(ch__3, &c__6, sout, &lsout, 6L, 80L);
#line 1078 "pmtexb2.f"
		} else if (all_1.acc[all_1.iv + ip * 5 - 6] == 'f') {
/* Writing concatenation */
#line 1079 "pmtexb2.f"
		    i__6[0] = 1, a__2[0] = all_1.s;
#line 1079 "pmtexb2.f"
		    i__6[1] = 4, a__2[1] = "xfl ";
#line 1079 "pmtexb2.f"
		    notef_(ch__4, 1L, &all_1.nolev[all_1.iv + ip * 5 - 6]);
#line 1079 "pmtexb2.f"
		    i__6[2] = 1, a__2[2] = ch__4;
#line 1079 "pmtexb2.f"
		    s_cat(ch__3, a__2, i__6, &c__3, 6L);
#line 1079 "pmtexb2.f"
		    addstr_(ch__3, &c__6, sout, &lsout, 6L, 80L);
#line 1081 "pmtexb2.f"
		} else if (all_1.acc[all_1.iv + ip * 5 - 6] == 'n') {
/* Writing concatenation */
#line 1082 "pmtexb2.f"
		    i__6[0] = 1, a__2[0] = all_1.s;
#line 1082 "pmtexb2.f"
		    i__6[1] = 4, a__2[1] = "xna ";
#line 1082 "pmtexb2.f"
		    notef_(ch__4, 1L, &all_1.nolev[all_1.iv + ip * 5 - 6]);
#line 1082 "pmtexb2.f"
		    i__6[2] = 1, a__2[2] = ch__4;
#line 1082 "pmtexb2.f"
		    s_cat(ch__3, a__2, i__6, &c__3, 6L);
#line 1082 "pmtexb2.f"
		    addstr_(ch__3, &c__6, sout, &lsout, 6L, 80L);
#line 1084 "pmtexb2.f"
		}
/* ####  Check for figure */
#line 1086 "pmtexb2.f"
		if (all_1.iv == 1 && s_cmp(all_1.fig + (ip - 1) * 6, "x", 6L, 
#line 1086 "pmtexb2.f"
			1L) != 0) {
#line 1086 "pmtexb2.f"
		    putfig_(all_1.fig + (ip - 1) * 6, sout, &lsout, 6L, 80L);
#line 1086 "pmtexb2.f"
		}
/* ####  See if a beam starts here */
#line 1089 "pmtexb2.f"
		if (numbms[all_1.iv - 1] > 0 && all_1.ibmcnt[all_1.iv - 1] <= 
#line 1089 "pmtexb2.f"
			numbms[all_1.iv - 1] && all_1.ibm1[all_1.iv + 
#line 1089 "pmtexb2.f"
			all_1.ibmcnt[all_1.iv - 1] * 5 - 6] == ip) {
#line 1091 "pmtexb2.f"
		    beamstrt_(mynotex, &lnote, nornb, ihornb, 25L);
#line 1092 "pmtexb2.f"
		    addstr_(mynotex, &lnote, sout, &lsout, 25L, 80L);
#line 1093 "pmtexb2.f"
		    all_1.beamon[all_1.iv - 1] = TRUE_;
#line 1094 "pmtexb2.f"
		    bspend = TRUE_;
#line 1095 "pmtexb2.f"
		}
/* #### Check for ornaments */
#line 1097 "pmtexb2.f"
		if (all_1.orn[all_1.iv + ip * 5 - 6] != 'x') {
#line 1098 "pmtexb2.f"
		    if (nornb[all_1.iv - 1] != 0) {
/* #### In a beam, height has already been calculated 
*/
#line 1100 "pmtexb2.f"
			ihorn = ihornb[all_1.iv + nornb[all_1.iv - 1] * 5 - 6]
#line 1100 "pmtexb2.f"
				;
#line 1101 "pmtexb2.f"
			++nornb[all_1.iv - 1];
#line 1102 "pmtexb2.f"
		    } else if (all_1.nolev[all_1.iv + ip * 5 - 6] >= 
#line 1102 "pmtexb2.f"
			    all_1.ncmid[all_1.iv - 1]) {
/* #### Separate note, lower stem */
/* Computing MAX */
#line 1104 "pmtexb2.f"
			i__4 = all_1.ncmid[all_1.iv - 1] + 5, i__7 = 
#line 1104 "pmtexb2.f"
				all_1.nolev[all_1.iv + ip * 5 - 6] + 2;
#line 1104 "pmtexb2.f"
			ihorn = max(i__4,i__7);
#line 1105 "pmtexb2.f"
		    } else {
/* #### Upper beam, must clear the stem */
/* Computing MAX */
#line 1107 "pmtexb2.f"
			r__1 = all_1.stemlen - .5f;
#line 1107 "pmtexb2.f"
			i__4 = all_1.ncmid[all_1.iv - 1] + 5, i__7 = 
#line 1107 "pmtexb2.f"
				all_1.nolev[all_1.iv + ip * 5 - 6] + 2 + ni_(&
#line 1107 "pmtexb2.f"
				r__1);
#line 1107 "pmtexb2.f"
			ihorn = max(i__4,i__7);
#line 1108 "pmtexb2.f"
		    }
#line 1109 "pmtexb2.f"
		    if (all_1.orn[all_1.iv + ip * 5 - 6] == 't') {
/* Writing concatenation */
#line 1110 "pmtexb2.f"
			i__5[0] = 1, a__1[0] = all_1.s;
#line 1110 "pmtexb2.f"
			i__5[1] = 6, a__1[1] = "pince ";
#line 1110 "pmtexb2.f"
			s_cat(mynotex, a__1, i__5, &c__2, 25L);
#line 1111 "pmtexb2.f"
			lnote = 8;
#line 1112 "pmtexb2.f"
		    } else if (all_1.orn[all_1.iv + ip * 5 - 6] == 'm') {
/* Writing concatenation */
#line 1113 "pmtexb2.f"
			i__5[0] = 1, a__1[0] = all_1.s;
#line 1113 "pmtexb2.f"
			i__5[1] = 8, a__1[1] = "mordant ";
#line 1113 "pmtexb2.f"
			s_cat(mynotex, a__1, i__5, &c__2, 25L);
#line 1114 "pmtexb2.f"
			lnote = 10;
#line 1115 "pmtexb2.f"
		    } else if (all_1.orn[all_1.iv + ip * 5 - 6] == 's') {
/* Writing concatenation */
#line 1116 "pmtexb2.f"
			i__5[0] = 1, a__1[0] = all_1.s;
#line 1116 "pmtexb2.f"
			i__5[1] = 4, a__1[1] = "mtr ";
#line 1116 "pmtexb2.f"
			s_cat(mynotex, a__1, i__5, &c__2, 25L);
#line 1117 "pmtexb2.f"
			lnote = 6;
#line 1118 "pmtexb2.f"
		    }
/* Writing concatenation */
#line 1119 "pmtexb2.f"
		    i__5[0] = lnote - 1, a__1[0] = mynotex;
#line 1119 "pmtexb2.f"
		    notef_(ch__4, 1L, &ihorn);
#line 1119 "pmtexb2.f"
		    i__5[1] = 1, a__1[1] = ch__4;
#line 1119 "pmtexb2.f"
		    s_cat(ch__5, a__1, i__5, &c__2, 26L);
#line 1119 "pmtexb2.f"
		    addstr_(ch__5, &lnote, sout, &lsout, lnote, 80L);
#line 1121 "pmtexb2.f"
		}
/* ####  Is a beam start pending? */
#line 1123 "pmtexb2.f"
		if (bspend) {
#line 1124 "pmtexb2.f"
		    beamn1_(mynotex, &lnote, 25L);
#line 1125 "pmtexb2.f"
		    bspend = FALSE_;
/* ####  Is a beam ending? */
#line 1127 "pmtexb2.f"
		} else if (numbms[all_1.iv - 1] > 0 && all_1.ibmcnt[all_1.iv 
#line 1127 "pmtexb2.f"
			- 1] <= numbms[all_1.iv - 1] && all_1.ibm2[all_1.iv + 
#line 1127 "pmtexb2.f"
			all_1.ibmcnt[all_1.iv - 1] * 5 - 6] == ip) {
#line 1129 "pmtexb2.f"
		    beamend_(mynotex, &lnote, 25L);
#line 1130 "pmtexb2.f"
		    nornb[all_1.iv - 1] = 0;
#line 1131 "pmtexb2.f"
		    ++all_1.ibmcnt[all_1.iv - 1];
#line 1132 "pmtexb2.f"
		    all_1.beamon[all_1.iv - 1] = FALSE_;
/* ####  Or if we're in the middle of a beam */
#line 1134 "pmtexb2.f"
		} else if (numbms[all_1.iv - 1] > 0 && all_1.beamon[all_1.iv 
#line 1134 "pmtexb2.f"
			- 1]) {
#line 1135 "pmtexb2.f"
		    beamid_(mynotex, &lnote, 25L);
#line 1136 "pmtexb2.f"
		} else {
/* ####  Write a separate note */
#line 1138 "pmtexb2.f"
		    notex_(mynotex, &lnote, 25L);
#line 1139 "pmtexb2.f"
		}
#line 1140 "pmtexb2.f"
		addstr_(mynotex, &lnote, sout, &lsout, 25L, 80L);
#line 1141 "pmtexb2.f"
		itnow += nspace[ib - 1];
#line 1142 "pmtexb2.f"
L10:
#line 1142 "pmtexb2.f"
		;
#line 1142 "pmtexb2.f"
	    }
#line 1143 "pmtexb2.f"
/* L11: */
#line 1143 "pmtexb2.f"
	}
/* Writing concatenation */
#line 1144 "pmtexb2.f"
	i__5[0] = 1, a__1[0] = all_1.s;
#line 1144 "pmtexb2.f"
	i__5[1] = 6, a__1[1] = "enotes";
#line 1144 "pmtexb2.f"
	s_cat(ch__6, a__1, i__5, &c__2, 7L);
#line 1144 "pmtexb2.f"
	addstr_(ch__6, &c__7, sout, &lsout, 7L, 80L);
#line 1145 "pmtexb2.f"
	if (lsout > 0) {
#line 1145 "pmtexb2.f"
	    s_wsfe(&io___148);
/* Writing concatenation */
#line 1145 "pmtexb2.f"
	    i__5[0] = lsout, a__1[0] = sout;
#line 1145 "pmtexb2.f"
	    i__5[1] = 1, a__1[1] = "%";
#line 1145 "pmtexb2.f"
	    s_cat(ch__7, a__1, i__5, &c__2, 81L);
#line 1145 "pmtexb2.f"
	    do_fio(&c__1, ch__7, lsout + 1);
#line 1145 "pmtexb2.f"
	    e_wsfe();
#line 1145 "pmtexb2.f"
	}
#line 1146 "pmtexb2.f"
/* L16: */
#line 1146 "pmtexb2.f"
    }
#line 1147 "pmtexb2.f"
    return 0;
} /* makeabar_ */

/* Subroutine */ int add2list_(integer *infr, integer *newip, integer *
	newstrt, integer *newdur, char *newacc, logical *newrest, integer *
	ntot, integer *istart, integer *istop, integer *nb, ftnlen newacc_len)
{
    /* System generated locals */
    integer i__1;

    /* Builtin functions */
    /* Subroutine */ int s_copy(char *, char *, ftnlen, ftnlen);

    /* Local variables */
    static integer iibar, ib, il, in, ip;


/* This inserts into the list a new "note" at location infr.  Inputs vars 
are*/
/*     (iv) = voice # (in common) */
/*     newip = position in voice, from beginning of bar */
/*     newstrt = starting time of new "note" */
/*     newdur =  duration */
/*     newacc = accidental value */
/*     newrest = rest value */

/* ccccccccccc */
/* c */
/* c  pmtex.inc */
/* c */
/* ccccccccccc */

/*  Move everything in the list to the right by one spot, and adjust ip */
/*    for notes in affected voice. */

#line 1168 "pmtexb2.f"
    /* Parameter adjustments */
#line 1168 "pmtexb2.f"
    --istop;
#line 1168 "pmtexb2.f"
    --istart;
#line 1168 "pmtexb2.f"

#line 1168 "pmtexb2.f"
    /* Function Body */
#line 1168 "pmtexb2.f"
    i__1 = *infr;
#line 1168 "pmtexb2.f"
    for (in = *ntot; in >= i__1; --in) {
#line 1169 "pmtexb2.f"
	if (all_1.list[(in << 2) - 4] == all_1.iv) {
#line 1169 "pmtexb2.f"
	    ++all_1.list[(in << 2) - 3];
#line 1169 "pmtexb2.f"
	}
#line 1170 "pmtexb2.f"
	for (il = 1; il <= 4; ++il) {
#line 1171 "pmtexb2.f"
	    all_1.list[il + (in + 1 << 2) - 5] = all_1.list[il + (in << 2) - 
#line 1171 "pmtexb2.f"
		    5];
#line 1172 "pmtexb2.f"
/* L35: */
#line 1172 "pmtexb2.f"
	}
#line 1173 "pmtexb2.f"
/* L34: */
#line 1173 "pmtexb2.f"
    }

/*  Move everything in nodur,rest,acc,nolev to the right by one */

#line 1177 "pmtexb2.f"
    i__1 = *newip;
#line 1177 "pmtexb2.f"
    for (ip = all_1.nnl[all_1.iv - 1]; ip >= i__1; --ip) {
#line 1178 "pmtexb2.f"
	all_1.nodur[all_1.iv + (ip + 1) * 5 - 6] = all_1.nodur[all_1.iv + ip *
#line 1178 "pmtexb2.f"
		 5 - 6];
#line 1179 "pmtexb2.f"
	all_1.nolev[all_1.iv + (ip + 1) * 5 - 6] = all_1.nolev[all_1.iv + ip *
#line 1179 "pmtexb2.f"
		 5 - 6];
#line 1180 "pmtexb2.f"
	all_1.acc[all_1.iv + (ip + 1) * 5 - 6] = all_1.acc[all_1.iv + ip * 5 
#line 1180 "pmtexb2.f"
		- 6];
#line 1181 "pmtexb2.f"
	all_1.orn[all_1.iv + (ip + 1) * 5 - 6] = all_1.orn[all_1.iv + ip * 5 
#line 1181 "pmtexb2.f"
		- 6];
#line 1182 "pmtexb2.f"
	all_1.rest[all_1.iv + (ip + 1) * 5 - 6] = all_1.rest[all_1.iv + ip * 
#line 1182 "pmtexb2.f"
		5 - 6];
#line 1183 "pmtexb2.f"
	if (all_1.iv == 1) {
#line 1183 "pmtexb2.f"
	    s_copy(all_1.fig + ip * 6, all_1.fig + (ip - 1) * 6, 6L, 6L);
#line 1183 "pmtexb2.f"
	}
#line 1184 "pmtexb2.f"
/* L36: */
#line 1184 "pmtexb2.f"
    }
#line 1185 "pmtexb2.f"
    ++all_1.nnl[all_1.iv - 1];
#line 1186 "pmtexb2.f"
    i__1 = all_1.nbars;
#line 1186 "pmtexb2.f"
    for (iibar = all_1.ibar; iibar <= i__1; ++iibar) {
#line 1187 "pmtexb2.f"
	++all_1.nib[all_1.iv + iibar * 5 - 6];
#line 1188 "pmtexb2.f"
/* L37: */
#line 1188 "pmtexb2.f"
    }
#line 1189 "pmtexb2.f"
    ++(*ntot);
#line 1190 "pmtexb2.f"
    ++all_1.nn[all_1.iv - 1];
#line 1191 "pmtexb2.f"
    all_1.nodur[all_1.iv + *newip * 5 - 6] = *newdur;
#line 1192 "pmtexb2.f"
    all_1.rest[all_1.iv + *newip * 5 - 6] = *newrest;
#line 1193 "pmtexb2.f"
    all_1.acc[all_1.iv + *newip * 5 - 6] = *newacc;
#line 1194 "pmtexb2.f"
    all_1.orn[all_1.iv + *newip * 5 - 6] = 'x';
#line 1195 "pmtexb2.f"
    if (all_1.iv == 1) {
#line 1195 "pmtexb2.f"
	s_copy(all_1.fig + (*newip - 1) * 6, "x", 6L, 1L);
#line 1195 "pmtexb2.f"
    }
#line 1196 "pmtexb2.f"
    all_1.list[(*infr << 2) - 4] = all_1.iv;
#line 1197 "pmtexb2.f"
    all_1.list[(*infr << 2) - 3] = *newip;
#line 1198 "pmtexb2.f"
    all_1.list[(*infr << 2) - 2] = *newstrt;
#line 1199 "pmtexb2.f"
    all_1.list[(*infr << 2) - 1] = all_1.list[(*infr + 1 << 2) - 2] - 
#line 1199 "pmtexb2.f"
	    all_1.list[(*infr << 2) - 2];
#line 1200 "pmtexb2.f"
    all_1.list[(*infr - 1 << 2) - 1] = all_1.list[(*infr << 2) - 2] - 
#line 1200 "pmtexb2.f"
	    all_1.list[(*infr - 1 << 2) - 2];

/* Check the note blocks */

#line 1204 "pmtexb2.f"
    i__1 = *nb;
#line 1204 "pmtexb2.f"
    for (ib = 1; ib <= i__1; ++ib) {
#line 1205 "pmtexb2.f"
	if (*infr <= istop[ib]) {
#line 1205 "pmtexb2.f"
	    ++istop[ib];
#line 1205 "pmtexb2.f"
	}
#line 1206 "pmtexb2.f"
	if (*infr < istart[ib]) {
#line 1206 "pmtexb2.f"
	    ++istart[ib];
#line 1206 "pmtexb2.f"
	}
#line 1207 "pmtexb2.f"
/* L38: */
#line 1207 "pmtexb2.f"
    }
#line 1208 "pmtexb2.f"
    return 0;
} /* add2list_ */

/* Subroutine */ int putfig_(char *fig, char *sout, integer *lsout, ftnlen 
	fig_len, ftnlen sout_len)
{
    /* System generated locals */
    address a__1[2], a__2[6];
    integer i__1[2], i__2[6], i__3;
    char ch__1[1], ch__2[23], ch__3[22], ch__4[21], ch__5[17], ch__6[12];

    /* Builtin functions */
    /* Subroutine */ int s_copy(char *, char *, ftnlen, ftnlen), s_cat(char *,
	     char **, integer *, integer *, ftnlen);

    /* Local variables */
    static char nofa[2];
    static integer tofa, lnof;
    static char s[1];
    static integer lnofa, ic;
    extern /* Subroutine */ int addstr_(char *, integer *, char *, integer *, 
	    ftnlen, ftnlen);
    static char ch1[1], ch2[1], nof[2];
    extern doublereal ord_(char *, ftnlen);
    static integer tof;

/*  Platform-independent backslash */
#line 1217 "pmtexb2.f"
    *s = '\\';
#line 1218 "pmtexb2.f"
    ic = 1;
#line 1219 "pmtexb2.f"
    s_copy(nof, "0", 2L, 1L);
#line 1220 "pmtexb2.f"
    s_copy(nofa, "-1", 2L, 2L);

/*  Beginning of loop \/ \/ */

#line 1224 "pmtexb2.f"
L1:
#line 1224 "pmtexb2.f"
    *ch1 = fig[ic - 1];
#line 1225 "pmtexb2.f"
    if (*ch1 == ' ') {
#line 1225 "pmtexb2.f"
	goto L2;
#line 1225 "pmtexb2.f"
    }

/*  Just starting or not yet finished */

#line 1229 "pmtexb2.f"
    lnof = 1;
#line 1230 "pmtexb2.f"
    tof = ord_(nof, 2L);
#line 1231 "pmtexb2.f"
    ch__1[0] = tof + 48;
#line 1231 "pmtexb2.f"
    s_copy(nof, ch__1, 2L, 1L);
#line 1232 "pmtexb2.f"
    if (tof > 9) {
#line 1233 "pmtexb2.f"
	lnof = 2;
#line 1234 "pmtexb2.f"
	tof = ord_(nof, 2L);
/* Writing concatenation */
#line 1235 "pmtexb2.f"
	i__1[0] = 1, a__1[0] = "1";
#line 1235 "pmtexb2.f"
	ch__1[0] = tof + 38;
#line 1235 "pmtexb2.f"
	i__1[1] = 1, a__1[1] = ch__1;
#line 1235 "pmtexb2.f"
	s_cat(nof, a__1, i__1, &c__2, 2L);
#line 1236 "pmtexb2.f"
    }
#line 1237 "pmtexb2.f"
    tofa = ord_(nofa, 2L);
#line 1238 "pmtexb2.f"
    if (tofa == -1) {
#line 1239 "pmtexb2.f"
	lnofa = 2;
#line 1240 "pmtexb2.f"
	s_copy(nofa, "-1", 2L, 2L);
#line 1241 "pmtexb2.f"
    } else if (tofa < 10) {
#line 1242 "pmtexb2.f"
	lnofa = 1;
#line 1243 "pmtexb2.f"
	ch__1[0] = tofa + 48;
#line 1243 "pmtexb2.f"
	s_copy(nofa, ch__1, 2L, 1L);
#line 1244 "pmtexb2.f"
    } else {
#line 1245 "pmtexb2.f"
	lnofa = 2;
/* Writing concatenation */
#line 1246 "pmtexb2.f"
	i__1[0] = 1, a__1[0] = "1";
#line 1246 "pmtexb2.f"
	ch__1[0] = tofa + 38;
#line 1246 "pmtexb2.f"
	i__1[1] = 1, a__1[1] = ch__1;
#line 1246 "pmtexb2.f"
	s_cat(nofa, a__1, i__1, &c__2, 2L);
#line 1247 "pmtexb2.f"
    }
#line 1248 "pmtexb2.f"
    if (*ch1 == '#' || *ch1 == '-' || *ch1 == 'n') {
#line 1249 "pmtexb2.f"
	++ic;
#line 1250 "pmtexb2.f"
	*ch2 = fig[ic - 1];
#line 1251 "pmtexb2.f"
	if (*ch2 == ' ') {

/*  Figure is a stand-alone accidental, so must be centered */

#line 1255 "pmtexb2.f"
	    if (*ch1 == '#') {
/* Writing concatenation */
#line 1256 "pmtexb2.f"
		i__2[0] = 1, a__2[0] = s;
#line 1256 "pmtexb2.f"
		i__2[1] = 5, a__2[1] = "Figu{";
#line 1256 "pmtexb2.f"
		i__2[2] = lnofa, a__2[2] = nofa;
#line 1256 "pmtexb2.f"
		i__2[3] = 2, a__2[3] = "}{";
#line 1256 "pmtexb2.f"
		i__2[4] = 1, a__2[4] = s;
#line 1256 "pmtexb2.f"
		i__2[5] = 12, a__2[5] = "smalls@harp}";
#line 1256 "pmtexb2.f"
		s_cat(ch__2, a__2, i__2, &c__6, 23L);
#line 1256 "pmtexb2.f"
		i__3 = lnofa + 21;
#line 1256 "pmtexb2.f"
		addstr_(ch__2, &i__3, sout, lsout, lnofa + 21, 80L);
#line 1258 "pmtexb2.f"
	    } else if (*ch1 == '-') {
/* Writing concatenation */
#line 1259 "pmtexb2.f"
		i__2[0] = 1, a__2[0] = s;
#line 1259 "pmtexb2.f"
		i__2[1] = 5, a__2[1] = "Figu{";
#line 1259 "pmtexb2.f"
		i__2[2] = lnofa, a__2[2] = nofa;
#line 1259 "pmtexb2.f"
		i__2[3] = 2, a__2[3] = "}{";
#line 1259 "pmtexb2.f"
		i__2[4] = 1, a__2[4] = s;
#line 1259 "pmtexb2.f"
		i__2[5] = 11, a__2[5] = "smallf@lat}";
#line 1259 "pmtexb2.f"
		s_cat(ch__3, a__2, i__2, &c__6, 22L);
#line 1259 "pmtexb2.f"
		i__3 = lnofa + 20;
#line 1259 "pmtexb2.f"
		addstr_(ch__3, &i__3, sout, lsout, lnofa + 20, 80L);
#line 1261 "pmtexb2.f"
	    } else if (*ch1 == 'n') {
/* Writing concatenation */
#line 1262 "pmtexb2.f"
		i__2[0] = 1, a__2[0] = s;
#line 1262 "pmtexb2.f"
		i__2[1] = 5, a__2[1] = "Figu{";
#line 1262 "pmtexb2.f"
		i__2[2] = lnofa, a__2[2] = nofa;
#line 1262 "pmtexb2.f"
		i__2[3] = 2, a__2[3] = "}{";
#line 1262 "pmtexb2.f"
		i__2[4] = 1, a__2[4] = s;
#line 1262 "pmtexb2.f"
		i__2[5] = 10, a__2[5] = "smalln@at}";
#line 1262 "pmtexb2.f"
		s_cat(ch__4, a__2, i__2, &c__6, 21L);
#line 1262 "pmtexb2.f"
		i__3 = lnofa + 19;
#line 1262 "pmtexb2.f"
		addstr_(ch__4, &i__3, sout, lsout, lnofa + 19, 80L);
#line 1264 "pmtexb2.f"
	    }
#line 1265 "pmtexb2.f"
	    goto L2;
#line 1266 "pmtexb2.f"
	} else {

/*  Figure is an accidental followed by a number */
/*  First put the accidental (offset to the left) */

#line 1271 "pmtexb2.f"
	    if (*ch1 == '#') {
/* Writing concatenation */
#line 1272 "pmtexb2.f"
		i__2[0] = 1, a__2[0] = s;
#line 1272 "pmtexb2.f"
		i__2[1] = 5, a__2[1] = "Figu{";
#line 1272 "pmtexb2.f"
		i__2[2] = lnofa, a__2[2] = nofa;
#line 1272 "pmtexb2.f"
		i__2[3] = 2, a__2[3] = "}{";
#line 1272 "pmtexb2.f"
		i__2[4] = 1, a__2[4] = s;
#line 1272 "pmtexb2.f"
		i__2[5] = 6, a__2[5] = "fsmsh}";
#line 1272 "pmtexb2.f"
		s_cat(ch__5, a__2, i__2, &c__6, 17L);
#line 1272 "pmtexb2.f"
		i__3 = lnofa + 15;
#line 1272 "pmtexb2.f"
		addstr_(ch__5, &i__3, sout, lsout, lnofa + 15, 80L);
#line 1275 "pmtexb2.f"
	    } else if (*ch1 == '-') {
/* Writing concatenation */
#line 1276 "pmtexb2.f"
		i__2[0] = 1, a__2[0] = s;
#line 1276 "pmtexb2.f"
		i__2[1] = 5, a__2[1] = "Figu{";
#line 1276 "pmtexb2.f"
		i__2[2] = lnofa, a__2[2] = nofa;
#line 1276 "pmtexb2.f"
		i__2[3] = 2, a__2[3] = "}{";
#line 1276 "pmtexb2.f"
		i__2[4] = 1, a__2[4] = s;
#line 1276 "pmtexb2.f"
		i__2[5] = 6, a__2[5] = "fsmfl}";
#line 1276 "pmtexb2.f"
		s_cat(ch__5, a__2, i__2, &c__6, 17L);
#line 1276 "pmtexb2.f"
		i__3 = lnofa + 15;
#line 1276 "pmtexb2.f"
		addstr_(ch__5, &i__3, sout, lsout, lnofa + 15, 80L);
#line 1279 "pmtexb2.f"
	    } else if (*ch1 == 'n') {
/* Writing concatenation */
#line 1280 "pmtexb2.f"
		i__2[0] = 1, a__2[0] = s;
#line 1280 "pmtexb2.f"
		i__2[1] = 5, a__2[1] = "Figu{";
#line 1280 "pmtexb2.f"
		i__2[2] = lnofa, a__2[2] = nofa;
#line 1280 "pmtexb2.f"
		i__2[3] = 2, a__2[3] = "}{";
#line 1280 "pmtexb2.f"
		i__2[4] = 1, a__2[4] = s;
#line 1280 "pmtexb2.f"
		i__2[5] = 6, a__2[5] = "fsmna}";
#line 1280 "pmtexb2.f"
		s_cat(ch__5, a__2, i__2, &c__6, 17L);
#line 1280 "pmtexb2.f"
		i__3 = lnofa + 15;
#line 1280 "pmtexb2.f"
		addstr_(ch__5, &i__3, sout, lsout, lnofa + 15, 80L);
#line 1283 "pmtexb2.f"
	    }

/*  Now put the number */

/* Writing concatenation */
#line 1287 "pmtexb2.f"
	    i__2[0] = 1, a__2[0] = s;
#line 1287 "pmtexb2.f"
	    i__2[1] = 5, a__2[1] = "Figu{";
#line 1287 "pmtexb2.f"
	    i__2[2] = lnof, a__2[2] = nof;
#line 1287 "pmtexb2.f"
	    i__2[3] = 2, a__2[3] = "}{";
#line 1287 "pmtexb2.f"
	    i__2[4] = 1, a__2[4] = ch2;
#line 1287 "pmtexb2.f"
	    i__2[5] = 1, a__2[5] = "}";
#line 1287 "pmtexb2.f"
	    s_cat(ch__6, a__2, i__2, &c__6, 12L);
#line 1287 "pmtexb2.f"
	    i__3 = lnof + 10;
#line 1287 "pmtexb2.f"
	    addstr_(ch__6, &i__3, sout, lsout, lnof + 10, 80L);
#line 1289 "pmtexb2.f"
	}
#line 1290 "pmtexb2.f"
    } else {

/*  Figure is a single number */

/* Writing concatenation */
#line 1294 "pmtexb2.f"
	i__2[0] = 1, a__2[0] = s;
#line 1294 "pmtexb2.f"
	i__2[1] = 5, a__2[1] = "Figu{";
#line 1294 "pmtexb2.f"
	i__2[2] = lnof, a__2[2] = nof;
#line 1294 "pmtexb2.f"
	i__2[3] = 2, a__2[3] = "}{";
#line 1294 "pmtexb2.f"
	i__2[4] = 1, a__2[4] = ch1;
#line 1294 "pmtexb2.f"
	i__2[5] = 1, a__2[5] = "}";
#line 1294 "pmtexb2.f"
	s_cat(ch__6, a__2, i__2, &c__6, 12L);
#line 1294 "pmtexb2.f"
	i__3 = lnof + 10;
#line 1294 "pmtexb2.f"
	addstr_(ch__6, &i__3, sout, lsout, lnof + 10, 80L);
#line 1296 "pmtexb2.f"
    }
#line 1297 "pmtexb2.f"
    ++ic;
#line 1298 "pmtexb2.f"
    tof = ord_(nof, 2L);
#line 1299 "pmtexb2.f"
    tof += 4;
#line 1300 "pmtexb2.f"
    ch__1[0] = tof + 48;
#line 1300 "pmtexb2.f"
    s_copy(nof, ch__1, 2L, 1L);
#line 1301 "pmtexb2.f"
    tofa = ord_(nofa, 2L);
#line 1302 "pmtexb2.f"
    tofa += 4;
#line 1303 "pmtexb2.f"
    ch__1[0] = tofa + 48;
#line 1303 "pmtexb2.f"
    s_copy(nofa, ch__1, 2L, 1L);
#line 1304 "pmtexb2.f"
    goto L1;
#line 1305 "pmtexb2.f"
L2:
#line 1306 "pmtexb2.f"
    return 0;
} /* putfig_ */

/* Subroutine */ int topfile_(char *basename, integer *lbase, integer *nv, 
	char *clef, integer *noinst, integer *musicsize, logical *figbass, 
	ftnlen basename_len, ftnlen clef_len)
{
    /* Initialized data */

    static char rnum[3*5] = "i  " "ii " "iii" "iv " "v  ";

    /* System generated locals */
    address a__1[3], a__2[2], a__3[4], a__4[10], a__5[6], a__6[8];
    integer i__1[3], i__2[2], i__3[4], i__4[10], i__5[6], i__6, i__7[8];
    char ch__1[30], ch__2[15], ch__3[12], ch__4[35], ch__5[17], ch__6[41], 
	    ch__7[23], ch__8[14], ch__9[11], ch__10[21], ch__11[7], ch__12[19]
	    , ch__13[16], ch__14[18], ch__15[1], ch__16[44], ch__17[22], 
	    ch__18[25], ch__19[24], ch__20[13], ch__21[20];

    /* Builtin functions */
    integer s_wsfe(cilist *), do_fio(integer *, char *, ftnlen), e_wsfe(void);
    /* Subroutine */ int s_cat(char *, char **, integer *, integer *, ftnlen);

    /* Local variables */
    static char s[1];
    static integer lname, iposn, iv, ipi, nvp;
    extern /* Character */ VOID clefnum_(char *, ftnlen, char *, ftnlen);
    static char tstring[40];

    /* Fortran I/O blocks */
    static cilist io___166 = { 0, 11, 0, "(a)", 0 };
    static cilist io___167 = { 0, 11, 0, "(a)", 0 };
    static cilist io___168 = { 0, 11, 0, "(a)", 0 };
    static cilist io___169 = { 0, 11, 0, "(a)", 0 };
    static cilist io___170 = { 0, 11, 0, "(a)", 0 };
    static cilist io___171 = { 0, 11, 0, "(a)", 0 };
    static cilist io___172 = { 0, 11, 0, "(a)", 0 };
    static cilist io___173 = { 0, 11, 0, "(a)", 0 };
    static cilist io___174 = { 0, 11, 0, "(a)", 0 };
    static cilist io___175 = { 0, 11, 0, "(a)", 0 };
    static cilist io___176 = { 0, 11, 0, "(a)", 0 };
    static cilist io___177 = { 0, 11, 0, "(a)", 0 };
    static cilist io___178 = { 0, 11, 0, "(a)", 0 };
    static cilist io___179 = { 0, 11, 0, "(a)", 0 };
    static cilist io___180 = { 0, 11, 0, "(a)", 0 };
    static cilist io___181 = { 0, 11, 0, "(a14,i1,a4)", 0 };
    static cilist io___182 = { 0, 11, 0, "(a11,i2,a1)", 0 };
    static cilist io___183 = { 0, 11, 0, "(a)", 0 };
    static cilist io___184 = { 0, 11, 0, "(a7,i3,a2)", 0 };
    static cilist io___185 = { 0, 11, 0, "(a7,i3,a2)", 0 };
    static cilist io___187 = { 0, 11, 0, "(a19,i1,a1)", 0 };
    static cilist io___188 = { 0, 11, 0, "(a16,i2,a1)", 0 };
    static cilist io___189 = { 0, 11, 0, "(a19,i2,a1)", 0 };
    static cilist io___190 = { 0, 11, 0, "(a18,i2,a1)", 0 };
    static cilist io___192 = { 0, 11, 0, "(a16)", 0 };
    static cilist io___193 = { 0, 11, 0, "(a)", 0 };
    static cilist io___195 = { 0, 11, 0, "(a)", 0 };
    static cilist io___196 = { 0, 11, 0, "(a12,i1)", 0 };
    static cilist io___197 = { 0, 6, 0, "(a12,i1)", 0 };
    static cilist io___199 = { 0, 6, 0, "(a)", 0 };
    static cilist io___201 = { 0, 6, 0, "(a)", 0 };
    static cilist io___202 = { 0, 11, 0, "(a)", 0 };
    static cilist io___203 = { 0, 11, 0, "(a19,i2,a2)", 0 };
    static cilist io___204 = { 0, 11, 0, "(a)", 0 };
    static cilist io___205 = { 0, 11, 0, "(a25,i2,a2,i2,a3)", 0 };
    static cilist io___206 = { 0, 11, 0, "(a21,i1,a2)", 0 };
    static cilist io___207 = { 0, 11, 0, "(a)", 0 };
    static cilist io___208 = { 0, 11, 0, "(a)", 0 };
    static cilist io___210 = { 0, 11, 0, "(a11,i1,a2)", 0 };
    static cilist io___211 = { 0, 11, 0, "(a11,i2,a2)", 0 };
    static cilist io___212 = { 0, 11, 0, "(a)", 0 };
    static cilist io___213 = { 0, 11, 0, "(a)", 0 };
    static cilist io___214 = { 0, 11, 0, "(a)", 0 };
    static cilist io___215 = { 0, 11, 0, "(a)", 0 };


#line 1318 "pmtexb2.f"
    /* Parameter adjustments */
#line 1318 "pmtexb2.f"
    --clef;
#line 1318 "pmtexb2.f"

#line 1318 "pmtexb2.f"
    /* Function Body */
/* Platform-independent backslash */
#line 1320 "pmtexb2.f"
    *s = '\\';
#line 1321 "pmtexb2.f"
    s_wsfe(&io___166);
#line 1321 "pmtexb2.f"
    do_fio(&c__1, "%%%%%%%%%%%%%%%%%", 17L);
#line 1321 "pmtexb2.f"
    e_wsfe();
#line 1322 "pmtexb2.f"
    s_wsfe(&io___167);
#line 1322 "pmtexb2.f"
    do_fio(&c__1, "%", 1L);
#line 1322 "pmtexb2.f"
    e_wsfe();
#line 1323 "pmtexb2.f"
    s_wsfe(&io___168);
/* Writing concatenation */
#line 1323 "pmtexb2.f"
    i__1[0] = 2, a__1[0] = "% ";
#line 1323 "pmtexb2.f"
    i__1[1] = *lbase, a__1[1] = basename;
#line 1323 "pmtexb2.f"
    i__1[2] = 4, a__1[2] = ".tex";
#line 1323 "pmtexb2.f"
    s_cat(ch__1, a__1, i__1, &c__3, 30L);
#line 1323 "pmtexb2.f"
    do_fio(&c__1, ch__1, *lbase + 6);
#line 1323 "pmtexb2.f"
    e_wsfe();
#line 1324 "pmtexb2.f"
    s_wsfe(&io___169);
#line 1324 "pmtexb2.f"
    do_fio(&c__1, "%", 1L);
#line 1324 "pmtexb2.f"
    e_wsfe();
#line 1325 "pmtexb2.f"
    s_wsfe(&io___170);
#line 1325 "pmtexb2.f"
    do_fio(&c__1, "%%%%%%%%%%%%%%%%", 16L);
#line 1325 "pmtexb2.f"
    e_wsfe();
#line 1326 "pmtexb2.f"
    s_wsfe(&io___171);
/* Writing concatenation */
#line 1326 "pmtexb2.f"
    i__2[0] = 1, a__2[0] = s;
#line 1326 "pmtexb2.f"
    i__2[1] = 14, a__2[1] = "input musicnft";
#line 1326 "pmtexb2.f"
    s_cat(ch__2, a__2, i__2, &c__2, 15L);
#line 1326 "pmtexb2.f"
    do_fio(&c__1, ch__2, 15L);
#line 1326 "pmtexb2.f"
    e_wsfe();
#line 1327 "pmtexb2.f"
    s_wsfe(&io___172);
/* Writing concatenation */
#line 1327 "pmtexb2.f"
    i__2[0] = 1, a__2[0] = s;
#line 1327 "pmtexb2.f"
    i__2[1] = 14, a__2[1] = "input musicvbm";
#line 1327 "pmtexb2.f"
    s_cat(ch__2, a__2, i__2, &c__2, 15L);
#line 1327 "pmtexb2.f"
    do_fio(&c__1, ch__2, 15L);
#line 1327 "pmtexb2.f"
    e_wsfe();
#line 1328 "pmtexb2.f"
    s_wsfe(&io___173);
/* Writing concatenation */
#line 1328 "pmtexb2.f"
    i__2[0] = 1, a__2[0] = s;
#line 1328 "pmtexb2.f"
    i__2[1] = 14, a__2[1] = "input musictex";
#line 1328 "pmtexb2.f"
    s_cat(ch__2, a__2, i__2, &c__2, 15L);
#line 1328 "pmtexb2.f"
    do_fio(&c__1, ch__2, 15L);
#line 1328 "pmtexb2.f"
    e_wsfe();
#line 1329 "pmtexb2.f"
    s_wsfe(&io___174);
/* Writing concatenation */
#line 1329 "pmtexb2.f"
    i__2[0] = 1, a__2[0] = s;
#line 1329 "pmtexb2.f"
    i__2[1] = 14, a__2[1] = "input musicsty";
#line 1329 "pmtexb2.f"
    s_cat(ch__2, a__2, i__2, &c__2, 15L);
#line 1329 "pmtexb2.f"
    do_fio(&c__1, ch__2, 15L);
#line 1329 "pmtexb2.f"
    e_wsfe();
#line 1330 "pmtexb2.f"
    s_wsfe(&io___175);
/* Writing concatenation */
#line 1330 "pmtexb2.f"
    i__2[0] = 1, a__2[0] = s;
#line 1330 "pmtexb2.f"
    i__2[1] = 14, a__2[1] = "input musictrp";
#line 1330 "pmtexb2.f"
    s_cat(ch__2, a__2, i__2, &c__2, 15L);
#line 1330 "pmtexb2.f"
    do_fio(&c__1, ch__2, 15L);
#line 1330 "pmtexb2.f"
    e_wsfe();
#line 1331 "pmtexb2.f"
    s_wsfe(&io___176);
/* Writing concatenation */
#line 1331 "pmtexb2.f"
    i__2[0] = 1, a__2[0] = s;
#line 1331 "pmtexb2.f"
    i__2[1] = 11, a__2[1] = "input pmtex";
#line 1331 "pmtexb2.f"
    s_cat(ch__3, a__2, i__2, &c__2, 12L);
#line 1331 "pmtexb2.f"
    do_fio(&c__1, ch__3, 12L);
#line 1331 "pmtexb2.f"
    e_wsfe();
#line 1332 "pmtexb2.f"
    if (*figbass) {
#line 1332 "pmtexb2.f"
	s_wsfe(&io___177);
/* Writing concatenation */
#line 1332 "pmtexb2.f"
	i__3[0] = 1, a__3[0] = s;
#line 1332 "pmtexb2.f"
	i__3[1] = 6, a__3[1] = "input ";
#line 1332 "pmtexb2.f"
	i__3[2] = *lbase, a__3[2] = basename;
#line 1332 "pmtexb2.f"
	i__3[3] = 4, a__3[3] = ".fig";
#line 1332 "pmtexb2.f"
	s_cat(ch__4, a__3, i__3, &c__4, 35L);
#line 1332 "pmtexb2.f"
	do_fio(&c__1, ch__4, *lbase + 11);
#line 1332 "pmtexb2.f"
	e_wsfe();
#line 1332 "pmtexb2.f"
    }
#line 1334 "pmtexb2.f"
    s_wsfe(&io___178);
/* Writing concatenation */
#line 1334 "pmtexb2.f"
    i__3[0] = 1, a__3[0] = s;
#line 1334 "pmtexb2.f"
    i__3[1] = 3, a__3[1] = "def";
#line 1334 "pmtexb2.f"
    i__3[2] = 1, a__3[2] = s;
#line 1334 "pmtexb2.f"
    i__3[3] = 12, a__3[3] = "autol#1#2#3{";
#line 1334 "pmtexb2.f"
    s_cat(ch__5, a__3, i__3, &c__4, 17L);
#line 1334 "pmtexb2.f"
    do_fio(&c__1, ch__5, 17L);
#line 1334 "pmtexb2.f"
    e_wsfe();
#line 1335 "pmtexb2.f"
    if (*figbass) {
#line 1335 "pmtexb2.f"
	s_wsfe(&io___179);
/* Writing concatenation */
#line 1335 "pmtexb2.f"
	i__4[0] = 1, a__4[0] = s;
#line 1335 "pmtexb2.f"
	i__4[1] = 6, a__4[1] = "global";
#line 1335 "pmtexb2.f"
	i__4[2] = 1, a__4[2] = s;
#line 1335 "pmtexb2.f"
	i__4[3] = 7, a__4[3] = "advance";
#line 1335 "pmtexb2.f"
	i__4[4] = 1, a__4[4] = s;
#line 1335 "pmtexb2.f"
	i__4[5] = 10, a__4[5] = "sysno by 1";
#line 1335 "pmtexb2.f"
	i__4[6] = 1, a__4[6] = s;
#line 1335 "pmtexb2.f"
	i__4[7] = 5, a__4[7] = "relax";
#line 1335 "pmtexb2.f"
	i__4[8] = 1, a__4[8] = s;
#line 1335 "pmtexb2.f"
	i__4[9] = 8, a__4[9] = "fixdrop%";
#line 1335 "pmtexb2.f"
	s_cat(ch__6, a__4, i__4, &c__10, 41L);
#line 1335 "pmtexb2.f"
	do_fio(&c__1, ch__6, 41L);
#line 1335 "pmtexb2.f"
	e_wsfe();
#line 1335 "pmtexb2.f"
    }
#line 1338 "pmtexb2.f"
    s_wsfe(&io___180);
/* Writing concatenation */
#line 1338 "pmtexb2.f"
    i__2[0] = 1, a__2[0] = s;
#line 1338 "pmtexb2.f"
    i__2[1] = 22, a__2[1] = "autolines{#1}{#2}{#3}}";
#line 1338 "pmtexb2.f"
    s_cat(ch__7, a__2, i__2, &c__2, 23L);
#line 1338 "pmtexb2.f"
    do_fio(&c__1, ch__7, 23L);
#line 1338 "pmtexb2.f"
    e_wsfe();
#line 1339 "pmtexb2.f"
    s_wsfe(&io___181);
/* Writing concatenation */
#line 1339 "pmtexb2.f"
    i__5[0] = 1, a__5[0] = s;
#line 1339 "pmtexb2.f"
    i__5[1] = 3, a__5[1] = "def";
#line 1339 "pmtexb2.f"
    i__5[2] = 1, a__5[2] = s;
#line 1339 "pmtexb2.f"
    i__5[3] = 4, a__5[3] = "ask{";
#line 1339 "pmtexb2.f"
    i__5[4] = 1, a__5[4] = s;
#line 1339 "pmtexb2.f"
    i__5[5] = 4, a__5[5] = "off{";
#line 1339 "pmtexb2.f"
    s_cat(ch__8, a__5, i__5, &c__6, 14L);
#line 1339 "pmtexb2.f"
    do_fio(&c__1, ch__8, 14L);
#line 1339 "pmtexb2.f"
    do_fio(&c__1, (char *)&comtop_1.iwaskpt, (ftnlen)sizeof(integer));
#line 1339 "pmtexb2.f"
    do_fio(&c__1, "pt}}", 4L);
#line 1339 "pmtexb2.f"
    e_wsfe();
#line 1341 "pmtexb2.f"
    s_wsfe(&io___182);
/* Writing concatenation */
#line 1341 "pmtexb2.f"
    i__2[0] = 1, a__2[0] = s;
#line 1341 "pmtexb2.f"
    i__2[1] = 10, a__2[1] = "musicsize=";
#line 1341 "pmtexb2.f"
    s_cat(ch__9, a__2, i__2, &c__2, 11L);
#line 1341 "pmtexb2.f"
    do_fio(&c__1, ch__9, 11L);
#line 1341 "pmtexb2.f"
    do_fio(&c__1, (char *)&(*musicsize), (ftnlen)sizeof(integer));
#line 1341 "pmtexb2.f"
    do_fio(&c__1, "%", 1L);
#line 1341 "pmtexb2.f"
    e_wsfe();
#line 1342 "pmtexb2.f"
    s_wsfe(&io___183);
/* Writing concatenation */
#line 1342 "pmtexb2.f"
    i__3[0] = 1, a__3[0] = s;
#line 1342 "pmtexb2.f"
    i__3[1] = 14, a__3[1] = "tracingstats=2";
#line 1342 "pmtexb2.f"
    i__3[2] = 1, a__3[2] = s;
#line 1342 "pmtexb2.f"
    i__3[3] = 5, a__3[3] = "relax";
#line 1342 "pmtexb2.f"
    s_cat(ch__10, a__3, i__3, &c__4, 21L);
#line 1342 "pmtexb2.f"
    do_fio(&c__1, ch__10, 21L);
#line 1342 "pmtexb2.f"
    e_wsfe();
#line 1343 "pmtexb2.f"
    s_wsfe(&io___184);
/* Writing concatenation */
#line 1343 "pmtexb2.f"
    i__2[0] = 1, a__2[0] = s;
#line 1343 "pmtexb2.f"
    i__2[1] = 6, a__2[1] = "hsize=";
#line 1343 "pmtexb2.f"
    s_cat(ch__11, a__2, i__2, &c__2, 7L);
#line 1343 "pmtexb2.f"
    do_fio(&c__1, ch__11, 7L);
#line 1343 "pmtexb2.f"
    i__6 = (integer) (comtop_1.widthpt + .1f);
#line 1343 "pmtexb2.f"
    do_fio(&c__1, (char *)&i__6, (ftnlen)sizeof(integer));
#line 1343 "pmtexb2.f"
    do_fio(&c__1, "pt", 2L);
#line 1343 "pmtexb2.f"
    e_wsfe();
#line 1344 "pmtexb2.f"
    s_wsfe(&io___185);
/* Writing concatenation */
#line 1344 "pmtexb2.f"
    i__2[0] = 1, a__2[0] = s;
#line 1344 "pmtexb2.f"
    i__2[1] = 6, a__2[1] = "vsize=";
#line 1344 "pmtexb2.f"
    s_cat(ch__11, a__2, i__2, &c__2, 7L);
#line 1344 "pmtexb2.f"
    do_fio(&c__1, ch__11, 7L);
#line 1344 "pmtexb2.f"
    i__6 = (integer) (comtop_1.height + .1f);
#line 1344 "pmtexb2.f"
    do_fio(&c__1, (char *)&i__6, (ftnlen)sizeof(integer));
#line 1344 "pmtexb2.f"
    do_fio(&c__1, "pt", 2L);
#line 1344 "pmtexb2.f"
    e_wsfe();
#line 1345 "pmtexb2.f"
    nvp = *nv;
#line 1346 "pmtexb2.f"
    if (*noinst == 0) {
#line 1346 "pmtexb2.f"
	nvp = 1;
#line 1346 "pmtexb2.f"
    }
#line 1347 "pmtexb2.f"
    s_wsfe(&io___187);
/* Writing concatenation */
#line 1347 "pmtexb2.f"
    i__3[0] = 1, a__3[0] = s;
#line 1347 "pmtexb2.f"
    i__3[1] = 3, a__3[1] = "def";
#line 1347 "pmtexb2.f"
    i__3[2] = 1, a__3[2] = s;
#line 1347 "pmtexb2.f"
    i__3[3] = 14, a__3[3] = "nbinstruments{";
#line 1347 "pmtexb2.f"
    s_cat(ch__12, a__3, i__3, &c__4, 19L);
#line 1347 "pmtexb2.f"
    do_fio(&c__1, ch__12, 19L);
#line 1347 "pmtexb2.f"
    do_fio(&c__1, (char *)&nvp, (ftnlen)sizeof(integer));
#line 1347 "pmtexb2.f"
    do_fio(&c__1, "}", 1L);
#line 1347 "pmtexb2.f"
    e_wsfe();
#line 1348 "pmtexb2.f"
    s_wsfe(&io___188);
/* Writing concatenation */
#line 1348 "pmtexb2.f"
    i__3[0] = 1, a__3[0] = s;
#line 1348 "pmtexb2.f"
    i__3[1] = 3, a__3[1] = "def";
#line 1348 "pmtexb2.f"
    i__3[2] = 1, a__3[2] = s;
#line 1348 "pmtexb2.f"
    i__3[3] = 11, a__3[3] = "topfacteur{";
#line 1348 "pmtexb2.f"
    s_cat(ch__13, a__3, i__3, &c__4, 16L);
#line 1348 "pmtexb2.f"
    do_fio(&c__1, ch__13, 16L);
#line 1348 "pmtexb2.f"
    do_fio(&c__1, (char *)&comtop_1.itopfacteur, (ftnlen)sizeof(integer));
#line 1348 "pmtexb2.f"
    do_fio(&c__1, "}", 1L);
#line 1348 "pmtexb2.f"
    e_wsfe();
#line 1350 "pmtexb2.f"
    s_wsfe(&io___189);
/* Writing concatenation */
#line 1350 "pmtexb2.f"
    i__3[0] = 1, a__3[0] = s;
#line 1350 "pmtexb2.f"
    i__3[1] = 3, a__3[1] = "def";
#line 1350 "pmtexb2.f"
    i__3[2] = 1, a__3[2] = s;
#line 1350 "pmtexb2.f"
    i__3[3] = 14, a__3[3] = "bottomfacteur{";
#line 1350 "pmtexb2.f"
    s_cat(ch__12, a__3, i__3, &c__4, 19L);
#line 1350 "pmtexb2.f"
    do_fio(&c__1, ch__12, 19L);
#line 1350 "pmtexb2.f"
    do_fio(&c__1, (char *)&comtop_1.ibotfacteur, (ftnlen)sizeof(integer));
#line 1350 "pmtexb2.f"
    do_fio(&c__1, "}", 1L);
#line 1350 "pmtexb2.f"
    e_wsfe();
#line 1352 "pmtexb2.f"
    s_wsfe(&io___190);
/* Writing concatenation */
#line 1352 "pmtexb2.f"
    i__3[0] = 1, a__3[0] = s;
#line 1352 "pmtexb2.f"
    i__3[1] = 3, a__3[1] = "def";
#line 1352 "pmtexb2.f"
    i__3[2] = 1, a__3[2] = s;
#line 1352 "pmtexb2.f"
    i__3[3] = 13, a__3[3] = "interfacteur{";
#line 1352 "pmtexb2.f"
    s_cat(ch__14, a__3, i__3, &c__4, 18L);
#line 1352 "pmtexb2.f"
    do_fio(&c__1, ch__14, 18L);
#line 1352 "pmtexb2.f"
    do_fio(&c__1, (char *)&comtop_1.interfacteur, (ftnlen)sizeof(integer));
#line 1352 "pmtexb2.f"
    do_fio(&c__1, "}", 1L);
#line 1352 "pmtexb2.f"
    e_wsfe();
#line 1354 "pmtexb2.f"
    if (*noinst > 0) {

/*  There are nv differenet instruments */

#line 1358 "pmtexb2.f"
	i__6 = *nv;
#line 1358 "pmtexb2.f"
	for (iv = 1; iv <= i__6; ++iv) {
#line 1359 "pmtexb2.f"
	    s_wsfe(&io___192);
/* Writing concatenation */
#line 1359 "pmtexb2.f"
	    i__3[0] = 1, a__3[0] = s;
#line 1359 "pmtexb2.f"
	    i__3[1] = 9, a__3[1] = "nbportees";
#line 1359 "pmtexb2.f"
	    i__3[2] = 3, a__3[2] = rnum + (iv - 1) * 3;
#line 1359 "pmtexb2.f"
	    i__3[3] = 3, a__3[3] = "=1%";
#line 1359 "pmtexb2.f"
	    s_cat(ch__13, a__3, i__3, &c__4, 16L);
#line 1359 "pmtexb2.f"
	    do_fio(&c__1, ch__13, 16L);
#line 1359 "pmtexb2.f"
	    e_wsfe();
#line 1360 "pmtexb2.f"
	    s_wsfe(&io___193);
/* Writing concatenation */
#line 1360 "pmtexb2.f"
	    i__7[0] = 1, a__6[0] = s;
#line 1360 "pmtexb2.f"
	    i__7[1] = 6, a__6[1] = "global";
#line 1360 "pmtexb2.f"
	    i__7[2] = 1, a__6[2] = s;
#line 1360 "pmtexb2.f"
	    i__7[3] = 8, a__6[3] = "cleftoks";
#line 1360 "pmtexb2.f"
	    i__7[4] = 3, a__6[4] = rnum + (iv - 1) * 3;
#line 1360 "pmtexb2.f"
	    i__7[5] = 3, a__6[5] = "={{";
#line 1360 "pmtexb2.f"
	    clefnum_(ch__15, 1L, clef + iv, 1L);
#line 1360 "pmtexb2.f"
	    i__7[6] = 1, a__6[6] = ch__15;
#line 1360 "pmtexb2.f"
	    i__7[7] = 12, a__6[7] = "}{0}{0}{0}}%";
#line 1360 "pmtexb2.f"
	    s_cat(ch__4, a__6, i__7, &c__8, 35L);
#line 1360 "pmtexb2.f"
	    do_fio(&c__1, ch__4, 35L);
#line 1360 "pmtexb2.f"
	    e_wsfe();
#line 1362 "pmtexb2.f"
	    for (lname = 24; lname >= 2; --lname) {
#line 1363 "pmtexb2.f"
		if (comtop_1.iname[(iv - 1) * 24 + (lname - 1)] != ' ') {
#line 1363 "pmtexb2.f"
		    goto L4;
#line 1363 "pmtexb2.f"
		}
#line 1364 "pmtexb2.f"
/* L3: */
#line 1364 "pmtexb2.f"
	    }
#line 1365 "pmtexb2.f"
L4:
#line 1366 "pmtexb2.f"
	    s_wsfe(&io___195);
/* Writing concatenation */
#line 1366 "pmtexb2.f"
	    i__7[0] = 1, a__6[0] = s;
#line 1366 "pmtexb2.f"
	    i__7[1] = 3, a__6[1] = "def";
#line 1366 "pmtexb2.f"
	    i__7[2] = 1, a__6[2] = s;
#line 1366 "pmtexb2.f"
	    i__7[3] = 10, a__6[3] = "instrument";
#line 1366 "pmtexb2.f"
	    i__7[4] = 3, a__6[4] = rnum + (iv - 1) * 3;
#line 1366 "pmtexb2.f"
	    i__7[5] = 1, a__6[5] = "{";
#line 1366 "pmtexb2.f"
	    i__7[6] = lname, a__6[6] = comtop_1.iname + (iv - 1) * 24;
#line 1366 "pmtexb2.f"
	    i__7[7] = 1, a__6[7] = "}";
#line 1366 "pmtexb2.f"
	    s_cat(ch__16, a__6, i__7, &c__8, 44L);
#line 1366 "pmtexb2.f"
	    do_fio(&c__1, ch__16, lname + 20);
#line 1366 "pmtexb2.f"
	    e_wsfe();
#line 1368 "pmtexb2.f"
/* L1: */
#line 1368 "pmtexb2.f"
	}
#line 1369 "pmtexb2.f"
    } else {

/*  There is one inst. with nv voices */

#line 1373 "pmtexb2.f"
	s_wsfe(&io___196);
/* Writing concatenation */
#line 1373 "pmtexb2.f"
	i__2[0] = 1, a__2[0] = s;
#line 1373 "pmtexb2.f"
	i__2[1] = 11, a__2[1] = "nbporteesi=";
#line 1373 "pmtexb2.f"
	s_cat(ch__3, a__2, i__2, &c__2, 12L);
#line 1373 "pmtexb2.f"
	do_fio(&c__1, ch__3, 12L);
#line 1373 "pmtexb2.f"
	do_fio(&c__1, (char *)&(*nv), (ftnlen)sizeof(integer));
#line 1373 "pmtexb2.f"
	e_wsfe();
#line 1374 "pmtexb2.f"
	s_wsfe(&io___197);
/* Writing concatenation */
#line 1374 "pmtexb2.f"
	i__2[0] = 1, a__2[0] = s;
#line 1374 "pmtexb2.f"
	i__2[1] = 11, a__2[1] = "nbporteesi=";
#line 1374 "pmtexb2.f"
	s_cat(ch__3, a__2, i__2, &c__2, 12L);
#line 1374 "pmtexb2.f"
	do_fio(&c__1, ch__3, 12L);
#line 1374 "pmtexb2.f"
	do_fio(&c__1, (char *)&(*nv), (ftnlen)sizeof(integer));
#line 1374 "pmtexb2.f"
	e_wsfe();
/* Writing concatenation */
#line 1375 "pmtexb2.f"
	i__3[0] = 1, a__3[0] = s;
#line 1375 "pmtexb2.f"
	i__3[1] = 6, a__3[1] = "global";
#line 1375 "pmtexb2.f"
	i__3[2] = 1, a__3[2] = s;
#line 1375 "pmtexb2.f"
	i__3[3] = 24, a__3[3] = "cleftoksi={{0}{0}{0}{0}}";
#line 1375 "pmtexb2.f"
	s_cat(tstring, a__3, i__3, &c__4, 40L);
#line 1376 "pmtexb2.f"
	s_wsfe(&io___199);
#line 1376 "pmtexb2.f"
	do_fio(&c__1, tstring, 40L);
#line 1376 "pmtexb2.f"
	e_wsfe();
#line 1377 "pmtexb2.f"
	i__6 = *nv;
#line 1377 "pmtexb2.f"
	for (iv = 1; iv <= i__6; ++iv) {
#line 1378 "pmtexb2.f"
	    iposn = iv * 3 + 18;
#line 1379 "pmtexb2.f"
	    clefnum_(ch__15, 1L, clef + iv, 1L);
#line 1379 "pmtexb2.f"
	    tstring[iposn - 1] = ch__15[0];
#line 1380 "pmtexb2.f"
	    s_wsfe(&io___201);
#line 1380 "pmtexb2.f"
	    do_fio(&c__1, tstring, 40L);
#line 1380 "pmtexb2.f"
	    e_wsfe();
#line 1381 "pmtexb2.f"
/* L2: */
#line 1381 "pmtexb2.f"
	}
#line 1382 "pmtexb2.f"
	s_wsfe(&io___202);
#line 1382 "pmtexb2.f"
	do_fio(&c__1, tstring, 40L);
#line 1382 "pmtexb2.f"
	e_wsfe();
#line 1383 "pmtexb2.f"
    }
#line 1384 "pmtexb2.f"
    s_wsfe(&io___203);
/* Writing concatenation */
#line 1384 "pmtexb2.f"
    i__2[0] = 1, a__2[0] = s;
#line 1384 "pmtexb2.f"
    i__2[1] = 18, a__2[1] = "signaturegenerale{";
#line 1384 "pmtexb2.f"
    s_cat(ch__12, a__2, i__2, &c__2, 19L);
#line 1384 "pmtexb2.f"
    do_fio(&c__1, ch__12, 19L);
#line 1384 "pmtexb2.f"
    do_fio(&c__1, (char *)&comtop_1.isig, (ftnlen)sizeof(integer));
#line 1384 "pmtexb2.f"
    do_fio(&c__1, "}%", 2L);
#line 1384 "pmtexb2.f"
    e_wsfe();
#line 1385 "pmtexb2.f"
    s_wsfe(&io___204);
/* Writing concatenation */
#line 1385 "pmtexb2.f"
    i__3[0] = 1, a__3[0] = s;
#line 1385 "pmtexb2.f"
    i__3[1] = 3, a__3[1] = "def";
#line 1385 "pmtexb2.f"
    i__3[2] = 1, a__3[2] = s;
#line 1385 "pmtexb2.f"
    i__3[3] = 17, a__3[3] = "gluemaxskip{7pt}%";
#line 1385 "pmtexb2.f"
    s_cat(ch__17, a__3, i__3, &c__4, 22L);
#line 1385 "pmtexb2.f"
    do_fio(&c__1, ch__17, 22L);
#line 1385 "pmtexb2.f"
    e_wsfe();
#line 1386 "pmtexb2.f"
    if (comtop_1.imeter == 0) {
#line 1387 "pmtexb2.f"
	s_wsfe(&io___205);
/* Writing concatenation */
#line 1387 "pmtexb2.f"
	i__3[0] = 1, a__3[0] = s;
#line 1387 "pmtexb2.f"
	i__3[1] = 13, a__3[1] = "generalmeter{";
#line 1387 "pmtexb2.f"
	i__3[2] = 1, a__3[2] = s;
#line 1387 "pmtexb2.f"
	i__3[3] = 10, a__3[3] = "meterfrac{";
#line 1387 "pmtexb2.f"
	s_cat(ch__18, a__3, i__3, &c__4, 25L);
#line 1387 "pmtexb2.f"
	do_fio(&c__1, ch__18, 25L);
#line 1387 "pmtexb2.f"
	do_fio(&c__1, (char *)&comtop_1.mtrnum, (ftnlen)sizeof(integer));
#line 1387 "pmtexb2.f"
	do_fio(&c__1, "}{", 2L);
#line 1387 "pmtexb2.f"
	do_fio(&c__1, (char *)&comtop_1.mtrden, (ftnlen)sizeof(integer));
#line 1387 "pmtexb2.f"
	do_fio(&c__1, "}}%", 3L);
#line 1387 "pmtexb2.f"
	e_wsfe();
#line 1390 "pmtexb2.f"
    } else if (comtop_1.imeter <= 4) {
#line 1391 "pmtexb2.f"
	s_wsfe(&io___206);
/* Writing concatenation */
#line 1391 "pmtexb2.f"
	i__3[0] = 1, a__3[0] = s;
#line 1391 "pmtexb2.f"
	i__3[1] = 13, a__3[1] = "generalmeter{";
#line 1391 "pmtexb2.f"
	i__3[2] = 1, a__3[2] = s;
#line 1391 "pmtexb2.f"
	i__3[3] = 6, a__3[3] = "meterN";
#line 1391 "pmtexb2.f"
	s_cat(ch__10, a__3, i__3, &c__4, 21L);
#line 1391 "pmtexb2.f"
	do_fio(&c__1, ch__10, 21L);
#line 1391 "pmtexb2.f"
	do_fio(&c__1, (char *)&comtop_1.imeter, (ftnlen)sizeof(integer));
#line 1391 "pmtexb2.f"
	do_fio(&c__1, "}%", 2L);
#line 1391 "pmtexb2.f"
	e_wsfe();
#line 1393 "pmtexb2.f"
    } else if (comtop_1.imeter == 5) {
#line 1394 "pmtexb2.f"
	s_wsfe(&io___207);
/* Writing concatenation */
#line 1394 "pmtexb2.f"
	i__3[0] = 1, a__3[0] = s;
#line 1394 "pmtexb2.f"
	i__3[1] = 12, a__3[1] = "generalmeter";
#line 1394 "pmtexb2.f"
	i__3[2] = 1, a__3[2] = s;
#line 1394 "pmtexb2.f"
	i__3[3] = 10, a__3[3] = "allabreve%";
#line 1394 "pmtexb2.f"
	s_cat(ch__19, a__3, i__3, &c__4, 24L);
#line 1394 "pmtexb2.f"
	do_fio(&c__1, ch__19, 24L);
#line 1394 "pmtexb2.f"
	e_wsfe();
#line 1395 "pmtexb2.f"
    } else if (comtop_1.imeter == 6) {
#line 1396 "pmtexb2.f"
	s_wsfe(&io___208);
/* Writing concatenation */
#line 1396 "pmtexb2.f"
	i__3[0] = 1, a__3[0] = s;
#line 1396 "pmtexb2.f"
	i__3[1] = 12, a__3[1] = "generalmeter";
#line 1396 "pmtexb2.f"
	i__3[2] = 1, a__3[2] = s;
#line 1396 "pmtexb2.f"
	i__3[3] = 7, a__3[3] = "meterC%";
#line 1396 "pmtexb2.f"
	s_cat(ch__10, a__3, i__3, &c__4, 21L);
#line 1396 "pmtexb2.f"
	do_fio(&c__1, ch__10, 21L);
#line 1396 "pmtexb2.f"
	e_wsfe();
#line 1397 "pmtexb2.f"
    }
#line 1398 "pmtexb2.f"
    ipi = comtop_1.fracindent * comtop_1.widthpt + .1f;
#line 1399 "pmtexb2.f"
    if (ipi < 10) {
#line 1400 "pmtexb2.f"
	s_wsfe(&io___210);
/* Writing concatenation */
#line 1400 "pmtexb2.f"
	i__2[0] = 1, a__2[0] = s;
#line 1400 "pmtexb2.f"
	i__2[1] = 10, a__2[1] = "parindent ";
#line 1400 "pmtexb2.f"
	s_cat(ch__9, a__2, i__2, &c__2, 11L);
#line 1400 "pmtexb2.f"
	do_fio(&c__1, ch__9, 11L);
#line 1400 "pmtexb2.f"
	do_fio(&c__1, (char *)&ipi, (ftnlen)sizeof(integer));
#line 1400 "pmtexb2.f"
	do_fio(&c__1, "pt", 2L);
#line 1400 "pmtexb2.f"
	e_wsfe();
#line 1401 "pmtexb2.f"
    } else {
#line 1402 "pmtexb2.f"
	s_wsfe(&io___211);
/* Writing concatenation */
#line 1402 "pmtexb2.f"
	i__2[0] = 1, a__2[0] = s;
#line 1402 "pmtexb2.f"
	i__2[1] = 10, a__2[1] = "parindent ";
#line 1402 "pmtexb2.f"
	s_cat(ch__9, a__2, i__2, &c__2, 11L);
#line 1402 "pmtexb2.f"
	do_fio(&c__1, ch__9, 11L);
#line 1402 "pmtexb2.f"
	do_fio(&c__1, (char *)&ipi, (ftnlen)sizeof(integer));
#line 1402 "pmtexb2.f"
	do_fio(&c__1, "pt", 2L);
#line 1402 "pmtexb2.f"
	e_wsfe();
#line 1403 "pmtexb2.f"
    }
#line 1404 "pmtexb2.f"
    s_wsfe(&io___212);
/* Writing concatenation */
#line 1404 "pmtexb2.f"
    i__3[0] = 1, a__3[0] = s;
#line 1404 "pmtexb2.f"
    i__3[1] = 4, a__3[1] = "null";
#line 1404 "pmtexb2.f"
    i__3[2] = 1, a__3[2] = s;
#line 1404 "pmtexb2.f"
    i__3[3] = 7, a__3[3] = "bigskip";
#line 1404 "pmtexb2.f"
    s_cat(ch__20, a__3, i__3, &c__4, 13L);
#line 1404 "pmtexb2.f"
    do_fio(&c__1, ch__20, 13L);
#line 1404 "pmtexb2.f"
    e_wsfe();
#line 1405 "pmtexb2.f"
    s_wsfe(&io___213);
/* Writing concatenation */
#line 1405 "pmtexb2.f"
    i__2[0] = 1, a__2[0] = s;
#line 1405 "pmtexb2.f"
    i__2[1] = 12, a__2[1] = "debutmorceau";
#line 1405 "pmtexb2.f"
    s_cat(ch__20, a__2, i__2, &c__2, 13L);
#line 1405 "pmtexb2.f"
    do_fio(&c__1, ch__20, 13L);
#line 1405 "pmtexb2.f"
    e_wsfe();
#line 1406 "pmtexb2.f"
    s_wsfe(&io___214);
/* Writing concatenation */
#line 1406 "pmtexb2.f"
    i__3[0] = 1, a__3[0] = s;
#line 1406 "pmtexb2.f"
    i__3[1] = 3, a__3[1] = "def";
#line 1406 "pmtexb2.f"
    i__3[2] = 1, a__3[2] = s;
#line 1406 "pmtexb2.f"
    i__3[3] = 12, a__3[3] = "freqbarno{5}";
#line 1406 "pmtexb2.f"
    s_cat(ch__5, a__3, i__3, &c__4, 17L);
#line 1406 "pmtexb2.f"
    do_fio(&c__1, ch__5, 17L);
#line 1406 "pmtexb2.f"
    e_wsfe();
#line 1407 "pmtexb2.f"
    s_wsfe(&io___215);
/* Writing concatenation */
#line 1407 "pmtexb2.f"
    i__3[0] = 1, a__3[0] = s;
#line 1407 "pmtexb2.f"
    i__3[1] = 13, a__3[1] = "linesinpage=0";
#line 1407 "pmtexb2.f"
    i__3[2] = 1, a__3[2] = s;
#line 1407 "pmtexb2.f"
    i__3[3] = 5, a__3[3] = "relax";
#line 1407 "pmtexb2.f"
    s_cat(ch__21, a__3, i__3, &c__4, 20L);
#line 1407 "pmtexb2.f"
    do_fio(&c__1, ch__21, 20L);
#line 1407 "pmtexb2.f"
    e_wsfe();
#line 1408 "pmtexb2.f"
    return 0;
} /* topfile_ */

/* Character */ VOID clefnum_(char *ret_val, ftnlen ret_val_len, char *
	clefname, ftnlen clefname_len)
{
#line 1412 "pmtexb2.f"
    if (*clefname == 'b') {
#line 1413 "pmtexb2.f"
	*ret_val = '6';
#line 1414 "pmtexb2.f"
    } else if (*clefname == 'a') {
#line 1415 "pmtexb2.f"
	*ret_val = '3';
#line 1416 "pmtexb2.f"
    } else if (*clefname == 't') {
#line 1417 "pmtexb2.f"
	*ret_val = '0';
#line 1418 "pmtexb2.f"
    }
#line 1419 "pmtexb2.f"
    return ;
} /* clefnum_ */

integer ni_(real *x)
{
    /* System generated locals */
    integer ret_val;

#line 1422 "pmtexb2.f"
    if (*x >= 0.f) {
#line 1423 "pmtexb2.f"
	ret_val = *x + .5001f;
#line 1424 "pmtexb2.f"
    } else {
#line 1425 "pmtexb2.f"
	ret_val = *x - .5001f;
#line 1426 "pmtexb2.f"
    }
#line 1427 "pmtexb2.f"
    return ret_val;
} /* ni_ */

/* Subroutine */ int setupb_(real *xelsk, integer *nnb, real *sumx, real *
	sumy, integer *ipb, integer *islope, integer *nolev1, integer *nornb)
{
    /* System generated locals */
    integer i__1, i__2;
    real r__1, r__2;
    doublereal d__1;

    /* Builtin functions */
    double pow_dd(doublereal *, doublereal *);
    integer i_sign(integer *, integer *);
    double sqrt(doublereal);

    /* Local variables */
    static real beta, smed, smin, elsperns;
    static integer i, j;
    static real t, ybeam;
    static integer nindx;
    static real slope[120], ynote;
    static integer n1, n2, in;
    extern integer ni_(real *);
    static integer nscmid;
    static real dnolev;
    static integer nolevo, ibc;
    extern /* Subroutine */ int setupb2_(real *, integer *, real *, real *, 
	    integer *, integer *, integer *);
    static integer inb, jnb;
    static real off;
    static integer nsc;
    static real deficit;
    static integer iul;
    static real syb, ssq, off1, off2, elsksum;
    extern integer log2_(integer *);


/* The outer combo algorithm */

/* ccccccccccc */
/* c */
/* c  pmtex.inc */
/* c */
/* ccccccccccc */
#line 1436 "pmtexb2.f"
    /* Parameter adjustments */
#line 1436 "pmtexb2.f"
    --nornb;
#line 1436 "pmtexb2.f"
    --ipb;
#line 1436 "pmtexb2.f"
    --xelsk;
#line 1436 "pmtexb2.f"

#line 1436 "pmtexb2.f"
    /* Function Body */
#line 1436 "pmtexb2.f"
    ibc = all_1.ibmcnt[all_1.iv - 1];
#line 1437 "pmtexb2.f"
    n1 = all_1.ipl[all_1.iv + all_1.ibm1[all_1.iv + ibc * 5 - 6] * 5 - 6];
#line 1438 "pmtexb2.f"
    n2 = all_1.ipl[all_1.iv + all_1.ibm2[all_1.iv + ibc * 5 - 6] * 5 - 6];
#line 1439 "pmtexb2.f"
    nornb[all_1.iv] = 0;

/* Need to figure how many elemskips to the each note. Use the list, */
/* counting only those members that have a non-zero interval to next note 
*/

#line 1444 "pmtexb2.f"
    elsksum = 0.f;
#line 1445 "pmtexb2.f"
    *nnb = 0;
#line 1446 "pmtexb2.f"
    *sumx = 0.f;
#line 1447 "pmtexb2.f"
    *sumy = 0.f;
#line 1448 "pmtexb2.f"
    i__1 = n2;
#line 1448 "pmtexb2.f"
    for (in = n1; in <= i__1; ++in) {
#line 1449 "pmtexb2.f"
	if (all_1.list[(in << 2) - 4] == all_1.iv && all_1.acc[all_1.iv + 
#line 1449 "pmtexb2.f"
		all_1.list[(in << 2) - 3] * 5 - 6] != 'a') {
#line 1450 "pmtexb2.f"
	    ++(*nnb);
#line 1451 "pmtexb2.f"
	    ipb[*nnb] = all_1.list[(in << 2) - 3];
#line 1452 "pmtexb2.f"
	    xelsk[*nnb] = elsksum;
#line 1453 "pmtexb2.f"
	    *sumx += elsksum;
#line 1454 "pmtexb2.f"
	    *sumy += all_1.nolev[all_1.iv + ipb[*nnb] * 5 - 6];
#line 1455 "pmtexb2.f"
	    if (all_1.orn[all_1.iv + ipb[*nnb] * 5 - 6] != 'x') {
#line 1455 "pmtexb2.f"
		++nornb[all_1.iv];
#line 1455 "pmtexb2.f"
	    }
#line 1456 "pmtexb2.f"
	}
#line 1457 "pmtexb2.f"
	if (in < n2 && all_1.list[(in << 2) - 1] != 0) {
#line 1458 "pmtexb2.f"
	    i__2 = all_1.list[(in << 2) - 1] / 2;
#line 1458 "pmtexb2.f"
	    nindx = log2_(&i__2) + 1;
#line 1459 "pmtexb2.f"
	    d__1 = (doublereal) ((nindx - 1) / 2.f);
#line 1459 "pmtexb2.f"
	    elsperns = pow_dd(&c_b763, &d__1);
#line 1460 "pmtexb2.f"
	    elsksum += elsperns;
#line 1461 "pmtexb2.f"
	}
#line 1462 "pmtexb2.f"
/* L2: */
#line 1462 "pmtexb2.f"
    }
#line 1463 "pmtexb2.f"
    nsc = 0;
#line 1464 "pmtexb2.f"
    i__1 = *nnb - 1;
#line 1464 "pmtexb2.f"
    for (inb = 1; inb <= i__1; ++inb) {
#line 1465 "pmtexb2.f"
	i__2 = *nnb;
#line 1465 "pmtexb2.f"
	for (jnb = inb + 1; jnb <= i__2; ++jnb) {
#line 1466 "pmtexb2.f"
	    ++nsc;
#line 1467 "pmtexb2.f"
	    slope[nsc - 1] = (all_1.nolev[all_1.iv + ipb[jnb] * 5 - 6] - 
#line 1467 "pmtexb2.f"
		    all_1.nolev[all_1.iv + ipb[inb] * 5 - 6]) / (xelsk[jnb] - 
#line 1467 "pmtexb2.f"
		    xelsk[inb]);
#line 1469 "pmtexb2.f"
	    if ((r__1 = slope[nsc - 1], dabs(r__1)) < 1e-4f) {
#line 1470 "pmtexb2.f"
		++nsc;
#line 1471 "pmtexb2.f"
		slope[nsc - 1] = slope[nsc - 2];
#line 1472 "pmtexb2.f"
		++nsc;
#line 1473 "pmtexb2.f"
		slope[nsc - 1] = slope[nsc - 2];
#line 1474 "pmtexb2.f"
	    }
#line 1475 "pmtexb2.f"
/* L5: */
#line 1475 "pmtexb2.f"
	}
#line 1475 "pmtexb2.f"
    }
/*       write(*,'(a7,1x,9f8.2/(8x,9f8.2))')'slopes:',(slope(i),i=1,nsc) 
*/
#line 1477 "pmtexb2.f"
    if (nsc == 1) {
#line 1478 "pmtexb2.f"
	smed = slope[0];
#line 1479 "pmtexb2.f"
	goto L6;
#line 1480 "pmtexb2.f"
    }
#line 1481 "pmtexb2.f"
    nscmid = nsc / 2 + 1;
#line 1482 "pmtexb2.f"
    i__2 = nscmid;
#line 1482 "pmtexb2.f"
    for (i = 1; i <= i__2; ++i) {
#line 1483 "pmtexb2.f"
	i__1 = nsc;
#line 1483 "pmtexb2.f"
	for (j = i + 1; j <= i__1; ++j) {
#line 1484 "pmtexb2.f"
	    if (slope[j - 1] < slope[i - 1]) {
#line 1485 "pmtexb2.f"
		t = slope[j - 1];
#line 1486 "pmtexb2.f"
		slope[j - 1] = slope[i - 1];
#line 1487 "pmtexb2.f"
		slope[i - 1] = t;
#line 1488 "pmtexb2.f"
	    }
#line 1489 "pmtexb2.f"
/* L7: */
#line 1489 "pmtexb2.f"
	}
#line 1489 "pmtexb2.f"
    }
#line 1490 "pmtexb2.f"
    smed = slope[nscmid - 1];
#line 1491 "pmtexb2.f"
    if (nsc == nsc / 2 << 1 && (r__1 = slope[nscmid - 2], dabs(r__1)) < (r__2 
#line 1491 "pmtexb2.f"
	    = slope[nscmid - 1], dabs(r__2))) {
#line 1491 "pmtexb2.f"
	smed = slope[nscmid - 2];
#line 1491 "pmtexb2.f"
    }
#line 1493 "pmtexb2.f"
L6:
#line 1494 "pmtexb2.f"
    r__1 = smed * all_1.slfac;
#line 1494 "pmtexb2.f"
    *islope = ni_(&r__1);
#line 1495 "pmtexb2.f"
    if (abs(*islope) > 9) {
#line 1495 "pmtexb2.f"
	*islope = i_sign(&c__9, islope);
#line 1495 "pmtexb2.f"
    }
/*       beta = (sumy-smed*sumx)/nnb */
#line 1497 "pmtexb2.f"
    beta = (*sumy - *islope / all_1.slfac * *sumx) / *nnb;
#line 1498 "pmtexb2.f"
    *nolev1 = beta + .5f;
/* #### Check if any stems are too short */
#line 1500 "pmtexb2.f"
    smin = 100.f;
#line 1501 "pmtexb2.f"
    iul = -1;
#line 1502 "pmtexb2.f"
    if (all_1.ul[all_1.iv + ibc * 5 - 6] == 'u') {
#line 1502 "pmtexb2.f"
	iul = 1;
#line 1502 "pmtexb2.f"
    }
#line 1503 "pmtexb2.f"
    ssq = 0.f;
#line 1504 "pmtexb2.f"
    syb = 0.f;
#line 1505 "pmtexb2.f"
    i__1 = *nnb;
#line 1505 "pmtexb2.f"
    for (inb = 1; inb <= i__1; ++inb) {
#line 1506 "pmtexb2.f"
	ybeam = *nolev1 + iul * all_1.stemlen + *islope * xelsk[inb] / 
#line 1506 "pmtexb2.f"
		all_1.slfac;
#line 1507 "pmtexb2.f"
	syb += ybeam;
#line 1508 "pmtexb2.f"
	ynote = (real) all_1.nolev[all_1.iv + ipb[inb] * 5 - 6];
#line 1509 "pmtexb2.f"
	off = ybeam - ynote;
#line 1510 "pmtexb2.f"
	if (inb == 1) {
#line 1511 "pmtexb2.f"
	    off1 = off;
#line 1512 "pmtexb2.f"
	} else if (inb == *nnb) {
#line 1513 "pmtexb2.f"
	    off2 = off;
#line 1514 "pmtexb2.f"
	}
#line 1515 "pmtexb2.f"
	ssq += off * off;
/* Computing MIN */
#line 1516 "pmtexb2.f"
	r__1 = smin, r__2 = iul * off;
#line 1516 "pmtexb2.f"
	smin = dmin(r__1,r__2);
#line 1517 "pmtexb2.f"
/* L4: */
#line 1517 "pmtexb2.f"
    }
#line 1518 "pmtexb2.f"
    dnolev = 0.f;
#line 1519 "pmtexb2.f"
    if (smin < all_1.stemmin) {
#line 1520 "pmtexb2.f"
	deficit = all_1.stemmin - smin;
#line 1521 "pmtexb2.f"
	nolevo = *nolev1;
#line 1522 "pmtexb2.f"
	r__1 = *nolev1 + iul * deficit;
#line 1522 "pmtexb2.f"
	*nolev1 = ni_(&r__1);
#line 1523 "pmtexb2.f"
	dnolev = (real) (*nolev1 - nolevo);
#line 1524 "pmtexb2.f"
	off1 += dnolev;
#line 1525 "pmtexb2.f"
	off2 += dnolev;
#line 1526 "pmtexb2.f"
    }
/* Computing 2nd power */
#line 1527 "pmtexb2.f"
    r__1 = dnolev;
#line 1527 "pmtexb2.f"
    ssq = ssq + dnolev * 2 * (syb - *sumy) + r__1 * r__1;
#line 1528 "pmtexb2.f"
    if (sqrt(ssq / *nnb) > all_1.stemmax && (dabs(off1) < all_1.stemmax || 
#line 1528 "pmtexb2.f"
	    dabs(off2) < all_1.stemmax)) {
/*#### The final check before switching is that first and last stems a
ren't*/
/*     both excessive. */
#line 1532 "pmtexb2.f"
	setupb2_(&xelsk[1], nnb, sumx, sumy, &ipb[1], islope, nolev1);
#line 1533 "pmtexb2.f"
    }
#line 1534 "pmtexb2.f"
    return 0;
} /* setupb_ */

/* Subroutine */ int setupb2_(real *xelsk, integer *nnb, real *sumx, real *
	sumy, integer *ipb, integer *islope, integer *nolev1)
{
    /* System generated locals */
    integer i__1, i__2;
    real r__1, r__2;
    doublereal d__1;

    /* Builtin functions */
    double pow_dd(doublereal *, doublereal *);
    integer i_sign(integer *, integer *);

    /* Local variables */
    static real beta, smin, elsperns, y, delta, ybeam;
    static integer nindx;
    static real ynote;
    static integer n1, n2;
    static real sumxx, sumxy, em;
    static integer in;
    extern integer ni_(real *);
    static integer nolevo, ibc, inb;
    static real deficit;
    static integer iul;
    static real elsksum;
    extern integer log2_(integer *);


/* The MEAN SQUARE slope algorithm */

/* ccccccccccc */
/* c */
/* c  pmtex.inc */
/* c */
/* ccccccccccc */
#line 1543 "pmtexb2.f"
    /* Parameter adjustments */
#line 1543 "pmtexb2.f"
    --ipb;
#line 1543 "pmtexb2.f"
    --xelsk;
#line 1543 "pmtexb2.f"

#line 1543 "pmtexb2.f"
    /* Function Body */
#line 1543 "pmtexb2.f"
    ibc = all_1.ibmcnt[all_1.iv - 1];
#line 1544 "pmtexb2.f"
    n1 = all_1.ipl[all_1.iv + all_1.ibm1[all_1.iv + ibc * 5 - 6] * 5 - 6];
#line 1545 "pmtexb2.f"
    n2 = all_1.ipl[all_1.iv + all_1.ibm2[all_1.iv + ibc * 5 - 6] * 5 - 6];

/* Need to figure how many elemskips to the each note. Use the list, */
/* counting only those members that have a non-zero interval to next note 
*/

#line 1550 "pmtexb2.f"
    elsksum = 0.f;
#line 1551 "pmtexb2.f"
    *nnb = 0;
#line 1552 "pmtexb2.f"
    ipb[1] = n1;
#line 1553 "pmtexb2.f"
    *sumx = 0.f;
#line 1554 "pmtexb2.f"
    sumxx = 0.f;
#line 1555 "pmtexb2.f"
    *sumy = 0.f;
#line 1556 "pmtexb2.f"
    sumxy = 0.f;
#line 1557 "pmtexb2.f"
    i__1 = n2;
#line 1557 "pmtexb2.f"
    for (in = n1; in <= i__1; ++in) {
#line 1558 "pmtexb2.f"
	if (all_1.list[(in << 2) - 4] == all_1.iv && all_1.acc[all_1.iv + 
#line 1558 "pmtexb2.f"
		all_1.list[(in << 2) - 3] * 5 - 6] != 'a') {
#line 1559 "pmtexb2.f"
	    ++(*nnb);
#line 1560 "pmtexb2.f"
	    ipb[*nnb] = all_1.list[(in << 2) - 3];
#line 1561 "pmtexb2.f"
	    xelsk[*nnb] = elsksum;
#line 1562 "pmtexb2.f"
	    *sumx += elsksum;
#line 1563 "pmtexb2.f"
	    sumxx += elsksum * elsksum;
#line 1564 "pmtexb2.f"
	    y = (real) all_1.nolev[all_1.iv + all_1.list[(in << 2) - 3] * 5 - 
#line 1564 "pmtexb2.f"
		    6];
#line 1565 "pmtexb2.f"
	    *sumy += y;
#line 1566 "pmtexb2.f"
	    sumxy += elsksum * y;
#line 1567 "pmtexb2.f"
	}
#line 1568 "pmtexb2.f"
	if (in < n2 && all_1.list[(in << 2) - 1] != 0) {
#line 1569 "pmtexb2.f"
	    i__2 = all_1.list[(in << 2) - 1] / 2;
#line 1569 "pmtexb2.f"
	    nindx = log2_(&i__2) + 1;
#line 1570 "pmtexb2.f"
	    d__1 = (doublereal) ((nindx - 1) / 2.f);
#line 1570 "pmtexb2.f"
	    elsperns = pow_dd(&c_b763, &d__1);
#line 1571 "pmtexb2.f"
	    elsksum += elsperns;
#line 1572 "pmtexb2.f"
	}
#line 1573 "pmtexb2.f"
/* L2: */
#line 1573 "pmtexb2.f"
    }
#line 1574 "pmtexb2.f"
    delta = *nnb * sumxx - *sumx * *sumx;
#line 1575 "pmtexb2.f"
    em = (*nnb * sumxy - *sumx * *sumy) / delta;
#line 1576 "pmtexb2.f"
    r__1 = em * all_1.slfac;
#line 1576 "pmtexb2.f"
    *islope = ni_(&r__1);
#line 1577 "pmtexb2.f"
    if (abs(*islope) > 9) {
#line 1578 "pmtexb2.f"
	*islope = i_sign(&c__9, islope);
#line 1579 "pmtexb2.f"
	beta = (*sumy - *islope / all_1.slfac * *sumx) / *nnb;
#line 1580 "pmtexb2.f"
    } else {
#line 1581 "pmtexb2.f"
	beta = (*sumy * sumxx - *sumx * sumxy) / delta;
#line 1582 "pmtexb2.f"
    }
#line 1583 "pmtexb2.f"
    *nolev1 = beta + .5f;
/* #### Check if any stems are too short */
#line 1585 "pmtexb2.f"
    smin = 100.f;
#line 1586 "pmtexb2.f"
    iul = -1;
#line 1587 "pmtexb2.f"
    if (all_1.ul[all_1.iv + ibc * 5 - 6] == 'u') {
#line 1587 "pmtexb2.f"
	iul = 1;
#line 1587 "pmtexb2.f"
    }
#line 1588 "pmtexb2.f"
    i__1 = *nnb;
#line 1588 "pmtexb2.f"
    for (inb = 1; inb <= i__1; ++inb) {
#line 1589 "pmtexb2.f"
	ybeam = *nolev1 + iul * all_1.stemlen + *islope * xelsk[inb] / 
#line 1589 "pmtexb2.f"
		all_1.slfac;
#line 1590 "pmtexb2.f"
	ynote = (real) all_1.nolev[all_1.iv + ipb[inb] * 5 - 6];
/* Computing MIN */
#line 1591 "pmtexb2.f"
	r__1 = smin, r__2 = iul * (ybeam - ynote);
#line 1591 "pmtexb2.f"
	smin = dmin(r__1,r__2);
#line 1592 "pmtexb2.f"
/* L4: */
#line 1592 "pmtexb2.f"
    }
#line 1593 "pmtexb2.f"
    if (smin < all_1.stemmin) {
#line 1594 "pmtexb2.f"
	deficit = all_1.stemmin - smin;
#line 1595 "pmtexb2.f"
	nolevo = *nolev1;
#line 1596 "pmtexb2.f"
	r__1 = *nolev1 + iul * deficit;
#line 1596 "pmtexb2.f"
	*nolev1 = ni_(&r__1);
#line 1597 "pmtexb2.f"
    }
#line 1598 "pmtexb2.f"
    return 0;
} /* setupb2_ */

