Dear Robert, Rafael,

So, I ran Rafael's code on my Mac, with R 2.13.1 installed.  Script ran 
for a long time. Note that there is 10-fold cross-validation going on 
here.  This brings up the possibility that Rafael's script did not run 
long enough on his 2.13..2 installation for the problem to arise.

We won't know if this is still a problem with versions later than 13.1 
until we run a script that calls maxent() perhaps 200 times.

Best,

Peter

Here is the code, screen output to show the number of calls to maxent(), 
traceback(), and sessionInfo()
(on an 8 core Mac Pro with 14 G memory).



######################################

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

 > Loading required package: JGR
Loading required package: rJava
Loading required package: JavaGD
Loading required package: iplots
starting httpd help server ... done

 > ## libraries
 > library(raster)
Loading required package: sp
raster version 1.9-58 (21-December-2011)
Warning message:
package 'raster' was built under R version 2.13.2
 > library(maptools)
Loading required package: foreign
Loading required package: lattice
Checking rgeos availability: FALSE
      Note: when rgeos is not available, polygon geometry     
computations in maptools depend on gpclib,
      which has a restricted licence. It is disabled by default;
      to enable gpclib, type gpclibPermit()
 > ## set working directory
 > #please adapt!
 > setwd('/Users/pearman/dropbox/Rafi_and_Peter/maxent_runs/')
 > ## source function
 > #source('run4models_restios_.r')
 > source('run4models_res_clust.r')
 > ### load data
 > ## species data
 > load('data/restio_abs')
 > load('data/restio_pres')
 > load('data/restio_list')
 > ## environmental layers
 > 
envstack<-stack(paste('data/gis/envstack/',list.files('data/gis/envstack/'),sep=''))
Geospatial Data Abstraction Library extensions to R successfully loaded
Loaded GDAL runtime: GDAL 1.8.1, released 2011/07/09
Path to GDAL shared files: 
/Library/Frameworks/GDAL.framework/Versions/1.8/Resources/gdal
Loaded PROJ.4 runtime: Rel. 4.7.1, 23 September 2009, [PJ_VERSION: 470]
Path to PROJ.4 shared files: (autodetected)
 > ## study area boundaries
 > cfr_poly<-readShapeSpatial('data/gis/mask_poly')
 > ## parameter sets
 > load('data/para_list')
 > ### call function for the specified set of species
 > ## define set of species
 > specset<-unlist(restio_list)
 > ## run function
 > run4models(presences=restio_pres,
+ absences=restio_abs,
+ npseudabs=15000,
+ species=specset,
+ envstack=envstack,
+ area=cfr_poly,
+ paraset=para_list,
+ models=c('me'),
+ #models=c('gbm','gam','glm','me'),
+ k=10,
+ resdir='results_me',
+ 
#gbm.args=list(n.trees=10000,shrinkage.bound=c(0.00005,0.001),interaction.depth=3,maxiter=5),
+ 
maxent.args=c('-J','-P','threshold=false','product=false','quadratic=false','linear=false'),
+ seed=42,
+ plot=FALSE,
+ help=FALSE)
Loading required package: splines
Loading required package: survival
Loaded gbm 1.6-3.1
Found 42 region(s) and 42 polygon(s)



################################
### Anthochortus crinalis
################################

Parameter set 1
################

-------------------
||| starting maxent - parameter set 1 of Anthochortus_crinalis
-------------------
=> fit the model
=> CrossValidation > 1 > 2 > 3 > 4 > 5 > 6 > 7 > 8 > 9 > 10

Parameter set 2
################

-------------------
||| starting maxent - parameter set 2 of Anthochortus_crinalis
-------------------
=> fit the model
=> CrossValidation > 1 > 2 > 3 > 4 > 5 > 6 > 7 > 8 > 9 > 10

Parameter set 3
################

-------------------
||| starting maxent - parameter set 3 of Anthochortus_crinalis
-------------------
=> fit the model
=> CrossValidation > 1 > 2 > 3 > 4 > 5 > 6 > 7 > 8 > 9 > 10

Parameter set 4
################

-------------------
||| starting maxent - parameter set 4 of Anthochortus_crinalis
-------------------
=> fit the model
=> CrossValidation > 1 > 2 > 3 > 4 > 5 > 6 > 7 > 8 > 9 > 10

Parameter set 5
################

-------------------
||| starting maxent - parameter set 5 of Anthochortus_crinalis
-------------------
=> fit the model
=> CrossValidation > 1 > 2 > 3 > 4 > 5 > 6 > 7 > 8 > 9 > 10

Parameter set 6
################

-------------------
||| starting maxent - parameter set 6 of Anthochortus_crinalis
-------------------
=> fit the model
=> CrossValidation > 1 > 2 > 3 > 4 > 5 > 6 > 7 > 8 > 9 > 10

