fortran: how to call intrinsic function time() when I already have an array time -


i need time routine , want wallclock time, using time() routine. however, code has 2d array called time, when do: startt=time() thinks referring array. how around without changing array name?

i tried make function outside main program bypass doesn't work:

     program timetest       real time(0:10,0:10) ! dummy array demonstrate problem      integer*8 startt,endt,tdif       time=0 ! initialize dummy array 0       startt=gettime()      call sleep(2) !stuff timed      endt=gettime()       tdif=endt-startt      print*,"tdif= ",tdif       end       integer*8 function gettime()        gettime=time()        print*,"gettime= ",gettime      end function 

output:

gettime= 0

gettime= -9223372036854775808

tdif= 0

you can't have 2 different things visible in program unit same name. first recommendation use fortran standard intrinsic subroutine system_clock rather time().

the approach took separate routine should work if declared gettime correct datatype in caller. have it, gettime integer(4) in main program integer(8) in function itself. these need match.


Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -