changes from prerelease src_CSA_DiL copied to devel
authorCezary Czaplewski <czarek@chem.univ.gda.pl>
Fri, 5 Dec 2014 10:36:00 +0000 (11:36 +0100)
committerCezary Czaplewski <czarek@chem.univ.gda.pl>
Fri, 5 Dec 2014 10:36:00 +0000 (11:36 +0100)
source/unres/src_CSA_DiL/CMakeLists.txt
source/unres/src_CSA_DiL/Makefile
source/unres/src_CSA_DiL/Makefile_MPICH_bluegene [new file with mode: 0644]
source/unres/src_CSA_DiL/Makefile_MPICH_gfortran [new file with mode: 0644]
source/unres/src_CSA_DiL/Makefile_MPICH_ifort [new file with mode: 0644]
source/unres/src_CSA_DiL/csa.F [new file with mode: 0644]
source/unres/src_CSA_DiL/csa.f [deleted file]

index ae64a42..5ce2b00 100644 (file)
@@ -18,7 +18,7 @@ set(UNRES_CSA_DiL_SRC0
        contact.f
        convert.f
        cored.f
-       csa.f
+       csa.F
        dfa.F
        diff12.f
        distfit.f
@@ -73,6 +73,7 @@ set(UNRES_CSA_DiL_PP_SRC
        cartder.F
        chainbuild.F
        checkder_p.F
+       csa.F
        dfa.F
        econstr_local.F
        energy_p_new_barrier.F
@@ -135,19 +136,19 @@ set_property(SOURCE ${UNRES_CSA_DiL_SRC3} PROPERTY COMPILE_FLAGS ${FFLAGS3} )
 #=========================================
 
 if(UNRES_CSA_FF STREQUAL "CASP3" )
-  set(CPPFLAGS "PROCOR -DUNRES -DISNAN -DSPLITELE -DLANG0 -DCRYST_TOR -DCRYST_BOND -DCRYST_THETA -DCRYST_SC -DMOMENT" )
+  set(CPPFLAGS "UNRES -DISNAN -DSPLITELE -DLANG0 -DMOMENT -DCRYST_BOND -DCRYST_THETA -DCRYST_SC -DCRYST_TOR" )
 elseif(UNRES_CSA_FF STREQUAL "ALPHA")
-  set(CPPFLAGS "PROCOR -DUNRES -DISNAN -DSPLITELE -DLANG0 -DMOMENT -DCRYST_BOND -DCRYST_THETA -DCRYST_SC" )
+  set(CPPFLAGS "UNRES -DISNAN -DSPLITELE -DLANG0 -DMOMENT -DCRYST_BOND -DCRYST_THETA -DCRYST_SC" )
 elseif(UNRES_CSA_FF STREQUAL "BETA")
-  set(CPPFLAGS "PROCOR -DUNRES -DISNAN -DSPLITELE -DLANG0 -DMOMENT -DCRYST_BOND -DCRYST_THETA -DCRYST_SC" )
+  set(CPPFLAGS "UNRES -DISNAN -DSPLITELE -DLANG0 -DMOMENT -DCRYST_BOND -DCRYST_THETA -DCRYST_SC" )
 elseif(UNRES_CSA_FF STREQUAL "ALPHABETA")
-  set(CPPFLAGS "PROCOR -DUNRES -DISNAN -DSPLITELE -DLANG0 -DMOMENT -DCRYST_BOND -DCRYST_THETA -DCRYST_SC" )
+  set(CPPFLAGS "UNRES -DISNAN -DSPLITELE -DLANG0 -DMOMENT -DCRYST_BOND -DCRYST_THETA -DCRYST_SC" )
 elseif(UNRES_CSA_FF STREQUAL "CASP5")
-  set(CPPFLAGS "PROCOR -DUNRES -DISNAN -DSPLITELE -DLANG0 -DCRYST_BOND -DCRYST_THETA -DCRYST_SC" )
+  set(CPPFLAGS "UNRES -DISNAN -DSPLITELE -DLANG0 -DMOMENT -DCRYST_BOND -DCRYST_THETA -DCRYST_SC" )
 elseif(UNRES_CSA_FF STREQUAL "3P")
-  set(CPPFLAGS "PROCOR -DUNRES -DISNAN -DSPLITELE -DLANG0 -DCRYST_BOND -DCRYST_THETA -DCRYST_SC" )
+  set(CPPFLAGS "UNRES -DISNAN -DSPLITELE -DLANG0 -DCRYST_BOND -DCRYST_THETA -DCRYST_SC" )
 elseif(UNRES_CSA_FF STREQUAL "4P")
-  set(CPPFLAGS "PROCOR -DUNRES -DISNAN -DSPLITELE -DLANG0 -DCRYST_BOND -DCRYST_THETA -DCRYST_SC" )
+  set(CPPFLAGS "UNRES -DISNAN -DSPLITELE -DLANG0 -DCRYST_BOND -DCRYST_THETA -DCRYST_SC" )
 endif(UNRES_CSA_FF STREQUAL "CASP3")
 
 #=========================================
index def0aff..8453cdd 120000 (symlink)
@@ -1 +1 @@
-Makefile-DFA-NEWPARM.matrix
\ No newline at end of file
+Makefile_MPICH_ifort
\ No newline at end of file
diff --git a/source/unres/src_CSA_DiL/Makefile_MPICH_bluegene b/source/unres/src_CSA_DiL/Makefile_MPICH_bluegene
new file mode 100644 (file)
index 0000000..1575096
--- /dev/null
@@ -0,0 +1,142 @@
+#################################################################################
+FC = mpixlf77
+OPT =  -O4 -qarch=qp -qtune=qp -qnocr
+#OPT =  -O3 -qarch=qp -qtune=qp -qdebug=function_trace
+#OPT =  -O -qarch=qp -qtune=qp
+#OPT = -O0 -C -g -qarch=qp -qtune=qp #-qdebug=function_trace
+#-Minline=name:scalar2,scalar,transpose2,matvec2,prodmat3 \
+#-Mprefetch=distance:8,nta
+
+#OPT1 = -O -g -qarch=qp -qtune=qp
+#OPT1 = -O -g -qarch=qp -qtune=qp -qdebug=function_trace
+OPT1 = ${OPT}
+#OPT2 = -O2 -qarch=qp -qtune=qp
+#OPT2 = -O2 -qarch=qp -qtune=qp -qdebug=function_trace
+OPT2 = ${OPT}
+#OPTE = -O4 -qarch=qp -qtune=qp
+#OPTE = -O4 -qarch=qp -qtune=qp
+OPTE=${OPT}
+
+CFLAGS = -c
+FFLAGS = -c ${OPT} -I$(INSTALL_DIR)/include
+FFLAGS1 = -c ${OPT1} -I$(INSTALL_DIR)/include
+FFLAGS2 = -c ${OPT2} -I$(INSTALL_DIR)/include
+FFLAGSE = -c ${OPTE} -I$(INSTALL_DIR)/include
+
+LIBS = xdrf/libxdrf.a
+
+ARCH = LINUX
+PP = /lib/cpp -P
+
+all: no_option
+       @echo "Specify force field: GAB, E0LL2Y, 4P or CASP3"
+
+.SUFFIXES: .F
+.F.o:
+       ${FC} ${FFLAGS} ${CPPFLAGS} $*.F
+
+
+object = unres_csa.o arcos.o cartprint.o chainbuild.o initialize_p.o \
+        matmult.o readrtns_csa.o parmread.o \
+        pinorm.o randgens.o rescode.o intcor.o timing.o misc.o intlocal.o \
+        cartder.o checkder_p.o econstr_local.o energy_p_new_barrier.o \
+       gradient_p.o minimize_p.o sumsld.o \
+        cored.o rmdd.o geomout_min.o readpdb.o \
+        intcartderiv.o \
+        MP.o printmat.o convert.o int_to_cart.o \
+       dfa.o \
+        together.o csa.o minim_jlee.o shift.o diff12.o bank.o newconf.o ran.o \
+        indexx.o prng_32.o contact.o gen_rand_conf.o \
+        sc_move.o test.o local_move.o rmsd.o fitsq.o elecont.o djacob.o \
+        distfit.o banach.o TMscore_subroutine.o minim_mult.o refsys.o
+
+no_option:
+
+GAB: CPPFLAGS = -DPROCOR -DLINUX -DPGI -DAMD64 -DUNRES -DISNAN -DMP -DMPI \
+       -DSPLITELE -DLANG0 -DCRYST_BOND -DCRYST_THETA -DCRYST_SC
+GAB: BIN = ../../../bin/unres/CSA/unres_csa-DL_xlf77_MPICH_GAB.exe
+LIBS =  -lpthread -L$(INSTALL_DIR)/lib -lmpich
+GAB: ${object}
+       cc -o compinfo compinfo.c
+       ./compinfo | true
+       ${FC} ${FFLAGS} cinfo.f
+       ${FC} ${OPT} ${object} cinfo.o ${LIBS}  -o ${BIN}
+
+E0LL2Y: CPPFLAGS = -DPROCOR -DLINUX -DPGI -DAMD64 -DUNRES -DISNAN -DMP -DMPI \
+       -DSPLITELE -DLANG0
+E0LL2Y: BIN = ../../../bin/unres/CSA/unres_csa-DL_xlf77_MPICH_E0LL2Y.exe
+E0LL2Y: ${object} 
+       cc -o compinfo compinfo.c
+       ./compinfo | true
+       ${FC} ${FFLAGS} cinfo.f
+       ${FC} ${OPT} ${object} cinfo.o ${LIBS}  -o ${BIN}
+
+4P: CPPFLAGS = -DLINUX -DPGI -DISNAN -DMP -DMPI -DUNRES \
+           -DSPLITELE -DAMD64 -DLANG0 \
+           -DCRYST_BOND -DCRYST_THETA -DCRYST_SC 
+4P: BIN = ../../../bin/unres/CSA/unres_csa-DL_xlf77_MPICH_4P.exe
+4P: ${object} 
+       cc -o compinfo compinfo.c
+       ./compinfo | true
+       ${FC} ${FFLAGS} cinfo.f
+       ${FC} ${OPT} ${object} cinfo.o ${LIBS}  -o ${BIN}
+
+clean:
+       /bin/rm -f *.o && /bin/rm -f compinfo 
+
+test.o: test.F
+       ${FC} ${FFLAGS} ${CPPFLAGS} test.F
+
+chainbuild.o: chainbuild.F
+       ${FC} ${FFLAGS} ${CPPFLAGS} chainbuild.F
+
+matmult.o: matmult.f
+       ${FC} ${FFLAGS} ${CPPFLAGS} matmult.f
+
+parmread.o : parmread.F
+       ${FC} ${FFLAGS} ${CPPFLAGS} parmread.F
+
+intcor.o : intcor.f
+       ${FC} ${FFLAGS} ${CPPFLAGS} intcor.f
+
+cartder.o : cartder.F
+       ${FC} ${FFLAGS} ${CPPFLAGS} cartder.F
+
+readpdb.o : readpdb.F
+       ${FC} ${FFLAGS2} ${CPPFLAGS} readpdb.F
+
+sumsld.o : sumsld.f
+       ${FC} ${FFLAGS} ${CPPFLAGS} sumsld.f
+        
+cored.o : cored.f
+       ${FC} ${FFLAGS1} ${CPPFLAGS} cored.f
+rmdd.o : rmdd.f
+       ${FC} ${FFLAGS} ${CPPFLAGS} rmdd.f
+
+energy_p_new_barrier.o : energy_p_new_barrier.F
+       ${FC} ${FFLAGSE} ${CPPFLAGS} energy_p_new_barrier.F
+
+gradient_p.o : gradient_p.F
+       ${FC} ${FFLAGSE} ${CPPFLAGS} gradient_p.F
+
+energy_p_new-sep_barrier.o : energy_p_new-sep_barrier.F
+       ${FC} ${FFLAGSE} ${CPPFLAGS} energy_p_new-sep_barrier.F
+
+lagrangian_lesyng.o : lagrangian_lesyng.F
+       ${FC} ${FFLAGSE} ${CPPFLAGS} lagrangian_lesyng.F
+
+MD_A-MTS.o : MD_A-MTS.F
+       ${FC} ${FFLAGSE} ${CPPFLAGS} MD_A-MTS.F
+
+blas.o : blas.f
+       ${FC} ${FFLAGS1} blas.f
+
+add.o : add.f
+       ${FC} ${FFLAGS1} add.f
+
+eigen.o : eigen.f
+       ${FC} ${FFLAGS2} eigen.f
+
+proc_proc.o: proc_proc.c
+       ${CC} ${CFLAGS} proc_proc.c
diff --git a/source/unres/src_CSA_DiL/Makefile_MPICH_gfortran b/source/unres/src_CSA_DiL/Makefile_MPICH_gfortran
new file mode 100644 (file)
index 0000000..c6cca6c
--- /dev/null
@@ -0,0 +1,130 @@
+###################################################################
+INSTALL_DIR = /users/software/mpich2-1.0.7
+
+FC= gfortran
+
+OPT =  -O
+
+FFLAGS = -c ${OPT} -I$(INSTALL_DIR)/include 
+FFLAGS1 = -c -I$(INSTALL_DIR)/include 
+FFLAGS2 = -c -O0 -I$(INSTALL_DIR)/include  
+FFLAGS3 = -c -O -I$(INSTALL_DIR)/include  
+FFLAGSE = -c -O3 -I$(INSTALL_DIR)/include
+
+LIBS = -L$(INSTALL_DIR)/lib -lmpich -lpthread
+
+ARCH = LINUX
+PP = /lib/cpp -P
+
+
+all: no_option
+       @echo "Specify force field: GAB, E0LL2Y, 4P or CASP3"
+
+.SUFFIXES: .F
+.F.o:
+       ${FC} ${FFLAGS} ${CPPFLAGS} $*.F
+
+
+object = unres_csa.o arcos.o cartprint.o chainbuild.o initialize_p.o \
+        matmult.o readrtns_csa.o parmread.o \
+        pinorm.o randgens.o rescode.o intcor.o timing.o misc.o intlocal.o \
+        cartder.o checkder_p.o econstr_local.o energy_p_new_barrier.o \
+       gradient_p.o minimize_p.o sumsld.o \
+        cored.o rmdd.o geomout_min.o readpdb.o \
+        intcartderiv.o \
+        MP.o printmat.o convert.o int_to_cart.o \
+       dfa.o \
+        together.o csa.o minim_jlee.o shift.o diff12.o bank.o newconf.o ran.o \
+        indexx.o prng_32.o contact.o gen_rand_conf.o \
+        sc_move.o test.o local_move.o rmsd.o fitsq.o elecont.o djacob.o \
+        distfit.o banach.o TMscore_subroutine.o minim_mult.o refsys.o
+
+no_option:
+
+GAB: CPPFLAGS = -DPROCOR -DLINUX -DG77 -DAMD64 -DUNRES -DISNAN -DMP -DMPI \
+       -DSPLITELE -DLANG0 -DCRYST_BOND -DCRYST_THETA -DCRYST_SC
+GAB: BIN = ../../../bin/unres/CSA/unres_csa-DL_gfort_MPICH_GAB.exe
+GAB: ${object}
+       cc -o compinfo compinfo.c
+       ./compinfo | true
+       ${FC} ${FFLAGS} cinfo.f
+       ${FC} ${OPT} ${object} cinfo.o ${LIBS}  -o ${BIN}
+
+E0LL2Y: CPPFLAGS = -DPROCOR -DLINUX -DG77 -DAMD64 -DUNRES -DISNAN -DMP -DMPI \
+       -DSPLITELE -DLANG0
+E0LL2Y: BIN = ../../../bin/unres/CSA/unres_csa-DL_gfort_MPICH_E0LL2Y.exe
+E0LL2Y: ${object} 
+       cc -o compinfo compinfo.c
+       ./compinfo | true
+       ${FC} ${FFLAGS} cinfo.f
+       ${FC} ${OPT} ${object} cinfo.o ${LIBS}  -o ${BIN}
+
+4P: CPPFLAGS = -DLINUX -DG77 -DISNAN -DMP -DMPI -DUNRES \
+           -DSPLITELE -DAMD64 -DLANG0 \
+           -DCRYST_BOND -DCRYST_THETA -DCRYST_SC 
+4P: BIN = ../../../bin/unres/CSA/unres_csa-DL_gfort_MPICH_4P.exe
+4P: ${object} 
+       cc -o compinfo compinfo.c
+       ./compinfo | true
+       ${FC} ${FFLAGS} cinfo.f
+       ${FC} ${OPT} ${object} cinfo.o ${LIBS}  -o ${BIN}
+
+clean:
+       /bin/rm -f *.o && /bin/rm -f compinfo 
+
+test.o: test.F
+       ${FC} ${FFLAGS} ${CPPFLAGS} test.F
+
+chainbuild.o: chainbuild.F
+       ${FC} ${FFLAGS} ${CPPFLAGS} chainbuild.F
+
+matmult.o: matmult.f
+       ${FC} ${FFLAGS} ${CPPFLAGS} matmult.f
+
+parmread.o : parmread.F
+       ${FC} ${FFLAGS} ${CPPFLAGS} parmread.F
+
+intcor.o : intcor.f
+       ${FC} ${FFLAGS} ${CPPFLAGS} intcor.f
+
+cartder.o : cartder.F
+       ${FC} ${FFLAGS} ${CPPFLAGS} cartder.F
+
+readpdb.o : readpdb.F
+       ${FC} ${FFLAGS2} ${CPPFLAGS} readpdb.F
+
+sumsld.o : sumsld.f
+       ${FC} ${FFLAGS} ${CPPFLAGS} sumsld.f
+        
+cored.o : cored.f
+       ${FC} ${FFLAGS1} ${CPPFLAGS} cored.f
+rmdd.o : rmdd.f
+       ${FC} ${FFLAGS} ${CPPFLAGS} rmdd.f
+
+energy_p_new_barrier.o : energy_p_new_barrier.F
+       ${FC} ${FFLAGSE} ${CPPFLAGS} energy_p_new_barrier.F
+
+gradient_p.o : gradient_p.F
+       ${FC} ${FFLAGSE} ${CPPFLAGS} gradient_p.F
+
+energy_p_new-sep_barrier.o : energy_p_new-sep_barrier.F
+       ${FC} ${FFLAGSE} ${CPPFLAGS} energy_p_new-sep_barrier.F
+
+lagrangian_lesyng.o : lagrangian_lesyng.F
+       ${FC} ${FFLAGSE} ${CPPFLAGS} lagrangian_lesyng.F
+
+MD_A-MTS.o : MD_A-MTS.F
+       ${FC} ${FFLAGSE} ${CPPFLAGS} MD_A-MTS.F
+
+blas.o : blas.f
+       ${FC} ${FFLAGS1} blas.f
+
+add.o : add.f
+       ${FC} ${FFLAGS1} add.f
+
+eigen.o : eigen.f
+       ${FC} ${FFLAGS2} eigen.f
+
+proc_proc.o: proc_proc.c
+       ${CC} ${CFLAGS} proc_proc.c
diff --git a/source/unres/src_CSA_DiL/Makefile_MPICH_ifort b/source/unres/src_CSA_DiL/Makefile_MPICH_ifort
new file mode 100644 (file)
index 0000000..7e2c69c
--- /dev/null
@@ -0,0 +1,132 @@
+###################################################################
+INSTALL_DIR = /users/software/mpich-1.2.7p1_intel-10.1_em64_ssh
+
+
+FC= ifort
+
+OPT =  -O3 -ip 
+
+FFLAGS = -c ${OPT} -I$(INSTALL_DIR)/include 
+FFLAGS1 = -c  -g -CA -CB -I$(INSTALL_DIR)/include 
+FFLAGS2 = -c  -g -O0 -I$(INSTALL_DIR)/include  
+FFLAGSE = -c  -O3 -ipo  -opt_report -I$(INSTALL_DIR)/include
+
+
+LIBS = -L$(INSTALL_DIR)/lib -lmpich 
+
+ARCH = LINUX
+PP = /lib/cpp -P
+
+
+all: no_option
+       @echo "Specify force field: GAB, E0LL2Y, 4P or CASP3"
+
+.SUFFIXES: .F
+.F.o:
+       ${FC} ${FFLAGS} ${CPPFLAGS} $*.F
+
+
+object = unres_csa.o arcos.o cartprint.o chainbuild.o initialize_p.o \
+        matmult.o readrtns_csa.o parmread.o \
+        pinorm.o randgens.o rescode.o intcor.o timing.o misc.o intlocal.o \
+        cartder.o checkder_p.o econstr_local.o energy_p_new_barrier.o \
+       gradient_p.o minimize_p.o sumsld.o \
+        cored.o rmdd.o geomout_min.o readpdb.o \
+        intcartderiv.o \
+        MP.o printmat.o convert.o int_to_cart.o \
+       dfa.o \
+        together.o csa.o minim_jlee.o shift.o diff12.o bank.o newconf.o ran.o \
+        indexx.o prng_32.o contact.o gen_rand_conf.o \
+        sc_move.o test.o local_move.o rmsd.o fitsq.o elecont.o djacob.o \
+        distfit.o banach.o TMscore_subroutine.o minim_mult.o refsys.o
+
+no_option:
+
+GAB: CPPFLAGS = -DPROCOR -DLINUX -DPGI -DAMD64 -DUNRES -DISNAN -DMP -DMPI \
+       -DSPLITELE -DLANG0 -DCRYST_BOND -DCRYST_THETA -DCRYST_SC
+GAB: BIN = ../../../bin/unres/CSA/unres_csa-DL_ifort_MPICH_GAB.exe
+LIBS =  -lpthread -L$(INSTALL_DIR)/lib -lmpich
+GAB: ${object}
+       cc -o compinfo compinfo.c
+       ./compinfo | true
+       ${FC} ${FFLAGS} cinfo.f
+       ${FC} ${OPT} ${object} cinfo.o ${LIBS}  -o ${BIN}
+
+E0LL2Y: CPPFLAGS = -DPROCOR -DLINUX -DPGI -DAMD64 -DUNRES -DISNAN -DMP -DMPI \
+       -DSPLITELE -DLANG0
+E0LL2Y: BIN = ../../../bin/unres/CSA/unres_csa-DL_ifort_MPICH_E0LL2Y.exe
+E0LL2Y: ${object} 
+       cc -o compinfo compinfo.c
+       ./compinfo | true
+       ${FC} ${FFLAGS} cinfo.f
+       ${FC} ${OPT} ${object} cinfo.o ${LIBS}  -o ${BIN}
+
+4P: CPPFLAGS = -DLINUX -DPGI -DISNAN -DMP -DMPI -DUNRES \
+           -DSPLITELE -DAMD64 -DLANG0 \
+           -DCRYST_BOND -DCRYST_THETA -DCRYST_SC 
+4P: BIN = ../../../bin/unres/CSA/unres_csa-DL_ifort_MPICH_4P.exe
+4P: ${object} 
+       cc -o compinfo compinfo.c
+       ./compinfo | true
+       ${FC} ${FFLAGS} cinfo.f
+       ${FC} ${OPT} ${object} cinfo.o ${LIBS}  -o ${BIN}
+
+clean:
+       /bin/rm -f *.o && /bin/rm -f compinfo 
+
+test.o: test.F
+       ${FC} ${FFLAGS} ${CPPFLAGS} test.F
+
+chainbuild.o: chainbuild.F
+       ${FC} ${FFLAGS} ${CPPFLAGS} chainbuild.F
+
+matmult.o: matmult.f
+       ${FC} ${FFLAGS} ${CPPFLAGS} matmult.f
+
+parmread.o : parmread.F
+       ${FC} ${FFLAGS} ${CPPFLAGS} parmread.F
+
+intcor.o : intcor.f
+       ${FC} ${FFLAGS} ${CPPFLAGS} intcor.f
+
+cartder.o : cartder.F
+       ${FC} ${FFLAGS} ${CPPFLAGS} cartder.F
+
+readpdb.o : readpdb.F
+       ${FC} ${FFLAGS2} ${CPPFLAGS} readpdb.F
+
+sumsld.o : sumsld.f
+       ${FC} ${FFLAGS} ${CPPFLAGS} sumsld.f
+        
+cored.o : cored.f
+       ${FC} ${FFLAGS1} ${CPPFLAGS} cored.f
+rmdd.o : rmdd.f
+       ${FC} ${FFLAGS} ${CPPFLAGS} rmdd.f
+
+energy_p_new_barrier.o : energy_p_new_barrier.F
+       ${FC} ${FFLAGSE} ${CPPFLAGS} energy_p_new_barrier.F
+
+gradient_p.o : gradient_p.F
+       ${FC} ${FFLAGSE} ${CPPFLAGS} gradient_p.F
+
+energy_p_new-sep_barrier.o : energy_p_new-sep_barrier.F
+       ${FC} ${FFLAGSE} ${CPPFLAGS} energy_p_new-sep_barrier.F
+
+lagrangian_lesyng.o : lagrangian_lesyng.F
+       ${FC} ${FFLAGSE} ${CPPFLAGS} lagrangian_lesyng.F
+
+MD_A-MTS.o : MD_A-MTS.F
+       ${FC} ${FFLAGSE} ${CPPFLAGS} MD_A-MTS.F
+
+blas.o : blas.f
+       ${FC} ${FFLAGS1} blas.f
+
+add.o : add.f
+       ${FC} ${FFLAGS1} add.f
+
+eigen.o : eigen.f
+       ${FC} ${FFLAGS2} eigen.f
+
+proc_proc.o: proc_proc.c
+       ${CC} ${CFLAGS} proc_proc.c
diff --git a/source/unres/src_CSA_DiL/csa.F b/source/unres/src_CSA_DiL/csa.F
new file mode 100644 (file)
index 0000000..a5149f2
--- /dev/null
@@ -0,0 +1,366 @@
+      subroutine make_array
+      implicit real*8 (a-h,o-z)
+      include 'DIMENSIONS'
+      include 'COMMON.IOUNITS'
+      include 'COMMON.CHAIN'
+      include 'COMMON.INTERACT'
+      include 'COMMON.CSA'
+
+ccccccccccccccccccccccccc
+c Level-2: group
+ccccccccccccccccccccccccc
+
+      indg=0
+      do k=1,numch
+ccccccccccccccccccccccccccccccccccccccccc
+! Groups the THETAs and the GAMMAs
+       do j=2,nres-1
+         indg=indg+1
+         if (j.lt.nres-1) then
+           ngroup(indg)=2
+         else
+           ngroup(indg)=1
+         endif
+         do i=1,ngroup(indg)
+          igroup(1,i,indg)=i
+          igroup(2,i,indg)=j
+          igroup(3,i,indg)=k
+         enddo
+       enddo
+ccccccccccccccccccccccccccccccccccccccccc
+      enddo
+! Groups the ALPHAs and the BETAs
+      do k=1,numch
+       do j=2,nres-1
+        if(itype(j).ne.10) then
+         indg=indg+1
+         ngroup(indg)=2
+         do i=1,ngroup(indg)
+          igroup(1,i,indg)=i+2
+          igroup(2,i,indg)=j
+          igroup(3,i,indg)=k
+         enddo
+        endif
+       enddo
+      enddo
+
+      ntotgr=indg
+      write(iout,*) 
+      write(iout,*) "# of groups: ",ntotgr
+      do i=1,ntotgr
+       write(iout,41) i,ngroup(i),((igroup(k,j,i),k=1,3),j=1,ngroup(i))
+      enddo
+!      close(iout)
+
+   40 format(i3,3x,3i3)
+   41 format(2i3,3x,6(3i3,2x))
+
+      return
+      end
+ccccccccccccccccccccccccccccccccccccccccccccccccc
+ccccccccccccccccccccccccccccccccccccccccccccccccc
+      subroutine make_ranvar(n,m,idum)
+      implicit real*8 (a-h,o-z)
+      include 'DIMENSIONS'
+      include 'COMMON.IOUNITS'
+      include 'COMMON.CHAIN'
+      include 'COMMON.VAR'
+      include 'COMMON.BANK'
+c al      m=0
+      print *,'HOHOHOHO Make_RanVar!!!!!',n,m
+      itrial=0
+      do while(m.lt.n .and. itrial.le.10000)
+        itrial=itrial+1
+        jeden=1
+        call gen_rand_conf(jeden,*10)
+        call intout
+        m=m+1
+        do j=2,nres-1
+          dihang_in(1,j,1,m)=theta(j+1)
+          dihang_in(2,j,1,m)=phi(j+2)
+          dihang_in(3,j,1,m)=alph(j)
+          dihang_in(4,j,1,m)=omeg(j)
+        enddo  
+        dihang_in(2,nres-1,1,m)=0.0d0
+        goto 20
+  10    write (iout,*) 'Failed to generate conformation #',m+1,
+     &   ' itrial=',itrial
+  20    continue
+      enddo
+      print *,'Make_RanVar!!!!! m=',m,' itrial=',itrial
+
+      return
+      end
+ccccccccccccccccccccccccccccccccccccccccccccccccc
+ccccccccccccccccccccccccccccccccccccccccccccccccc
+      subroutine make_ranvar_reg(n,idum)
+      implicit real*8 (a-h,o-z)
+      include 'DIMENSIONS'
+      include 'COMMON.IOUNITS'
+      include 'COMMON.CHAIN'
+      include 'COMMON.VAR'
+      include 'COMMON.BANK'
+      include 'COMMON.GEO'
+      m=0
+      print *,'HOHOHOHO Make_RanVar_reg!!!!!'
+      itrial=0
+      do while(m.lt.n .and. itrial.le.10000)
+        itrial=itrial+1
+        jeden=1
+        call gen_rand_conf(jeden,*10)
+!        call intout
+        m=m+1
+        do j=2,nres-1
+          dihang_in(1,j,1,m)=theta(j+1)
+          dihang_in(2,j,1,m)=phi(j+2)
+          dihang_in(3,j,1,m)=alph(j)
+          dihang_in(4,j,1,m)=omeg(j)
+          if(m.le.n*0.1) then
+           dihang_in(1,j,1,m)=90.0*deg2rad
+           dihang_in(2,j,1,m)=50.0*deg2rad
+          endif
+        enddo  
+        dihang_in(2,nres-1,1,m)=0.0d0
+        goto 20
+  10    write (iout,*) 'Failed to generate conformation #',m+1,
+     &   ' itrial=',itrial
+  20    continue
+      enddo
+      print *,'Make_RanVar!!!!! m=',m,' itrial=',itrial
+
+      return
+      end
+ccccccccccccccccccccccccccccccccccccccccccccccccc
+ccccccccccccccccccccccccccccccccccccccccccccccccc
+      subroutine from_pdb(n,idum)
+c This subroutine stores the UNRES int variables generated from 
+c subroutine readpdb into the 1st conformation of in dihang_in.
+c Subsequent n-1 conformations of dihang_in have identical values
+c of theta and phi as the 1st conformation but random values for
+c alph and omeg.
+c The array cref (also generated from subroutine readpdb) is stored
+c to crefjlee to be used for rmsd calculation in CSA, if necessary.
+      implicit real*8 (a-h,o-z)
+      include 'DIMENSIONS'
+      include 'COMMON.IOUNITS'
+      include 'COMMON.CHAIN'
+      include 'COMMON.VAR'
+      include 'COMMON.BANK'
+      include 'COMMON.GEO'
+
+      m=1
+      do j=2,nres-1
+        dihang_in(1,j,1,m)=theta(j+1)
+        dihang_in(2,j,1,m)=phi(j+2)
+        dihang_in(3,j,1,m)=alph(j)
+        dihang_in(4,j,1,m)=omeg(j)
+      enddo
+      dihang_in(2,nres-1,1,k)=0.0d0
+
+      do m=2,n
+       do k=2,nres-1
+        dihang_in(1,k,1,m)=dihang_in(1,k,1,1)
+        dihang_in(2,k,1,m)=dihang_in(2,k,1,1)
+        if(dabs(dihang_in(3,k,1,1)).gt.1.d-6) then
+         dihang_in(3,k,1,m)=90.d0*ran1(idum)+90.d0
+         dihang_in(3,k,1,m)=dihang_in(3,k,1,m)*deg2rad
+        endif
+        if(dabs(dihang_in(4,k,1,1)).gt.1.d-6) then
+         dihang_in(4,k,1,m)=360.d0*ran1(idum)-180.d0
+         dihang_in(4,k,1,m)=dihang_in(4,k,1,m)*deg2rad
+        endif
+       enddo
+      enddo
+
+c Store cref to crefjlee (they are in COMMON.CHAIN).
+      do k=1,2*nres
+       do kk=1,3
+        crefjlee(kk,k)=cref(kk,k)
+       enddo
+      enddo
+
+      open(icsa_native_int,file=csa_native_int,status="old")
+      do m=1,n
+        write(icsa_native_int,*) m,e
+         write(icsa_native_int,200) 
+     &    (dihang_in(1,k,1,m)*rad2deg,k=2,nres-1)
+         write(icsa_native_int,200) 
+     &    (dihang_in(2,k,1,m)*rad2deg,k=2,nres-2)
+         write(icsa_native_int,200) 
+     &    (dihang_in(3,k,1,m)*rad2deg,k=2,nres-1)
+         write(icsa_native_int,200) 
+     &    (dihang_in(4,k,1,m)*rad2deg,k=2,nres-1)
+      enddo
+
+      do k=1,nres
+       write(icsa_native_int,200) (crefjlee(i,k),i=1,3)
+      enddo
+      close(icsa_native_int)
+
+  200 format (8f10.4)
+
+      return
+      end
+ccccccccccccccccccccccccccccccccccccccccccccccccc
+ccccccccccccccccccccccccccccccccccccccccccccccccc
+      subroutine from_int(n,mm,idum)
+      implicit real*8 (a-h,o-z)
+      include 'DIMENSIONS'
+      include 'COMMON.IOUNITS'
+      include 'COMMON.CHAIN'
+      include 'COMMON.VAR'
+      include 'COMMON.INTERACT'
+      include 'COMMON.BANK'
+      include 'COMMON.GEO'
+      include 'COMMON.CONTACTS'
+#ifdef MOMENT
+      include 'COMMON.CONTACTS.MOMENT'
+#endif 
+      integer ilen
+      external ilen
+      logical fail
+      double precision energia(0:n_ene)
+
+      open(icsa_native_int,file=csa_native_int,status="old")
+      read (icsa_native_int,*)
+      call read_angles(icsa_native_int,*10)
+      goto 11
+   10 write (iout,'(2a)') "CHUJ NASTAPIL - error in ",
+     &  csa_native_int(:ilen(csa_native_int))
+   11 continue
+      call intout
+      do j=2,nres-1
+        dihang_in(1,j,1,1)=theta(j+1)
+        dihang_in(2,j,1,1)=phi(j+2)
+        dihang_in(3,j,1,1)=alph(j)
+        dihang_in(4,j,1,1)=omeg(j)
+      enddo
+      dihang_in(2,nres-1,1,1)=0.0d0
+
+c         read(icsa_native_int,*) ind,e
+c         read(icsa_native_int,200) (dihang_in(1,k,1,1),k=2,nres-1)
+c         read(icsa_native_int,200) (dihang_in(2,k,1,1),k=2,nres-2)
+c         read(icsa_native_int,200) (dihang_in(3,k,1,1),k=2,nres-1)
+c         read(icsa_native_int,200) (dihang_in(4,k,1,1),k=2,nres-1)
+c         dihang_in(2,nres-1,1,1)=0.d0
+
+         maxsi=100
+         maxcount_fail=100
+
+         do m=mm+2,n
+c          do k=2,nres-1
+c           dihang_in(1,k,1,m)=dihang_in(1,k,1,1)
+c           dihang_in(2,k,1,m)=dihang_in(2,k,1,1)
+c           if(abs(dihang_in(3,k,1,1)).gt.1.d-3) then
+c            dihang_in(3,k,1,m)=90.d0*ran1(idum)+90.d0
+c           endif
+c           if(abs(dihang_in(4,k,1,1)).gt.1.d-3) then
+c            dihang_in(4,k,1,m)=360.d0*ran1(idum)-180.d0
+c           endif
+c          enddo
+c           call intout
+           fail=.true.
+
+           icount_fail=0
+
+           DO WHILE (FAIL .AND. ICOUNT_FAIL .LE. MAXCOUNT_FAIL)
+
+           do i=nnt,nct
+             if (itype(i).ne.10) then
+cd             print *,'i=',i,' itype=',itype(i),' theta=',theta(i+1)
+               fail=.true.
+               ii=0
+               do while (fail .and. ii .le. maxsi)
+                 call gen_side(itype(i),theta(i+1),alph(i),omeg(i),fail)
+                 ii = ii+1
+               enddo
+             endif
+           enddo
+           call chainbuild
+           call etotal(energia(0))
+           fail = (energia(0).ge.1.0d20)
+           icount_fail=icount_fail+1
+
+           ENDDO
+
+           if (icount_fail.gt.maxcount_fail) then
+             write (iout,*) 
+     &       'Failed to generate non-overlaping near-native conf.',
+     &       m
+           endif
+
+           do j=2,nres-1
+             dihang_in(1,j,1,m)=theta(j+1)
+             dihang_in(2,j,1,m)=phi(j+2)
+             dihang_in(3,j,1,m)=alph(j)
+             dihang_in(4,j,1,m)=omeg(j)
+           enddo
+           dihang_in(2,nres-1,1,m)=0.0d0
+         enddo
+
+c      do m=1,n
+c       write(icsa_native_int,*) m,e
+c         write(icsa_native_int,200) (dihang_in(1,k,1,m),k=2,nres-1)
+c         write(icsa_native_int,200) (dihang_in(2,k,1,m),k=2,nres-2)
+c         write(icsa_native_int,200) (dihang_in(3,k,1,m),k=2,nres-1)
+c         write(icsa_native_int,200) (dihang_in(4,k,1,m),k=2,nres-1)
+c      enddo
+c     close(icsa_native_int)
+
+c      do m=mm+2,n
+c       do i=1,4
+c        do j=2,nres-1
+c         dihang_in(i,j,1,m)=dihang_in(i,j,1,m)*deg2rad
+c        enddo
+c       enddo
+c      enddo
+
+      call dihang_to_c(dihang_in(1,1,1,1))
+
+c Store c to cref (they are in COMMON.CHAIN).
+      do k=1,2*nres
+       do kk=1,3
+        crefjlee(kk,k)=c(kk,k)
+       enddo
+      enddo
+
+      call contact(.true.,ncont_ref,icont_ref,co)
+
+c      do k=1,nres
+c       write(icsa_native_int,200) (crefjlee(i,k),i=1,3)
+c      enddo
+      close(icsa_native_int)
+
+  200 format (8f10.4)
+
+      return
+      end
+ccccccccccccccccccccccccccccccccccccccccccccccccc
+ccccccccccccccccccccccccccccccccccccccccccccccccc
+      subroutine dihang_to_c(aarray)
+      implicit real*8 (a-h,o-z)
+      include 'DIMENSIONS'
+      include 'COMMON.CSA'
+      include 'COMMON.BANK'
+      include 'COMMON.CHAIN'
+      include 'COMMON.GEO'
+      include 'COMMON.VAR'
+
+      dimension aarray(mxang,maxres,mxch)
+
+c     do i=4,nres
+c      phi(i)=dihang_in(1,i-2,1,1)
+c     enddo
+      do i=2,nres-1
+       theta(i+1)=aarray(1,i,1)
+       phi(i+2)=aarray(2,i,1)
+       alph(i)=aarray(3,i,1)
+       omeg(i)=aarray(4,i,1)
+      enddo
+
+      call chainbuild
+
+      return
+      end
+ccccccccccccccccccccccccccccccccccccccccccccccccc
+ccccccccccccccccccccccccccccccccccccccccccccccccc
diff --git a/source/unres/src_CSA_DiL/csa.f b/source/unres/src_CSA_DiL/csa.f
deleted file mode 100644 (file)
index a5149f2..0000000
+++ /dev/null
@@ -1,366 +0,0 @@
-      subroutine make_array
-      implicit real*8 (a-h,o-z)
-      include 'DIMENSIONS'
-      include 'COMMON.IOUNITS'
-      include 'COMMON.CHAIN'
-      include 'COMMON.INTERACT'
-      include 'COMMON.CSA'
-
-ccccccccccccccccccccccccc
-c Level-2: group
-ccccccccccccccccccccccccc
-
-      indg=0
-      do k=1,numch
-ccccccccccccccccccccccccccccccccccccccccc
-! Groups the THETAs and the GAMMAs
-       do j=2,nres-1
-         indg=indg+1
-         if (j.lt.nres-1) then
-           ngroup(indg)=2
-         else
-           ngroup(indg)=1
-         endif
-         do i=1,ngroup(indg)
-          igroup(1,i,indg)=i
-          igroup(2,i,indg)=j
-          igroup(3,i,indg)=k
-         enddo
-       enddo
-ccccccccccccccccccccccccccccccccccccccccc
-      enddo
-! Groups the ALPHAs and the BETAs
-      do k=1,numch
-       do j=2,nres-1
-        if(itype(j).ne.10) then
-         indg=indg+1
-         ngroup(indg)=2
-         do i=1,ngroup(indg)
-          igroup(1,i,indg)=i+2
-          igroup(2,i,indg)=j
-          igroup(3,i,indg)=k
-         enddo
-        endif
-       enddo
-      enddo
-
-      ntotgr=indg
-      write(iout,*) 
-      write(iout,*) "# of groups: ",ntotgr
-      do i=1,ntotgr
-       write(iout,41) i,ngroup(i),((igroup(k,j,i),k=1,3),j=1,ngroup(i))
-      enddo
-!      close(iout)
-
-   40 format(i3,3x,3i3)
-   41 format(2i3,3x,6(3i3,2x))
-
-      return
-      end
-ccccccccccccccccccccccccccccccccccccccccccccccccc
-ccccccccccccccccccccccccccccccccccccccccccccccccc
-      subroutine make_ranvar(n,m,idum)
-      implicit real*8 (a-h,o-z)
-      include 'DIMENSIONS'
-      include 'COMMON.IOUNITS'
-      include 'COMMON.CHAIN'
-      include 'COMMON.VAR'
-      include 'COMMON.BANK'
-c al      m=0
-      print *,'HOHOHOHO Make_RanVar!!!!!',n,m
-      itrial=0
-      do while(m.lt.n .and. itrial.le.10000)
-        itrial=itrial+1
-        jeden=1
-        call gen_rand_conf(jeden,*10)
-        call intout
-        m=m+1
-        do j=2,nres-1
-          dihang_in(1,j,1,m)=theta(j+1)
-          dihang_in(2,j,1,m)=phi(j+2)
-          dihang_in(3,j,1,m)=alph(j)
-          dihang_in(4,j,1,m)=omeg(j)
-        enddo  
-        dihang_in(2,nres-1,1,m)=0.0d0
-        goto 20
-  10    write (iout,*) 'Failed to generate conformation #',m+1,
-     &   ' itrial=',itrial
-  20    continue
-      enddo
-      print *,'Make_RanVar!!!!! m=',m,' itrial=',itrial
-
-      return
-      end
-ccccccccccccccccccccccccccccccccccccccccccccccccc
-ccccccccccccccccccccccccccccccccccccccccccccccccc
-      subroutine make_ranvar_reg(n,idum)
-      implicit real*8 (a-h,o-z)
-      include 'DIMENSIONS'
-      include 'COMMON.IOUNITS'
-      include 'COMMON.CHAIN'
-      include 'COMMON.VAR'
-      include 'COMMON.BANK'
-      include 'COMMON.GEO'
-      m=0
-      print *,'HOHOHOHO Make_RanVar_reg!!!!!'
-      itrial=0
-      do while(m.lt.n .and. itrial.le.10000)
-        itrial=itrial+1
-        jeden=1
-        call gen_rand_conf(jeden,*10)
-!        call intout
-        m=m+1
-        do j=2,nres-1
-          dihang_in(1,j,1,m)=theta(j+1)
-          dihang_in(2,j,1,m)=phi(j+2)
-          dihang_in(3,j,1,m)=alph(j)
-          dihang_in(4,j,1,m)=omeg(j)
-          if(m.le.n*0.1) then
-           dihang_in(1,j,1,m)=90.0*deg2rad
-           dihang_in(2,j,1,m)=50.0*deg2rad
-          endif
-        enddo  
-        dihang_in(2,nres-1,1,m)=0.0d0
-        goto 20
-  10    write (iout,*) 'Failed to generate conformation #',m+1,
-     &   ' itrial=',itrial
-  20    continue
-      enddo
-      print *,'Make_RanVar!!!!! m=',m,' itrial=',itrial
-
-      return
-      end
-ccccccccccccccccccccccccccccccccccccccccccccccccc
-ccccccccccccccccccccccccccccccccccccccccccccccccc
-      subroutine from_pdb(n,idum)
-c This subroutine stores the UNRES int variables generated from 
-c subroutine readpdb into the 1st conformation of in dihang_in.
-c Subsequent n-1 conformations of dihang_in have identical values
-c of theta and phi as the 1st conformation but random values for
-c alph and omeg.
-c The array cref (also generated from subroutine readpdb) is stored
-c to crefjlee to be used for rmsd calculation in CSA, if necessary.
-      implicit real*8 (a-h,o-z)
-      include 'DIMENSIONS'
-      include 'COMMON.IOUNITS'
-      include 'COMMON.CHAIN'
-      include 'COMMON.VAR'
-      include 'COMMON.BANK'
-      include 'COMMON.GEO'
-
-      m=1
-      do j=2,nres-1
-        dihang_in(1,j,1,m)=theta(j+1)
-        dihang_in(2,j,1,m)=phi(j+2)
-        dihang_in(3,j,1,m)=alph(j)
-        dihang_in(4,j,1,m)=omeg(j)
-      enddo
-      dihang_in(2,nres-1,1,k)=0.0d0
-
-      do m=2,n
-       do k=2,nres-1
-        dihang_in(1,k,1,m)=dihang_in(1,k,1,1)
-        dihang_in(2,k,1,m)=dihang_in(2,k,1,1)
-        if(dabs(dihang_in(3,k,1,1)).gt.1.d-6) then
-         dihang_in(3,k,1,m)=90.d0*ran1(idum)+90.d0
-         dihang_in(3,k,1,m)=dihang_in(3,k,1,m)*deg2rad
-        endif
-        if(dabs(dihang_in(4,k,1,1)).gt.1.d-6) then
-         dihang_in(4,k,1,m)=360.d0*ran1(idum)-180.d0
-         dihang_in(4,k,1,m)=dihang_in(4,k,1,m)*deg2rad
-        endif
-       enddo
-      enddo
-
-c Store cref to crefjlee (they are in COMMON.CHAIN).
-      do k=1,2*nres
-       do kk=1,3
-        crefjlee(kk,k)=cref(kk,k)
-       enddo
-      enddo
-
-      open(icsa_native_int,file=csa_native_int,status="old")
-      do m=1,n
-        write(icsa_native_int,*) m,e
-         write(icsa_native_int,200) 
-     &    (dihang_in(1,k,1,m)*rad2deg,k=2,nres-1)
-         write(icsa_native_int,200) 
-     &    (dihang_in(2,k,1,m)*rad2deg,k=2,nres-2)
-         write(icsa_native_int,200) 
-     &    (dihang_in(3,k,1,m)*rad2deg,k=2,nres-1)
-         write(icsa_native_int,200) 
-     &    (dihang_in(4,k,1,m)*rad2deg,k=2,nres-1)
-      enddo
-
-      do k=1,nres
-       write(icsa_native_int,200) (crefjlee(i,k),i=1,3)
-      enddo
-      close(icsa_native_int)
-
-  200 format (8f10.4)
-
-      return
-      end
-ccccccccccccccccccccccccccccccccccccccccccccccccc
-ccccccccccccccccccccccccccccccccccccccccccccccccc
-      subroutine from_int(n,mm,idum)
-      implicit real*8 (a-h,o-z)
-      include 'DIMENSIONS'
-      include 'COMMON.IOUNITS'
-      include 'COMMON.CHAIN'
-      include 'COMMON.VAR'
-      include 'COMMON.INTERACT'
-      include 'COMMON.BANK'
-      include 'COMMON.GEO'
-      include 'COMMON.CONTACTS'
-#ifdef MOMENT
-      include 'COMMON.CONTACTS.MOMENT'
-#endif 
-      integer ilen
-      external ilen
-      logical fail
-      double precision energia(0:n_ene)
-
-      open(icsa_native_int,file=csa_native_int,status="old")
-      read (icsa_native_int,*)
-      call read_angles(icsa_native_int,*10)
-      goto 11
-   10 write (iout,'(2a)') "CHUJ NASTAPIL - error in ",
-     &  csa_native_int(:ilen(csa_native_int))
-   11 continue
-      call intout
-      do j=2,nres-1
-        dihang_in(1,j,1,1)=theta(j+1)
-        dihang_in(2,j,1,1)=phi(j+2)
-        dihang_in(3,j,1,1)=alph(j)
-        dihang_in(4,j,1,1)=omeg(j)
-      enddo
-      dihang_in(2,nres-1,1,1)=0.0d0
-
-c         read(icsa_native_int,*) ind,e
-c         read(icsa_native_int,200) (dihang_in(1,k,1,1),k=2,nres-1)
-c         read(icsa_native_int,200) (dihang_in(2,k,1,1),k=2,nres-2)
-c         read(icsa_native_int,200) (dihang_in(3,k,1,1),k=2,nres-1)
-c         read(icsa_native_int,200) (dihang_in(4,k,1,1),k=2,nres-1)
-c         dihang_in(2,nres-1,1,1)=0.d0
-
-         maxsi=100
-         maxcount_fail=100
-
-         do m=mm+2,n
-c          do k=2,nres-1
-c           dihang_in(1,k,1,m)=dihang_in(1,k,1,1)
-c           dihang_in(2,k,1,m)=dihang_in(2,k,1,1)
-c           if(abs(dihang_in(3,k,1,1)).gt.1.d-3) then
-c            dihang_in(3,k,1,m)=90.d0*ran1(idum)+90.d0
-c           endif
-c           if(abs(dihang_in(4,k,1,1)).gt.1.d-3) then
-c            dihang_in(4,k,1,m)=360.d0*ran1(idum)-180.d0
-c           endif
-c          enddo
-c           call intout
-           fail=.true.
-
-           icount_fail=0
-
-           DO WHILE (FAIL .AND. ICOUNT_FAIL .LE. MAXCOUNT_FAIL)
-
-           do i=nnt,nct
-             if (itype(i).ne.10) then
-cd             print *,'i=',i,' itype=',itype(i),' theta=',theta(i+1)
-               fail=.true.
-               ii=0
-               do while (fail .and. ii .le. maxsi)
-                 call gen_side(itype(i),theta(i+1),alph(i),omeg(i),fail)
-                 ii = ii+1
-               enddo
-             endif
-           enddo
-           call chainbuild
-           call etotal(energia(0))
-           fail = (energia(0).ge.1.0d20)
-           icount_fail=icount_fail+1
-
-           ENDDO
-
-           if (icount_fail.gt.maxcount_fail) then
-             write (iout,*) 
-     &       'Failed to generate non-overlaping near-native conf.',
-     &       m
-           endif
-
-           do j=2,nres-1
-             dihang_in(1,j,1,m)=theta(j+1)
-             dihang_in(2,j,1,m)=phi(j+2)
-             dihang_in(3,j,1,m)=alph(j)
-             dihang_in(4,j,1,m)=omeg(j)
-           enddo
-           dihang_in(2,nres-1,1,m)=0.0d0
-         enddo
-
-c      do m=1,n
-c       write(icsa_native_int,*) m,e
-c         write(icsa_native_int,200) (dihang_in(1,k,1,m),k=2,nres-1)
-c         write(icsa_native_int,200) (dihang_in(2,k,1,m),k=2,nres-2)
-c         write(icsa_native_int,200) (dihang_in(3,k,1,m),k=2,nres-1)
-c         write(icsa_native_int,200) (dihang_in(4,k,1,m),k=2,nres-1)
-c      enddo
-c     close(icsa_native_int)
-
-c      do m=mm+2,n
-c       do i=1,4
-c        do j=2,nres-1
-c         dihang_in(i,j,1,m)=dihang_in(i,j,1,m)*deg2rad
-c        enddo
-c       enddo
-c      enddo
-
-      call dihang_to_c(dihang_in(1,1,1,1))
-
-c Store c to cref (they are in COMMON.CHAIN).
-      do k=1,2*nres
-       do kk=1,3
-        crefjlee(kk,k)=c(kk,k)
-       enddo
-      enddo
-
-      call contact(.true.,ncont_ref,icont_ref,co)
-
-c      do k=1,nres
-c       write(icsa_native_int,200) (crefjlee(i,k),i=1,3)
-c      enddo
-      close(icsa_native_int)
-
-  200 format (8f10.4)
-
-      return
-      end
-ccccccccccccccccccccccccccccccccccccccccccccccccc
-ccccccccccccccccccccccccccccccccccccccccccccccccc
-      subroutine dihang_to_c(aarray)
-      implicit real*8 (a-h,o-z)
-      include 'DIMENSIONS'
-      include 'COMMON.CSA'
-      include 'COMMON.BANK'
-      include 'COMMON.CHAIN'
-      include 'COMMON.GEO'
-      include 'COMMON.VAR'
-
-      dimension aarray(mxang,maxres,mxch)
-
-c     do i=4,nres
-c      phi(i)=dihang_in(1,i-2,1,1)
-c     enddo
-      do i=2,nres-1
-       theta(i+1)=aarray(1,i,1)
-       phi(i+2)=aarray(2,i,1)
-       alph(i)=aarray(3,i,1)
-       omeg(i)=aarray(4,i,1)
-      enddo
-
-      call chainbuild
-
-      return
-      end
-ccccccccccccccccccccccccccccccccccccccccccccccccc
-ccccccccccccccccccccccccccccccccccccccccccccccccc