|
[Fortran] 纯文本查看 复制代码 08 | type , abstract :: int_ary |
10 | integer , allocatable :: iAry ( : ) |
12 | procedure ( strategy_procedure ) , deferred , pass :: SRead_int_ary |
16 | subroutine strategy_procedure ( this , iunit ) |
19 | class ( int_ary ) , intent ( inout ) :: this |
20 | integer , intent ( in ) :: iunit |
21 | end subroutine strategy_procedure |
25 | type , extends ( int_ary ) :: int_ary_ 2 P |
26 | character ( len = 2 ) , allocatable :: CAry ( : ) |
28 | procedure , pass :: SRead_int_ary = > SRead_int_ary_ 2 p |
32 | type , extends ( int_ary ) :: int_ary_ 3 P |
33 | character ( len = 3 ) , allocatable :: CAry ( : ) |
35 | procedure , pass :: SRead_int_ary = > SRead_int_ary_ 3 p |
40 | Subroutine SRead_int_ary_ 2 p ( this , iunit ) |
42 | class ( int_ary_ 2 P ) , intent ( inout ) :: this |
43 | integer , intent ( in ) :: iunit |
44 | read ( iunit , * ) this % iNs |
45 | allocate ( this % iAry ( this % iNs ) ) |
46 | read ( iunit , * ) this % iAry |
47 | allocate ( this % CAry ( this % iNs ) ) |
48 | call SInt_to_ 2 Char ( this % iAry , this % CAry ) |
52 | Subroutine SRead_int_ary_ 3 p ( this , iunit ) |
54 | class ( int_ary_ 3 P ) , intent ( inout ) :: this |
55 | integer , intent ( in ) :: iunit |
56 | read ( iunit , * ) this % iNs |
57 | allocate ( this % iAry ( this % iNs ) ) |
58 | read ( iunit , * ) this % iAry |
59 | allocate ( this % CAry ( this % iNs ) ) |
60 | call SInt_to_ 3 Char ( this % iAry , this % CAry ) |
这段代码中的
read(iunit,*) this%iNs
allocate(this%iAry(this%iNs))
read(iunit,*) this%iAry
allocate(this%CAry(this%iNs))
每次都是重复的吗,能提炼出来,抽象成一个函数吗
|
|