Re: Re: Fortran Users! Is there a better way to do this?
Ron Hudson <[email protected]>
| Newsgroups | gmane.comp.emulators.turnkey-mvs |
|---|---|
| Message-ID | <[email protected]> |
On Sun, May 16, 2010 at 10:54 AM, yvette hirth <yvette-RPrnXxQTqyxWk0Htik3J/[email protected]> wrote: > > > John R. Macdonald wrote: > > > Another approach would be to use unformatted I/O, and write your > > values out to a temporary file. Read that file back in with another > > language that does more efficient I/O and do your printing at that > > time. So Fortran does the calculations and writes the numbers to a > > tape or temp file, which you pass to a second step written in COBOL or > > PL/I that formats the report. > > wouldn't the easiest and fastest approach be to write out all five > values per line with one format statement? > > can't you do: > > do 20 (index = ...) > v1 = value(index) > v2 = value(index + 1) > v3 = value(index + 2) > v4 = value(index + 3) > v5 = value(index + 4) > WRITE (*,*) 'v1=',v1,', v2=',v2,', v3=',v3,', v4=',v4,', v5=',v5 > index = index + 5 > 20 continue > > ? > > yvette hirth > Your suggesting close to what I am already doing... Actually I am computing them - The function takes n n = some positive integer if (mod(n,2) .eq. 0) n = n / 2 if (mod(n,2) .ne. 0) n = 3 * n + 1 print n repeat until n = 1 but I want to print them 5 wide to save virtual paper... I am currently saving 5 of them in an array and then printing out the array. The writing is easy: write(6,100) (array(i), i = 1,5) 100 format (' ',5I12) Then I empty the array and fill it again to print the next line. I was hoping to do it without the array and indexes and stuff. > >