Hello,
I need to use a Fortran program to read a group of data stored as unsigned integers.
In F90, it sounds the rule to declare an integer only applies to signed integers.
I am thinking to read in unsigned data first as signed integers, then convert them to signed integers (if there exists a function such as “convert()” to the job).
For example, to read a given unsigned integer stored in file “data”, I may write a short code as below
implicit none
integer :: x
integer :: convert
open(1, filename='data')
read(1,*)x
x=convert(x)
print*, x
close(1)
end
Now, the questions are: 1. I am not sure if it is ok to read an unsigned integer in the way to read signed integer. 2. if the first step is OK, how to write a convert function.
Thanks a lot
I need to use a Fortran program to read a group of data stored as unsigned integers.
In F90, it sounds the rule to declare an integer only applies to signed integers.
I am thinking to read in unsigned data first as signed integers, then convert them to signed integers (if there exists a function such as “convert()” to the job).
For example, to read a given unsigned integer stored in file “data”, I may write a short code as below
implicit none
integer :: x
integer :: convert
open(1, filename='data')
read(1,*)x
x=convert(x)
print*, x
close(1)
end
Now, the questions are: 1. I am not sure if it is ok to read an unsigned integer in the way to read signed integer. 2. if the first step is OK, how to write a convert function.
Thanks a lot