- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi everybody
I am currently building a model for the estimation of fog input into a tropical forest. Therefore I need to read some spatial data in the .asc or .txt format and to process them pixel by pixel.
To get a bit into it, I tried it with implicit reading and writing on a 2 rows/3columns samplefile, but it wont work:
The samplefile is files.txt:
123
456
The way I tried it is:
program try
implicit none
integer :: i,j
character*1 edgy(2,3)
open (3, file="test.txt",Access='direct',recl=3)
open(2,file="files.txt",Access='direct',recl=3)
do 1, i=1,2
read (2,rec=i) (edgy(i,j),j=1,3)
write(3,rec=i) (edgy(i,j),j=1,3)
1 continue
close(2)
close(3)
end
The output in test.txt is only:
123
4
Any idea what I am doing wrong? Hard to find more on this processing in the net
Greets and Thanks,
Frank
I am currently building a model for the estimation of fog input into a tropical forest. Therefore I need to read some spatial data in the .asc or .txt format and to process them pixel by pixel.
To get a bit into it, I tried it with implicit reading and writing on a 2 rows/3columns samplefile, but it wont work:
The samplefile is files.txt:
123
456
The way I tried it is:
program try
implicit none
integer :: i,j
character*1 edgy(2,3)
open (3, file="test.txt",Access='direct',recl=3)
open(2,file="files.txt",Access='direct',recl=3)
do 1, i=1,2
read (2,rec=i) (edgy(i,j),j=1,3)
write(3,rec=i) (edgy(i,j),j=1,3)
1 continue
close(2)
close(3)
end
The output in test.txt is only:
123
4
Any idea what I am doing wrong? Hard to find more on this processing in the net
Greets and Thanks,
Frank
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - firetry
Hi everybody
I am currently building a model for the estimation of fog input into a tropical forest. Therefore I need to read some spatial data in the .asc or .txt format and to process them pixel by pixel.
To get a bit into it, I tried it with implicit reading and writing on a 2 rows/3columns samplefile, but it wont work:
The samplefile is files.txt:
123
456
The way I tried it is:
program try
implicit none
integer :: i,j
character*1 edgy(2,3)
open (3, file="test.txt",Access='direct',recl=3)
open(2,file="files.txt",Access='direct',recl=3)
do 1, i=1,2
read (2,rec=i) (edgy(i,j),j=1,3)
write(3,rec=i) (edgy(i,j),j=1,3)
1 continue
close(2)
close(3)
end
The output in test.txt is only:
123
4
Any idea what I am doing wrong? Hard to find more on this processing in the net
Greets and Thanks,
Frank
I am currently building a model for the estimation of fog input into a tropical forest. Therefore I need to read some spatial data in the .asc or .txt format and to process them pixel by pixel.
To get a bit into it, I tried it with implicit reading and writing on a 2 rows/3columns samplefile, but it wont work:
The samplefile is files.txt:
123
456
The way I tried it is:
program try
implicit none
integer :: i,j
character*1 edgy(2,3)
open (3, file="test.txt",Access='direct',recl=3)
open(2,file="files.txt",Access='direct',recl=3)
do 1, i=1,2
read (2,rec=i) (edgy(i,j),j=1,3)
write(3,rec=i) (edgy(i,j),j=1,3)
1 continue
close(2)
close(3)
end
The output in test.txt is only:
123
4
Any idea what I am doing wrong? Hard to find more on this processing in the net
Greets and Thanks,
Frank
Frank,
In your input, 123 is recognised as a single integer, and so is read into the first element of the array. you would need to add some format statements, giving the format of the input as 3i1, so that three separate integers 1,2,3 are read.
David
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Is files.txt really direct access ?
If it is a sequential formatted text file itwould have "hidden" information (maybe header and trailer lengths or CR, LF characters)
I created a files.txt using notepad and ran your program and got exactly the output you describe.
The contents of that files.txt (in HEX) is 3132 330d 0a34 3536 0d0a
the 0d and 0a are CR/LF
Also may I suggest you define edgy as (3,2) and change edgy(i,j) to edgy(j,i) this will keep the data contiguouswhich helps in debugging especially if the actual sizes are large.
Les

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