d44dcc5b2e2bd7f53f8dcf82138bc836b62eb7ad
[unres.git] / source / unres / src_MD / CMakeLists.txt
1 #
2 # CMake project file for UNRES with MD for single chains
3
4
5 enable_language (Fortran)
6
7
8 #================================
9 # Set source file lists
10 #================================
11 set(UNRES_MD_SRC0 
12         add.f 
13         arcos.f
14         banach.f 
15         blas.f 
16         bond_move.f 
17         cartder.F 
18         cartprint.f 
19         check_sc_distr.f
20         check_bond.f 
21         chainbuild.F 
22         checkder_p.F 
23         compare_s1.F 
24         contact.f 
25         convert.f 
26         cored.f 
27         dihed_cons.F 
28         djacob.f 
29         econstr_local.F
30         eigen.f 
31         elecont.f 
32         energy_split-sep.F 
33         entmcm.F
34         fitsq.f 
35         gauss.f 
36         gen_rand_conf.F
37         geomout.F 
38         gnmr1.f 
39         intcartderiv.F 
40         initialize_p.F 
41         int_to_cart.f 
42         intcor.f 
43         intlocal.f 
44         kinetic_lesyng.f 
45         lagrangian_lesyng.F 
46         local_move.f 
47         map.f 
48         matmult.f 
49         mc.F 
50         mcm.F 
51         MD_A-MTS.F 
52         minimize_p.F 
53         minim_mcmf.F 
54         misc.f 
55         moments.f
56         MP.F 
57         MREMD.F 
58         muca_md.f 
59         parmread.F 
60         pinorm.f 
61         printmat.f 
62         q_measure.F 
63         randgens.f 
64         rattle.F 
65         readpdb.F 
66         readrtns.F 
67         refsys.f 
68         regularize.F
69         rescode.f 
70         rmdd.f 
71         rmsd.F 
72         sc_move.F 
73         sort.f 
74         stochfric.F 
75         sumsld.f 
76         surfatom.f 
77         test.F
78         timing.F
79         thread.F 
80         unres.F
81         ssMD.F
82 )
83
84 if(Fortran_COMPILER_NAME STREQUAL "ifort")
85   set(UNRES_MD_SRC0 ${UNRES_MD_SRC0} prng.f ) 
86 elseif(Fortran_COMPILER_NAME STREQUAL "mpif90")
87   set(UNRES_MD_SRC0 ${UNRES_MD_SRC0} prng.f )
88 elseif(Fortran_COMPILER_NAME STREQUAL "f95")
89   set(UNRES_MD_SRC0 ${UNRES_MD_SRC0} prng.f )
90 elseif(Fortran_COMPILER_NAME STREQUAL "gfortran")
91   set(UNRES_MD_SRC0 ${UNRES_MD_SRC0} prng.f )
92 else()
93   set(UNRES_MD_SRC0 ${UNRES_MD_SRC0} prng_32.F )
94 endif (Fortran_COMPILER_NAME STREQUAL "ifort")
95
96
97 set(UNRES_MD_SRC3 
98         energy_p_new_barrier.F 
99         energy_p_new-sep_barrier.F 
100         gradient_p.F )
101
102 set(UNRES_MD_PP_SRC
103         cartder.F
104         chainbuild.F 
105         checkder_p.F 
106         compare_s1.F 
107         dihed_cons.F 
108         econstr_local.F 
109         energy_p_new_barrier.F 
110         energy_p_new-sep_barrier.F 
111         energy_split-sep.F 
112         entmcm.F 
113         gen_rand_conf.F
114         geomout.F 
115         gradient_p.F 
116         initialize_p.F 
117         intcartderiv.F 
118         lagrangian_lesyng.F 
119         mc.F 
120         mcm.F 
121         MD_A-MTS.F
122         minimize_p.F 
123         minim_mcmf.F 
124         MP.F 
125         MREMD.F 
126         parmread.F 
127         q_measure1.F 
128         q_measure3.F 
129         q_measure.F
130         rattle.F 
131         readpdb.F 
132         readrtns.F 
133         regularize.F 
134         rmsd.F 
135         sc_move.F 
136         stochfric.F 
137         test.F 
138         thread.F 
139         timing.F
140         unres.F 
141         proc_proc.c 
142
143
144
145 if(NOT Fortran_COMPILER_NAME STREQUAL "ifort")
146   set(UNRES_MD_PP_SRC ${UNRES_MD_PP_SRC} prng_32.F) 
147 endif(NOT Fortran_COMPILER_NAME STREQUAL "ifort")
148
149 #================================================
150 # Set comipiler flags for different sourcefiles  
151 #================================================
152 if (Fortran_COMPILER_NAME STREQUAL "ifort")
153   set(FFLAGS0 "-ip -w" ) 
154   set(FFLAGS1 "-w -g -d2 -CA -CB" ) 
155   set(FFLAGS2 "-w -g -00 ")
156   #set(FFLAGS3 "-c -w -O3 -ipo -ipo_obj -opt_report" )
157   set(FFLAGS3 "-w -ipo " )
158 elseif (Fortran_COMPILER_NAME STREQUAL "gfortran")
159   set(FFLAGS0 "-std=legacy -I. " ) 
160   set(FFLAGS1 "-std=legacy -g -I. " ) 
161   set(FFLAGS2 "-std=legacy -I. ")
162   #set(FFLAGS3 "-c -w -O3 -ipo -ipo_obj -opt_report" )
163   set(FFLAGS3 "-std=legacy -I. " )
164 <<<<<<< HEAD
165 <<<<<<< HEAD
166 =======
167 =======
168 >>>>>>> f3fb02dcb801d48f6bdc6f48c78bc8a3a2c7fb97
169 elseif (Fortran_COMPILER_NAME STREQUAL "g77")
170   set(FFLAGS0 "-I ${CMAKE_CURRENT_SOURCE_DIR} " ) 
171   set(FFLAGS1 "-g -I ${CMAKE_CURRENT_SOURCE_DIR} " ) 
172   set(FFLAGS2 "-I ${CMAKE_CURRENT_SOURCE_DIR} ")
173   set(FFLAGS3 "-I ${CMAKE_CURRENT_SOURCE_DIR} " )
174 <<<<<<< HEAD
175 >>>>>>> f3fb02dcb801d48f6bdc6f48c78bc8a3a2c7fb97
176 =======
177 >>>>>>> f3fb02dcb801d48f6bdc6f48c78bc8a3a2c7fb97
178 endif (Fortran_COMPILER_NAME STREQUAL "ifort")
179
180
181 # Add MPI compiler flags
182 if(UNRES_WITH_MPI)
183   set(FFLAGS0 "${FFLAGS0} -I${MPIF_INCLUDE_DIRECTORIES}")
184   set(FFLAGS1 "${FFLAGS1} -I${MPIF_INCLUDE_DIRECTORIES}")
185   set(FFLAGS2 "${FFLAGS2} -I${MPIF_INCLUDE_DIRECTORIES}")
186   set(FFLAGS3 "${FFLAGS3} -I${MPIF_INCLUDE_DIRECTORIES}")
187 endif(UNRES_WITH_MPI)
188
189 set_property(SOURCE ${UNRES_MD_SRC0} APPEND PROPERTY COMPILE_FLAGS ${FFLAGS0} )
190 #set_property(SOURCE ${UNRES_MD_SRC1} PROPERTY COMPILE_FLAGS ${FFLAGS1} )
191 #set_property(SOURCE ${UNRES_MD_SRC2} PROPERTY COMPILE_FLAGS ${FFLAGS2} )
192 set_property(SOURCE ${UNRES_MD_SRC3} PROPERTY COMPILE_FLAGS ${FFLAGS3} )
193
194 #=========================================
195 # Settings for GAB force field 
196 #=========================================
197 if(UNRES_MD_FF STREQUAL "GAB" )
198   # set preprocesor flags   
199   set(CPPFLAGS "PROCOR -DUNRES -DISNAN -DSPLITELE -DLANG0 -DCRYST_BOND -DCRYST_THETA -DCRYST_SC" )
200
201 #=========================================
202 #  Settings for E0LL2Y force field
203 #=========================================
204 elseif(UNRES_MD_FF STREQUAL "E0LL2Y")
205   # set preprocesor flags   
206   set(CPPFLAGS "PROCOR -DUNRES -DISNAN -DSPLITELE -DLANG0" )
207 endif(UNRES_MD_FF STREQUAL "GAB")
208
209 #=========================================
210 # System specific flags
211 #=========================================
212 if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
213   set(CPPFLAGS "${CPPFLAGS} -DLINUX") 
214 endif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
215
216 #=========================================
217 # Compiler specific flags
218 #=========================================
219
220 if (Fortran_COMPILER_NAME STREQUAL "ifort")
221   # Add ifort preprocessor flags
222   set(CPPFLAGS "${CPPFLAGS} -DPGI") 
223 elseif (Fortran_COMPILER_NAME STREQUAL "f95")
224   # Add new gfortran flags
225   set(CPPFLAGS "${CPPFLAGS} -DG77") 
226 elseif (Fortran_COMPILER_NAME STREQUAL "gfortran")
227   # Add old gfortran flags
228   set(CPPFLAGS "${CPPFLAGS} -DG77") 
229 <<<<<<< HEAD
230 <<<<<<< HEAD
231 =======
232 elseif (Fortran_COMPILER_NAME STREQUAL "g77")
233   # Add old gfortran flags
234   set(CPPFLAGS "${CPPFLAGS} -DG77")
235 >>>>>>> f3fb02dcb801d48f6bdc6f48c78bc8a3a2c7fb97
236 =======
237 elseif (Fortran_COMPILER_NAME STREQUAL "g77")
238   # Add old gfortran flags
239   set(CPPFLAGS "${CPPFLAGS} -DG77")
240 >>>>>>> f3fb02dcb801d48f6bdc6f48c78bc8a3a2c7fb97
241 else(Fortran_COMPILER_NAME STREQUAL "ifort")
242   # Default preprocessor flag
243   set(CPPFLAGS "${CPPFLAGS} -DPGI")
244 endif (Fortran_COMPILER_NAME STREQUAL "ifort")
245
246 #=========================================
247 # Add MPI preprocessor flags
248 #=========================================
249 if (UNRES_WITH_MPI)
250   set(CPPFLAGS "${CPPFLAGS} -DMP -DMPI") 
251 endif(UNRES_WITH_MPI)
252
253 #=========================================
254 # Apply preprocesor flags to *.F files
255 #=========================================
256 set_property(SOURCE ${UNRES_MD_PP_SRC} PROPERTY COMPILE_DEFINITIONS ${CPPFLAGS} )  
257
258
259 #========================================
260 #  Setting binary name
261 #========================================
262 if(UNRES_WITH_MPI) 
263   # binary with mpi
264   set(UNRES_BIN "unres_${Fortran_COMPILER_NAME}_MPICH_${UNRES_MD_FF}.exe")
265 else(UNRES_WITH_MPI)
266   # binary without mpi
267   set(UNRES_BIN "unres_${Fortran_COMPILER_NAME}_single_${UNRES_MD_FF}.exe")
268 endif(UNRES_WITH_MPI)  
269
270 #=========================================
271 # cinfo.f workaround for cmake
272 #=========================================
273 # get the current date  
274 TODAY(DATE)
275 # generate cinfo.f
276
277 set(CINFO "${CMAKE_CURRENT_BINARY_DIR}/cinfo.f")
278 FILE(WRITE ${CINFO}
279 "C CMake generated file
280        subroutine cinfo
281        include 'COMMON.IOUNITS'
282        write(iout,*)'++++ Compile info ++++'
283        write(iout,*)'Version ${UNRES_MAJOR}.${UNRES_MINOR} build ${UNRES_PATCH}'
284 ")
285
286 CINFO_FORMAT(${CINFO} "Compiled" "${DATE}" )
287 CINFO_FORMAT(${CINFO} "Compiled by" "$ENV{USER}@$ENV{HOST}" )
288 CINFO_FORMAT(${CINFO} "OS name:" "${CMAKE_SYSTEM_NAME}" )
289 CINFO_FORMAT(${CINFO} "OS release:" "${CMAKE_SYSTEM}" )
290 CINFO_FORMAT(${CINFO} "Fortran Compiler:" "${CMAKE_Fortran_COMPILER}" )
291 CINFO_FORMAT(${CINFO} "MD Force field:" "${UNRES_MD_FF}" )
292 CINFO_FORMAT(${CINFO} "CPPFLAGS =" "${CPPFLAGS}")
293
294 FILE(APPEND ${CINFO} 
295 "       write(iout,*)'++++ End of compile info ++++'  
296        return 
297        end ")
298
299 # add include path
300 set_property(SOURCE ${CMAKE_CURRENT_BINARY_DIR}/cinfo.f PROPERTY COMPILE_FLAGS "${FFLAGS0} -I${CMAKE_CURRENT_SOURCE_DIR}")
301
302 #=========================================
303 # Set full unres MD sources
304 #=========================================
305 set(UNRES_MD_SRCS ${UNRES_MD_SRC0} ${UNRES_MD_SRC3} ${CMAKE_CURRENT_BINARY_DIR}/cinfo.f )
306
307
308 #=========================================
309 # Build the binary
310 #=========================================
311 add_executable(UNRES_BIN-MD ${UNRES_MD_SRCS} )
312 set_target_properties(UNRES_BIN-MD PROPERTIES OUTPUT_NAME ${UNRES_BIN})
313 #set_property(TARGET ${UNRES_BIN} PROPERTY RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/unres/MD )
314 #add_dependencies (${UNRES_BIN} ${UNRES_XDRFLIB})
315
316
317 #=========================================
318 # Link libraries
319 #=========================================
320 # link MPI library (libmpich.a)  
321 if(UNRES_WITH_MPI)
322   target_link_libraries( UNRES_BIN-MD ${MPIF_LIBRARIES} )
323 endif(UNRES_WITH_MPI)
324 # link libxdrf.a 
325 #message("UNRES_XDRFLIB=${UNRES_XDRFLIB}")
326 target_link_libraries( UNRES_BIN-MD xdrf )
327
328 #=========================================
329 # TESTS 
330 #=========================================
331
332 #-- Copy all the data files from the test directory into the source directory
333 #SET(UNRES_TEST_FILES
334 #       ala10.inp
335 #    )
336
337 #FOREACH (UNRES_TEST_FILE ${UNRES_TEST_FILES})
338 #      SET (unres_test_dest "${CMAKE_CURRENT_BINARY_DIR}/${UNRES_TEST_FILE}")
339 #      MESSAGE (STATUS " Copying ${UNRES_TEST_FILE} from ${CMAKE_SOURCE_DIR}/examples/unres/MD/ff_gab/${UNRES_TEST_FILE} to ${unres_test_dest}")
340 #      ADD_CUSTOM_COMMAND (
341 #          TARGET     ${UNRES_BIN}
342 #          POST_BUILD
343 #          COMMAND    ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/examples/unres/MD/ff_gab/${UNRES_TEST_FILE} ${unres_test_dest}
344 #      )
345 #ENDFOREACH (UNRES_TEST_FILE ${UNRES_TEST_FILES})
346
347 #=========================================
348 # Generate data test files
349 #=========================================
350 #  test_single_ala.sh
351 #=========================================
352
353 FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/scripts/test_single_ala.sh
354 "#!/bin/sh
355 export POT=GB
356 export PREFIX=ala10
357 #-----------------------------------------------------------------------------
358 UNRES_BIN=./${UNRES_BIN}
359 #-----------------------------------------------------------------------------
360 DD=${CMAKE_SOURCE_DIR}/PARAM
361 export BONDPAR=$DD/bond.parm
362 export THETPAR=$DD/thetaml.5parm
363 export ROTPAR=$DD/scgauss.parm
364 export TORPAR=$DD/torsion_631Gdp.parm
365 export TORDPAR=$DD/torsion_double_631Gdp.parm
366 export ELEPAR=$DD/electr_631Gdp.parm
367 export SIDEPAR=$DD/sc_GB_opt.1gab_3S_qclass5no310-shan2-sc-16-10-8k
368 export FOURIER=$DD/fourier_opt.parm.1igd_hc_iter3_3
369 export SCPPAR=$DD/scp.parm
370 export SCCORPAR=$DD/sccor_pdb_shelly.dat
371 export PATTERN=$DD/patterns.cart
372 #-----------------------------------------------------------------------------
373 $UNRES_BIN
374 ")
375
376 #
377 # File permissions workaround
378 #
379 FILE(   COPY ${CMAKE_CURRENT_BINARY_DIR}/scripts/test_single_ala.sh 
380         DESTINATION ${CMAKE_CURRENT_BINARY_DIR}
381         FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
382 )
383
384
385
386 #=========================================
387 #  ala10.inp
388 #=========================================
389
390 file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/ala10.inp
391 "ala10 unblocked
392 SEED=-1111333 MD ONE_LETTER rescale_mode=2 
393 nstep=15000 ntwe=100 ntwx=1000 dt=0.1 lang=0 tbf t_bath=300 damax=1.0          &
394 reset_moment=1000 reset_vel=1000
395 WLONG=1.35279 WSCP=1.59304 WELEC=0.71534 WBOND=1.00000 WANG=1.13873            &
396 WSCLOC=0.16258 WTOR=1.98599 WTORD=1.57069 WCORRH=0.42887 WCORR5=0.00000        &
397 WCORR6=0.00000 WEL_LOC=0.16036 WTURN3=1.68722 WTURN4=0.66230 WTURN6=0.00000    &
398 WVDWPP=0.11371 WHPB=1.00000                                                    &
399 CUTOFF=7.00000 WCORR4=0.00000
400 12
401 XAAAAAAAAAAX 
402  0
403  0
404    90.0000   90.0000   90.0000  90.000   90.000   90.000   90.000   90.000 
405    90.0000   90.0000
406   180.0000  180.0000  180.0000 180.000  180.000  180.000  180.000  180.000
407   180.0000
408   110.0000  110.0000  110.0000 100.000  110.000  100.000  110.000  110.000 
409   110.0000  110.0000
410  -120.0000 -120.0000 -120.000 -120.000 -120.000 -120.000 -120.000 -120.000
411  -120.0000 -120.0000
412 ")
413
414
415 # Add tests
416
417 if(NOT UNRES_WITH_MPI)
418                   
419   add_test(NAME UNRES_MD_Ala10 COMMAND sh ${CMAKE_CURRENT_BINARY_DIR}/test_single_ala.sh )
420
421 else(NOT UNRES_WITH_MPI)
422
423
424   add_test(NAME UNRES_MD_MPI_Ala10 COMMAND mpiexec -boot ${CMAKE_CURRENT_BINARY_DIR}/test_single_ala.sh )
425
426 endif(NOT UNRES_WITH_MPI)
427