Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

bswap32.sh 601 B

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
  1. #!/usr/bin/env bash
  2. #
  3. # test byteswapping 32 bit integers
  4. # generate random binary file
  5. BYTES=$((1024*1024)) # 1 MiB
  6. head -c $BYTES /dev/urandom > data.b
  7. # swap
  8. gmt convert -bi1I -bo1Iw data.b | gmt convert -bi1Iw -bo1I > out.u
  9. gmt convert -bi1i -bo1iw data.b | gmt convert -bi1iw -bo1i > out.d
  10. # compare result
  11. diff -q data.b out.u
  12. diff -q data.b out.d
  13. # swap using gmt xyz2grd
  14. gmt xyz2grd -Sswapped_tmp.b -ZI data.b
  15. gmt xyz2grd -Sswapped.b -ZI swapped_tmp.b
  16. # compare result
  17. diff -q data.b swapped.b
  18. # files must differ
  19. if diff -q swapped_tmp.b swapped.b; then
  20. false # return with error
  21. fi
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...