Silverfrost Forums

Welcome to our forums

Problem with OPTIMISE switch with FTN95 compiler

3 Aug 2005 3:46 #249

I have identified a problem with the OPTIMISE switch with FTN95. The following screen dump demonstrate this.


D:\contram\c7\tuba\ver16\opt_test>type test.inc integer4 M_vtype,M_Ftype,N_vtype,N_Ftype,N_Evlyrs parameter (M_vtype=10) parameter (M_Ftype=3) real4 dmfc_allyr(M_vtype,M_Ftype),dsfc_allyr(M_vtype,M_Ftype) common /cdata/N_vtype,N_Ftype,N_Evlyrs,dmfc_allyr,dsfc_allyr

D:\contram\c7\tuba\ver16\opt_test>type test.for C******************************************************************************* PROGRAM TEST C******************************************************************************* include 'test.inc'

c integer4 M_vtype,M_Ftype,N_vtype,N_Ftype,N_Evlyrs c parameter (M_vtype=10) c parameter (M_Ftype=3) c real4 dmfc_allyr(M_vtype,M_Ftype),dsfc_allyr(M_vtype,M_Ftype) c common /cdata/N_vtype,N_Ftype,N_Evlyrs,dmfc_allyr,dsfc_allyr

  integer*4 S_dmfc,A_dmfc,A_dsfc
  N_vtype=1
  N_Ftype=2
  N_Evlyrs=1
  S_dmfc=8*N_vtype*N_Ftype*N_Evlyrs
  call get_storage@(A_dmfc,s_dmfc)
  call get_storage@(A_dsfc,s_dmfc)
  call fuel_con_out(DCORE8(A_dmfc),DCORE8(A_dsfc))
  call return_storage@(A_dsfc)
  call return_storage@(A_dmfc)
  end

C******************************************************************************* subroutine fuel_con_out(dm_fuel_con,ds_fuel_con) C*******************************************************************************

  include 'test.inc'

c real8 dm_fuel_con(N_vtype,N_Evlyrs,N_Ftype) real8 ds_fuel_con(N_vtype,N_Evlyrs,N_Ftype) c dm_fuel_con(1,1,1)=1000.0 dm_fuel_con(1,1,2)=1000.0 call fuel_aggr(dm_fuel_con,dmfc_allyr) ds_fuel_con(1,1,1)=2000.0 ds_fuel_con(1,1,2)=2000.0 call fuel_aggr(ds_fuel_con,dsfc_allyr) write(,)'Aggr=',dsfc_allyr(1,1) return end C******************************************************************************* subroutine fuel_aggr(fuel_con,fc_allyr) C*******************************************************************************

  include 'test.inc'

c integer4 v,y,f real4 fc_allyr(M_vtype,M_Ftype) real8 fuel_con(N_vtype,N_Evlyrs,N_Ftype) c do f=1,N_Ftype do v=1,N_vtype fc_allyr(v,f)=0.0 do y=1,N_Evlyrs fc_allyr(v,f)=fc_allyr(v,f)+fuel_con(v,y,f) if(f.eq.1.and.v.eq.1.and.y.eq.1) + write(,*)fc_allyr(v,f),fuel_con(v,y,f) end do end do end do return end

D:\contram\c7\tuba\ver16\opt_test>ftn95 test.for/link [FTN95/Win32 Ver. 4.8.2038 Copyright (C) Salford Software Ltd 1993-2005] Licensed to: Paul Chu Organisation: MOTT MACDONALD

NO ERRORS  [<TEST> FTN95/Win32 v4.8.2038]
NO ERRORS  [<FUEL_CON_OUT> FTN95/Win32 v4.8.2038]
NO ERRORS  [<FUEL_AGGR> FTN95/Win32 v4.8.2038]

Creating executable: test.EXE

D:\contram\c7\tuba\ver16\opt_test>test 1000.00 1000.00000000 2000.00 2000.00000000 Aggr= 2000.00

D:\contram\c7\tuba\ver16\opt_test>ftn95 /intl /logl /save /zeroise /INHIBIT_OPT 36 /OPTIMISE test.for /link [FTN95/Win32 Ver. 4.8.2038 Copyright (C) Salford Software Ltd 1993-2005] Licensed to: Paul Chu Organisation: MOTT MACDONALD

NO ERRORS  [<TEST> FTN95/Win32 v4.8.2038]
NO ERRORS  [<FUEL_CON_OUT> FTN95/Win32 v4.8.2038]
NO ERRORS  [<FUEL_AGGR> FTN95/Win32 v4.8.2038]

Creating executable: test.EXE

D:\contram\c7\tuba\ver16\opt_test>test 0.00000 1000.00000000 0.00000 2000.00000000 Aggr= 0.00000


The test program works fine without the OPTIMISE switch. However, with the /OPTIMISE switch it produces wrong results.

Ananda

5 Aug 2005 6:05 #258

Ananda

Your program reveals a bug the optimiser that is affecting the line

   fc_allyr(v,f)=fc_allyr(v,f)+fuel_con(v,y,f)

The problem is caused by the mixed precision (*4 and *8) in the expression.

There are various ways around this (until the bug is fixed)

  1. Change all REAL4 to REAL8 or
  2. Break the assignment into two parts to avoid adding REAL4 to REAL8
  3. Use /INHIBIT_OPT 30 on this part of the code.

Note for other users reading this correspondance...

  1. There may not be much improvement in performance when using /OPTIMISE except perhaps during intensive numerical calculations. If you want do use /OPTIMISE, do some timing tests to see if there is a significant improvement in the runtime. If there is no improvement, then for safety, do not use /OPTIMISE.

  2. /INHIBIT_OPT will not generally be available until the next release.

23 Aug 2005 11:59 #280

This bug has now been fixed.

Please login to reply.