From: FarrukhMohsen on
I am trying to get the system date and time using the following
code

Integer time
Integer stime
Character rdate(64)
stime = time()
call ctime(stime, rdate)
write (*,100) rdate
100 format (a32)
stop
end


However, I am getting an error message saying:
Reference to intrinsic CTIME is invalid. One or more of the arguments
have incorrect type. Could you please help?
From: Richard Maine on
FarrukhMohsen <FarrukhMohsen(a)gmail.com> wrote:

> I am trying to get the system date and time using the following
> code
>
> Integer time
> Integer stime
> Character rdate(64)
> stime = time()
> call ctime(stime, rdate)
> write (*,100) rdate
> 100 format (a32)
> stop
> end
>
>
> However, I am getting an error message saying:
> Reference to intrinsic CTIME is invalid. One or more of the arguments
> have incorrect type. Could you please help?

Well, neither time nor ctime are standard Fortran. Among other things,
that means I don't have data about them at hand. They might vary from
one compiler to another (certainly they vary at least in that some
compilers won't accept them at all) and you said nothing that I could
find about what compiler you were using. From the message, I deduce that
your compiler presumably does have something of at least the name ctime.
I could probably paw around the net and find guesses as to what the
interface was likely to be, but that seems like more bother than the
result would be worth. (If it is a wrapper for the Unix library ctime, I
wouldn't off-hand expect a subroutine, but perhaps it could be that way;
such a thing would be compiler specific.) Instead...

I'd recommend instead that you use the standard Fortran intrinsic
date_and_time. See any f90 text for details on it. Even if you happen to
be stuck with an f77 compiler, some f77 compilers have implemented a
subset of the date_and_time functionality.

--
Richard Maine | Good judgement comes from experience;
email: last name at domain . net | experience comes from bad judgement.
domain: summertriangle | -- Mark Twain
From: Kurt Kallblad on

"FarrukhMohsen" <FarrukhMohsen(a)gmail.com> wrote in message
news:11c589cd-f21e-45b1-8ffc-0f63785b01b1(a)m73g2000hsh.googlegroups.com...
>I am trying to get the system date and time using the following
> code
>
> Integer time
> Integer stime
> Character rdate(64)
> stime = time()
> call ctime(stime, rdate)
> write (*,100) rdate
> 100 format (a32)
> stop
> end
>
>
> However, I am getting an error message saying:
> Reference to intrinsic CTIME is invalid. One or more of the
> arguments
> have incorrect type. Could you please help?

Hi,

My first advice: Follow Richard's suggestion!

If you still want to use non portable code following may be of
some help.
The program works with CVF6.6C (and I guess as well with Intels
compiler).

program x
use dfport ! A module within CVF
implicit none
! integer time
! in CVF is time declared in dfport
integer stime
character(len=24) :: rdate
! must be a string at least 24 character long
! Character rdate(64) has elements of length 1
! which are to short to store the resulr in
stime = time()
write (*,*) stime
rdate = ctime(stime) ! only one integer argument is allowed
write (*,*) rdate
end program

Good luck
Kurt

 | 
Pages: 1
Prev: ftcl
Next: Foray Build Tool Project Started