Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
28456 Discussions

Data in Array Constructor using multiplier has error

Ken_B_1
Beginner
318 Views

Can anyone help? I cannot get the array constructor data values to compile when using a multiplier on a constant.

This is an f77 conversion. Using MS VS 2003 and Intel V9.

The array used to look like:

      DATA ASTP1/0.,20.,40.,3*0.0/

I believed it should be like:

 Real, Parameter :: ASTP1(6) = (/0.,20.,40.,3*0.0/)

I also tried others  below that also did not work
 
 Real, Parameter :: ASTP1(6) = [0.,20.,40.,3*0.0]    
 Real, Parameter :: ASTP1(6) = [/0.,20.,40.,3*0.0/]

The issue is there are some arrays with 80*0..

That would be alot to do by hand.

Thanks Ken

 

 

 

 

0 Kudos
4 Replies
FortranFan
Honored Contributor II
318 Views

Are you trying to set the last 3 values to zero?

program p

   integer :: i
   real, parameter :: ASTP1(6) = [ 0., 20., 40., [(0.0, i=1,3)] ]

   print *, " ASTP1 = ", ASTP1

   stop

end program p
  ASTP1 =    0.00000000       20.0000000       40.0000000       0.00000000
 0.00000000       0.00000000

 

0 Kudos
Ken_B_1
Beginner
318 Views

Thank you. That can work. But I wonder is the 3*0. operation no longer applicable?

0 Kudos
FortranFan
Honored Contributor II
318 Views

Ken B. wrote:

Thank you. That can work. But I wonder is the 3*0. operation no longer applicable?

By "3*0. operation", I assume you mean the repeat operation where 3 successive elements are assigned a specific value.  You may want to look into the Fortran language standard (https://software.intel.com/en-us/node/581560) for more detail, but I believe such repeat syntax is restricted to DATA statements and perhaps in NAMELIST I/O processing as well.

0 Kudos
NotThatItMatters
Beginner
318 Views

Yes, the repeat syntax is valid for DATA statements, reference https://software.intel.com/en-us/node/580482, but I think that is the only place it is allowed.  Probably something for the deep dark past when I was learning the language.

0 Kudos
Reply