Hi,
I'm using Intel FORTRAN and trying to write an array to a file. the array is initialiesd so all values are equal to -9.
The array is not complete, meaning that i do not want to output all the array values, i only want to output those not equal to -9. I want to write the array to lines of 20 array values in a text file, with each value seperated by 2 spaces.
I have tried a few ways, including the below, but can't get the result I want.
The below writes out 20 values, however it always fills the last line with 20 values even if there are no values in the array. This means that i get the below as the final line in the file. I need the solution not to print anything for the last values instead of *********.
0.1500000 0.1500000 0.1500000 0.1500000 0.1500000 0.1500000 0.1500000 0.1500000 0.1500000 0.1500000 0.1500000 0.1500000 0.1500000 0.1500000 0.1500000 0.1500000 ********* ********* ********* *********
c Write out J values
c
write(57,21) "# Y Values"
c
do 700 n=MIN_NODE,MAX_NODE,20
c
if (NODE_ARRAY(n,1).ne.-9)then
write(57,10) (NODE_ARRAY((n+i),2), i=0,19)
endif
c
700 enddo
To try and get around the above problems i tried the below, but it only outputs one value on a line, and only outputs 20 lines.
c
c Write out I values
c
21 format(A)
10 format(20(f9.7,2X))
write(57,21) "# X Values"
c
do 600 n=MIN_NODE,MAX_NODE,20
do 601 i=0,19
c
if(i+(n*20).gt.MAX_NODE) go to 125
c
if (NODE_ARRAY((n+i),1).ne.-9)then
write(57,10) (NODE_ARRAY((n+i),1))
endif
c
601 enddo
600 enddo
c
c
125 continue
c
I'm using Intel FORTRAN and trying to write an array to a file. the array is initialiesd so all values are equal to -9.
The array is not complete, meaning that i do not want to output all the array values, i only want to output those not equal to -9. I want to write the array to lines of 20 array values in a text file, with each value seperated by 2 spaces.
I have tried a few ways, including the below, but can't get the result I want.
The below writes out 20 values, however it always fills the last line with 20 values even if there are no values in the array. This means that i get the below as the final line in the file. I need the solution not to print anything for the last values instead of *********.
0.1500000 0.1500000 0.1500000 0.1500000 0.1500000 0.1500000 0.1500000 0.1500000 0.1500000 0.1500000 0.1500000 0.1500000 0.1500000 0.1500000 0.1500000 0.1500000 ********* ********* ********* *********
c Write out J values
c
write(57,21) "# Y Values"
c
do 700 n=MIN_NODE,MAX_NODE,20
c
if (NODE_ARRAY(n,1).ne.-9)then
write(57,10) (NODE_ARRAY((n+i),2), i=0,19)
endif
c
700 enddo
To try and get around the above problems i tried the below, but it only outputs one value on a line, and only outputs 20 lines.
c
c Write out I values
c
21 format(A)
10 format(20(f9.7,2X))
write(57,21) "# X Values"
c
do 600 n=MIN_NODE,MAX_NODE,20
do 601 i=0,19
c
if(i+(n*20).gt.MAX_NODE) go to 125
c
if (NODE_ARRAY((n+i),1).ne.-9)then
write(57,10) (NODE_ARRAY((n+i),1))
endif
c
601 enddo
600 enddo
c
c
125 continue
c