#=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~=~
#                                      numgeo - GiD interface
#                       Copyright (C) 2023-today Jan Machacek, Rahul Dogra
#=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~=~
#
# Procedure to override the default GiD_Event_SelectGIDBatFile
#
# History
# - 26.09.2024, J. Machacek - Initial version
#
#=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~=~

proc numgeo::Select_GID_Bat_File { project_name basename } {
  set problemtype_tail [file tail [GiD_Info Project ProblemType]] 
  set filename_bat $problemtype_tail.win.bat
  if { $::tcl_platform(platform) != "windows" } {
    set filename_bat $problemtype_tail.unix.bat
  }
  #
  # Set number of cpus
  # 
  set root [$::gid_groups_conds::doc documentElement] ;
  set path {string(//container[@n="_execution_settings_"]/value[@n="_ncpus_"]/@v)}
  set ncpus [$root selectNodes $path]
  # It is important to add the filename_bat at the beginning, otherwise GiD will not find the bat file
  # The four original arguments are still provided to the bat file, although not specified here
  # dont understand why, but it is like this, so append only the new ones
  set result [list $filename_bat $ncpus]
  return $result
}
