Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/fortran/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
包含IEEE_GET_ROUNDING_模式的库的gfortran链接器参数_Fortran_Gfortran - Fatal编程技术网

包含IEEE_GET_ROUNDING_模式的库的gfortran链接器参数

包含IEEE_GET_ROUNDING_模式的库的gfortran链接器参数,fortran,gfortran,Fortran,Gfortran,作为练习,我正在尝试为区间算术编写一个简单的Fortran库。我想显式地设置舍入模式,做一些工作,然后将舍入模式恢复到原来的状态。但是,当使用gfortran,gcc的Fortran前端进行编译时,我无法确定哪个库需要链接到生成的可执行文件 ! get_rounding_mode.f03 ! print the rounding mode program get_rounding_mode f = IEEE_GET_ROUNDING_MODE() print *,f end progr

作为练习,我正在尝试为区间算术编写一个简单的Fortran库。我想显式地设置舍入模式,做一些工作,然后将舍入模式恢复到原来的状态。但是,当使用
gfortran
gcc
的Fortran前端进行编译时,我无法确定哪个库需要链接到生成的可执行文件

! get_rounding_mode.f03
! print the rounding mode

program get_rounding_mode
  f = IEEE_GET_ROUNDING_MODE()
  print *,f
end program get_rounding_mode
试着做一件最简单的可能奏效的事情会让我

gfortran get_rounding_mode.f03 
/usr/bin/ld: /tmp/ccTLaxeN.o: in function `MAIN__':
get_rounding_mode.f03:(.text+0x20): undefined reference to `ieee_get_rounding_mode_'
collect2: error: ld returned 1 exit status
Exit 1
通过到处寻找ieee\u get\u rounding我找到了它,但我不知道如何引导
gfortran
链接它,因为它似乎已经在
libgfortran
中了

find /usr/ -exec nm --print-file-name '{}' '+' 2>&1 | grep 'ieee_get_rounding'
/usr/lib/libgfortran.so.5:000000000023edc0 T __ieee_arithmetic_MOD_ieee_get_rounding_mode
/usr/lib/libgfortran.so:000000000023edc0 T __ieee_arithmetic_MOD_ieee_get_rounding_mode

IEEE\u获取\u舍入\u模式
不是一个函数。它是一个子程序。你需要像这样做

program get_rounding_mode
   use ieee_arithmetic
   implicit none
   ieee_rounding_type mode
   real x
   if (ieee_support_rounding(x)) then
      call ieee_get_rounding_mode(mode)       ! Get current rounding mode
      call ieee_set_rounding_mode(IEEE_TO_UP) ! Set rounding up
      !
      ! Do your work here!
      !
      call ieee_set_rounding_mode(mode)       ! Reset rounding mode
   end if
 end program get_rounding_mode

哎哟,忘了
隐式无
x

的声明了吗?您是否提醒
使用相应的
?如果我
使用IEEE\u算术
,错误会变为
在(1)处意外使用子程序名称“IEEE\u获取\u舍入\u模式”
。。。我认为这意味着我使用的[function]/[constant]/[macro]/[任何类型的实体
IEEE\u GET\u ROUNDING\u MODE
都不正确。我认为
libc
中的
fegetround
符合我的要求。您知道如何在
libc
中定义gfortran曲面函数吗?