Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Problem when writing unformatted data to file using Intel Fortran
Hi,

I need to write large data to file without formatting them. The
following program demonstrates what happens if compiled with:

Intel(R) Fortran Compiler for 32-bit applications, Version 8.1    Build
20041019Z Package ID: l_fc_pu_8.1.021
Copyright (C) 1985-2004 Intel Corporation.  All rights reserved.

program unform
implicit none

integer, dimension(:,:), pointer :: kdata
integer :: n1,n2

n1=10; n2=264448
allocate(kdata(n1,n2)); kdata=1

open(unit=77,file="test.bin",form="UNFORMATTED")
write(unit=77) n1
write(unit=77) n2
write(unit=77) kdata
close(77)
deallocate(kdata)

open(unit=77,file="test.bin",form="unformatted")
read(unit=77) n1
read(unit=77) n2
allocate(kdata(n1,n2))
read(unit=77) kdata
close(unit=77)

end program unform

In line "write(unit=77) kdata" I get a segmentation fault. If I change
the pointer attribute of kdata into allocatable everything works fine.
However, I need the pointer attribute in my real code. In addition if I
let kdata be "allocatable" but modify its output according to

write(unit=77) kdata(:,:)

the same segmantation fault occurs.

Many thanks in advance,
Matthias Moeller

Report this thread to moderator Post Follow-up to this message
Old Post
Matthias Möller
04-27-05 01:58 PM


Re: Problem when writing unformatted data to file using Intel Fortran
Matthias Möller wrote:

> I need to write large data to file without formatting them. The
following program demonstrates what happens if compiled with:


(snip)

>   n1=10; n2=264448
>   allocate(kdata(n1,n2)); kdata=1


>   open(unit=77,file="test.bin",form="UNFORMATTED")
>   write(unit=77) n1
>   write(unit=77) n2
>   write(unit=77) kdata
>   close(77)


Remember that each UNFORMATTED write writes one record to the
file.  It might require enough buffer space for the largest
record written, which is huge in your case.

I don't know that there is any magical record size, but
I might suggest keeping it below about 64K bytes, or
16K elements assuming four byte data.  For your case, I would
probably try:

open(unit=77,file="test.bin",form="UNFORMATTED")
write(unit=77) n1,n2
do 1 i=1,n2
1     write(unit=77) (kdata(j,i),j=1,n1)
close(77)

Without knowing the possible values for n1, it is hard to say.
This might make the record length a little small, but if n1 can
get to the 100's or 1000's it is probably about right.
If n1 is always 10 then you could write multiple columns
(or is it rows, I forget) to each record.

As data is in memory with the leftmost subscript varying fastest,
you should write it out that way, as shown above.

-- glen



Report this thread to moderator Post Follow-up to this message
Old Post
glen herrmannsfeldt
04-28-05 09:01 AM


Re: Problem when writing unformatted data to file using Intel Fortran
Thanks for your help. I wonder where to get version 8.1.027. The latest
version which can be downloaded from Intel is 8.1.024

Matthias Moeller

> Your program is running out of stack due to a stack temporary created by t
he
> compiler.  I haven't tried your case, but we did make some changes in this
> area since the compiler you're using.  8.1.027 is current.  The alternativ
e is
> to raise your stacksize limit.
>
>
> Steve Lionel
> Software Products Division
> Intel Corporation
> Nashua, NH
>
> User communities for Intel Software Development Products
>   http://softwareforums.intel.com/
> Intel Fortran Support
>   http://developer.intel.com/software/products/support/

Report this thread to moderator Post Follow-up to this message
Old Post
Matthias Möller
04-28-05 01:58 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Fortran archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 07:34 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.