gpt4 book ai didi

fortran - OpenMP 几个 "shared"-指令?

转载 作者:行者123 更新时间:2023-12-04 14:18:41 25 4
gpt4 key购买 nike

嘿,
我在 OpenMP 中有很长的共享变量列表,所以我必须在 fortran 中拆分行并使用“&”-语法来确保行粘在一起!

类似的东西:

!$OMP PARALLEL DEFAULT(private) SHARED(vars....,
& more_vars...,
& more_vars...
& )

在没有 OpenMP 的情况下编译时,这会给我带来错误,因为只有第一个赞才会被识别为评论!现在的问题是我不能添加“!”在那些前面带有“&”的行前面支持不使用 OpenMP 的编译:
!$OMP PARALLEL DEFAULT(private) SHARED(vars....,
! & more_vars...,
! & more_vars...
! & )

因为它不再用 OpenMP 编译了......但我想在一个代码中支持这两种编译......关于如何做的任何建议?

最佳答案

您没有使用正确的语法。如果您查看 OpenMP V3.0 规范的第 2.1.2 节免费源格式指令,您将看到以下内容:

The sentinel can appear in any column as long as it is preceded only by white space (spaces and tab characters). It must appear as a single word with no intervening character. Fortran free form line length, white space, and continuation rules apply to the directive line. Initial directive lines must have a space after the sentinel. Continued directive lines must have an ampersand as the last nonblank character on the line, prior to any comment placed inside the directive. Continuation directive lines can have an ampersand after the directive sentinel with optional white space before and after the ampersand.



所以正确的形式应该是:
!$OMP PARALLEL DEFAULT(private) SHARED(vars...., &
!$OMP& more_vars..., &
!$OMP& more_vars... &
!$OMP& )

对于固定形式,它是同一类型的东西。您以 OMP 标记开始每一行,并确保连续行在第 6 列中具有非空白和非零字符。

关于fortran - OpenMP 几个 "shared"-指令?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5651772/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com