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

bswap64.sh 903 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
29
30
  1. #!/usr/bin/env bash
  2. #
  3. # test byteswapping 64 bit integers
  4. exit 0 # not implemented yet, disabled for the time being
  5. # generate random binary file
  6. BYTES=$((1024*1024)) # 1 MiB
  7. head -c $BYTES /dev/urandom > data.b
  8. # these won't work because of GMT's internal double representation:
  9. #gmt convert -bi1L -bo1Lw data.b | gmt convert -bi1Lw -bo1L > out.u
  10. #gmt convert -bi1l -bo1lw data.b | gmt convert -bi1lw -bo1l > out.d
  11. # swap using gmt xyz2grd
  12. gmt xyz2grd -S8 -Gswapped_tmp.b data.b
  13. gmt xyz2grd -S8 -Gswapped.b swapped_tmp.b
  14. # swap skipping 16384 bytes
  15. gmt xyz2grd -S8/16384 -Gswapped_tmp.b data.b
  16. gmt xyz2grd -S8/16384 -Gswapped_skip.b swapped_tmp.b
  17. # swap region of 524288 bytes
  18. gmt xyz2grd -S8/16384/524288 -Gswapped_tmp.b data.b
  19. gmt xyz2grd -S8/16384/524288 -Gswapped_region.b swapped_tmp.b
  20. # compare result
  21. diff -q data.b swapped.b
  22. diff -q data.b swapped_skip.b
  23. diff -q data.b swapped_region.b
Tip!

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

Comments

Loading...