SUMMARY: Sun Fortran - structures/records and I/O

From: G W Cantello (glenn.w.cantello@hydro.on.ca)
Date: Fri May 16 1997 - 10:22:32 CDT


The original post follows at end.

Many Thanks to:
nadya@bog.ucsd.edu (Nadya Williams)
pln@egret1.Stanford.EDU (Patrick L. Nolan)

As Patrick suggests, ditching the implied loop may fix the problem. It does.
However, I have the loop in there to prevent writing the entire vector when
I often have only a few entries. (i.e. write 4 records as opposed to all 100)

Also, as Nadya suggests, having a field size that doesn't line up on 4 byte
boundaries could be a problem. I had checked this already. I will be changing
my logical*1 to a logical*4 just to avoid problems with this in the future.

It seems that I can continue with the implied loop to cut down on space
used if I break my record down into its individual fields as follows:

OLD STYLE:
        write (nrfout,err=999)
     + num_phist,(phist(i),i=1,num_phist),

NEW STYLE:
        write (nrfout,err=999)
     + num_phist,(phist(i).date,phist(i).time,phist(i).dst,
     + phist(i).power,i=1,num_phist),

The coding is/looks a little clumsier but it works... and for now that's
what I need.

Thanks again.

ORIGINAL POST
=============
----- Begin Included Message -----

Apologies if this is the wrong place for this. I tried comp.sys.sun.apps

We have been running an application on Sun platform using Sun's Fortran
compiler for about 10 years now. About 5 years ago we introduced the Sun
extensions (VMS extension?) "STRUCTURE" and "RECORD" into the code. With
the latest release of Sun Fortran just installed (Version 4.2) some of
the code for I/O that uses an implied DO loop for a record fails under
optimization. If I compile with no options, a fully functioninf
executable is built (but slow). When I try to use level 4 optimization,
it fails on any routine that is using a record with implied do loop.

Running under SOLARIS 2.5.

Finally, we have the exact same code compiling and running fine under
Sun Fortran version 4.0

The relevant pieces of the code are as follows:

      integer*4 MAX_PHIST
      parameter (MAX_PHIST = 100)
      integer*4 num_phist

      structure /phist_type/
         integer*4 date
         integer*4 time
         logical*1 dst
         real*4 power
      end structure

      record /phist_type/ phist(MAX_PHIST)

And then later in the code:

          read (nfrinp,iostat=ios) num_phist,(phist(i),i=1,num_phist)

I've not found anything in the current documentation that says "DON'T DO
THIS" or warnings etc..

Any ideas? (other than run away from Fortran)

----- End Included Message -----

===========================================================
Glenn W. Cantello EMail: Glenn.W.Cantello@hydro.on.ca
Reactor Safety and Operational Analysis Dept, Ontario Hydro
Location H11-G27 ; Tel (416) 592-5534 ; Fax (416) 592-8802
700 University Avenue, Toronto, Ontario M5G 1X6 CANADA



This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:11:55 CDT