This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Locales in C effect read in Fortran


It took me quite a while to sort this out. The program attached works with English locales but not with German ones. Apparently the decimal point is replaced by a decimal comma somewhere during the read.
program bug
implicit none

interface
 subroutine mklocal() bind(c)
 end subroutine mklocal
end interface

character(3)::str='1.8'
real*8::r

call mklocal()
str='1.8'; read(str,*) r; write(6,*) 'str,r:"',str,'", ',r
end program
#include <stdio.h>
#include <stdlib.h>
#include <locale.h>

void mklocal()
{
 if (setlocale(LC_ALL,"de_DE.UTF-8")==NULL) {printf("Cannot set german locales.\n"); exit(-1);}
// if (setlocale(LC_ALL,"en_GB.UTF-8")==NULL) {printf("Cannot set english locales.\n"); exit(-1);}
}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]