OpenMP fortran 学习
参考自TAMU的PPThttps://people.math.umass.edu/~johnston/PHI_WG_2014/OpenMPSlides_tamu_sc.pdf 什么是OpenMP 在C、C++和FORTRAN中用于编写共享内存并行程序的事实上的标准API OpenMP API 由以下组成: 编译器指令 Compiler Directives 运行时 子程序/函数 Runtime subroutines/functions 环境变量 Environment variables 例子: 代码 PROGRAM HELLO !$OMP PARALLEL PRINT *,”Hello World” !$ OMP END PARALLEL STOP END 编译指令 intel: ifort -openmp -o hi.x hello.f pgi: pgfortran -mp -o hi.x hello.f gnu: gfortran -fopenmp -o hi.x hello.f 运行指令 Export OMP_NUM_THREADS=4 ./hi.x FORTRAN指令格式: !$ OMP PARALLEL [clauses] : !$OMP END PARALLEL OpenMP 遵循Fork/Join模型 OpenMP程序从一个线程开始;主线程(线程0)