You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've created a SAC file by using your code. But when I use saclst to check some parameters, it raises an error: sacio: Actual file size 19832 != expected file size: 39032 [npts: 4800]
I think the reason is that Fortran's character is not fully compatible with C's char *. In C, there should be an '\0' at the end of each char arrays to indicate its end.
To solve this problem, I think one way is to add a subroutine in the source file:
subroutine create_c_char(mychar)
use iso_c_binding,only : c_null_char
implicit none
character(len=*),intent(inout) :: mychar
mychar = trim(mychar) // c_null_char
end subroutine
Before calling sacio_writesac/write_header, you could call this subroutine to convert all character arrays in sachead to C's char*. In addition, the length of each character array, like kstnm should have length 9 instead of 8.
Thanks!
The text was updated successfully, but these errors were encountered:
Hi Liang,
I've created a SAC file by using your code. But when I use
saclst
to check some parameters, it raises an error:sacio: Actual file size 19832 != expected file size: 39032 [npts: 4800]
I think the reason is that Fortran's
character
is not fully compatible with C'schar *
. In C, there should be an'\0'
at the end of each char arrays to indicate its end.To solve this problem, I think one way is to add a subroutine in the source file:
Before calling sacio_writesac/write_header, you could call this subroutine to convert all character arrays in sachead to C's char*. In addition, the length of each character array, like kstnm should have length 9 instead of 8.
Thanks!
The text was updated successfully, but these errors were encountered: