forrtl:警告(402):要塞:(1) [英] forrtl: warning (402): fort: (1)

查看:564
本文介绍了forrtl:警告(402):要塞:(1)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在运行时获取以下警告:

i get the following warning at runtime:

...
forrtl: warning (402): fort: (1): In call to I/O Write routine, an array temporary was created for argument #2

forrtl: warning (402): fort: (1): In call to I/O Write routine, an array temporary was created for argument #3

forrtl: warning (402): fort: (1): In call to GERADHEIT_LINIAL, an array temporary was created for argument #2

forrtl: warning (402): fort: (1): In call to GERADHEIT_LINIAL, an array temporary was created for argument #3
...   

有关子程序/写声明的每一个电话。

for every call of the subroutine / write statement.

子程序调用:

integer :: l,kreise
character(*)::setname
real(8),diemnsion(:,:,:),allocatable::stripe
integer,dimension(:)s(j)

...code and allocation of arrays...
 do j=n(1)
   call geradheit_linial (s(j),stripe(j,1:s(j),1),
&                       stripe(j,1:s(j),2),setname)
 end do

...

subroutine geradheit_linial (ndaten,x,r,setname)
  implicit none
  integer,intent(in) :: ndaten
  real(8),dimension(ndaten),intent(in)  :: x,r
  character(*),intent(in) :: setname   

和写语句:

    write(91,*)'Gerade: ',gerade(maxloc(reslt(1:i)),minsumloc,1),
&               gerade(maxloc(reslt(1:i)),minsumloc,2)

阵列条纹被分配有预期每个维的最大值,所以大部分的时间仅一个子集是通过呼叫传递。

The array stripe is allocated with the maximum value expected for each dimension, so most of the time only a subset is passed through the call.

据我的理解,它是不是真的在精度方面存在问题,而是可以在程序中,因此很多写作的RAM完成放缓。因此,有多少它减慢我的计算(条纹可具有大约条纹尺寸(100,300,3)和可以得到更大的晚些时候)?我怎么能避免这种额外的阵列?

As far as i understand, it isn't really a problem in terms of accuracy but may slow down the program, hence a lot of writing to the RAM is done. So how much does it slow down my computation (stripe may have a dimension of about stripe(100,300,3) and could get bigger sometime later)? And how can i avoid such extra arrays?.

推荐答案

我认为你收到此警告,因为子程序正在通过非连续的数组段,编译器已决定子程序应该得到一个连续的临时数组含必要的值。我期望子程序code被写入阵列中的条款和隐含的假设,正如我们在Fortran编程的时候总是这样,它是连续的。

I think that you are getting this warning because the subroutines are being passed non-contiguous array sections and the compiler has decided that the subroutine should get a contiguous temporary array containing the necessary values. I expect that the subroutine code is written in terms of an array and implicitly assumes, as we always do when programming in Fortran, that it is contiguous.

如果我看了你的code正确,编译器理解这句话

If I read your code correctly the compiler understands this statement

stripe(j,1:s(j),1)

来表示(因为它是)

to mean (as it were)

stripe(j,1,1)
stripe(j,2,1)
stripe(j,3,1)
...

一直以来,我希望你知道,Fortran数组存储与第一索引值通过内存变化最为迅速,您的数组段的进步。

Since, as I expect that you are aware, Fortran arrays are stored with the first index value changing most rapidly, your array section strides through memory.

您可以共进晚餐preSS使用编译器选项 noarg_temp_created 警告。请注意,这只做SUP preSS警告(这可能保存的程序的运行时间,我想一个smidgeon),它不会影响编译器做什么的,临时的阵列仍将被创建。

You could suppress the warning with the compiler option noarg_temp_created. Note that this does only suppress the warning (which might save a smidgeon of the program's run time I suppose), it does not affect what the compiler does, the temporary arrays will still be created.

您可以写code创建包含部分临时数组来传递给子程序。我看不出做这么多的优势;我期望编译器发出code性能优于任何code你写这样一个简单的操作。

You could write code to create temporary arrays containing the section to be passed to the subroutine. I don't see much advantage in doing this; I'd expect the compiler to issue code that outperforms any code you write for such a straightforward operation.

或者你可以重塑/重排的原始数组一次,开始调用子程序,并给它正确的形状,并安排到切片连续的块之前。然后unpermute / unreshape在所有呼叫的结束。

Or you could reshape / permute your original array once, before starting to call the subroutine, and give it the right shape and arrangement for slicing into contiguous blocks. And then unpermute / unreshape at the end of all the calls.

的唯一确凿的方式来回答你的问题你目前的code的相对性能和任何其他的配方是code起来,并拿出你的秒表。

The only conclusive way to answer your question about the relative performance of your current code and any alternative formulations is to code them up and get out your stopwatch.

这篇关于forrtl:警告(402):要塞:(1)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