-
0 votesanswersviews
在每个数据类型实例中复制过程
当我们从具有传递过程指针的数据类型(类)创建多个实例时,是否在每个实例中复制了实际过程(子例程/函数)?或只是复制指针? 例如,请考虑以下编译和运行正确的代码 . module mod2 implicit none private type class_type integer :: a, b, c contains procedure :: add =&... -
13 votesanswersviews
Fortran派生类型赋值
假设我有一个Fortran派生类型 type :: atype integer :: n integer :: a(10) integer, allocatable :: b(:) end type 我有两个这种类型的实例 type(atype) :: t1, t2 当我做以下任务时到底发生了什么? t2 = t1 我对此感兴趣因为我想正确地创建派生类型变量的副本意... -
2 votesanswersviews
当我使用自动重新分配时,派生类型的可分配组件会发生什么?
在我的程序中,我想创建一个容器类型,包含某个派生类型的数组 . 我想为容器添加类型绑定过程,它调用数组的所有组件上的过程 . 由于数组的大小不同,我尝试使用自动重新分配功能 . 我遇到了可分配字符的问题 . 这是一个小片段,显示设置: module realloc_test ... -
1 votesanswersviews
fortran中与类型无关的内存重新分配
我尝试构建一个子例程来为类型无关的可分配数组重新分配内存,如下所示: subroutine reallocate(vector, num) implicit none class(*), dimension(:), allocatable, intent(inout) :: vector integer :: num class(*), dimension(:), allocatable :: ... -
1 votesanswersviews
使用gdb在Fortran中打印可分配数组:未处理的矮化表达式操作码0x97 [重复]
这个问题在这里已有答案: Fortran print allocatable array in gdb 3个答案 我使用gdb作为调试器在Cygwin和Eclipse中调试了以下代码: program codetest implicit none integer, parameter :: dp = kind(1.0d0) integer, parameter :: ... -
3 votesanswersviews
为了在超出范围的可分配数组的元素上调用,终结例程是否需要是元素的?
如果我有一个可终结的派生类型的可分配数组,当数组超出范围时,是否会在每个单独的元素上调用终结器? 这是一个小代码示例,说明了这个问题: module LeakyTypeModule implicit none private type, public :: LeakyType real, pointer :: dontLeakMe(:) => null() ...