force legacy standard for gfortran
[unres.git] / source / unres / src_MD-M / CMakeLists.txt
1 #
2 # CMake project file for UNRES with MD for single chains
3
4
5 enable_language (Fortran)
6
7 #================================
8 # build the xdrf library 
9 #================================ 
10 #add_subdirectory(xdrf)
11
12 #================================
13 # Set source file lists
14 #================================
15 set(UNRES_MDM_SRC0 
16         add.f 
17         arcos.f
18         banach.f
19         bank.F 
20         blas.f 
21         bond_move.f 
22         cartder.F 
23         cartprint.f 
24         chainbuild.F 
25         check_bond.f 
26         checkder_p.F 
27         check_sc_distr.f
28         compare_s1.F 
29         contact.f 
30         convert.f 
31         cored.f
32         csa.f 
33         dihed_cons.F
34         diff12.f
35         distfit.f 
36         djacob.f
37         econstr_local.F
38         eigen.f 
39         elecont.f 
40         energy_split-sep.F 
41         entmcm.F
42         fitsq.f 
43         gauss.f 
44         gen_rand_conf.F
45         geomout.F 
46         gnmr1.f
47         indexx.f 
48         initialize_p.F 
49         intcartderiv.F
50         intcor.f 
51         intlocal.f 
52         int_to_cart.f 
53         kinetic_lesyng.f 
54         lagrangian_lesyng.F
55         local_move.f 
56         map.f 
57         matmult.f 
58         mc.F 
59         mcm.F 
60         MD_A-MTS.F 
61         minimize_p.F
62         minim_jlee.F 
63         minim_mcmf.F 
64         misc.f 
65         moments.f
66         MP.F 
67         MREMD.F 
68         muca_md.f 
69         newconf.f
70         parmread.F 
71         permut.F
72         pinorm.f 
73         printmat.f 
74         q_measure.F 
75         ran.f
76         randgens.f 
77         rattle.F 
78         readpdb.F
79         readrtns_CSA.F 
80         refsys.f 
81         regularize.F
82         rescode.f 
83         rmdd.f 
84         rmsd.F 
85         sc_move.F 
86         shift.F
87         sort.f 
88         stochfric.F 
89         sumsld.f 
90         surfatom.f 
91         test.F 
92         thread.F 
93         timing.F
94         together.F
95         unres.F
96 )
97
98 if (Fortran_COMPILER_NAME STREQUAL "ifort")
99   set(UNRES_MDM_SRC0 ${UNRES_MDM_SRC0} prng.f ) 
100 elseif(Fortran_COMPILER_NAME STREQUAL "mpif90")
101   set(UNRES_MDM_SRC0 ${UNRES_MDM_SRC0} prng.f )
102 else()
103   set(UNRES_MDM_SRC0 ${UNRES_MDM_SRC0} prng_32.F )
104 endif (Fortran_COMPILER_NAME STREQUAL "ifort")
105
106
107 set(UNRES_MDM_SRC3 energy_p_new_barrier.F energy_p_new-sep_barrier.F gradient_p.F )
108
109 set(UNRES_MDM_PP_SRC
110         bank.F 
111         cartder.F 
112         chainbuild.F 
113         checkder_p.F 
114         compare_s1.F
115         cored.f
116         csa.f 
117         dihed_cons.F
118         diff12.f 
119         econstr_local.F 
120         energy_p_new.F
121         energy_p_new_barrier.F 
122         energy_p_new-sep_barrier.F 
123         energy_split-sep.F 
124         entmcm.F 
125         gen_rand_conf.F
126         geomout.F 
127         gradient_p.F 
128         intcor.f
129         initialize_p.F 
130         intcartderiv.F 
131         lagrangian_lesyng.F 
132         matmult.f
133         mc.F 
134         mcm.F 
135         MD_A-MTS.F
136         minimize_p.F 
137         minim_jlee.F
138         minim_mcmf.F 
139         MP.F 
140         MREMD.F
141         newconf.f 
142         parmread.F 
143         permut.F
144         q_measure1.F 
145         q_measure3.F 
146         q_measure.F
147         ran.f
148         rattle.F 
149         readpdb.F 
150         readrtns_CSA.F 
151         regularize.F
152         rmdd.f 
153         rmsd.F 
154         sc_move.F
155         shift.F 
156         stochfric.F
157         sumsld.f 
158         test.F 
159         thread.F 
160         timing.F
161         together.F
162         unres.F
163         proc_proc.c
164
165
166
167 if(NOT Fortran_COMPILER_NAME STREQUAL "ifort")
168   set(UNRES_MDM_PP_SRC "${UNRES_MDM_PP_SRC} prng_32.F") 
169 endif(NOT Fortran_COMPILER_NAME STREQUAL "ifort")
170
171
172 #================================================
173 # Set comipiler flags for different sourcefiles  
174 #================================================
175 if (Fortran_COMPILER_NAME STREQUAL "ifort")
176   set(FFLAGS0 "-ip -w" ) 
177   set(FFLAGS1 "-w -g -d2 -CA -CB" ) 
178   set(FFLAGS2 "-w -g -00 ")
179   set(FFLAGS3 "-w -ipo " )
180 elseif (Fortran_COMPILER_NAME STREQUAL "gfortran")
181   set(FFLAGS0 "-std=legacy -I. " ) 
182   set(FFLAGS1 "-std=legacy -g -I. " ) 
183   set(FFLAGS2 "-std=legacy -I. ")
184   set(FFLAGS3 "-std=legacy -I. " )
185 endif (Fortran_COMPILER_NAME STREQUAL "ifort")
186
187
188 # Add MPI compiler flags
189 if(UNRES_WITH_MPI)
190   set(FFLAGS0 "${FFLAGS0} -I${MPIF_INCLUDE_DIRECTORIES}")
191   set(FFLAGS1 "${FFLAGS1} -I${MPIF_INCLUDE_DIRECTORIES}")
192   set(FFLAGS2 "${FFLAGS2} -I${MPIF_INCLUDE_DIRECTORIES}")
193   set(FFLAGS3 "${FFLAGS3} -I${MPIF_INCLUDE_DIRECTORIES}")
194 endif(UNRES_WITH_MPI)
195
196 set_property(SOURCE ${UNRES_MDM_SRC0} APPEND PROPERTY COMPILE_FLAGS ${FFLAGS0} )
197 #set_property(SOURCE ${UNRES_MD_SRC1} PROPERTY COMPILE_FLAGS ${FFLAGS1} )
198 #set_property(SOURCE ${UNRES_MD_SRC2} PROPERTY COMPILE_FLAGS ${FFLAGS2} )
199 set_property(SOURCE ${UNRES_MDM_SRC3} PROPERTY COMPILE_FLAGS ${FFLAGS3} )
200
201 #=========================================
202 # Settings for GAB force field 
203 #=========================================
204 if(UNRES_MD_FF STREQUAL "GAB" )
205   # set preprocesor flags   
206   set(CPPFLAGS "PROCOR -DUNRES -DISNAN -DSPLITELE -DLANG0 -DCRYST_BOND -DCRYST_THETA -DCRYST_SC" )
207
208 #=========================================
209 #  Settings for E0LL2Y force field
210 #=========================================
211 elseif(UNRES_MD_FF STREQUAL "E0LL2Y")
212   # set preprocesor flags   
213   set(CPPFLAGS "PROCOR -DUNRES -DISNAN -DSPLITELE -DLANG0" )
214 endif(UNRES_MD_FF STREQUAL "GAB")
215
216
217 #=========================================
218 # System specific flags
219 #=========================================
220 if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
221   set(CPPFLAGS "${CPPFLAGS} -DLINUX") 
222 endif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
223
224
225 #=========================================
226 # Compiler specific flags
227 #=========================================
228
229 if (Fortran_COMPILER_NAME STREQUAL "ifort")
230   # Add ifort preprocessor flags
231   set(CPPFLAGS "${CPPFLAGS} -DPGI") 
232 elseif (Fortran_COMPILER_NAME STREQUAL "f95")
233   # Add new gfortran flags
234   set(CPPFLAGS "${CPPFLAGS} -DG77") 
235 elseif (Fortran_COMPILER_NAME STREQUAL "gfortran")
236   # Add old gfortran flags
237   set(CPPFLAGS "${CPPFLAGS} -DG77") 
238 endif (Fortran_COMPILER_NAME STREQUAL "ifort")
239
240
241 #=========================================
242 # Add MPI preprocessor flags
243 #=========================================
244 if (UNRES_WITH_MPI)
245   set(CPPFLAGS "${CPPFLAGS} -DMP -DMPI") 
246 endif(UNRES_WITH_MPI)
247
248
249 # add 64-bit specific preprocessor flags
250 if (architektura STREQUAL "64")
251   set(CPPFLAGS "${CPPFLAGS} -DAMD64")
252 endif (architektura STREQUAL "64")
253
254
255
256 # Apply preprocesor flags to *.F files
257 set_property(SOURCE ${UNRES_MDM_PP_SRC} PROPERTY COMPILE_DEFINITIONS ${CPPFLAGS} )  
258
259 # Apply preprocesor flags to proc_proc.c
260 set_property(SOURCE proc_proc.c PROPERTY COMPILE_DEFINITIONS "SGI" )  
261
262
263 #========================================
264 #  Setting binary name
265 #========================================
266 if(UNRES_WITH_MPI) 
267   # binary with mpi
268   set(UNRES_BIN "unres_${Fortran_COMPILER_NAME}_MPICH_${UNRES_FF}.exe")
269 else(UNRES_WITH_MPI)
270   # binary without mpi
271   set(UNRES_BIN "unres_${Fortran_COMPILER_NAME}_single_${UNRES_FF}.exe")
272 endif(UNRES_WITH_MPI)  
273
274 #=========================================
275 # cinfo.f workaround for cmake
276 #=========================================
277 # get the current date  
278 TODAY(DATE)
279 # generate cinfo.f
280 set(CINFO "${CMAKE_CURRENT_BINARY_DIR}/cinfo.f")
281 FILE(WRITE ${CINFO}
282 "C CMake generated file
283        subroutine cinfo
284        include 'COMMON.IOUNITS'
285        write(iout,*)'++++ Compile info ++++'
286        write(iout,*)'Version ${UNRES_MAJOR}.${UNRES_MINOR} build ${UNRES_PATCH}'
287 ")
288
289 CINFO_FORMAT(${CINFO} "Compiled" "${DATE}" )
290 CINFO_FORMAT(${CINFO} "Compiled by" "$ENV{USER}@$ENV{HOST}" )
291 CINFO_FORMAT(${CINFO} "OS name:" "${CMAKE_SYSTEM_NAME}" )
292 CINFO_FORMAT(${CINFO} "OS release:" "${CMAKE_SYSTEM}" )
293 CINFO_FORMAT(${CINFO} "Fortran Compiler:" "${CMAKE_Fortran_COMPILER}" )
294 CINFO_FORMAT(${CINFO} "MD Force field:" "${UNRES_MD_FF}" )
295 CINFO_FORMAT(${CINFO} "CPPFLAGS =" "${CPPFLAGS}")
296
297 FILE(APPEND ${CINFO} 
298 "       write(iout,*)'++++ End of compile info ++++'  
299        return 
300        end ")
301
302
303 # add include path
304 set_property(SOURCE ${CMAKE_CURRENT_BINARY_DIR}/cinfo.f PROPERTY COMPILE_FLAGS "${FFLAGS0} -I${CMAKE_CURRENT_SOURCE_DIR}")
305
306 #=========================================
307 # Set full unres MD-M sources
308 #=========================================
309 set(UNRES_MDM_SRCS ${UNRES_MDM_SRC0} ${UNRES_MDM_SRC3} ${CMAKE_CURRENT_BINARY_DIR}/cinfo.f proc_proc.c )
310
311 #=========================================
312 # Build the binary
313 #=========================================
314 add_executable(UNRES_BIN-MD-M ${UNRES_MDM_SRCS} )
315 set_target_properties(UNRES_BIN-MD-M PROPERTIES OUTPUT_NAME ${UNRES_BIN})
316
317 #set_property(TARGET ${UNRES_BIN} PROPERTY RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/unres/MD )
318 #add_dependencies (${UNRES_BIN} ${UNRES_XDRFLIB})
319
320 #=========================================
321 # Link libraries
322 #=========================================
323 # link MPI library (libmpich.a)  
324 if(UNRES_WITH_MPI)
325   target_link_libraries( UNRES_BIN-MD-M ${MPIF_LIBRARIES} )
326 endif(UNRES_WITH_MPI)
327 # link libxdrf.a 
328 #message("UNRES_XDRFLIB=${UNRES_XDRFLIB}")
329 target_link_libraries( UNRES_BIN-MD-M xdrf )
330
331 #=========================================
332 # TESTS 
333 #=========================================
334
335 #-- Copy all the data files from the test directory into the source directory
336 #SET(UNRES_TEST_FILES
337 #       ala10.inp
338 #    )
339
340 #FOREACH (UNRES_TEST_FILE ${UNRES_TEST_FILES})
341 #      SET (unres_test_dest "${CMAKE_CURRENT_BINARY_DIR}/${UNRES_TEST_FILE}")
342 #      MESSAGE (STATUS " Copying ${UNRES_TEST_FILE} from ${CMAKE_SOURCE_DIR}/examples/unres/MD/ff_gab/${UNRES_TEST_FILE} to ${unres_test_dest}")
343 #      ADD_CUSTOM_COMMAND (
344 #          TARGET     ${UNRES_BIN}
345 #          POST_BUILD
346 #          COMMAND    ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/examples/unres/MD/ff_gab/${UNRES_TEST_FILE} ${unres_test_dest}
347 #      )
348 #ENDFOREACH (UNRES_TEST_FILE ${UNRES_TEST_FILES})
349
350 #=========================================
351 # Generate data test files
352 #=========================================
353
354 #if(NOT UNRES_WITH_MPI)
355
356 #  add_test(NAME UNRES_MD_Ala10 COMMAND sh ${CMAKE_CURRENT_BINARY_DIR}/test_single_ala.sh )
357
358 #endif(NOT UNRES_WITH_MPI)
359