Fortran&OpenMP - 1.环境配置

编译OpenMP程序的时候,需要在编译源文件和连接时都加入‘-fopenmp’编译选项。
以Code::Blocks13.11为例,需要在‘Project‘-‘Build Option‘-‘Compiler Flags‘中勾选‘Enable the OpenMP extensions [-fopenmp]‘;
Fortran&OpenMP - 1.环境配置

在同一窗口的‘Linker Settings’-‘Other Linker Options’中加入“-fopenmp”
Fortran&OpenMP - 1.环境配置
环境设置完毕,可以进行程序编辑了。
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

Fortran&OpenMP - 1.环境配置

Fortran&OpenMP - 1.环境配置

上一篇:基于AOP实现权限管理:访问控制模型RBAC和ACL


下一篇:Linux Shell 脚本攻略 - 第三章 以文件之名