Skip to content

Commit

Permalink
Initial changes to remove cernlib dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
gaskelld committed Jul 13, 2020
1 parent 0bef3b5 commit 1ebbca8
Show file tree
Hide file tree
Showing 16 changed files with 640 additions and 59 deletions.
8 changes: 7 additions & 1 deletion CTP/Makefile.Unix
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,16 @@ endif

include ../Makefile.etc

#ctp_sources = thTest.c thTestParse.c thTestExecute.c thHandlers.c thParm.c \
# thUtils.c thLoad.c thGroup.c thHist.c thReport.c thGethit.c \
# daVarRegister.c daVarRpcProc.c daVarHandlers.c daVarServ.c \
# daVarRpc_svc.c daVarRpc_xdr.c daVarHashLib.c thTree.c

ctp_sources = thTest.c thTestParse.c thTestExecute.c thHandlers.c thParm.c \
thUtils.c thLoad.c thGroup.c thHist.c thReport.c thGethit.c \
thUtils.c thLoad.c thGroup.c thReport.c \
daVarRegister.c daVarRpcProc.c daVarHandlers.c daVarServ.c \
daVarRpc_svc.c daVarRpc_xdr.c daVarHashLib.c thTree.c

ctpclient_sources = daVarRpc_xdr.c daVarRpc_clnt.c thClient.c