Parameter set 7
################

-------------------
||| starting maxent - parameter set 7 of Anthochortus_crinalis
-------------------
=> fit the model
=> CrossValidation > 1 > 2 > 3 > 4 > 5 > 6 > 7 > 8 > 9 > 10

Parameter set 8
################

-------------------
||| starting maxent - parameter set 8 of Anthochortus_crinalis
-------------------
=> fit the model
=> CrossValidation > 1 > 2 > 3 > 4 > 5 > 6 > 7 > 8 > 9 > 10


################################
### Restio distractus
################################

Parameter set 1
################

-------------------
||| starting maxent - parameter set 1 of Restio_distractus
-------------------
=> fit the model
=> CrossValidation > 1 > 2 > 3 > 4 > 5 > 6 > 7 > 8 > 9 > 10

Parameter set 2
################

-------------------
||| starting maxent - parameter set 2 of Restio_distractus
-------------------
=> fit the model
=> CrossValidation > 1 > 2 > 3 > 4 > 5 > 6 > 7 > 8 > 9 > 10

Parameter set 3
################

-------------------
||| starting maxent - parameter set 3 of Restio_distractus
-------------------
=> fit the model
=> CrossValidation > 1 > 2 > 3 > 4 > 5 > 6 > 7 > 8 > 9 > 10

Parameter set 4
################

-------------------
||| starting maxent - parameter set 4 of Restio_distractus
-------------------
=> fit the model
=> CrossValidation > 1 > 2 > 3 > 4 > 5 > 6 > 7 > 8 > 9 > 10

Parameter set 5
################

-------------------
||| starting maxent - parameter set 5 of Restio_distractus
-------------------
=> fit the model
=> CrossValidation > 1 > 2 > 3 > 4 > 5 > 6 > 7 > 8 > 9 > 10

Parameter set 6
################

-------------------
||| starting maxent - parameter set 6 of Restio_distractus
-------------------
=> fit the model
=> CrossValidation > 1 > 2 > 3 > 4 > 5 > 6 > 7 > 8 > 9 > 10

Parameter set 7
################

-------------------
||| starting maxent - parameter set 7 of Restio_distractus
-------------------
=> fit the model
=> CrossValidation > 1 > 2 > 3 > 4 > 5 > 6 > 7 > 8 > 9 > 10

Parameter set 8
################

-------------------
||| starting maxent - parameter set 8 of Restio_distractus
-------------------
=> fit the model
=> CrossValidation > 1 > 2 > 3 > 4 > 5 > 6 > 7 > 8 > 9 > 10


################################
### Thamnochortus muirii
################################

Parameter set 1
################

-------------------
||| starting maxent - parameter set 1 of Thamnochortus_muirii
-------------------
=> fit the model
=> CrossValidation > 1Error in file(con, "r") : cannot open the connection
In addition: Warning message:
In file(con, "r") :
   cannot open file 
'/var/folders/N0/N0KnkG3wG9Sz1BGWvEbmp+++wjA/-Tmp-/R_raster_tmp/maxent/7961801842/species.lambdas': 
No such file or directory
 > traceback()
7: file(con, "r")
6: readLines(paste(dirout, "/species.lambdas", sep = ""))
5: unlist(readLines(paste(dirout, "/species.lambdas", sep = "")))
4: .local(x, p, ...)
3: maxent(train.data.back, train.data.occ, args = me.args) at 
run4models_res_clust.r#589
2: maxent(train.data.back, train.data.occ, args = me.args) at 
run4models_res_clust.r#589
1: run4models(presences = restio_pres, absences = restio_abs, npseudabs 
= 15000,
        species = specset, envstack = envstack, area = cfr_poly,
        paraset = para_list, models = c("me"), k = 10, resdir = 
"results_me",
        maxent.args = c("-J", "-P", "threshold=false", "product=false",
            "quadratic=false", "linear=false"), seed = 42, plot = FALSE,
        help = FALSE)
 > sessionInfo()
R version 2.13.1 (2011-07-08)
Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)

locale:
[1] C

attached base packages:
[1] splines   stats     graphics  grDevices utils     datasets  methods
[8] base

other attached packages:
  [1] gbm_1.6-3.1           survival_2.36-9       gam_1.04.1
  [4] dismo_0.7-8           PresenceAbsence_1.1.5 rgdal_0.7-5
  [7] maptools_0.8-10       lattice_0.19-33       foreign_0.8-45
[10] raster_1.9-58         sp_0.9-88             JGR_1.7-7
[13] iplots_1.1-4          JavaGD_0.5-4          rJava_0.9-1

