The event handler and its ctx are called whenever the trigger is given by calling on_set_memory(). This allows to handle side effects, e.g. when a variable is from outside a class (the context) such as happens with the BMI.
40 character(len=*), intent(in) :: var_name
41 character(len=*), intent(in) :: mem_path
42 procedure(set_handler_iface), pointer :: handler
43 class(*), pointer :: ctx
44
45 integer(I4B) :: handler_idx
46 class(EventHandlerDataType), pointer :: handler_data => null()
47 class(*), pointer :: handler_data_genptr
48 type(MemoryType), pointer :: mt
49 logical(LGP) :: found
50
51
52 allocate (handler_data)
53 handler_data%handler => handler
54 handler_data%handlerContext => ctx
55
56 handler_data_genptr => handler_data
57 call handler_list%Add(handler_data_genptr)
58
59
60 handler_idx = handler_list%Count()
61
62
63 mt => null()
64 found = .false.
65 call get_from_memorystore(var_name, mem_path, mt, found)
66 mt%set_handler_idx = handler_idx
67