Paralelize混合f77 f90 Fortran代码? [英] Paralelize mixed f77 f90 Fortran code?
问题描述
我有一个主要编写在f77中的代码,但也有用f90语法编写的例程。
我一直在阅读如何在每种情况下使用openMP,但现在我怀疑如果我在相同的代码中使用两种语法,该怎么做? / p>
更具体地说,我应该使用
use omp_lib
或
include 'omp_lib.h'
但是在同一个.f文件中我有两个sintaxys。如果我同时使用?
我正在用gfortran 4.8.4进行编译。
如果我使用let's say
请使用omp_lib(表示f90语法)
然后我必须使用通讯员语法
!$ omp parallel shared(var1,var2)private(i,j)
!$ omp do
do j = 1,n
do i = 1,m
var1(i,j)= var2
end do
end do
!$ omp end do
然而,有几行我会用f77写成一个循环
< pre $
c $ omp parallel shared(w)private(i,j)
c $ omp do
do 20 i = 10,1,-2
write(*,*)'i =',i
20 continue
c $ omp end do
但是这种方式来调用并行循环会被使用omp_lib识别吗?
同样的问题是相反的。首先,您需要使用 您只需要这个,当你可以调用一个过程: ,但不适用于指令。 对于Fortran 90及更高版本的代码(即使是固定形式,看起来像Fortran 77)使用 ,因为编译器可以更好地检查是否正确调用了函数(它与它们有明确的接口)。 如果代码是真的Fortran 77(而不只是看起来像这样),你必须使用 I have a code written mostly in f77 however there are also routines written with the f90 syntax. I've been reading how to use openMP for each case, but now I have the doubt how should I do it if I have both syntax in the same code? More specifically should I use or but in the same .f file I have both sintaxys. what if I use both? I am compiling with gfortran 4.8.4. If I use let's say Then I have to use the correspondent syntax However a few lines down I'll have a do loop written in f77 but this way to call the parallel loop would be recognised by using use omp_lib? The same question when is the opposite. First, you need the You only need this, when you call a procedure like: or but not for the directives. For Fortran 90 and later code (even in fixed form which looks like Fortran 77) use because the compiler is then better able to check if you call the functions properly (it has an explicit interface to them). If the code is true Fortran 77 (and not just looking like it), you have to use the 这篇关于Paralelize混合f77 f90 Fortran代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋! use
或 include
!$ omp
指令,则不需要。
$ b $或b 调用omp_set_num_threads(1)
$ b $ $ p $ tid = omp_get_thread_num()
code>
use omp_lib
include
,尽管从技术上讲Fortran 77并不是我知道。这是Fortran 77的通用非标准扩展。 use omp_lib
include 'omp_lib.h'
use omp_lib (meaning f90 syntax)
!$omp parallel shared ( var1, var2 ) private ( i, j )
!$omp do
do j = 1, n
do i = 1, m
var1(i,j) = var2
end do
end do
!$omp end do
c$omp parallel shared ( w ) private ( i, j )
c$omp do
do 20 i = 10, 1, -2
write(*,*) 'i =', i
20 continue
c$omp end do
use
or include
only if you call OpenMP procedures. If you just have a couple of !$omp
directives it is not needed. call omp_set_num_threads(1)
tid = omp_get_thread_num()
use omp_lib
include
although technically Fortran 77 doesn't even know that. It is a common non-standard extension to Fortran 77.