	program parallel_demo
	implicit none

	integer fork, wait
	external fork, wait

	integer result, pid

	result = 999

* fork starts new process,
* returns 0 to child, pid of child to parent
	if( fork() .eq. 0 ) then
	  call calculation("child", result, 4711, 25)
	  call exit(0)
	endif

	print *, "result = ", result

	call calculation("parent", result, 672, 1717)

* wait for child process to finish
	pid = wait(0)
	end

************************************************************

	subroutine calculation(caller, result, a, b)
	implicit none
	character*(*) caller
	integer result, a, b

	result = a + b

	print *, caller, "'s result: ", result
	end

