<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: FORTRAN interface to CRTL functions in Operating System - OpenVMS</title>
    <link>https://community.hpe.com/t5/operating-system-openvms/fortran-interface-to-crtl-functions/m-p/4747895#M41396</link>
    <description>StanQ: perror and strerror are the usual path, if you've not seen those:&lt;BR /&gt;&lt;BR /&gt;here's something that some nameless body wrote up on this topic over a decade ago:&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://h71000.www7.hp.com/wizard/wiz_3017.html" target="_blank"&gt;http://h71000.www7.hp.com/wizard/wiz_3017.html&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;You can decide to use the C message catalog or other mechanisms.  I've posted some tools in the GNM stuff on the Freeware that deals with printing messages from signals and such.&lt;BR /&gt;&lt;BR /&gt;The biggest issues I tend to encounter with this stuff is the general lack of UTF8 string support within the compiler, and the increasing age and availability of the required libraries and tools.  But yes, message handling is pretty weak.&lt;BR /&gt;&lt;BR /&gt;And before you reply, yes, I know from wchar and the rest of the Unicode zoo.  I'm now using C tools that allow Unicode directly in the source files and Unicode strings, and that's definitely fun to haul over to VMS.  Not.&lt;BR /&gt;</description>
    <pubDate>Mon, 21 Mar 2011 15:31:24 GMT</pubDate>
    <dc:creator>Hoff</dc:creator>
    <dc:date>2011-03-21T15:31:24Z</dc:date>
    <item>
      <title>FORTRAN interface to CRTL functions</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/fortran-interface-to-crtl-functions/m-p/4747864#M41365</link>
      <description>VMS V8.4, Fortran V8.2 and C V7.3 on Alpha:&lt;BR /&gt;&lt;BR /&gt;I want to call the CRTL function&lt;BR /&gt;  struc tm *gmtime (const time_t timer);&lt;BR /&gt;from a Fortran program. I tried some versions (with/without INTERFACE, EXTERNAL etc.) but didn't find the right one. For debugging purpose I wrote a dummy c-function ggtime &lt;BR /&gt;  struc tm *ggtime (const time_t timer);&lt;BR /&gt;with only a printf() for the argument timer to be able to see what Fortran is passing to the c-function.&lt;BR /&gt;Defining in Fortran the c-function as a subroutine or an INT*4 function (only to debug the argument), the printf() shows the right value; Fortran puts the argument in the first position of the argument list and returns the function value per register.&lt;BR /&gt;But defining the c-function as a TYPE, the argument list is built different (the return value or its address is put somewhere in the argument list), so the c-function doesn't get the correct argument and printf() show a wrong value. The argument lists for a Fortran TYPE function and a c struc function differs right?&lt;BR /&gt;Do I have to build a wrapper c subroutine or can I build the right interface to the c function in Fortran directly (via !DEC$ ATTRIBUTES etc.)?&lt;BR /&gt;Calling the CRTL function&lt;BR /&gt;  time_t mktime (struc tm *timeptr)&lt;BR /&gt;from Fortran via decc$mktime works fine, the argument list matches between Fortran and C (tm is passed by reference as the first argument, time_t is passed back as integer*4 in the r0 register).</description>
      <pubDate>Thu, 03 Feb 2011 08:43:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/fortran-interface-to-crtl-functions/m-p/4747864#M41365</guid>
      <dc:creator>Michael Menge</dc:creator>
      <dc:date>2011-02-03T08:43:45Z</dc:date>
    </item>
    <item>
      <title>Re: FORTRAN interface to CRTL functions</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/fortran-interface-to-crtl-functions/m-p/4747865#M41366</link>
      <description>This one, using an interface to gmtime_r as a subroutine seems to work:&lt;BR /&gt;&lt;BR /&gt;===============================================&lt;BR /&gt;Program test_gmtime&lt;BR /&gt;USE tm_type&lt;BR /&gt;&lt;BR /&gt;INTERFACE&lt;BR /&gt;!  FUNCTION gmtime_f(t,tm_p)&lt;BR /&gt;  SUBROUTINE gmtime_f(t,tm_p)&lt;BR /&gt;USE tm_type&lt;BR /&gt;  INTEGER , INTENT(IN) :: t&lt;BR /&gt;  type(TM), INTENT(OUT)  :: tm_p&lt;BR /&gt;!  type(TM) , pointer :: gmtime_f&lt;BR /&gt;!  END FUNCTION&lt;BR /&gt;  END subroutine&lt;BR /&gt;END INTERFACE&lt;BR /&gt;&lt;BR /&gt;type (TM) :: tm_p&lt;BR /&gt;type (TM), pointer :: tm_r&lt;BR /&gt;&lt;BR /&gt;! tm_r=gmtime_f(0,tm_p)&lt;BR /&gt; call gmtime_f(0,tm_p)&lt;BR /&gt;&lt;BR /&gt; print *, ' ',tm_p%tm_year,tm_p%tm_mon,tm_p%tm_mday,tm_p%tm_hour,tm_p%tm_min&lt;BR /&gt;END program test_gmtime &lt;BR /&gt;=============================================&lt;BR /&gt;! where gmtime_f.c is:&lt;BR /&gt;#include  &lt;TIME.H&gt;&lt;BR /&gt; struct tm *gmtime_f (const time_t *timer, struct tm *result) {&lt;BR /&gt;   return gmtime_r (timer,result);&lt;BR /&gt; }&lt;BR /&gt;=============================================&lt;BR /&gt;tm_type module is:&lt;BR /&gt;&lt;BR /&gt;MODULE TM_TYPE&lt;BR /&gt;PUBLIC&lt;BR /&gt;TYPE  :: TM&lt;BR /&gt;        INTEGER tm_sec      ! seconds after the minute [0, 61]  &lt;BR /&gt;        INTEGER tm_min      ! minutes after the hour [0, 59]    &lt;BR /&gt;        INTEGER tm_hour     ! hours since midnight [0, 23]      &lt;BR /&gt;        INTEGER tm_mday     ! day of the month [1, 31]          &lt;BR /&gt;        INTEGER tm_mon      ! months since January [0, 11]      &lt;BR /&gt;        INTEGER tm_year     ! years since 1900                  &lt;BR /&gt;        INTEGER tm_wday     ! days since Sunday [0, 6]          &lt;BR /&gt;        INTEGER tm_yday     ! days since January 1 [0, 365]     &lt;BR /&gt;        INTEGER tm_isdst    ! Daylight Saving Time flag         &lt;BR /&gt;        INTEGER tm_gmtoff  ! offset from UTC in seconds        &lt;BR /&gt;        INTEGER fill1   !to account for newer struct tm&lt;BR /&gt;        INTEGER fill2&lt;BR /&gt;END TYPE TM&lt;BR /&gt;END MODULE TM_TYPE&lt;BR /&gt;&lt;BR /&gt;=============================================&lt;BR /&gt;&lt;BR /&gt;But the version to use gmtime as a function returning a pointer to type TM seems not to work:&lt;BR /&gt;Either my pointer assignement syntax is wrong , or F90 pointer types are not compatible with C pointers.&lt;BR /&gt;&lt;BR /&gt;integer,pointer:: probably is not the same as  &lt;BR /&gt;c_intptr_t in iso_c_binding.&lt;BR /&gt; &lt;BR /&gt;&lt;/TIME.H&gt;</description>
      <pubDate>Thu, 03 Feb 2011 13:18:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/fortran-interface-to-crtl-functions/m-p/4747865#M41366</guid>
      <dc:creator>Joseph Huber_1</dc:creator>
      <dc:date>2011-02-03T13:18:58Z</dc:date>
    </item>
    <item>
      <title>Re: FORTRAN interface to CRTL functions</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/fortran-interface-to-crtl-functions/m-p/4747866#M41367</link>
      <description>And to the question if Fortran(90) can use a C function returning a pointer: it apparently is not VMS specific. It needs ISO_C_BINDING, see this discussion:&lt;BR /&gt; &lt;A href="http://stackoverflow.com/questions/3852790/fortran-interface-to-call-a-c-function-that-return-a-pointer" target="_blank"&gt;http://stackoverflow.com/questions/3852790/fortran-interface-to-call-a-c-function-that-return-a-pointer&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;(and no, VMS Fortran 8.2 does not yet have iso_c_binding, no?)&lt;BR /&gt;</description>
      <pubDate>Thu, 03 Feb 2011 14:21:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/fortran-interface-to-crtl-functions/m-p/4747866#M41367</guid>
      <dc:creator>Joseph Huber_1</dc:creator>
      <dc:date>2011-02-03T14:21:51Z</dc:date>
    </item>
    <item>
      <title>Re: FORTRAN interface to CRTL functions</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/fortran-interface-to-crtl-functions/m-p/4747867#M41368</link>
      <description>A Fortran 2003 version would probably look like:&lt;BR /&gt;&lt;BR /&gt;PROGRAM test_gmtime&lt;BR /&gt;USE tm_type&lt;BR /&gt;USE, intrinsic :: iso_c_binding, only : c_ptr,c_f_pointer&lt;BR /&gt;&lt;BR /&gt;IMPLICIT NONE&lt;BR /&gt;&lt;BR /&gt;INTERFACE&lt;BR /&gt;FUNCTION gmtime_f(t,tm_p)&lt;BR /&gt;USE, intrinsic :: iso_c_binding, only : c_ptr&lt;BR /&gt;USE tm_type&lt;BR /&gt; INTEGER , INTENT(IN) :: t&lt;BR /&gt; type(TM), INTENT(OUT)  :: tm_p&lt;BR /&gt; type(c_ptr)  :: gmtime_f&lt;BR /&gt;END FUNCTION&lt;BR /&gt;END INTERFACE&lt;BR /&gt;&lt;BR /&gt; type (TM) :: tm_p&lt;BR /&gt; type (TM), pointer :: tm_r&lt;BR /&gt; type(c_ptr) :: c_p&lt;BR /&gt;&lt;BR /&gt; c_p= gmtime_f(0,tm_p)&lt;BR /&gt; call c_f_pointer(c_p, tm_r)    !convert C- to Fortran-pointer&lt;BR /&gt; print *, ' ',tm_p%tm_year,tm_p%tm_mon,tm_p%tm_mday,tm_p%tm_hour,tm_p%tm_min&lt;BR /&gt; print *, ' ',tm_r%tm_year,tm_r%tm_mon,tm_r%tm_mday,tm_r%tm_hour,tm_r%tm_min&lt;BR /&gt;END PROGRAM test_gmtime &lt;BR /&gt;&lt;BR /&gt;The c_f_pointer call makes the difference!&lt;BR /&gt;</description>
      <pubDate>Thu, 03 Feb 2011 14:42:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/fortran-interface-to-crtl-functions/m-p/4747867#M41368</guid>
      <dc:creator>Joseph Huber_1</dc:creator>
      <dc:date>2011-02-03T14:42:14Z</dc:date>
    </item>
    <item>
      <title>Re: FORTRAN interface to CRTL functions</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/fortran-interface-to-crtl-functions/m-p/4747868#M41369</link>
      <description>I just made a test of the F2003 version on&lt;BR /&gt; GNU Fortran (SUSE Linux) 4.4.1 [gcc-4_4-branch revision 150839]&lt;BR /&gt;&lt;BR /&gt;and it works perfectly, returning the tm structure both in the passed argument structure, and in the returned C pointer to a tm structure.&lt;BR /&gt;&lt;BR /&gt;Remember the difference between C pointers and Fortran POINTER type:&lt;BR /&gt;C pointers in practice are simply addresses,&lt;BR /&gt;while Fortran POINTER types are opaque structures. They contain the address of the pointee, the association status, and probably in addition some description of type and size.&lt;BR /&gt;</description>
      <pubDate>Thu, 03 Feb 2011 18:06:02 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/fortran-interface-to-crtl-functions/m-p/4747868#M41369</guid>
      <dc:creator>Joseph Huber_1</dc:creator>
      <dc:date>2011-02-03T18:06:02Z</dc:date>
    </item>
    <item>
      <title>Re: FORTRAN interface to CRTL functions</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/fortran-interface-to-crtl-functions/m-p/4747869#M41370</link>
      <description>&amp;gt;Do I have to build a wrapper c subroutine or &amp;gt;can I build the right interface to the c &amp;gt;function in Fortran directly (via !DEC$ &amp;gt;ATTRIBUTES etc.)?&lt;BR /&gt;&lt;BR /&gt;yes, that's why I wrapped it in gmtime_f.&lt;BR /&gt;The reason is, that decc$gmtime(_r) exists in CRTL, but apparently returns nothing.&lt;BR /&gt;Looking into time.h, it shows that gmtime_r is effectively defined as either&lt;BR /&gt;  __utc_gmtime(_r) or&lt;BR /&gt;  __utc_localtime_(r)&lt;BR /&gt;depending on some macro definitions.</description>
      <pubDate>Thu, 03 Feb 2011 18:14:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/fortran-interface-to-crtl-functions/m-p/4747869#M41370</guid>
      <dc:creator>Joseph Huber_1</dc:creator>
      <dc:date>2011-02-03T18:14:52Z</dc:date>
    </item>
    <item>
      <title>Re: FORTRAN interface to CRTL functions</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/fortran-interface-to-crtl-functions/m-p/4747870#M41371</link>
      <description>For the VMS part we are using VMS Fortran V8.2, so there isn't any ISO_C_BINDING right?&lt;BR /&gt;As mentioned the c-function decc$mktime works fine with fortran and returns the time_t value(INTEGER*4) in the same way as a fortran function. I wonder in which way the c-compiler returns the tm pointer as the function result?&lt;BR /&gt;For the fortran pointer is an opaque structure and not the same as a c pointer, perhaps the fortran POINTER statement POINTER (tm_p,tm) could be used. This kind of pointer works like in c and is also available on our other platform SLES with the inter compiler.&lt;BR /&gt;Also when using the !DEC$ atttribute C directive for the c funtion name in the fortran interface definition, the compiler should be able to handle the return value of the c function in the correct manner.</description>
      <pubDate>Fri, 04 Feb 2011 12:47:16 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/fortran-interface-to-crtl-functions/m-p/4747870#M41371</guid>
      <dc:creator>Michael Menge</dc:creator>
      <dc:date>2011-02-04T12:47:16Z</dc:date>
    </item>
    <item>
      <title>Re: FORTRAN interface to CRTL functions</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/fortran-interface-to-crtl-functions/m-p/4747871#M41372</link>
      <description>&lt;BR /&gt;[&lt;BR /&gt;As mentioned the c-function decc$mktime works fine with fortran and returns the time_t value(INTEGER*4) in the same way as a fortran function. I wonder in which way the c-compiler returns the tm pointer as the function result?&lt;BR /&gt;]&lt;BR /&gt;&lt;BR /&gt;For scalars (integer,real,logical) it is not a problem, C and Fortran return the value in a register.&lt;BR /&gt;C also returns pointers simply in a register (an address).&lt;BR /&gt;&lt;BR /&gt;If You like dirty programming, then You can declare the C function simply as INTEGER*4 or INTEGER*8 and pass the function return value as an argument to another subroutine/function expecting a pointer to a structure or array.&lt;BR /&gt;This is basically what iso_c_binding provides in subroutine c_f_pointer. &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;[&lt;BR /&gt;For the fortran pointer is an opaque structure and not the same as a c pointer, perhaps the fortran POINTER statement POINTER (tm_p,tm) could be used. This kind &lt;BR /&gt;of pointer works like in c and is also available on our other platform SLES with the inter compiler.&lt;BR /&gt;]&lt;BR /&gt;&lt;BR /&gt;This is the old pre-f90 non-standard type of pointer (called "Cray pointers", because it stems from Cray-Fortran).&lt;BR /&gt;I doubt is is directly compatable with C pointer return, but if You tested it, so be it...&lt;BR /&gt;&lt;BR /&gt;[&lt;BR /&gt;Also when using the !DEC$ atttribute C directive for the c funtion name in the fortran interface definition, the compiler should be able to handle the return value of the c function in the correct manner.&lt;BR /&gt;]&lt;BR /&gt;&lt;BR /&gt;Maybe, but then again without iso_c_binding the result is nothing but some integer type containing an address, You can pass the value to procedures as above, but can't use it as a  F90 POINTER type without a conversion routine like c_f_pointer().&lt;BR /&gt;&lt;BR /&gt;In the case of gmtime_r it is not necessary.&lt;BR /&gt;For other kind of C RTL functions such a kind of bricolage might be necessary; although I find it much more cleaner to write a Fortran wrapper, e.g. in the style of the Posix Fortran IPXF* and PXF* routines, which pass everything as subroutine arguments, not via function return.&lt;BR /&gt;&lt;BR /&gt;Some of my examples:&lt;BR /&gt; &lt;A href="http://www.mpp.mpg.de/~huber/util/" target="_blank"&gt;http://www.mpp.mpg.de/~huber/util/&lt;/A&gt;&lt;BR /&gt; see *PXF* and *_f source files.&lt;BR /&gt;</description>
      <pubDate>Fri, 04 Feb 2011 13:39:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/fortran-interface-to-crtl-functions/m-p/4747871#M41372</guid>
      <dc:creator>Joseph Huber_1</dc:creator>
      <dc:date>2011-02-04T13:39:19Z</dc:date>
    </item>
    <item>
      <title>Re: FORTRAN interface to CRTL functions</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/fortran-interface-to-crtl-functions/m-p/4747872#M41373</link>
      <description>I'd suggest implementing this with the Sun or GNU Fortran gmtime intrinsic interface:&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://gcc.gnu.org/onlinedocs/gfortran/GMTIME.html" target="_blank"&gt;http://gcc.gnu.org/onlinedocs/gfortran/GMTIME.html&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;This if somebody doesn't already have that coded and posted somewhere, given Sun and GNU Fortran code does tend to get ported around to other Fortran compilers.&lt;BR /&gt;&lt;BR /&gt;If this is a more generic request for a time value for logging or such, then there are system services and RTL calls that can and do fetch values useful for timestamps, including sys$getutc and friends.</description>
      <pubDate>Fri, 04 Feb 2011 14:40:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/fortran-interface-to-crtl-functions/m-p/4747872#M41373</guid>
      <dc:creator>Hoff</dc:creator>
      <dc:date>2011-02-04T14:40:01Z</dc:date>
    </item>
    <item>
      <title>Re: FORTRAN interface to CRTL functions</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/fortran-interface-to-crtl-functions/m-p/4747873#M41374</link>
      <description>[ GNU Fortran GMTIME ]&lt;BR /&gt;&lt;BR /&gt;Yes of course, that's exactly what my gmtime_f is for VMS:&lt;BR /&gt; call gmtime_f(0,tm_p)&lt;BR /&gt;&lt;BR /&gt;I just named it differently, because it could conflict with gmtime, if linked to the VAXC RTL.&lt;BR /&gt;&lt;BR /&gt;In my first reply I just added a F90 INTERFACE, one can use it without, and instead of the TM type one can simply pass an integer array in F77.&lt;BR /&gt;</description>
      <pubDate>Fri, 04 Feb 2011 18:02:16 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/fortran-interface-to-crtl-functions/m-p/4747873#M41374</guid>
      <dc:creator>Joseph Huber_1</dc:creator>
      <dc:date>2011-02-04T18:02:16Z</dc:date>
    </item>
    <item>
      <title>Re: FORTRAN interface to CRTL functions</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/fortran-interface-to-crtl-functions/m-p/4747874#M41375</link>
      <description>Hi Michael,&lt;BR /&gt;&lt;BR /&gt;If you consider the technical articles at &lt;A href="http://vouters.dyndns.org/tima/Linux-Fortran-Internationalizing_messages.html" target="_blank"&gt;http://vouters.dyndns.org/tima/Linux-Fortran-Internationalizing_messages.html&lt;/A&gt; and &lt;A href="http://vouters.dyndns.org/tima/OpenVMS-Fortran-Internationalizing_messages.html" target="_blank"&gt;http://vouters.dyndns.org/tima/OpenVMS-Fortran-Internationalizing_messages.html&lt;/A&gt; perform exactly the same. However my HP Fortran for OpenVMS not recognizing ISO_C_BINDING, the VMS solution to this problem is entirely OpenVMS dependant. This is no matter of the VMS CRTL often prefixing its routines with DECC$.&lt;BR /&gt;&lt;BR /&gt;In the hope this can give you some clues.&lt;BR /&gt;Philippe</description>
      <pubDate>Sat, 05 Feb 2011 13:39:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/fortran-interface-to-crtl-functions/m-p/4747874#M41375</guid>
      <dc:creator>Ph Vouters</dc:creator>
      <dc:date>2011-02-05T13:39:53Z</dc:date>
    </item>
    <item>
      <title>Re: FORTRAN interface to CRTL functions</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/fortran-interface-to-crtl-functions/m-p/4747875#M41376</link>
      <description>In general I would discourage direct calls of decc$* routines (except the ones documented in CRTL help): You never know what macros the C compiler is defining/expecting/using.&lt;BR /&gt;See this example:&lt;BR /&gt;&lt;BR /&gt;      program test_ctime&lt;BR /&gt;      character*32 ct&lt;BR /&gt;      integer t&lt;BR /&gt;      integer decc$time&lt;BR /&gt;      external decc$time&lt;BR /&gt;&lt;BR /&gt;      t=0&lt;BR /&gt;      call CTIME_F(t,ct)&lt;BR /&gt;      print *,' t=',t,' ',ct&lt;BR /&gt;&lt;BR /&gt;      print *,' using time_f():'&lt;BR /&gt;      call time_f(t)&lt;BR /&gt;      call CTIME_F(t,ct)&lt;BR /&gt;      print *,' t=',t,' ',ct&lt;BR /&gt;&lt;BR /&gt;      print *,' using decc$time():'&lt;BR /&gt;      t=decc$time()&lt;BR /&gt;      call CTIME_F(t,ct)&lt;BR /&gt;      print *,' t=',t,' ',ct&lt;BR /&gt;      end&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Where time_f.c and ctime_f.c are the wrapper routines at &lt;BR /&gt; &lt;A href="http://www.mpp.mpg.de/~huber/util/" target="_blank"&gt;http://www.mpp.mpg.de/~huber/util/&lt;/A&gt; &lt;BR /&gt;&lt;BR /&gt;fortran test_ctime&lt;BR /&gt;link test_ctime&lt;BR /&gt;show time&lt;BR /&gt;   5-FEB-2011 21:17:07&lt;BR /&gt;run test_ctime&lt;BR /&gt; t=           0  Thu Jan  1 01:00:00 1970   &lt;BR /&gt; using time_f():&lt;BR /&gt; t=  1296937035  Sat Feb  5 21:17:15 2011   &lt;BR /&gt; using decc$time():&lt;BR /&gt; t=  1296940635  Sat Feb  5 22:17:15 2011&lt;BR /&gt;                                             Observe the different values for t !   &lt;BR /&gt;&lt;BR /&gt;There are even more discrepancies when mktime() comes into play:&lt;BR /&gt;&lt;BR /&gt; &lt;A href="http://www.mpp.mpg.de/~huber/util/tests/test_mktime.for" target="_blank"&gt;http://www.mpp.mpg.de/~huber/util/tests/test_mktime.for&lt;/A&gt;&lt;BR /&gt;</description>
      <pubDate>Sat, 05 Feb 2011 20:32:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/fortran-interface-to-crtl-functions/m-p/4747875#M41376</guid>
      <dc:creator>Joseph Huber_1</dc:creator>
      <dc:date>2011-02-05T20:32:42Z</dc:date>
    </item>
    <item>
      <title>Re: FORTRAN interface to CRTL functions</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/fortran-interface-to-crtl-functions/m-p/4747876#M41377</link>
      <description>mktime e.g. needs&lt;BR /&gt;&lt;BR /&gt;#define  _DECC_V4_SOURCE&lt;BR /&gt;#define  _VMS_V6_SOURCE&lt;BR /&gt;#define _TM_LONG&lt;BR /&gt;#define USE_GMTOFF  /* seems always to give the correct offset*/&lt;BR /&gt;#define __USE_XOPEN 1&lt;BR /&gt;#define _XOPEN_SOURCE&lt;BR /&gt;#define  __TM_USE_UTC_TIME&lt;BR /&gt;&lt;BR /&gt;to produce the right result:&lt;BR /&gt;&lt;BR /&gt;sh time&lt;BR /&gt;   6-FEB-2011 10:54:56&lt;BR /&gt;run test_mktime&lt;BR /&gt; 1296989699  ctime_f(decc$time()):&lt;BR /&gt;Sun Feb  6 11:54:59 2011&lt;BR /&gt;                               &lt;BR /&gt; 1296989699  ctime_f(decc$mktime(gmtime_f(decc$time(),tm))):&lt;BR /&gt;Sun Feb  6 11:54:59 2011&lt;BR /&gt;                               &lt;BR /&gt; 1296989699  ctime_f(mktime_f(gmtime_f(decc$time(),tm))):&lt;BR /&gt;Sun Feb  6 11:54:59 2011&lt;BR /&gt;                               &lt;BR /&gt; 1296986099  ctime_f(time_f()):&lt;BR /&gt;Sun Feb  6 10:54:59 2011&lt;BR /&gt;                               &lt;BR /&gt; 1296986099  ctime_f(mktime_f(gmtime_f(time_f(),tm))):&lt;BR /&gt;Sun Feb  6 10:54:59 2011&lt;BR /&gt;&lt;BR /&gt;The results of ctime() should match the VMS show time, they do not if decc$ calls are used without wrappers!&lt;BR /&gt;&lt;BR /&gt;Without that definition,&lt;BR /&gt;ctime_f(mktime_f(gmtime_f(time_f(),tm)))&lt;BR /&gt;is not the same as&lt;BR /&gt; ctime_f(time_f())&lt;BR /&gt;&lt;BR /&gt;So again, direct calls to decc$time,decc$gmtime,decc$mktime do not produce the correct results.</description>
      <pubDate>Sun, 06 Feb 2011 10:06:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/fortran-interface-to-crtl-functions/m-p/4747876#M41377</guid>
      <dc:creator>Joseph Huber_1</dc:creator>
      <dc:date>2011-02-06T10:06:30Z</dc:date>
    </item>
    <item>
      <title>Re: FORTRAN interface to CRTL functions</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/fortran-interface-to-crtl-functions/m-p/4747877#M41378</link>
      <description>Is there an explanation for the different seconds from time() and decc$time() (missing/other c-macros active) or is it a bug? A call to decc$crtl_init() gives the same results.</description>
      <pubDate>Mon, 07 Feb 2011 10:58:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/fortran-interface-to-crtl-functions/m-p/4747877#M41378</guid>
      <dc:creator>Michael Menge</dc:creator>
      <dc:date>2011-02-07T10:58:19Z</dc:date>
    </item>
    <item>
      <title>Re: FORTRAN interface to CRTL functions</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/fortran-interface-to-crtl-functions/m-p/4747878#M41379</link>
      <description>Have a look into &lt;TIME.H&gt;&lt;BR /&gt;If not the behaviour of VMS before V7 is requested by macros like _DECC_V4_SOURCE and _VMS_V6_SOURCE (see HELP CRTL TIME FUNCTION_VAR), then a C time() call uses an __UTC_* entry point. The DECC_V4/VMS_V6* macros would result in time_t to be calculated from local VMS time, resulting in 1 hour difference in my (MET) case, which seems to be the case for direct calls to decc$time().&lt;BR /&gt;&lt;BR /&gt;Other differences come from compiling gmtime(_r) with or without the   __TM_USE_UTC_TIME and *GMTOFF* macros.&lt;BR /&gt;Interestingly I need to compile mktime with the _V4_/_V6_ macros to have the above chain of &lt;BR /&gt; ctime(time()) &lt;BR /&gt;giving the same result as &lt;BR /&gt; ctime(mktime(gmtime(time(),tm))),&lt;BR /&gt;&lt;BR /&gt;but this may be due to the old VMS/DECC version combination I have.&lt;BR /&gt;&lt;/TIME.H&gt;</description>
      <pubDate>Mon, 07 Feb 2011 12:08:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/fortran-interface-to-crtl-functions/m-p/4747878#M41379</guid>
      <dc:creator>Joseph Huber_1</dc:creator>
      <dc:date>2011-02-07T12:08:50Z</dc:date>
    </item>
    <item>
      <title>Re: FORTRAN interface to CRTL functions</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/fortran-interface-to-crtl-functions/m-p/4747879#M41380</link>
      <description>decc$localtime_r returns GMT time and&lt;BR /&gt;decc$gmtime_r returns (as mentioned) only 0:&lt;BR /&gt;program test&lt;BR /&gt;integer tm(0:10),scnds&lt;BR /&gt;scnds = 1301184000 ! 2011-03-27T00:00:00Z&lt;BR /&gt;tm = 0&lt;BR /&gt;call decc$gmtime_r (scnds,tm)&lt;BR /&gt;print *, 'gmt', scnds, tm&lt;BR /&gt;tm = 0&lt;BR /&gt;call decc$localtime_r (scnds,tm)&lt;BR /&gt;print *, 'local', scnds, tm&lt;BR /&gt;&lt;BR /&gt;scnds = 1301194800 ! 2011-03-27T03:00:00Z&lt;BR /&gt;tm = 0&lt;BR /&gt;call decc$gmtime_r (scnds,tm)&lt;BR /&gt;print *, 'gmt', scnds, tm&lt;BR /&gt;tm = 0&lt;BR /&gt;call decc$localtime_r (scnds,tm)&lt;BR /&gt;print *, 'local', scnds, tm&lt;BR /&gt;end&lt;BR /&gt;&lt;BR /&gt;Isn't it a bug for decc$gmtime_r returning nothing or are there any hints not to use it?</description>
      <pubDate>Mon, 07 Feb 2011 15:12:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/fortran-interface-to-crtl-functions/m-p/4747879#M41380</guid>
      <dc:creator>Michael Menge</dc:creator>
      <dc:date>2011-02-07T15:12:06Z</dc:date>
    </item>
    <item>
      <title>Re: FORTRAN interface to CRTL functions</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/fortran-interface-to-crtl-functions/m-p/4747880#M41381</link>
      <description>Replacing decc$gmtime_r by the wrapper routine gmtime_f mentioned above and&lt;BR /&gt;decc$localtime_r by localtime_f.c:&lt;BR /&gt;&lt;BR /&gt;#include &lt;TIME.H&gt;&lt;BR /&gt;struc tm *localtime_f (const time_t *scnds, struc tm *result)&lt;BR /&gt;{&lt;BR /&gt;return localtime_r (scnds, result);&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;gives the correct results.&lt;BR /&gt;&lt;/TIME.H&gt;</description>
      <pubDate>Mon, 07 Feb 2011 15:45:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/fortran-interface-to-crtl-functions/m-p/4747880#M41381</guid>
      <dc:creator>Michael Menge</dc:creator>
      <dc:date>2011-02-07T15:45:32Z</dc:date>
    </item>
    <item>
      <title>Re: FORTRAN interface to CRTL functions</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/fortran-interface-to-crtl-functions/m-p/4747881#M41382</link>
      <description>&amp;gt; decc$localtime_r returns GMT time and&lt;BR /&gt;but -as the name indicates- should return local time.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&amp;gt;decc$gmtime_r returns (as mentioned) only 0:&lt;BR /&gt;&amp;gt;Isn't it a bug for decc$gmtime_r returning &amp;gt;nothing or are there any hints not to use it?&lt;BR /&gt;&lt;BR /&gt;There are no hints not only not to use it, but also no hints to use it.&lt;BR /&gt;&lt;BR /&gt;Since direct calls to decc$* are not documented, all is speculation and mood.</description>
      <pubDate>Mon, 07 Feb 2011 16:05:09 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/fortran-interface-to-crtl-functions/m-p/4747881#M41382</guid>
      <dc:creator>Joseph Huber_1</dc:creator>
      <dc:date>2011-02-07T16:05:09Z</dc:date>
    </item>
    <item>
      <title>Re: FORTRAN interface to CRTL functions</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/fortran-interface-to-crtl-functions/m-p/4747882#M41383</link>
      <description>For the record. HP Fortran for OpenVMS solution. Next time write a corresponding C program and $ cc/list/machine to know which DECC$ entry points the HP C compiler uses.&lt;BR /&gt;&lt;BR /&gt;$ fortran/source_form=free/debug/noopt gmtime.f90&lt;BR /&gt;$ link gmtime&lt;BR /&gt;$ run gmtime&lt;BR /&gt;tm%tm_sec=          21&lt;BR /&gt;tm%tm_min=          18&lt;BR /&gt;tm%tm_hour=          11&lt;BR /&gt;tm%tm_mday=           9&lt;BR /&gt;tm%tm_mon=         111&lt;BR /&gt;tm%tm_wday=           9&lt;BR /&gt;tm%tm_yday=          39&lt;BR /&gt;tm%tm_isdst=           0&lt;BR /&gt;$ type gmtime.f90&lt;BR /&gt;program gmtime&lt;BR /&gt;    implicit none&lt;BR /&gt;    integer(kind=4) t0;&lt;BR /&gt;    integer(kind=4) tm_ptr;&lt;BR /&gt;    external print_tm, decc$perror&lt;BR /&gt;    integer(kind=4),external :: decc$__utc_time ,decc$__utctz_gmtime&lt;BR /&gt;&lt;BR /&gt;    t0=decc$__utc_time(%val(0))&lt;BR /&gt;    tm_ptr=decc$__utctz_gmtime(%ref(t0))&lt;BR /&gt;    if (tm_ptr .eq. 0) then&lt;BR /&gt;        call decc$perror(%ref('gmtime'))&lt;BR /&gt;        stop&lt;BR /&gt;    endif&lt;BR /&gt;    call print_tm(%val(tm_ptr))&lt;BR /&gt;    stop&lt;BR /&gt;end&lt;BR /&gt;&lt;BR /&gt;subroutine print_tm(tm)&lt;BR /&gt;   implicit none&lt;BR /&gt;   type tm_t&lt;BR /&gt;      integer(kind=4) tm_sec&lt;BR /&gt;      integer(kind=4) tm_min&lt;BR /&gt;      integer(kind=4) tm_hour&lt;BR /&gt;      integer(kind=4) tm_mday&lt;BR /&gt;      integer(kind=4) tm_mon&lt;BR /&gt;      integer(kind=4) tm_year&lt;BR /&gt;      integer(kind=4) tm_wday&lt;BR /&gt;      integer(kind=4) tm_yday&lt;BR /&gt;      integer(kind=4) tm_isdst&lt;BR /&gt;      integer(kind=4) tm_gmtoff&lt;BR /&gt;      integer(kind=4) tm_zone&lt;BR /&gt;   end type tm_t&lt;BR /&gt;   type (tm_t) tm&lt;BR /&gt;&lt;BR /&gt;   print *,"tm%tm_sec=",tm%tm_sec&lt;BR /&gt;   print *,"tm%tm_min=",tm%tm_min&lt;BR /&gt;   print *,"tm%tm_hour=",tm%tm_hour&lt;BR /&gt;   print *,"tm%tm_mday=",tm%tm_mday&lt;BR /&gt;   print *,"tm%tm_mon=",tm%tm_year&lt;BR /&gt;   print *,"tm%tm_wday=",tm%tm_mday&lt;BR /&gt;   print *,"tm%tm_yday=",tm%tm_yday&lt;BR /&gt;   print *,"tm%tm_isdst=",tm%tm_isdst&lt;BR /&gt;   return&lt;BR /&gt;end&lt;BR /&gt;</description>
      <pubDate>Wed, 09 Feb 2011 11:23:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/fortran-interface-to-crtl-functions/m-p/4747882#M41383</guid>
      <dc:creator>Ph Vouters</dc:creator>
      <dc:date>2011-02-09T11:23:19Z</dc:date>
    </item>
    <item>
      <title>Re: FORTRAN interface to CRTL functions</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/fortran-interface-to-crtl-functions/m-p/4747883#M41384</link>
      <description>Michael,&lt;BR /&gt;&lt;BR /&gt;The full solution is documented at &lt;A href="http://vouters.dyndns.org/tima/OpenVMS-Fortran-time-gmtime-Calling_time_and_gtime_in_Fortran_OpenVMS.html" target="_blank"&gt;http://vouters.dyndns.org/tima/OpenVMS-Fortran-time-gmtime-Calling_time_and_gtime_in_Fortran_OpenVMS.html&lt;/A&gt;&lt;BR /&gt;Yours truly,&lt;BR /&gt;Philippe</description>
      <pubDate>Wed, 09 Feb 2011 13:14:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/fortran-interface-to-crtl-functions/m-p/4747883#M41384</guid>
      <dc:creator>Ph Vouters</dc:creator>
      <dc:date>2011-02-09T13:14:30Z</dc:date>
    </item>
  </channel>
</rss>

