restored fully the code using native fortran/c types/structs