标签: intel-fortran


测试目录是否存在

我正在尝试使用Fortan90验证目录是否存在.在我发现的各种网站上:

logical :: dir_e
inquire(file='./docs/.', exist=dir_e)

if ( dir_e ) then
  write(*,*) "dir exists!"
else
  ! workaround: it calls an extern program...
  call system('mkdir docs')
end if
Run Code Online (Sandbox Code Playgroud)

但是,inquire返回False目录是否存在,如果我执行此代码两次,我收到一条错误消息

无法制作dir,文件已经存在

如果我使用:

inquire(file='./docs/test', exist=dir_e)
Run Code Online (Sandbox Code Playgroud)

使用现有文件测试,inquire返回true.

如何检查目录的存在?我正在使用ubuntu 11.04和ifort编译器.

fortran fortran90 intel-fortran

6
推荐指数
2
解决办法
1万
查看次数

只有在使用Intel Visual Fortran编译时,子程序调用上的堆栈溢出,并且当由Compaq Visual Fortran编译时才会很好

使用Fortran .dll的相同源文件,我可以使用Compaq Visual Fortran 6.6C或Intel Visual Fortran 12.1.3.300(IA-32)编译它们.问题是英特尔二进制文件的执行失败,但与Compaq一起运行良好.我正在Windows 7 64位系统上编译32位..dll调用驱动程序是写入的C#.

_chkstk()当调用内部子例程(从.dll入口例程调用)时,失败消息来自可怕的调用.(SO回答chkstk())

有问题的程序被声明为(原谅固定文件格式)

  SUBROUTINE SRF(den, crpm, icrpm, inose, qeff, rev,  
 &               qqmax, lvtyp1, lvtyp2, avespd, fridry, luin,  
 &               luout, lurtpo, ludiag, ndiag, n, nzdepth, 
 &               unit, unito, ier)

  INTEGER*4 lvtyp1, lvtyp2, luin, luout, lurtpo, ludiag, ndiag, n, 
 &          ncp, inose, icrpm, ier, nzdepth
  REAL*8    den, crpm, qeff, rev, qqmax, avespd, fridry           
  CHARACTER*2  unit, unito
Run Code Online (Sandbox Code Playgroud)