loaded via a namespace (and not attached):
[1] grid_2.13.1  tools_2.13.1
Warning message:
'DESCRIPTION' file has 'Encoding' field and re-encoding is not possible
 >
-------- Original Message --------
Subject: 	Re: [R-sig-Geo] connection error when calling maxent()
Date: 	Thu, 12 Jan 2012 15:27:35 +0100
From: 	Rafael Wüest <rafael.wueest@wsl.ch>
To: 	Robert J. Hijmans <r.hijmans@gmail.com>
CC: 	r-sig-geo@r-project.org



>  It appears that the MaxEnt output file gets overwritten by another process.

Yes, I also have this impression after some testing (e.g. the temporary raster directories got emptied every time I started a new R raster session in parallel).

The problem disappeared when I updated to R 2.13.2, so no more worries from my side!

Many thanks for the help and the development of raster and associates - it's just great!

Rafael

On 12.01.2012, at 01:33, Robert J. Hijmans wrote:

>  Rafael,
>
>  Please send more info about what you are doing. It appears that the MaxEnt output file gets overwritten by another process. Can you also send your sessionInfo() (after first updating R to a more recent version)?
>
>  Robert
>
>
>  On Wed, Jan 4, 2012 at 8:52 AM, rafael.wueest<rafael.wueest@wsl.ch>  wrote:
>  Hi Folks
>
>  when I am trying to call the maxent() function within a function I created,
>  I am getting the following error:
>
>  Error in file(con, "r") : cannot open the connection
>  In addition: Warning message:
>  In file(con, "r") :
>   cannot open file
>  '/var/folders/ft/fthJYD+6GkCvmcCArZBaQU++waU/-Tmp-/R_raster_tmp/maxent/10943312360/species.lambdas':
>  No such file or directory
>
>  I am here also pasting some output of
>  >traceback()
>  7: file(con, "r")
>  6: readLines(paste(dirout, "/species.lambdas", sep = ""))
>  5: unlist(readLines(paste(dirout, "/species.lambdas", sep = "")))
>  4: .local(x, p, ...)
>  3: maxent(background, occ, args = me.args) at run4models_restios.r#558
>  ...
>
>  I am using JGR on a Mac and downloaded the newest dismo (CRAN sources) and
>  maxent version (see below).
>
>  Can anyone help me? I am happy to provide more detailed information...
>
>  Rafa
>
>  >maxent()
>  This is MaxEnt version 3.3.3k
>
>  >sessionInfo()
>  R version 2.12.2 (2011-02-25)
>  Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)
>
>  locale:
>  [1] C
>
>  attached base packages:
>  [1] splines   stats     graphics  grDevices utils     datasets  methods
>  [8] base
>
>  other attached packages:
>   [1] gbm_1.6-3.1           survival_2.36-5       gam_1.04.1
>   [4] PresenceAbsence_1.1.5 maptools_0.8-10       lattice_0.19-33
>   [7] foreign_0.8-42        rgdal_0.6-33          dismo_0.7-14
>  [10] raster_1.9-13         sp_0.9-84             JGR_1.7-7
>  [13] iplots_1.1-4          JavaGD_0.5-4          rJava_0.9-1
>
>  loaded via a namespace (and not attached):
>  [1] grid_2.12.2  tools_2.12.2
>  Warning message:
>  'DESCRIPTION' file has 'Encoding' field and re-encoding is not possible
>
>
>  --
>  View this message in context: http://r-sig-geo.2731867.n2.nabble.com/connection-error-when-calling-maxent-tp7151125p7151125.html
>  Sent from the R-sig-geo mailing list archive at Nabble.com.
>
>  _______________________________________________
>  R-sig-Geo mailing list
>  R-sig-Geo@r-project.org
>  https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>



--
Rafael Wüest
Swiss Federal Research Institute WSL
Zürcherstrasse 111
8903 Birmensdorf
Switzerland

+41 44 7392126
rafael.wueest@wsl.ch
http://www.wsl.ch/info/mitarbeitende/wueest

_______________________________________________
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo



-- 
Peter B. Pearman, Ph.D.
Land Use Dynamics
Swiss Federal Research Institute WSL
Zürcherstrasse 111
8903 Birmensdorf
Switzerland

pearman@wsl.ch
Tel. ++41 (0)44 739 2524
Fax ++41 (0)44 739 2215

Homepage:
<http://www.wsl.ch/info/mitarbeitende/pearman>

Swiss National Fund Projects:
Evolutionary Niche dyNamics of Invasive Species
'ENNIS'<http://www.wsl.ch/fe/landschaftsdynamik/projekte/ennis/index_EN>

Spatially Explicit Evolution of Diversity
'SPEED'<http://www.wsl.ch/fe/landschaftsdynamik/projekte/speed/index_EN>


	[[alternative HTML version deleted]]

