!-------------------------------------- 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 stop_world_view - Update status file and stop MPI
*
#include "model_macros_f.h"
*

      subroutine stop_world_view (F_continue_L) 1,8
*
      implicit none
*
      logical F_continue_L
*
*author
*     M. Desgagne
*
*revision
* v2_00 - Desgagne M.       - initial MPI version
* v2_10 - Lee V.            - added watch_pid mechanism (removepid)
* v2_20 - Lee V.            - put version number of code in "exfin"
* v2_21 - Desgagne M.       - rpn_comm stooge for MPI
* v2_30 - Dugas B.          - add call to gemtim
* v2_31 - Dugas B.          - replace F_done_L by F_continue_L and
* v2_31                       modify the documentation accordingly
* v2_31 - Desgagne M.       - remove system call to Um_hook.sh (-post)
* v3_10 - Corbeil & Desgagne & Lee - AIXport+Opti+OpenMP
* v3_11 - M. Desgagne       - change to exfin
*
*object
*
*arguments
*  Name        I/O                 Description
*---------------------------------------------------------------------
* F_continue_L I    -     .true. means the model integration continues
*---------------------------------------------------------------------
*
*implicits
#include "lun.cdk"
#include "ptopo.cdk"
#include "path.cdk"
#include "lctl.cdk"
#include "version.cdk"
*
*modules
      integer exfin, longueur
      external exfin, longueur
*
      character*256 postjob_S
      integer err
*
*-------------------------------------------------------------------
*
      call tmg_stop0 (1)
      call tmg_terminate0 ( Ptopo_myproc, 'GEMDM' ) 
*
#if defined (NEC)
      call flush(5)
      call flush(6)
      if (Lun_out.gt.0) call gemtim (Lun_out)
#endif
*
      call itf_cpl_terminate (Lun_out.gt.0)

      if (Lun_out.gt.0) then
         err = exfin(Version_mod_S//Version_dstp_S,Version_S,'OK')
         write (postjob_S,34) Lctl_step
         postjob_S='_endstep='//postjob_S(1:longueur(postjob_S))
         call write_status_file2 (postjob_S)
         if (F_continue_L) then
            call write_status_file2 ('_status=RS')
         else
            call write_status_file2 ('_status=ED')
         endif
         call close_status_file2 ()
      endif
*
      call rpn_comm_Barrier("grid", err)
      call rpn_comm_FINALIZE(err)
*
 33   format (i6)
 34   format (i10.10)
*-------------------------------------------------------------------
*
      return
      end