cmake changes for pgf90
[unres.git] / source / unres / src_MIN / CMakeLists.txt
1 #
2 # CMake project file for UNRES with Minimazation 
3
4
5 enable_language (Fortran)
6
7 #================================
8 # Set source file lists
9 #================================
10 # sources used with FFLAGS0
11 set(UNRES_MIN_SRC0 
12         arcos.f
13         cartder.F 
14         cartprint.f 
15         chainbuild.F 
16         checkder_p.F 
17         convert.f 
18         djacob.f
19         econstr_local.F
20         gen_rand_conf.F
21         geomout_min.F
22         initialize_p.F 
23         intcartderiv.F
24         intcor.f 
25         intlocal.f 
26         int_to_cart.f 
27         matmult.f 
28         minimize_p.F
29         misc.f 
30         MP.F 
31         parmread.F 
32         pinorm.f 
33         printmat.f 
34         randgens.f 
35         readrtns_min.F
36         rescode.f 
37         refsys.f
38         rmdd.f 
39         sc_move.F
40         sumsld.f 
41         timing.F
42         unres_min.F
43
44 )
45 # sources used with FFLAGS1
46 set(UNRES_MIN_SRC1 
47         cored.f
48 )
49
50 # sources used with FFLAGS2
51 set(UNRES_MIN_SRC2 
52         readpdb.F
53 )
54
55 # sources used with FFLAGS3
56 set(UNRES_MIN_SRC3 
57         energy_p_new_barrier.F
58         gradient_p.F
59 )
60
61 # sources used with preprocesor flags (should also be listed above with FFLAGSX)
62 set(UNRES_MIN_PP_SRC
63         bank.F 
64         cartder.F 
65         chainbuild.F 
66         checkder_p.F 
67         compare_s1.F
68         cored.f
69         csa.f 
70         dihed_cons.F
71         diff12.f 
72         econstr_local.F
73         energy_p_new.F
74         energy_p_new_barrier.F 
75         energy_split-sep.F 
76         entmcm.F 
77         gen_rand_conf.F
78         geomout_min.F 
79         gradient_p.F 
80         intcor.f
81         initialize_p.F 
82         intcartderiv.F 
83         lagrangian_lesyng.F 
84         matmult.f
85         mc.F 
86         mcm.F 
87         MD_A-MTS.F
88         minimize_p.F 
89         minim_jlee.F
90         minim_mcmf.F 
91         MP.F 
92         MREMD.F
93         newconf.f 
94         parmread.F 
95         permut.F
96         prng_32.F 
97         q_measure1.F 
98         q_measure3.F 
99         q_measure.F
100         ran.f
101         rattle.F 
102         readpdb.F 
103         readrtns_min.F
104         regularize.F
105         rmdd.f 
106         rmsd.F 
107         sc_move.F
108         shift.F 
109         stochfric.F
110         sumsld.f 
111         test.F 
112         thread.F 
113         timing.F
114         together.F
115         unres.F 
116
117
118
119 #================================================
120 # Set comipiler flags for different sourcefiles  
121 #================================================
122 if (Fortran_COMPILER_NAME STREQUAL "ifort")
123   find_package (Threads)
124   set(FFLAGS0 "-g -ip -w" ) 
125   set(FFLAGS1 "-w -g -d2 -CA -CB" ) 
126   set(FFLAGS2 "-w -g -00 ")
127   set(FFLAGS3 "-g -w -ipo " )
128 elseif (Fortran_COMPILER_NAME STREQUAL "gfortran")
129   set(FFLAGS0 "-std=legacy -O " ) 
130   set(FFLAGS1 "-std=legacy -g -C" ) 
131   set(FFLAGS2 "-std=legacy -g -O0 ")
132   set(FFLAGS3 "-std=legacy -O3" )
133 endif (Fortran_COMPILER_NAME STREQUAL "ifort")
134
135
136 set_property(SOURCE ${UNRES_MIN_SRC0} PROPERTY COMPILE_FLAGS ${FFLAGS0} )
137 set_property(SOURCE ${UNRES_MIN_SRC1} PROPERTY COMPILE_FLAGS ${FFLAGS1} )
138 set_property(SOURCE ${UNRES_MIN_SRC2} PROPERTY COMPILE_FLAGS ${FFLAGS2} )
139 set_property(SOURCE ${UNRES_MIM_SRC3} PROPERTY COMPILE_FLAGS ${FFLAGS3} )
140
141 #=========================================
142 # Settings for GAB force field 
143 #=========================================
144 if(UNRES_MD_FF STREQUAL "GAB" )
145   # set preprocesor flags   
146   set(CPPFLAGS "PROCOR -DUNRES -DISNAN -DSPLITELE -DLANG0 -DCRYST_BOND -DCRYST_THETA -DCRYST_SC")
147
148 #=========================================
149 #  Settings for E0LL2Y force field
150 #=========================================
151 elseif(UNRES_MD_FF STREQUAL "E0LL2Y")
152   # set preprocesor flags   
153   set(CPPFLAGS "PROCOR -DUNRES -DISNAN -DSPLITELE -DLANG0" )
154 elseif(UNRES_MD_FF STREQUAL "4P")
155   set(CPPFLAGS "UNRES -DISNAN -DSPLITELE -DLANG0 -DCRYST_BOND -DCRYST_THETA -DCRYST_SC -DSCCORPDB" )
156 endif(UNRES_MD_FF STREQUAL "GAB")
157
158 #=========================================
159 # System specific flags
160 #=========================================
161 if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
162   set(CPPFLAGS "${CPPFLAGS} -DLINUX") 
163 endif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
164
165
166 if (Fortran_COMPILER_NAME STREQUAL "ifort")
167   # Add ifort preprocessor flags
168   set(CPPFLAGS "${CPPFLAGS} -DPGI") 
169 elseif (Fortran_COMPILER_NAME STREQUAL "f95")
170   # Add gfortran flags
171   set(CPPFLAGS "${CPPFLAGS} -DG77") 
172 elseif (Fortran_COMPILER_NAME STREQUAL "gfortran")
173   # Add gfortran flags
174   set(CPPFLAGS "${CPPFLAGS} -DG77") 
175 elseif (Fortran_COMPILER_NAME STREQUAL "pgf90")
176   set(CPPFLAGS "${CPPFLAGS} -DPGI")
177   FILE(COPY ${CMAKE_SOURCE_DIR}/source/lib/isnan_pgi.f DESTINATION ${CMAKE_CURRENT_BINARY_DIR} )
178   list(APPEND UNRES_MIN_SRC0 ${CMAKE_CURRENT_BINARY_DIR}/isnan_pgi.f)
179 endif (Fortran_COMPILER_NAME STREQUAL "ifort")
180
181
182 # add 64-bit specific preprocessor flags
183 if (architektura STREQUAL "64")
184   set(CPPFLAGS "${CPPFLAGS} -DAMD64")
185 endif (architektura STREQUAL "64")
186
187 # Apply preprocesor flags to *.F files
188 set_property(SOURCE ${UNRES_MIN_PP_SRC} PROPERTY COMPILE_DEFINITIONS ${CPPFLAGS} )  
189
190
191
192 #========================================
193 #  Setting binary name
194 #========================================
195 set(UNRES_BIN "unres_${Fortran_COMPILER_NAME}_MIN_single_${UNRES_MD_FF}.exe")
196
197 #========================================
198 #  cinfo.f workaround for Cmake
199 #========================================
200 # get the current date  
201 TODAY(DATE)
202 # generate cinfo.f
203
204 set(CINFO "${CMAKE_CURRENT_BINARY_DIR}/cinfo.f")
205 FILE(WRITE ${CINFO}
206 "C CMake generated file
207        subroutine cinfo
208        include 'COMMON.IOUNITS'
209        write(iout,*)'++++ Compile info ++++'
210        write(iout,*)'Version ${UNRES_MAJOR}.${UNRES_MINOR} build ${UNRES_PATCH}'
211 ")
212
213 CINFO_FORMAT(${CINFO} "Compiled" "${DATE}" )
214 CINFO_FORMAT(${CINFO} "Compiled by" "$ENV{USER}@$ENV{HOST}" )
215 CINFO_FORMAT(${CINFO} "OS name:" "${CMAKE_SYSTEM_NAME}" )
216 CINFO_FORMAT(${CINFO} "OS release:" "${CMAKE_SYSTEM}" )
217 CINFO_FORMAT(${CINFO} "Fortran Compiler:" "${CMAKE_Fortran_COMPILER}" )
218 CINFO_FORMAT(${CINFO} "CPPFLAGS =" "${CPPFLAGS}")
219
220 FILE(APPEND ${CINFO} 
221 "       write(iout,*)'Version MINI energy and minimalization only'
222        write(iout,*)'++++ End of compile info ++++'  
223        return 
224        end ")
225
226 # add include path
227 set_property(SOURCE ${CMAKE_CURRENT_BINARY_DIR}/cinfo.f PROPERTY COMPILE_FLAGS "${FFLAGS0} -I${CMAKE_CURRENT_SOURCE_DIR}")
228
229 #=========================================
230 # Set full unres MIN sources
231 #=========================================
232 set(UNRES_MIN_SRCS ${UNRES_MIN_SRC0} ${UNRES_MIN_SRC1} ${UNRES_MIN_SRC2} ${UNRES_MIN_SRC3} ${CMAKE_CURRENT_BINARY_DIR}/cinfo.f )
233
234 #=========================================
235 # Build the binary
236 #=========================================
237 add_executable(UNRES_MIN_BIN ${UNRES_MIN_SRCS} )
238 set_target_properties(UNRES_MIN_BIN PROPERTIES OUTPUT_NAME ${UNRES_BIN})
239
240 if (Fortran_COMPILER_NAME STREQUAL "ifort")
241   target_link_libraries (UNRES_MIN_BIN ${CMAKE_THREAD_LIBS_INIT})
242 endif (Fortran_COMPILER_NAME STREQUAL "ifort")
243 set_property(TARGET UNRES_MIN_BIN PROPERTY RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin )
244
245
246 #=========================================
247 # Install Path
248 #=========================================
249 install(TARGETS UNRES_MIN_BIN DESTINATION ${CMAKE_INSTALL_PREFIX}/unres/MINIM)
250
251 #=========================================
252 # TESTS 
253 #=========================================
254
255 #=========================================
256 # Generate data test files
257 #=========================================
258 #  test_single_ala.sh
259 #=========================================
260
261 FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/scripts/test_single_ala.sh
262 "#!/bin/sh
263 export POT=GB
264 export PREFIX=ala10
265 #-----------------------------------------------------------------------------
266 UNRES_BIN=${CMAKE_BINARY_DIR}/bin/${UNRES_BIN}
267 #-----------------------------------------------------------------------------
268 DD=${CMAKE_SOURCE_DIR}/PARAM
269 export BONDPAR=$DD/bond.parm
270 export THETPAR=$DD/thetaml.5parm
271 export ROTPAR=$DD/scgauss.parm
272 export TORPAR=$DD/torsion_631Gdp.parm
273 export TORDPAR=$DD/torsion_double_631Gdp.parm
274 export ELEPAR=$DD/electr_631Gdp.parm
275 export SIDEPAR=$DD/sc_GB_opt.1gab_3S_qclass5no310-shan2-sc-16-10-8k
276 export FOURIER=$DD/fourier_opt.parm.1igd_hc_iter3_3
277 export SCPPAR=$DD/scp.parm
278 export SCCORPAR=$DD/sccor_pdb_shelly.dat
279 export PATTERN=$DD/patterns.cart
280 #-----------------------------------------------------------------------------
281 $UNRES_BIN
282 ")
283
284 #
285 # File permissions workaround
286 #
287 FILE(   COPY ${CMAKE_CURRENT_BINARY_DIR}/scripts/test_single_ala.sh 
288         DESTINATION ${CMAKE_CURRENT_BINARY_DIR}
289         FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
290 )
291
292
293
294 #=========================================
295 #  ala10.inp
296 #=========================================
297
298 file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/ala10.inp
299 "ala10 unblocked
300 SEED=-1111333 MD ONE_LETTER rescale_mode=2 
301 nstep=15000 ntwe=100 ntwx=1000 dt=0.1 lang=0 tbf t_bath=300 damax=1.0          &
302 reset_moment=1000 reset_vel=1000
303 WLONG=1.35279 WSCP=1.59304 WELEC=0.71534 WBOND=1.00000 WANG=1.13873            &
304 WSCLOC=0.16258 WTOR=1.98599 WTORD=1.57069 WCORRH=0.42887 WCORR5=0.00000        &
305 WCORR6=0.00000 WEL_LOC=0.16036 WTURN3=1.68722 WTURN4=0.66230 WTURN6=0.00000    &
306 WVDWPP=0.11371 WHPB=1.00000                                                    &
307 CUTOFF=7.00000 WCORR4=0.00000
308 12
309 XAAAAAAAAAAX 
310  0
311  0
312    90.0000   90.0000   90.0000  90.000   90.000   90.000   90.000   90.000 
313    90.0000   90.0000
314   180.0000  180.0000  180.0000 180.000  180.000  180.000  180.000  180.000
315   180.0000
316   110.0000  110.0000  110.0000 100.000  110.000  100.000  110.000  110.000 
317   110.0000  110.0000
318  -120.0000 -120.0000 -120.000 -120.000 -120.000 -120.000 -120.000 -120.000
319  -120.0000 -120.0000
320 ")
321
322 if(UNRES_MD_FF STREQUAL "E0LL2Y")
323
324 FILE(COPY ${CMAKE_SOURCE_DIR}/ctest/prota.pdb
325         DESTINATION ${CMAKE_CURRENT_BINARY_DIR} )
326
327 FILE(COPY ${CMAKE_SOURCE_DIR}/ctest/prota_unres.pdb
328         DESTINATION ${CMAKE_CURRENT_BINARY_DIR} )
329
330 FILE(COPY ${CMAKE_SOURCE_DIR}/ctest/prota_ENE.inp
331         DESTINATION ${CMAKE_CURRENT_BINARY_DIR} )
332
333 FILE(COPY ${CMAKE_SOURCE_DIR}/ctest/prota_MIN_CART.inp
334         DESTINATION ${CMAKE_CURRENT_BINARY_DIR} )
335
336 FILE(COPY ${CMAKE_SOURCE_DIR}/ctest/1l2y_MIN_INT.inp
337         DESTINATION ${CMAKE_CURRENT_BINARY_DIR} )
338
339 FILE(COPY ${CMAKE_SOURCE_DIR}/ctest/1L2Y.pdb
340         DESTINATION ${CMAKE_CURRENT_BINARY_DIR} )
341
342 FILE(COPY ${CMAKE_SOURCE_DIR}/ctest/prota_unres_energy_check.sh
343         DESTINATION ${CMAKE_CURRENT_BINARY_DIR} 
344         FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
345 )
346
347
348 #=========================================
349 #  test_prota_E0LL2Y.sh
350 #=========================================
351
352 FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/scripts/test_prota_E0LL2Y.sh
353 "#!/bin/sh
354 export POT=GB
355 export FGPROCS=$2
356 export PREFIX=$1
357 #-----------------------------------------------------------------------------
358 UNRES_BIN=${CMAKE_BINARY_DIR}/bin/${UNRES_BIN}
359 #-----------------------------------------------------------------------------
360 DD=${CMAKE_SOURCE_DIR}/PARAM
361 export BONDPAR=$DD/bond_AM1.parm
362 export THETPAR=$DD/theta_abinitio.parm
363 export ROTPAR=$DD/rotamers_AM1_aura.10022007.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/scinter_$POT.parm
368 export FOURIER=$DD/fourier_opt.parm.1igd_hc_iter3_3
369 export SCPPAR=$DD/scp.parm
370 export SCCORPAR=$DD/sccor_am1_pawel.dat
371 export THETPARPDB=$DD/thetaml.5parm
372 export ROTPARPDB=$DD/scgauss.parm
373 export PATTERN=$DD/patterns.cart
374 #-----------------------------------------------------------------------------
375 echo CTEST_FULL_OUTPUT
376 $UNRES_BIN
377 ./prota_unres_energy_check.sh $1 ${UNRES_BIN}
378 ")
379
380 #
381 # File permissions workaround
382 #
383 FILE(   COPY ${CMAKE_CURRENT_BINARY_DIR}/scripts/test_prota_E0LL2Y.sh 
384         DESTINATION ${CMAKE_CURRENT_BINARY_DIR}
385         FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
386 )
387
388 endif(UNRES_MD_FF STREQUAL "E0LL2Y")
389
390
391
392 # Add tests
393
394   if(UNRES_MD_FF STREQUAL "GAB")
395 #    add_test(NAME UNRES-MIN_Ala10 COMMAND sh ${CMAKE_CURRENT_BINARY_DIR}/test_single_ala.sh )
396   endif(UNRES_MD_FF STREQUAL "GAB")
397  
398   if(UNRES_MD_FF STREQUAL "E0LL2Y")
399     add_test(NAME UNRES-MIN_ENE_prota COMMAND sh ${CMAKE_CURRENT_BINARY_DIR}/test_prota_E0LL2Y.sh prota_ENE 1 )
400     add_test(NAME UNRES-MIN_MIN_prota COMMAND sh ${CMAKE_CURRENT_BINARY_DIR}/test_prota_E0LL2Y.sh prota_MIN_CART 1 )
401     add_test(NAME UNRES-MIN_MIN_INT COMMAND sh ${CMAKE_CURRENT_BINARY_DIR}/test_prota_E0LL2Y.sh 1l2y_MIN_INT 1 )
402   endif(UNRES_MD_FF STREQUAL "E0LL2Y")
403
404