Skip to content

Commit bcb7e6c

Browse files
committed
Add notes from talking through
1 parent 565c034 commit bcb7e6c

File tree

7 files changed

+10
-4
lines changed

7 files changed

+10
-4
lines changed

NOTES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- TODO: ZN to write implementation notes and why we don't use a pure pointer based solution

src/example_fgen_basic/error_v/creation.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ function create_error(inv) result(err)
3636
if (mod(inv, 2) .eq. 0) then
3737
err = ErrorV(code=1, message="Even number supplied")
3838
else
39-
err = ErrorV(code=0)
39+
err = ErrorV(code=NO_ERROR_CODE)
4040
end if
4141

4242
end function create_error

src/example_fgen_basic/error_v/creation_wrapper.f90

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,15 @@ subroutine create_error(inv, res_instance_index)
3939

4040
type(ErrorV), pointer :: res
4141

42+
! Use the pointer more or less like a normal instance of the derived type
43+
res = o_create_error(inv)
44+
4245
! This is the other trick for wrapping.
4346
! We have to ensure that we have correctly associated pointers
4447
! with the derived type instances we want to 'pass' across the Python-Fortran interface.
4548
! Once we've done this, we can then set them more or less like normal derived types.
4649
res_instance_index = error_v_manager_get_free_instance_number()
4750
call error_v_manager_associate_pointer_with_instance(res_instance_index, res)
48-
49-
! Use the pointer more or less like a normal instance of the derived type
50-
res = o_create_error(inv)
5151
! Ensure that the instance index is set correctly
5252
res % instance_index = res_instance_index
5353

src/example_fgen_basic/error_v/error_v.f90

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ module m_error_v
3333
! (means you can stop but also unwind errors and traceback along the way)
3434

3535
! TODO: think about adding trace (might be simpler than compiling with traceback)
36+
! type(ErrorV), allocatable, dimension(:) :: causes
3637

3738
contains
3839

src/example_fgen_basic/error_v/error_v_manager.f90

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ function get_free_instance_number() result(instance_index)
4444

4545
end function get_free_instance_number
4646

47+
! Might be a better way to do this as the pointers are a bit confusing, let's see
4748
subroutine associate_pointer_with_instance(instance_index, instance_pointer)
4849
!! Associate a pointer with the instance corresponding to the given model index
4950
!!

src/example_fgen_basic/error_v/error_v_wrapper.f90

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ subroutine iget_message( &
4848

4949
integer, intent(in) :: instance_index
5050

51+
! TODO: make this variable length
5152
character(len=128), intent(out) :: message
5253

5354
type(ErrorV), pointer :: instance

src/example_fgen_basic/fpyfgen/derived_type_manager_helpers.f90

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ subroutine get_derived_type_free_instance_number(instance_index, n_instances, in
5151

5252
end do
5353

54+
! Should be an error or similar here
55+
5456
end subroutine get_derived_type_free_instance_number
5557

5658
subroutine finalise_derived_type_instance_number(instance_index, n_instances, instance_avail, instance_array)

0 commit comments

Comments
 (0)