# Problem with oifs\_run on macOS: ulimit and sed command not working

**URL:** <https://forum.ecmwf.int/t/problem-with-oifs-run-on-macos-ulimit-and-sed-command-not-working/12118>\
**Category:** OpenIFS\
**Tags:** openifs-macos, openifs-installation-and-compilation, openifs-43r3\
**Created:** [2 July 2021 10:40 UTC](https://forum.ecmwf.int/t/problem-with-oifs-run-on-macos-ulimit-and-sed-command-not-working/12118 "2021-07-02T10:40:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Glenn\_Carver](https://forum.ecmwf.int/letter_avatar_proxy/v4/letter/g/e495f1/32.png) [@Glenn\_Carver](https://forum.ecmwf.int/u/Glenn_Carver)\
**Post date:** [2 July 2021 10:40 UTC](https://forum.ecmwf.int/t/problem-with-oifs-run-on-macos-ulimit-and-sed-command-not-working/12118/1 "2021-07-02T10:40:49Z")

</div>

Hi,

I'm trying OpenIFS on a mac (10.12.6 : Sierra).&nbsp; I've found a couple of problems with the oifs\_run script.

The first problem is the use of 'ulimit':

```
#  Make sure process stack limit is increased
ulimit -s unlimited
```

this doesn't work as macOS doesn't support setting 'ulimited' stack.&nbsp; I worked around this by changing the line to:

`ulimit -s unlimited || true`

(or could comment it out).

The second problem was a bit more curious. I get errors from the 'sed' command to replace the values of NPROC in the namelist file:

`sed: -i may not be used with stdin`

Despite reordering the arguments to sed, this error persisted. The script use of sed looks completely correct to me and I could not reproduce this problem on my linux machine. It's seems specific to mac and maybe my macOS version. However, the workaround is to explicitly put a space after the '-i' argument using an escape character '\':

```
sed -e "s/NPROC=[^,]*,/NPROC=${OIFS_NPROC},/" \
     -e "s/NPRNT_STATS=[^,]*,/NPRNT_STATS=${OIFS_NPROC},/" \
     -i\ fort.4
```

which now works as expected.

Cheers, Ryan.

---

<div class="post-metadata">

**Author:** ![Glenn\_Carver](https://forum.ecmwf.int/letter_avatar_proxy/v4/letter/g/e495f1/32.png) [@Glenn\_Carver](https://forum.ecmwf.int/u/Glenn_Carver)\
**Post date:** [2 July 2021 20:29 UTC](https://forum.ecmwf.int/t/problem-with-oifs-run-on-macos-ulimit-and-sed-command-not-working/12118/2 "2021-07-02T20:29:45Z")

</div>

Hi Ryan,

Thanks for that. I was aware of the issue with ulimit and have already made the same correction.

The problem with 'sed -i' is because macOS is based on FreeBSD, so the version of sed behaves differently to the GNU sed on linux.&nbsp; An answer is here:&nbsp;  
[https://stackoverflow.com/questions/35620009/sed-extra-characters-at-end-of-l-command](https://stackoverflow.com/questions/35620009/sed-extra-characters-at-end-of-l-command)  
 but in short, the -i flag in FreeBSD (macOS) requires an argument after it whereas GNU sed doesn't. The filename after -i flag is interpreted as the suffix to apply to the 'original' file. Although using a space character via '\ ' will work, it will generate a file with a trailing space, which is not ideal. Probably better to use '-i .orig' instead.

Cheers,&nbsp; Glenn

---

<div class="post-metadata">

**Author:** ![Glenn\_Carver](https://forum.ecmwf.int/letter_avatar_proxy/v4/letter/g/e495f1/32.png) [@Glenn\_Carver](https://forum.ecmwf.int/u/Glenn_Carver)\
**Post date:** [2 July 2021 20:31 UTC](https://forum.ecmwf.int/t/problem-with-oifs-run-on-macos-ulimit-and-sed-command-not-working/12118/3 "2021-07-02T20:31:15Z")

</div>

Thanks, I've changed the command to 'sed -i .old' which works fine. Maybe make this the default in oifs\_run?
