小编rob*_*sta的帖子

如何为'allocate'编写包装器

我正在尝试为'allocate'函数编写一个包装器,即接收数组和维度的函数,分配内存并返回已分配的数组.最重要的是该函数必须使用不同级别的数组.但是我必须在函数接口中明确声明数组的等级,在这种情况下,如果我将某个等级的数组作为参数传递,代码只会编译.例如,此代码无法编译:

module memory_allocator
contains 

  subroutine memory(array, length)
    implicit none

    real(8), allocatable, intent(out), dimension(:) :: array
    integer, intent(in) :: length

    integer :: ierr

    print *, "memory: before: ", allocated(array)

    allocate(array(length), stat=ierr)
    if (ierr /= 0) then
      print *, "error allocating memory: ierr=", ierr
    end if

    print *, "memory: after: ", allocated(array)

  end subroutine memory

  subroutine freem(array)
    implicit none

    real(8), allocatable, dimension(:) :: array

    print *, "freem: before: ", allocated(array)
    deallocate(array)
    print *, "freem: after: ", allocated(array)

  end subroutine freem

end module …
Run Code Online (Sandbox Code Playgroud)

fortran

8
推荐指数
1
解决办法
3590
查看次数

从PHP调用外部库.什么是更快:执行或扩展?

我需要从网页调用用C++编写的外部库并显示结果.平台是Linux,Apache,PHP.

我目前的想法是使用PHP服务,它将调用我的库/程序.我发现有两种可能的方法可以做到这一点:1)使用PHP'exec'函数2)编写PHP扩展

我好奇什么效果更好?快点?减少加载服务器?

我可能需要每秒进行4次调用,所以我希望尽可能优化.

PS如果您了解从网页调用C++库或程序的其他(更有效)方法,请告诉我.

非常感谢,
罗布斯塔

php web-applications php-extension

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

标签 统计

fortran ×1

php ×1

php-extension ×1

web-applications ×1