# Fish operator, hist command, local and global variables

**URL:** <https://forum.itascainternational.com/t/fish-operator-hist-command-local-and-global-variables/2202>\
**Category:** 3DEC\
**Created:** [August 13, 2025, 12:18pm UTC](https://forum.itascainternational.com/t/fish-operator-hist-command-local-and-global-variables/2202 "2025-08-13T12:18:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Damir](https://avatars.discourse-cdn.com/v4/letter/d/7993a0/32.png) [@Damir](https://forum.itascainternational.com/u/Damir)\
**Post date:** [August 13, 2025, 12:18pm UTC](https://forum.itascainternational.com/t/fish-operator-hist-command-local-and-global-variables/2202/1 "2025-08-13T12:18:36Z")

</div>

Hi everybody!

This question may be trivial, so sorry in advance. I have, let’s say, 200 cross sections throughout the complicated structure. Sections are used to integrate and plot various outputs. I use _fish operator_ and _splitting_ for efficient summation, and plan to use _callback_. But, how can I efficiently reach _local_ sum from the _operator_ and use it globally with _fish hist_ (or some other strategy) to plot it? I suppose the problem lies in the connection between local variables in operator and global variables that should be defined for plotting purposes. But how to do that efficiently for many cross sections?

Thanks!

Parts of the code are:

…

fish operator reactions(gx)  
;  
local reactions\_total = vector(0,0,0)  
local reactions\_tower = vector(0,0,0)  
local reactions\_nave = vector(0,0,0)  
local reactions\_buttress = vector(0,0,0)  
;  
if block.gp.pos.z(gx) \< 0.01 then  
local reac = block.gp.force.reaction(gx)  
reactions\_total += reac  
if block.gp.pos.x(gx) \<= 10.8 & block.gp.pos.z(gx) \<= 0.01 then  
reactions\_tower += reac  
endif  
if block.gp.pos.x(gx) \> 10.8 & block.gp.pos.z(gx) \<= 0.01 then  
reactions\_nave += reac  
endif  
if block.gp.pos.x(gx) \>= 21.04 & block.gp.pos.x(gx) \<= 27.85 & block.gp.pos.y(gx) \>= -0.01 & block.gp.pos.y(gx) \<= 4.965 & block.gp.pos.z(gx) \<= 0.01 then  
reactions\_buttress += reac  
endif  
endif  
end

….

; I’m dead lost here.

fish hist name … ; I need to plot histories of reactions\_total or reactions\_tower or reactions\_nave or reactions\_buttress

…

model solve time 16.35 fish-call -100 [reactions(::block.gp.list)] interval 1000

program return

fish callback add [reactions(::block.gp.list)] -100 interval 1000

---

<div class="post-metadata">

**Author:** ![jhazzard](https://avatars.discourse-cdn.com/v4/letter/j/4af34b/32.png) [@jhazzard](https://forum.itascainternational.com/u/jhazzard)\
**Post date:** [August 13, 2025, 3:52pm UTC](https://forum.itascainternational.com/t/fish-operator-hist-command-local-and-global-variables/2202/2 "2025-08-13T15:52:56Z")

</div>

The short answer is that you can’t use locals for this. Presumably you want to sum gridpoint forces over multiple gridpoints? In this case they will need to be globals, in which case you can’t sum inside an operator (without locking).

I would make a regular FISH function (not an operator) that does all the work. Since you are only calling it every 1000 steps, it sholdn’t slow things down too much. You will need to make a separate FISH variable for each thing you want to record as a history. Then you don’t need to use a fish callback. Just take a history of the function.

I expect you don’t want to define 200 different FISH variables. Another way to do it would be to store data in tables. Then you can plot them just like histories. In this case you would need to use a fishcall.

---

<div class="post-metadata">

**Author:** ![Damir](https://avatars.discourse-cdn.com/v4/letter/d/7993a0/32.png) [@Damir](https://forum.itascainternational.com/u/Damir)\
**Post date:** [August 13, 2025, 9:54pm UTC](https://forum.itascainternational.com/t/fish-operator-hist-command-local-and-global-variables/2202/3 "2025-08-13T21:54:03Z")

</div>

Thanks Jim!

Regards!

Damir
