Goddard-Fortran-Ecosystem / gFTL

Software containers for Fortran
Apache License 2.0
41 stars 10 forks source link

[V2] Vector initialisation from array of elements #238

Closed EmilyBourne closed 2 weeks ago

EmilyBourne commented 1 month ago

According to the documentation it should be possible to create a Vector from an array of elements. However I cannot get a MRE to work. My code is:

module Vector_integer_mod

#define T integer
#define Vector Vector_integer
#define VectorIterator Vector_integer_Iterator
#include <vector/template.inc>

end module Vector_integer_mod
program test_program
  use Vector_integer_mod

  implicit none

  type(Vector_integer) :: b

  b = Vector_integer([1_i64, 2_i64, 3_i64])

end program test_program

I also tried:

program test_program
  use Vector_integer_mod

  implicit none

  integer :: a(3)
  type(Vector_integer) :: b

  a = [1_i64, 2_i64, 3_i64]
  b = Vector_integer(a)

end program test_program

In both cases I get the error:


   11 |   b = Vector_integer([1_i64, 2_i64, 3_i64])
      |       1
Error: Component ‘elements’ at (1) is a PRIVATE component of ‘vector_integer’

I don't know if I am using the function wrong or if this is simply a bug. I could not find a test for this function here.

Compiler: GNU Fortran 11.4.0 OS: Ubuntu 22.04

tclune commented 1 month ago

At first glance this seems to just be a kind mismatch. You have defined the vector using default integers (usually this is INT32), but your attempt to use the container is with INT64. Your example programs do not actually define a value of i64 so presumably do not compile as written above.

tclune commented 1 month ago

If my analysis is correct then you should either change the declaration of T to be:

#define T integer(i64)

or change the usage to be

a = [1,2,3]
tclune commented 1 month ago

Ah - another problem may be that you have not indicated to the templating layer that your type has certain necessary properties (listable) to be used in your context. There is special support for intrinsics to spare you the details:

Either use:

#define T __INTEGER

or

#define T __INTEGER64
EmilyBourne commented 1 month ago

Thank you very much for the speedy reply. By changing the usage to:

a = [1,2,3]

I get the linker error:

