From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24452 invoked by alias); 19 Sep 2011 14:35:30 -0000 Received: (qmail 24302 invoked by uid 22791); 19 Sep 2011 14:35:27 -0000 X-SWARE-Spam-Status: No, hits=1.2 required=5.0 tests=BAYES_50,DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED,RP_MATCHES_RCVD,SPF_HELO_PASS,T_TO_NO_BRKTS_FREEMAIL,UNPARSEABLE_RELAY X-Spam-Check-By: sourceware.org Received: from lo.gmane.org (HELO lo.gmane.org) (80.91.229.12) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 19 Sep 2011 14:35:13 +0000 Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1R5ew6-0007zm-VG for gcc-help@gcc.gnu.org; Mon, 19 Sep 2011 16:35:07 +0200 Received: from 186.212.72.107.static.host.gvt.net.br ([186.212.72.107.static.host.gvt.net.br]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 19 Sep 2011 16:35:06 +0200 Received: from lrribeiro by 186.212.72.107.static.host.gvt.net.br with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 19 Sep 2011 16:35:06 +0200 To: gcc-help@gcc.gnu.org From: Luciano Subject: error with free format in read/print/write Date: Mon, 19 Sep 2011 14:35:00 -0000 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit User-Agent: Loom/3.14 (http://gmane.org/) X-IsSubscribed: yes Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org X-SW-Source: 2011-09/txt/msg00154.txt.bz2 Hello, my name is Luciano. I have Fortran 4:4.5.2-1Ubuntu3 The GNU Fortran 95 compiler installed by synaptic. In man gfortran => gcc-4.5.2 2011-04-18 GFORTRAN(1) When I read one variable in Pmat.prn the variable modify the value if not out is formated. In original 1 space between numbers. Pmat.prn Pmatout.prn - out formated 1.20 2.31 3.42 4.53 1.20 2.31 3.42 4.53 6.74 7.85 8.96 9.07 6.74 7.85 8.96 9.07 2.28 3.39 4.40 5.51 2.28 3.39 4.40 5.51 6.72 5.43 7.24 4.55 6.72 5.43 7.24 4.55 ======================================================================== Free Format in Read and out with PRINT* x = line 1 1.2000000 2.3099999 3.4200001 4.5300002 x 1 * 2 2.4000001 4.6199999 6.8400002 9.0600004 x 1 * 3 3.6000001 6.9299998 10.260000 13.590000 x 1 * 4 4.8000002 9.2399998 13.680000 18.120001 x = line 2 6.7399998 7.8499999 8.9600000 9.0699997 x 2 * 2 13.480000 15.700000 17.920000 18.139999 x 2 * 3 20.219999 23.549999 26.880001 27.209999 x 2 * 4 26.959999 31.400000 35.840000 36.279999 x = line 3 2.2800000 3.3900001 4.4000001 5.5100002 x 3 * 2 4.5599999 6.7800002 8.8000002 11.020000 x 3 * 3 6.8400002 10.170000 13.200001 16.530001 x 3 * 4 9.1199999 13.560000 17.600000 22.040001 x = line 4 6.7199998 5.4299998 7.2399998 4.5500002 x 4 * 2 13.440000 10.860000 14.480000 9.1000004 x 4 * 3 20.160000 16.289999 21.719999 13.650001 x 4 * 4 26.879999 21.719999 28.959999 18.200001 ======================================================================== Formated Format in Read with WRITE Line 1 - Out in Screen by Write*,formats (free format) L---> 1.20 2.31 3.42 4.53 x did read with formated format and print with free format - screen by print x = 1.2000000 2.3099999 3.4200001 4.5300002 x * 2 = 2.4000001 4.6199999 6.8400002 9.0600004 x * 3 = 3.6000001 6.9299998 10.260000 13.590000 x * 4 = 4.8000002 9.2399998 13.680000 18.120001 Line 2 - Out in Screen by Write*,formats (free format) L---> 6.74 7.85 8.96 9.07 x did read with formated format and print with free format - screen by print x = 6.7399998 7.8499999 8.9600000 9.0699997 x * 2 = 13.480000 15.700000 17.920000 18.139999 x * 3 = 20.219999 23.549999 26.880001 27.209999 x * 4 = 26.959999 31.400000 35.840000 36.279999 Line 3 - Out in Screen by Write*,formats (free format) L---> 2.28 3.39 4.40 5.51 x did read with formated format and print with free format - screen by print x = 2.2800000 3.3900001 4.4000001 5.5100002 x * 2 = 4.5599999 6.7800002 8.8000002 11.020000 x * 3 = 6.8400002 10.170000 13.200001 16.530001 x * 4 = 9.1199999 13.560000 17.600000 22.040001 Line 4 - Out in Screen by Write*,formats (free format) L---> 6.72 5.43 7.24 4.55 x did read with formated format and print with free format - screen by print x = 6.7199998 5.4299998 7.2399998 4.5500002 x * 2 = 13.440000 10.860000 14.480000 9.1000004 x * 3 = 20.160000 16.289999 21.719999 13.650001 x * 4 = 26.879999 21.719999 28.959999 18.200001 ========================================================================== program abre_aquivo ! ! ARQUIVO LIDO => Pmat.prn ! 1.20 2.31 3.42 4.53 ! 6.74 7.85 8.96 9.07 ! 2.28 3.39 4.40 5.51 ! 6.72 5.43 7.24 4.55 ! ! ARQUVIVO GRAVADO COM FORMATAÇÃO Pmatout.prn ! 1.20 2.31 3.42 4.53 ! 6.74 7.85 8.96 9.07 ! 2.28 3.39 4.40 5.51 ! 6.72 5.43 7.24 4.55 ! implicit none real ::a,b,c,d integer::i ! open(1,file='Pmat.prn') open(2,file='Pmatout.prn') ! print*,' ' print*,'Leitura livre' ! do i=1,4 read(1,*)a,b,c,d print*,'x = linha',i,' ',a,b,c,d print*,"x ",i,' * 2 ', a*2,b*2,c*2,d*2 print*,"x ",i,' * 3 ', a*3,b*3,c*3,d*3 print*,"x ",i,' * 4 ', a*4,b*4,c*4,d*4 enddo ! print*,' ' print*,'Leitura formatada' ! rewind(1) ! do i = 1,4 read(1,'(f4.2, 1x, f4.2, 1x, f4.2, 1x, f4.2)')a,b,c,d write(*,'(f4.2, 1x, f4.2, 1x, f4.2, 1x, f4.2, 1x, a40)'),a,b,c,d,"<=== Saída na Tela, via Write*,formatos " write(2,'(f4.2, 1x, f4.2, 1x, f4.2, 1x, f4.2)')a,b,c,d print*, 'x com leitura formatada e print formato livre"*" - Tela via print', a,b,c,d print*, 'x * 2 - com leitura formatada e print formato livre "*" ',a*2,b*2,c*2,d*2 print*, 'x * 3 - com leitura formatada e print formato livre "*" ',a*3,b*3,c*3,d*3 print*, 'x * 4 - com leitura formatada e print formato livre "*" ',a*4,b*4,c*4,d*4 enddo close(1); close(2) end ========================================================================== Is this a problem with the compiler ? Or my processor can bad ? My hardware is a Intel Core 2 Quad: Memory: 2,GiB Processor 0: Intel(R) Core(TM)2 Quad CPU Q6600 @ 2.40GHz Processor 1: Intel(R) Core(TM)2 Quad CPU Q6600 @ 2.40GHz Processor 2: Intel(R) Core(TM)2 Quad CPU Q6600 @ 2.40GHz Processor 3: Intel(R) Core(TM)2 Quad CPU Q6600 @ 2.40GHz System: 11.04(natty) - 64 bits - (Portuguese) Kernel Linux 2.6.38-11-generic GNOME 2.32.1 Thank for Gfortran! Luciano R Ribeiro --