# Command string exceeds upper length of 320 characters

**URL:** <https://forum.generic-mapping-tools.org/t/command-string-exceeds-upper-length-of-320-characters/2529>\
**Category:** Q&A\
**Created:** [January 18, 2022, 8:01pm UTC](https://forum.generic-mapping-tools.org/t/command-string-exceeds-upper-length-of-320-characters/2529 "2022-01-18T20:01:06Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![John\_Geodesy](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/john_geodesy/32/116_2.png) [@John\_Geodesy](https://forum.generic-mapping-tools.org/u/John_Geodesy)\
**Post date:** [January 18, 2022, 8:01pm UTC](https://forum.generic-mapping-tools.org/t/command-string-exceeds-upper-length-of-320-characters/2529/1 "2022-01-18T20:01:06Z")

</div>

I haven’t seen this one before, in scripts I’ve run in the past.

My task is to run xyz2grd using the -di option to replace huge invalid values to NaNs. The invalid value has about 300 digits to it, so when I use the command:

`gmt xyz2grd t1.bin -Gtg.grd -R-3950/3950/-3950/4350 -I25 -r -Z${zpr} -di${inval}`

This warning is issued:

`xyz2grd [WARNING]: Command string exceeds upper length of 320 characters (will be truncated in non-netCDF grid files)`

It used to work…

---

<div class="post-metadata">

**Author:** ![pwessel](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/pwessel/32/30_2.png) [@pwessel](https://forum.generic-mapping-tools.org/u/pwessel)\
**Post date:** [January 18, 2022, 8:13pm UTC](https://forum.generic-mapping-tools.org/t/command-string-exceeds-upper-length-of-320-characters/2529/2 "2022-01-18T20:13:41Z")

</div>

In the past, any string longer than the fixed lengths in the GMT grid header would be truncated. We recently added extensions so that for netCDF grids (the default) we can have as long strings as we want. The Warning is just a warning. But, perhaps it should only be printed when NOT using netcdf output grids. I will see if that is possible.

---

<div class="post-metadata">

**Author:** ![pwessel](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/pwessel/32/30_2.png) [@pwessel](https://forum.generic-mapping-tools.org/u/pwessel)\
**Post date:** [January 18, 2022, 8:24pm UTC](https://forum.generic-mapping-tools.org/t/command-string-exceeds-upper-length-of-320-characters/2529/3 "2022-01-18T20:24:42Z")

</div>

Cannot easily prevent these warnings, but I think it is reasonable to warn when those strings exceed the standard grid definition. This only happens in extreme cases anyway.

---

<div class="post-metadata">

**Author:** ![John\_Geodesy](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/john_geodesy/32/116_2.png) [@John\_Geodesy](https://forum.generic-mapping-tools.org/u/John_Geodesy)\
**Post date:** [January 19, 2022, 7:28pm UTC](https://forum.generic-mapping-tools.org/t/command-string-exceeds-upper-length-of-320-characters/2529/4 "2022-01-19T19:28:34Z")

</div>

The problem, here, is that the -di option isn’t doing it’s job. The values ~ 1.79769e+308 need to be turned into NaNs. And they’re getting through as non-NaN values when generating tg.grd.

---

<div class="post-metadata">

**Author:** ![John\_Geodesy](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/john_geodesy/32/116_2.png) [@John\_Geodesy](https://forum.generic-mapping-tools.org/u/John_Geodesy)\
**Post date:** [January 19, 2022, 7:39pm UTC](https://forum.generic-mapping-tools.org/t/command-string-exceeds-upper-length-of-320-characters/2529/5 "2022-01-19T19:39:38Z")

</div>

Try this, with the attached .bin file, Paul:

inval=179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368. # h5 invalid value  
zpr=BLd  
gmt xyz2grd t1.bin -Gtg.grd -R-3950/3950/-3950/4350 -I25 -r -Z${zpr} -di${inval}

Thanks!

[t1.bin.zip](https://forum.generic-mapping-tools.org/uploads/short-url/dZlYeipMV04wJKu2IgzS1P3MDGI.zip) (188.1 KB)

---

<div class="post-metadata">

**Author:** ![pwessel](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/pwessel/32/30_2.png) [@pwessel](https://forum.generic-mapping-tools.org/u/pwessel)\
**Post date:** [January 19, 2022, 7:51pm UTC](https://forum.generic-mapping-tools.org/t/command-string-exceeds-upper-length-of-320-characters/2529/6 "2022-01-19T19:51:13Z")

</div>

It is a feature. By default -di applies to column 2 but you can change that with +c. Add +c0 for now. I think it is fair to say this is a bug when -Z is used since it implies a single input z column.

---

<div class="post-metadata">

**Author:** ![John\_Geodesy](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/john_geodesy/32/116_2.png) [@John\_Geodesy](https://forum.generic-mapping-tools.org/u/John_Geodesy)\
**Post date:** [January 19, 2022, 8:21pm UTC](https://forum.generic-mapping-tools.org/t/command-string-exceeds-upper-length-of-320-characters/2529/7 "2022-01-19T20:21:41Z")

</div>

Aha. That works, my script never complained before! Thank you!

---

<div class="post-metadata">

**Author:** ![pwessel](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/pwessel/32/30_2.png) [@pwessel](https://forum.generic-mapping-tools.org/u/pwessel)\
**Post date:** [January 19, 2022, 9:31pm UTC](https://forum.generic-mapping-tools.org/t/command-string-exceeds-upper-length-of-320-characters/2529/8 "2022-01-19T21:31:12Z")

</div>

The issue is now fixed in master so that -di for -Z defaults to the first (and only) input column. Thanks for the example.
