Dusty deck Fortran, strange real*8 /real_size=32 interaction.

Post Reply

Topic author
jonesd
Valued Contributor
Posts: 78
Joined: Mon Aug 09, 2021 7:59 pm
Reputation: 0
Status: Offline

Dusty deck Fortran, strange real*8 /real_size=32 interaction.

Post by jonesd » Wed Feb 07, 2024 3:13 pm

I have an old Fortran program from 1983 I could never get working of X86, getting an unexpected NaN when it should have converted an input digit to a real*8. I could never track down the exact point of failure (the lack of debugger support didn't help). This morning I decided to attack it again with Fortran X8.5-7 and got it to not fail if I added a couple extraneous type* statements in 2 of the routines, the failure went away. After a couple more cycles adding/removing output statements, I compiled the code with /real_size=64 and it worked without the extra statements. All the routines set implicit real*8 or explicitly declare the variables, so /real_size=64 shouldn't have been necessary. Compiling with /list/show=all/real_size=32 didn't show any r*4 variables.

This morning I installed V8.5-8 (OpenVMS 9.2-2) and got the same behavior (albeit better debugger support).


jreagan
VSI Expert
Master
Posts: 139
Joined: Tue Dec 01, 2020 8:40 am
Reputation: 0
Status: Offline

Re: Dusty deck Fortran, strange real*8 /real_size=32 interaction.

Post by jreagan » Thu Feb 08, 2024 9:41 am

Can you give a short example? So no difference between the default, /REAL=32, and /REAL=64 listings but you say that using /REAL=64 "fixed" it? I'll assume that if you looked at the generated code with ANAL/OBJ/DISA, the "bad" vs "good" modules have different code?


Topic author
jonesd
Valued Contributor
Posts: 78
Joined: Mon Aug 09, 2021 7:59 pm
Reputation: 0
Status: Offline

Re: Dusty deck Fortran, strange real*8 /real_size=32 interaction.

Post by jonesd » Fri Feb 09, 2024 2:17 am

jreagan wrote:
Thu Feb 08, 2024 9:41 am
Can you give a short example? So no difference between the default, /REAL=32, and /REAL=64 listings but you say that using /REAL=64 "fixed" it? I'll assume that if you looked at the generated code with ANAL/OBJ/DISA, the "bad" vs "good" modules have different code?
I didn't until you mentioned it, and yes they do have different code (and I had to learn about /page=section and ignore=header=3). The section size is 4 bytes longer for the /real_size=32 compile, which incurs several differences just due to jump offsets. The extra 4 bytes appear to be a cvtsi2ssl instruction at line 225 in the rs32 object. Another notable difference is the movq at line 65 where the constant changes from $3FB99999A0000000 to $3FB999999999999A.

https://drive.google.com/file/d/15nSbvv ... sp=sharing

Code: Select all

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
File USER:[JONESD.UTILITY.BOMAR]OPEXEC-rs32.anl;5                                              |  File USER:[JONESD.UTILITY.BOMAR]OPEXEC-rs64.anl;5                                            
----------------------------------------------- 11 -------------------------------------------------------------------------------------------- 11 --------------------------------------------
Section size 1032 bytes                                                                        |  Section size 1028 bytes                                                                      
                                                                                               |                                                                                               
                                                CPI0_0:                                        |                                                  CPI0_0:                                      
                              00 00  00000000:  addb    %al,(%rax)                             |                                00 00  00000000:  addb    %al,(%rax)                           
----------------------------------------------- 20 -------------------------------------------------------------------------------------------- 20 --------------------------------------------
                              00 00  00000008:  addb    %al,(%rax)                             |                                   9A  00000008:  ??                                           
                  3F B9 99 99 A0 00  0000000A:  addb    %ah,3FB99999(%rax)                     |                                   99  00000009:  clq                                          
                                                                                               |                                   99  0000000A:  clq                                          
                                                                                               |                                   99  0000000B:  clq                                          
                                                                                               |                                   99  0000000C:  clq                                          
                                                                                               |                                   99  0000000D:  clq                                          
                                                                                               |                       89 48 55 3F B9  0000000E:  movl    $8948553F,%ecx                       
                                                OPEXEC::                                       |                                                  OPEXEC::                                     
                                 55  00000010:  pushq   %rbp                                   |                                   55  00000010:  pushq   %rbp                                 
                           E5 89 48  00000011:  movq    %rsp,%rbp                              |                             E5 89 48  00000011:  movq    %rsp,%rbp                            
----------------------------------------------- 65 -------------------------------------------------------------------------------------------- 70 --------------------------------------------
      3F B9 99 99 A0 00 00 00 B9 48  000000C9:  movq    $3FB99999A0000000,%rcx                 |        3F B9 99 99 99 99 99 9A B9 48  000000C9:  movq    $3FB999999999999A,%rcx               
                           08 89 48  000000D3:  movq    %rcx,(%rax)                            |                             08 89 48  000000D3:  movq    %rcx,(%rax)                          
               00 00 00 00 05 8B 48  000000D6:  movq    var$0003@GOTPCREL(%rip),%rax           |                 00 00 00 00 05 8B 48  000000D6:  movq    var$0003@GOTPCREL(%rip),%rax         
                           00 63 48  000000DD:  movslq  (%rax),%rax                            |                             00 63 48  000000DD:  movslq  (%rax),%rax                          
----------------------------------------------- 72 -------------------------------------------------------------------------------------------- 77 --------------------------------------------
                     00 00 02 DD E9  000000F3:  jmpq    00000000000003D5                       |                       00 00 02 D9 E9  000000F3:  jmpq    00000000000003D1                     
               00 00 00 00 1D 8B 48  000000F8:  movq    INSTRC@GOTPCREL(%rip),%rbx             |                 00 00 00 00 1D 8B 48  000000F8:  movq    INSTRC@GOTPCREL(%rip),%rbx           
               00 00 00 00 25 8B 4C  000000FF:  movq    IDUM@GOTPCREL(%rip),%r12               |                 00 00 00 00 25 8B 4C  000000FF:  movq    IDUM@GOTPCREL(%rip),%r12             
                     00 00 00 7D E9  00000106:  jmpq    0000000000000188                       |                       00 00 00 7D E9  00000106:  jmpq    0000000000000188                     
----------------------------------------------- 126 ------------------------------------------------------------------------------------------- 131 -------------------------------------------
               00 00 02 2C 0D 8D 48  000001C5:  leaq    JTI0_0(%rip),%rcx                      |                 00 00 02 28 0D 8D 48  000001C5:  leaq    JTI0_0(%rip),%rcx                    
                        81 04 63 48  000001CC:  movslq  (%rcx,%rax,4),%rax                     |                          81 04 63 48  000001CC:  movslq  (%rcx,%rax,4),%rax                   
                           C8 01 48  000001D0:  addq    %rcx,%rax                              |                             C8 01 48  000001D0:  addq    %rcx,%rax                            
                              E0 FF  000001D3:  jmpq    *%rax                                  |                                E0 FF  000001D3:  jmpq    *%rax                                
----------------------------------------------- 211 ------------------------------------------------------------------------------------------- 216 -------------------------------------------
                  00 00 00 88 8C 0F  00000349:  jl      00000000000003D7                       |                    00 00 00 84 8C 0F  00000349:  jl      00000000000003D3                     
               00 00 00 00 35 8B 48  0000034F:  movq    HVALU@GOTPCREL(%rip),%rsi              |                 00 00 00 00 35 8B 48  0000034F:  movq    HVALU@GOTPCREL(%rip),%rsi            
                           DF 89 48  00000356:  movq    %rbx,%rdi                              |                             DF 89 48  00000356:  movq    %rbx,%rdi                            
                        02 00 B8 66  00000359:  movw    $0200,%ax                              |                          02 00 B8 66  00000359:  movw    $0200,%ax                            
----------------------------------------------- 218 ------------------------------------------------------------------------------------------- 223 -------------------------------------------
                              67 EB  0000036C:  jmpb    00000000000003D5                       |                                63 EB  0000036C:  jmpb    00000000000003D1                     
               00 00 00 00 0D 8B 48  0000036E:  movq    var$0005@GOTPCREL(%rip),%rcx           |                 00 00 00 00 0D 8B 48  0000036E:  movq    var$0005@GOTPCREL(%rip),%rcx         
                  F8 C1 54 10 0F F2  00000375:  movsd   -08(%rcx,%rax,8),%xmm2                 |                    F8 C1 54 10 0F F2  00000375:  movsd   -08(%rcx,%rax,8),%xmm2               
                        D0 75 8B 48  0000037B:  movq    -30(%rbp),%rsi                         |                          D0 75 8B 48  0000037B:  movq    -30(%rbp),%rsi                       
----------------------------------------------- 225 ------------------------------------------------------------------------------------------- 230 -------------------------------------------
                        0E 2A 0F F3  00000391:  cvtsi2ssl (%rsi),%xmm1                         |                             C0 57 0F  00000391:  xorps   %xmm0,%xmm0                          
                           C0 57 0F  00000395:  xorps   %xmm0,%xmm0                            |                          06 2A 0F F2  00000394:  cvtsi2sdl (%rsi),%xmm0                       
                        C1 5A 0F F3  00000398:  cvtss2sd %xmm1,%xmm0                           |                 00 00 00 00 0D 8B 48  00000398:  movq    var$0006@GOTPCREL(%rip),%rcx         
               00 00 00 00 0D 8B 48  0000039C:  movq    var$0006@GOTPCREL(%rip),%rcx           |                          09 10 0F F2  0000039F:  movsd   (%rcx),%xmm1                         
                        09 10 0F F2  000003A3:  movsd   (%rcx),%xmm1                           |                          C1 59 0F F2  000003A3:  mulsd   %xmm1,%xmm0                          
                        C1 59 0F F2  000003A7:  mulsd   %xmm1,%xmm0                            |                          C2 58 0F F2  000003A7:  addsd   %xmm2,%xmm0                          
                        C2 58 0F F2  000003AB:  addsd   %xmm2,%xmm0                            |                    F8 C2 44 11 0F F2  000003AB:  movsd   %xmm0,-08(%rdx,%rax,8)               
                  F8 C2 44 11 0F F2  000003AF:  movsd   %xmm0,-08(%rdx,%rax,8)                 |              FF FF FC 47 15 10 0F F2  000003B1:  movsd   CPI0_0(%rip),%xmm2                   
            FF FF FC 43 15 10 0F F2  000003B5:  movsd   CPI0_0(%rip),%xmm2                     |                          D1 2E 0F 66  000003B9:  ucomisd %xmm1,%xmm2                          
                        D1 2E 0F 66  000003BD:  ucomisd %xmm1,%xmm2                            |                                0C 76  000003BD:  jbe     00000000000003CB                     
                              0C 76  000003C1:  jbe     00000000000003CF                       |              FF FF FC 41 0D 59 0F F2  000003BF:  mulsd   CPI0_1(%rip),%xmm1                   
            FF FF FC 3D 0D 59 0F F2  000003C3:  mulsd   CPI0_1(%rip),%xmm1                     |                          09 11 0F F2  000003C7:  movsd   %xmm1,(%rcx)                         
                        09 11 0F F2  000003CB:  movsd   %xmm1,(%rcx)                           |                    00 00 00 23 06 C7  000003CB:  movl    $00000023,(%rsi)                     
                  00 00 00 23 06 C7  000003CF:  movl    $00000023,(%rsi)                       |                                03 8B  000003D1:  movl    (%rbx),%eax                          
                              03 8B  000003D5:  movl    (%rbx),%eax                            |                             F9 C0 83  000003D3:  addl    $-07,%eax                            
                           F9 C0 83  000003D7:  addl    $-07,%eax                              |                             03 F8 83  000003D6:  cmpl    $03,%eax                             
                           03 F8 83  000003DA:  cmpl    $03,%eax                               |                 00 00 00 00 05 8B 48  000003D9:  movq    NEWENT@GOTPCREL(%rip),%rax           
               00 00 00 00 05 8B 48  000003DD:  movq    NEWENT@GOTPCREL(%rip),%rax             |                             00 92 0F  000003E0:  setb    (%rax)                               
                           00 92 0F  000003E4:  setb    (%rax)                                 |                          18 C4 83 48  000003E3:  addq    $18,%rsp                             
                        18 C4 83 48  000003E7:  addq    $18,%rsp                               |                                   5B  000003E7:  popq    %rbx                                 
                                 5B  000003EB:  popq    %rbx                                   |                                5C 41  000003E8:  popq    %r12                                 
                              5C 41  000003EC:  popq    %r12                                   |                                5D 41  000003EA:  popq    %r13                                 
                              5D 41  000003EE:  popq    %r13                                   |                                5E 41  000003EC:  popq    %r14                                 
                              5E 41  000003F0:  popq    %r14                                   |                                5F 41  000003EE:  popq    %r15                                 
                              5F 41  000003F2:  popq    %r15                                   |                                   5D  000003F0:  popq    %rbp                                 
                                 5D  000003F4:  popq    %rbp                                   |                                   C3  000003F1:  retq                                         
                                 C3  000003F5:  retq                                           |                                90 90  000003F2:  .byte   0x90,0x90                            
                              90 90  000003F6:  .byte   0x90,0x90                              |                                                  JTI0_0:                                      
                                                JTI0_0:                                        |                          FF FF FD E1  000003F4:  .byte   0xE1,0xFD,0xFF,0xFF                  
            FF FF FE 2A FF FF FD DD  000003F8:  .byte   0xDD,0xFD,0xFF,0xFF,0x2A,0xFE,0xFF,0x  |              FF FF FE 55 FF FF FE 2E  000003F8:  .byte   0x2E,0xFE,0xFF,0xFF,0x55,0xFE,0xFF,0x
            FF FF FD 46 FF FF FE 51  00000400:  .byte   0x51,0xFE,0xFF,0xFF,0x46,0xFD,0xFF,0x  |                          FF FF FD 4A  00000400:  .byte   0x4A,0xFD,0xFF,0xFF                  
<FF>                                                                                           |  <FF>                                                                                         
                                                                                               |                                                                                               
The analysis uncovered NO errors.                                                              |  The analysis uncovered NO errors.                                                            
----------------------------------------------- 264 ------------------------------------------------------------------------------------------- 269 -------------------------------------------
ANALY/OBJECT/DISASSEM/PAGE=SEPARATE OPEXEC-rs32.obj/OUT=OPEXEC-rs32.anl                        |  ANALY/OBJECT/DISASSEM/PAGE=SEPARATE OPEXEC-rs64.obj/OUT=OPEXEC-rs64.anl                      
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Number of difference sections found: 9
Number of difference records found: 45

DIFFERENCES /IGNORE=(HEADER=3)/WIDTH=192/MATCH=3/OUTPUT=USER:[JONESD.UTILITY.BOMAR]OPEXEC-rs32-64.diff;5/PARALLEL=3-
    USER:[JONESD.UTILITY.BOMAR]OPEXEC-rs32.anl;5-
    USER:[JONESD.UTILITY.BOMAR]OPEXEC-rs64.anl;5

Last edited by jonesd on Fri Feb 09, 2024 2:24 am, edited 1 time in total.

Post Reply