本帖最后由 安靖 于 2015-5-22 20:59 编辑
用gdb调试Fortran程序,如何查看派生类型数据?
例如,查看ndim就可以直接输入: p data%ndim但是要查看coorn里的数据是什么命令呢? coorn是动态分配的数组
我输入 p data%coorn 提示 =<object is not allocated>
但是coorn明明已经分配好内存了
[Fortran] 纯文本查看 复制代码
! test2.f90
program main
use comm_data
implicit none
type(core_data) :: data
call allo_core_data( data, 2, 4)
data % coorn = 4.0
write(*,*) data % coorn
stop
end program main
! comm_data.f90
module comm_data
implicit none
save
type core_data
integer ndim
integer npoint
real, allocatable, dimension(:,:) :: coorn
end type core_data
contains
subroutine allo_core_data( data, ndim, npoint )
implicit none
type(core_data), intent(out) :: data
integer, intent(in) :: npoint
integer, intent(in) :: ndim
data % ndim = ndim
data % npoint = npoint
allocate( data % coorn( data % ndim, data % npoint ) )
data % coorn = 0.0
end subroutine allo_core_data
end module comm_data
makefile
TARGET = test.out
GC = ifort
CFLAGS = -fpp -g
SOR = comm_data.f90 test2.f90
OBJS = test2.o comm_data.o
$(OBJS):
@echo "-----------------------------------"
@echo "Compiling..."
@echo "-----------------------------------"
@$(GC) $(CFLAGS) -c $(SOR) $(INCLUDE)
@echo "-----------------------------------"
@echo "Linking..."
@echo "-----------------------------------"
@$(GC) $(CFLAGS) -o $(TARGET) $(OBJS) $(LIBS)
@echo "-----------------------------------"
@echo "Deleting OBJ & MOD files..."
@echo "-----------------------------------"
@rm -fr *.o
@echo "-----------------------------------"
clean:
@rm -fr *.o *.mod
@rm -fr $(TARGET)
|