Web Images Videos Maps News Shopping Gmail more »
Recently Visited Groups | Help | Sign in
Google Groups Home
system_clock only returns count=0
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  7 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
John McFarland  
View profile  
 More options Jun 12, 3:23 pm
From: John McFarland <john.mcfarl...@swri.org>
Date: Fri, 12 Jun 2009 12:23:33 -0700 (PDT)
Local: Fri, Jun 12 2009 3:23 pm
Subject: system_clock only returns count=0
Hi, I'm having trouble using the system_clock intrinsic with g95: it
is only returning count=0.  I get the same behavior on Linux x86 and
on Windows x86 under MinGW.  Here is my test program:

--------------------------------------------------------------
[sys_clock]$ g95 --version | head -n1
G95 (GCC 4.0.3 (g95 0.92!) May  5 2009)
[sys_clock]$ cat prog.f90
PROGRAM prog
  INTEGER :: clock, rate, cmax

  CALL SYSTEM_CLOCK(clock,count_rate=rate,count_max=cmax)
  PRINT*, 'size of int:', sizeof(clock)
  PRINT*, 'count:', clock
  PRINT*, 'rate:', rate
  PRINT*, 'max:', cmax
END PROGRAM prog
[sys_clock]$ g95 prog.f90
[sys_clock]$ a.out
 size of int: 4
 count: 0
 rate: 10000
 max: 2147483647
----------------------------------------------------------------------

Am I doing something wrong here?

Thanks,
John


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
jjt-fds  
View profile  
 More options Jun 12, 3:34 pm
From: jjt-fds <jtrel...@haifire.com>
Date: Fri, 12 Jun 2009 12:34:39 -0700 (PDT)
Local: Fri, Jun 12 2009 3:34 pm
Subject: Re: system_clock only returns count=0
Try the following.

PROGRAM prog
  INTEGER :: clock, rate, cmax, i, j
  REAL(8) :: D

DO i = 1, 5
  CALL SYSTEM_CLOCK(clock,count_rate=rate,count_max=cmax)
  PRINT*, 'size of int:', sizeof(clock)
  PRINT*, 'count:', clock
  PRINT*, 'rate:', rate
  PRINT*, 'max:', cmax
!!!!!!!!!!!!!!!!!!!
!! WORK A LITTLE !!
!!!!!!!!!!!!!!!!!!!
  DO j = 1, 999
     D = SIN(D) +0.25
  END DO
END DO
END PROGRAM prog

-Javier


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
John McFarland  
View profile  
 More options Jun 12, 3:47 pm
From: John McFarland <john.mcfarl...@swri.org>
Date: Fri, 12 Jun 2009 12:47:26 -0700 (PDT)
Local: Fri, Jun 12 2009 3:47 pm
Subject: Re: system_clock only returns count=0
Thanks, I tied that, and my output looks like:
[sys_clock]$ ./a.out
 count: 0
 count: 1
 count: 2
 count: 2
 count: 3

So it looks like it is counting.  However, I am trying to use this to
randomize the random number seed as described at
http://gcc.gnu.org/onlinedocs/gfortran/RANDOM_005fSEED.html, in which
case this will not work.  I am aware that with g95, calling random_seed
() without arguments will randomize the seed, but this does not work
on certain other compilers (e.g. gfortran, which just sets the seed to
a "default" value).

I guess my real question is whether or not there is a compiler-
independent mechanism for randomizing the seed?

John


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
John McFarland  
View profile  
 More options Jun 12, 4:02 pm
From: John McFarland <john.mcfarl...@swri.org>
Date: Fri, 12 Jun 2009 13:02:50 -0700 (PDT)
Local: Fri, Jun 12 2009 4:02 pm
Subject: Re: system_clock only returns count=0
Also from reading here:
http://www.ncsa.uiuc.edu/UserInfo/Resources/Hardware/IBMp690/IBM/usr/...,
it states that "The initial value of COUNT depends on the current
value of the processor clock in a range from 0 to COUNT_MAX."  It
seems like that by always starting the count at 0 when you make the
first call to system_clock, g95 is not producing the correct behavior.

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
jjt-fds  
View profile  
 More options Jun 12, 4:15 pm
From: jjt-fds <jtrel...@haifire.com>
Date: Fri, 12 Jun 2009 13:15:18 -0700 (PDT)
Local: Fri, Jun 12 2009 4:15 pm
Subject: Re: system_clock only returns count=0
You can search among system files to get a "number" that changes from
run to run.  Use INQUIRE, if the file is found, open it, read a
number, then return with this number.  For example, you can search for
the file

/proc/uptime

If it's there then it will contain different numbers at different
times.  With enough research you can write a subroutine that can look
for standard files on many types of OS's without ever having to call a
nonstandard subroutine such as system().

-Javier


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Evangelos Bertakis  
View profile  
 More options Jun 15, 7:27 am
From: Evangelos Bertakis <eberta...@gmail.com>
Date: Mon, 15 Jun 2009 13:27:03 +0200
Local: Mon, Jun 15 2009 7:27 am
Subject: Re: system_clock only returns count=0
How about using DATE_AND_TIME() to construct a seed? The output of the
function is bound to be different every time you run the program.

Evangelos


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
John McFarland  
View profile  
 More options Jun 15, 11:59 am
From: John McFarland <john.mcfarl...@swri.org>
Date: Mon, 15 Jun 2009 08:59:55 -0700 (PDT)
Local: Mon, Jun 15 2009 11:59 am
Subject: Re: system_clock only returns count=0
Thanks, this is also what Andy Vaught suggested, and we are now using
it.  See here: http://gcc.gnu.org/onlinedocs/gcc-4.0.2/gfortran/DATE_005fAND_005fTIM....
This function returns milliseconds, seconds, minutes, etc., and can
easily be used to generate a seed.  Works with both g95 and gfortran.

On Jun 15, 6:27 am, Evangelos Bertakis <eberta...@gmail.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google