The main documentation of the Parallel_Write Procedure contains additional explanation of this code listing.
subroutine Parallel_Write_0 (String, Unit, PE) ! Input variables. type(character,*), intent(in) :: String ! Output string. type(integer), intent(in), optional :: Unit ! Output unit number. type(integer), intent(in), optional :: PE ! Output PE number. ! Internal variables. type(character,LEN(String),1) :: IO_String ! Assembled output string. type(integer) :: IO_Unit ! Actual output unit number. type(integer) :: i ! Loop counter. !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ! Verify requirements - none. ! Initialize (on all PEs) and assemble the IO PE variable. call Initialize (IO_String, NPEs) call Assemble (IO_String, String) ! Only output on the IO PE. if (this_is_IO_PE) then ! Set unit number. if (PRESENT(Unit)) then IO_Unit = Unit else IO_Unit = 6 end if ! Output for a single PE. if (PRESENT(PE)) then write (IO_Unit,100) TRIM(IO_String(PE)) ! Output for all the PEs. else do i = 1, NPEs write (IO_Unit,100) TRIM(IO_String(i)) end do end if ! Format statement. 100 format (a) end if ! Finalize variable. call Finalize (IO_String) ! Verify guarantees - none. return end subroutine Parallel_Write_0 subroutine Parallel_Write_1 (String, Unit, PE) ! Input variables. type(character,*,1,np), intent(in) :: String ! Output string. type(integer), intent(in), optional :: Unit ! Output unit number. type(integer), intent(in), optional :: PE ! Output PE number. ! Internal variables. type(character,LEN(String),1) :: IO_String ! Assembled output string. type(integer) :: IO_Unit ! Actual output unit number. type(integer) :: i ! Loop counter. type(integer,1) :: Length_Vector ! Vector of lengths for each PE. type(integer) :: Length_PE ! Lengths on each PE. !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ! Verify requirements - none. ! Initialize (on all PEs) and assemble the IO PE variables. Length_PE = SIZE(String) call Initialize (Length_Vector, NPEs) call Assemble (Length_Vector, Length_PE) call Initialize (IO_String, SUM(Length_Vector)) call Assemble (IO_String, String) ! Only output on the IO PE. if (this_is_IO_PE) then ! Set unit number. if (PRESENT(Unit)) then IO_Unit = Unit else IO_Unit = 6 end if ! Output for a single PE. if (PRESENT(PE)) then do i = SUM(Length_Vector(1:PE-1)) + 1, SUM(Length_Vector(1:PE)) write (IO_Unit,100) TRIM(IO_String(i)) end do ! Output for all the PEs. else do i = 1, SUM(Length_Vector) write (IO_Unit,100) TRIM(IO_String(i)) end do end if ! Format statement. 100 format (a) end if ! Finalize variables. call Finalize (Length_Vector) call Finalize (IO_String) ! Verify guarantees - none. return end subroutine Parallel_Write_1