- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello everyone,
This is the first time I write in this forum, but I read many threads very very useful.
I am converting all my programs from Compaq compiler to Intel compiler, and in this case, I have a file with some data, and I want to replace some information.
My problem is that I have a number (double) and I want to make a cast to character. My code is this:
double precision, dimension (dimdata) :: datavector
character ( len = 20 ) :: cast, castcopy
write(castcopy, '(1pg12.7)') datavector(numaccess)
The last line make the program crashes. The whole project compile perfectly, but when it is running and it arrives to this line, it crashes (and the console window closes). I checked that the error is in this line.
Any suggestion??
Thanks!!!
This is the first time I write in this forum, but I read many threads very very useful.
I am converting all my programs from Compaq compiler to Intel compiler, and in this case, I have a file with some data, and I want to replace some information.
My problem is that I have a number (double) and I want to make a cast to character. My code is this:
double precision, dimension (dimdata) :: datavector
character ( len = 20 ) :: cast, castcopy
write(castcopy, '(1pg12.7)') datavector(numaccess)
The last line make the program crashes. The whole project compile perfectly, but when it is running and it arrives to this line, it crashes (and the console window closes). I checked that the error is in this line.
Any suggestion??
Thanks!!!
Link Copied
4 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
What is the problem?
[fortran]program tcast integer, parameter :: dimdata=2 double precision, dimension (dimdata) :: datavector = [1d1,2d2] character ( len = 20 ) :: castcopy integer :: numaccess do numaccess=1,dimdata write(castcopy, '(1pg12.7)') datavector(numaccess) print *,numaccess,datavector(numaccess),castcopy end do end program tcast [/fortran]Compile and run:
[bash]s:LANG>ifort /traceback /fpe:0 cast1.f90 Intel Visual Fortran Compiler Professional for applications running on IA-32, Version 11.1 Build 2010120 1 Package ID: w_cprof_p_11.1.070 Copyright (C) 1985-2010 Intel Corporation. All rights reserved. Microsoft Incremental Linker Version 9.00.30729.01 Copyright (C) Microsoft Corporation. All rights reserved. -out:cast1.exe -subsystem:console -incremental:no cast1.obj s:LANG>cast1 1 10.0000000000000 10.00000 2 200.000000000000 200.0000 [/bash]
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
What is the value of numaccess ?
Did you get or see an error message? If so what was it?
You shouldbuild your application with debug run time options on- for example /check:all
(or at least check array bounds and uninitialised variables)
Les
Did you get or see an error message? If so what was it?
You shouldbuild your application with debug run time options on- for example /check:all
(or at least check array bounds and uninitialised variables)
Les
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm sorry guys, that line was wrong, but not for the casting....It was a mistake of array's dimension!!
Thanks anyway.
BTW, could you any explain to me why this format to make that casting?? '1pg12.7' I found it somewhere....but I don't get it...
Thanks anyway.
BTW, could you any explain to me why this format to make that casting?? '1pg12.7' I found it somewhere....but I don't get it...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Take a look at "Format Specifications" in the fortran help file
In my installation is is here
ms-help://MS.VSCC.v90/intel.forprodocs/intel.fprocompilerdocs/main_for/lref_for/source_files/pghfrmio.htm
regards
Lars
In my installation is is here
ms-help://MS.VSCC.v90/intel.forprodocs/intel.fprocompilerdocs/main_for/lref_for/source_files/pghfrmio.htm
regards
Lars

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page