Path: g2news1.google.com!news1.google.com!newshub.sdsu.edu!newsfeed.news2me.com!newsfeeds.sol.net!post2.nntp.sol.net!posts.news.megabitz.net!nnrp1-asbnva.megabitz.net!not-for-mail From: Daniel Franke Newsgroups: comp.lang.fortran,comp.lang.c.moderated Subject: reading fp-values written in Fortran D-format in C Followup-To: comp.lang.c.moderated Date: Fri, 27 Feb 2009 06:53:35 -0600 (CST) Organization: EMBL Sender: c...@herd.plethora.net Approved: c...@plethora.net Message-ID: User-Agent: KNode/0.10.9 Return-Path: X-Original-to: c...@plethora.net X-Old-complaints-to: n...@it-news01.desy.de Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 Delivered-To: c...@localhost.plethora.net X-Old-trace: it-news01.desy.de 1235489118 27272 192.109.31.138 (24 Feb 2009 15:25:18 GMT) Content-Transfer-encoding: 7Bit Lines: 42 NNTP-Posting-Date: 27 Feb 2009 12:53:58 GMT NNTP-Posting-Host: 7bd2605a.news.megabitz.net X-Trace: DXC=?JXLW\Fl^l]Kh3L^7M]mX\><6FU_Q:4mR^W\Y;gN2lO]`oLd<[3QQT[82^9cOV50WP7d@DE\31QYUMoRO]O40E3X`H03LY\jMhPWPj?SAO0InS X-Complaints-To: abuse@megabitz.net [cross-posting to get views from both sides of the pond] Hi all. I have some trouble reading floating-point numbers written with the Fortran D-descriptor: $> cat dout.f90 write( *, FMT="(d13.5)") 3.1415 end $> gfortran dout.f90 -o dout && ./dout 0.31415D+01 Reading above number via [f]scanf in C: $> cat din.c #include int main() { double x; fscanf(stdin, "%lf", &x); fprintf(stdout, "%lf\n", x); return 0; } $> gcc din.c -o din && ./dout | din 0.314150 While I can update the application that writes files in above format, I still have to deal with existing files. Besides converting these files via sed, is there anything in C (short of reimplementing/patching scanf) that would allow me to read numbers in this format properly? Thanks Daniel -- comp.lang.c.moderated - moderation address: c...@plethora.net -- you must have an appropriate newsgroups line in your header for your mail to be seen, or the newsgroup name in square brackets in the subject line. Sorry.