For Programmers: Free Programming Magazines  


Home > Archive > Fortran > July 2004 > Question about DATA statement initialisation in a module









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Question about DATA statement initialisation in a module
Paul Van Delst

2004-07-29, 8:56 pm

Hello,

A colleague had some code like:

MODULE mydata
PRIVATE
REAL, PUBLIC, SAVE, DIMENSION(10)::emc
DATA emc/1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0/
END MODULE mydata

which compiled with no problems. When he USEd the module mydata in some other code and
printed out the values of "emc" he always got zeroes. I never use DATA statements anymore,
so I changed the code to

MODULE mydata
PRIVATE
REAL, PUBLIC, PARAMETER, DIMENSION(10)::emc = &
(/1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0/)
END MODULE mydata

and, as expected, when he printed out the "emc" numbers they were now 1.0,2.0,...10.0.

My question is, why doesn't the first module make the emc numbers available? Oh, and both
forms worked using the PGI compiler. Only the SGI f90 compiler gave zeroes for the first form.

Thanks,

paulv

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com