并像这样调用:

      CALL SRF(den, crpm(i), i, inose, qeff(i), rev(i),  
 &             qqmax(i), lvtyp1, lvtyp2, …
Run Code Online (Sandbox Code Playgroud)

fortran arguments intel-fortran

6
推荐指数
1
解决办法
1517
查看次数

使用ifort进行数组复制的程序崩溃

该程序Illegal instruction: 4在MacOSX Lion和ifort(IFORT)12.1.0 20111011上崩溃

program foo
      real, pointer :: a(:,:), b(:,:)
      allocate(a(5400, 5400))
      allocate(b(5400, 3600))
      a=1.0
      b(:, 1:3600) = a(:, 1:3600)

      print *, a
      print *, b

      deallocate(a)
      deallocate(b)

end program 
Run Code Online (Sandbox Code Playgroud)

同一个程序与gfortran一起使用.我没有看到任何问题.有任何想法吗 ?展开副本并在列上执行显式循环适用于两个编译器.

请注意,使用allocatable而不是指针我没有问题.

如果语句在模块内部,则行为相同.我在ifort(IFORT)12.1.3 20120130上确认了相同的行为.

显然,Linux和ifort 12.1.5没有问题

我尝试使用以下链接选项增加堆栈大小

ifort -Wl,-stack_size,0x40000000,-stack_addr,0xf0000000 test.f90

但我仍然得到同样的错误.增加ulimit -s到同样的问题.

编辑2:我做了一些调试,显然当数组拼接操作时会出现问题

      b(:, 1:3600) = a(:, 1:3600)
Run Code Online (Sandbox Code Playgroud)

涉及可疑接近16 M数据的值.

我正在比较所产生的操作码,但如果有办法看到更具交际性的中间代码形式,我很乐意欣赏它.

fortran fortran95 intel-fortran

6
推荐指数
2
解决办法
2311
查看次数

在Fortran中将逻辑类型转换为double

我正在寻找一种将逻辑类型变量转换为真实类型的防弹方式,这种方式可以在ifort和gfortran中使用.以下适用于ifort,但不适用于gfortran:

logical :: a
real :: b
a = .true.
b = dble(a)
Run Code Online (Sandbox Code Playgroud)

gfortran中抛出的错误是

b = dble(a)
         1
Error: 'a' argument of 'dble' intrinsic at (1) must be a numeric type
Run Code Online (Sandbox Code Playgroud)

显然,.true.应映射到1.d0和.false.到0.d0.这样做的最佳方法是什么?

fortran gfortran intel-fortran

6
推荐指数
2
解决办法
5004
查看次数

使用英特尔Fortran编译器的f2py

我试图使用f2py将我的python程序与我的Fortran模块连接起来.

我在Win7平台上.

我使用最新的Anaconda 64(1.7)作为Python + NumPy堆栈.

My Fortran编译器是最新的Intel Fortran编译器64(版本14.0.0.103 Build 20130728).

我在执行时遇到了很多问题 f2py -c -m PyModule FortranModule.f90 --fcompiler=intelvem

最后一个,我似乎无法理清的是,看起来像f2py/distutils传递给编译器的标志序列与ifort所期望的不匹配.

调用ifort时,我收到一系列有关未知选项的警告消息.

ifort: command line warning #10006: ignoring unknown option '/LC:\Anaconda\libs'
ifort: command line warning #10006: ignoring unknown option'/LC:\Anaconda\PCbuild\amd64'
ifort: command line warning #10006: ignoring unknown option '/lpython27'
Run Code Online (Sandbox Code Playgroud)

我怀疑这与我最后从链接器获得的错误有关

error LNK2019: unresolved external symbol __imp_PyImport_ImportModule referenced in function _import_array
error LNK2019... and so forth (there are about 30-40 lines like that, with different python modules missing)
Run Code Online (Sandbox Code Playgroud)

它的结论很简单

fatal error LNK1120: 42 unresolved …
Run Code Online (Sandbox Code Playgroud)

fortran distutils f2py python-2.7 intel-fortran

6
推荐指数
1
解决办法
2851
查看次数

纯函数指针

为了遍历Fortran中的链表,我使用指向当前元素的指针,该元素移动到循环内的下一个元素.尝试pure在对所述链表执行操作的函数内应用此操作会导致错误.

例:

module list
  implicit none

  ! Node
  type n_list
    integer               :: val
    type(n_list),pointer  :: next => NULL()
  end type

  ! Linked list
  type t_list
    type(n_list),pointer  :: head
  end type

contains

  pure function in_list( list, val ) result(res)
    implicit none
    class(t_list),intent(in)  :: list
    integer,intent(in)        :: val
    logical                   :: res
    type(n_list),pointer      :: cur

    res = .true.
    ! Traverse the list
    cur => list%head
    do while ( associated(cur) )
      if ( cur%val == val ) return 
      cur => cur%next
    enddo …
Run Code Online (Sandbox Code Playgroud)

fortran gfortran intel-fortran

6
推荐指数
3
解决办法
532
查看次数

阅读写作fortran使用不同的编译器直接访问未格式化的文件

我在一个程序中有一节写入直接访问二进制文件,如下所示:

open (53, file=filename, form='unformatted', status='unknown',
& access='direct',action='write',recl=320*385*8)
write (53,rec=1) ulat
write (53,rec=2) ulng
close(53)
Run Code Online (Sandbox Code Playgroud)

该程序使用ifort编译.但是,如果我从使用gfortran编译的其他程序中读取数据文件,则无法正确重建数据.如果读取数据的程序也在ifort中编译,那么我可以正确地重建数据.这是读取数据文件的代码:

OPEN(53, FILE=fname, form="unformatted", status="unknown", access="direct", action="read", recl=320*385*8)
READ(53,REC=2) DAT
Run Code Online (Sandbox Code Playgroud)

我不明白为什么会这样?我可以用两个编译器正确读取第一条记录,这是我混合编译器时无法正确重建的第二条记录.

fortran binaryfiles gfortran intel-fortran

6
推荐指数
1
解决办法
6543
查看次数

导致错误的预处理器警告的常见原因

我不熟悉导致以下警告的原因:

warning #5117: Bad # preprocessor line
#include "rtt_alloc_rad.interface"
Run Code Online (Sandbox Code Playgroud)

我已经看过一些明显的问题,比如#include左边是红色的.我想知道在哪里寻找可能的原因的一些提示.

我正在使用英特尔编译器:ifort版本15.0.1

该代码具有与外部库相关联的大型气候模型.很难知道要发布什么,但警告来自以下代码段:

MODULE rtt_interface

use rtt_types,    only : rtt_options, rtt_coefs, profile_Type, &
transmission_Type, radiance_Type,rtt_coef_scatt_ir,rtt_optpar_ir, &       
rtt_chanprof, rtt_emissivity, rtt_reflectance
use rtt_const,    only : errorstatus_success, errorstatus_fatal, & 
platform_name,inst_name
use rtt_unix_env, only : rtt_exit
use cosp_kinds,     only : wp,wi,wl

IMPLICIT NONE

real(wp), parameter :: tmin_baran = 193.1571_wp  

#include "rtt_alloc_rad.interface" 
#include "rtt_alloc_transmission.interface"
#include "rtt_alloc_prof.interface"
#include "rtt_dealloc_coefs.interface"
#include "rtt_direct.interface"
#include "rtt_print_opts.interface"

! snip...

END MODULE rtt_interface
Run Code Online (Sandbox Code Playgroud)

我用标志编译: f90flags=-g -fp-model precise -traceback -r8 -O0

fortran fortran90 intel-fortran

6
推荐指数
1
解决办法
2954
查看次数

Linux Fortran OpenMP - 从 OpenMP 任务调用的子例程访问全局变量

从 OpenMP 任务调用的内部子例程访问程序全局变量是否合法/有效?

ifort 2021.7.0 20220726 不会报告错误,但似乎会根据编译器选项产生随机结果。例子:

program test1
  implicit none
  integer :: i, j, g
  g = 42
  !$OMP PARALLEL DEFAULT(SHARED)
     !$OMP SINGLE
        i = 0
        j = 1
        do while (j < 60)
           i = i + 1
           !$OMP TASK DEFAULT(SHARED) FIRSTPRIVATE(i,j)
              call sub(i,j)
           !$OMP END TASK
           j = j + j
        end do
     !$OMP END SINGLE
  !$OMP END PARALLEL
  stop

contains

  subroutine sub(i,j)
    implicit none
    integer i,j
    !$OMP CRITICAL(unit6)
       write(6,*) i,j,g
    !$OMP END CRITICAL(unit6)
  end subroutine sub …
Run Code Online (Sandbox Code Playgroud)

linux fortran openmp intel-fortran

6
推荐指数
1
解决办法
307
查看次数