@@ -8,7 +8,8 @@ module m_result_gen
88 private
99
1010 integer , parameter , public :: T_NONE = 0 , T_CLAIM = - 1 , &
11- T_INT = 1 , T_DP = 2 , T_ERR = 3
11+ T_INT = 1 , T_DP = 2 , T_ARR_INT = 3 , &
12+ T_ERR = 99
1213
1314 type, public :: ResultGen
1415
@@ -17,11 +18,15 @@ module m_result_gen
1718
1819 integer (kind= i8) :: data_int
1920 real (kind= dp) :: data_dp
21+ integer (kind= i8), allocatable :: data_array_int_1d(:), &
22+ data_array_int_2d(:,:), &
23+ data_array_int_3d(:,:,:)
2024 contains
2125 procedure :: is_free = > is_none
2226 procedure :: is_error
2327 procedure :: is_int
2428 procedure :: is_dp
29+ procedure :: is_arr_int
2530 procedure :: build
2631 procedure :: finalise
2732 final :: finalise_auto
@@ -33,19 +38,20 @@ module m_result_gen
3338
3439contains
3540! ------------------ Constructor -------------------------
36- function constructor (tag ,data_int ,data_dp ,error_v ) result(self)
41+ function constructor (tag ,data_int ,data_dp ,data_arr_int , error_v ) result(self)
3742
3843 type (ResultGen) :: self
3944 type (ResultGen) :: res_check
4045
4146 integer (kind= i8), optional , intent (in ) :: data_int
4247 real (kind= dp), optional , intent (in ) :: data_dp
48+ integer (kind= i8), optional , intent (in ) :: data_arr_int(..)
4349 type (ErrorV), optional , intent (in ) :: error_v
4450
4551 integer , intent (in ) :: tag
4652 integer :: cause
4753
48- call self % build (tag = tag, data_int = data_int, data_dp = data_dp,&
54+ call self % build (tag = tag, data_int = data_int, data_dp = data_dp, data_arr_int = data_arr_int, &
4955 error_v = error_v, res= res_check)
5056
5157 if (res_check % is_error()) then
@@ -67,24 +73,29 @@ function constructor(tag,data_int,data_dp,error_v) result(self)
6773 end function constructor
6874
6975! ------------------ Setter -------------------------
70- subroutine build (self ,tag ,data_int ,data_dp ,error_v ,res )
76+ subroutine build (self ,tag ,data_int ,data_dp ,data_arr_int , error_v ,res )
7177
7278 class(ResultGen),intent (out ) :: self
7379 type (ResultGen),intent (out ), optional :: res
7480
7581 type (ErrorV), intent (in ), optional :: error_v
7682 real (kind= dp), intent (in ), optional :: data_dp
7783 integer (kind= i8), intent (in ), optional :: data_int
84+ integer (kind= i8), intent (in ), optional :: data_arr_int(..)
7885 integer , intent (in ) :: tag
7986
8087 self % tag = tag
8188
8289 if (tag == T_CLAIM) then
90+ ! MZ: makes sense?
8391 return
8492 else if (present (data_int) .and. tag == T_INT) then
8593 self % data_int = data_int
8694 else if (present (data_dp) .and. tag == T_DP)then
8795 self % data_dp = data_dp
96+ else if (present (data_arr_int) .and. tag == T_ARR_INT)then
97+ call ship_to_int_array(self, data_arr_int)
98+ self % tag = tag
8899 else if (present (error_v) .and. tag == T_ERR)then
89100 allocate (self % error_v, source = error_v)
90101 else
@@ -95,13 +106,44 @@ subroutine build(self,tag,data_int,data_dp,error_v,res)
95106
96107 end subroutine build
97108
109+ subroutine ship_to_int_array (self , data_arr_int )
110+
111+ class(ResultGen), intent (inout ) :: self
112+ integer (kind= i8), intent (in ) :: data_arr_int(..)
113+
114+ select rank(data_arr_int)
115+ rank (1 )
116+ allocate (self % data_array_int_1d(size (data_arr_int, 1 )), &
117+ source = data_arr_int &
118+ )
119+
120+ rank (2 )
121+ allocate (self % data_array_int_2d(size (data_arr_int, 1 ), size (data_arr_int, 2 )), &
122+ source = data_arr_int &
123+ )
124+
125+ rank (3 )
126+ allocate (self % data_array_int_3d(size (data_arr_int, 1 ), size (data_arr_int, 2 ), size (data_arr_int, 3 )), &
127+ source = data_arr_int &
128+ )
129+
130+ rank default
131+ print * , " ERRRORORORORO"
132+ end select
133+
134+ end subroutine ship_to_int_array
135+
98136! ------------------ Destructor -------------------------
99137
100138 subroutine finalise (self )
101139
102140 class(ResultGen),intent (inout ) :: self
103141
104142 self% tag = T_NONE
143+ if (allocated (self % data_array_int_1d)) deallocate (self% data_array_int_1d)
144+ if (allocated (self % data_array_int_2d)) deallocate (self% data_array_int_2d)
145+ if (allocated (self % data_array_int_3d)) deallocate (self% data_array_int_3d)
146+
105147 if (allocated (self % error_v)) deallocate (self % error_v)
106148
107149 end subroutine finalise
@@ -152,6 +194,13 @@ pure logical function is_dp(self)
152194
153195 end function is_dp
154196
197+ pure logical function is_arr_int(self)
198+
199+ class(ResultGen), intent (in ) :: self
200+
201+ is_arr_int = (self % tag == T_ARR_INT)
202+
203+ end function is_arr_int
155204! ------------------ Getter -------------------------
156205 !
157206 ! pure function get_int(self) result(data_int)
0 commit comments