forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

UNION issue? Compiler issue?

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> General
View previous topic :: View next topic  
Author Message
wahorger



Joined: 13 Oct 2014
Posts: 1217
Location: Morrison, CO, USA

PostPosted: Fri Nov 09, 2018 10:21 pm    Post subject: UNION issue? Compiler issue? Reply with quote

I was playing around with the UNION statement in a TYPE and ran into a run-time error that baffled me. When I do these declarations (code below), then do an I/O, it crashes with this error.

Quote:

Error 90, File access and properties are incompatible


Best I can determine, this is proper usage in Fortran 95. Your insights will be useful.

Code:

    type:: abcdefg
    sequence
        union
            integer*2 dcba
            integer*2 qrst
            integer*4 uvwx
        end union
    end type
     type (abcdefg):: defg
     defg%uvwx = 32
     write(*,*)"this is a test"
    end
Back to top
View user's profile Send private message Visit poster's website
mecej4



Joined: 31 Oct 2006
Posts: 1885

PostPosted: Sat Nov 10, 2018 2:17 am    Post subject: Reply with quote

UNION is an (obsolete) non-standard extension to Fortran 77, and not needed in Fortran 95.

The following code runs, but I am not sure what you wanted to do.
Code:
    program OBSOLETE
    implicit none
    type:: abcdefg
        sequence
        union
           map
              integer*2 dcba
              integer*2 qrst
           end map
           map
              integer*4 uvwx
           end map
        end union
    end type
    type (abcdefg):: defg
!
    defg%uvwx = 32 + 65536*16
    write(*,*)"this is a test: "
    write(*,10)'uvwx',defg%uvwx
    write(*,10)'dcba',defg%dcba
    write(*,10)'qrst',defg%qrst
 10 format(A4,2x,Z8)
    end
Back to top
View user's profile Send private message
wahorger



Joined: 13 Oct 2014
Posts: 1217
Location: Morrison, CO, USA

PostPosted: Sat Nov 10, 2018 3:41 am    Post subject: Reply with quote

mecej4, yes, there is something about using the MAP directive that makes the code work. This is an obsolete feature, yet it can have great utility. I have seen different implementations described; some require the use of the MAP directive, some do not.

Thanks for looking in to it deeper for me. It is appreciated.

Bill
Back to top
View user's profile Send private message Visit poster's website
mecej4



Joined: 31 Oct 2006
Posts: 1885

PostPosted: Sat Nov 10, 2018 4:24 am    Post subject: Reply with quote

MAP...END MAP is something that I could not find a proper description of in the FTN95 documentation. I ended up consulting the Digital/Compaq Visual Fortran Language Reference Manual, http://jp.xlsoft.com/documents/intel/cvf/cvf_lref.pdf .

My guess is that FTN95 supports correct usage of MAP...END MAP, but a program that uses it improperly or leaves out essential syntax will behave in an unpredictable manner when compiled with FTN95.

Out of curiosity, I tried Lahey Fortran 95 7.10 on your original code, and received the following useful error messages:
Quote:
jwd1600i-s "su0.f90", line 1: No component defined in derived type definition for 'abcdefg'.
jwd1423i-s "su0.f90", line 4: Only MAP declaration can appear in range of UNION declaration.
jwd1423i-s "su0.f90", line 5: Only MAP declaration can appear in range of UNION declaration.
jwd1423i-s "su0.f90", line 6: Only MAP declaration can appear in range of UNION declaration.
jwd1497i-s "su0.f90", line 10, column 11: 'uvwx' not a component of a derived type, cannot be specified as structure component.

As we can see, Lahey F95 can be useful in getting the syntax correct in your code, following which you can return to FTN95.

Another finding, worth appreciating, perhaps: your example as well as my modification embed a non-standard F77 extended type component (UNION) inside an F90 Derived Type, and it works!


Last edited by mecej4 on Sat Nov 10, 2018 12:54 pm; edited 3 times in total
Back to top
View user's profile Send private message
LitusSaxonicum



Joined: 23 Aug 2005
Posts: 2388
Location: Yateley, Hants, UK

PostPosted: Sat Nov 10, 2018 11:54 am    Post subject: Reply with quote

UNIONs, eh?

https://www.youtube.com/watch?v=69O8xmIeenU

Eddie
Back to top
View user's profile Send private message
John-Silver



Joined: 30 Jul 2013
Posts: 1520
Location: Aerospace Valley

PostPosted: Sat Nov 10, 2018 8:50 pm    Post subject: Reply with quote

... and then 10 years later, same cause different turnip head in charge, a young east londoner wrote an equally poignant song to rally the masses, which he discusses here before giving an acoustìc rendition.
_________________
''Computers (HAL and MARVIN excepted) are incredibly rigid. They question nothing. Especially input data.Human beings are incredibly trusting of computers and don't check input data. Together cocking up even the simplest calculation ... Smile "
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> General All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group