# Set of programs to convert UNRES xdrf format (compressed Cartesian coordinates) to PDF
# or raw-Cartesian format (*.x) or to extract backbone angular coordinates (*.ang)
# The pdb files can be constructed from canonical or MREMD trajectories.
#
# The xdrf library is required
#
# Programs
#
# xdrf2pdb   : converts a single cx trajectory file to PDB format
# xdrf2x     : converts a single cx trajectory file to raw-coordinate (x) format
# xdrf2ang   : extracts backbone angles from a cx trajectory file
# xdrf2pdb-m : converts a selected trajectory of a MREMD run dumpend into a cx file to PDB format
#
# xdrf2pdb1  : converts conformation(s) selected from a wham post-processing run into PDB format
# xdrf2x1    : converts conformation(s) selected from a wham post-processing run into raw (x) format.
#
# 9/23/2010 A. Liwo

FC=ifort
INSTALL_DIR = /users/software/mpich2-1.4.1p1_intel
#FC= ${INSTALL_DIR}/bin/mpif90
BINDIR = ../../bin

#OPT =  -fast
OPT = #-CA -CB

FFLAGS = -fpp -c ${OPT} 

CPPFLAGS = -DLINUX -DUNRES -DMP -DMPI -DSPLITELE -DPROCOR -DNEWUNRES  -DXDRFPDB -CB -g

M4 	= m4
M4FILE	= underscore.m4

.SUFFIXES: .F90
.F90.o:
	${FC} ${FFLAGS} ${CPPFLAGS} $*.F90
.f90.o:
	${FC} ${FFLAGS} ${CPPFLAGS} $*.f90
.c.o:
	${CC} -c  ${CPPFLAGS} $*.c

DATA_FILE= ../unres/data

data = names.o io_units.o compare_data.o energy_data.o geometry_data.o MD_data.o
data2 = names.o energy_data.o geometry_data.o

xdrf2pdb: ${data} io_base.o xdrf2pdb.o xdrf/libxdrf.a
	${FC} -Bstatic -o ${BINDIR}/xdrf2pdb-mult ${data} io_base.o xdrf2pdb.o xdrf/libxdrf.a

#xdrf2pdb1: xdrf2pdb1.o geomout.o misc.o rescode.o nazwy.o xdrf/libxdrf.a
#	${FC} -Bstatic -o ${BINDIR}/xdrf2pdb1-mult xdrf2pdb1.o geomout.o rescode.o misc.o nazwy.o xdrf/libxdrf.a

xdrf2pdb-m: ${data} io_base.o xdrf2pdb-m.o xdrf/libxdrf.a
	${FC} -Bstatic -o ${BINDIR}/xdrf2pdb-m-mult ${data} io_base.o  xdrf2pdb-m.o  xdrf/libxdrf.a

xdrf2x: ${data2} xdrf2x.o xdrf/libxdrf.a
	${FC} -o ${BINDIR}/xdrf2x-mult ${data2} xdrf2x.o xdrf/libxdrf.a

#xdrf2x1: xdrf2x1.o xdrf/libxdrf.a
#	${FC} -o xdrf2x1-mult xdrf2x1.o xdrf/libxdrf.a 

xdrf/libxdrf.a:
	cd xdrf && make

clean:
	rm -f *.o *.mod


names.o: ${DATA_FILE}/names.F90
	${FC} ${FFLAGS} ${CPPFLAGS} ${DATA_FILE}/names.F90

io_units.o: ${DATA_FILE}/io_units.F90
	${FC} ${FFLAGS} ${CPPFLAGS} ${DATA_FILE}/io_units.F90

compare_data.o: ${DATA_FILE}/compare_data.F90
	${FC} ${FFLAGS} ${CPPFLAGS} ${DATA_FILE}/compare_data.F90

energy_data.o: ${DATA_FILE}/energy_data.F90
	${FC} ${FFLAGS} ${CPPFLAGS} ${DATA_FILE}/energy_data.F90

geometry_data.o: ${DATA_FILE}/geometry_data.F90
	${FC} ${FFLAGS} ${CPPFLAGS} ${DATA_FILE}/geometry_data.F90

MD_data.o: ${DATA_FILE}/MD_data.F90
	${FC} ${FFLAGS} ${CPPFLAGS} ${DATA_FILE}/MD_data.F90

io_base.o: ../unres/io_base.F90
	${FC} ${FFLAGS} ${CPPFLAGS} ../unres/io_base.F90
geometry.o: ../unres/geometry.F90
	${FC} ${FFLAGS} ${CPPFLAGS} ../unres/geometry.F90

