您的位置:首页 > 运维架构

Fortran&OpenMP - 1.环境配置

2014-01-19 21:04 288 查看
编译OpenMP程序的时候,需要在编译源文件和连接时都加入‘-fopenmp’编译选项。
以Code::Blocks13.11为例,需要在'Project'-'Build Option'-'Compiler Flags'中勾选'Enable the OpenMP extensions [-fopenmp]';



在同一窗口的‘Linker Settings’-‘Other Linker Options’中加入“-fopenmp”



环境设置完毕,可以进行程序编辑了。
program main
implicit none
include 'omp_lib.h'
integer :: threadCount
integer :: threadNum
!$OMP PARALLEL PRIVATE(threadCount, threadNum)
threadCount = OMP_GET_NUM_THREADS()
threadNum = OMP_GET_THREAD_NUM()
write(*, "('THREAD: ', I2, '/', I2)") threadNum, threadCount
!$OMP END PARALLEL
end program


内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: