!-------------------------------------- LICENCE BEGIN ------------------------------------
!Environment Canada - Atmospheric Science and Technology License/Disclaimer, 
!                     version 3; Last Modified: May 7, 2008.
!This is free but copyrighted software; you can use/redistribute/modify it under the terms 
!of the Environment Canada - Atmospheric Science and Technology License/Disclaimer 
!version 3 or (at your option) any later version that should be found at: 
!http://collaboration.cmc.ec.gc.ca/science/rpn.comm/license.html 
!
!This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 
!without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
!See the above mentioned License/Disclaimer for more details.
!You should have received a copy of the License/Disclaimer along with this software; 
!if not, you can write to: EC-RPN COMM Group, 2121 TransCanada, suite 500, Dorval (Quebec), 
!CANADA, H9P 1J3; or send e-mail to service.rpn@ec.gc.ca
!-------------------------------------- LICENCE END --------------------------------------
***s/r gemtim3 - Print out date and cpu statistics
*
#include "model_macros_f.h"
*

      subroutine gemtim3 ( unf ) 4
      implicit none
*
      integer unf
*author
*     B. Dugas
*
*revision
*
*arguments
* unf           I  - standard out unit number
**
      logical, save :: timini_L
      data timini_L / .false. /
*
#if defined (AIX)
c#include "cstv.cdk"
      integer get_max_rss
      external get_max_rss
      real    spJour,Jour
      integer Used0,Used,SoftLim,HardLim,ppjour
      integer maxJour,Hold_Rsti,ierr
      save    Used0,ppJour,Jour
*
      character date_S*8 ,time_S*10
      character jour_S*11,heure_S*10
      real          users,systs
      real, save :: user0,syst0
      data          user0,syst0 / 0.0, 0.0 /
*----------------------------------------------------------------
*
      if (unf.le.0) return
*
c      call RPN_COMM_bcast( Step_rsti,1,"MPI_INTEGER",0,"grid",ierr )

      call date_and_time( date_S,time_S )
      jour_S  = date_S(1:4)//'/'//date_S(5:6)//'/'//date_S(7:8)//' '
      heure_S = time_S(1:2)//'h'//time_S(3:4)//'m'//time_S(5:6)//'s,'
*
      call setrteopts('cpu_time_type=total_usertime')
      call cpu_time( users )
*
      call setrteopts('cpu_time_type=total_systime')
      call cpu_time( systs )
*
      if (timini_L)  write(unf,1000)
     +    ' At '//jour_S//heure_S, users-user0, systs-syst0,get_max_rss()
*
      user0 = users
      syst0 = systs
#endif
      timini_L = .true.
*
*----------------------------------------------------------------
 1000    format(/A,' User Time (sec) : ',f10.6,
     +             ' Sys  Time (sec) : ',f10.6,
     +            ', Mem (Kbytes/PE) : ',i10)
 1001    format(/  ' In GEMTIM2, Step_rsti reset to ',I4) 
*
      return
      end