Memory Allocation Issue in Atlantis Model Version 6698

32 views
Skip to first unread message

Kévin Cazelles

unread,
Jan 14, 2025, 4:16:53 PM1/14/25
to Atlantis ecosystem model

Hi all,

While working with Atlantis model version 6698, I encountered an issue related to memory allocation for BITAC_sp used in the harvest module. Specifically, at line 1166 of the atManageSetup.c file, the following allocation is used:

bm->BiTAC_sp = (double ****) alloc4d(2, bm->K_num_tot_sp, totalreg_id + 1, 6);

However, the way BiTAC_sp is utilized throughout the code is consistent with the following allocation instead:

bm->BiTAC_sp = (double ****) alloc4d(2, totalreg_id + 1, bm->K_num_tot_sp, 6);

This misallocation caused a segmentation fault in my use case. It’s possible that this issue has been addressed in newer versions of Atlantis, but unfortunately, I do not have access to those versions to confirm.

I wanted to bring this to the attention of the community in case others have encountered a similar problem or if it might still exist in current versions.

Kevin Cazelles

Isaac Kaplan - NOAA Federal

unread,
Jan 15, 2025, 11:53:42 AM1/15/25
to Kévin Cazelles, Atlantis ecosystem model
Hi Kevin,
  In v6718,  I can confirm that I have the same as the first line you noted: 

bm->BiTAC_sp = (double ****) alloc4d(2, bm->K_num_tot_sp, totalreg_id + 1, 6);

 I suspect that most use cases just get lucky and allocate more than necessary. At least I can confirm that I have encountered segmentation faults before, when I forget to think about whether other  "K_num" vector size parameters match what I intend. 

A quick look at a Run.prm file from Puget Sound , for instance, shows:  (no fishery management actually active though) 
K_num_tot_sp    79      # 73 for puget sound including detritus.  total number of biological groups in the model
K_num_reg         2    # Maximum number of management zonings used in the model
I think other western North American models have something similar. 

Others have more expertise here but I suspect you have made a good catch. 

Isaac

--
You received this message because you are subscribed to the Google Groups "Atlantis ecosystem model" group.
To unsubscribe from this group and stop receiving emails from it, send an email to atlantis-ecosystem...@googlegroups.com.
To view this discussion, visit https://groups.google.com/d/msgid/atlantis-ecosystem-model/9f765037-8266-47b3-b309-df86a2c5a9e8n%40googlegroups.com.


--
Isaac Kaplan
Northwest Fisheries Science Center
National Marine Fisheries Service, NOAA
Conservation Biology Division, Room 205 South
2725 Montlake Blvd. E., Seattle WA 98112
cell phone 1(206)384-2043
Reply all
Reply to author
Forward
0 new messages