test_program.F90:(.text+0x16f): undefined reference to `__vector_integer_mod_MOD_vector_new_vector_initializer_list'

which is presumably due to the fact that I haven't indicated to the templating layer that the type is listable.

I also tried:

#define T integer(8)

however I couldn't get this to compile. The error is:

/home/emily/Code/pyccel/pyccel/extensions/gFTL/include/v2/parameters/define_derived_macros.m4:64:0:

   64 | #if __T() > 0
      | 
Error: missing binary operator before token "("
/home/emily/Code/pyccel/pyccel/extensions/gFTL/include/v2/parameters/define_derived_macros.m4:64:0:

   64 | #if __T() > 0
      | 
Error: missing binary operator before token "("
/home/emily/Code/pyccel/pyccel/extensions/gFTL/include/v2/parameters/define_derived_macros.m4:64:0:

   64 | #if __T() > 0
      | 
Error: missing binary operator before token "("
/home/emily/Code/pyccel/pyccel/extensions/gFTL/include/v2/parameters/define_derived_macros.m4:64:0:

   64 | #if __T() > 0
      | 
Error: missing binary operator before token "("

I also didn't manage to use the intrinsics. Using #define T __INTEGER64 I get quite a long error message.

``` gFTL/vector/specification.inc:45:24: 45 | __T_declare_component__ :: item | 1 Error: Symbol ‘int64’ at (1) has no IMPLICIT type gFTL/vector/procedures.inc:50:24: 50 | __T_declare_dummy__, optional, intent(in) :: value | 1 Error: Symbol ‘int64’ at (1) has no IMPLICIT type gFTL/vector/procedures.inc:61:24: 61 | __T_declare_dummy__, optional, intent(in) :: value | 1 Error: Symbol ‘int64’ at (1) has no IMPLICIT type gFTL/vector/procedures.inc:103:24: 103 | __T_declare_dummy__, dimension(:), intent(in) :: il ! initializer list | 1 Error: Symbol ‘int64’ at (1) has no IMPLICIT type gFTL/vector/procedures.inc:109:28: 109 | __T_COPY__(v%elements(i)%item, il(i)) | 1 Error: ‘item’ at (1) is not a member of the ‘vector_wrapper’ structure gFTL/vector/procedures.inc:179:24: 179 | __T_declare_result__, pointer :: res | 1 Error: Symbol ‘int64’ at (1) has no IMPLICIT type gFTL/vector/procedures.inc:175:56: 175 | function __MANGLE(at_size_kind)(this, i, rc) result(res) | 1 Error: Function result ‘res’ at (1) has no IMPLICIT type gFTL/vector/procedures.inc:189:39: 189 | res => this%elements(idx)%item | 1 Error: ‘item’ at (1) is not a member of the ‘vector_wrapper’ structure gFTL/vector/procedures.inc:199:24: 199 | __T_declare_result__, pointer :: res | 1 Error: Symbol ‘int64’ at (1) has no IMPLICIT type gFTL/vector/procedures.inc:196:54: 196 | function __MANGLE(at_default)(this, i, rc) result(res) | 1 Error: Function result ‘res’ at (1) has no IMPLICIT type gFTL/vector/procedures.inc:214:39: 214 | res => this%elements(idx)%item | 1 Error: ‘item’ at (1) is not a member of the ‘vector_wrapper’ structure gFTL/vector/procedures.inc:227:24: 227 | __T_declare_result__, pointer :: res | 1 Error: Symbol ‘int64’ at (1) has no IMPLICIT type gFTL/vector/procedures.inc:229:34: 229 | res => this%elements(i)%item | 1 Error: ‘item’ at (1) is not a member of the ‘vector_wrapper’ structure gFTL/vector/procedures.inc:224:52: 224 | function __MANGLE(of_size_kind)(this, i) result(res) | 1 Error: Function result ‘res’ at (1) has no IMPLICIT type gFTL/vector/procedures.inc:237:24: 237 | __T_declare_result__, pointer :: res | 1 Error: Symbol ‘int64’ at (1) has no IMPLICIT type gFTL/vector/procedures.inc:239:34: 239 | res => this%elements(i)%item | 1 Error: ‘item’ at (1) is not a member of the ‘vector_wrapper’ structure gFTL/vector/procedures.inc:234:50: 234 | function __MANGLE(of_default)(this, i) result(res) | 1 Error: Function result ‘res’ at (1) has no IMPLICIT type gFTL/vector/procedures.inc:251:24: 251 | __T_declare_component__, dimension(:), pointer :: res | 1 Error: Symbol ‘int64’ at (1) has no IMPLICIT type gFTL/vector/procedures.inc:254:44: 254 | res => this%elements(:this%vsize)%item | 1 Error: ‘item’ at (1) is not a member of the ‘vector_wrapper’ structure gFTL/vector/procedures.inc:249:41: 249 | function __MANGLE(data)(this) result(res) | 1 Error: Function result ‘res’ at (1) has no IMPLICIT type gFTL/vector/procedures.inc:265:24: 265 | __T_declare_result__, pointer :: res | 1 Error: Symbol ‘int64’ at (1) has no IMPLICIT type gFTL/vector/procedures.inc:267:43: 267 | res => this%elements(this%vsize)%item | 1 Error: ‘item’ at (1) is not a member of the ‘vector_wrapper’ structure gFTL/vector/procedures.inc:263:41: 263 | function __MANGLE(back)(this) result(res) | 1 Error: Function result ‘res’ at (1) has no IMPLICIT type gFTL/vector/procedures.inc:277:24: 277 | __T_declare_result__, pointer :: res | 1 Error: Symbol ‘int64’ at (1) has no IMPLICIT type gFTL/vector/procedures.inc:279:34: 279 | res => this%elements(1)%item | 1 Error: ‘item’ at (1) is not a member of the ‘vector_wrapper’ structure gFTL/vector/procedures.inc:275:42: 275 | function __MANGLE(front)(this) result(res) | 1 Error: Function result ‘res’ at (1) has no IMPLICIT type gFTL/vector/procedures.inc:293:24: 293 | __T_declare_dummy__, intent(in) :: value | 1 Error: Symbol ‘int64’ at (1) has no IMPLICIT type gFTL/vector/procedures.inc:306:30: 306 | __T_COPY__(this%elements(idx)%item, value) | 1 Error: ‘item’ at (1) is not a member of the ‘vector_wrapper’ structure gFTL/vector/procedures.inc:315:24: 315 | __T_declare_dummy__, intent(in) :: value | 1 Error: Symbol ‘int64’ at (1) has no IMPLICIT type gFTL/vector/procedures.inc:329:24: 329 | __T_declare_dummy__, intent(in) :: value | 1 Error: Symbol ‘int64’ at (1) has no IMPLICIT type gFTL/vector/procedures.inc:340:24: 340 | __T_declare_dummy__, intent(in) :: value | 1 Error: Symbol ‘int64’ at (1) has no IMPLICIT type gFTL/vector/procedures.inc:347:37: 347 | __T_MOVE__(this%elements(i+count)%item, this%elements(i)%item) | 1 Error: ‘item’ at (1) is not a member of the ‘vector_wrapper’ structure gFTL/vector/procedures.inc:351:31: 351 | __T_COPY__(this%elements(j)%item, value) | 1 Error: ‘item’ at (1) is not a member of the ‘vector_wrapper’ structure gFTL/vector/procedures.inc:366:24: 366 | __T_declare_dummy__, intent(in) :: value | 1 Error: Symbol ‘int64’ at (1) has no IMPLICIT type gFTL/vector/procedures.inc:379:24: 379 | __T_declare_dummy__, intent(in) :: value | 1 Error: Symbol ‘int64’ at (1) has no IMPLICIT type gFTL/vector/procedures.inc:388:33: 388 | __T_MOVE__(this%elements(i+n)%item, this%elements(i)%item) | 1 Error: ‘item’ at (1) is not a member of the ‘vector_wrapper’ structure gFTL/vector/procedures.inc:392:51: 392 | __T_COPY__(this%elements(pos%current_index + i)%item, value) | 1 Error: ‘item’ at (1) is not a member of the ‘vector_wrapper’ structure gFTL/vector/procedures.inc:406:24: 406 | __T_declare_dummy__, intent(in) :: values(:) | 1 Error: Symbol ‘int64’ at (1) has no IMPLICIT type gFTL/vector/procedures.inc:414:33: 414 | __T_MOVE__(this%elements(i+n)%item, this%elements(i)%item) | 1 Error: ‘item’ at (1) is not a member of the ‘vector_wrapper’ structure gFTL/vector/procedures.inc:417:55: 417 | __T_COPY__(this%elements(pos%current_index + i - 1)%item, values(i)) | 1 Error: ‘item’ at (1) is not a member of the ‘vector_wrapper’ structure gFTL/vector/procedures.inc:446:24: 446 | __T_declare_component__, intent(in) :: array(:) | 1 Error: Symbol ‘int64’ at (1) has no IMPLICIT type gFTL/vector/procedures.inc:453:30: 453 | this%elements(1:n)%item = array(1:n) | 1 Error: ‘item’ at (1) is not a member of the ‘vector_wrapper’ structure gFTL/vector/procedures.inc:486:28: 486 | associate (l => lhs%elements(i)%item, r => rhs%elements(i)%item) | 1 Error: Invalid association target at (1) gFTL/vector/procedures.inc:491:15: 491 | end associate | 1 Error: Expecting END DO statement at (1) gFTL/vector/procedures.inc:541:24: 541 | __T_declare_result__, pointer :: lhs_i, rhs_i | 1 Error: Symbol ‘int64’ at (1) has no IMPLICIT type gFTL/vector/procedures.inc:606:24: 606 | __T_declare_dummy__, intent(in) :: value | 1 Error: Symbol ‘int64’ at (1) has no IMPLICIT type gFTL/vector/procedures.inc:640:24: 640 | __T_declare_dummy__, optional, intent(in) :: value | 1 Error: Symbol ‘int64’ at (1) has no IMPLICIT type gFTL/vector/procedures.inc:676:37: 676 | __T_COPY__(this%elements(i)%item, value) | 1 Error: ‘item’ at (1) is not a member of the ‘vector_wrapper’ structure gFTL/vector/procedures.inc:681:37: 681 | __T_COPY__(this%elements(i)%item, __T_default__) | 1 Error: ‘item’ at (1) is not a member of the ‘vector_wrapper’ structure gFTL/vector/procedures.inc:694:24: 694 | __T_declare_dummy__, optional, intent(in) :: value | 1 Error: Symbol ‘int64’ at (1) has no IMPLICIT type gFTL/vector/procedures.inc:782:18: 782 | __T_MOVE__(a%item, b%item) | 1 Error: ‘item’ at (1) is not a member of the ‘vector_wrapper’ structure gFTL/vector/procedures.inc:860:28: 860 | __T_MOVE__(temp(i)%item, this%elements(i)%item) | 1 Error: ‘item’ at (1) is not a member of the ‘vector_wrapper’ structure gFTL/vector/procedures.inc:915:27: 915 | __T_declare_dummy__, intent(in) :: value | 1 Error: Symbol ‘int64’ at (1) has no IMPLICIT type gFTL/vector/procedures.inc:920:28: 920 | associate (q => this%elements(i)%item) | 1 Error: Invalid association target at (1) gFTL/vector/procedures.inc:922:15: 922 | end associate | 1 Error: Expecting END DO statement at (1) gFTL/vector/iterator_procedures.inc:26:27: 26 | __T_declare_result__, pointer :: ptr | 1 Error: Symbol ‘int64’ at (1) has no IMPLICIT type gFTL/vector/iterator_procedures.inc:29:54: 29 | ptr => this%elements(this%current_index)%item | 1 Error: ‘item’ at (1) is not a member of the ‘vector_wrapper’ structure gFTL/vector/iterator_procedures.inc:35:27: 35 | __T_declare_result__, pointer :: ptr | 1 Error: Symbol ‘int64’ at (1) has no IMPLICIT type gFTL/vector/iterator_procedures.inc:39:58: 39 | ptr => this%elements(this%current_index + i)%item | 1 Error: ‘item’ at (1) is not a member of the ‘vector_wrapper’ structure gFTL/vector/iterator_procedures.inc:44:27: 44 | __T_declare_result__, pointer :: ptr | 1 Error: Symbol ‘int64’ at (1) has no IMPLICIT type gFTL/vector/iterator_procedures.inc:48:58: 48 | ptr => this%elements(this%current_index + i)%item | 1 Error: ‘item’ at (1) is not a member of the ‘vector_wrapper’ structure gFTL/vector/reverse_iterator_procedures.inc:28:27: 28 | __T_declare_result__, pointer :: ptr | 1 Error: Symbol ‘int64’ at (1) has no IMPLICIT type gFTL/vector/reverse_iterator_procedures.inc:27:48: 27 | function __MANGLE(riter_of)(this) result(ptr) | 1 Error: Function result ‘ptr’ at (1) has no IMPLICIT type gFTL/vector/reverse_iterator_procedures.inc:37:27: 37 | __T_declare_result__, pointer :: ptr | 1 Error: Symbol ‘int64’ at (1) has no IMPLICIT type gFTL/vector/reverse_iterator_procedures.inc:36:68: 36 | function __MANGLE(riter_of_offset_size_kind)(this, i) result(ptr) | 1 Error: Function result ‘ptr’ at (1) has no IMPLICIT type gFTL/vector/reverse_iterator_procedures.inc:46:27: 46 | __T_declare_result__, pointer :: ptr | 1 Error: Symbol ‘int64’ at (1) has no IMPLICIT type gFTL/vector/reverse_iterator_procedures.inc:45:66: 45 | function __MANGLE(riter_of_offset_default)(this, i) result(ptr) | 1 Error: Function result ‘ptr’ at (1) has no IMPLICIT type gFTL/algorithms/find/procedures.inc:6:27: 6 | __T_declare_dummy__, intent(in) :: value | 1 Error: Symbol ‘int64’ at (1) has no IMPLICIT type gFTL/algorithms/find/procedures.inc:8:27: 8 | __T_declare_result__, pointer :: ptr | 1 Error: Symbol ‘int64’ at (1) has no IMPLICIT type gFTL/algorithms/find/procedures.inc:47:33: 47 | __T_declare_dummy__, intent(in) :: item | 1 Error: Symbol ‘int64’ at (1) has no IMPLICIT type gFTL/algorithms/find/procedures.inc:70:33: 70 | __T_declare_dummy__, intent(in) :: item | 1 Error: Symbol ‘int64’ at (1) has no IMPLICIT type gFTL/algorithms/find/procedures.inc:6:27: 6 | __T_declare_dummy__, intent(in) :: value | 1 Error: Symbol ‘int64’ at (1) has no IMPLICIT type gFTL/algorithms/find/procedures.inc:8:27: 8 | __T_declare_result__, pointer :: ptr | 1 Error: Symbol ‘int64’ at (1) has no IMPLICIT type gFTL/algorithms/find/procedures.inc:47:33: 47 | __T_declare_dummy__, intent(in) :: item | 1 Error: Symbol ‘int64’ at (1) has no IMPLICIT type gFTL/algorithms/find/procedures.inc:70:33: 70 | __T_declare_dummy__, intent(in) :: item | 1 Error: Symbol ‘int64’ at (1) has no IMPLICIT type gFTL/vector/procedures.inc:444:48: 444 | subroutine __MANGLE(copy_from_array)(this, array) | 1 Error: Symbol ‘array’ at (1) has no IMPLICIT type gFTL/algorithms/find/procedures.inc:2:51: 2 | function __MANGLE(find_basic)(first, last, value) result(iter) | 1 Error: Symbol ‘value’ at (1) has no IMPLICIT type gFTL/algorithms/find/procedures.inc:44:35: 44 | logical function p(item) | 1 Error: Symbol ‘item’ at (1) has no IMPLICIT type gFTL/algorithms/find/procedures.inc:67:35: 67 | logical function q(item) | 1 Error: Symbol ‘item’ at (1) has no IMPLICIT type gFTL/vector/procedures.inc:913:43: 913 | function __MANGLE(get_index)(this, value) result(i) | 1 Error: Symbol ‘value’ at (1) has no IMPLICIT type gFTL/vector/procedures.inc:361:63: 361 | function __MANGLE(insert_count_default)(this, pos, count, value) result(iter) | 1 Error: Symbol ‘value’ at (1) has no IMPLICIT type gFTL/vector/procedures.inc:335:75: 335 | recursive function __MANGLE(insert_count_size_kind)(this, pos, count, value) result(iter) | 1 Error: Symbol ‘value’ at (1) has no IMPLICIT type gFTL/vector/procedures.inc:402:48: 402 | function __MANGLE(insert_list)(this, pos, values) result(iter) | 1 Error: Symbol ‘values’ at (1) has no IMPLICIT type gFTL/vector/procedures.inc:325:56: 325 | recursive function __MANGLE(insert_one)(this, pos, value) result(iter) | 1 Error: Symbol ‘value’ at (1) has no IMPLICIT type gFTL/vector/procedures.inc:373:61: 373 | function __MANGLE(insert_range)(this, pos, first, last, value) result(iter) | 1 Error: Symbol ‘value’ at (1) has no IMPLICIT type gFTL/vector/procedures.inc:58:51: 58 | function __MANGLE(new_vector_fill_default)(n, value) result(v) | 1 Error: Symbol ‘value’ at (1) has no IMPLICIT type gFTL/vector/procedures.inc:47:53: 47 | function __MANGLE(new_vector_fill_size_kind)(n, value) result(v) | 1 Error: Symbol ‘value’ at (1) has no IMPLICIT type gFTL/vector/procedures.inc:101:49: 101 | function __MANGLE(new_vector_initializer_list)(il) result(v) | 1 Error: Symbol ‘il’ at (1) has no IMPLICIT type; did you mean ‘i’? gFTL/vector/procedures.inc:604:52: 604 | recursive subroutine __MANGLE(push_back)(this, value, unused, rc) | 1 Error: Symbol ‘value’ at (1) has no IMPLICIT type gFTL/vector/procedures.inc:690:62: 690 | subroutine __MANGLE(resize_default)(this, count, unused, value, rc) | 1 Error: Symbol ‘value’ at (1) has no IMPLICIT type gFTL/vector/procedures.inc:636:64: 636 | subroutine __MANGLE(resize_size_kind)(this, count, unused, value, rc) | 1 Error: Symbol ‘value’ at (1) has no IMPLICIT type gFTL/algorithms/find/procedures.inc:2:59: 2 | function __MANGLE(find_basic)(first, last, value) result(iter) | 1 Error: Symbol ‘value’ at (1) has no IMPLICIT type gFTL/algorithms/find/procedures.inc:44:35: 44 | logical function p(item) | 1 Error: Symbol ‘item’ at (1) has no IMPLICIT type gFTL/algorithms/find/procedures.inc:67:35: 67 | logical function q(item) | 1 Error: Symbol ‘item’ at (1) has no IMPLICIT type gFTL/vector/procedures.inc:312:47: 312 | subroutine __MANGLE(set_default)(this, i, value) | 1 Error: Symbol ‘value’ at (1) has no IMPLICIT type gFTL/vector/procedures.inc:290:49: 290 | subroutine __MANGLE(set_size_kind)(this, i, value) | 1 Error: Symbol ‘value’ at (1) has no IMPLICIT type gFTL/vector/iterator_procedures.inc:43:65: 43 | function __MANGLE(iter_of_offset_default)(this, i) result(ptr) | 1 Error: Result ‘ptr’ of contained function ‘vector_iter_of_offset_default’ at (1) has no IMPLICIT type gFTL/vector/iterator_procedures.inc:34:67: 34 | function __MANGLE(iter_of_offset_size_kind)(this, i) result(ptr) | 1 Error: Result ‘ptr’ of contained function ‘vector_iter_of_offset_size_kind’ at (1) has no IMPLICIT type gFTL/vector/iterator_procedures.inc:25:47: 25 | function __MANGLE(iter_of)(this) result(ptr) | 1 Error: Result ‘ptr’ of contained function ‘vector_iter_of’ at (1) has no IMPLICIT type gFTL/vector/specification.inc:104:26: 104 | generic :: insert => __MANGLE(insert_one) | 1 Error: ‘vector_insert_one’ and ‘vector_insert_list’ for GENERIC ‘insert’ at (1) are ambiguous gFTL/vector/procedures.inc:444:36: 444 | subroutine __MANGLE(copy_from_array)(this, array) | 1 Error: Second argument of defined assignment at (1) must be INTENT(IN) gFTL/algorithms/find/procedures.inc:12:15: 12 | ptr => iter%of() | 1 Error: Symbol ‘ptr’ at (1) has no IMPLICIT type; did you mean ‘iter’? gFTL/algorithms/find/procedures.inc:12:15: 12 | ptr => iter%of() | 1 Error: Symbol ‘ptr’ at (1) has no IMPLICIT type; did you mean ‘iter’? gFTL/vector/procedures.inc:921:19: 921 | if (__T_EQ__(q, value)) return | 1 Error: Symbol ‘q’ at (1) has no IMPLICIT type gFTL/vector/procedures.inc:545:14: 545 | lhs_i => lhs%of(i) | 1 Error: Symbol ‘lhs_i’ at (1) has no IMPLICIT type; did you mean ‘lhs’? gFTL/vector/procedures.inc:546:14: 546 | rhs_i => rhs%of(i) | 1 Error: Symbol ‘rhs_i’ at (1) has no IMPLICIT type; did you mean ‘rhs’? gFTL/vector/procedures.inc:487:26: 487 | if (.not. (__T_EQ__(l,r))) then | 1 Error: Symbol ‘l’ at (1) has no IMPLICIT type gFTL/vector/procedures.inc:487:31: 487 | if (.not. (__T_EQ__(l,r))) then | 1 Error: Symbol ‘r’ at (1) has no IMPLICIT type gFTL/vector/procedures.inc:196:3: 196 | function __MANGLE(at_default)(this, i, rc) result(res) | 1 Error: Symbol ‘vector_at_default’ at (1) has no IMPLICIT type; did you mean ‘vector_not_equal’? gFTL/vector/procedures.inc:263:3: 263 | function __MANGLE(back)(this) result(res) | 1 Error: Symbol ‘vector_back’ at (1) has no IMPLICIT type; did you mean ‘vector_begin’? gFTL/vector/procedures.inc:175:3: 175 | function __MANGLE(at_size_kind)(this, i, rc) result(res) | 1 Error: Symbol ‘vector_at_size_kind’ at (1) has no IMPLICIT type; did you mean ‘vector_max_size’? gFTL/vector/procedures.inc:249:3: 249 | function __MANGLE(data)(this) result(res) | 1 Error: Symbol ‘vector_data’ at (1) has no IMPLICIT type; did you mean ‘vector_empty’? gFTL/vector/procedures.inc:275:3: 275 | function __MANGLE(front)(this) result(res) | 1 Error: Symbol ‘vector_front’ at (1) has no IMPLICIT type; did you mean ‘vector_rend’? gFTL/vector/procedures.inc:234:3: 234 | function __MANGLE(of_default)(this, i) result(res) | 1 Error: Symbol ‘vector_of_default’ at (1) has no IMPLICIT type; did you mean ‘vector_not_equal’? gFTL/vector/procedures.inc:224:3: 224 | function __MANGLE(of_size_kind)(this, i) result(res) | 1 Error: Symbol ‘vector_of_size_kind’ at (1) has no IMPLICIT type; did you mean ‘gftl_size_kind’? gFTL/vector/iterator_procedures.inc:43:6: 43 | function __MANGLE(iter_of_offset_default)(this, i) result(ptr) | 1 Error: Symbol ‘vector_iter_of_offset_default’ at (1) has no IMPLICIT type; did you mean ‘vector_iter_a_plus_n_default’? gFTL/vector/iterator_procedures.inc:25:6: 25 | function __MANGLE(iter_of)(this) result(ptr) | 1 Error: Symbol ‘vector_iter_of’ at (1) has no IMPLICIT type; did you mean ‘vector_iter_end’? gFTL/vector/iterator_procedures.inc:34:6: 34 | function __MANGLE(iter_of_offset_size_kind)(this, i) result(ptr) | 1 Error: Symbol ‘vector_iter_of_offset_size_kind’ at (1) has no IMPLICIT type; did you mean ‘vector_iter_a_plus_n_size_kind’? gFTL/vector/reverse_iterator_procedures.inc:27:6: 27 | function __MANGLE(riter_of)(this) result(ptr) | 1 Error: Symbol ‘vector_riter_of’ at (1) has no IMPLICIT type; did you mean ‘vector_iter_end’? gFTL/vector/reverse_iterator_procedures.inc:45:6: 45 | function __MANGLE(riter_of_offset_default)(this, i) result(ptr) | 1 Error: Symbol ‘vector_riter_of_offset_default’ at (1) has no IMPLICIT type; did you mean ‘vector_riter_a_plus_n_default’? gFTL/vector/reverse_iterator_procedures.inc:36:6: 36 | function __MANGLE(riter_of_offset_size_kind)(this, i) result(ptr) | 1 Error: Symbol ‘vector_riter_of_offset_size_kind’ at (1) has no IMPLICIT type; did you mean ‘vector_riter_a_plus_n_size_kind’? gFTL/vector/procedures.inc:699:15: 699 | call this%resize(int(count,kind=GFTL_SIZE_KIND), value=value, rc=rc) | 1 Error: Found no matching specific binding for the call to the GENERIC ‘resize’ at (1) gFTL/vector/procedures.inc:613:15: 613 | call this%resize(this%vsize+1, value=value, rc=rc) | 1 Error: Found no matching specific binding for the call to the GENERIC ‘resize’ at (1) gFTL/vector/procedures.inc:368:13: 368 | iter = this%insert(pos, int(count,kind=GFTL_SIZE_KIND), value) | 1 Error: ‘insert’ at (1) should be a FUNCTION gFTL/vector/procedures.inc:331:13: 331 | iter = this%insert(pos, 1_GFTL_SIZE_KIND, value) | 1 Error: ‘insert’ at (1) should be a FUNCTION gFTL/vector/procedures.inc:107:12: 107 | call v%resize(size(il,kind=GFTL_SIZE_KIND)) | 1 Error: Found no matching specific binding for the call to the GENERIC ‘resize’ at (1) gFTL/vector/procedures.inc:91:12: 91 | call v%resize(x%size()) | 1 Error: Found no matching specific binding for the call to the GENERIC ‘resize’ at (1) ```

The crux of which seems to be:

Symbol ‘int64’ at (1) has no IMPLICIT type

I found this example: https://github.com/Goddard-Fortran-Ecosystem/gFTL/blob/main/include/v2/examples/integer64.m4

which may be relevant but it includes types/integer.inc which seems to be a file from v1.

EmilyBourne commented 1 month ago

Actually the linker error is just because I forgot to link the .o file. Using a = [1,2,3] works correctly. It seems that gFTL is able to deduce the fact that it is listable in this case.

For the kind parameter I found the KINDLEN keyword here: https://github.com/Goddard-Fortran-Ecosystem/gFTL/blob/45b4d4a044f2a2796f07c6e69e01847d2b0d7228/include/v2/examples/integer64.m4#L7-L8

If I include the first line then the file Vector_integer_mod.F90 compiles but if I also include the second line then I get the warning:

gFTL_extensions/Vector_integer_mod.F90:5:0:

    5 | #define _T()_kindlen_string "(kind=8)"
      | 
Warning: "_T" redefined
gFTL_extensions/Vector_integer_mod.F90:4:0:

    4 | #define _T()_KINDLEN(context) (kind=8)
      | 
note: this is the location of the previous definition

regardless this doesn't seem to affect the kind of the integer stored in the vector as I still get the error:

test_program.F90:10:7:

   10 |   b = Vector_integer(a)
      |       1
Error: Component ‘elements’ at (1) is a PRIVATE component of ‘vector_integer’

when compiling the program that uses the type

EmilyBourne commented 1 month ago

After some digging I have found this:

module Vector_integer_mod

#define T integer
#define T_KINDLEN(context) (kind=8)
#define Vector Vector_integer
#define VectorIterator Vector_integer_Iterator
#include <vector/template.inc>

end module Vector_integer_mod

which seems to work. This is actually documented. It just wasn't clear to me how it should be used. I must have either missed it or tried a different syntax that didn't work.

Would you like me to create a PR to add an example for this? If so should it go directly in the docs or should it go here: https://github.com/Goddard-Fortran-Ecosystem/gFTL/blob/main/include/v2/examples ? Or somewhere else?

tclune commented 1 month ago

@EmilyBourne I am glad you found a combination that you are happy with. And I'm more than happy to accept contributions to the examples. The directory you suggest above is a bit weird in that it really is a collection of m4 definitions that allows cmake to build a variety of include files. Not really full fledged examples. (And I should note that it includes integer.m4, which is your use case.)

I would also like to point out that if you are primarily interested in containers with intrinsic types, there is a separate repo: https://github.com/Goddard-Fortran-Ecosystem/gFTL-shared that creates templates for most common cases (and then some). This is especially useful when you want to pass containers between multiple layers in a large project.

What is really needed is a v2 replacement for these examples. I can probably meet you half way if you want to start a new v2-examples directory. I'm loathe to write documentation on my own but can easily be prodded to collaborate.

EmilyBourne commented 1 month ago

@tclune

I have created a PR #239 adding the v2 examples for vectors. I am happy to give you a hand with documentation if you can help me fill in the gaps

tclune commented 1 month ago

Hi @EmilyBourne . My apologies - I meant to look at this over the weekend. I hope to get back to you later in the week on this.