pyne/pyne — pull request #512 by elliottbiondo (2014-08-21 19:18:48+00:00)
Title: Fortran

This PR adds a thin Fortran interface to the ```Sampler``` class so that it can be used with MCNP5. The ```mcnp_sampling_setup_()``` function (trailing underscore necessary for Fortran name mangling) reads a mesh file called "source.h5m" with the tag "source_density" and optionally "biased_source_density". Sampling modes (analog, uniform, user) are specified by passing a single integer argument. A global instance of the ```Sampler``` class is created so that only 1 instance exists per node when MPI is used (to save memory). The ```mcnp_particle_birth_()``` function can then be called to generate particle birth parameters.

This code can be run from Fortran very easily. Here is a test program that reads a mesh and prints 5000 samples to a "samples.out" file:
```fortran
program psuedo_mcnp
implicit none
double precision :: xxx, yyy, zzz, erg, wgt
double precision, dimension(6) :: rands
integer:: i, j, mode
integer, parameter :: out_unit=2
mode = 1
call mcnp_sampling_setup(mode)

open(unit=out_unit,file="samples.out", action="write", status="replace")

do i=1,5000
do j=1,6
rands(j) = RAND()
end do
call mcnp_particle_birth(rands, xxx, yyy, zzz, erg, wgt)
write(out_unit,*) xxx, yyy, zzz, erg, wgt
end do
end program psuedo_mcnp
```
Assuming this program is called wrapper.F90 it can be compiled like:
```
gfortran wrapper.F90 -lpyne -lstdc++
```

In order to use this in MCNP5, a source.F90 subroutine is required. I am currently maintaining one [here](https://github.com/elliottbiondo/sourceF90/blob/master/source.F90). Using this source.F90 I have successfully compiled MCNP5 with MPI and repeated one of the trials from my RPSD paper and gotten the same results.

I am not sure if the source.F90 belongs in PyNE or not. If it does, where should I put it? I should note all of this work is subject to change as I make progress on my thesis work.

@makeclean should probably have a look at this.