lib_targets := $(patsubst %.c, libctp.a(%.o), $(ctp_sources)) \
Expand Down
6 changes: 3 additions & 3 deletions CTP/thGroup.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,11 @@ typedef struct thHook thHook;
/* How many of these c routines are "advertised */
thHook thHooks[] = {
{PARMSTR ,thLoadParameters,0,0,0,0,0,0},
{GETHITSTR ,thBookGethits,thExecuteaGethitBlock,0,0,0,0,0},
/*{GETHITSTR ,thBookGethits,thExecuteaGethitBlock,0,0,0,0,0},*/
{TESTSTR ,thBookTests,thExecuteTestsV,thClearTestFlagsV,thClearTestScalersV
,thIncTestScalersV,0,0},
{HISTSTR,thBookHists,thExecuteHistsV,thClearHistsV,0,0,0,0},
{UHISTSTR,thBookHists,0,0,0,0,0,0},
/*{HISTSTR,thBookHists,thExecuteHistsV,thClearHistsV,0,0,0,0},*/
/*{UHISTSTR,thBookHists,0,0,0,0,0,0},*/
{TREESTR,thBookTree,thFillTreeV,thClearTreeV,0,0,thWriteTreeV,thCloseTreeV},
{REPORTSTR,thBookReports,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0}};
Expand Down
6 changes: 3 additions & 3 deletions CTP/thHandlers.c
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,8 @@ daVarStatus thHistRHandler(char *name, daVarStruct *varclass, any *retval)
retval->any_u.error = S_DAVAR_UNKATTR;
if(thLastIdRhandled != *((DAINT *) varp->varptr)) {
thLastIdRhandled = *((DAINT *) varp->varptr);
HGIVE(*((DAINT *) varp->varptr),chtitle,NX,XMI,XMA,NY,YMI,YMA
,NWT,LOC);
/*HGIVE(*((DAINT *) varp->varptr),chtitle,NX,XMI,XMA,NY,YMI,YMA
,NWT,LOC);*/
}
if(strcasecmp(attribute,TH_ND) == 0){
retval->valtype = DAVARINT_RPC;
Expand Down Expand Up @@ -207,7 +207,7 @@ daVarStatus thHistRHandler(char *name, daVarStruct *varclass, any *retval)
retval->any_u.r.r_val = (float *)malloc(size*sizeof(float));
/* Next line gives warning "assignment of read-only location */
char tmpstring[] = "HIST";
HUNPAK(thLastIdRhandled,retval->any_u.r.r_val,tmpstring,(int) 1);
/*HUNPAK(thLastIdRhandled,retval->any_u.r.r_val,tmpstring,(int) 1);*/
}
}
return(status);
Expand Down
4 changes: 2 additions & 2 deletions CTP/thLoad.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ extern daVarStatus thRHandler();*/
char *types[]={PARMSTR, GETHITSTR, TESTSTR, HISTSTR, UHISTSTR,
TREESTR,
REPORTSTR, 0};
thStatus (*hooks[])()={thLoadParameters, thBookGethits, thBookTests,
thBookHists, thBookHists,
thStatus (*hooks[])()={thLoadParameters, /*thBookGethits,*/ thBookTests,
/*thBookHists, thBookHists,*/
thBookTree,
thBookReports, 0};

Expand Down
28 changes: 13 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,8 @@
## These will have to be modified when setting up your own simc. They
## point to the software necessary to run simc.

## ARGONNE DEFAULT SETUP FLAGS:
#simcdir = .
#Csoft = /disk1/users/reinhold/Csoft/05Dec1996

## CEBAF DEFAULT SETUP FLAGS:
simcdir = .
#Csoft = /group/hallc/Csoft/Analyzer
#Csoft = /group/c-gep/jones/Linux_fc8/

## U Regina SETUP FLAGS
simcdir = .
Csoft = /home/huberg/r2d2/simc/

## THE REST SHOULD BE OK WITHOUT MODIFICATION.

Expand All @@ -31,11 +21,12 @@ A = $(simcdir)/shared/
SH = $(simcdir)/shms/
T = $(simcdir)/cteq5/
C = $(simcdir)/calo/
CH = $(simcdir)/cern/

OBJ1 = target.o brem.o gauss1.o NtupleInit.o NtupleClose.o enerloss_new.o
OBJ2 = radc.o init.o dbase.o physics_kaon.o physics_pion.o physics_delta.o physics_proton.o loren.o sf_lookup.o
OBJ3 = semi_physics.o rho_physics.o rho_decay.o generate_rho.o trg_track.o semi_dilution.o
OBJ4 = results_write.o event.o ranlux.o jacobians.o
OBJ4 = results_write.o event.o call_ranlux.o jacobians.o
OBJ5 = $(A)musc.o $(A)musc_ext.o $(A)project.o $(A)transp.o
OBJ6 = $(A)rotate_haxis.o $(A)rotate_vaxis.o $(A)locforunt.o
OBJ7 = $(H)mc_hms.o $(H)mc_hms_hut.o $(H)mc_hms_recon.o
Expand All @@ -45,13 +36,16 @@ OBJA = $(L)mc_hrsl.o $(L)mc_hrsl_hut.o $(L)mc_hrsl_recon.o
OBJB = $(SH)mc_shms.o $(SH)mc_shms_hut.o $(SH)mc_shms_recon.o
OBJC = $(T)Ctq5Pdf.o
OBJD = $(C)mc_calo.o $(C)mc_calo_recon.o
my_objs = $(OBJ1) $(OBJ2) $(OBJ3) $(OBJ4) $(OBJ5) $(OBJ6) $(OBJ7) $(OBJ8) $(OBJ9) $(OBJA) $(OBJB) $(OBJC) $(OBJD)
OBJCH = $(CH)lfit.o $(CH)ranlux.o $(CH)fint.o $(CH)kerset.o $(CH)abend.o

my_objs = $(OBJ1) $(OBJ2) $(OBJ3) $(OBJ4) $(OBJ5) $(OBJ6) $(OBJ7) $(OBJ8) $(OBJ9) $(OBJA) $(OBJB) $(OBJC) $(OBJD) $(OBJCH)

my_deps = $(my_objs:.o=.d)

MYOS := $(subst -,,$(shell uname))
#CERNLIBS = -lgeant$(GEANTVER) -lpawlib -lgraflib -lgrafX11 -lpacklib -lmathlib
CERNLIBS = -Wl,-static -lgeant$(GEANTVER) -lpawlib -lgraflib -lgrafX11 -lpacklib -lkernlib -lmathlib -ljetset74 -Wl,-dy
#CERNLIBS = -Wl,-static -lgeant$(GEANTVER) -lpawlib -lgraflib -lgrafX11 -lpacklib -lkernlib -lmathlib -ljetset74 -Wl,-dy


#For use with gfortran compiler
# -fno-automatic - all program storage treated as static
Expand All @@ -68,7 +62,7 @@ ifeq ($(MYOS),Linux)
FFLAGS= $(INCLUDES) $(FFLAGSA)
FFLAG1=$(FFLAGS) -c
OTHERLIBS = -L$(LIBROOT) -lctp \
-L$(CERN_ROOT)/lib $(CERNLIBS) -L/usr/lib64
-L$(CERN_ROOT)/lib -L/usr/lib64
# 64 vs 32 bit
# -L$(CERN_ROOT)/lib $(CERNLIBS) -L/usr/lib
FC := gfortran
Expand Down Expand Up @@ -113,6 +107,10 @@ $(R)/%.o: $(R)/%.f
$(SH)/%.o: $(SH)/%.f
$(F77) $(FFLAGS) -c $< -o $@

$(CH)/%.o: $(SH)/%.f
$(F77) $(FFLAGS) -c $< -o $@


DEPEND_RULE = ( cat $< | sed -n -e \
"s|^[ ]*[Ii][Nn][Cc][Ll][Uu][Dd][Ee][ ]*['\"]|$@: $(@D)/|p" | \
sed -e "s|['\"].*$$||" | \
Expand Down Expand Up @@ -164,7 +162,7 @@ CTP/O.Linux/Linux/lib/libctp.a:


clean:
$(RM) *.[od] $(H)*.[od] $(S)*.[od] $(L)*.[od] $(R)*.[od] $(SH)*.[od] $(A)*.[od] $(T)*.[od] $(C)*.[od] simc
$(RM) *.[od] $(H)*.[od] $(S)*.[od] $(L)*.[od] $(R)*.[od] $(SH)*.[od] $(A)*.[od] $(T)*.[od] $(C)*.[od] $(CH)*.[od] simc

real_clean:
$(RM) *.[od] $(H)*.[od] $(S)*.[od] $(L)*.[od] $(R)*.[od] $(SH)*.[od] $(A)*.[od] $(T)*.[od] $(C)*.[od] simc
Expand Down
10 changes: 5 additions & 5 deletions NtupleClose.f
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ subroutine NtupleClose(filename)
character*80 filename
integer*4 cycle

cycle= 0 !dummy for HROUT
call HCDIR(NtupleDirectory,' ')
call HROUT(NtupleID,cycle,' ') !flush CERNLIB buffers
call HREND(NtupleName) !CERNLIB close file
write(6,*)'Closing file:',filename(1:60)
c cycle= 0 !dummy for HROUT
c call HCDIR(NtupleDirectory,' ')
c call HROUT(NtupleID,cycle,' ') !flush CERNLIB buffers
c call HREND(NtupleName) !CERNLIB close file
c write(6,*)'Closing file:',filename(1:60)
CLOSE(NtupleIO) !close IO channel

return
Expand Down
40 changes: 24 additions & 16 deletions NtupleInit.f
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,27 @@ subroutine NtupleInit(filename)

character*80 filename,directory
character*16 NtupleTag(80),name,title
integer*4 m,io,recl,bank,id,status
parameter(recl = 1024)
parameter(bank = 8000)
integer*4 m,io,recl,bank,id,status,i
c parameter(recl = 1024)
c parameter(bank = 8000)
parameter(io = 29)
parameter(name = 'SimcNtuple')
parameter(title = 'SIMTUPLE')

NtupleID = defaultID
id = NtupleID
c NtupleID = defaultID
c id = NtupleID
NtupleIO = io
NtupleName = name
c NtupleName = name

call HCDIR(directory,'R') !CERNLIB read current directory
call HROPEN(io,name,filename,'N',recl,status) !CERNLIB
c call HCDIR(directory,'R') !CERNLIB read current directory
c call HROPEN(io,name,filename,'N',recl,status) !CERNLIB
!directory set to "//TUPLE"
if (status.ne.0)then
write(6,*) 'HROPEN error: istat=',status
stop
endif
c if (status.ne.0)then
c write(6,*) 'HROPEN error: istat=',status
c stop
c endif

open(NtupleIO,file=filename,form="unformatted",access="sequential")

m = 0
m = m+1
Expand Down Expand Up @@ -279,11 +281,17 @@ subroutine NtupleInit(filename)

NtupleSize = m

call HBOOKN(id,title,NtupleSize,name,bank,NtupleTag) !create Ntuple

call HCDIR(NtupleDirectory,'R') !record Ntuple directory
c call HBOOKN(id,title,NtupleSize,name,bank,NtupleTag) !create Ntuple
c
c call HCDIR(NtupleDirectory,'R') !record Ntuple directory
c
c call HCDIR(directory,' ') !reset CERNLIB directory

call HCDIR(directory,' ') !reset CERNLIB directory
c write ntuple size first
write(NtupleIO) NtupleSize
do i=1,m
write(NtupleIO) NtupleTag(i)
enddo

return
end
Expand Down
3 changes: 2 additions & 1 deletion ranlux.f → call_ranlux.f
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ subroutine start_file_random_state(fname)
double precision function grnd()
implicit none
integer len/1000/,latest,i
real*4 rvec(1000)
c real*4 rvec(1000)
real*8 rvec(1000)

if(latest.le.0 .or. latest.ge.1000) then
CALL RANLUX(RVEC,LEN)
Expand Down
16 changes: 16 additions & 0 deletions cern/abend.f
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
*
* $Id: abend.F,v 1.1.1.1 1996/02/15 17:48:36 mclareni Exp $
*
* $Log: abend.F,v $
* Revision 1.1.1.1 1996/02/15 17:48:36 mclareni
* Kernlib
*
*
#include "kernnumt/pilot.h"
SUBROUTINE ABEND
#include "kernnumt/sysdat.inc"
IF(LGFILE .EQ. 0) WRITE(*,1000)
IF(LGFILE .NE. 0) WRITE(LGFILE,1000)
RETURN
1000 FORMAT(31H ABEND ROUTINE HAS BEEN CALLED.)
END
84 changes: 84 additions & 0 deletions cern/fint.f
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
*
* $Id: fint.F,v 1.1.1.1 1996/02/15 17:48:36 mclareni Exp $
*
* $Log: fint.F,v $
* Revision 1.1.1.1 1996/02/15 17:48:36 mclareni
* Kernlib
*
*
#include "kernnum/pilot.h"
FUNCTION FINT(NARG,ARG,NENT,ENT,TABLE)
C
C INTERPOLATION ROUTINE. AUTHOR C. LETERTRE.
C MODIFIED BY B. SCHORR, 1.07.1982.
C
INTEGER NENT(9)
REAL*4 ARG(9), ENT(9), TABLE(9)
INTEGER INDEX(32)
REAL WEIGHT(32)
LOGICAL MFLAG, RFLAG
FINT = 0.
IF(NARG .LT. 1 .OR. NARG .GT. 5) GOTO 300
LMAX = 0
ISTEP = 1
KNOTS = 1
INDEX(1) = 1
WEIGHT(1) = 1.
DO 100 N = 1, NARG
X = ARG(N)
NDIM = NENT(N)
LOCA = LMAX
LMIN = LMAX + 1
LMAX = LMAX + NDIM
IF(NDIM .GT. 2) GOTO 10
IF(NDIM .EQ. 1) GOTO 100
H = X - ENT(LMIN)
IF(H .EQ. 0.) GOTO 90
ISHIFT = ISTEP
IF(X-ENT(LMIN+1) .EQ. 0.) GOTO 21
ISHIFT = 0
ETA = H / (ENT(LMIN+1) - ENT(LMIN))
GOTO 30
10 LOCB = LMAX + 1
11 LOCC = (LOCA+LOCB) / 2
IF(X-ENT(LOCC)) 12, 20, 13
12 LOCB = LOCC
GOTO 14
13 LOCA = LOCC
14 IF(LOCB-LOCA .GT. 1) GOTO 11
LOCA = MIN0( MAX0(LOCA,LMIN), LMAX-1 )
ISHIFT = (LOCA - LMIN) * ISTEP
ETA = (X - ENT(LOCA)) / (ENT(LOCA+1) - ENT(LOCA))
GOTO 30
20 ISHIFT = (LOCC - LMIN) * ISTEP
21 DO 22 K = 1, KNOTS
INDEX(K) = INDEX(K) + ISHIFT
22 CONTINUE
GOTO 90
30 DO 31 K = 1, KNOTS
INDEX(K) = INDEX(K) + ISHIFT
INDEX(K+KNOTS) = INDEX(K) + ISTEP
WEIGHT(K+KNOTS) = WEIGHT(K) * ETA
WEIGHT(K) = WEIGHT(K) - WEIGHT(K+KNOTS)
31 CONTINUE
KNOTS = 2*KNOTS
90 ISTEP = ISTEP * NDIM
100 CONTINUE
DO 200 K = 1, KNOTS
I = INDEX(K)
FINT = FINT + WEIGHT(K) * TABLE(I)
200 CONTINUE
RETURN
300 CALL KERMTR('E104.1',LGFILE,MFLAG,RFLAG)
IF(MFLAG) THEN
IF(LGFILE .EQ. 0) THEN
WRITE(*,1000) NARG
ELSE
WRITE(LGFILE,1000) NARG
ENDIF
ENDIF
IF(.NOT. RFLAG) CALL ABEND
RETURN
1000 FORMAT( 7X, 24HFUNCTION FINT ... NARG =,I6,
+ 17H NOT WITHIN RANGE)
END
Loading

0 comments on commit 1ebbca8

Please sign in to comment.