      SUBROUTINE WRITE_ACT_MPI(MY_ID,IRPT,ACPT,ACTDIF,ACTSUM1,ACTSUM2)
C Bernd Berg Jun 8 2008.
C Write act in MPI lattice gauge theory simulations (nlat=1,2).
C IUO   Write to main output file (assumed to be open).
      include '../../Libs/Fortran/implicit.sta'
      include 'mpif.h'
      include '../../Libs/Fortran/constants.par'
      include '../../Libs/Fortran_par/latmpi.par'
      include '../../Libs/Fortran_par/mc.par' ! Contains IUO.
      include '../../Libs/MPI_par/common_cblat.f' 
c     include '../../Libs/MPI_par/common_cbu1.f' 
      common/acthw/acthw1,acthw2
      ltest=.true.
      ltest=.false.
      IF(MY_ID.EQ.0) THEN
        IF(NLAT.EQ.1) THEN
          IF(IRPT.LT.1) THEN
            WRITE(IUO,'(/,2X,"ACPT,ACTDIF,ACTSUM1,ACTSUM2:")')
            WRITE(IUO,'(F7.3,3G15.6)') ACPT,ACTDIF,ACTSUM1,ACTSUM2
          ELSE 
            IF(IRPT.EQ.1) WRITE(IUO,'(/,2X,
     &        "IRPT,ACPT,ACTDIF,ACTSUM1,ACTSUM2:",/)')
            WRITE(IUO,'(I6,F7.3,3G15.6)') 
     &         IRPT,ACPT,ACTDIF,ACTSUM1,ACTSUM2
          ENDIF
        ELSE
          IF(IRPT.LT.1) THEN
            WRITE(IUO,'(/,2X,"ACPT,  ACTDIF,",4X,"ACTSUM1,",3X,
     &                  "ACTSUM2,",5X,"acthw1,",5X,"acthw2:")')
            WRITE(IUO,'(F7.3,5G12.4)') ACPT,ACTDIF,ACTSUM1,ACTSUM2,
     &                                 acthw1,acthw2
          ELSE 
            IF(IRPT.EQ.1) WRITE(IUO,'(/,2X,"IRPT ACPT",3X,"ACTDIF",6X,
     &             "ACTSUM1",5X,"ACTSUM2",5X,"acthw1",5X,"acthw2",/)')
            WRITE(IUO,'(I5,F7.3,5G12.4)') IRPT,ACPT,ACTDIF,
     &                        ACTSUM1,ACTSUM2,acthw1,acthw2
          ENDIF 
        ENDIF
      ENDIF
      if(ltest) then 
        close(iud2)
        call mpi_finalize(ierr)
      stop "write_act_mpi: ltest."
      endif
      RETURN
      END
