* expho.kumac: Execute cmz management operations interactively: * Create cmz libraries gcdes.cmz, zcdes.cmz, and phosim.cmz * cmz ascii-readable file phosim.car; * Create cmz library server.cmz from cmz ascii-readable file server.car; * Extract PMC source, command, data, document, and/or include files * from the .cmz libraries. * Use: in cmz, exe expho and follow prompts. * This macro leaves you in cmz, to allow further work; type exit to * leave cmz. * Note that the .cmz files are platform-independent. * Problem: because library names are entered with .cmz, there's no good * way to refer or set default to a particularly library. We could force * the user to enter the name without the extension, but that has not been * a good solution in the past. * 25-Apr-97 Generalize handling of platform-specific code * The default CMZ selections for UFILE are "type" and the Phobos label * for the operating system, "aix", ..., as listed below. * 01-Dec-96 Creation (Robin Verdier) * mess Type y for a positive response to any question, q to exit, mess or press return to accept the default. If a file to be created mess already exists, you should answer 'n' to the 'create new' question. mess If you are unsure whether a file exists, use ctrl-c or q to exit mess this macro, execute shell or exit and check, then return or restart. mess mess Define operating system for default directory syntax and CMZ mess selections that can be overridden later. Choose aix for IBM, mess hp-ux for HP, irix for SGI, osf1 for DEC Unix, solaris for Sun, mess vms for DEC OpenVMS on Alpha or VAX, or q to quit. mess Operating system (aix/hp-ux/irix/osf1/solaris/vms/q) [aix]? os = aix read os if [os] = 'q' then goto END endif dis = UNIX if [os] = 'vms' then dis = VMS endif * mess Optional pathname to cmz files, such as mess /phobos/u/phobos/sim/pro at BNL, mess /scratchp/phobos/sim/pro on Ralph2.mit.edu mess /phobos/sim/pro on abacus.mit.edu mess phobos_root:[sim.new on irene.mit.edu mess You can refer to this path as '[pr]' in specifying filenames. pr = /phobos/u/phobos/sim/pro if [dis] = 'VMS' then pr = 'phobos_root:[sim.new' endif read pr * cardir = 0 cmzdir = 0 gcdcmzfile = 0 pmccmzfile = 0 srvcmzfile = 0 zcdcmzfile = 0 * * GEANT common descriptor CMZ library * mess Make GEANT common descriptor library gcdes.cmz from gcdes.car (y/n/q)? MakeGCDCMZ = 'n' read MakeGCDCMZ if [MakeGCDCMZ] = 'q' then goto END endif if [MakeGCDCMZ] = 'y' then if [cardir] = 0 then cardir = [pr]/cmz * The following rigamarole is necessary since vms directories end in ] * whereas unix directories do not. It would be easier if cmz supported * null strings. if [dis] = 'VMS' then cardir = [pr].cmz] endif endif mess Directory for gcdes.car? read cardir gcdcar = gcdes.car mess gcdes .car filename? read gcdcar if [cmzdir] = 0 then cmzdir = [cardir] endif mess Directory for gcdes .cmz file? read cmzdir gcdcmzlib = gcdes.cmz mess gcdes .cmz filename? read gcdcmzlib carfile = [cardir]/[gcdcar] gcdcmzfile = [cmzdir]/[gcdcmzlib] if [dis] = 'VMS' then carfile = [cardir][gcdcar] gcdcmzfile = [cmzdir][gcdcmzlib] endif newcmz = 'y' mess Create new [gcdcmzlib] (n will overwrite existing one)? read newcmz release * if [newcmz] = 'y' then mess Creating Geant common descriptor CMZ library [gcdcmzfile] mess from [carfile] create [gcdcmzfile] else mess Replacing Geant common descriptor CMZ library [gcdcmzfile] mess from [carfile] file [gcdcmzfile] endif arc [carfile] mess endif * * Zebra common descriptor CMZ library * mess Make Zebra common descriptor library zcdes.cmz from zcdes.car (y/n/q)? MakeZCDCMZ = 'n' read MakeZCDCMZ if [MakeZCDCMZ] = 'q' then goto END endif if [MakeZCDCMZ] = 'y' then if [cardir] = 0 then cardir = [pr]/cmz if [dis] = 'VMS' then cardir = [pr].cmz] endif endif mess Directory for zcdes.car? read cardir zcdcar = zcdes.car mess zcdes .car filename? read zcdcar if [cmzdir] = 0 then cmzdir = [cardir] endif mess Directory for zcdes .cmz file? read cmzdir zcdcmzlib = zcdes.cmz mess zcdes .cmz filename ? read zcdcmzlib carfile = [cardir]/[zcdcar] zcdcmzfile = [cmzdir]/[zcdcmzlib] if [dis] = 'VMS' then carfile = [cardir][zcdcar] zcdcmzfile = [cmzdir][zcdcmzlib] endif newcmz = 'y' mess Create new [zcdcmzlib] (n will overwrite existing one)? read newcmz release * if [newcmz] = 'y' then mess Creating Geant common descriptor CMZ library [zcdcmzfile] mess from [carfile] create [zcdcmzfile] else mess Replacing Geant common descriptor CMZ library [zcdcmzfile] mess from [carfile] file [zcdcmzfile] endif arc [carfile] mess endif * * PMC CMZ library * mess Make PMC library phosim.cmz from phosim.car (y/n/q)? MakePMCLib = 'n' read MakePMCLib if [MakePMCLib] = 'q' then goto END endif if [MakePMCLib] = 'y' then if [cardir] = 0 then cardir = [pr]/cmz if [dis] = 'VMS' then cardir = [pr].cmz] endif endif mess Directory for phosim.car? read cardir pmccar = phosim.car mess phosim .car filename? read pmccar if [cmzdir] = 0 then cmzdir = [cardir] endif mess Directory for phosim .cmz file? read cmzdir pmccmzlib = phosim.cmz mess phosim .cmz filename? read pmccmzlib carfile = [cardir]/[pmccar] pmccmzfile = [cmzdir]/[pmccmzlib] if [dis] = 'VMS' then carfile = [cardir][pmccar] pmccmzfile = [cmzdir][pmccmzlib] endif newcmz = 'y' mess Create new [pmccmzlib] (n will overwrite existing one)? read newcmz release * if [newcmz] = 'y' then mess Creating PMC CMZ library [pmccmzfile] mess from [carfile] create [pmccmzfile] else mess Replacing PMC CMZ library [pmccmzfile] mess from [carfile] file [pmccmzfile] endif arc [carfile] mess endif * * Server CMZ library * mess Make Phobos MC server library server.cmz from server.car (y/n/q)? MakeServerLib = 'n' read MakeServerLib if [MakeServerLib] = 'q' then goto END endif if [MakeServerLib] = 'y' then if [cardir] = 0 then cardir = [pr]/cmz if [dis] = 'VMS' then cardir = [pr].cmz] endif endif mess Directory for server.car? read cardir srvcar = server.car mess server .car filename? read srvcar if [cmzdir] = 0 then cmzdir = [cardir] endif mess Directory for server .cmz file? read cmzdir srvcmzlib = server.cmz mess server .cmz filename? read srvcmzlib carfile = [cardir]/[srvcar] srvcmzfile = [cmzdir]/[srvcmzlib] if [dis] = 'VMS' then carfile = [cardir][srvcar] srvcmzfile = [cmzdir][srvcmzlib] endif newcmz = 'y' mess Create new [srvcmzlib] (n will overwrite existing one)? read newcmz release * if [newcmz] = 'y' then mess Creating server CMZ library [srvcmzfile] mess from [carfile] create [srvcmzfile] else mess Replacing server CMZ library [srvcmzfile] mess from [carfile] file [srvcmzfile] endif arc [carfile] mess endif * * Command files * mess Extract VMS procedures, UNIX scripts, and/or kumacs (y/n/q)? ExtractCmds = 'n' read ExtractCmds if [ExtractCmds] = 'q' then goto END endif if [ExtractCmds] = 'y' then release * if [pmccmzfile] = 0 then pmccmzfile = [pr]/cmz/phosim.cmz if [dis] = 'VMS' then pmccmzfile = [pr].cmz]phosim.cmz endif mess phosim .cmz library? read pmccmzfile endif file [pmccmzfile] -r * mess Extract VMS command procedures (y/n/q)? ExtractVMS = 'n' read ExtractVMS if [ExtractVMS] = 'q' then goto END endif if [ExtractVMS] = 'y' then CmdDir = [pr]/cmd if [dis] = 'VMS' then CmdDir = [pr].cmd] endif mess Directory for created files? read CmdDir mess Command procedures to extract? Procs = '*' dir com/[Procs] read Procs mess Extracting VMS command procedure files from [pmccmzfile] set [CmdDir]/*.com -f text if [dis] = 'VMS' then set [CmdDir]*.com -f text endif ctot com/[Procs] mess endif * mess Extract Unix scripts (y/n/q)? ExtractUnix = 'n' read ExtractUnix if [ExtractUnix] = 'q' then goto END endif if [ExtractUnix] = 'y' then UnixDir = [pr]/unix if [dis] = 'VMS' then UnixDir = [pr].unix] endif mess Directory for created files? read UnixDir mess Unix scripts to extract? Scripts = '*' dir unix/[Scripts] read Scripts mess Extracting Unix script files from [pmccmzfile] set [UnixDir]/* -f text if [dis] = 'VMS' then set [UnixDir]*. -f text endif ctot unix/[Scripts] mess endif * mess Extract .kumac macro files (y/n/q)? ExtractKumacs = 'n' read ExtractKumacs if [ExtractKumacs] = 'q' then goto END endif if [ExtractKumacs] = 'y' then CmdDir = [pr]/cmd if [dis] = 'VMS' then CmdDir = [pr].cmd] endif mess Directory for created files? read CmdDir mess Kumac files to extract? Kumacs = '*' dir kumac/[Kumacs] read Kumacs mess Extracting .kumac macro files from [pmccmzfile] set [CmdDir]/*.kumac -f text if [dis] = 'VMS' then set [CmdDir]*.kumac -f text endif ctot kumac/[Kumacs] mess endif * mess Extract .awk scripts (y/n/q)? ExtractAwks = 'n' read ExtractAwks if [ExtractAwks] = 'q' then goto END endif if [ExtractAwks] = 'y' then AwkDir = [pr]/awk if [dis] = 'VMS' then AwkDir = [pr].awk] endif mess Directory for created files? read AwkDir mess Awk scripts to extract? Awks = '*' dir awk/[Awks] read Awks mess Extracting .awk scripts from [pmccmzfile] set [AwkDir]/*.awk -f text if [dis] = 'VMS' then set [AwkDir]*.awk -f text endif ctot awk/[Awks] mess endif endif * * Data files * mess Extract data files including geometry and field maps (y/n/q)? ExtractData = 'n' read ExtractData if [ExtractData] = 'q' then goto END endif if [ExtractData] = 'y' then release * if [pmccmzfile] = 0 then pmccmzfile = [pr]/cmz/phosim.cmz if [dis] = 'VMS' then pmccmzfile = [pr].cmz]phosim.cmz endif mess phosim .cmz library? read pmccmzfile endif file [pmccmzfile] -r DataDir = [pr]/dat if [dis] = 'VMS' then DataDir = [pr].dat] endif mess Directory for created files? read DataDir mess Data files to extract? * The following works interactively but not in a macro: * DataFiles = 'cont?* map?* ugcdat?*' * DataFiles = 'CONTDEMO CONTROL CONTROL_B PHOMAG?* UGCDAT?*' DataFiles = '*' dir dat/[DataFiles] read DataFiles mess Extracting data files from [pmccmzfile] set [DataDir]/*.txt -f text if [dis] = 'VMS' then set [DataDir]*.txt -f text endif ctot dat/[DataFiles] mess Note that the track file and magnetic field map are not included mess in the CMZ library. mess endif * * Documents: * mess Extract document files (y/n/q)? ExtractDocs = n read ExtractDocs if [ExtractDocs] = 'q' then goto END endif if [ExtractDocs] = 'y' then release * if [pmccmzfile] = 0 then pmccmzfile = [pr]/cmz/phosim.cmz if [dis] = 'VMS' then pmccmzfile = [pr].cmz]phosim.cmz endif mess phosim .cmz library? read pmccmzfile endif file [pmccmzfile] -r DocDir = [pr]/doc if [dis] = 'VMS' then DocDir = [pr].doc] endif mess Directory for created files? read DocDir mess Document files to extract? DocFiles = '*' dir doc/[DocFiles] read DocFiles mess Extracting document files from [pmccmzfile] set [DocDir]/*.doc -f text if [dis] = 'VMS' then set [DocDir]*.doc -f text endif ctot doc/[DocFiles] mess endif * * Platform-specific files * mess Extract platform-specific source files (y/n/q)? mess This is presently necessary only for IBM, HP, and DEC. mess Note that source file extractions will fail unless the common mess descriptor libraries gcdes.cmz and zcdes.cmz exist. ExtractOss = 'n' read ExtractOss if [ExtractOss] = 'q' then goto END endif if [ExtractOss] = 'y' then if [gcdcmzfile] = 0 then gcdcmzfile = [pr]/cmz/gcdes.cmz if [dis] = 'VMS' then gcdcmzfile = [pr].cmz]gcdes.cmz endif mess GCDES .cmz library? read gcdcmzfile endif if [zcdcmzfile] = 0 then zcdcmzfile = [pr]/cmz/zcdes.cmz if [dis] = 'VMS' then zcdcmzfile = [pr].cmz]zcdes.cmz endif mess ZCDES .cmz library? read zcdcmzfile endif if [pmccmzfile] = 0 then pmccmzfile = [pr]/cmz/phosim.cmz if [dis] = 'VMS' then pmccmzfile = [pr].cmz]phosim.cmz endif mess phosim .cmz library? read pmccmzfile endif mess Directory for created files? SrcDir = [pr]/src[os]/ if [dis] = 'VMS' then SrcDir = [pr].src[os]] endif read SrcDir seq . sel . sel type sel [os] mess The following default CMZ selectors should normally be correct mes for the [os] operating system: sel mess If required, you may now enter an additional selector, or an mess existing selector preceded by - to remove it, or 0 when no mess more changes are required. SELECT: AddSel = 0 read AddSel if [AddSel] <> 0 then sel [AddSel] sel goto SELECT endif release * mess Please ignore the CMZ QTRACEx override messages file [zcdcmzfile] -r seq /QCDE file [gcdcmzfile] -r seq -o /gcdes file [pmccmzfile] -r seq /inc set [SrcDir]*.f -f if [dis] = 'VMS' then set [SrcDir]*.for -f endif * Select on osf1 to get UFILE grep -i OSF1 for/* mess The following files are selected: buffer mess Normally only UFILE on IBM, HP-UX, or OSF1 is platform-specific. mess If required, you may now enter an additional filename, or an mess existing filename preceded by - to remove it, or 0 when no mess more changes are required. FILE: AddFile = 0 read AddFile if [AddFile] <> 0 then buf [AddFile] buf goto FILE endif mess Extracting platform-specific FORTRAN source files from [pmclib] cxtract -b mess endif * * Include files * mess Extract include files (y/n/q)? ExtractIncs = n read ExtractIncs if [ExtractIncs] = 'q' then goto END endif if [ExtractIncs] = 'y' then release * if [pmccmzfile] = 0 then pmccmzfile = [pr]/cmz/phosim.cmz if [dis] = 'VMS' then pmccmzfile = [pr].cmz]phosim.cmz endif mess phosim .cmz library? read pmccmzfile endif file [pmccmzfile] -r IncDir = [pr]/inc if [dis] = 'VMS' then IncDir = [pr].inc] endif mess Directory for created files? read IncDir mess Include files to extract? IncFiles = '*' dir inc/[IncFiles] read IncFiles mess Extracting include files from [pmccmzfile] set [IncDir]/*.inc -f text if [dis] = 'VMS' then set [IncDir]*.inc -f text endif ctot inc/[IncFiles] mess endif * * PMC source files * mess Extract PMC source files (y/n/q)? ExtractPMCSrc = 'n' read ExtractPMCSrc if [ExtractPMCSrc] = 'q' then goto END endif if [ExtractPMCSrc] = 'y' then mess Normal or server version (n / s)? vers = n nss = NOSERV read vers if [vers] = s then nss = SERVER endif if [gcdcmzfile] = 0 then gcdcmzfile = [pr]/cmz/gcdes.cmz if [dis] = 'VMS' then gcdcmzfile = [pr].cmz]gcdes.cmz endif mess GCDES .cmz library? read gcdcmzfile endif if [zcdcmzfile] = 0 then zcdcmzfile = [pr]/cmz/zcdes.cmz if [dis] = 'VMS' then zcdcmzfile = [pr].cmz]zcdes.cmz endif mess ZCDES .cmz library? read zcdcmzfile endif if [pmccmzfile] = 0 then pmccmzfile = [pr]/cmz/phosim.cmz if [dis] = 'VMS' then pmccmzfile = [pr].cmz]phosim.cmz endif mess phosim .cmz library? read pmccmzfile endif mess Directory for created files? PMCSrcDir = [pr]/srcgen if [dis] = 'VMS' then PMCSrcDir = [pr].srcgen] endif read PMCSrcDir mess Extracting PMC source files from [pmccmzfile] mess with CMZ selection [dis] mess You should edit this kumac if you wish to select EUCARD, IBM, mess NONTUP, or SUN. None of these is necessary. release * seq . sel . sel type sel [dis] sel [nss] mess Please ignore the CMZ QTRACEx override messages file [zcdcmzfile] -r seq /QCDE file [gcdcmzfile] -r seq -o /gcdes file [pmccmzfile] -r seq /inc set [PMCSrcDir]/*.f -f if [dis] = 'VMS' then set [PMCSrcDir]*.for -f endif mess PMC source files to extract? PMCSrcFiles = '*' dir for/[PMCSrcFiles] read PMCSrcFiles cxtract for/[PMCSrcFiles] mess Modified CERN source files to extract? ModCernSrcFiles = '*' dir modcern/[ModCernSrcFiles] read ModCernSrcFiles cxtract modcern/[ModCERNSrcFiles] mess endif * * Server Fortran source decks: * mess Extract MC server source files (y/n/q)? ExtractSrvSrc = 'n' read ExtractSrvSrc if [ExtractSrvSrc] = 'q' then goto END endif if [ExtractSrvSrc] = 'y' then if [gcdcmzfile] = 0 then gcdcmzfile = [pr]/cmz/gcdes.cmz if [dis] = 'VMS' then gcdcmzfile = [pr].cmz]gcdes.cmz endif mess GCDES .cmz library? read gcdcmzfile endif if [zcdcmzfile] = 0 then zcdcmzfile = [pr]/cmz/zcdes.cmz if [dis] = 'VMS' then zcdcmzfile = [pr].cmz]zcdes.cmz endif mess ZCDES .cmz library? read zcdcmzfile endif if [srvcmzfile] = 0 then srvcmzfile = [pr]/cmz/server.cmz if [dis] = 'VMS' then srvcmzfile = [pr].cmz]server.cmz endif mess server .cmz library? read srvcmzfile endif mess Directory for created files? SrvSrcDir = [pr]/srcsrv if [dis] = 'VMS' then SrvSrcDir = [pr].srcsrv] endif read SrvSrcDir mess Extracting MC server source files from [srvcmzfile] mess with CMZ selection [dis]. mess You should edit this kumac if you wish to select SHELL or UXXL. mess SHELL is obsolete, UXXL is specific to the Sun OS, neither is mess necessary. release * seq . sel . sel type sel [dis] file [zcdcmzfile] -r seq /QCDE file [gcdcmzfile] -r seq -o /gcdes file [srvcmzfile] -r seq /inc set [SrvSrcDir]/*.f -f if [dis] = 'VMS' then set [SrvSrcDir]*.for -f endif mess Server source files to extract? SrvSrcFiles = '*' dir for/[SrvSrcFiles] read SrvSrcFiles cxtract for/[SrvSrcFiles] endif * mess Extract server versions of PMC files (unnecessary unless you will mess compile and link the server version)? ExtractSrvPMC = 'n' read ExtractSrvPMC if [ExtractSrvPMC] = 'y' then mess CAUTION: These files should not be extracted into the same directory mess as the normal non-server versions, or they will overwrite them. mess Directory for created files? SrvPMCDir = [pr]/srcsrv if [dis] = 'VMS' then SrvPMCDir = [pr].srcsrv] endif read SrvPMCDir * The following should be checked in stoper, ugserv, and ugcons mess Selector key that indicates server versions in the PMC library? mess (The default selector, 'noserv', is correct at present.) mess To skip this extraction, reply '0' SrvSel = 'noserv' read SrvSel if [SrvSel] <> '0' then mess Extracting server versions of PMC source files from [pmclib] mess with CMZ selection [dis]. mess You must edit this kumac if you wish to select EUCARD or SUN. if [gcdcmzfile] = 0 then gcdcmzfile = [pr]/cmz/gcdes.cmz if [dis] = 'VMS' then gcdcmzfile = [pr].cmz]gcdes.cmz endif mess GCDES .cmz library? read gcdcmzfile endif if [zcdcmzfile] = 0 then zcdcmzfile = [pr]/cmz/zcdes.cmz if [dis] = 'VMS' then zcdcmzfile = [pr].cmz]zcdes.cmz endif mess ZCDES .cmz library? read zcdcmzfile endif if [pmccmzfile] = 0 then pmccmzfile = [pr]/cmz/phosim.cmz if [dis] = 'VMS' then pmccmzfile = [pr].cmz]phosim.cmz endif mess phosim .cmz library? read pmccmzfile endif release * seq . sel . sel type sel [dis] sel SERVER mess Please ignore the CMZ QTRACEx override messages file [zcdcmzfile] -r seq /QCDE file [gcdcmzfile] -r seq -o /gcdes file [pmccmzfile] -r seq /inc set [SrvPMCDir]/*.f -f if [dis] = 'VMS' then set [SrvPMCDir]*.for -f endif grep -i [SrvSel] for/* buffer cxtract -b mess endif endif * END: