[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

20030514: including udunits.inc in Fortran90 routine



Bill,

>Date: Wed, 14 May 2003 13:45:56 -0700
>From: Bill Riley <address@hidden>
>Organization: ?
>To: Steve Emmerson <address@hidden>
>Subject: Re: 20030513: including udunits.inc in Fortran90 routine

The above message contained the following:

> Thanks, but before you responded I just went into udunits.inc and 
> changed all the "C" in the first column to "!" and it worked.

Interesting solution.

> Now my next problem is that I don't really know how to call udunits.  I 
> have "time" in hours since 1/1/0000 as a real*8 variable. Here is what I 
> put in my subroutine:
> 
>      unitptr = UTMAKE()
>      ercode = UTCALTIME(time,unitptr,oyear,omonth,oday,ohour,tmin,tsec)
> 
> But I get error=-5 back. Am I setting unitptr wrong? How should I do 
> this? Thanks much.

The error code -5 means that the unit structure passed to UTCALTIME is
invalid. This makes sense because you're basically passing an empty unit
structure that isn't a unit of time. You need to set the unit between
your calls, e.g.,

    unitptr = UTMAKE()
    errcode = UTDEC("hours since 1-01-01", unitptr);
    ercode = UTCALTIME(time,unitptr,oyear,omonth,oday,ohour,tmin,tsec)

Interesting time-origin by the way. I hope you know that there is no
year zero: 1 BCE (alias BC) is immediately followed by 1 CE (alias AD).

Regards,
Steve Emmerson


NOTE: All email exchanges with Unidata User Support are recorded in the Unidata inquiry tracking system and then made publicly available through the web. If you do not want to have your interactions made available in this way, you must let us know in each email you send to us.