# Prescribing wave conditions comes with Segmentation fault

**URL:** <https://opentelemac.org/forum/t/prescribing-wave-conditions-comes-with-segmentation-fault/7841>\
**Category:** TOMAWAC\
**Created:** [November 13, 2024, 12:48pm UTC](https://opentelemac.org/forum/t/prescribing-wave-conditions-comes-with-segmentation-fault/7841 "2024-11-13T12:48:25Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![user\_8525](https://opentelemac.org/forum/letter_avatar_proxy/v4/letter/u/8e8cbc/32.png) [@user\_8525](https://opentelemac.org/forum/u/user_8525)\
**Post date:** [November 13, 2024, 12:48pm UTC](https://opentelemac.org/forum/t/prescribing-wave-conditions-comes-with-segmentation-fault/7841/1 "2024-11-13T12:48:25Z")

</div>

I need to prescribe the wave condition (HM0, TP, DIR) at the open boundary nodes (LIFBOR = 5) using a modified LIMWAC (newmeanWAVE.f) subroutine and an ascii file containing the datat at a hourly timestep (boundaryWaves\_meanPeakDirection.dat). This triplet is then replicated to the liquid nodes, and a call to SPEINI is made to compute the directional variance spectrum.

However, an inevitable “Segmentation fault - invalid memory reference” occurs…

Please see attached file (out).

Could anyone provide a tip on how to resolve this issue?

[name removed]

[newmeanWAVE-4.f](https://opentelemac.org/forum/uploads/short-url/yuLLrCnD1AXmYReYZOX03hSpokw.f) (10.8 KB)

---

<div class="post-metadata">

**Author:** ![user\_8473](https://opentelemac.org/forum/letter_avatar_proxy/v4/letter/u/8c91f0/32.png) [@user\_8473](https://opentelemac.org/forum/u/user_8473)\
**Post date:** [November 13, 2024, 1:07pm UTC](https://opentelemac.org/forum/t/prescribing-wave-conditions-comes-with-segmentation-fault/7841/2 "2024-11-13T13:07:16Z")

</div>

Hello

It is difficult to see the error without running the full case

but I think you should add a save, so that you keep the value of your array from a call to another.

regards

---

<div class="post-metadata">

**Author:** ![user\_8525](https://opentelemac.org/forum/letter_avatar_proxy/v4/letter/u/8e8cbc/32.png) [@user\_8525](https://opentelemac.org/forum/u/user_8525)\
**Post date:** [November 13, 2024, 1:30pm UTC](https://opentelemac.org/forum/t/prescribing-wave-conditions-comes-with-segmentation-fault/7841/3 "2024-11-13T13:30:59Z")

</div>

Dear [name removed]

I am attaching the various files needed to run my [name removed] case.

Thank you in advance for your time and assistance.

[name removed]

[case.zip](https://opentelemac.org/forum/uploads/short-url/A0479JKONnSwcMaz83xnMx9nrEq.zip) (1.16 MB)

---

<div class="post-metadata">

**Author:** ![user\_8525](https://opentelemac.org/forum/letter_avatar_proxy/v4/letter/u/8e8cbc/32.png) [@user\_8525](https://opentelemac.org/forum/u/user_8525)\
**Post date:** [November 13, 2024, 1:33pm UTC](https://opentelemac.org/forum/t/prescribing-wave-conditions-comes-with-segmentation-fault/7841/4 "2024-11-13T13:33:57Z")

</div>

Does TOMAWAC interpolate the different parameters (Hm0, [name removed], Dir) between time steps to match the specified timestep in the cas file?

---

<div class="post-metadata">

**Author:** ![user\_8473](https://opentelemac.org/forum/letter_avatar_proxy/v4/letter/u/8c91f0/32.png) [@user\_8473](https://opentelemac.org/forum/u/user_8473)\
**Post date:** [November 14, 2024, 9:40am UTC](https://opentelemac.org/forum/t/prescribing-wave-conditions-comes-with-segmentation-fault/7841/5 "2024-11-14T09:40:47Z")

</div>

hello

you will find your fortran so that it works. I have some comments :

- it is better to use user\_limwac instead of modifying limwac see examples/tomawac/calais\_test/tom\_variable.cas for an example

- I delete one useless call to speinit, this useless call was the reason of the segmentation fault since there was not the good number of arguments in the call

- I added the save so that you keep your values a time step to another.

- I deleted the 2nd loop on HOURLY\_TIMESTEPS that you were doing at each timestep, since you know you go forward in time.

regards

[newmeanWAVE.f](https://opentelemac.org/forum/uploads/short-url/eScucuGBxcczQEPNmltC26MwTrK.f) (10.9 KB)

---

<div class="post-metadata">

**Author:** ![user\_8473](https://opentelemac.org/forum/letter_avatar_proxy/v4/letter/u/8c91f0/32.png) [@user\_8473](https://opentelemac.org/forum/u/user_8473)\
**Post date:** [November 14, 2024, 9:47am UTC](https://opentelemac.org/forum/t/prescribing-wave-conditions-comes-with-segmentation-fault/7841/6 "2024-11-14T09:47:37Z")

</div>

Tomawac does not do anything, it is up to you to interpolate,

instead of

HM0L = HM0L\_MB(TT)

you can write something like

HM0L = coef \* HM0L\_MB(TT) +(1-coeff)\* HM0L\_MB(TT+1)

---

<div class="post-metadata">

**Author:** ![user\_8525](https://opentelemac.org/forum/letter_avatar_proxy/v4/letter/u/8e8cbc/32.png) [@user\_8525](https://opentelemac.org/forum/u/user_8525)\
**Post date:** [November 14, 2024, 10:08am UTC](https://opentelemac.org/forum/t/prescribing-wave-conditions-comes-with-segmentation-fault/7841/7 "2024-11-14T10:08:07Z")

</div>

Dear [name removed],

Thank you very much for your help. Your guidance was clear and extremely helpful, and I truly appreciate the time you took to assist me. It made a real difference.

Thanks again for your support and for making the forum such a great resource.

[name removed]
