<p>I am helping an undergrad with their project and their thesis advisor has requested they use GENELAND for their analysis. I haven't worked on this sort of analysis, so all I have done is install it in their R, hand over the manual, and help troubleshoot any errors they can't resolve. </p>

<p>We've gotten the analysis through the MCMC stage and are getting an error with the PostProcessingChain command.</p>

<p>Their MCMC command is: </p>

<pre><code>MCMC(geno.hap=geno1, spatial=FALSE, nb.nuclei.max=3, 
    varnpop=TRUE, freq.model="Uncorrelated", 
    filter.null.alleles=FALSE, nit=100000, 
    thinning=100, npopmin=1, npopinit=3, 
    npopmax=10, rate.max=3, delta.coord=0, 
    path.mcmc="/Users/myname/localdoc/GENELAND")
</code></pre>

<p>Their PostProcessChain command is: </p>

<pre><code>PostProcessChain(coordinates=gene1coord.utm, 
    path.mcmc ="/Users/myname/localdoc/GENELAND/", 
    nxdom=100, nydom=100, burnin=200)
</code></pre>

<p>This is exactly the same command as in the manual, and <code>gene1coord.utm</code> is an R object with the coordinates transformed into UTM coordinates. The error we receive is:</p>

<p><a href="https://i.sstatic.net/avlCv.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/avlCv.png" alt="Fortran runtime error: File already opened in another unit"></a></p>

<pre><code>([1] "Calling Fortran function postprocesschain2"

At line 12334 of file main.f (unit = 10)

Fortran runtime error: File already opened in another unit)
</code></pre>

<p>I have tried <code>fix(PostProcessChain)</code> to see if there's something I can adjust and this is what I see for the section that shows up:</p>

<p><a href="https://i.sstatic.net/tqUoE.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/tqUoE.png" alt="fix(PostProcessChain)"></a></p>

<p>So far, here is the list of things I have tried:</p>

<ul>
<li>Reinstall X11</li>
<li>Reinstall gfortran</li>
<li>make sure that R is 3.4.x as the GENELAND package suggests</li>
<li>Tried different parameters on MCMC just in case it was user error</li>
<li>Tried different parameters on PostProcessChain, but they're the same as the manual really</li>
<li>Tried different kinds of coordinates</li>
<li>Tried a spatial analysis instead of a non-spatial</li>
<li>Googled the error</li>
<li>Restarted the computer</li>
</ul>

<p>Alternatively, is there another program that does similar analysis to geneland? I'm not sure if the advisor recommended it because it's the only thing that does what it does or because that's just what they used back in the day.</p>

<p>Edit: There were 3 blank files in the folder titled %FO, P, and x. When I deleted them the "file open" error went away but it still hangs up on [ 1 ] <code>Calling Fortran function postprocesschain2</code> and has a fatal error that crashes R.</p>

CC BY-SA 4.0
2019-03-07T19:21:19.017Z
I don't suppose the file is currently being accessed by anything else, right? Just to be 100% sure, have you tried rebooting (in case something weird happened and you have a stale open file handle somewhere)? Also, please avoid posting images of text. That makes it considerably harder for us to copy the error and look for it.
terdon
CC BY-SA 4.0
2019-03-07T21:30:04.487Z
@terdon Thanks, no one/nothing else could be accessing the files but R. There isn't even a file called "main.f" or any files with 12000 lines in the folder the MCMC output goes to, and PostProcessChain accesses.

I tried a restart and it changed nothing.
Kate Sheridan
<r><phylogenetics>
Geneland R + Fortran error?
# Geneland R + Fortran error?

(Asked by: username_0 on 2019-03-07)

I am helping an undergrad with their project and their thesis advisor has requested they use GENELAND for their analysis. I haven't worked on this sort of analysis, so all I have done is install it in their R, hand over the manual, and help troubleshoot any errors they can't resolve. 
We've gotten the analysis through the MCMC stage and are getting an error with the PostProcessingChain command.
Their MCMC command is: 
MCMC(geno.hap=geno1, spatial=FALSE, nb.nuclei.max=3, 
    varnpop=TRUE, freq.model="Uncorrelated", 
    filter.null.alleles=FALSE, nit=100000, 
    thinning=100, npopmin=1, npopinit=3, 
    npopmax=10, rate.max=3, delta.coord=0, 
    path.mcmc="/Users/myname/localdoc/GENELAND")

Their PostProcessChain command is: 
PostProcessChain(coordinates=gene1coord.utm, 
    path.mcmc ="/Users/myname/localdoc/GENELAND/", 
    nxdom=100, nydom=100, burnin=200)

This is exactly the same command as in the manual, and gene1coord.utm is an R object with the coordinates transformed into UTM coordinates. The error we receive is:

([1] "Calling Fortran function postprocesschain2"

At line 12334 of file main.f (unit = 10)

Fortran runtime error: File already opened in another unit)

I have tried fix(PostProcessChain) to see if there's something I can adjust and this is what I see for the section that shows up:

So far, here is the list of things I have tried:

Reinstall X11
Reinstall gfortran
make sure that R is 3.4.x as the GENELAND package suggests
Tried different parameters on MCMC just in case it was user error
Tried different parameters on PostProcessChain, but they're the same as the manual really
Tried different kinds of coordinates
Tried a spatial analysis instead of a non-spatial
Googled the error
Restarted the computer

Alternatively, is there another program that does similar analysis to geneland? I'm not sure if the advisor recommended it because it's the only thing that does what it does or because that's just what they used back in the day.
Edit: There were 3 blank files in the folder titled %FO, P, and x. When I deleted them the "file open" error went away but it still hangs up on [ 1 ] Calling Fortran function postprocesschain2 and has a fatal error that crashes R.

**Tags:** r, phylogenetics
> **Comments:**
> **username_1**: I don't suppose the file is currently being accessed by anything else, right? Just to be 100% sure, have you tried rebooting (in case something weird happened and you have a stale open file handle somewhere)? Also, please avoid posting images of text. That makes it considerably harder for us to copy the error and look for it.  
> **username_0**: @terdon Thanks, no one/nothing else could be accessing the files but R. There isn't even a file called "main.f" or any files with 12000 lines in the folder the MCMC output goes to, and PostProcessChain accesses.  I tried a restart and it changed nothing.  

---

## 0 answers

