Dear people, The sample code below converts 4 characters to an integer using the transfer function. If the characters are stored in an array of characters this works fine. If the characters are stored in a string the transfer fails.
The following commands were used to compile with both gfortran and pgf90 (also ifort and g95 give the same output as pgf90): gfortran -o test_convert test_convert.F90 pgf90 -o test_convert test_convert.F90 When executed the program produces the following output: pgf90 result: byte_string = 157 127 100 0 byte_array = 157 127 100 0 byte_string: value = 6586269 byte_array: value = 6586269 byte_string holds 4 bytes byte_array holds 4 bytes gfortran result: byte_string = 157 127 100 0 byte_array = 157 127 100 0 byte_string: value = 157 byte_array: value = 6586269 byte_string holds 4 bytes byte_array holds 4 bytes sample code: program test_convert implicit none character(len=4) :: byte_string character(len=1),dimension(4) :: byte_array integer*4 :: value,n,i byte_string(1:1) = char(157) byte_string(2:2) = char(127) byte_string(3:3) = char(100) byte_string(4:4) = char(0) byte_array(1:4) = (/char(157),char(127),char(100),char(0)/) print *,"byte_string = ",(ichar(byte_string(i:i)),i=1,4) print *,"byte_array = ",(ichar(byte_array( i:i)),i=1,4) value = transfer(byte_string(1:4),value) print *,"byte_string: value = ",value value = transfer(byte_array(1:4),value) print *,"byte_array: value = ",value inquire(iolength=n) byte_string print *,"byte_string holds ",n," bytes" inquire(iolength=n) byte_array print *,"byte_array holds ",n," bytes" end program test_convert If I understand correctly transfer() should only look at the second parameter (and the optional size parameter) to decide whether the result should be a scalar or an array. At least this is what Metcalf and Reid say in their book fortran90/95 explained. However, gfortran seems to look at the rank of the first parameter as well. best regards, Jos de Kloe -- Summary: incorrect conversion from string to integer by convert() Product: gcc Version: 4.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: kloedej at knmi dot nl http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29951