#=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~=~
#                    numgeo - GiD interface
#             Copyright (C) 2023-today Jan Machacek, Rahul Dogra
#=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~=~
#
# History
# - 26.11.2023, J. Machacek - Initial version
# - 12-02-2025, R. Dogra - Added units in Degree 
# - 12-02-2025, R. Dogra - Added Delta_max and Delta_min for FoS
# - 03.03.2025, R. Dogra - Added truss elements
# - 07.03.2025, R. Dogra - Added beam elements
# - 10.03.2025, R. Dogra - Added rotation boundary condition 
# - 16.03.2025, R. Dogra - Added mass point 
# - 02.04.2025, R. Dogra - Added flexible boundary conditions
# - 11.04.2025, R. Dogra - Added embedded regions
# - 07.05.2025, R. Dogra - Added no cutback option
# - 16.05.2025, J. Machacek - Fix *Output, field for cases where no field output is prescribed
# - 05.06.2025, R. Dogra - Fix Equal DOF assigned to many groups
# - 21.06.2025, R. Dogra - Removed repetition in Contacts
# - 24.06.2025, R. Dogra - Added stiffness factor in tangential contacts
# - 25.06.2025, R. Dogra - Added optional parameters for Hypo-ISA   
# - 19.08.2025, R. Dogra - Added FPL-Stabilisation
# - 19.08.2025, J. Machacek - Fix Modified-Cam-Clay param
# - 16.09.2025, R. Dogra - Added flow condition (in/out-flow) 
# - 18.09.2025, R. Dogra - Added HYPO-IGS2 and Improve HYPO-ISA 
# - 19.09.2025, R. Dogra - Added Mohr-Coulomb-3 
# - 23.09.2025, R. Dogra - Corrected fluctuation state variable
# - 25.09.2025, R. Dogra - Added spatial state variable
# - 26.10.2025, R. Dogra - Added Hydraulic models 
# - 27.10.2025, R. Dogra - Discretisation outside tangential contact
# - 28.10.2025, R. Dogra - Added optional parameters for MC model 
# - 29.10.2025, R. Dogra - Added optional parameters for Sanisand model 
# - 29.10.2025, R. Dogra - Added optional parameters for MCC model 
# - 29.10.2025, R. Dogra - Added Hypoplastic-GIS
# - 30.10.2025, R. Dogra - Updated contact: Added adhesion
# - 02.11.2025, R. Dogra - Added reduction in contact
# - 24.11.2025, R. Dogra - Changed material visibility
# - 25.11.2025, R. Dogra - Added AVISA model
# - 29.12.2025, R. Dogra - Added Hardening-Soil model
# - 20.01.2026, R. Dogra - Added warnings to assign material
# - 27.01.2026, R. Dogra - Added error for an empty group
# - 17.02.2026, R. Dogra - Added Neo Hooke 2 model 
# - 28-04-2026, R. Dogra - Added Coulomb contact model as per numgeo 2026
# Memo:
# - get_domnode_attribute returns the current value of "n" (name) of $group
#
#
#=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~~=~=~

proc numgeo::WriteCalculationFile { filename ModelName} {

  set filenameMesh $ModelName
  append filenameMesh "-mesh"
  append filename "-calculation.inp"

  customlib::InitWriteFile $filename
  
  # xml document to get some tree data
  set root [$::gid_groups_conds::doc documentElement] ;
  
  customlib::WriteString "**=================================================================="
  customlib::WriteString "**            numgeo input file"  
  customlib::WriteString "**=================================================================="
  customlib::WriteString "**"  
  customlib::WriteString "** Input file for the finite element code numgeo (Machacek & Staubach)"
  customlib::WriteString "**"   
  customlib::WriteString "** The input file was created by numgeo-GiD (Machacek & Dogra)"   
  customlib::WriteString "**"   
  customlib::WriteString "** numgeo is available from www.numgeo.de"   
  customlib::WriteString "** numgeo-GiD can be downloaded from https://j-machacek.github.io/numgeo-gid/download/index.html" 
  customlib::WriteString "**"  
  customlib::WriteString "** Contact:"
  customlib::WriteString "** - Jan Machacek, jan.machacek@tu-darmstadt.de"
  customlib::WriteString "** - Rahul Dogra, rahul.dogra@tu-darmstadt.de"
  customlib::WriteString "**"
  customlib::WriteString "**=================================================================="
  
  #
  # Import mesh
  # 
  customlib::WriteString "**"
  customlib::WriteString "** Mesh"
  customlib::WriteString "**"
  GiD_WriteCalculationFile puts "*Include = $filenameMesh"
  
  set document [$::gid_groups_conds::doc documentElement]  
  
  #
  # Error empty group
  #
  set group_list [GiD_Groups list]
  foreach group_name $group_list {
    set has_entities 0
    foreach etype {points lines surfaces volumes nodes elements} {
      if {[llength [GiD_EntitiesGroups get $group_name $etype]] > 0} {
        set has_entities 1
        break
      }
    }
    if {!$has_entities} {
      error [= "Group '$group_name' is empty or nothing is assigned to it. Please assign node/element/point/line/surface/volume to the group '$group_name'."]
    }
  }
  
  #
  # Solid Section
  # 
  set xp [format_xpath {container[@n="_assign_material"]/condition[@n="_solid_sections_"]/group}]
  set group [$document selectNodes $xp]
  if {[llength $group] == 0} {
    WarnWin [= "Please check: Material is not assigned properly"]
  }
  foreach group [$document selectNodes $xp] {
    set group_name [get_domnode_attribute $group n]
    set node [$group selectNodes "./value\[@n = '_material_'\]"]
    set material [get_domnode_attribute $node v]
    customlib::WriteString "**"
    customlib::WriteString "** Solid Sections"
    customlib::WriteString "**"
    GiD_WriteCalculationFile puts "*Assign material, elset=$group_name, material=$material"
  }
  customlib::WriteString ""
  
  # Truss Sections 
  set document [$::gid_groups_conds::doc documentElement]
  set xp [format_xpath {container[@n="_assign_material"]/condition[@n="_truss_sections_"]/group}]
  foreach group [$document selectNodes $xp] {
    set group_name [get_domnode_attribute $group n]
    set node [$group selectNodes "./value\[@n = '_truss_'\]"]
    set truss [get_domnode_attribute $node v]
    customlib::WriteString "** Truss/Beam Section "
    GiD_WriteCalculationFile puts "*Assign material, elset=$group_name, material=$truss"
  }
  customlib::WriteString ""
  
  #
  # Materials
  #
  customlib::WriteString "**"
  customlib::WriteString "** Materials"
  customlib::WriteString "**"
  set xp [format_xpath {container[@n="_mat_"]/container[@n="_truss_prop_"]/blockdata}]
  set list [$root selectNodes $xp]
  foreach itruss $list {
    set truss_beam_name [$itruss getAttribute "name"]
    set node [$itruss selectNodes [format_xpath {value[@n="_Truss_beam_model_"]}]]
    set truss_beam [$node getAttribute "v"]
    if {$truss_beam == "Truss"} {
      # Truss properties
      set node [$itruss selectNodes [format_xpath {value[@n="_truss_area_"]}]]
      set truss_area [$node getAttribute "v"]
      set node [$itruss selectNodes [format_xpath {value[@n="_truss_stiffness_"]}]]
      set truss_stiffness [$node getAttribute "v"]
      GiD_WriteCalculationFile puts "** Material = $truss_beam_name"
      GiD_WriteCalculationFile puts "*Material, name=$truss_beam_name, phases=1"
      GiD_WriteCalculationFile puts "*Truss properties"
      GiD_WriteCalculationFile puts "$truss_area, $truss_stiffness"
    } elseif {$truss_beam == "Beam"} {
      # Beam properties
      set node [$itruss selectNodes [format_xpath {value[@n="_beam_area_"]}]]
      set beam_area [$node getAttribute "v"]
      set node [$itruss selectNodes [format_xpath {value[@n="_beam_y_modulus_"]}]]
      set beam_stiffness [$node getAttribute "v"]
      set node [$itruss selectNodes [format_xpath {value[@n="_beam_s_modulus_"]}]]
      set beam_shear [$node getAttribute "v"]
      set node [$itruss selectNodes [format_xpath {value[@n="_beam_I_yy_"]}]]
      set beam_Iyy [$node getAttribute "v"]
      set node [$itruss selectNodes [format_xpath {value[@n="_beam_I_zz_"]}]]
      set beam_Izz [$node getAttribute "v"]
      set node [$itruss selectNodes [format_xpath {value[@n="_beam_torsional_"]}]]
      set beam_torsion [$node getAttribute "v"]
      set node [$itruss selectNodes [format_xpath {value[@n="_beam_shear_correction_y_"]}]]
      set beam_shear_y [$node getAttribute "v"]
      set node [$itruss selectNodes [format_xpath {value[@n="_beam_shear_correction_z_"]}]]
      set beam_shear_z [$node getAttribute "v"]
      GiD_WriteCalculationFile puts "** Material = $truss_beam_name"
      GiD_WriteCalculationFile puts "*Material, name=$truss_beam_name, phases=1"
      GiD_WriteCalculationFile puts "*Beam properties"
      GiD_WriteCalculationFile puts "$beam_area, $beam_stiffness, $beam_shear, $beam_Iyy, $beam_Izz, $beam_torsion, $beam_shear_y, $beam_shear_z"
    } elseif {$truss_beam == "...select..."} {}
  }
  customlib::WriteString ""
  
  # Solid materials
  
  # create a list of material definitions
  set xp [format_xpath {container[@n="_mat_"]/container[@n="_materials_"]/blockdata}]
  set list [$root selectNodes $xp]
  
  # loop over all material definitions
  foreach imat $list {
    # material name and number of phases
    set matname [$imat getAttribute "name"]
    set node [$imat selectNodes [format_xpath {value[@n="_nphases_"]}]]
    set nphases [$node getAttribute "v"]
    # mechanical model (stess-strain)
    set node [$imat selectNodes [format_xpath {value[@n="_mechanical_"]}]]
    set model_name [$node getAttribute "v"]
	#  Material models
    set valid_models {
      "Linear Elasticity"
      "HCA Linear Elasticity"
      "Linear Elasticity"
      "Mohr-Coulomb"
      "Mohr-Coulomb-2"
      "Mohr-Coulomb-3"
      "Modified-Cam-Clay"
      "Matsuoka-Nakai"
      "Hardening-Soil"
      "Hypoplasticity"
      "Hypoplastic+IGS-2"
      "Hypoplasticity+ISA"
      "Hypoplasticity+ISA-SF"
      "Hypoplastic+GIS"
      "Sanisand"
      "AVISA"
      "HCA Linear Elasticity"
      "HCA Hypoplasticity"
      "HCA Hypoplasticity+ISA"
      "HCA Sanisand"
      "Barotropic elasticity"
      "AVHP"
      "Neo Hooke-2"
    }
    if {[lsearch -exact $valid_models $model_name] != -1} {
        customlib::WriteString ""
        GiD_WriteCalculationFile puts "** Material = $matname"
        GiD_WriteCalculationFile puts "*Material, name=$matname, phases=$nphases"
    } else {}
	
      # Linear Elasticity
    if {$model_name == "Linear Elasticity"} {
      set node [$imat selectNodes [format_xpath {container[@n="_mech_LE_"]/value[@n="_LE0_"]}]]
      set name [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_LE_"]/value[@n="_LE1_"]}]]
      set p1 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_LE_"]/value[@n="_LE2_"]}]]
      set p2 [$node getAttribute "v"]
      GiD_WriteCalculationFile puts "*Mechanical = Linear_Elasticity"
      GiD_WriteCalculationFile puts "$p1, $p2"
	  
      # HCA Linear Elasticity
    } elseif {$model_name == "HCA Linear Elasticity"} {
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_LE_"]/container[@n="_LE_con_"]/value[@n="_HCA_LE0_"]}]]
      set name [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_LE_"]/container[@n="_LE_con_"]/value[@n="_HCA_LE1_"]}]]
      set p1 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_LE_"]/container[@n="_LE_con_"]/value[@n="_HCA_LE2_"]}]]
      set p2 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_LE_"]/container[@n="_HCA_LE_con_"]/value[@n="_HCA_LE3_"]}]]
      set HCA1 [gid_groups_conds::convert_value_to $node rad]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_LE_"]/container[@n="_HCA_LE_con_"]/value[@n="_HCA_LE4_"]}]]
      set HCA2 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_LE_"]/container[@n="_HCA_LE_con_"]/value[@n="_HCA_LE5_"]}]]
      set HCA3 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_LE_"]/container[@n="_HCA_LE_con_"]/value[@n="_HCA_LE6_"]}]]
      set HCA4 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_LE_"]/container[@n="_HCA_LE_con_"]/value[@n="_HCA_LE7_"]}]]
      set HCA5 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_LE_"]/container[@n="_HCA_LE_con_"]/value[@n="_HCA_LE8_"]}]]
      set HCA6 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_LE_"]/container[@n="_HCA_LE_con_"]/value[@n="_HCA_LE9_"]}]]
      set HCA7 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_LE_"]/container[@n="_HCA_LE_con_"]/value[@n="_HCA_LE10_"]}]]
      set HCA8 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_LE_"]/container[@n="_HCA_LE_con_"]/value[@n="_HCA_LE11_"]}]]
      set HCA9 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_LE_"]/container[@n="_HCA_LE_con_"]/value[@n="_HCA_LE12_"]}]]
      set HCA10 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_LE_"]/container[@n="_HCA_LE_con_"]/value[@n="_HCA_LE13_"]}]]
      set HCA11 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_LE_"]/container[@n="_HCA_LE_con_"]/value[@n="_HCA_LE14_"]}]]
      set HCA12 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_LE_"]/container[@n="_HCA_LE_con_"]/value[@n="_HCA_LE15_"]}]]
      set HCA13 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_LE_"]/container[@n="_HCA_LE_con_"]/value[@n="_HCA_LE16_"]}]]
      set HCA14 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_LE_"]/container[@n="_HCA_LE_con_"]/value[@n="_HCA_LE17_"]}]]
      set HCA15 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_LE_"]/container[@n="_HCA_LE_con_"]/value[@n="_HCA_LE18_"]}]]
      set HCA16 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_LE_"]/container[@n="_HCA_LE_con_"]/value[@n="_HCA_LE19_"]}]]
      set HCA17 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_LE_"]/container[@n="_HCA_LE_con_"]/value[@n="_HCA_LE20_"]}]]
      set HCA18 [$node getAttribute "v"]
      GiD_WriteCalculationFile puts "*Mechanical = HCA_Linear_elasticity"
      GiD_WriteCalculationFile puts "$p1, $p2"
      GiD_WriteCalculationFile puts "$HCA1, $HCA2, $HCA3, $HCA4, $HCA5, 0, $HCA6, 0"
      GiD_WriteCalculationFile puts "$HCA7, $HCA8, $HCA9, $HCA10, $HCA11, $HCA12, $HCA13, $HCA14"
      GiD_WriteCalculationFile puts "$HCA15, $HCA16, $HCA17, $HCA18" 
      # HCA steps
      set impl_list_str ""
      set rec_list_str ""
      set exp_list_str ""
      set list_imp [format_xpath {container[@n="_mat_"]/container[@n="_materials_"]/blockdata/container[@n="_mech_HCA_LE_"]/container[@n="_HCA_LE_con_"]/container[@n="_HCA_LE22_"]/blockdata}]
      set imp_list [$root selectNodes $list_imp]
      GiD_WriteCalculationFile puts "*Implicit HCA steps"
      foreach implicit_name $imp_list {
        set impl_list [$implicit_name getAttribute "name"]
        if {$impl_list_str eq ""} {
          set impl_list_str $impl_list
        } else {
          append impl_list_str ,$impl_list
        }
      }
      GiD_WriteCalculationFile puts "$impl_list_str"
      set list_rec [format_xpath {container[@n="_mat_"]/container[@n="_materials_"]/blockdata/container[@n="_mech_HCA_LE_"]/container[@n="_HCA_LE_con_"]/container[@n="_HCA_LE23_"]/blockdata}]
      set rec_list [$root selectNodes $list_rec]
      GiD_WriteCalculationFile puts "*Recording HCA steps"
      foreach record_name $rec_list {
        set rec_list [$record_name getAttribute "name"]
        if {$rec_list_str eq ""} {
          set rec_list_str $rec_list
        } else {
          append rec_list_str ,$rec_list
        }
      }
      GiD_WriteCalculationFile puts "$rec_list_str"
      set list_exp [format_xpath {container[@n="_mat_"]/container[@n="_materials_"]/blockdata/container[@n="_mech_HCA_LE_"]/container[@n="_HCA_LE_con_"]/container[@n="_HCA_LE24_"]/blockdata}]
      set exp_list [$root selectNodes $list_exp]
      GiD_WriteCalculationFile puts "*Explicit HCA steps"
      foreach explicit_name $exp_list {
        set expl_list [$explicit_name getAttribute "name"]
        if {$exp_list_str eq ""} {
          set exp_list_str $expl_list
        } else {
          append exp_list_str ,$expl_list
        }
      }
      GiD_WriteCalculationFile puts "$exp_list_str"
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_LE_"]/container[@n="_HCA_LE_con_"]/value[@n="_HCA_LE21_"]}]]
      set HCA19 [$node getAttribute "v"]
      GiD_WriteCalculationFile puts "*HCA cycle time"
      GiD_WriteCalculationFile puts "$HCA19"
	  
      # Mohr-Coulomb
    } elseif {$model_name == "Mohr-Coulomb"} {
      set node [$imat selectNodes [format_xpath {container[@n="_mech_MC_"]/value[@n="_MC0_"]}]]
      set name [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_MC_"]/value[@n="_MC1_"]}]]
      set p1 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_MC_"]/value[@n="_MC2_"]}]]
      set p2 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_MC_"]/value[@n="_MC3_"]}]]
      set p3 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_MC_"]/value[@n="_MC4_"]}]]
      set p4 [gid_groups_conds::convert_value_to $node rad]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_MC_"]/value[@n="_MC5_"]}]]
      set p5 [gid_groups_conds::convert_value_to $node rad]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_MC_"]/value[@n="_MC6_"]}]]
      set p6 [$node getAttribute "v"]
	  set node [$imat selectNodes [format_xpath {container[@n="_mech_MC_"]/container[@n="_Optional_parameters_"]/value[@n="_MC7_"]}]]
      set p7 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_MC_"]/container[@n="_Optional_parameters_"]/value[@n="_MC7a_"]}]]
      set p7a [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_MC_"]/container[@n="_Optional_parameters_"]/value[@n="_MC8_"]}]]
      set p8 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_MC_"]/container[@n="_Optional_parameters_"]/value[@n="_MC8a_"]}]]
      set p8a [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_MC_"]/container[@n="_Optional_parameters_"]/value[@n="_MC9_"]}]]
      set p9 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_MC_"]/container[@n="_Optional_parameters_"]/value[@n="_MC9a_"]}]]
      set p9a [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_MC_"]/container[@n="_Optional_parameters_"]/value[@n="_MC10_"]}]]
      set p10 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_MC_"]/container[@n="_Optional_parameters_"]/value[@n="_MC10a_"]}]]
      set p10a [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_MC_"]/container[@n="_Optional_parameters_"]/value[@n="_MC11_"]}]]
      set p11 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_MC_"]/container[@n="_Optional_parameters_"]/value[@n="_MC11a_"]}]]
      set p11a [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_MC_"]/container[@n="_Optional_parameters_"]/value[@n="_MC12_"]}]]
      set p12 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_MC_"]/container[@n="_Optional_parameters_"]/value[@n="_MC12a_"]}]]
      set p12a [$node getAttribute "v"]
      # core block
      GiD_WriteCalculationFile puts "*Mechanical = $name"
      GiD_WriteCalculationFile puts "$p1, $p2, $p3, $p4, $p5, $p6"
      set anyYes [expr {$p7 eq "Yes" || $p8 eq "Yes" || $p9 eq "Yes" || $p10 eq "Yes" || $p11 eq "Yes" || $p12 eq "Yes"}]
      if {$anyYes} {
        GiD_WriteCalculationFile puts "*Optional mechanical parameter"
        if {$p7 eq "Yes"} { GiD_WriteCalculationFile puts "min_pressure, $p7a" }
        if {$p8 eq "Yes"} { GiD_WriteCalculationFile puts "tol_yield, $p8a" }
        if {$p9 eq "Yes"} { GiD_WriteCalculationFile puts "return_mapping, $p9a" }
        if {$p10 eq "Yes"} { GiD_WriteCalculationFile puts "cep_ratio, $p10a" }
        if {$p11 eq "Yes"} { GiD_WriteCalculationFile puts "reduction_psi, $p11a" }
        if {$p12 eq "Yes"} { GiD_WriteCalculationFile puts "reduction_nu, $p12a" }
      } else {}
	  
      # Mohr-Coulomb-2
    } elseif {$model_name == "Mohr-Coulomb-2"} {
      set node [$imat selectNodes [format_xpath {container[@n="_mech_MC2_"]/value[@n="_MC20_"]}]]
      set name [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_MC2_"]/value[@n="_MC21_"]}]]
      set p1 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_MC2_"]/value[@n="_MC22_"]}]]
      set p2 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_MC2_"]/value[@n="_MC23_"]}]]
      set p3 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_MC2_"]/value[@n="_MC24_"]}]]
      set p4 [gid_groups_conds::convert_value_to $node rad]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_MC2_"]/value[@n="_MC25_"]}]]
      set p5 [gid_groups_conds::convert_value_to $node rad]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_MC2_"]/value[@n="_MC26_"]}]]
      set p6 [$node getAttribute "v"]
      GiD_WriteCalculationFile puts "*Mechanical = $name"
      GiD_WriteCalculationFile puts "$p1, $p2, $p3, $p4, $p5, $p6"
	 
      # Mohr-Coulomb-3
    } elseif {$model_name == "Mohr-Coulomb-3"} {
      set node [$imat selectNodes [format_xpath {container[@n="_mech_MC3_"]/value[@n="_MC30_"]}]]
      set name [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_MC3_"]/value[@n="_MC31_"]}]]
      set p1 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_MC3_"]/value[@n="_MC32_"]}]]
      set p2 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_MC3_"]/value[@n="_MC33_"]}]]
      set p3 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_MC3_"]/value[@n="_MC34_"]}]]
      set p4 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_MC3_"]/value[@n="_MC35_"]}]]
      set p5 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_MC3_"]/value[@n="_MC36_"]}]]
      set p6 [$node getAttribute "v"]
      GiD_WriteCalculationFile puts "*Mechanical = Mohr-Coulomb-3"
      GiD_WriteCalculationFile puts "$p1, $p2, $p3, $p4, $p5, $p6"
	  
      #Hypoplasticity
    } elseif {$model_name == "Hypoplasticity"} {
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP_"]/value[@n="_HP0_"]}]]
      set name [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP_"]/value[@n="_HP1_"]}]]
      set p1 [gid_groups_conds::convert_value_to $node rad]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP_"]/value[@n="_HP2_"]}]]
      set p2 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP_"]/value[@n="_HP3_"]}]]
      set p3 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP_"]/value[@n="_HP4_"]}]]
      set p4 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP_"]/value[@n="_HP5_"]}]]
      set p5 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP_"]/value[@n="_HP6_"]}]]
      set p6 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP_"]/value[@n="_HP7_"]}]]
      set p7 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP_"]/value[@n="_HP8_"]}]]
      set p8 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP_"]/value[@n="_HP9_"]}]]
      set p9 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP_"]/value[@n="_HP10_"]}]]
      set p10 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP_"]/value[@n="_HP11_"]}]]
      set p11 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP_"]/value[@n="_HP12_"]}]]
      set p12 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP_"]/value[@n="_HP13_"]}]]
      set p13 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP_"]/value[@n="_HP14_"]}]]
      set p14 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP_"]/value[@n="_HP15_"]}]]
      set p15 [$node getAttribute "v"]
      GiD_WriteCalculationFile puts "*Mechanical = Hypoplasticity"
      GiD_WriteCalculationFile puts "$p1, $p2, $p3, $p4, $p5, $p6, $p7, $p8"
      GiD_WriteCalculationFile puts "$p9, $p10, $p11, $p12, $p13, $p14, $p15"
	  
	  #Hypo-IGS
    } elseif {$model_name == "Hypoplastic+IGS-2"} {
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP2_"]/value[@n="_HPI0_"]}]]
      set name [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP2_"]/value[@n="_HPI1_"]}]]
      set p1 [gid_groups_conds::convert_value_to $node rad]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP2_"]/value[@n="_HPI2_"]}]]
      set p2 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP2_"]/value[@n="_HPI3_"]}]]
      set p3 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP2_"]/value[@n="_HPI4_"]}]]
      set p4 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP2_"]/value[@n="_HPI5_"]}]]
      set p5 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP2_"]/value[@n="_HPI6_"]}]]
      set p6 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP2_"]/value[@n="_HPI7_"]}]]
      set p7 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP2_"]/value[@n="_HPI8_"]}]]
      set p8 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP2_"]/value[@n="_HPI9_"]}]]
      set p9 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP2_"]/value[@n="_HPI10_"]}]]
      set p10 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP2_"]/value[@n="_HPI11_"]}]]
      set p11 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP2_"]/value[@n="_HPI12_"]}]]
      set p12 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP2_"]/value[@n="_HPI13_"]}]]
      set p13 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP2_"]/container[@n="_Optional_parameters_"]/value[@n="_HPI14_"]}]]
      set p14 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP2_"]/container[@n="_Optional_parameters_"]/value[@n="_HPI14a_"]}]]
      set p14a [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP2_"]/container[@n="_Optional_parameters_"]/value[@n="_HPI15_"]}]]
      set p15 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP2_"]/container[@n="_Optional_parameters_"]/value[@n="_HPI15a_"]}]]
      set p15a [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP2_"]/container[@n="_Optional_parameters_"]/value[@n="_HPI16_"]}]]
      set p16 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP2_"]/container[@n="_Optional_parameters_"]/value[@n="_HPI16a_"]}]]
      set p16a [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP2_"]/container[@n="_Optional_parameters_"]/value[@n="_HPI17_"]}]]
      set p17 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP2_"]/container[@n="_Optional_parameters_"]/value[@n="_HPI17a_"]}]]
      set p17a [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP2_"]/container[@n="_Optional_parameters_"]/value[@n="_HPI18_"]}]]
      set p18 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP2_"]/container[@n="_Optional_parameters_"]/value[@n="_HPI18a_"]}]]
      set p18a [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP2_"]/container[@n="_Optional_parameters_"]/value[@n="_HPI19_"]}]]
      set p19 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP2_"]/container[@n="_Optional_parameters_"]/value[@n="_HPI19a_"]}]]
      set p19a [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP2_"]/container[@n="_Optional_parameters_"]/value[@n="_HPI20_"]}]]
      set p20 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP2_"]/container[@n="_Optional_parameters_"]/value[@n="_HPI20a_"]}]]
      set p20a [$node getAttribute "v"]
      # core block
      GiD_WriteCalculationFile puts "*Mechanical = Hypo-IGS"
      GiD_WriteCalculationFile puts "$p1, $p2, $p3, $p4, $p5, $p6, $p7, $p8"
      GiD_WriteCalculationFile puts "$p9, $p10, $p11, $p12, $p13"
      set anyYes [expr {$p14 eq "Yes" || $p15 eq "Yes" || $p16 eq "Yes" || $p17 eq "Yes" || $p18 eq "Yes" || $p19 eq "Yes" || $p20 eq "Yes"}]
      if {$anyYes} {
        GiD_WriteCalculationFile puts "*Optional mechanical parameter"
        if {$p14 eq "Yes"} { GiD_WriteCalculationFile puts "min_pressure, $p14a"}
        if {$p15 eq "Yes"} { GiD_WriteCalculationFile puts "phantom_E, $p15a"}
        if {$p16 eq "Yes"} { GiD_WriteCalculationFile puts "phantom_NU, $p16a"}
        if {$p17 eq "Yes"} { GiD_WriteCalculationFile puts "projection_dev, $p17a"}
        if {$p18 eq "Yes"} { GiD_WriteCalculationFile puts "Bulk_water, $p18a"}
        if {$p19 eq "Yes"} { GiD_WriteCalculationFile puts "Integrator, $p19a"}
        if {$p20 eq "Yes"} { GiD_WriteCalculationFile puts "projection_Iso, $p20a"}
      } else {}
	  
      # Hypo-GIS
    } elseif {$model_name == "Hypoplastic+GIS"} {
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP_GIS_"]/value[@n="_HPG0_"]}]]
      set name [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP_GIS_"]/value[@n="_HPG1_"]}]]
      set p1 [gid_groups_conds::convert_value_to $node rad]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP_GIS_"]/value[@n="_HPG2_"]}]]
      set p2 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP_GIS_"]/value[@n="_HPG3_"]}]]
      set p3 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP_GIS_"]/value[@n="_HPG4_"]}]]
      set p4 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP_GIS_"]/value[@n="_HPG5_"]}]]
      set p5 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP_GIS_"]/value[@n="_HPG6_"]}]]
      set p6 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP_GIS_"]/value[@n="_HPG7_"]}]]
      set p7 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP_GIS_"]/value[@n="_HPG8_"]}]]
      set p8 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP_GIS_"]/value[@n="_HPG9_"]}]]
      set p9 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP_GIS_"]/value[@n="_HPG10_"]}]]
      set p10 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP_GIS_"]/value[@n="_HPG11_"]}]]
      set p11 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP_GIS_"]/value[@n="_HPG12_"]}]]
      set p12 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP_GIS_"]/value[@n="_HPG13_"]}]]
      set p13 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP_GIS_"]/value[@n="_HPG14_"]}]]
      set p14 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP_GIS_"]/value[@n="_HPG15_"]}]]
      set p15 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP_GIS_"]/value[@n="_HPG16_"]}]]
      set p16 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP_GIS_"]/value[@n="_HPG17_"]}]]
      set p17 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP_GIS_"]/value[@n="_HPG18_"]}]]
      set p18 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP_GIS_"]/container[@n="_Optional_parameters_"]/value[@n="_HPG19_"]}]]
      set p19 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP_GIS_"]/container[@n="_Optional_parameters_"]/value[@n="_HPG19a_"]}]]
      set p19a [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP_GIS_"]/container[@n="_Optional_parameters_"]/value[@n="_HPG20_"]}]]
      set p20 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP_GIS_"]/container[@n="_Optional_parameters_"]/value[@n="_HPG20a_"]}]]
      set p20a [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP_GIS_"]/container[@n="_Optional_parameters_"]/value[@n="_HPG21_"]}]]
      set p21 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP_GIS_"]/container[@n="_Optional_parameters_"]/value[@n="_HPG21a_"]}]]
      set p21a [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP_GIS_"]/container[@n="_Optional_parameters_"]/value[@n="_HPG22_"]}]]
      set p22 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP_GIS_"]/container[@n="_Optional_parameters_"]/value[@n="_HPG22a_"]}]]
      set p22a [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP_GIS_"]/container[@n="_Optional_parameters_"]/value[@n="_HPG23_"]}]]
      set p23 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP_GIS_"]/container[@n="_Optional_parameters_"]/value[@n="_HPG23a_"]}]]
      set p23a [$node getAttribute "v"]
      # core block
      GiD_WriteCalculationFile puts "*Mechanical = Hypo-GIS"
      GiD_WriteCalculationFile puts "$p1, $p2, $p3, $p4, $p5, $p6, $p7, $p8"
      GiD_WriteCalculationFile puts "$p9, $p10, $p11, $p12, $p13, $p14, $p15, $p16"
      GiD_WriteCalculationFile puts "$p17, $p18"
      set anyYes [expr {$p19 eq "Yes" || $p20 eq "Yes" || $p21 eq "Yes" || $p22 eq "Yes" || $p23 eq "Yes"}]
      if {$anyYes} {
        GiD_WriteCalculationFile puts "*Optional mechanical parameter"
        if {$p19 eq "Yes"} { GiD_WriteCalculationFile puts "Phantom_E, $p19a"}
        if {$p20 eq "Yes"} { GiD_WriteCalculationFile puts "phantom_NU, $p20a"}
        if {$p21 eq "Yes"} { GiD_WriteCalculationFile puts "Bulk_water, $p21a"}
        if {$p22 eq "Yes"} { GiD_WriteCalculationFile puts "min_pressure, $p22a"}
        if {$p23 eq "Yes"} { GiD_WriteCalculationFile puts "Integrator, $p23a"}
      } else {}
	  
	  # HCA Hypoplastic
    } elseif {$model_name == "HCA Hypoplasticity"} {
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_HP_"]/container[@n="_HP_con_"]/value[@n="_HCA_HP0_"]}]]
      set name [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_HP_"]/container[@n="_HP_con_"]/value[@n="_HCA_HP1_"]}]]
      set p1 [gid_groups_conds::convert_value_to $node rad]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_HP_"]/container[@n="_HP_con_"]/value[@n="_HCA_HP2_"]}]]
      set p2 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_HP_"]/container[@n="_HP_con_"]/value[@n="_HCA_HP3_"]}]]
      set p3 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_HP_"]/container[@n="_HP_con_"]/value[@n="_HCA_HP4_"]}]]
      set p4 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_HP_"]/container[@n="_HP_con_"]/value[@n="_HCA_HP5_"]}]]
      set p5 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_HP_"]/container[@n="_HP_con_"]/value[@n="_HCA_HP6_"]}]]
      set p6 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_HP_"]/container[@n="_HP_con_"]/value[@n="_HCA_HP7_"]}]]
      set p7 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_HP_"]/container[@n="_HP_con_"]/value[@n="_HCA_HP8_"]}]]
      set p8 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_HP_"]/container[@n="_HP_con_"]/value[@n="_HCA_HP9_"]}]]
      set p9 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_HP_"]/container[@n="_HP_con_"]/value[@n="_HCA_HP10_"]}]]
      set p10 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_HP_"]/container[@n="_HP_con_"]/value[@n="_HCA_HP11_"]}]]
      set p11 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_HP_"]/container[@n="_HP_con_"]/value[@n="_HCA_HP12_"]}]]
      set p12 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_HP_"]/container[@n="_HP_con_"]/value[@n="_HCA_HP13_"]}]]
      set p13 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_HP_"]/container[@n="_HP_con_"]/value[@n="_HCA_HP14_"]}]]
      set p14 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_HP_"]/container[@n="_HP_con_"]/value[@n="_HCA_HP15_"]}]]
      set p15 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_HP_"]/container[@n="_HCA_HP_con_"]/value[@n="_HCA_HP16_"]}]]
      set HCA1 [gid_groups_conds::convert_value_to $node rad]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_HP_"]/container[@n="_HCA_HP_con_"]/value[@n="_HCA_HP17_"]}]]
      set HCA2 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_HP_"]/container[@n="_HCA_HP_con_"]/value[@n="_HCA_HP18_"]}]]
      set HCA3 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_HP_"]/container[@n="_HCA_HP_con_"]/value[@n="_HCA_HP19_"]}]]
      set HCA4 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_HP_"]/container[@n="_HCA_HP_con_"]/value[@n="_HCA_HP20_"]}]]
      set HCA5 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_HP_"]/container[@n="_HCA_HP_con_"]/value[@n="_HCA_HP21_"]}]]
      set HCA6 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_HP_"]/container[@n="_HCA_HP_con_"]/value[@n="_HCA_HP22_"]}]]
      set HCA7 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_HP_"]/container[@n="_HCA_HP_con_"]/value[@n="_HCA_HP23_"]}]]
      set HCA8 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_HP_"]/container[@n="_HCA_HP_con_"]/value[@n="_HCA_HP24_"]}]]
      set HCA9 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_HP_"]/container[@n="_HCA_HP_con_"]/value[@n="_HCA_HP25_"]}]]
      set HCA10 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_HP_"]/container[@n="_HCA_HP_con_"]/value[@n="_HCA_HP26_"]}]]
      set HCA11 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_HP_"]/container[@n="_HCA_HP_con_"]/value[@n="_HCA_HP27_"]}]]
      set HCA12 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_HP_"]/container[@n="_HCA_HP_con_"]/value[@n="_HCA_HP28_"]}]]
      set HCA13 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_HP_"]/container[@n="_HCA_HP_con_"]/value[@n="_HCA_HP29_"]}]]
      set HCA14 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_HP_"]/container[@n="_HCA_HP_con_"]/value[@n="_HCA_HP30_"]}]]
      set HCA15 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_HP_"]/container[@n="_HCA_HP_con_"]/value[@n="_HCA_HP31_"]}]]
      set HCA16 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_HP_"]/container[@n="_HCA_HP_con_"]/value[@n="_HCA_HP32_"]}]]
      set HCA17 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_HP_"]/container[@n="_HCA_HP_con_"]/value[@n="_HCA_HP33_"]}]]
      set HCA18 [$node getAttribute "v"]
      GiD_WriteCalculationFile puts "*Mechanical = HCA_Hypoplasticity"
      GiD_WriteCalculationFile puts "$p1, $p2, $p3, $p4, $p5, $p6, $p7, $p8"
      GiD_WriteCalculationFile puts "$p9, $p10, $p11, $p12, $p13, $p14, $p15"
      GiD_WriteCalculationFile puts "$HCA1, $HCA2, $HCA3, $HCA4, $HCA5, 0, $HCA6, 0"
      GiD_WriteCalculationFile puts "$HCA7, $HCA8, $HCA9, $HCA10, $HCA11, $HCA12, $HCA13, $HCA14"
      GiD_WriteCalculationFile puts "$HCA15, $HCA16, $HCA17, $HCA18" 
      # HCA steps
      set impl_list_str ""
      set rec_list_str ""
      set exp_list_str ""
      set list_imp [format_xpath {container[@n="_mat_"]/container[@n="_materials_"]/blockdata/container[@n="_mech_HCA_HP_"]/container[@n="_HCA_HP_con_"]/container[@n="_HCA_HP35_"]/blockdata}]
      set imp_list [$root selectNodes $list_imp]
      GiD_WriteCalculationFile puts "*Implicit HCA steps"
      foreach implicit_name $imp_list {
        set impl_list [$implicit_name getAttribute "name"]
        if {$impl_list_str eq ""} {
          set impl_list_str $impl_list
        } else {
          append impl_list_str ,$impl_list
        }
      }
      GiD_WriteCalculationFile puts "$impl_list_str"
      set list_rec [format_xpath {container[@n="_mat_"]/container[@n="_materials_"]/blockdata/container[@n="_mech_HCA_HP_"]/container[@n="_HCA_HP_con_"]/container[@n="_HCA_HP36_"]/blockdata}]
      set rec_list [$root selectNodes $list_rec]
      GiD_WriteCalculationFile puts "*Recording HCA steps"
      foreach record_name $rec_list {
        set rec_list [$record_name getAttribute "name"]
        if {$rec_list_str eq ""} {
          set rec_list_str $rec_list
        } else {
          append rec_list_str ,$rec_list
        }
      }
      GiD_WriteCalculationFile puts "$rec_list_str"
      set list_exp [format_xpath {container[@n="_mat_"]/container[@n="_materials_"]/blockdata/container[@n="_mech_HCA_HP_"]/container[@n="_HCA_HP_con_"]/container[@n="_HCA_HP37_"]/blockdata}]
      set exp_list [$root selectNodes $list_exp]
      GiD_WriteCalculationFile puts "*Explicit HCA steps"
      foreach explicit_name $exp_list {
        set expl_list [$explicit_name getAttribute "name"]
        if {$exp_list_str eq ""} {
          set exp_list_str $expl_list
        } else {
          append exp_list_str ,$expl_list
        }
      }
      GiD_WriteCalculationFile puts "$exp_list_str"
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_HP_"]/container[@n="_HCA_HP_con_"]/value[@n="_HCA_HP34_"]}]]
      set HCA19 [$node getAttribute "v"]
      GiD_WriteCalculationFile puts "*HCA cycle time"
      GiD_WriteCalculationFile puts "$HCA19"
	  
      # Hypo-ISA  
    } elseif {$model_name == "Hypoplasticity+ISA"} {
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP_ISA_"]/value[@n="_HPI0_"]}]]
      set name [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP_ISA_"]/value[@n="_HPI1_"]}]]
      set p1 [gid_groups_conds::convert_value_to $node rad]                            
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP_ISA_"]/value[@n="_HPI2_"]}]]
      set p2 [$node getAttribute "v"]                            
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP_ISA_"]/value[@n="_HPI3_"]}]]
      set p3 [$node getAttribute "v"]                            
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP_ISA_"]/value[@n="_HPI4_"]}]]
      set p4 [$node getAttribute "v"]                            
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP_ISA_"]/value[@n="_HPI5_"]}]]
      set p5 [$node getAttribute "v"]                            
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP_ISA_"]/value[@n="_HPI6_"]}]]
      set p6 [$node getAttribute "v"]                            
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP_ISA_"]/value[@n="_HPI7_"]}]]
      set p7 [$node getAttribute "v"]                            
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP_ISA_"]/value[@n="_HPI8_"]}]]
      set p8 [$node getAttribute "v"]                            
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP_ISA_"]/value[@n="_HPI9_"]}]]
      set p9 [$node getAttribute "v"]                            
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP_ISA_"]/value[@n="_HPI10_"]}]]
      set p10 [$node getAttribute "v"]                           
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP_ISA_"]/value[@n="_HPI11_"]}]]
      set p11 [$node getAttribute "v"]                           
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP_ISA_"]/value[@n="_HPI12_"]}]]
      set p12 [$node getAttribute "v"]                           
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP_ISA_"]/value[@n="_HPI13_"]}]]
      set p13 [$node getAttribute "v"]                           
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP_ISA_"]/value[@n="_HPI14_"]}]]
      set p14 [$node getAttribute "v"]                           
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP_ISA_"]/value[@n="_HPI15_"]}]]
      set p15 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP_ISA_"]/value[@n="_HPI16_"]}]]
      set p16 [$node getAttribute "v"]                            
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP_ISA_"]/container[@n="_Optional_parameters_"]/value[@n="_HPI17_"]}]]
      set p17 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP_ISA_"]/container[@n="_Optional_parameters_"]/value[@n="_HPI17a_"]}]]
      set p17a [$node getAttribute "v"]	  
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP_ISA_"]/container[@n="_Optional_parameters_"]/value[@n="_HPI18_"]}]]
      set p18 [$node getAttribute "v"]     
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP_ISA_"]/container[@n="_Optional_parameters_"]/value[@n="_HPI18a_"]}]]
      set p18a [$node getAttribute "v"]  	  
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP_ISA_"]/container[@n="_Optional_parameters_"]/value[@n="_HPI19_"]}]]
      set p19 [$node getAttribute "v"] 
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP_ISA_"]/container[@n="_Optional_parameters_"]/value[@n="_HPI19a_"]}]]
      set p19a [$node getAttribute "v"] 
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP_ISA_"]/container[@n="_Optional_parameters_"]/value[@n="_HPI20_"]}]]
      set p20 [$node getAttribute "v"]  
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP_ISA_"]/container[@n="_Optional_parameters_"]/value[@n="_HPI20a_"]}]]
      set p20a [$node getAttribute "v"]  
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP_ISA_"]/container[@n="_Optional_parameters_"]/value[@n="_HPI21_"]}]]
      set p21 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP_ISA_"]/container[@n="_Optional_parameters_"]/value[@n="_HPI21a_"]}]]
      set p21a [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP_ISA_"]/container[@n="_Optional_parameters_"]/value[@n="_HPI22_"]}]]
      set p22 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP_ISA_"]/container[@n="_Optional_parameters_"]/value[@n="_HPI22a_"]}]]
      set p22a [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP_ISA_"]/container[@n="_Optional_parameters_"]/value[@n="_HPI23_"]}]]
      set p23 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP_ISA_"]/container[@n="_Optional_parameters_"]/value[@n="_HPI23a_"]}]]
      set p23a [$node getAttribute "v"]
      # Always write the core block
      GiD_WriteCalculationFile puts "*Mechanical = HYPO-ISA"
      GiD_WriteCalculationFile puts "$p1, $p2, $p3, $p4, $p5, $p6, $p7, $p8"
      GiD_WriteCalculationFile puts "$p9, $p10, $p11, $p12, $p13, $p14, $p15, $p16"
      set anyYes [expr {$p17 eq "Yes" || $p18 eq "Yes" || $p19 eq "Yes" || $p20 eq "Yes" || $p21 eq "Yes" || $p22 eq "Yes" || $p23 eq "Yes"}]
      if {$anyYes} {
        GiD_WriteCalculationFile puts "*Optional mechanical parameter"
        if {$p17 eq "Yes"} { GiD_WriteCalculationFile puts "min_pressure, $p17a" }
        if {$p18 eq "Yes"} { GiD_WriteCalculationFile puts "phantom_E, $p18a" }
        if {$p19 eq "Yes"} { GiD_WriteCalculationFile puts "phantom_NU, $p19a" }
        if {$p20 eq "Yes"} { GiD_WriteCalculationFile puts "projection_dev, $p20a" }
        if {$p21 eq "Yes"} { GiD_WriteCalculationFile puts "Bulk_water, $p21a" }
        if {$p22 eq "Yes"} { GiD_WriteCalculationFile puts "Integrator, $p22a" }
        if {$p23 eq "Yes"} { GiD_WriteCalculationFile puts "projection_Iso, $p23a" }
      }
	  
      # Hypo-ISA-SF  
    } elseif {$model_name == "Hypoplasticity+ISA-SF"} {
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP_ISA_SF_"]/value[@n="_HPI_SF0_"]}]]
      set name [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP_ISA_SF_"]/value[@n="_HPI_SF1_"]}]]
      set p1 [gid_groups_conds::convert_value_to $node rad]                            
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP_ISA_SF_"]/value[@n="_HPI_SF2_"]}]]
      set p2 [$node getAttribute "v"]                            
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP_ISA_SF_"]/value[@n="_HPI_SF3_"]}]]
      set p3 [$node getAttribute "v"]                            
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP_ISA_SF_"]/value[@n="_HPI_SF4_"]}]]
      set p4 [$node getAttribute "v"]                            
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP_ISA_SF_"]/value[@n="_HPI_SF5_"]}]]
      set p5 [$node getAttribute "v"]                            
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP_ISA_SF_"]/value[@n="_HPI_SF6_"]}]]
      set p6 [$node getAttribute "v"]                            
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP_ISA_SF_"]/value[@n="_HPI_SF7_"]}]]
      set p7 [$node getAttribute "v"]                            
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP_ISA_SF_"]/value[@n="_HPI_SF8_"]}]]
      set p8 [$node getAttribute "v"]                            
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP_ISA_SF_"]/value[@n="_HPI_SF9_"]}]]
      set p9 [$node getAttribute "v"]                            
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP_ISA_SF_"]/value[@n="_HPI_SF10_"]}]]
      set p10 [$node getAttribute "v"]                           
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP_ISA_SF_"]/value[@n="_HPI_SF11_"]}]]
      set p11 [$node getAttribute "v"]                           
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP_ISA_SF_"]/value[@n="_HPI_SF12_"]}]]
      set p12 [$node getAttribute "v"]                           
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP_ISA_SF_"]/value[@n="_HPI_SF13_"]}]]
      set p13 [$node getAttribute "v"]                           
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP_ISA_SF_"]/value[@n="_HPI_SF14_"]}]]
      set p14 [$node getAttribute "v"]                           
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP_ISA_SF_"]/value[@n="_HPI_SF15_"]}]]
      set p15 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP_ISA_SF_"]/value[@n="_HPI_SF16_"]}]]
      set p16 [$node getAttribute "v"] 
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP_ISA_SF_"]/value[@n="_HPI_SF17_"]}]]
      set p17 [$node getAttribute "v"]                            
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP_ISA_SF_"]/value[@n="_HPI_SF18_"]}]]
      set p18 [$node getAttribute "v"]                           
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP_ISA_SF_"]/value[@n="_HPI_SF19_"]}]]
      set p19 [$node getAttribute "v"]                           
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP_ISA_SF_"]/value[@n="_HPI_SF20_"]}]]
      set p20 [$node getAttribute "v"]                           
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP_ISA_SF_"]/value[@n="_HPI_SF21_"]}]]
      set p21 [$node getAttribute "v"]                           
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP_ISA_SF_"]/value[@n="_HPI_SF22_"]}]]
      set p22 [$node getAttribute "v"]                           
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP_ISA_SF_"]/value[@n="_HPI_SF23_"]}]]
      set p23 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP_ISA_SF_"]/value[@n="_HPI_SF24_"]}]]
      set p24 [$node getAttribute "v"] 	  
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP_ISA_SF_"]/container[@n="_Optional_parameters_"]/value[@n="_HPI_SF25_"]}]]
      set p25 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP_ISA_SF_"]/container[@n="_Optional_parameters_"]/value[@n="_HPI_SF25a_"]}]]
      set p25a [$node getAttribute "v"]	  
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP_ISA_SF_"]/container[@n="_Optional_parameters_"]/value[@n="_HPI_SF26_"]}]]
      set p26 [$node getAttribute "v"]     
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP_ISA_SF_"]/container[@n="_Optional_parameters_"]/value[@n="_HPI_SF26a_"]}]]
      set p26a [$node getAttribute "v"]  	  
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP_ISA_SF_"]/container[@n="_Optional_parameters_"]/value[@n="_HPI_SF27_"]}]]
      set p27 [$node getAttribute "v"] 
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP_ISA_SF_"]/container[@n="_Optional_parameters_"]/value[@n="_HPI_SF27a_"]}]]
      set p27a [$node getAttribute "v"] 
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP_ISA_SF_"]/container[@n="_Optional_parameters_"]/value[@n="_HPI_SF28_"]}]]
      set p28 [$node getAttribute "v"]  
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP_ISA_SF_"]/container[@n="_Optional_parameters_"]/value[@n="_HPI_SF28a_"]}]]
      set p28a [$node getAttribute "v"]  
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP_ISA_SF_"]/container[@n="_Optional_parameters_"]/value[@n="_HPI_SF29_"]}]]
      set p29 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP_ISA_SF_"]/container[@n="_Optional_parameters_"]/value[@n="_HPI_SF29a_"]}]]
      set p29a [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP_ISA_SF_"]/container[@n="_Optional_parameters_"]/value[@n="_HPI_SF30_"]}]]
      set p30 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP_ISA_SF_"]/container[@n="_Optional_parameters_"]/value[@n="_HPI_SF30a_"]}]]
      set p30a [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP_ISA_SF_"]/container[@n="_Optional_parameters_"]/value[@n="_HPI_SF31_"]}]]
      set p31 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HP_ISA_SF_"]/container[@n="_Optional_parameters_"]/value[@n="_HPI_SF31a_"]}]]
      set p31a [$node getAttribute "v"]
      # Always write the core block
      GiD_WriteCalculationFile puts "*Mechanical = HYPO-ISA-SF"
      GiD_WriteCalculationFile puts "$p1, $p2, $p3, $p4, $p5, $p6, $p7, $p8"
      GiD_WriteCalculationFile puts "$p9, $p10, $p11, $p12, $p13, $p14, $p15, $p16"
      GiD_WriteCalculationFile puts "$p17, $p18, $p19, $p20, $p21, $p22, $p23, $p24"
      set anyYes [expr {$p25 eq "Yes" || $p26 eq "Yes" || $p27 eq "Yes" || $p28 eq "Yes" || $p29 eq "Yes" || $p30 eq "Yes" || $p31 eq "Yes"}]
      if {$anyYes} {
        GiD_WriteCalculationFile puts "*Optional mechanical parameter"
        if {$p25 eq "Yes"} { GiD_WriteCalculationFile puts "min_pressure, $p25a" }
        if {$p26 eq "Yes"} { GiD_WriteCalculationFile puts "phantom_E, $p26a" }
        if {$p27 eq "Yes"} { GiD_WriteCalculationFile puts "phantom_NU, $p27a" }
        if {$p28 eq "Yes"} { GiD_WriteCalculationFile puts "projection_dev, $p28a" }
        if {$p29 eq "Yes"} { GiD_WriteCalculationFile puts "Bulk_water, $p29a" }
        if {$p30 eq "Yes"} { GiD_WriteCalculationFile puts "Integrator, $p30a" }
        if {$p31 eq "Yes"} { GiD_WriteCalculationFile puts "projection_Iso, $p31a" }
      }
	  
      # HCA-Hypo-ISA
    } elseif {$model_name == "HCA Hypoplasticity+ISA"} {
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_HP_ISA_"]/container[@n="_HPI_con_"]/value[@n="_HCA_HPI0_"]}]]
      set name [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_HP_ISA_"]/container[@n="_HPI_con_"]/value[@n="_HCA_HPI1_"]}]]
      set p1 [gid_groups_conds::convert_value_to $node rad]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_HP_ISA_"]/container[@n="_HPI_con_"]/value[@n="_HCA_HPI2_"]}]]
      set p2 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_HP_ISA_"]/container[@n="_HPI_con_"]/value[@n="_HCA_HPI3_"]}]]
      set p3 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_HP_ISA_"]/container[@n="_HPI_con_"]/value[@n="_HCA_HPI4_"]}]]
      set p4 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_HP_ISA_"]/container[@n="_HPI_con_"]/value[@n="_HCA_HPI5_"]}]]
      set p5 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_HP_ISA_"]/container[@n="_HPI_con_"]/value[@n="_HCA_HPI6_"]}]]
      set p6 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_HP_ISA_"]/container[@n="_HPI_con_"]/value[@n="_HCA_HPI7_"]}]]
      set p7 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_HP_ISA_"]/container[@n="_HPI_con_"]/value[@n="_HCA_HPI8_"]}]]
      set p8 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_HP_ISA_"]/container[@n="_HPI_con_"]/value[@n="_HCA_HPI9_"]}]]
      set p9 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_HP_ISA_"]/container[@n="_HPI_con_"]/value[@n="_HCA_HPI10_"]}]]
      set p10 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_HP_ISA_"]/container[@n="_HPI_con_"]/value[@n="_HCA_HPI11_"]}]]
      set p11 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_HP_ISA_"]/container[@n="_HPI_con_"]/value[@n="_HCA_HPI12_"]}]]
      set p12 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_HP_ISA_"]/container[@n="_HPI_con_"]/value[@n="_HCA_HPI13_"]}]]
      set p13 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_HP_ISA_"]/container[@n="_HPI_con_"]/value[@n="_HCA_HPI14_"]}]]
      set p14 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_HP_ISA_"]/container[@n="_HPI_con_"]/value[@n="_HCA_HPI15_"]}]]
      set p15 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_HP_ISA_"]/container[@n="_HPI_con_"]/value[@n="_HCA_HPI16_"]}]]
      set p16 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_HP_ISA_"]/container[@n="_HPI_con_"]/value[@n="_HCA_HPI17_"]}]]
      set p17 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_HP_ISA_"]/container[@n="_HPI_con_"]/value[@n="_HCA_HPI18_"]}]]
      set p18 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_HP_ISA_"]/container[@n="_HPI_con_"]/value[@n="_HCA_HPI19_"]}]]
      set p19 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_HP_ISA_"]/container[@n="_HPI_con_"]/value[@n="_HCA_HPI20_"]}]]
      set p20 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_HP_ISA_"]/container[@n="_HPI_con_"]/value[@n="_HCA_HPI21_"]}]]
      set p21 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_HP_ISA_"]/container[@n="_HCA_HPI_con_"]/value[@n="_HCA_HPI22_"]}]]
      set HCA1 [gid_groups_conds::convert_value_to $node rad]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_HP_ISA_"]/container[@n="_HCA_HPI_con_"]/value[@n="_HCA_HPI23_"]}]]
      set HCA2 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_HP_ISA_"]/container[@n="_HCA_HPI_con_"]/value[@n="_HCA_HPI24_"]}]]
      set HCA3 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_HP_ISA_"]/container[@n="_HCA_HPI_con_"]/value[@n="_HCA_HPI25_"]}]]
      set HCA4 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_HP_ISA_"]/container[@n="_HCA_HPI_con_"]/value[@n="_HCA_HPI26_"]}]]
      set HCA5 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_HP_ISA_"]/container[@n="_HCA_HPI_con_"]/value[@n="_HCA_HPI27_"]}]]
      set HCA6 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_HP_ISA_"]/container[@n="_HCA_HPI_con_"]/value[@n="_HCA_HPI28_"]}]]
      set HCA7 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_HP_ISA_"]/container[@n="_HCA_HPI_con_"]/value[@n="_HCA_HPI29_"]}]]
      set HCA8 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_HP_ISA_"]/container[@n="_HCA_HPI_con_"]/value[@n="_HCA_HPI30_"]}]]
      set HCA9 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_HP_ISA_"]/container[@n="_HCA_HPI_con_"]/value[@n="_HCA_HPI31_"]}]]
      set HCA10 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_HP_ISA_"]/container[@n="_HCA_HPI_con_"]/value[@n="_HCA_HPI32_"]}]]
      set HCA11 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_HP_ISA_"]/container[@n="_HCA_HPI_con_"]/value[@n="_HCA_HPI33_"]}]]
      set HCA12 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_HP_ISA_"]/container[@n="_HCA_HPI_con_"]/value[@n="_HCA_HPI34_"]}]]
      set HCA13 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_HP_ISA_"]/container[@n="_HCA_HPI_con_"]/value[@n="_HCA_HPI35_"]}]]
      set HCA14 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_HP_ISA_"]/container[@n="_HCA_HPI_con_"]/value[@n="_HCA_HPI36_"]}]]
      set HCA15 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_HP_ISA_"]/container[@n="_HCA_HPI_con_"]/value[@n="_HCA_HPI37_"]}]]
      set HCA16 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_HP_ISA_"]/container[@n="_HCA_HPI_con_"]/value[@n="_HCA_HPI38_"]}]]
      set HCA17 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_HP_ISA_"]/container[@n="_HCA_HPI_con_"]/value[@n="_HCA_HPI39_"]}]]
      set HCA18 [$node getAttribute "v"]
      GiD_WriteCalculationFile puts "*Mechanical = HCA-HYPO-ISA"
      GiD_WriteCalculationFile puts "$p1, $p2, $p3, $p4, $p5, $p6, $p7, $p8"
      GiD_WriteCalculationFile puts "$p9, $p10, $p11, $p12, $p13, $p14, $p15, $p16"
      GiD_WriteCalculationFile puts "$p17, $p18, $p19, $p20, $p21"
      GiD_WriteCalculationFile puts "$HCA1, $HCA2, $HCA3, $HCA4, $HCA5, 0, $HCA6, 0"
      GiD_WriteCalculationFile puts "$HCA7, $HCA8, $HCA9, $HCA10, $HCA11, $HCA12, $HCA13, $HCA14"
      GiD_WriteCalculationFile puts "$HCA15, $HCA16, $HCA17, $HCA18" 
      # HCA steps
      set impl_list_str ""
      set rec_list_str ""
      set exp_list_str ""
      set list_imp [format_xpath {container[@n="_mat_"]/container[@n="_materials_"]/blockdata/container[@n="_mech_HCA_HP_ISA_"]/container[@n="_HCA_HPI_con_"]/container[@n="_HCA_HPI41_"]/blockdata}]
      set imp_list [$root selectNodes $list_imp]
      GiD_WriteCalculationFile puts "*Implicit HCA steps"
      foreach implicit_name $imp_list {
        set impl_list [$implicit_name getAttribute "name"]
        if {$impl_list_str eq ""} {
          set impl_list_str $impl_list
        } else {
          append impl_list_str ,$impl_list
        }
      }
      GiD_WriteCalculationFile puts "$impl_list_str"
      set list_rec [format_xpath {container[@n="_mat_"]/container[@n="_materials_"]/blockdata/container[@n="_mech_HCA_HP_ISA_"]/container[@n="_HCA_HPI_con_"]/container[@n="_HCA_HPI42_"]/blockdata}]
      set rec_list [$root selectNodes $list_rec]
      GiD_WriteCalculationFile puts "*Recording HCA steps"
      foreach record_name $rec_list {
        set rec_list [$record_name getAttribute "name"]
        if {$rec_list_str eq ""} {
          set rec_list_str $rec_list
        } else {
          append rec_list_str ,$rec_list
        }
      }
      GiD_WriteCalculationFile puts "$rec_list_str"
      set list_exp [format_xpath {container[@n="_mat_"]/container[@n="_materials_"]/blockdata/container[@n="_mech_HCA_HP_ISA_"]/container[@n="_HCA_HPI_con_"]/container[@n="_HCA_HPI43_"]/blockdata}]
      set exp_list [$root selectNodes $list_exp]
      GiD_WriteCalculationFile puts "*Explicit HCA steps"
      foreach explicit_name $exp_list {
        set expl_list [$explicit_name getAttribute "name"]
        if {$exp_list_str eq ""} {
          set exp_list_str $expl_list
        } else {
          append exp_list_str ,$expl_list
        }
      }
      GiD_WriteCalculationFile puts "$exp_list_str"
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_HP_ISA_"]/container[@n="_HCA_HPI_con_"]/value[@n="_HCA_HPI40_"]}]]
      set HCA19 [$node getAttribute "v"]
      GiD_WriteCalculationFile puts "*HCA cycle time"
      GiD_WriteCalculationFile puts "$HCA19" 
	  
      # Sanisand
    } elseif {$model_name == "Sanisand"} {
      set node [$imat selectNodes [format_xpath {container[@n="_mech_Sanisand_"]/value[@n="_SS0_"]}]]
      set name [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_Sanisand_"]/value[@n="_SS1_"]}]]
      set p1 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_Sanisand_"]/value[@n="_SS2_"]}]]
      set p2 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_Sanisand_"]/value[@n="_SS3_"]}]]
      set p3 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_Sanisand_"]/value[@n="_SS4_"]}]]
      set p4 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_Sanisand_"]/value[@n="_SS5_"]}]]
      set p5 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_Sanisand_"]/value[@n="_SS6_"]}]]
      set p6 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_Sanisand_"]/value[@n="_SS7_"]}]]
      set p7 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_Sanisand_"]/value[@n="_SS8_"]}]]
      set p8 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_Sanisand_"]/value[@n="_SS9_"]}]]
      set p9 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_Sanisand_"]/value[@n="_SS10_"]}]]
      set p10 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_Sanisand_"]/value[@n="_SS11_"]}]]
      set p11 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_Sanisand_"]/value[@n="_SS12_"]}]]
      set p12 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_Sanisand_"]/value[@n="_SS13_"]}]]
      set p13 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_Sanisand_"]/value[@n="_SS14_"]}]]
      set p14 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_Sanisand_"]/value[@n="_SS15_"]}]]
      set p15 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_Sanisand_"]/value[@n="_SS16_"]}]]
      set p16 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_Sanisand_"]/container[@n="_Optional_parameters_"]/value[@n="_SS17_"]}]]
      set p17 [$node getAttribute "v"]     
      set node [$imat selectNodes [format_xpath {container[@n="_mech_Sanisand_"]/container[@n="_Optional_parameters_"]/value[@n="_SS17a_"]}]]
      set p17a [$node getAttribute "v"]  	  
      set node [$imat selectNodes [format_xpath {container[@n="_mech_Sanisand_"]/container[@n="_Optional_parameters_"]/value[@n="_SS18_"]}]]
      set p18 [$node getAttribute "v"] 
      set node [$imat selectNodes [format_xpath {container[@n="_mech_Sanisand_"]/container[@n="_Optional_parameters_"]/value[@n="_SS18a_"]}]]
      set p18a [$node getAttribute "v"] 
      set node [$imat selectNodes [format_xpath {container[@n="_mech_Sanisand_"]/container[@n="_Optional_parameters_"]/value[@n="_SS19_"]}]]
      set p19 [$node getAttribute "v"] 
      set node [$imat selectNodes [format_xpath {container[@n="_mech_Sanisand_"]/container[@n="_Optional_parameters_"]/value[@n="_SS19a_"]}]]
      set p19a [$node getAttribute "v"] 
      set node [$imat selectNodes [format_xpath {container[@n="_mech_Sanisand_"]/container[@n="_Optional_parameters_"]/value[@n="_SS20_"]}]]
      set p20 [$node getAttribute "v"]  
      set node [$imat selectNodes [format_xpath {container[@n="_mech_Sanisand_"]/container[@n="_Optional_parameters_"]/value[@n="_SS20a_"]}]]
      set p20a [$node getAttribute "v"]  
      set node [$imat selectNodes [format_xpath {container[@n="_mech_Sanisand_"]/container[@n="_Optional_parameters_"]/value[@n="_SS21_"]}]]
      set p21 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_Sanisand_"]/container[@n="_Optional_parameters_"]/value[@n="_SS21a_"]}]]
      set p21a [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_Sanisand_"]/container[@n="_Optional_parameters_"]/value[@n="_SS22_"]}]]
      set p22 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_Sanisand_"]/container[@n="_Optional_parameters_"]/value[@n="_SS22a_"]}]]
      set p22a [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_Sanisand_"]/container[@n="_Optional_parameters_"]/value[@n="_SS23_"]}]]
      set p23 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_Sanisand_"]/container[@n="_Optional_parameters_"]/value[@n="_SS23a_"]}]]
      set p23a [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_Sanisand_"]/container[@n="_Optional_parameters_"]/value[@n="_SS24_"]}]]
      set p24 [$node getAttribute "v"] 
      set node [$imat selectNodes [format_xpath {container[@n="_mech_Sanisand_"]/container[@n="_Optional_parameters_"]/value[@n="_SS24a_"]}]]
      set p24a [$node getAttribute "v"] 
      set node [$imat selectNodes [format_xpath {container[@n="_mech_Sanisand_"]/container[@n="_Optional_parameters_"]/value[@n="_SS25_"]}]]
      set p25 [$node getAttribute "v"] 
      set node [$imat selectNodes [format_xpath {container[@n="_mech_Sanisand_"]/container[@n="_Optional_parameters_"]/value[@n="_SS25a_"]}]]
      set p25a [$node getAttribute "v"] 
      set node [$imat selectNodes [format_xpath {container[@n="_mech_Sanisand_"]/container[@n="_Optional_parameters_"]/value[@n="_SS26_"]}]]
      set p26 [$node getAttribute "v"]  
      set node [$imat selectNodes [format_xpath {container[@n="_mech_Sanisand_"]/container[@n="_Optional_parameters_"]/value[@n="_SS26a_"]}]]
      set p26a [$node getAttribute "v"]  
      set node [$imat selectNodes [format_xpath {container[@n="_mech_Sanisand_"]/container[@n="_Optional_parameters_"]/value[@n="_SS27_"]}]]
      set p27 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_Sanisand_"]/container[@n="_Optional_parameters_"]/value[@n="_SS27a_"]}]]
      set p27a [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_Sanisand_"]/container[@n="_Optional_parameters_"]/value[@n="_SS28_"]}]]
      set p28 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_Sanisand_"]/container[@n="_Optional_parameters_"]/value[@n="_SS28a_"]}]]
      set p28a [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_Sanisand_"]/container[@n="_Optional_parameters_"]/value[@n="_SS29_"]}]]
      set p29 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_Sanisand_"]/container[@n="_Optional_parameters_"]/value[@n="_SS29a_"]}]]
      set p29a [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_Sanisand_"]/container[@n="_Optional_parameters_"]/value[@n="_SS30_"]}]]
      set p30 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_Sanisand_"]/container[@n="_Optional_parameters_"]/value[@n="_SS30a_"]}]]
      set p30a [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_Sanisand_"]/container[@n="_Optional_parameters_"]/value[@n="_SS31_"]}]]
      set p31 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_Sanisand_"]/container[@n="_Optional_parameters_"]/value[@n="_SS31a_"]}]]
      set p31a [$node getAttribute "v"]
      # core block
      GiD_WriteCalculationFile puts "*Mechanical = Sanisand-2"
      GiD_WriteCalculationFile puts "$p1, $p2, $p3, $p4, $p5, $p6, $p7, $p8"
      GiD_WriteCalculationFile puts "$p9, $p10, $p11, $p12, $p13, $p14, $p15, $p16"
      set anyYes [expr {$p17 eq "Yes" || $p18 eq "Yes" || $p19 eq "Yes" || $p20 eq "Yes" || $p21 eq "Yes" || $p22 eq "Yes" || $p23 eq "Yes" || $p24 eq "Yes" || $p25 eq "Yes" || $p26 eq "Yes" || $p27 eq "Yes" || $p28 eq "Yes" || $p29 eq "Yes" || $p30 eq "Yes" || $p31 eq "Yes"}]
      if {$anyYes} {
        GiD_WriteCalculationFile puts "*Optional mechanical parameter"
        if {$p17 eq "Yes"} { GiD_WriteCalculationFile puts "min_pressure, $p17a"}
        if {$p18 eq "Yes"} { GiD_WriteCalculationFile puts "integration, $p18a"}
        if {$p19 eq "Yes"} { GiD_WriteCalculationFile puts "tol_stress, $p19a"}
        if {$p20 eq "Yes"} { GiD_WriteCalculationFile puts "minimum_dh, $p20a"}
        if {$p21 eq "Yes"} { GiD_WriteCalculationFile puts "allow_cutback, $p21a"}
        if {$p22 eq "Yes"} { GiD_WriteCalculationFile puts "drift_correction, $p22a"}
        if {$p23 eq "Yes"} { GiD_WriteCalculationFile puts "drift_maxiter, $p23a"}
        if {$p24 eq "Yes"} { GiD_WriteCalculationFile puts "tol_yield, $p24a"}
        if {$p25 eq "Yes"} { GiD_WriteCalculationFile puts "tangent_stiffness, $p25a"}
        if {$p26 eq "Yes"} { GiD_WriteCalculationFile puts "jacobi, $p26a"}
        if {$p27 eq "Yes"} { GiD_WriteCalculationFile puts "maximum_strain , $p27a"}
        if {$p28 eq "Yes"} { GiD_WriteCalculationFile puts "maximum_voidratio, $p28a"}
        if {$p29 eq "Yes"} { GiD_WriteCalculationFile puts "minimum_voidratio, $p29a"}
        if {$p30 eq "Yes"} { GiD_WriteCalculationFile puts "bulk_water, $p30a"}
		if {$p31 eq "Yes"} { GiD_WriteCalculationFile puts "mb_formulation, $p31a"}
      } else {}
	  
      # HCA Sanisand 
    } elseif {$model_name == "HCA Sanisand"} {
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_Sani_"]/container[@n="_SS_con_"]/value[@n="_HCA_SS0_"]}]]
      set name [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_Sani_"]/container[@n="_SS_con_"]/value[@n="_HCA_SS1_"]}]]
      set p1 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_Sani_"]/container[@n="_SS_con_"]/value[@n="_HCA_SS2_"]}]]
      set p2 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_Sani_"]/container[@n="_SS_con_"]/value[@n="_HCA_SS3_"]}]]
      set p3 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_Sani_"]/container[@n="_SS_con_"]/value[@n="_HCA_SS4_"]}]]
      set p4 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_Sani_"]/container[@n="_SS_con_"]/value[@n="_HCA_SS5_"]}]]
      set p5 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_Sani_"]/container[@n="_SS_con_"]/value[@n="_HCA_SS6_"]}]]
      set p6 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_Sani_"]/container[@n="_SS_con_"]/value[@n="_HCA_SS7_"]}]]
      set p7 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_Sani_"]/container[@n="_SS_con_"]/value[@n="_HCA_SS8_"]}]]
      set p8 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_Sani_"]/container[@n="_SS_con_"]/value[@n="_HCA_SS9_"]}]]
      set p9 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_Sani_"]/container[@n="_SS_con_"]/value[@n="_HCA_SS10_"]}]]
      set p10 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_Sani_"]/container[@n="_SS_con_"]/value[@n="_HCA_SS11_"]}]]
      set p11 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_Sani_"]/container[@n="_SS_con_"]/value[@n="_HCA_SS12_"]}]]
      set p12 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_Sani_"]/container[@n="_SS_con_"]/value[@n="_HCA_SS13_"]}]]
      set p13 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_Sani_"]/container[@n="_SS_con_"]/value[@n="_HCA_SS14_"]}]]
      set p14 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_Sani_"]/container[@n="_SS_con_"]/value[@n="_HCA_SS15_"]}]]
      set p15 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_Sani_"]/container[@n="_SS_con_"]/value[@n="_HCA_SS16_"]}]]
      set p16 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_Sani_"]/container[@n="_HCA_SS_con_"]/value[@n="_HCA_SS17_"]}]]
      set HCA1 [gid_groups_conds::convert_value_to $node rad]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_Sani_"]/container[@n="_HCA_SS_con_"]/value[@n="_HCA_SS18_"]}]]
      set HCA2 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_Sani_"]/container[@n="_HCA_SS_con_"]/value[@n="_HCA_SS19_"]}]]
      set HCA3 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_Sani_"]/container[@n="_HCA_SS_con_"]/value[@n="_HCA_SS20_"]}]]
      set HCA4 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_Sani_"]/container[@n="_HCA_SS_con_"]/value[@n="_HCA_SS21_"]}]]
      set HCA5 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_Sani_"]/container[@n="_HCA_SS_con_"]/value[@n="_HCA_SS22_"]}]]
      set HCA6 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_Sani_"]/container[@n="_HCA_SS_con_"]/value[@n="_HCA_SS23_"]}]]
      set HCA7 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_Sani_"]/container[@n="_HCA_SS_con_"]/value[@n="_HCA_SS24_"]}]]
      set HCA8 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_Sani_"]/container[@n="_HCA_SS_con_"]/value[@n="_HCA_SS25_"]}]]
      set HCA9 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_Sani_"]/container[@n="_HCA_SS_con_"]/value[@n="_HCA_SS26_"]}]]
      set HCA10 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_Sani_"]/container[@n="_HCA_SS_con_"]/value[@n="_HCA_SS27_"]}]]
      set HCA11 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_Sani_"]/container[@n="_HCA_SS_con_"]/value[@n="_HCA_SS28_"]}]]
      set HCA12 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_Sani_"]/container[@n="_HCA_SS_con_"]/value[@n="_HCA_SS29_"]}]]
      set HCA13 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_Sani_"]/container[@n="_HCA_SS_con_"]/value[@n="_HCA_SS30_"]}]]
      set HCA14 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_Sani_"]/container[@n="_HCA_SS_con_"]/value[@n="_HCA_SS31_"]}]]
      set HCA15 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_Sani_"]/container[@n="_HCA_SS_con_"]/value[@n="_HCA_SS32_"]}]]
      set HCA16 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_Sani_"]/container[@n="_HCA_SS_con_"]/value[@n="_HCA_SS33_"]}]]
      set HCA17 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_Sani_"]/container[@n="_HCA_SS_con_"]/value[@n="_HCA_SS34_"]}]]
      set HCA18 [$node getAttribute "v"]
      GiD_WriteCalculationFile puts "*Mechanical = HCA-Sanisand-2"
      GiD_WriteCalculationFile puts "$p1, $p2, $p3, $p4, $p5, $p6, $p7, $p8"
      GiD_WriteCalculationFile puts "$p9, $p10, $p11, $p12, $p13, $p14, $p15, $p16"
      GiD_WriteCalculationFile puts "$HCA1, $HCA2, $HCA3, $HCA4, $HCA5, 0, $HCA6, 0"
      GiD_WriteCalculationFile puts "$HCA7, $HCA8, $HCA9, $HCA10, $HCA11, $HCA12, $HCA13, $HCA14"
      GiD_WriteCalculationFile puts "$HCA15, $HCA16, $HCA17, $HCA18" 
      # HCA steps
      set impl_list_str ""
      set rec_list_str ""
      set exp_list_str ""
      set list_imp [format_xpath {container[@n="_mat_"]/container[@n="_materials_"]/blockdata/container[@n="_mech_HCA_Sani_"]/container[@n="_HCA_SS_con_"]/container[@n="_HCA_SS36_"]/blockdata}]
      set imp_list [$root selectNodes $list_imp]
      GiD_WriteCalculationFile puts "*Implicit HCA steps"
      foreach implicit_name $imp_list {
        set impl_list [$implicit_name getAttribute "name"]
        if {$impl_list_str eq ""} {
          set impl_list_str $impl_list
        } else {
          append impl_list_str ,$impl_list
        }
      }
      GiD_WriteCalculationFile puts "$impl_list_str"
      set list_rec [format_xpath {container[@n="_mat_"]/container[@n="_materials_"]/blockdata/container[@n="_mech_HCA_Sani_"]/container[@n="_HCA_SS_con_"]/container[@n="_HCA_SS37_"]/blockdata}]
      set rec_list [$root selectNodes $list_rec]
      GiD_WriteCalculationFile puts "*Recording HCA steps"
      foreach record_name $rec_list {
        set rec_list [$record_name getAttribute "name"]
        if {$rec_list_str eq ""} {
          set rec_list_str $rec_list
        } else {
          append rec_list_str ,$rec_list
        }
      }
      GiD_WriteCalculationFile puts "$rec_list_str"
      set list_exp [format_xpath {container[@n="_mat_"]/container[@n="_materials_"]/blockdata/container[@n="_mech_HCA_Sani_"]/container[@n="_HCA_SS_con_"]/container[@n="_HCA_SS38_"]/blockdata}]
      set exp_list [$root selectNodes $list_exp]
      GiD_WriteCalculationFile puts "*Explicit HCA steps"
      foreach explicit_name $exp_list {
        set expl_list [$explicit_name getAttribute "name"]
        if {$exp_list_str eq ""} {
          set exp_list_str $expl_list
        } else {
          append exp_list_str ,$expl_list
        }
      }
      GiD_WriteCalculationFile puts "$exp_list_str"
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HCA_Sani_"]/container[@n="_HCA_SS_con_"]/value[@n="_HCA_SS35_"]}]]
      set HCA19 [$node getAttribute "v"]
      GiD_WriteCalculationFile puts "*HCA cycle time"
      GiD_WriteCalculationFile puts "$HCA19" 
	  
      #Modified cam clay
    } elseif {$model_name == "Modified-Cam-Clay"} {
      set node [$imat selectNodes [format_xpath {container[@n="_mech_MCC_"]/value[@n="_MCC0_"]}]]
      set name [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_MCC_"]/value[@n="_MCC1_"]}]]
      set p1 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_MCC_"]/value[@n="_MCC2_"]}]]
      set p2 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_MCC_"]/value[@n="_MCC3_"]}]]
      set p3 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_MCC_"]/value[@n="_MCC4_"]}]]
      set p4 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_MCC_"]/value[@n="_MCC5_"]}]]
      set p5 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_MCC_"]/value[@n="_MCC6_"]}]]
      set p6 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_MCC_"]/value[@n="_MCC7_"]}]]
      set p7 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_MCC_"]/value[@n="_MCC8_"]}]]
      set p8 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_MCC_"]/value[@n="_MCC9_"]}]]
      set p9 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_MCC_"]/value[@n="_MCC10_"]}]]
      set p10 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_MCC_"]/container[@n="_Optional_parameters_"]/value[@n="_MCC11_"]}]]
      set p11 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_MCC_"]/container[@n="_Optional_parameters_"]/value[@n="_MCC11a_"]}]]
      set p11a [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_MCC_"]/container[@n="_Optional_parameters_"]/value[@n="_MCC12_"]}]]
      set p12 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_MCC_"]/container[@n="_Optional_parameters_"]/value[@n="_MCC12a_"]}]]
      set p12a [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_MCC_"]/container[@n="_Optional_parameters_"]/value[@n="_MCC13_"]}]]
      set p13 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_MCC_"]/container[@n="_Optional_parameters_"]/value[@n="_MCC13a_"]}]]
      set p13a [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_MCC_"]/container[@n="_Optional_parameters_"]/value[@n="_MCC14_"]}]]
      set p14 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_MCC_"]/container[@n="_Optional_parameters_"]/value[@n="_MCC14a_"]}]]
      set p14a [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_MCC_"]/container[@n="_Optional_parameters_"]/value[@n="_MCC15_"]}]]
      set p15 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_MCC_"]/container[@n="_Optional_parameters_"]/value[@n="_MCC15a_"]}]]
      set p15a [$node getAttribute "v"]
      # core block
      GiD_WriteCalculationFile puts "*Mechanical = $name"
      GiD_WriteCalculationFile puts "$p1, $p2, $p3, $p4, $p5, $p6, $p7, $p8"
      GiD_WriteCalculationFile puts "$p9, $p10"
      set anyYes [expr {$p11 eq "Yes" || $p12 eq "Yes" || $p13 eq "Yes" || $p14 eq "Yes" || $p15 eq "Yes"}]
      if {$anyYes} {
        GiD_WriteCalculationFile puts "*Optional mechanical parameter"
        if {$p11 eq "Yes"} { GiD_WriteCalculationFile puts "integrator, $p11a" }
        if {$p12 eq "Yes"} { GiD_WriteCalculationFile puts "tol_stress, $p12a" }
        if {$p13 eq "Yes"} { GiD_WriteCalculationFile puts "num_diff, $p13a" }
        if {$p14 eq "Yes"} { GiD_WriteCalculationFile puts "perturbation, $p14a" }
        if {$p15 eq "Yes"} { GiD_WriteCalculationFile puts "jacobi, $p15a" }
      } else {}
	  
      # Barotropic elasticity
    } elseif {$model_name == "Barotropic elasticity"} {
      set node [$imat selectNodes [format_xpath {container[@n="_mech_Barotropic_"]/value[@n="_BE0_"]}]]
      set name [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_Barotropic_"]/value[@n="_BE1_"]}]]
      set p1 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_Barotropic_"]/value[@n="_BE2_"]}]]
      set p2 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_Barotropic_"]/value[@n="_BE3_"]}]]
      set p3 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_Barotropic_"]/value[@n="_BE4_"]}]]
      set p4 [$node getAttribute "v"]
      GiD_WriteCalculationFile puts "*Mechanical = $name"
      GiD_WriteCalculationFile puts "$p1, $p2, $p3, $p4"
	  
      # Matsuoka-Nakai
    } elseif {$model_name == "Matsuoka-Nakai"} {
      set node [$imat selectNodes [format_xpath {container[@n="_mech_MN_"]/value[@n="_MN0_"]}]]
      set name [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_MN_"]/value[@n="_MN1_"]}]]
      set p1 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_MN_"]/value[@n="_MN2_"]}]]
      set p2 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_MN_"]/value[@n="_MN3_"]}]]
      set p3 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_MN_"]/value[@n="_MN4_"]}]]
      set p4 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_MN_"]/value[@n="_MN5_"]}]]
      set p5 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_MN_"]/value[@n="_MN6_"]}]]
      set p6 [$node getAttribute "v"]
      GiD_WriteCalculationFile puts "*Mechanical = $name"
      GiD_WriteCalculationFile puts "$p1, $p2, $p3, $p4, $p5, $p6"

      # Hardening-Soil
    } elseif {$model_name == "Hardening-Soil"} {
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HS_"]/value[@n="_HS0_"]}]]
      set name [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HS_"]/value[@n="_HS1_"]}]]
      set p1 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HS_"]/value[@n="_HS2_"]}]]
      set p2 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HS_"]/value[@n="_HS3_"]}]]
      set p3 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HS_"]/value[@n="_HS4_"]}]]
      set p4 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HS_"]/value[@n="_HS5_"]}]]
      set p5 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HS_"]/value[@n="_HS6_"]}]]
      set p6 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HS_"]/value[@n="_HS7_"]}]]
      set p7 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HS_"]/value[@n="_HS8_"]}]]
      set p8 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HS_"]/value[@n="_HS9_"]}]]
      set p9 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HS_"]/value[@n="_HS10_"]}]]
      set p10 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HS_"]/value[@n="_HS11_"]}]]
      set p11 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HS_"]/value[@n="_HS12_"]}]]
      set p12 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HS_"]/value[@n="_HS13_"]}]]
      set p13 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_HS_"]/value[@n="_HS14_"]}]]
      set p14 [$node getAttribute "v"]
      GiD_WriteCalculationFile puts "*Mechanical = Hardening-Soil-MN"
      GiD_WriteCalculationFile puts "$p1, $p2, $p3, $p4, $p5, $p6, $p7, $p8"
      GiD_WriteCalculationFile puts "$p9, $p10, $p11, $p12, $p13, $p14"
	  
      # AVHP
    } elseif {$model_name == "AVHP"} {
      set node [$imat selectNodes [format_xpath {container[@n="_mech_AVHP_"]/value[@n="_AV0_"]}]]
      set name [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_AVHP_"]/value[@n="_AV1_"]}]]
      set p1 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_AVHP_"]/value[@n="_AV2_"]}]]
      set p2 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_AVHP_"]/value[@n="_AV3_"]}]]
      set p3 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_AVHP_"]/value[@n="_AV4_"]}]]
      set p4 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_AVHP_"]/value[@n="_AV5_"]}]]
      set p5 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_AVHP_"]/value[@n="_AV6_"]}]]
      set p6 [gid_groups_conds::convert_value_to $node rad]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_AVHP_"]/value[@n="_AV7_"]}]]
      set p7 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_AVHP_"]/value[@n="_AV8_"]}]]
      set p8 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_AVHP_"]/value[@n="_AV9_"]}]]
      set p9 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_AVHP_"]/value[@n="_AV10_"]}]]
      set p10 [$node getAttribute "v"]
      GiD_WriteCalculationFile puts "*Mechanical = $name"
      GiD_WriteCalculationFile puts "$p1, $p2, $p3, $p4, $p5, $p6, $p7, $p8"
      GiD_WriteCalculationFile puts "$p9, $p10"
      # AVISA
    } elseif {$model_name == "AVISA"} {
      set node [$imat selectNodes [format_xpath {container[@n="_mech_AVISA_"]/value[@n="_AVI0_"]}]]
      set name [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_AVISA_"]/value[@n="_AVI1_"]}]]
      set p1 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_AVISA_"]/value[@n="_AVI2_"]}]]
      set p2 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_AVISA_"]/value[@n="_AVI3_"]}]]
      set p3 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_AVISA_"]/value[@n="_AVI4_"]}]]
      set p4 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_AVISA_"]/value[@n="_AVI5_"]}]]
      set p5 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_AVISA_"]/value[@n="_AVI6_"]}]]
      set p6 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_AVISA_"]/value[@n="_AVI7_"]}]]
      set p7 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_AVISA_"]/value[@n="_AVI8_"]}]]
      set p8 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_AVISA_"]/value[@n="_AVI9_"]}]]
      set p9 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_AVISA_"]/value[@n="_AVI10_"]}]]
      set p10 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_AVISA_"]/value[@n="_AVI11_"]}]]
      set p11 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_AVISA_"]/value[@n="_AVI12_"]}]]
      set p12 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_AVISA_"]/value[@n="_AVI13_"]}]]
      set p13 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_AVISA_"]/value[@n="_AVI14_"]}]]
      set p14 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_AVISA_"]/value[@n="_AVI15_"]}]]
      set p15 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_AVISA_"]/value[@n="_AVI16_"]}]]
      set p16 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_AVISA_"]/value[@n="_AVI17_"]}]]
      set p17 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_AVISA_"]/value[@n="_AVI18_"]}]]
      set p18 [$node getAttribute "v"]
      GiD_WriteCalculationFile puts "*Mechanical = AVISA"
      GiD_WriteCalculationFile puts "$p1, $p2, $p3, $p4, $p5, $p6, $p7, $p8"
      GiD_WriteCalculationFile puts "$p9, $p10, $p11, $p12, $p13, $p14, $p15, $p16"
      GiD_WriteCalculationFile puts "$p17, $p18"
	  # Neo-Hooke-2
    } elseif {$model_name == "Neo Hooke-2"} {
      set node [$imat selectNodes [format_xpath {container[@n="_mech_NH2_"]/value[@n="_NH0_"]}]]
      set name [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_NH2_"]/value[@n="_NH1_"]}]]
      set p1 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_mech_NH2_"]/value[@n="_NH2_"]}]]
      set p2 [$node getAttribute "v"]
      GiD_WriteCalculationFile puts "*Mechanical = Neo_hooke_2"
      GiD_WriteCalculationFile puts "$p1, $p2"
	}  
    # density
    if {[lsearch -exact $valid_models $model_name] != -1} {
      if {$nphases == "1"} {
        set node [$imat selectNodes [format_xpath {container[@n="_density_"]/value[@n="phase1"]}]]
        set density1 [$node getAttribute "v"]
        GiD_WriteCalculationFile puts "*Density"
        GiD_WriteCalculationFile puts $density1
      } elseif {$nphases == "2"} {
        set node [$imat selectNodes [format_xpath {container[@n="_density_"]/value[@n="phase1"]}]]
        set density1 [$node getAttribute "v"]
        set node [$imat selectNodes [format_xpath {container[@n="_density_"]/value[@n="phase2"]}]]
        set density2 [$node getAttribute "v"]
        GiD_WriteCalculationFile puts "*Density"
        GiD_WriteCalculationFile puts "$density1, $density2"
      } elseif {$nphases == "3"} {
        set node [$imat selectNodes [format_xpath {container[@n="_density_"]/value[@n="phase1"]}]]
        set density1 [$node getAttribute "v"]
        set node [$imat selectNodes [format_xpath {container[@n="_density_"]/value[@n="phase2"]}]]
        set density2 [$node getAttribute "v"]
        set node [$imat selectNodes [format_xpath {container[@n="_density_"]/value[@n="phase3"]}]]
        set density3 [$node getAttribute "v"]
        GiD_WriteCalculationFile puts "*Density"
        GiD_WriteCalculationFile puts "$density1, $density2, $density3"
      }
    } else {}  
  
    # Bulk modulus
    if {$nphases == "2"} {
      set node [$imat selectNodes [format_xpath {container[@n="_bulk_modulus_"]/value[@n="fluid1"]}]]
      set par1 [$node getAttribute "v"]
      GiD_WriteCalculationFile puts "*Bulk modulus"
      GiD_WriteCalculationFile puts "$par1"
    } elseif {$nphases == "3"} {
      set node [$imat selectNodes [format_xpath {container[@n="_bulk_modulus_"]/value[@n="fluid1"]}]]
      set par1 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_bulk_modulus_"]/value[@n="fluid2"]}]]
      set par2 [$node getAttribute "v"]
      GiD_WriteCalculationFile puts "*Bulk modulus"
      GiD_WriteCalculationFile puts "$par1, $par2"
    }
    
    # Dynamic viscosity
    if {$nphases == "2"} {
      set node [$imat selectNodes [format_xpath {container[@n="_dynamic_viscosity_"]/value[@n="d_visco1"]}]]
      set par1 [$node getAttribute "v"]
      GiD_WriteCalculationFile puts "*Dynamic viscosity"
      GiD_WriteCalculationFile puts "$par1"
    } elseif {$nphases == "3"} {
      set node [$imat selectNodes [format_xpath {container[@n="_dynamic_viscosity_"]/value[@n="d_visco1"]}]]
      set par1 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_dynamic_viscosity_"]/value[@n="d_visco2"]}]]
      set par2 [$node getAttribute "v"]
      GiD_WriteCalculationFile puts "*Dynamic viscosity"
      GiD_WriteCalculationFile puts "$par1, $par2"
    }
    
    # Permeability
    set node [$imat selectNodes [format_xpath {container[@n="_permeability_"]/value[@n="_PM1_"]}]]
    set permeability_type [$node getAttribute "v"]
    if {$nphases == "2"|| $nphases == "3"} {
      if {$permeability_type == "Isotropic"} {
        GiD_WriteCalculationFile puts "*Permeability = Isotropic"
        set node [$imat selectNodes [format_xpath {container[@n="_permeability_"]/value[@n="_PM2_"]}]]
        set par2 [$node getAttribute "v"]
        GiD_WriteCalculationFile puts "$par2"
      } elseif {$permeability_type == "Kozeny-Carman"} {
        GiD_WriteCalculationFile puts "*Permeability = Kozeny-Carman"
        set node [$imat selectNodes [format_xpath {container[@n="_permeability_"]/value[@n="_PM3_"]}]]
        set par3 [$node getAttribute "v"]
        set node [$imat selectNodes [format_xpath {container[@n="_permeability_"]/value[@n="_PM4_"]}]]
        set par4 [$node getAttribute "v"]
        GiD_WriteCalculationFile puts "$par3,$par4"
      }
    } 
    
    # hydraulic model (saturation-suction)
    if {$nphases == "3"} {
      set node [$imat selectNodes [format_xpath {container[@n="_hydraulic_"]/value[@n="_hydraulic_model_"]}]]
      set model_name [$node getAttribute "v"]
      # Van Genuchten
      if {$model_name == "Van Genuchten"} {
        set node [$imat selectNodes [format_xpath {container[@n="_hydraulic_"]/value[@n="_VG1_"]}]]
        set p1 [$node getAttribute "v"]
        set node [$imat selectNodes [format_xpath {container[@n="_hydraulic_"]/value[@n="_VG2_"]}]]
        set p2 [$node getAttribute "v"]
        set node [$imat selectNodes [format_xpath {container[@n="_hydraulic_"]/value[@n="_VG3_"]}]]
        set p3 [$node getAttribute "v"]
        set node [$imat selectNodes [format_xpath {container[@n="_hydraulic_"]/value[@n="_JA0_"]}]]
        set par [$node getAttribute "v"]
        GiD_WriteCalculationFile puts "*Hydraulic = Van Genuchten, swr=$p1"
        GiD_WriteCalculationFile puts "$p2, $p3"
        if {$par == "Deactivated"} {
        } else {
          GiD_WriteCalculationFile puts "*Jacobian = $par"
        }
      } elseif {$model_name == "Brooks-Corey"} {
        set node [$imat selectNodes [format_xpath {container[@n="_hydraulic_"]/value[@n="_BC1_"]}]]
        set p1 [$node getAttribute "v"]
        set node [$imat selectNodes [format_xpath {container[@n="_hydraulic_"]/value[@n="_BC2_"]}]]
        set p2 [$node getAttribute "v"]
        set node [$imat selectNodes [format_xpath {container[@n="_hydraulic_"]/value[@n="_BC3_"]}]]
        set p3 [$node getAttribute "v"]
        set node [$imat selectNodes [format_xpath {container[@n="_hydraulic_"]/value[@n="_JA0_"]}]]
        set par [$node getAttribute "v"]
        GiD_WriteCalculationFile puts "*Hydraulic = Brooks_Corey, swr=$p1"
        GiD_WriteCalculationFile puts "$p2, $p3"
        if {$par == "Deactivated"} {
        } else {
          GiD_WriteCalculationFile puts "*Jacobian = $par"
        }
      } elseif {$model_name == "Fredlung-Xing"} {
        set node [$imat selectNodes [format_xpath {container[@n="_hydraulic_"]/value[@n="_FX1_"]}]]
        set p1 [$node getAttribute "v"]
        set node [$imat selectNodes [format_xpath {container[@n="_hydraulic_"]/value[@n="_FX2_"]}]]
        set p2 [$node getAttribute "v"]
        set node [$imat selectNodes [format_xpath {container[@n="_hydraulic_"]/value[@n="_FX3_"]}]]
        set p3 [$node getAttribute "v"]
        set node [$imat selectNodes [format_xpath {container[@n="_hydraulic_"]/value[@n="_FX4_"]}]]
        set p4 [$node getAttribute "v"]
        set node [$imat selectNodes [format_xpath {container[@n="_hydraulic_"]/value[@n="_JA0_"]}]]
        set par [$node getAttribute "v"]
        GiD_WriteCalculationFile puts "*Hydraulic = Fredlund-Xing"
        GiD_WriteCalculationFile puts "$p1, $p2, $p3, $p4"
        if {$par == "Deactivated"} {
        } else {
          GiD_WriteCalculationFile puts "*Jacobian = $par"
        }
      } elseif {$model_name == "Exponential model"} {
        set node [$imat selectNodes [format_xpath {container[@n="_hydraulic_"]/value[@n="_EX1_"]}]]
        set p1 [$node getAttribute "v"]
        set node [$imat selectNodes [format_xpath {container[@n="_hydraulic_"]/value[@n="_EX2_"]}]]
        set p2 [$node getAttribute "v"]
        set node [$imat selectNodes [format_xpath {container[@n="_hydraulic_"]/value[@n="_JA0_"]}]]
        set par [$node getAttribute "v"]
        GiD_WriteCalculationFile puts "*Hydraulic = Exponential, swr=$p1"
        GiD_WriteCalculationFile puts "$p2"
        if {$par == "Deactivated"} {
        } else {
          GiD_WriteCalculationFile puts "*Jacobian = $par"
        }
      } elseif {$model_name == "Gallipoli model"} {
        set node [$imat selectNodes [format_xpath {container[@n="_hydraulic_"]/value[@n="_GL1_"]}]]
        set p1 [$node getAttribute "v"]
        set node [$imat selectNodes [format_xpath {container[@n="_hydraulic_"]/value[@n="_GL2_"]}]]
        set p2 [$node getAttribute "v"]
        set node [$imat selectNodes [format_xpath {container[@n="_hydraulic_"]/value[@n="_GL3_"]}]]
        set p3 [$node getAttribute "v"]
        set node [$imat selectNodes [format_xpath {container[@n="_hydraulic_"]/value[@n="_GL4_"]}]]
        set p4 [$node getAttribute "v"]
        set node [$imat selectNodes [format_xpath {container[@n="_hydraulic_"]/value[@n="_GL5_"]}]]
        set p5 [$node getAttribute "v"]
        set node [$imat selectNodes [format_xpath {container[@n="_hydraulic_"]/value[@n="_JA0_"]}]]
        set par [$node getAttribute "v"]
        GiD_WriteCalculationFile puts "*Hydraulic = Gallipoli, swr=$p1"
        GiD_WriteCalculationFile puts "$p2, $p3, $p4, $p5"
        if {$par == "Deactivated"} {
        } else {
          GiD_WriteCalculationFile puts "*Jacobian = $par"
        }
      }
    }
  
    # relative permeability model (relative permeability - saturation)
    if {$nphases == "3"} {
      set node [$imat selectNodes [format_xpath {container[@n="_rel_permeability_"]/value[@n="_rel_permeability_model_"]}]]
      set model_name [$node getAttribute "v"]
      # Van Genuchten
      if {$model_name == "Van Genuchten"} {
        set node [$imat selectNodes [format_xpath {container[@n="_rel_permeability_"]/value[@n="_VGR0_"]}]]
        set name [$node getAttribute "v"]
        set node [$imat selectNodes [format_xpath {container[@n="_rel_permeability_"]/value[@n="_VGR1_"]}]]
        set p1 [$node getAttribute "v"]
        set node [$imat selectNodes [format_xpath {container[@n="_rel_permeability_"]/value[@n="_VGR2_"]}]]
        set p2 [$node getAttribute "v"]
        set node [$imat selectNodes [format_xpath {container[@n="_rel_permeability_"]/value[@n="_VGR3_"]}]]
        set p3 [$node getAttribute "v"]
        GiD_WriteCalculationFile puts "*Relative permeability = $name"
        GiD_WriteCalculationFile puts "$p1, $p2, $p3"
      }
    }
	
    # Bishop effective stress
    if {$nphases == "3"} {
      # Van Genuchten
      if {$model_name == "Van Genuchten"} {
        set node [$imat selectNodes [format_xpath {container[@n="_Bishop_"]/value[@n="_BI0_"]}]]
        set par [$node getAttribute "v"]
        GiD_WriteCalculationFile puts "*Bishop effective stress = $par"
      }
    }
    
    # Strength reduction
    set node [$imat selectNodes [format_xpath {container[@n="_strength_reduction_"]/value[@n="_strength_"]}]]
    set st_re [$node getAttribute "v"]
    if {$st_re == "Yes"} {
      GiD_WriteCalculationFile puts "*Reducible Strength"
    } else {}
    
    # Mimimum pressure
    set node [$imat selectNodes [format_xpath {container[@n="_stab_par_"]/container[@n="_min_press_"]/value[@n="_min_pre_"]}]]
    set mi_pr [$node getAttribute "v"]
    if {$mi_pr == "Yes"} {
      set node [$imat selectNodes [format_xpath {container[@n="_stab_par_"]/container[@n="_min_press_"]/value[@n="_min_p_"]}]]
      set m_v [$node getAttribute "v"]
      GiD_WriteCalculationFile puts "*Min pressure"
      GiD_WriteCalculationFile puts "$m_v"
    } else {}
    
    # Mechanical viscosity
    set node [$imat selectNodes [format_xpath {container[@n="_stab_par_"]/container[@n="_mech_viscosity_"]/value[@n="_mech_visco_"]}]]
    set _mech_visco_ [$node getAttribute "v"]
    if {$_mech_visco_ == "Yes"} {
      set node [$imat selectNodes [format_xpath {container[@n="_stab_par_"]/container[@n="_mech_viscosity_"]/value[@n="_mech_viso_0_"]}]]
      set _mech_0_ [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_stab_par_"]/container[@n="_mech_viscosity_"]/value[@n="_mech_viso_1_"]}]]
      set _mech_1_ [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_stab_par_"]/container[@n="_mech_viscosity_"]/value[@n="_mech_viso_2_"]}]]
      set _mech_2_ [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_stab_par_"]/container[@n="_mech_viscosity_"]/value[@n="_mech_viso_3_"]}]]
      set _mech_3_ [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_stab_par_"]/container[@n="_mech_viscosity_"]/value[@n="_mech_viso_4_"]}]]
      set _mech_4_ [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_stab_par_"]/container[@n="_mech_viscosity_"]/value[@n="_mech_viso_5_"]}]]
      set _mech_5_ [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_stab_par_"]/container[@n="_mech_viscosity_"]/value[@n="_mech_viso_6_"]}]]
      set _mech_6_ [$node getAttribute "v"]
      GiD_WriteCalculationFile puts "*Mechanical viscosity = $_mech_0_ "
      GiD_WriteCalculationFile puts "$_mech_1_, $_mech_2_, $_mech_3_, $_mech_4_, $_mech_5_, $_mech_6_"
    } else {}  
  
    # Phantom Elasticity
    set node [$imat selectNodes [format_xpath {container[@n="_stab_par_"]/container[@n="_pham_elas_"]/value[@n="_pham_ela_"]}]]
    set ph_el [$node getAttribute "v"]
    if {$ph_el == "Yes"} {
      set node [$imat selectNodes [format_xpath {container[@n="_stab_par_"]/container[@n="_pham_elas_"]/value[@n="_pha_el_1_"]}]]
      set p_e1 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_stab_par_"]/container[@n="_pham_elas_"]/value[@n="_pha_el_2_"]}]]
      set p_e2 [$node getAttribute "v"]
      GiD_WriteCalculationFile puts "*Phantom elasticity"
      GiD_WriteCalculationFile puts "$p_e1, $p_e2"
    } else {}  
    
    # FPL-stabilisation
    set node [$imat selectNodes [format_xpath {container[@n="_stab_par_"]/container[@n="_fpl_stab_"]/value[@n="_fpl_"]}]]
    set fpl1 [$node getAttribute "v"]
    set node [$imat selectNodes [format_xpath {container[@n="_stab_par_"]/container[@n="_fpl_stab_"]/value[@n="_fpl_alpha_"]}]]
    set fpl2 [$node getAttribute "v"]
    if {$fpl1 == "Yes"} {
      GiD_WriteCalculationFile puts "*FPL-stabilisation"
      GiD_WriteCalculationFile puts "$fpl2"
    } else {}

    # Damping
    set node [$imat selectNodes [format_xpath {container[@n="_damping_"]/value[@n="_damp_"]}]]
    set damp [$node getAttribute "v"]
    if {$damp == "Yes"} {
      set node [$imat selectNodes [format_xpath {container[@n="_damping_"]/value[@n="_damp1_"]}]]
      set d_a1 [$node getAttribute "v"]
      set node [$imat selectNodes [format_xpath {container[@n="_damping_"]/value[@n="_damp2_"]}]]
      set d_a2 [$node getAttribute "v"]
      GiD_WriteCalculationFile puts "*Damping"
      GiD_WriteCalculationFile puts "$d_a1, $d_a2"
    } else {}
  
    # Hourglass
    set node [$imat selectNodes [format_xpath {container[@n="_stab_par_"]/container[@n="_hr_glass_"]/value[@n="_hr_gl_"]}]]
    set hr_gls [$node getAttribute "v"]
    set node [$imat selectNodes [format_xpath {container[@n="_stab_par_"]/container[@n="_hr_glass_"]/value[@n="_hr_method_"]}]]
    set hr_1 [$node getAttribute "v"]
    set node [$imat selectNodes [format_xpath {container[@n="_stab_par_"]/container[@n="_hr_glass_"]/value[@n="_hr_m1_"]}]]
    set hr_2 [$node getAttribute "v"]
    set node [$imat selectNodes [format_xpath {container[@n="_stab_par_"]/container[@n="_hr_glass_"]/value[@n="_hr_m2_"]}]]
    set hr_3 [$node getAttribute "v"]
    if {$hr_gls == "Yes"} {
      if {$nphases == "1"} {
        GiD_WriteCalculationFile puts "*Hourglass, $hr_1 = $hr_2"
      } elseif {$nphases == "2"} {
        GiD_WriteCalculationFile puts "*Hourglass, $hr_1 = $hr_2 ,$hr_3"
      }
    } elseif {$hr_gls == "No"} {}
  }  
  customlib::WriteString ""
  
  #
  # Amplitude
  # 
  
  customlib::WriteString "**"
  customlib::WriteString "** Loading amplitude/signal "
  customlib::WriteString "**"
  # create a list of amplitudes
  set xp [format_xpath {container[@n="_amplitudes_"]/blockdata}]
  set list [$root selectNodes $xp]
  # loop over all Amplitude
  foreach iamp $list {
    # Amplitude name
    set ampname [$iamp getAttribute "name"]
    set node [$iamp selectNodes [format_xpath {value[@n="_amp1_"]}]]
    set ampli [$node getAttribute "v"]
    # ramp
    if {$ampli == "ramp"} {
      set node [$iamp selectNodes [format_xpath {value[@n="_r1_"]}]]
      set p0 [$node getAttribute "v"]
      set node [$iamp selectNodes [format_xpath {value[@n="_r2_"]}]]
      set p1 [$node getAttribute "v"]
      set node [$iamp selectNodes [format_xpath {value[@n="_r3_"]}]]
      set p2 [$node getAttribute "v"]
      set node [$iamp selectNodes [format_xpath {value[@n="_r4_"]}]]
      set p3 [$node getAttribute "v"]
      GiD_WriteCalculationFile puts "*Amplitude, Name=$ampname, Type=$ampli"
      GiD_WriteCalculationFile puts "$p0, $p1, $p2, $p3"
    } elseif  {$ampli == "rising sin"} {
      set node [$iamp selectNodes [format_xpath {value[@n="_rs1_"]}]]
      set p0 [$node getAttribute "v"]
      set node [$iamp selectNodes [format_xpath {value[@n="_rs2_"]}]]
      set p1 [$node getAttribute "v"]
      set node [$iamp selectNodes [format_xpath {value[@n="_rs3_"]}]]
      set p2 [$node getAttribute "v"]
      GiD_WriteCalculationFile puts "*Amplitude, Name=$ampname, Type=rising_sine"
      GiD_WriteCalculationFile puts "$p0, $p1, $p2"
    } elseif {$ampli == "rising cos"} {
      set node [$iamp selectNodes [format_xpath {value[@n="_rc1_"]}]]
      set p0 [$node getAttribute "v"]
      set node [$iamp selectNodes [format_xpath {value[@n="_rc2_"]}]]
      set p1 [$node getAttribute "v"]
      set node [$iamp selectNodes [format_xpath {value[@n="_rc3_"]}]]
      set p2 [$node getAttribute "v"]
      GiD_WriteCalculationFile puts "*Amplitude, Name=$ampname, Type=rising_cosine"
      GiD_WriteCalculationFile puts "$p0, $p1, $p2"
    } elseif {$ampli == "user"} {
      GiD_WriteCalculationFile puts "*Amplitude, Name=$ampname, Type=user"
    } elseif {$ampli == "tabular"} {
      GiD_WriteCalculationFile puts "*Amplitude, Name=$ampname, Type=tabular"
      set nodes [$iamp selectNodes [format_xpath {value[@n="_tab_"]/function/functionVariable[@n="interpolator_func"]/value[@n="point"]}]]
      foreach node $nodes {
        set pi [$node getAttribute "v"]
        GiD_WriteCalculationFile puts "$pi"
      }
    } elseif {$ampli == "periodic"} {
      GiD_WriteCalculationFile puts "*Amplitude, Name=$ampname, Type=periodic"
      set node [$iamp selectNodes [format_xpath {value[@n="_p1_"]}]]
      set p0 [$node getAttribute "v"]
      set node [$iamp selectNodes [format_xpath {value[@n="_p2_"]}]]
      set p1 [$node getAttribute "v"]
      set node [$iamp selectNodes [format_xpath {value[@n="_p3_"]}]]
      set p2 [$node getAttribute "v"]
      set node [$iamp selectNodes [format_xpath {value[@n="_p4_"]}]]
      set p3 [$node getAttribute "v"]
      GiD_WriteCalculationFile puts "$p0, $p1, $p2, $p3"
      set node [$iamp selectNodes [format_xpath {value[@n="_p5_"]}]]
      set p4 [$node getAttribute "v"]
      if {$p4 == "single frequency"} {
        set node [$iamp selectNodes [format_xpath {value[@n="_p6_"]}]]
        set p5 [$node getAttribute "v"]
        GiD_WriteCalculationFile puts "$p5"
      } elseif  {$p4 == "multiple frequencies"} {
        set nodes [$iamp selectNodes [format_xpath {value[@n="_p7_"]/function/functionVariable[@n="interpolator_func"]/value[@n="point"]}]]
        foreach node $nodes {
          set p6 [$node getAttribute "v"]
          GiD_WriteCalculationFile puts "$p6"
        }	  
      } else {} 
    } elseif {$ampli == "additional amplitudes"} {
      set xp [format_xpath {container[@n='_amplitudes_']/blockdata[@n='_amplitude_']/condition[@n='_lab_cyclic_']}]
			set list [$root selectNodes $xp]
			set additional_amplitude 0
      if {[llength $list] > 0} {
        foreach add_ampli $list {
          set xp "./group"
          set groups [$add_ampli selectNodes $xp]
          foreach group $groups {
            set group_name [get_domnode_attribute $group n]
            set node [$group selectNodes [format_xpath {value[@n="_lab_cyc_1_"]}]]
            set p0 [$node getAttribute "v"]
            set node [$group selectNodes [format_xpath {value[@n="_lab_cyc_2_"]}]]
            set p1 [$node getAttribute "v"]
            set node [$group selectNodes [format_xpath {value[@n="_lab_cyc_3_"]}]]
            set p2 [$node getAttribute "v"]
            set node [$group selectNodes [format_xpath {value[@n="_lab_cyc_4_"]}]]
            set p3 [$node getAttribute "v"]
            set node [$group selectNodes [format_xpath {value[@n="_lab_cyc_5_"]}]]
            set p4 [$node getAttribute "v"]
            GiD_WriteCalculationFile puts "*Amplitude, Name=$ampname, Type=lab-cyclic-stress-strain-control"
            GiD_WriteCalculationFile puts "$group_name, $p0, $p1, $p2, $p3, $p4"
          }
        }
      } else {}
      set xp [format_xpath {container[@n='_amplitudes_']/blockdata[@n='_amplitude_']/condition[@n='_lab_trix_']}]
      set list [$root selectNodes $xp]
      set additional_amplitude 0
      if {[llength $list] > 0} {
        foreach add_ampli $list {
      	  set xp "./group"
      	  set groups [$add_ampli selectNodes $xp]
          foreach group $groups {
            set group_name [get_domnode_attribute $group n]
            set node [$group selectNodes [format_xpath {value[@n="_lab_tri_1_"]}]]
            set p0 [$node getAttribute "v"]
            GiD_WriteCalculationFile puts "*Amplitude, Name=$ampname, Type=lab-triaxial-constant-pressure"
            GiD_WriteCalculationFile puts "$group_name, $p0"
          }
        }
      } else {}
    }
  }
  customlib::WriteString ""
  
  #
  # Embedded region
  # 
  set xp [format_xpath {container[@n="_embedded_region_"]/blockdata}]
  set container_list [$root selectNodes $xp]
  foreach iemb_reg $container_list {
    # Select the group nodes under the embedded element condition
    set node [format_xpath {condition[@n="_embedded_element_"]/group}]
    set group_nodes1 [$iemb_reg selectNodes $node]
    foreach group $group_nodes1 {
      set group_name1 [get_domnode_attribute $group n]
    }
    set node [format_xpath {condition[@n="_embedded_node_"]/group}]
    set group_nodes2 [$iemb_reg selectNodes $node]
    foreach group $group_nodes2 {
      set group_name2 [get_domnode_attribute $group n]
    }
    set node [format_xpath {condition[@n="_host_element_"]/group}]
    set group_nodes3 [$iemb_reg selectNodes $node]
    foreach group $group_nodes3 {
      set group_name3 [get_domnode_attribute $group n]
    }
    set node [$iemb_reg selectNodes [format_xpath {value[@n="_method_"]}]]
    set value [$node getAttribute "v"]
    if {[llength $group_nodes1] > 0 && [llength $group_nodes2] > 0 && [llength $group_nodes3] > 0} {
      customlib::WriteString "**"
      customlib::WriteString "** Embedded region"
      customlib::WriteString "**"
      if {$value == "absorbed"} {
        customlib::WriteString "*Embedded region, absorbed"
        customlib::WriteString "$group_name1, $group_name2, $group_name3"
      } else {}
    }
  }
  customlib::WriteString ""
  
  #
  # Contact/interaction
  # 

  # create a list of contacts
  set xp [format_xpath {container[@n="_contact1_"]/blockdata}]
  set list [$root selectNodes $xp]
  # loop over all contacts
  foreach icon $list {
    # contact name
    set conname [$icon getAttribute "name"]
    set node [$icon selectNodes [format_xpath {container[@n="_normal_contacts_"]/value[@n="_contact_model_"]}]]
    set con_model [$node getAttribute "v"]
    set node [$icon selectNodes [format_xpath {container[@n="_normal_contacts_"]/value[@n="_sep_"]}]]
    set sepration [$node getAttribute "v"]
    set node [$icon selectNodes [format_xpath {container[@n="_normal_contacts_"]/value[@n="_penalty_"]}]]
    set penalty_type [$node getAttribute "v"]
    set node [$icon selectNodes [format_xpath {container[@n="_normal_contacts_"]/value[@n="_value_"]}]]
    set value [$node getAttribute "v"]
    set node [$icon selectNodes [format_xpath {container[@n="_normal_contacts_"]/value[@n="_non_constant_"]}]]
    set non_constant [$node getAttribute "v"]
    set node [$icon selectNodes [format_xpath {container[@n="_normal_contacts_"]/value[@n="_adhesion_"]}]]
    set adhesion [$node getAttribute "v"]
    set node [$icon selectNodes [format_xpath {container[@n="_normal_contacts_"]/value[@n="_adhesion_value_"]}]]
    set adhesion_value [$node getAttribute "v"]
    set node [$icon selectNodes [format_xpath {container[@n="_tangential_contacts_"]/value[@n="_user_"]}]]
    set user [$node getAttribute "v"]
    set node [$icon selectNodes [format_xpath {container[@n="_tangential_contacts_"]/value[@n="_Frc_model_"]}]]
    set cmodel [$node getAttribute "v"]
    set node [$icon selectNodes [format_xpath {container[@n="_tangential_contacts_"]/value[@n="_tan_stiff_factor_"]}]]
    set tanstiffness [$node getAttribute "v"]	
    set node [$icon selectNodes [format_xpath {container[@n="_tangential_contacts_"]/value[@n="_value_stiff_"]}]]
    set valuestiff [$node getAttribute "v"]
    set node [$icon selectNodes [format_xpath {container[@n="_tangential_contacts_"]/value[@n="_c_C1_"]}]]
    set pc1 [$node getAttribute "v"]
    set node [$icon selectNodes [format_xpath {container[@n="_tangential_contacts_"]/value[@n="_c_C2_"]}]]
    set pc2 [$node getAttribute "v"]
    set node [$icon selectNodes [format_xpath {container[@n="_tangential_contacts_"]/value[@n="_c_C3_"]}]]
    set pc3 [$node getAttribute "v"]	
    set node [$icon selectNodes [format_xpath {container[@n="_tangential_contacts_"]/value[@n="_c_MC1_"]}]]
    set p1 [$node getAttribute "v"]
    set node [$icon selectNodes [format_xpath {container[@n="_tangential_contacts_"]/value[@n="_c_MC2_"]}]]
    set p2 [$node getAttribute "v"]
    set node [$icon selectNodes [format_xpath {container[@n="_tangential_contacts_"]/value[@n="_c_MC3_"]}]]
    set p3 [$node getAttribute "v"]
    set node [$icon selectNodes [format_xpath {container[@n="_tangential_contacts_"]/value[@n="_c_MC4_"]}]]
    set p4 [$node getAttribute "v"]
    set node [$icon selectNodes [format_xpath {container[@n="_tangential_contacts_"]/value[@n="_c_hp1_"]}]]
    set ph1 [$node getAttribute "v"]
    set node [$icon selectNodes [format_xpath {container[@n="_tangential_contacts_"]/value[@n="_c_hp2_"]}]]
    set ph2 [$node getAttribute "v"]
    set node [$icon selectNodes [format_xpath {container[@n="_tangential_contacts_"]/value[@n="_c_hp3_"]}]]
    set ph3 [$node getAttribute "v"]
    set node [$icon selectNodes [format_xpath {container[@n="_tangential_contacts_"]/value[@n="_c_hp4_"]}]]
    set ph4 [$node getAttribute "v"]
    set node [$icon selectNodes [format_xpath {container[@n="_tangential_contacts_"]/value[@n="_c_hp5_"]}]]
    set ph5 [$node getAttribute "v"]
    set node [$icon selectNodes [format_xpath {container[@n="_tangential_contacts_"]/value[@n="_c_hp6_"]}]]
    set ph6 [$node getAttribute "v"]
    set node [$icon selectNodes [format_xpath {container[@n="_tangential_contacts_"]/value[@n="_c_hp7_"]}]]
    set ph7 [$node getAttribute "v"]
    set node [$icon selectNodes [format_xpath {container[@n="_tangential_contacts_"]/value[@n="_c_hp8_"]}]]
    set ph8 [$node getAttribute "v"]
    set node [$icon selectNodes [format_xpath {container[@n="_tangential_contacts_"]/value[@n="_c_hp9_"]}]]
    set ph9 [$node getAttribute "v"]
    set node [$icon selectNodes [format_xpath {container[@n="_tangential_contacts_"]/value[@n="_c_hp10_"]}]]
    set ph10 [$node getAttribute "v"]
    set node [$icon selectNodes [format_xpath {container[@n="_tangential_contacts_"]/value[@n="_c_hp11_"]}]]
    set ph11 [$node getAttribute "v"]
    set node [$icon selectNodes [format_xpath {container[@n="_tangential_contacts_"]/value[@n="_c_hp12_"]}]]
    set ph12 [$node getAttribute "v"]
    set node [$icon selectNodes [format_xpath {container[@n="_tangential_contacts_"]/value[@n="_c_hp13_"]}]]
    set ph13 [$node getAttribute "v"]
    set node [$icon selectNodes [format_xpath {container[@n="_tangential_contacts_"]/value[@n="_c_hp14_"]}]]
    set ph14 [$node getAttribute "v"]
    set node [$icon selectNodes [format_xpath {container[@n="_tangential_contacts_"]/value[@n="_c_hp15_"]}]]
    set ph15 [$node getAttribute "v"]
    set node [$icon selectNodes [format_xpath {container[@n="_tangential_contacts_"]/value[@n="_c_hp16_"]}]]
    set ph16 [$node getAttribute "v"]
    set groupLists [$icon selectNodes {./condition[@n='_contact_pair_']/groupList}]
    set valid_group_pair_found 0
    foreach groupList $groupLists {
      set groups [$groupList selectNodes "./group"]
      if {[llength $groups] >= 2} {
        set valid_group_pair_found 1
      }
    }
    if {!$valid_group_pair_found} {
      continue
    }
    customlib::WriteString "**"
    customlib::WriteString "** Contact/interaction"
    customlib::WriteString "**"
    if {$sepration == "no"} {
      if {$user == "yes"} {
        if {$non_constant == "yes"} {
          if {$penalty_type == "...select..."} {
            if {$adhesion == "yes"} {
              GiD_WriteCalculationFile puts "*Interaction, Name=$conname, user"
              GiD_WriteCalculationFile puts "*Normal, Mechanical=$con_model, No Separation, non constant"
              GiD_WriteCalculationFile puts ",$adhesion_value"
              if {$cmodel == "Coulomb"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Coulomb"
                } elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Coulomb, stiffness_factor=$valuestiff"
                }
              } elseif {$cmodel == "Mohr-coulomb"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Mohr-Coulomb"
                } elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Mohr-Coulomb, stiffness_factor=$valuestiff"
                }
              } elseif {$cmodel == "Hypoplastic"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Hypoplasticity_numgeo"
                } elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Hypoplasticity_numgeo, stiffness_factor=$valuestiff"
                }
              } elseif {$cmodel == "Friction less"} {}
            } elseif {$adhesion == "no"} {
              GiD_WriteCalculationFile puts "*Interaction, Name=$conname, user"
              GiD_WriteCalculationFile puts "*Normal, Mechanical=$con_model, No Separation, non constant"
              if {$cmodel == "Coulomb"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Coulomb"
                } elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Coulomb, stiffness_factor=$valuestiff"
                }
              } elseif {$cmodel == "Mohr-coulomb"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Mohr-Coulomb"
                } elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Mohr-Coulomb, stiffness_factor=$valuestiff"
                }
              } elseif {$cmodel == "Hypoplastic"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Hypoplasticity_numgeo"
                } elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Hypoplasticity_numgeo, stiffness_factor=$valuestiff"
                }
              } elseif {$cmodel == "Friction less"} {}
            }
          } elseif {$penalty_type == "Stiffness factor"} {
            if {$adhesion == "yes"} {
              GiD_WriteCalculationFile puts "*Interaction, Name=$conname, user"
              GiD_WriteCalculationFile puts "*Normal, Name=$conname, Mechanical=$con_model, No Separation, stiffness_factor=$value, non constant"
              GiD_WriteCalculationFile puts ",$adhesion_value"
              if {$cmodel == "Coulomb"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Coulomb"
                } elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Coulomb, stiffness_factor=$valuestiff"
                }
              } elseif {$cmodel == "Mohr-coulomb"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Mohr-Coulomb"
                } elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Mohr-Coulomb, stiffness_factor=$valuestiff"
                }
              } elseif {$cmodel == "Hypoplastic"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Hypoplasticity_numgeo"
                } elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Hypoplasticity_numgeo, stiffness_factor=$valuestiff"
                }
              } elseif {$cmodel == "Friction less"} {}
            } elseif {$adhesion == "no"} {
              GiD_WriteCalculationFile puts "*Interaction, Name=$conname, user"
              GiD_WriteCalculationFile puts "*Normal, Name=$conname, Mechanical=$con_model, No Separation, stiffness_factor=$value, non constant"
              if {$cmodel == "Coulomb"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Coulomb"
                } elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Coulomb, stiffness_factor=$valuestiff"
                }
              } elseif {$cmodel == "Mohr-coulomb"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Mohr-Coulomb"
                } elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Mohr-Coulomb, stiffness_factor=$valuestiff"
                }
              } elseif {$cmodel == "Hypoplastic"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Hypoplasticity_numgeo"
                } elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Hypoplasticity_numgeo, stiffness_factor=$valuestiff"
                }
              } elseif {$cmodel == "Friction less"} {}
            }
          } elseif {$penalty_type == "Constant"} {
            if {$adhesion == "yes"} {
              GiD_WriteCalculationFile puts "*Interaction, Name=$conname, user"
              GiD_WriteCalculationFile puts "*Normal, Mechanical=$con_model, No Separation, non constant"
              GiD_WriteCalculationFile puts ",$adhesion_value"
            } elseif {$adhesion == "no"} {
              GiD_WriteCalculationFile puts "*Interaction, Name=$conname, user"
              GiD_WriteCalculationFile puts "*Normal, Mechanical=$con_model, No Separation, non constant"
            }
            GiD_WriteCalculationFile puts "*friction, model=$cmodel"
          }
        } elseif {$non_constant == "no"} {
          if {$penalty_type == "...select..."} {
            if {$adhesion == "yes"} {
              GiD_WriteCalculationFile puts "*Interaction, Name=$conname, user"
              GiD_WriteCalculationFile puts "*Normal, Mechanical=$con_model, No Separation"
              GiD_WriteCalculationFile puts ",$adhesion_value"
              if {$cmodel == "Coulomb"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Coulomb"
                } elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Coulomb, stiffness_factor=$valuestiff"
                }
              } elseif {$cmodel == "Mohr-coulomb"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Mohr-Coulomb"
                } elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Mohr-Coulomb, stiffness_factor=$valuestiff"
                }
              } elseif {$cmodel == "Hypoplastic"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Hypoplasticity_numgeo"
                } elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Hypoplasticity_numgeo, stiffness_factor=$valuestiff"
                }
              } elseif {$cmodel == "Friction less"} {}
            } elseif {$adhesion == "no"} {
              GiD_WriteCalculationFile puts "*Interaction, Name=$conname, user"
              GiD_WriteCalculationFile puts "*Normal, Mechanical=$con_model, No Separation"
              if {$cmodel == "Coulomb"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Coulomb"
                } elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Coulomb, stiffness_factor=$valuestiff"
                }
              } elseif {$cmodel == "Mohr-coulomb"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Mohr-Coulomb"
                } elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Mohr-Coulomb, stiffness_factor=$valuestiff"
                }
              } elseif {$cmodel == "Hypoplastic"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Hypoplasticity_numgeo"
                } elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Hypoplasticity_numgeo, stiffness_factor=$valuestiff"
                }
              } elseif {$cmodel == "Friction less"} {}
            }
          } elseif {$penalty_type == "Stiffness factor"} {
            if {$adhesion == "yes"} {
              GiD_WriteCalculationFile puts "*Interaction, Name=$conname, user"
              GiD_WriteCalculationFile puts "*Normal, Mechanical=$con_model, No Separation,  stiffness_factor=$value"
              GiD_WriteCalculationFile puts ",$adhesion_value"
              if {$cmodel == "Coulomb"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Coulomb"
                } elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Coulomb, stiffness_factor=$valuestiff"
                }
              } elseif {$cmodel == "Mohr-coulomb"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Mohr-Coulomb"
                } elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Mohr-Coulomb, stiffness_factor=$valuestiff"
                }
              } elseif {$cmodel == "Hypoplastic"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Hypoplasticity_numgeo"
                } elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Hypoplasticity_numgeo, stiffness_factor=$valuestiff"
                }
              } elseif {$cmodel == "Friction less"} {}
            } elseif {$adhesion == "no"} {
              GiD_WriteCalculationFile puts "*Interaction, Name=$conname, user"
              GiD_WriteCalculationFile puts "*Normal, Mechanical=$con_model, No Separation,  stiffness_factor=$value"
              if {$cmodel == "Coulomb"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Coulomb"
                } elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Coulomb, stiffness_factor=$valuestiff"
                }
              } elseif {$cmodel == "Mohr-coulomb"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Mohr-Coulomb"
                } elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Mohr-Coulomb, stiffness_factor=$valuestiff"
                }
              } elseif {$cmodel == "Hypoplastic"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Hypoplasticity_numgeo"
                } elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Hypoplasticity_numgeo, stiffness_factor=$valuestiff"
                }
              } elseif {$cmodel == "Friction less"} {}
            }
          } elseif {$penalty_type == "Constant"} {
            if {$adhesion == "yes"} {
              GiD_WriteCalculationFile puts "*Interaction, Name=$conname, user"
              GiD_WriteCalculationFile puts "*Normal, Mechanical=$con_model, No Separation"
              GiD_WriteCalculationFile puts "$value, $adhesion_value"
              if {$cmodel == "Coulomb"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Coulomb"
                } elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Coulomb, stiffness_factor=$valuestiff"
                }
              } elseif {$cmodel == "Mohr-coulomb"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Mohr-Coulomb"
                } elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Mohr-Coulomb, stiffness_factor=$valuestiff"
                }
              } elseif {$cmodel == "Hypoplastic"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Hypoplasticity_numgeo"
                } elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Hypoplasticity_numgeo, stiffness_factor=$valuestiff"
                }
              } elseif {$cmodel == "Friction less"} {}
            }  elseif {$adhesion == "no"} {
              GiD_WriteCalculationFile puts "*Interaction, Name=$conname, user"
              GiD_WriteCalculationFile puts "*Normal, Mechanical=$con_model, No Separation"
              GiD_WriteCalculationFile puts "$value"
              if {$cmodel == "Coulomb"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Coulomb"
                } elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Coulomb, stiffness_factor=$valuestiff"
                }
              } elseif {$cmodel == "Mohr-coulomb"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Mohr-Coulomb"
                } elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Mohr-Coulomb, stiffness_factor=$valuestiff"
                }
              } elseif {$cmodel == "Hypoplastic"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Hypoplasticity_numgeo"
                } elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Hypoplasticity_numgeo, stiffness_factor=$valuestiff"
                }
              } elseif {$cmodel == "Friction less"} {}
            }
          }
        }
      } elseif {$user == "no"} {
        if {$non_constant == "yes"} {
          if {$penalty_type == "...select..."} {
            if {$adhesion == "yes"} {
              GiD_WriteCalculationFile puts "*Interaction, Name=$conname"
              GiD_WriteCalculationFile puts "*Normal, Mechanical=$con_model, No Separation, non constant"
              GiD_WriteCalculationFile puts ", $adhesion_value"
              if {$cmodel == "Coulomb"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Coulomb"
                  GiD_WriteCalculationFile puts "$pc1, $pc2, $pc3"
                } elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Coulomb, stiffness_factor=$valuestiff"
                  GiD_WriteCalculationFile puts "$pc1, $pc2, $pc3"
                }
              } elseif {$cmodel == "Mohr-Coulomb"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Mohr-Coulomb"
                  GiD_WriteCalculationFile puts "$p1, $p2, $p3, $p4"
                } elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Mohr-Coulomb, stiffness_factor=$valuestiff"
                  GiD_WriteCalculationFile puts "$p1, $p2, $p3, $p4"
                }
              } elseif {$cmodel == "Hypoplastic"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Hypoplasticity_numgeo"
                  GiD_WriteCalculationFile puts "$ph1, $ph2, $ph3, $ph4, $ph5, $ph6, $ph7, $ph8"
                  GiD_WriteCalculationFile puts "$ph9, $ph10, $ph11, $ph12, $ph13, $ph14, $ph15, $ph16"
                }	elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Hypoplasticity_numgeo, stiffness_factor=$valuestiff"
                  GiD_WriteCalculationFile puts "$ph1, $ph2, $ph3, $ph4, $ph5, $ph6, $ph7, $ph8"
                  GiD_WriteCalculationFile puts "$ph9, $ph10, $ph11, $ph12, $ph13, $ph14, $ph15, $ph16"
                }
              } elseif {$cmodel == "Friction less"} {}
            } elseif {$adhesion == "no"} {
              GiD_WriteCalculationFile puts "*Interaction, Name=$conname"
              GiD_WriteCalculationFile puts "*Normal, Mechanical=$con_model, No Separation, non constant"
              GiD_WriteCalculationFile puts ", $adhesion_value"
              if {$cmodel == "Coulomb"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Coulomb"
                  GiD_WriteCalculationFile puts "$pc1, $pc2, $pc3"
                } elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Coulomb, stiffness_factor=$valuestiff"
                  GiD_WriteCalculationFile puts "$pc1, $pc2, $pc3"
                }
              } elseif {$cmodel == "Mohr-Coulomb"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Mohr-Coulomb"
                  GiD_WriteCalculationFile puts "$p1, $p2, $p3, $p4"
                } elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Mohr-Coulomb, stiffness_factor=$valuestiff"
                  GiD_WriteCalculationFile puts "$p1, $p2, $p3, $p4"
                }
              } elseif {$cmodel == "Hypoplastic"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Hypoplasticity_numgeo"
                  GiD_WriteCalculationFile puts "$ph1, $ph2, $ph3, $ph4, $ph5, $ph6, $ph7, $ph8"
                  GiD_WriteCalculationFile puts "$ph9, $ph10, $ph11, $ph12, $ph13, $ph14, $ph15, $ph16"
                }	elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Hypoplasticity_numgeo, stiffness_factor=$valuestiff"
                  GiD_WriteCalculationFile puts "$ph1, $ph2, $ph3, $ph4, $ph5, $ph6, $ph7, $ph8"
                  GiD_WriteCalculationFile puts "$ph9, $ph10, $ph11, $ph12, $ph13, $ph14, $ph15, $ph16"
                }
              } elseif {$cmodel == "Friction less"} {}
            }
          } elseif {$penalty_type == "Stiffness factor"} {
            if {$adhesion == "yes"} {
              GiD_WriteCalculationFile puts "*Interaction, Name=$conname"
              GiD_WriteCalculationFile puts "*Normal, Mechanical=$con_model, No Separation, stiffness_factor=$value, non constant"
              GiD_WriteCalculationFile puts ", $adhesion_value"
              if {$cmodel == "Coulomb"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Coulomb"
                  GiD_WriteCalculationFile puts "$pc1, $pc2, $pc3"
                } elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Coulomb, stiffness_factor=$valuestiff"
                  GiD_WriteCalculationFile puts "$pc1, $pc2, $pc3"
                }
              } elseif {$cmodel == "Mohr-Coulomb"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Mohr-Coulomb"
                  GiD_WriteCalculationFile puts "$p1, $p2, $p3, $p4"
                } elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Mohr-Coulomb, stiffness_factor=$valuestiff"
                  GiD_WriteCalculationFile puts "$p1, $p2, $p3, $p4"
                }
              } elseif {$cmodel == "Hypoplastic"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Hypoplasticity_numgeo"
                  GiD_WriteCalculationFile puts "$ph1, $ph2, $ph3, $ph4, $ph5, $ph6, $ph7, $ph8"
                  GiD_WriteCalculationFile puts "$ph9, $ph10, $ph11, $ph12, $ph13, $ph14, $ph15, $ph16"
                }	elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Hypoplasticity_numgeo, stiffness_factor=$valuestiff"
                  GiD_WriteCalculationFile puts "$ph1, $ph2, $ph3, $ph4, $ph5, $ph6, $ph7, $ph8"
                  GiD_WriteCalculationFile puts "$ph9, $ph10, $ph11, $ph12, $ph13, $ph14, $ph15, $ph16"
                }
              } elseif {$cmodel == "Friction less"} {}
            } elseif {$adhesion == "no"} {
              GiD_WriteCalculationFile puts "*Interaction, Name=$conname"
              GiD_WriteCalculationFile puts "*Normal, Mechanical=$con_model, No Separation, stiffness_factor=$value, non constant"
              if {$cmodel == "Coulomb"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Coulomb"
                  GiD_WriteCalculationFile puts "$pc1, $pc2, $pc3"
                } elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Coulomb, stiffness_factor=$valuestiff"
                  GiD_WriteCalculationFile puts "$pc1, $pc2, $pc3"
                }
              } elseif {$cmodel == "Mohr-Coulomb"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Mohr-Coulomb"
                  GiD_WriteCalculationFile puts "$p1, $p2, $p3, $p4"
                } elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Mohr-Coulomb, stiffness_factor=$valuestiff"
                  GiD_WriteCalculationFile puts "$p1, $p2, $p3, $p4"
                }
              } elseif {$cmodel == "Hypoplastic"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Hypoplasticity_numgeo"
                  GiD_WriteCalculationFile puts "$ph1, $ph2, $ph3, $ph4, $ph5, $ph6, $ph7, $ph8"
                  GiD_WriteCalculationFile puts "$ph9, $ph10, $ph11, $ph12, $ph13, $ph14, $ph15, $ph16"
                }	elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Hypoplasticity_numgeo, stiffness_factor=$valuestiff"
                  GiD_WriteCalculationFile puts "$ph1, $ph2, $ph3, $ph4, $ph5, $ph6, $ph7, $ph8"
                  GiD_WriteCalculationFile puts "$ph9, $ph10, $ph11, $ph12, $ph13, $ph14, $ph15, $ph16"
                }
              } elseif {$cmodel == "Friction less"} {}
            }
          } elseif {$penalty_type == "Constant"} {
            if {$adhesion == "yes"} {
              GiD_WriteCalculationFile puts "*Interaction, Name=$conname"
              GiD_WriteCalculationFile puts "*Normal, Mechanical=$con_model, No Separation, non constant"
              GiD_WriteCalculationFile puts ", $adhesion_value"
              if {$cmodel == "Coulomb"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Coulomb"
                  GiD_WriteCalculationFile puts "$pc1, $pc2, $pc3"
                } elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Coulomb, stiffness_factor=$valuestiff"
                  GiD_WriteCalculationFile puts "$pc1, $pc2, $pc3"
                }
              } elseif {$cmodel == "Mohr-Coulomb"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Mohr-Coulomb"
                  GiD_WriteCalculationFile puts "$p1, $p2, $p3, $p4"
                } elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Mohr-Coulomb, stiffness_factor=$valuestiff"
                  GiD_WriteCalculationFile puts "$p1, $p2, $p3, $p4"
                }
              } elseif {$cmodel == "Hypoplastic"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Hypoplasticity_numgeo"
                  GiD_WriteCalculationFile puts "$ph1, $ph2, $ph3, $ph4, $ph5, $ph6, $ph7, $ph8"
                  GiD_WriteCalculationFile puts "$ph9, $ph10, $ph11, $ph12, $ph13, $ph14, $ph15, $ph16"
                }	elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Hypoplasticity_numgeo, stiffness_factor=$valuestiff"
                  GiD_WriteCalculationFile puts "$ph1, $ph2, $ph3, $ph4, $ph5, $ph6, $ph7, $ph8"
                  GiD_WriteCalculationFile puts "$ph9, $ph10, $ph11, $ph12, $ph13, $ph14, $ph15, $ph16"
                }
              } elseif {$cmodel == "Friction less"} {}
            } elseif {$adhesion == "no"} {
              GiD_WriteCalculationFile puts "*Interaction, Name=$conname"
              GiD_WriteCalculationFile puts "*Normal, Mechanical=$con_model, No Separation, non constant"
              if {$cmodel == "Coulomb"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Coulomb"
                  GiD_WriteCalculationFile puts "$pc1, $pc2, $pc3"
                } elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Coulomb, stiffness_factor=$valuestiff"
                  GiD_WriteCalculationFile puts "$pc1, $pc2, $pc3"
                }
              } elseif {$cmodel == "Mohr-Coulomb"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Mohr-Coulomb"
                  GiD_WriteCalculationFile puts "$p1, $p2, $p3, $p4"
                } elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Mohr-Coulomb, stiffness_factor=$valuestiff"
                  GiD_WriteCalculationFile puts "$p1, $p2, $p3, $p4"
                }
              } elseif {$cmodel == "Hypoplastic"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Hypoplasticity_numgeo"
                  GiD_WriteCalculationFile puts "$ph1, $ph2, $ph3, $ph4, $ph5, $ph6, $ph7, $ph8"
                  GiD_WriteCalculationFile puts "$ph9, $ph10, $ph11, $ph12, $ph13, $ph14, $ph15, $ph16"
                }	elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Hypoplasticity_numgeo, stiffness_factor=$valuestiff"
                  GiD_WriteCalculationFile puts "$ph1, $ph2, $ph3, $ph4, $ph5, $ph6, $ph7, $ph8"
                  GiD_WriteCalculationFile puts "$ph9, $ph10, $ph11, $ph12, $ph13, $ph14, $ph15, $ph16"
                }
              } elseif {$cmodel == "Friction less"} {}
            }
          }
        } elseif {$non_constant == "no"} {
          if {$penalty_type == "...select..."} {
            if {$adhesion == "yes"} {
              GiD_WriteCalculationFile puts "*Interaction, Name=$conname"
              GiD_WriteCalculationFile puts "*Normal, Mechanical=$con_model, No Separation"
              GiD_WriteCalculationFile puts ", $adhesion_value"
              if {$cmodel == "Coulomb"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Coulomb"
                  GiD_WriteCalculationFile puts "$pc1, $pc2, $pc3"
                } elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Coulomb, stiffness_factor=$valuestiff"
                  GiD_WriteCalculationFile puts "$pc1, $pc2, $pc3"
                }
              } elseif {$cmodel == "Mohr-Coulomb"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Mohr-Coulomb"
                  GiD_WriteCalculationFile puts "$p1, $p2, $p3, $p4"
                } elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Mohr-Coulomb, stiffness_factor=$valuestiff"
                  GiD_WriteCalculationFile puts "$p1, $p2, $p3, $p4"
                }
              } elseif {$cmodel == "Hypoplastic"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Hypoplasticity_numgeo"
                  GiD_WriteCalculationFile puts "$ph1, $ph2, $ph3, $ph4, $ph5, $ph6, $ph7, $ph8"
                  GiD_WriteCalculationFile puts "$ph9, $ph10, $ph11, $ph12, $ph13, $ph14, $ph15, $ph16"
                }	elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Hypoplasticity_numgeo, stiffness_factor=$valuestiff"
                  GiD_WriteCalculationFile puts "$ph1, $ph2, $ph3, $ph4, $ph5, $ph6, $ph7, $ph8"
                  GiD_WriteCalculationFile puts "$ph9, $ph10, $ph11, $ph12, $ph13, $ph14, $ph15, $ph16"
                }
              } elseif {$cmodel == "Friction less"} {}
            } elseif {$adhesion == "no"} {
              GiD_WriteCalculationFile puts "*Interaction, Name=$conname"
              GiD_WriteCalculationFile puts "*Normal, Mechanical=$con_model, No Separation"
              if {$cmodel == "Coulomb"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Coulomb"
                  GiD_WriteCalculationFile puts "$pc1, $pc2, $pc3"
                } elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Coulomb, stiffness_factor=$valuestiff"
                  GiD_WriteCalculationFile puts "$pc1, $pc2, $pc3"
                }
              } elseif {$cmodel == "Mohr-Coulomb"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Mohr-Coulomb"
                  GiD_WriteCalculationFile puts "$p1, $p2, $p3, $p4"
                } elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Mohr-Coulomb, stiffness_factor=$valuestiff"
                  GiD_WriteCalculationFile puts "$p1, $p2, $p3, $p4"
                }
              } elseif {$cmodel == "Hypoplastic"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Hypoplasticity_numgeo"
                  GiD_WriteCalculationFile puts "$ph1, $ph2, $ph3, $ph4, $ph5, $ph6, $ph7, $ph8"
                  GiD_WriteCalculationFile puts "$ph9, $ph10, $ph11, $ph12, $ph13, $ph14, $ph15, $ph16"
                }	elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Hypoplasticity_numgeo, stiffness_factor=$valuestiff"
                  GiD_WriteCalculationFile puts "$ph1, $ph2, $ph3, $ph4, $ph5, $ph6, $ph7, $ph8"
                  GiD_WriteCalculationFile puts "$ph9, $ph10, $ph11, $ph12, $ph13, $ph14, $ph15, $ph16"
                }
              } elseif {$cmodel == "Friction less"} {}
            }
          } elseif {$penalty_type == "Stiffness factor"} {
            if {$adhesion == "yes"} {
              GiD_WriteCalculationFile puts "*Interaction, Name=$conname"
              GiD_WriteCalculationFile puts "*Normal, Mechanical=$con_model, No Separation, stiffness_factor=$value"
              GiD_WriteCalculationFile puts ", $adhesion_value"
              if {$cmodel == "Coulomb"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Coulomb"
                  GiD_WriteCalculationFile puts "$pc1, $pc2, $pc3"
                } elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Coulomb, stiffness_factor=$valuestiff"
                  GiD_WriteCalculationFile puts "$pc1, $pc2, $pc3"
                }
              } elseif {$cmodel == "Mohr-Coulomb"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Mohr-Coulomb"
                  GiD_WriteCalculationFile puts "$p1, $p2, $p3, $p4"
                } elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Mohr-Coulomb, stiffness_factor=$valuestiff"
                  GiD_WriteCalculationFile puts "$p1, $p2, $p3, $p4"
                }
              } elseif {$cmodel == "Hypoplastic"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Hypoplasticity_numgeo"
                  GiD_WriteCalculationFile puts "$ph1, $ph2, $ph3, $ph4, $ph5, $ph6, $ph7, $ph8"
                  GiD_WriteCalculationFile puts "$ph9, $ph10, $ph11, $ph12, $ph13, $ph14, $ph15, $ph16"
                }	elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Hypoplasticity_numgeo, stiffness_factor=$valuestiff"
                  GiD_WriteCalculationFile puts "$ph1, $ph2, $ph3, $ph4, $ph5, $ph6, $ph7, $ph8"
                  GiD_WriteCalculationFile puts "$ph9, $ph10, $ph11, $ph12, $ph13, $ph14, $ph15, $ph16"
                }
              } elseif {$cmodel == "Friction less"} {}
            } elseif {$adhesion == "no"} {
              GiD_WriteCalculationFile puts "*Interaction, Name=$conname"
              GiD_WriteCalculationFile puts "*Normal, Mechanical=$con_model, No Separation, stiffness_factor=$value"
              if {$cmodel == "Coulomb"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Coulomb"
                  GiD_WriteCalculationFile puts "$pc1, $pc2, $pc3"
                } elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Coulomb, stiffness_factor=$valuestiff"
                  GiD_WriteCalculationFile puts "$pc1, $pc2, $pc3"
                }
              } elseif {$cmodel == "Mohr-Coulomb"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Mohr-Coulomb"
                  GiD_WriteCalculationFile puts "$p1, $p2, $p3, $p4"
                } elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Mohr-Coulomb, stiffness_factor=$valuestiff"
                  GiD_WriteCalculationFile puts "$p1, $p2, $p3, $p4"
                }
              } elseif {$cmodel == "Hypoplastic"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Hypoplasticity_numgeo"
                  GiD_WriteCalculationFile puts "$ph1, $ph2, $ph3, $ph4, $ph5, $ph6, $ph7, $ph8"
                  GiD_WriteCalculationFile puts "$ph9, $ph10, $ph11, $ph12, $ph13, $ph14, $ph15, $ph16"
                }	elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Hypoplasticity_numgeo, stiffness_factor=$valuestiff"
                  GiD_WriteCalculationFile puts "$ph1, $ph2, $ph3, $ph4, $ph5, $ph6, $ph7, $ph8"
                  GiD_WriteCalculationFile puts "$ph9, $ph10, $ph11, $ph12, $ph13, $ph14, $ph15, $ph16"
                }
              } elseif {$cmodel == "Friction less"} {}
            }
          } elseif {$penalty_type == "Constant"} {
            if {$adhesion == "yes"} {
              GiD_WriteCalculationFile puts "*Interaction, Name=$conname"
              GiD_WriteCalculationFile puts "*Normal, Name=$conname, Mechanical=$con_model, No Separation"
              GiD_WriteCalculationFile puts "$value, $adhesion_value"
              if {$cmodel == "Coulomb"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Coulomb"
                  GiD_WriteCalculationFile puts "$pc1, $pc2, $pc3"
                } elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Coulomb, stiffness_factor=$valuestiff"
                  GiD_WriteCalculationFile puts "$pc1, $pc2, $pc3"
                }
              } elseif {$cmodel == "Mohr-Coulomb"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Mohr-Coulomb"
                  GiD_WriteCalculationFile puts "$p1, $p2, $p3, $p4"
                } elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Mohr-Coulomb, stiffness_factor=$valuestiff"
                  GiD_WriteCalculationFile puts "$p1, $p2, $p3, $p4"
                }
              } elseif {$cmodel == "Hypoplastic"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Hypoplasticity_numgeo"
                  GiD_WriteCalculationFile puts "$ph1, $ph2, $ph3, $ph4, $ph5, $ph6, $ph7, $ph8"
                  GiD_WriteCalculationFile puts "$ph9, $ph10, $ph11, $ph12, $ph13, $ph14, $ph15, $ph16"
                }	elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Hypoplasticity_numgeo, stiffness_factor=$valuestiff"
                  GiD_WriteCalculationFile puts "$ph1, $ph2, $ph3, $ph4, $ph5, $ph6, $ph7, $ph8"
                  GiD_WriteCalculationFile puts "$ph9, $ph10, $ph11, $ph12, $ph13, $ph14, $ph15, $ph16"
                }
              } elseif {$cmodel == "Friction less"} {}
            } elseif {$adhesion == "no"} {
              GiD_WriteCalculationFile puts "*Interaction, Name=$conname"
              GiD_WriteCalculationFile puts "*Normal, Name=$conname, Mechanical=$con_model, No Separation"
              GiD_WriteCalculationFile puts "$value"
              if {$cmodel == "Coulomb"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Coulomb"
                  GiD_WriteCalculationFile puts "$pc1, $pc2, $pc3"
                } elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Coulomb, stiffness_factor=$valuestiff"
                  GiD_WriteCalculationFile puts "$pc1, $pc2, $pc3"
                }
              } elseif {$cmodel == "Mohr-Coulomb"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Mohr-Coulomb"
                  GiD_WriteCalculationFile puts "$p1, $p2, $p3, $p4"
                } elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Mohr-Coulomb, stiffness_factor=$valuestiff"
                  GiD_WriteCalculationFile puts "$p1, $p2, $p3, $p4"
                }
              } elseif {$cmodel == "Hypoplastic"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Hypoplasticity_numgeo"
                  GiD_WriteCalculationFile puts "$ph1, $ph2, $ph3, $ph4, $ph5, $ph6, $ph7, $ph8"
                  GiD_WriteCalculationFile puts "$ph9, $ph10, $ph11, $ph12, $ph13, $ph14, $ph15, $ph16"
                }	elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Hypoplasticity_numgeo, stiffness_factor=$valuestiff"
                  GiD_WriteCalculationFile puts "$ph1, $ph2, $ph3, $ph4, $ph5, $ph6, $ph7, $ph8"
                  GiD_WriteCalculationFile puts "$ph9, $ph10, $ph11, $ph12, $ph13, $ph14, $ph15, $ph16"
                }
              } elseif {$cmodel == "Friction less"} {}
            }
          }
        }
      }
    } elseif {$sepration == "yes"} {
      if {$user == "yes"} {
        if {$non_constant == "yes"} {
          if {$penalty_type == "...select..."} {
            if {$adhesion == "yes"} {
              GiD_WriteCalculationFile puts "*Interaction, Name=$conname, user"
              GiD_WriteCalculationFile puts "*Normal, Mechanical=$con_model, non constant"
              GiD_WriteCalculationFile puts ", $adhesion_value"
              if {$cmodel == "Coulomb"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Coulomb"
                } elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Coulomb, stiffness_factor=$valuestiff"
                }
              } elseif {$cmodel == "Mohr-coulomb"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Mohr-Coulomb"
                } elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Mohr-Coulomb, stiffness_factor=$valuestiff"
                }
              } elseif {$cmodel == "Hypoplastic"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Hypoplasticity_numgeo"
                } elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Hypoplasticity_numgeo, stiffness_factor=$valuestiff"
                }
              } elseif {$cmodel == "Friction less"} {}
            } elseif {$adhesion == "no"} {
              GiD_WriteCalculationFile puts "*Interaction, Name=$conname, user"
              GiD_WriteCalculationFile puts "*Normal, Mechanical=$con_model, non constant"
              if {$cmodel == "Coulomb"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Coulomb"
                } elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Coulomb, stiffness_factor=$valuestiff"
                }
              } elseif {$cmodel == "Mohr-coulomb"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Mohr-Coulomb"
                } elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Mohr-Coulomb, stiffness_factor=$valuestiff"
                }
              } elseif {$cmodel == "Hypoplastic"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Hypoplasticity_numgeo"
                } elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Hypoplasticity_numgeo, stiffness_factor=$valuestiff"
                }
              } elseif {$cmodel == "Friction less"} {}
            }
          } elseif {$penalty_type == "Stiffness factor"} {
            if {$adhesion == "yes"} {
              GiD_WriteCalculationFile puts "*Interaction, Name=$conname, user"
              GiD_WriteCalculationFile puts "*Normal, Mechanical=$con_model, stiffness_factor=$value, non constant"
              GiD_WriteCalculationFile puts ", $adhesion_value"
              if {$cmodel == "Coulomb"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Coulomb"
                } elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Coulomb, stiffness_factor=$valuestiff"
                }
              } elseif {$cmodel == "Mohr-coulomb"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Mohr-Coulomb"
                } elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Mohr-Coulomb, stiffness_factor=$valuestiff"
                }
              } elseif {$cmodel == "Hypoplastic"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Hypoplasticity_numgeo"
                } elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Hypoplasticity_numgeo, stiffness_factor=$valuestiff"
                }
              } elseif {$cmodel == "Friction less"} {}
            } elseif {$adhesion == "no"} {
              GiD_WriteCalculationFile puts "*Interaction, Name=$conname, user"
              GiD_WriteCalculationFile puts "*Normal, Mechanical=$con_model, stiffness_factor=$value, non constant"
              if {$cmodel == "Coulomb"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Coulomb"
                } elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Coulomb, stiffness_factor=$valuestiff"
                }
              } elseif {$cmodel == "Mohr-coulomb"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Mohr-Coulomb"
                } elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Mohr-Coulomb, stiffness_factor=$valuestiff"
                }
              } elseif {$cmodel == "Hypoplastic"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Hypoplasticity_numgeo"
                } elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Hypoplasticity_numgeo, stiffness_factor=$valuestiff"
                }
              } elseif {$cmodel == "Friction less"} {}
            }
          } elseif {$penalty_type == "Constant"} {
            if {$adhesion == "yes"} {
              GiD_WriteCalculationFile puts "*Interaction, Name=$conname, user"
              GiD_WriteCalculationFile puts "*Normal, Mechanical=$con_model, non constant"
              GiD_WriteCalculationFile puts ", $adhesion_value"
              if {$cmodel == "Coulomb"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Coulomb"
                } elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Coulomb, stiffness_factor=$valuestiff"
                }
              } elseif {$cmodel == "Mohr-coulomb"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Mohr-Coulomb"
                } elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Mohr-Coulomb, stiffness_factor=$valuestiff"
                }
              } elseif {$cmodel == "Hypoplastic"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Hypoplasticity_numgeo"
                } elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Hypoplasticity_numgeo, stiffness_factor=$valuestiff"
                }
              } elseif {$cmodel == "Friction less"} {}
            } elseif {$adhesion == "no"} {
              GiD_WriteCalculationFile puts "*Interaction, Name=$conname, user"
              GiD_WriteCalculationFile puts "*Normal, Mechanical=$con_model, non constant"
              GiD_WriteCalculationFile puts "$value"
              if {$cmodel == "Coulomb"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Coulomb"
                } elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Coulomb, stiffness_factor=$valuestiff"
                }
              } elseif {$cmodel == "Mohr-coulomb"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Mohr-Coulomb"
                } elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Mohr-Coulomb, stiffness_factor=$valuestiff"
                }
              } elseif {$cmodel == "Hypoplastic"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Hypoplasticity_numgeo"
                } elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Hypoplasticity_numgeo, stiffness_factor=$valuestiff"
                }
              } elseif {$cmodel == "Friction less"} {}
            }
          }
        } elseif {$non_constant == "no"} {
          if {$penalty_type == "...select..."} {
            if {$adhesion == "yes"} {
              GiD_WriteCalculationFile puts "*Interaction, Name=$conname, user"
              GiD_WriteCalculationFile puts "*Normal, Mechanical=$con_model"
        	  GiD_WriteCalculationFile puts ", $adhesion_value"
              if {$cmodel == "Coulomb"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Coulomb"
                } elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Coulomb, stiffness_factor=$valuestiff"
                }
              } elseif {$cmodel == "Mohr-coulomb"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Mohr-Coulomb"
                } elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Mohr-Coulomb, stiffness_factor=$valuestiff"
                }
              } elseif {$cmodel == "Hypoplastic"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Hypoplasticity_numgeo"
                } elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Hypoplasticity_numgeo, stiffness_factor=$valuestiff"
                }
              } elseif {$cmodel == "Friction less"} {}
        	} elseif {$adhesion == "no"} {
              GiD_WriteCalculationFile puts "*Interaction, Name=$conname, user"
              GiD_WriteCalculationFile puts "*Normal, Mechanical=$con_model"
              if {$cmodel == "Coulomb"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Coulomb"
                } elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Coulomb, stiffness_factor=$valuestiff"
                }
              } elseif {$cmodel == "Mohr-coulomb"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Mohr-Coulomb"
                } elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Mohr-Coulomb, stiffness_factor=$valuestiff"
                }
              } elseif {$cmodel == "Hypoplastic"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Hypoplasticity_numgeo"
                } elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Hypoplasticity_numgeo, stiffness_factor=$valuestiff"
                }
              } elseif {$cmodel == "Friction less"} {}
        	}
          } elseif {$penalty_type == "Stiffness factor"} {
            if {$adhesion == "yes"} {
              GiD_WriteCalculationFile puts "*Interaction, Name=$conname, user"
              GiD_WriteCalculationFile puts "*Normal, Mechanical=$con_model, stiffness_factor=$value"
        	  GiD_WriteCalculationFile puts ", $adhesion_value"
              if {$cmodel == "Coulomb"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Coulomb"
                } elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Coulomb, stiffness_factor=$valuestiff"
                }
              } elseif {$cmodel == "Mohr-coulomb"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Mohr-Coulomb"
                } elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Mohr-Coulomb, stiffness_factor=$valuestiff"
                }
              } elseif {$cmodel == "Hypoplastic"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Hypoplasticity_numgeo"
                } elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Hypoplasticity_numgeo, stiffness_factor=$valuestiff"
                }
              } elseif {$cmodel == "Friction less"} {}
        	} elseif {$adhesion == "no"} {
              GiD_WriteCalculationFile puts "*Interaction, Name=$conname, user"
              GiD_WriteCalculationFile puts "*Normal, Mechanical=$con_model, stiffness_factor=$value"
              if {$cmodel == "Coulomb"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Coulomb"
                } elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Coulomb, stiffness_factor=$valuestiff"
                }
              } elseif {$cmodel == "Mohr-coulomb"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Mohr-Coulomb"
                } elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Mohr-Coulomb, stiffness_factor=$valuestiff"
                }
              } elseif {$cmodel == "Hypoplastic"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Hypoplasticity_numgeo"
                } elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Hypoplasticity_numgeo, stiffness_factor=$valuestiff"
                }
              } elseif {$cmodel == "Friction less"} {}
        	}
          } elseif {$penalty_type == "Constant"} {
            if {$adhesion == "yes"} { 
              GiD_WriteCalculationFile puts "*Interaction, Name=$conname, user"
              GiD_WriteCalculationFile puts "*Normal, Name=$conname, Mechanical=$con_model"
              GiD_WriteCalculationFile puts "$value, $adhesion_value"
              if {$cmodel == "Coulomb"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Coulomb"
                } elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Coulomb, stiffness_factor=$valuestiff"
                }
              } elseif {$cmodel == "Mohr-coulomb"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Mohr-Coulomb"
                } elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Mohr-Coulomb, stiffness_factor=$valuestiff"
                }
              } elseif {$cmodel == "Hypoplastic"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Hypoplasticity_numgeo"
                } elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Hypoplasticity_numgeo, stiffness_factor=$valuestiff"
                }
              } elseif {$cmodel == "Friction less"} {}
        	} elseif {$adhesion == "no"} { 
              GiD_WriteCalculationFile puts "*Interaction, Name=$conname, user"
              GiD_WriteCalculationFile puts "*Normal, Name=$conname, Mechanical=$con_model"
              GiD_WriteCalculationFile puts "$value"
              if {$cmodel == "Coulomb"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Coulomb"
                } elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Coulomb, stiffness_factor=$valuestiff"
                }
              } elseif {$cmodel == "Mohr-coulomb"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Mohr-Coulomb"
                } elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Mohr-Coulomb, stiffness_factor=$valuestiff"
                }
              } elseif {$cmodel == "Hypoplastic"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Hypoplasticity_numgeo"
                } elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Hypoplasticity_numgeo, stiffness_factor=$valuestiff"
                }
              } elseif {$cmodel == "Friction less"} {}
        	}
          }
        }
      } elseif {$user == "no"} {
        if {$non_constant == "yes"} {
          if {$penalty_type == "...select..."} {
            if {$adhesion == "yes"} { 
              GiD_WriteCalculationFile puts "*Interaction, Name=$conname"
              GiD_WriteCalculationFile puts "*Normal, Mechanical=$con_model, non constant"
              GiD_WriteCalculationFile puts ", $adhesion_value"
              if {$cmodel == "Coulomb"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Coulomb"
                  GiD_WriteCalculationFile puts "$pc1, $pc2, $pc3"
                } elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Coulomb, stiffness_factor=$valuestiff"
                  GiD_WriteCalculationFile puts "$pc1, $pc2, $pc3"
                }
              } elseif {$cmodel == "Mohr-Coulomb"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Mohr-Coulomb"
                  GiD_WriteCalculationFile puts "$p1, $p2, $p3, $p4"
                } elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Mohr-Coulomb, stiffness_factor=$valuestiff"
                  GiD_WriteCalculationFile puts "$p1, $p2, $p3, $p4"
                }
              } elseif {$cmodel == "Hypoplastic"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Hypoplasticity_numgeo"
                  GiD_WriteCalculationFile puts "$ph1, $ph2, $ph3, $ph4, $ph5, $ph6, $ph7, $ph8"
                  GiD_WriteCalculationFile puts "$ph9, $ph10, $ph11, $ph12, $ph13, $ph14, $ph15, $ph16"
                }	elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Hypoplasticity_numgeo, stiffness_factor=$valuestiff"
                  GiD_WriteCalculationFile puts "$ph1, $ph2, $ph3, $ph4, $ph5, $ph6, $ph7, $ph8"
                  GiD_WriteCalculationFile puts "$ph9, $ph10, $ph11, $ph12, $ph13, $ph14, $ph15, $ph16"
                }
              } elseif {$cmodel == "Friction less"} {}
            } elseif {$adhesion == "no"} { 
              GiD_WriteCalculationFile puts "*Interaction, Name=$conname"
              GiD_WriteCalculationFile puts "*Normal, Mechanical=$con_model, non constant"
              if {$cmodel == "Coulomb"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Coulomb"
                  GiD_WriteCalculationFile puts "$pc1, $pc2, $pc3"
                } elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Coulomb, stiffness_factor=$valuestiff"
                  GiD_WriteCalculationFile puts "$pc1, $pc2, $pc3"
                }
              } elseif {$cmodel == "Mohr-Coulomb"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Mohr-Coulomb"
                  GiD_WriteCalculationFile puts "$p1, $p2, $p3, $p4"
                } elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Mohr-Coulomb, stiffness_factor=$valuestiff"
                  GiD_WriteCalculationFile puts "$p1, $p2, $p3, $p4"
                }
              } elseif {$cmodel == "Hypoplastic"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Hypoplasticity_numgeo"
                  GiD_WriteCalculationFile puts "$ph1, $ph2, $ph3, $ph4, $ph5, $ph6, $ph7, $ph8"
                  GiD_WriteCalculationFile puts "$ph9, $ph10, $ph11, $ph12, $ph13, $ph14, $ph15, $ph16"
                }	elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Hypoplasticity_numgeo, stiffness_factor=$valuestiff"
                  GiD_WriteCalculationFile puts "$ph1, $ph2, $ph3, $ph4, $ph5, $ph6, $ph7, $ph8"
                  GiD_WriteCalculationFile puts "$ph9, $ph10, $ph11, $ph12, $ph13, $ph14, $ph15, $ph16"
                }
              } elseif {$cmodel == "Friction less"} {}
            }
          } elseif {$penalty_type == "Stiffness factor"} {
            if {$adhesion == "yes"} { 
              GiD_WriteCalculationFile puts "*Interaction, Name=$conname"
              GiD_WriteCalculationFile puts "*Normal, Mechanical=$con_model, stiffness_factor=$value, non constant"
              GiD_WriteCalculationFile puts ", $adhesion_value"
              if {$cmodel == "Coulomb"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Coulomb"
                  GiD_WriteCalculationFile puts "$pc1, $pc2, $pc3"
                } elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Coulomb, stiffness_factor=$valuestiff"
                  GiD_WriteCalculationFile puts "$pc1, $pc2, $pc3"
                }
              } elseif {$cmodel == "Mohr-Coulomb"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Mohr-Coulomb"
                  GiD_WriteCalculationFile puts "$p1, $p2, $p3, $p4"
                } elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Mohr-Coulomb, stiffness_factor=$valuestiff"
                  GiD_WriteCalculationFile puts "$p1, $p2, $p3, $p4"
                }
              } elseif {$cmodel == "Hypoplastic"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Hypoplasticity_numgeo"
                  GiD_WriteCalculationFile puts "$ph1, $ph2, $ph3, $ph4, $ph5, $ph6, $ph7, $ph8"
                  GiD_WriteCalculationFile puts "$ph9, $ph10, $ph11, $ph12, $ph13, $ph14, $ph15, $ph16"
                }	elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Hypoplasticity_numgeo, stiffness_factor=$valuestiff"
                  GiD_WriteCalculationFile puts "$ph1, $ph2, $ph3, $ph4, $ph5, $ph6, $ph7, $ph8"
                  GiD_WriteCalculationFile puts "$ph9, $ph10, $ph11, $ph12, $ph13, $ph14, $ph15, $ph16"
                }
              } elseif {$cmodel == "Friction less"} {}
            } elseif {$adhesion == "no"} { 
              GiD_WriteCalculationFile puts "*Interaction, Name=$conname"
              GiD_WriteCalculationFile puts "*Normal, Mechanical=$con_model, stiffness_factor=$value, non constant"
              if {$cmodel == "Coulomb"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Coulomb"
                  GiD_WriteCalculationFile puts "$pc1, $pc2, $pc3"
                } elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Coulomb, stiffness_factor=$valuestiff"
                  GiD_WriteCalculationFile puts "$pc1, $pc2, $pc3"
                }
              } elseif {$cmodel == "Mohr-Coulomb"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Mohr-Coulomb"
                  GiD_WriteCalculationFile puts "$p1, $p2, $p3, $p4"
                } elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Mohr-Coulomb, stiffness_factor=$valuestiff"
                  GiD_WriteCalculationFile puts "$p1, $p2, $p3, $p4"
                }
              } elseif {$cmodel == "Hypoplastic"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Hypoplasticity_numgeo"
                  GiD_WriteCalculationFile puts "$ph1, $ph2, $ph3, $ph4, $ph5, $ph6, $ph7, $ph8"
                  GiD_WriteCalculationFile puts "$ph9, $ph10, $ph11, $ph12, $ph13, $ph14, $ph15, $ph16"
                }	elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Hypoplasticity_numgeo, stiffness_factor=$valuestiff"
                  GiD_WriteCalculationFile puts "$ph1, $ph2, $ph3, $ph4, $ph5, $ph6, $ph7, $ph8"
                  GiD_WriteCalculationFile puts "$ph9, $ph10, $ph11, $ph12, $ph13, $ph14, $ph15, $ph16"
                }
              } elseif {$cmodel == "Friction less"} {}
            }
          } elseif {$penalty_type == "Constant"} {
            if {$adhesion == "yes"} {
              GiD_WriteCalculationFile puts "*Interaction, Name=$conname"
              GiD_WriteCalculationFile puts "*Normal, Mechanical=$con_model, non constant"
              GiD_WriteCalculationFile puts ", $adhesion_value"
              if {$cmodel == "Coulomb"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Coulomb"
                  GiD_WriteCalculationFile puts "$pc1, $pc2, $pc3"
                } elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Coulomb, stiffness_factor=$valuestiff"
                  GiD_WriteCalculationFile puts "$pc1, $pc2, $pc3"
                }
              } elseif {$cmodel == "Mohr-Coulomb"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Mohr-Coulomb"
                  GiD_WriteCalculationFile puts "$p1, $p2, $p3, $p4"
                } elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Mohr-Coulomb, stiffness_factor=$valuestiff"
                  GiD_WriteCalculationFile puts "$p1, $p2, $p3, $p4"
                }
              } elseif {$cmodel == "Hypoplastic"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Hypoplasticity_numgeo"
                  GiD_WriteCalculationFile puts "$ph1, $ph2, $ph3, $ph4, $ph5, $ph6, $ph7, $ph8"
                  GiD_WriteCalculationFile puts "$ph9, $ph10, $ph11, $ph12, $ph13, $ph14, $ph15, $ph16"
                }	elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Hypoplasticity_numgeo, stiffness_factor=$valuestiff"
                  GiD_WriteCalculationFile puts "$ph1, $ph2, $ph3, $ph4, $ph5, $ph6, $ph7, $ph8"
                  GiD_WriteCalculationFile puts "$ph9, $ph10, $ph11, $ph12, $ph13, $ph14, $ph15, $ph16"
                }
              } elseif {$cmodel == "Friction less"} {}
            } elseif {$adhesion == "no"} {
              GiD_WriteCalculationFile puts "*Interaction, Name=$conname"
              GiD_WriteCalculationFile puts "*Normal, Mechanical=$con_model, non constant"
              GiD_WriteCalculationFile puts "$value"
              if {$cmodel == "Coulomb"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Coulomb"
                  GiD_WriteCalculationFile puts "$pc1, $pc2, $pc3"
                } elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Coulomb, stiffness_factor=$valuestiff"
                  GiD_WriteCalculationFile puts "$pc1, $pc2, $pc3"
                }
              } elseif {$cmodel == "Mohr-Coulomb"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Mohr-Coulomb"
                  GiD_WriteCalculationFile puts "$p1, $p2, $p3, $p4"
                } elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Mohr-Coulomb, stiffness_factor=$valuestiff"
                  GiD_WriteCalculationFile puts "$p1, $p2, $p3, $p4"
                }
              } elseif {$cmodel == "Hypoplastic"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Hypoplasticity_numgeo"
                  GiD_WriteCalculationFile puts "$ph1, $ph2, $ph3, $ph4, $ph5, $ph6, $ph7, $ph8"
                  GiD_WriteCalculationFile puts "$ph9, $ph10, $ph11, $ph12, $ph13, $ph14, $ph15, $ph16"
                }	elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Hypoplasticity_numgeo, stiffness_factor=$valuestiff"
                  GiD_WriteCalculationFile puts "$ph1, $ph2, $ph3, $ph4, $ph5, $ph6, $ph7, $ph8"
                  GiD_WriteCalculationFile puts "$ph9, $ph10, $ph11, $ph12, $ph13, $ph14, $ph15, $ph16"
                }
              } elseif {$cmodel == "Friction less"} {}
            }
          }
        } elseif {$non_constant == "no"} {
          if {$penalty_type == "...select..."} {
            if {$adhesion == "yes"} {
              GiD_WriteCalculationFile puts "*Interaction, Name=$conname"
              GiD_WriteCalculationFile puts "*Normal, Mechanical=$con_model"
              GiD_WriteCalculationFile puts ", $adhesion_value"
              if {$cmodel == "Coulomb"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Coulomb"
                  GiD_WriteCalculationFile puts "$pc1, $pc2, $pc3"
                } elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Coulomb, stiffness_factor=$valuestiff"
                  GiD_WriteCalculationFile puts "$pc1, $pc2, $pc3"
                }
              } elseif {$cmodel == "Mohr-Coulomb"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Mohr-Coulomb"
                  GiD_WriteCalculationFile puts "$p1, $p2, $p3, $p4"
                } elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Mohr-Coulomb, stiffness_factor=$valuestiff"
                  GiD_WriteCalculationFile puts "$p1, $p2, $p3, $p4"
                }
              } elseif {$cmodel == "Hypoplastic"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Hypoplasticity_numgeo"
                  GiD_WriteCalculationFile puts "$ph1, $ph2, $ph3, $ph4, $ph5, $ph6, $ph7, $ph8"
                  GiD_WriteCalculationFile puts "$ph9, $ph10, $ph11, $ph12, $ph13, $ph14, $ph15, $ph16"
                }	elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Hypoplasticity_numgeo, stiffness_factor=$valuestiff"
                  GiD_WriteCalculationFile puts "$ph1, $ph2, $ph3, $ph4, $ph5, $ph6, $ph7, $ph8"
                  GiD_WriteCalculationFile puts "$ph9, $ph10, $ph11, $ph12, $ph13, $ph14, $ph15, $ph16"
                }
              } elseif {$cmodel == "Friction less"} {}
            } elseif {$adhesion == "no"} {
              GiD_WriteCalculationFile puts "*Interaction, Name=$conname"
              GiD_WriteCalculationFile puts "*Normal, Mechanical=$con_model"
              if {$cmodel == "Coulomb"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Coulomb"
                  GiD_WriteCalculationFile puts "$pc1, $pc2, $pc3"
                } elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Coulomb, stiffness_factor=$valuestiff"
                  GiD_WriteCalculationFile puts "$pc1, $pc2, $pc3"
                }
              } elseif {$cmodel == "Mohr-Coulomb"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Mohr-Coulomb"
                  GiD_WriteCalculationFile puts "$p1, $p2, $p3, $p4"
                } elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Mohr-Coulomb, stiffness_factor=$valuestiff"
                  GiD_WriteCalculationFile puts "$p1, $p2, $p3, $p4"
                }
              } elseif {$cmodel == "Hypoplastic"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Hypoplasticity_numgeo"
                  GiD_WriteCalculationFile puts "$ph1, $ph2, $ph3, $ph4, $ph5, $ph6, $ph7, $ph8"
                  GiD_WriteCalculationFile puts "$ph9, $ph10, $ph11, $ph12, $ph13, $ph14, $ph15, $ph16"
                }	elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Hypoplasticity_numgeo, stiffness_factor=$valuestiff"
                  GiD_WriteCalculationFile puts "$ph1, $ph2, $ph3, $ph4, $ph5, $ph6, $ph7, $ph8"
                  GiD_WriteCalculationFile puts "$ph9, $ph10, $ph11, $ph12, $ph13, $ph14, $ph15, $ph16"
                }
              } elseif {$cmodel == "Friction less"} {}
            }
          } elseif {$penalty_type == "Stiffness factor"} {
            if {$adhesion == "yes"} {
              GiD_WriteCalculationFile puts "*Interaction, Name=$conname"
              GiD_WriteCalculationFile puts "*Normal, Mechanical=$con_model, stiffness_factor=$value"
              GiD_WriteCalculationFile puts ", $adhesion_value"
              if {$cmodel == "Coulomb"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Coulomb"
                  GiD_WriteCalculationFile puts "$pc1, $pc2, $pc3"
                } elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Coulomb, stiffness_factor=$valuestiff"
                  GiD_WriteCalculationFile puts "$pc1, $pc2, $pc3"
                }
              } elseif {$cmodel == "Mohr-Coulomb"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Mohr-Coulomb"
                  GiD_WriteCalculationFile puts "$p1, $p2, $p3, $p4"
                } elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Mohr-Coulomb, stiffness_factor=$valuestiff"
                  GiD_WriteCalculationFile puts "$p1, $p2, $p3, $p4"
                }
              } elseif {$cmodel == "Hypoplastic"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Hypoplasticity_numgeo"
                  GiD_WriteCalculationFile puts "$ph1, $ph2, $ph3, $ph4, $ph5, $ph6, $ph7, $ph8"
                  GiD_WriteCalculationFile puts "$ph9, $ph10, $ph11, $ph12, $ph13, $ph14, $ph15, $ph16"
                }	elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Hypoplasticity_numgeo, stiffness_factor=$valuestiff"
                  GiD_WriteCalculationFile puts "$ph1, $ph2, $ph3, $ph4, $ph5, $ph6, $ph7, $ph8"
                  GiD_WriteCalculationFile puts "$ph9, $ph10, $ph11, $ph12, $ph13, $ph14, $ph15, $ph16"
                }
              } elseif {$cmodel == "Friction less"} {}
            } elseif {$adhesion == "no"} {
              GiD_WriteCalculationFile puts "*Interaction, Name=$conname"
              GiD_WriteCalculationFile puts "*Normal, Mechanical=$con_model, stiffness_factor=$value"
              if {$cmodel == "Coulomb"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Coulomb"
                  GiD_WriteCalculationFile puts "$pc1, $pc2, $pc3"
                } elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Coulomb, stiffness_factor=$valuestiff"
                  GiD_WriteCalculationFile puts "$pc1, $pc2, $pc3"
                }
              } elseif {$cmodel == "Mohr-Coulomb"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Mohr-Coulomb"
                  GiD_WriteCalculationFile puts "$p1, $p2, $p3, $p4"
                } elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Mohr-Coulomb, stiffness_factor=$valuestiff"
                  GiD_WriteCalculationFile puts "$p1, $p2, $p3, $p4"
                }
              } elseif {$cmodel == "Hypoplastic"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Hypoplasticity_numgeo"
                  GiD_WriteCalculationFile puts "$ph1, $ph2, $ph3, $ph4, $ph5, $ph6, $ph7, $ph8"
                  GiD_WriteCalculationFile puts "$ph9, $ph10, $ph11, $ph12, $ph13, $ph14, $ph15, $ph16"
                }	elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Hypoplasticity_numgeo, stiffness_factor=$valuestiff"
                  GiD_WriteCalculationFile puts "$ph1, $ph2, $ph3, $ph4, $ph5, $ph6, $ph7, $ph8"
                  GiD_WriteCalculationFile puts "$ph9, $ph10, $ph11, $ph12, $ph13, $ph14, $ph15, $ph16"
                }
              } elseif {$cmodel == "Friction less"} {}
            }
          } elseif {$penalty_type == "Constant"} {
            if {$adhesion == "yes"} {
              GiD_WriteCalculationFile puts "*Interaction, Name=$conname"
              GiD_WriteCalculationFile puts "*Normal, Mechanical=$con_model"
              GiD_WriteCalculationFile puts "$value, $adhesion_value"
              if {$cmodel == "Coulomb"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Coulomb"
                  GiD_WriteCalculationFile puts "$pc1, $pc2, $pc3"
                } elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Coulomb, stiffness_factor=$valuestiff"
                  GiD_WriteCalculationFile puts "$pc1, $pc2, $pc3"
                }
              } elseif {$cmodel == "Mohr-Coulomb"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Mohr-Coulomb"
                  GiD_WriteCalculationFile puts "$p1, $p2, $p3, $p4"
                } elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Mohr-Coulomb, stiffness_factor=$valuestiff"
                  GiD_WriteCalculationFile puts "$p1, $p2, $p3, $p4"
                }
              } elseif {$cmodel == "Hypoplastic"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Hypoplasticity_numgeo"
                  GiD_WriteCalculationFile puts "$ph1, $ph2, $ph3, $ph4, $ph5, $ph6, $ph7, $ph8"
                  GiD_WriteCalculationFile puts "$ph9, $ph10, $ph11, $ph12, $ph13, $ph14, $ph15, $ph16"
                }	elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Hypoplasticity_numgeo, stiffness_factor=$valuestiff"
                  GiD_WriteCalculationFile puts "$ph1, $ph2, $ph3, $ph4, $ph5, $ph6, $ph7, $ph8"
                  GiD_WriteCalculationFile puts "$ph9, $ph10, $ph11, $ph12, $ph13, $ph14, $ph15, $ph16"
                }
              } elseif {$cmodel == "Friction less"} {}
            } elseif {$adhesion == "no"} {
              GiD_WriteCalculationFile puts "*Interaction, Name=$conname"
              GiD_WriteCalculationFile puts "*Normal, Mechanical=$con_model"
              if {$cmodel == "Coulomb"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Coulomb"
                  GiD_WriteCalculationFile puts "$pc1, $pc2, $pc3"
                } elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Coulomb, stiffness_factor=$valuestiff"
                  GiD_WriteCalculationFile puts "$pc1, $pc2, $pc3"
                }
              } elseif {$cmodel == "Mohr-Coulomb"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Mohr-Coulomb"
                  GiD_WriteCalculationFile puts "$p1, $p2, $p3, $p4"
                } elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Mohr-Coulomb, stiffness_factor=$valuestiff"
                  GiD_WriteCalculationFile puts "$p1, $p2, $p3, $p4"
                }
              } elseif {$cmodel == "Hypoplastic"} {
                if {$tanstiffness == "no"} {
                  GiD_WriteCalculationFile puts "*friction, model=Hypoplasticity_numgeo"
                  GiD_WriteCalculationFile puts "$ph1, $ph2, $ph3, $ph4, $ph5, $ph6, $ph7, $ph8"
                  GiD_WriteCalculationFile puts "$ph9, $ph10, $ph11, $ph12, $ph13, $ph14, $ph15, $ph16"
                }	elseif {$tanstiffness == "yes"} {
                  GiD_WriteCalculationFile puts "*friction, model=Hypoplasticity_numgeo, stiffness_factor=$valuestiff"
                  GiD_WriteCalculationFile puts "$ph1, $ph2, $ph3, $ph4, $ph5, $ph6, $ph7, $ph8"
                  GiD_WriteCalculationFile puts "$ph9, $ph10, $ph11, $ph12, $ph13, $ph14, $ph15, $ph16"
                }
              } elseif {$cmodel == "Friction less"} {}
            }
          }
        }
      }
    }
    # contact pairs
    set node [$icon selectNodes [format_xpath {value[@n="_Dis_"]}]]
    set dis [$node getAttribute "v"]
    GiD_WriteCalculationFile puts "*Contact pair, Interaction=$conname, Discretisation=$dis"
    foreach groupList $groupLists {
      set groups [$groupList selectNodes "./group"]
      if {[llength $groups] >= 2} {
        set names {}
        foreach group $groups {
          set name [get_domnode_attribute $group n]
          lappend names $name
        }
        set master_set [lindex $names 0]
        set slave_set [lindex $names 1]
        GiD_WriteCalculationFile puts "$slave_set, $master_set"
      }
    }
    # Contact options (write once)
    customlib::WriteString "** Contact options"
    set node [$icon selectNodes [format_xpath {container[@n="_contact_options_"]/value[@n="_Contact_option_"]}]]
    set contact_option [$node getAttribute "v"]
    if {$contact_option == "Yes"} {
      set node [$icon selectNodes [format_xpath {container[@n="_contact_options_"]/value[@n="_Clearance_"]}]]
      set Clearance [$node getAttribute "v"]
      set node [$icon selectNodes [format_xpath {container[@n="_contact_options_"]/value[@n="_checkdisp_checkdist_"]}]]
      set check_disp_dist [$node getAttribute "v"]
      set node [$icon selectNodes [format_xpath {container[@n="_contact_options_"]/value[@n="_reduction_"]}]]
      set reduction [$node getAttribute "v"]
      if {$reduction == "yes"} {
        if {$check_disp_dist == "Yes"} {
          set node [$icon selectNodes [format_xpath {container[@n="_contact_options_"]/value[@n="_Check_disp_"]}]]
          set check_disp [$node getAttribute "v"]
          set node [$icon selectNodes [format_xpath {container[@n="_contact_options_"]/value[@n="_Check_dist_"]}]]
          set check_dist [$node getAttribute "v"]
          GiD_WriteCalculationFile puts "*Contact options, name=$conname, Clearance=$Clearance, Check Disp=$check_disp, Check Dist=$check_dist, reduction"
        } elseif {$check_disp_dist == "No"} {
          GiD_WriteCalculationFile puts "*Contact options, name=$conname, Clearance=$Clearance, reduction"
        }
      } elseif {$reduction == "no"} {
        if {$check_disp_dist == "Yes"} {
          set node [$icon selectNodes [format_xpath {container[@n="_contact_options_"]/value[@n="_Check_disp_"]}]]
          set check_disp [$node getAttribute "v"]
          set node [$icon selectNodes [format_xpath {container[@n="_contact_options_"]/value[@n="_Check_dist_"]}]]
          set check_dist [$node getAttribute "v"]
          GiD_WriteCalculationFile puts "*Contact options, name=$conname, Clearance=$Clearance, Check Disp=$check_disp, Check Dist=$check_dist"
        } else {
          GiD_WriteCalculationFile puts "*Contact options, name=$conname, Clearance=$Clearance"
        }
      }
    }
  }
  customlib::WriteString ""
	
  #
  # Initial-conditions
  # 
  customlib::WriteString "**"
  customlib::WriteString "** Initial Conditions"
  customlib::WriteString "**"
  #Initial void ratio
  set xp [format_xpath {container[@n="_initial_conditions_"]/container[@n="_initial_void_c"]/blockdata[@n="_initial_void_"]/condition[@n="_ini_void_"]}]
  set list [$root selectNodes $xp]
  set wrote_initial_void 0
  if {[llength $list] > 0} {
    foreach ivoid $list {
      set xp "./group"
      set groups [$ivoid selectNodes $xp]
      foreach group $groups {
        set group_name [get_domnode_attribute $group n]
        set node [$group selectNodes [format_xpath {value[@n="_vo_1_"]}]]
        set vr1 [$node getAttribute "v"]
        if {[string length $vr1] > 0} {
          if {$wrote_initial_void == 0} {
            GiD_WriteCalculationFile puts "*initial conditions, type=void ratio, default"
            set wrote_initial_void 1
          }
            GiD_WriteCalculationFile puts "$group_name, $vr1"
        }
      }
    }
  } else {}
  #initial stess
  set xp [format_xpath {container[@n="_initial_conditions_"]/container[@n="_initial_stress_c"]/blockdata[@n="_initial_stress_"]/condition[@n="_ini_stress_"]}]
  set list [$root selectNodes $xp]
  set wrote_initial_stress 0
  if {[llength $list] > 0} {
    foreach istress $list {
      set xp "./group"
      set groups [$istress selectNodes $xp]
      foreach group $groups {
        set group_name [get_domnode_attribute $group n]
        set node [$group selectNodes [format_xpath {value[@n="_str0_"]}]]
        set vs0 [$node getAttribute "v"]
        if {$vs0 == "geostatic"} {
          if {$wrote_initial_stress == 0} {
            GiD_WriteCalculationFile puts "*initial conditions, type=stress, geostatic"
            set wrote_initial_stress 1
          }
          set node [$group selectNodes [format_xpath {value[@n="_str1_"]}]]
          set vs1 [$node getAttribute "v"]
          set node [$group selectNodes [format_xpath {value[@n="_str2_"]}]]
          set vs2 [$node getAttribute "v"]
          set node [$group selectNodes [format_xpath {value[@n="_str3_"]}]]
          set vs3 [$node getAttribute "v"]
          set node [$group selectNodes [format_xpath {value[@n="_str4_"]}]]
          set vs4 [$node getAttribute "v"]
          set node [$group selectNodes [format_xpath {value[@n="_str5_"]}]]
          set vs5 [$node getAttribute "v"]
          set node [$group selectNodes [format_xpath {value[@n="_str6_"]}]]
          set vs6 [$node getAttribute "v"]
          GiD_WriteCalculationFile puts "$group_name, $vs1, $vs2, $vs3, $vs4, $vs5, $vs6"
        } elseif {$vs0 == "full"} {
          if {$wrote_initial_stress == 0} {
            GiD_WriteCalculationFile puts "*initial conditions, type=stress, full"
            set wrote_initial_stress 1
          }
          set node [$group selectNodes [format_xpath {value[@n="_str7_"]}]]
          set vs1 [$node getAttribute "v"]
          set node [$group selectNodes [format_xpath {value[@n="_str8_"]}]]
          set vs2 [$node getAttribute "v"]
          set node [$group selectNodes [format_xpath {value[@n="_str9_"]}]]
          set vs3 [$node getAttribute "v"]
          set node [$group selectNodes [format_xpath {value[@n="_str10_"]}]]
          set vs4 [$node getAttribute "v"]
          set node [$group selectNodes [format_xpath {value[@n="_str11_"]}]]
          set vs5 [$node getAttribute "v"]
          set node [$group selectNodes [format_xpath {value[@n="_str12_"]}]]
          set vs6 [$node getAttribute "v"]
          GiD_WriteCalculationFile puts "$group_name, $vs1, $vs2, $vs3, $vs4, $vs5, $vs6"
        } elseif {$vs0 == "user"} {
          if {$wrote_initial_stress == 0} {
            GiD_WriteCalculationFile puts "*initial conditions, type=stress, user"
            set wrote_initial_stress 1
          }
        }
      }
    }
  } else {}
  #pore water pressure
  set xp [format_xpath {container[@n="_initial_conditions_"]/container[@n="_pore_water_c"]/blockdata[@n="_pore_water_pressure_"]/condition[@n="_po_water_"]}]
  set list [$root selectNodes $xp]
  set wrote_initial_pore_wa 0
  if {[llength $list] > 0} {
    foreach powa $list {
      set xp "./group"
      set groups [$powa selectNodes $xp]
      foreach group $groups {
        set group_name [get_domnode_attribute $group n]
        set node [$group selectNodes [format_xpath {value[@n="_pwp1_"]}]]
        set pw1 [$node getAttribute "v"]
        set node [$group selectNodes [format_xpath {value[@n="_pwp2_"]}]]
        set pw2 [$node getAttribute "v"]
        set node [$group selectNodes [format_xpath {value[@n="_pwp3_"]}]]
        set pw3 [$node getAttribute "v"]
        set node [$group selectNodes [format_xpath {value[@n="_pwp4_"]}]]
        set pw4 [$node getAttribute "v"]
        if {[string length $pw1] > 0} {
          if {[string length $pw2] > 0} {
            if {$wrote_initial_pore_wa == 0} {
              GiD_WriteCalculationFile puts "*initial conditions, type=pore water pressure, default"
              set wrote_initial_pore_wa 1
            }
            GiD_WriteCalculationFile puts "$group_name, $pw1, $pw2, $pw3, $pw4"
          }
        }
      }
    }
  } else {}
  #pore air pressure
  set xp [format_xpath {container[@n="_initial_conditions_"]/container[@n="_pore_air_c"]/blockdata[@n="_pore_air_pressure_"]/condition[@n="_po_air_"]}]
  set list [$root selectNodes $xp]
  set wrote_initial_pore_air 0
  if {[llength $list] > 0} {
    foreach powa $list {
      set xp "./group"
      set groups [$powa selectNodes $xp]
      foreach group $groups {
        set group_name [get_domnode_attribute $group n]
        set node [$group selectNodes [format_xpath {value[@n="_pap1_"]}]]
        set pa1 [$node getAttribute "v"]
        set node [$group selectNodes [format_xpath {value[@n="_pap2_"]}]]
        set pa2 [$node getAttribute "v"]
        set node [$group selectNodes [format_xpath {value[@n="_pap3_"]}]]
        set pa3 [$node getAttribute "v"]
        set node [$group selectNodes [format_xpath {value[@n="_pap4_"]}]]
        set pa4 [$node getAttribute "v"]
        if {[string length $pa1] > 0} {
          if {[string length $pa2] > 0} {
            if {$wrote_initial_pore_air == 0} {
              GiD_WriteCalculationFile puts "*initial conditions, type=pore air pressure, default"
              set wrote_initial_pore_air 1
            }
            GiD_WriteCalculationFile puts "$group_name, $pa1, $pa2, $pa3, $pa4"
          }
        }
      }
    }
  } else {}
  # State Variables
  set xp [format_xpath {container[@n="_initial_conditions_"]/container[@n="_state_var_"]/blockdata[@n="_state_variable_"]}]
  set list [$root selectNodes $xp]
  # Initialize flags for write-once sections
  set default_written 0
  set user_written 0
  set fluctuation_written 0
  foreach stvar $list {
    set xp "./condition\[@n='_sta_var_'\]/group"
    set groups [$stvar selectNodes $xp]
    foreach group $groups {
      set group_name [get_domnode_attribute $group n]
      set node [$group selectNodes [format_xpath {value[@n="_stv1_"]}]]
      set stva1 [$node getAttribute "v"]
      set node [$group selectNodes [format_xpath {value[@n="_stv2_"]}]]
      set stva2 [$node getAttribute "v"]
      set node [$group selectNodes [format_xpath {value[@n="_stv3_"]}]]
      set stva3 [$node getAttribute "v"]
      set node [$group selectNodes [format_xpath {value[@n="_stv4_"]}]]
      set stva4 [$node getAttribute "v"]
      set node [$group selectNodes [format_xpath {value[@n="_stv5_"]}]]
      set stva5 [$node getAttribute "v"]
      set node [$group selectNodes [format_xpath {value[@n="_stv6_"]}]]
      set stva6 [$node getAttribute "v"]
      set node [$group selectNodes [format_xpath {value[@n="_stv7_"]}]]
      set stva7 [$node getAttribute "v"]
      set node [$group selectNodes [format_xpath {value[@n="_stv8_"]}]]
      set stva8 [$node getAttribute "v"]
      # Only write if the state variable name (_stv2_) is present
      if {[llength $stva2] > 0} {
        if {$stva1 eq "default"} {
          if {!$default_written} {
            GiD_WriteCalculationFile puts "*initial conditions, type=state variables"
            set default_written 1
          }
          GiD_WriteCalculationFile puts "$group_name, $stva2, $stva3"
        } elseif {$stva1 eq "user"} {
          if {!$user_written} {
            GiD_WriteCalculationFile puts "*initial conditions, type=state variables, user"
            set user_written 1
          }
          GiD_WriteCalculationFile puts "$group_name"
        } elseif {$stva1 eq "fluctuation"} {
          if {!$fluctuation_written} {
            GiD_WriteCalculationFile puts "*initial conditions, type=state variables, fluctuation"
            set fluctuation_written 1
          }
          GiD_WriteCalculationFile puts "$group_name, $stva2, $stva4, $stva5, $stva6"
        } elseif {$stva1 eq "spatial data"} {
          # Always write the spatial data header each time, with the current $stva7
          GiD_WriteCalculationFile puts "*initial conditions, type=state variables, $stva7"
          GiD_WriteCalculationFile puts "$group_name, $stva2, $stva8.txt"
        }
      }
    }
  }
  customlib::WriteString ""

  #
  # Steps
  # 
  
  # create a list of steps
  set xp [format_xpath {container[@n="_steps_"]/blockdata}]
  set list [$root selectNodes $xp]
  # loop over all steps
  set step_num 0
  foreach istep $list {
    set step_num [expr $step_num + 1]
    customlib::WriteString "**"
    GiD_WriteCalculationFile puts "** Step $step_num"
    customlib::WriteString "**"
	
    # skip Step
    set node [$istep selectNodes [format_xpath {value[@n="_skip_"]}]]
    set skipstep [$node getAttribute "v"]
    if {$skipstep == "Yes"} {
      # material name and number of phases
      set stepname [$istep getAttribute "name"]
      set node [$istep selectNodes [format_xpath {container[@n="_solution_settings_"]/value[@n="_maxiter_"]}]]
      set maxiter [$node getAttribute "v"]
      set node [$istep selectNodes [format_xpath {container[@n="_solution_settings_"]/value[@n="_miniter_"]}]]
      set miniter [$node getAttribute "v"]
      set node [$istep selectNodes [format_xpath {container[@n="_solution_settings_"]/value[@n="_maxinc_"]}]]
      set maxinc [$node getAttribute "v"]
      set node [$istep selectNodes [format_xpath {container[@n="_solution_settings_"]/value[@n="_cutback_"]}]]
      set cutback [$node getAttribute "v"]
      set node [$istep selectNodes [format_xpath {value[@n="_nlgeom_"]}]]
      set nlgeom [$node getAttribute "v"]
      if {$nlgeom == "Yes"} {
        if {$cutback == "No"} {
          GiD_WriteCalculationFile puts "*Step, name=$stepname, inc=$maxinc, maxiter=$maxiter, miniter=$miniter, nlgeom"
        } elseif {$cutback == "Yes"} {
          GiD_WriteCalculationFile puts "*Step, name=$stepname, inc=$maxinc, maxiter=$maxiter, miniter=$miniter, nlgeom, no cutback"
        }
      } elseif {$nlgeom == "No"} {
        if {$cutback == "No"} {
          GiD_WriteCalculationFile puts "*Step, name=$stepname, inc=$maxinc, maxiter=$maxiter, miniter=$miniter"
        } elseif {$cutback == "Yes"} {
          GiD_WriteCalculationFile puts "*Step, name=$stepname, inc=$maxinc, maxiter=$maxiter, miniter=$miniter, no cutback"
        }
      }

      #
      # Analysis type: Static, Transient, Dynamic
      #
      
      set node [$istep selectNodes [format_xpath {value[@n="_analysis_"]}]]
      set analysis [$node getAttribute "v"]
      GiD_WriteCalculationFile puts "*$analysis"
      
      #
      # Time integration settings
      #
      if {$analysis == "Geostatic"} {
      } elseif {$analysis == "Reduction"} {
        set node [$istep selectNodes [format_xpath {container[@n="_factor_of_saftey_"]/value[@n="_Fos_"]}]]
        set p5 [$node getAttribute "v"]
        set node [$istep selectNodes [format_xpath {container[@n="_factor_of_saftey_"]/value[@n="_dFos_"]}]]
        set p6 [$node getAttribute "v"]
        set node [$istep selectNodes [format_xpath {container[@n="_factor_of_saftey_"]/value[@n="_maxdFos_"]}]]
        set p7 [$node getAttribute "v"]
        set node [$istep selectNodes [format_xpath {container[@n="_factor_of_saftey_"]/value[@n="_mindFos_"]}]]
        set p8 [$node getAttribute "v"]
        GiD_WriteCalculationFile puts "$p5, $p6, $p7, $p8"
      } else {
        set node [$istep selectNodes [format_xpath {container[@n="_time_integration_"]/value[@n="_dt0_"]}]]
        set p1 [$node getAttribute "v"]
        set node [$istep selectNodes [format_xpath {container[@n="_time_integration_"]/value[@n="_t_"]}]]
        set p2 [$node getAttribute "v"]
        set node [$istep selectNodes [format_xpath {container[@n="_time_integration_"]/value[@n="_dtmin_"]}]]
        set p3 [$node getAttribute "v"]
        set node [$istep selectNodes [format_xpath {container[@n="_time_integration_"]/value[@n="_dtmax_"]}]]
        set p4 [$node getAttribute "v"]
        GiD_WriteCalculationFile puts "$p1, $p2, $p3, $p4"
        if {$analysis == "Dynamic"} {
          set node [$istep selectNodes [format_xpath {container[@n="_time_integration_"]/value[@n="_time_integration_scheme_"]}]]
          set p1 [$node getAttribute "v"]
          if {$p1 == "Backward Euler"} {
            GiD_WriteCalculationFile puts "*$p1"
          } elseif {$p1 == "Hilber-Hughes-Taylor"} {
            set node [$istep selectNodes [format_xpath {container[@n="_time_integration_"]/value[@n="_hht_alpha_"]}]]
            set p2 [$node getAttribute "v"]
            GiD_WriteCalculationFile puts "*$p1, alpha=$p2"
          }
        }
      }

      #
      # Solution settings
      #
      
      # Solver
      set node [$istep selectNodes [format_xpath {container[@n="_solution_settings_"]/value[@n="_solver_"]}]]
      set solver [$node getAttribute "v"]
      GiD_WriteCalculationFile puts "*Solver, $solver"
      
      # Extrapolation
      set node [$istep selectNodes [format_xpath {container[@n="_solution_settings_"]/value[@n="_extrapolation_"]}]]
      set extra_p [$node getAttribute "v"]
      if {$extra_p != "default"} {
        GiD_WriteCalculationFile puts "*Extrapolation, $extra_p"
      }
  
      # Controls - Displacement
      set node [$istep selectNodes [format_xpath {container[@n="_solution_settings_"]/container[@n="_controls_"]/container[@n="_disp_"]/value[@n="_status_"]}]]
      set status [$node getAttribute "v"]
      if {$status == "Deactivate"} {
        GiD_WriteCalculationFile puts ""
        GiD_WriteCalculationFile puts "*Controls, u, deactivate"
      } elseif {$status == "Modify"} {
        set node [$istep selectNodes [format_xpath {container[@n="_solution_settings_"]/container[@n="_controls_"]/container[@n="_disp_"]/value[@n="_eps1_"]}]]
        set eps1 [$node getAttribute "v"]
        set node [$istep selectNodes [format_xpath {container[@n="_solution_settings_"]/container[@n="_controls_"]/container[@n="_disp_"]/value[@n="_eps2_"]}]]
        set eps2 [$node getAttribute "v"]
        set node [$istep selectNodes [format_xpath {container[@n="_solution_settings_"]/container[@n="_controls_"]/container[@n="_disp_"]/value[@n="_eps3_"]}]]
        set eps3 [$node getAttribute "v"]
        set node [$istep selectNodes [format_xpath {container[@n="_solution_settings_"]/container[@n="_controls_"]/container[@n="_disp_"]/value[@n="_zero1_"]}]]
        set zero1 [$node getAttribute "v"]
        set node [$istep selectNodes [format_xpath {container[@n="_solution_settings_"]/container[@n="_controls_"]/container[@n="_disp_"]/value[@n="_zero2_"]}]]
        set zero2 [$node getAttribute "v"]
        set node [$istep selectNodes [format_xpath {container[@n="_solution_settings_"]/container[@n="_controls_"]/container[@n="_disp_"]/value[@n="_relax_"]}]]
        set relax [$node getAttribute "v"]
        GiD_WriteCalculationFile puts ""
        GiD_WriteCalculationFile puts "*Controls, u, modify"
        GiD_WriteCalculationFile puts "$eps1, $eps2, $eps3, $zero1, $zero2, $relax"
      }
	  
	  # Controls - Pore water pressure
      set node [$istep selectNodes [format_xpath {container[@n="_solution_settings_"]/container[@n="_controls_"]/container[@n="_pw_control_"]/value[@n="_p_status_"]}]]
      set status [$node getAttribute "v"]
      if {$status == "Deactivate"} {
        GiD_WriteCalculationFile puts ""
        GiD_WriteCalculationFile puts "*Controls, pw, deactivate"
      } elseif {$status == "Modify"} {
        set node [$istep selectNodes [format_xpath {container[@n="_solution_settings_"]/container[@n="_controls_"]/container[@n="_pw_control_"]/value[@n="_pw_eps1_"]}]]
        set eps1 [$node getAttribute "v"]
        set node [$istep selectNodes [format_xpath {container[@n="_solution_settings_"]/container[@n="_controls_"]/container[@n="_pw_control_"]/value[@n="_pw_eps2_"]}]]
        set eps2 [$node getAttribute "v"]
        set node [$istep selectNodes [format_xpath {container[@n="_solution_settings_"]/container[@n="_controls_"]/container[@n="_pw_control_"]/value[@n="_pw_eps3_"]}]]
        set eps3 [$node getAttribute "v"]
        set node [$istep selectNodes [format_xpath {container[@n="_solution_settings_"]/container[@n="_controls_"]/container[@n="_pw_control_"]/value[@n="_pw_zero1_"]}]]
        set zero1 [$node getAttribute "v"]
        set node [$istep selectNodes [format_xpath {container[@n="_solution_settings_"]/container[@n="_controls_"]/container[@n="_pw_control_"]/value[@n="_pw_zero2_"]}]]
        set zero2 [$node getAttribute "v"]
        set node [$istep selectNodes [format_xpath {container[@n="_solution_settings_"]/container[@n="_controls_"]/container[@n="_pw_control_"]/value[@n="_pw_relax_"]}]]
        set relax [$node getAttribute "v"]
        GiD_WriteCalculationFile puts ""
        GiD_WriteCalculationFile puts "*Controls, pw, modify"
        GiD_WriteCalculationFile puts "$eps1, $eps2, $eps3, $zero1, $zero2, $relax"
      }
  
      # Accelators
      set node [$istep selectNodes [format_xpath {container[@n="_solution_settings_"]/container[@n="_accelerators_"]/value[@n="_method_"]}]]
      set method [$node getAttribute "v"]
      if {$method == "Relaxation"} {
        set node [$istep selectNodes [format_xpath {container[@n="_solution_settings_"]/container[@n="_accelerators_"]/value[@n="_Relax_lambda_"]}]]
        set Relax1 [$node getAttribute "v"]
        GiD_WriteCalculationFile puts ""
        GiD_WriteCalculationFile puts "*Accelerator, type = Relaxation"
        GiD_WriteCalculationFile puts "$Relax1"
      } elseif {$method == "Back-looking"} {
        set node [$istep selectNodes [format_xpath {container[@n="_solution_settings_"]/container[@n="_accelerators_"]/value[@n="_BL_lambda_min_"]}]]
        set BL1 [$node getAttribute "v"]
        set node [$istep selectNodes [format_xpath {container[@n="_solution_settings_"]/container[@n="_accelerators_"]/value[@n="_BL_lambda_max_"]}]]
        set BL2 [$node getAttribute "v"]
        GiD_WriteCalculationFile puts ""
        GiD_WriteCalculationFile puts "*Accelerator, type = Back-looking"
        GiD_WriteCalculationFile puts "$BL1, $BL2"
      } elseif {$method == "Linear"} {
        set node [$istep selectNodes [format_xpath {container[@n="_solution_settings_"]/container[@n="_accelerators_"]/value[@n="_L_lambda_min_"]}]]
        set L1 [$node getAttribute "v"]
        set node [$istep selectNodes [format_xpath {container[@n="_solution_settings_"]/container[@n="_accelerators_"]/value[@n="_L_lambda_max_"]}]]
        set L2 [$node getAttribute "v"]
        GiD_WriteCalculationFile puts ""
        GiD_WriteCalculationFile puts "*Accelerator, type = Linear"
        GiD_WriteCalculationFile puts "$L1, $L2"
      } elseif {$method == "Anderson"} {
        set node [$istep selectNodes [format_xpath {container[@n="_solution_settings_"]/container[@n="_accelerators_"]/value[@n="_And_alpha_"]}]]
        set A1 [$node getAttribute "v"]
        set node [$istep selectNodes [format_xpath {container[@n="_solution_settings_"]/container[@n="_accelerators_"]/value[@n="_And_depth_"]}]]
        set A2 [$node getAttribute "v"]
        GiD_WriteCalculationFile puts ""
        GiD_WriteCalculationFile puts "*Accelerator, type = Anderson"
        GiD_WriteCalculationFile puts "$A1, $A2"
      }
      
      #
      # Reset
      #
      set node [$istep selectNodes [format_xpath {container[@n="_reset_"]/value[@n="_rest_"]}]]
      set re0 [$node getAttribute "v"]
      set node [$istep selectNodes [format_xpath {container[@n="_reset_"]/value[@n="_rest1_"]}]]
      set re1 [get_domnode_attribute $node v] 
      set node [$istep selectNodes [format_xpath {container[@n="_reset_"]/value[@n="_rest2_"]}]]
      set re2 [get_domnode_attribute $node v] 
      set node [$istep selectNodes [format_xpath {container[@n="_reset_"]/value[@n="_rest3_"]}]]
      set re3 [get_domnode_attribute $node v]
      set node [$istep selectNodes [format_xpath {container[@n="_reset_"]/value[@n="_rest4_"]}]]
      set re4 [get_domnode_attribute $node v]
      if {$re0=="Yes"} {
        GiD_WriteCalculationFile puts "*Reset"
        if {$re1 == "Yes"} {append _reset_list_ "Displacement, "}
        if {$re2 == "Yes"} {append _reset_list_ "Strain, "}
        if {$re3 == "Yes"} {append _reset_list_ "Stress, "}
        if {$re4 == "Yes"} {append _reset_list_ "Void ratio, "}
        # Write calculation file if there are terms to output
        if {[string length $_reset_list_] > 0} {
          GiD_WriteCalculationFile puts "$_reset_list_"
        }
        unset _reset_list_
      } else {}
      
      #
      # Direct Boundary conditions applied to the solid phase
      #
      
      set xp "./container\[@n='_boundary_conditions_'\]/container\[@n='_direct_BC_'\]/condition\[@n='_solid_'\]/group"
      set groups [$istep selectNodes $xp]
      foreach group $groups {
        set group_name [get_domnode_attribute $group n]
        set node [$group selectNodes "./value\[@n = '_scalar_linear_'\]"]
        set scale_type [get_domnode_attribute $node v]
        set node [$group selectNodes "./value\[@n = '_constant_'\]"]
        set cons [get_domnode_attribute $node v]
        if {$cons == "Yes"} {
          if  {$scale_type == "Scalar"} {
          set node [$group selectNodes "./value\[@n = '_type_'\]"]
          set bc_type [get_domnode_attribute $node v]
            if {$bc_type == "displacement"} {
              GiD_WriteCalculationFile puts "*Boundary"
            } else {
              GiD_WriteCalculationFile puts "*Boundary, $bc_type"
            }
            set node [$group selectNodes "./value\[@n = '_x_'\]"]
            set bc_magnitudex [get_domnode_attribute $node v]
            if {$bc_magnitudex == "free"} {
            } elseif {$bc_magnitudex == "fixed"} {
              GiD_WriteCalculationFile puts "$group_name, u1, 0"
            } else {
              set node [$group selectNodes "./value\[@n = '_xp_'\]"]
              set bc_magnitudexp [get_domnode_attribute $node v]
              GiD_WriteCalculationFile puts "$group_name, u1, $bc_magnitudexp"
            }
            set node [$group selectNodes "./value\[@n = '_y_'\]"]
            set bc_magnitudey [get_domnode_attribute $node v]
            if {$bc_magnitudey == "free"} {
            } elseif {$bc_magnitudey == "fixed"} {
              GiD_WriteCalculationFile puts "$group_name, u2, 0"
            } else {
              set node [$group selectNodes "./value\[@n = '_yp_'\]"]
              set bc_magnitudeyp [get_domnode_attribute $node v]
              GiD_WriteCalculationFile puts "$group_name, u2, $bc_magnitudeyp"
            }
            set node [$group selectNodes "./value\[@n = '_z_'\]"]
            set bc_magnitudez [get_domnode_attribute $node v]
            if {$bc_magnitudez == "free"} {
            } elseif {$bc_magnitudez == "fixed"} {
              GiD_WriteCalculationFile puts "$group_name, u3, 0"
            } else {
              set node [$group selectNodes "./value\[@n = '_zp_'\]"]
              set bc_magnitudezp [get_domnode_attribute $node v]
              GiD_WriteCalculationFile puts "$group_name, u3, $bc_magnitudezp"
            }			
          } elseif {$scale_type == "Linear distribution"} {
            set node [$group selectNodes "./value\[@n = '_type_'\]"]
            set bc_type [get_domnode_attribute $node v]
            if {$bc_type == "displacement"} {
              GiD_WriteCalculationFile puts "*Boundary, type=hydrostatic"
            } else {
              GiD_WriteCalculationFile puts "*Boundary, $bc_type, type=hydrostatic"
            }
            set node [$group selectNodes "./value\[@n = '_dirct_'\]"]
            set dirc [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_value_'\]"]
            set linear1 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_zero_'\]"]
            set linear2 [get_domnode_attribute $node v]
            if {$dirc == "x"} {
              GiD_WriteCalculationFile puts "$group_name, u1, $linear1, $linear2"
            } elseif {$dirc == "y"} {
              GiD_WriteCalculationFile puts "$group_name, u2, $linear1, $linear2"
            } elseif {$dirc == "z"} {
              GiD_WriteCalculationFile puts "$group_name, u3, $linear1, $linear2"
            }
          } elseif {$scale_type == "Moving hydrostatic"} {
            set node [$group selectNodes "./value\[@n = '_type_'\]"]
            set bc_type [get_domnode_attribute $node v]
            if {$bc_type == "displacement"} {
              GiD_WriteCalculationFile puts "*Boundary, type=Moving-hydrostatic"
            } else {
              GiD_WriteCalculationFile puts "*Boundary, $bc_type, type=Moving-hydrostatic"
            }
            set node [$group selectNodes "./value\[@n = '_MH_dir_'\]"]
            set MH1 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_MH_impliment_dir_'\]"]
            set MH2 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_MH_slope_'\]"]
            set MH3 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_MH_z0_'\]"]
            set MH4 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_MH_t0_'\]"]
            set MH5 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_MH_z1_'\]"]
            set MH6 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_MH_t1_'\]"]
            set MH7 [get_domnode_attribute $node v]
            if {$MH1 == "x"} {
              if {$MH2 == "x"} {
                GiD_WriteCalculationFile puts "$group_name, u1, 1, $MH3, $MH4, $MH5, $MH6, $MH7"
              } elseif {$MH2 == "y"} {
                GiD_WriteCalculationFile puts "$group_name, u1, 2, $MH3, $MH4, $MH5, $MH6, $MH7"
              } elseif {$MH2 == "z"} {
                GiD_WriteCalculationFile puts "$group_name, u1, 3, $MH3, $MH4, $MH5, $MH6, $MH7"
              }
            } elseif {$MH1 == "y"} {
              if {$MH1 == "x"} {
                  GiD_WriteCalculationFile puts "$group_name, u2, 1, $MH3, $MH4, $MH5, $MH6, $MH7"
              } elseif {$MH2 == "y"} {
                  GiD_WriteCalculationFile puts "$group_name, u2, 2, $MH3, $MH4, $MH5, $MH6, $MH7"
              } elseif {$MH2 == "z"} {
                  GiD_WriteCalculationFile puts "$group_name, u2, 3, $MH3, $MH4, $MH5, $MH6, $MH7"
              }
            } elseif {$MH1 == "z"} {
              if {$MH2 == "x"} {
                  GiD_WriteCalculationFile puts "$group_name, u3, 1, $MH3, $MH4, $MH5, $MH6, $MH7"
              } elseif {$MH2 == "y"} {
                  GiD_WriteCalculationFile puts "$group_name, u3, 2, $MH3, $MH4, $MH5, $MH6, $MH7"
              } elseif {$MH2 == "z"} {
                  GiD_WriteCalculationFile puts "$group_name, u3, 3, $MH3, $MH4, $MH5, $MH6, $MH7"
              }
            }
          }	
        } elseif {$cons == "No"} {
          set node [$group selectNodes "./value\[@n = '_amplitude_'\]"]
          set amplname [get_domnode_attribute $node v]
          if  {$scale_type == "Scalar"} {
            set node [$group selectNodes "./value\[@n = '_type_'\]"]
            set bc_type [get_domnode_attribute $node v]
            if {$bc_type == "displacement"} {
              GiD_WriteCalculationFile puts "*Boundary, amplitude=$amplname"
            } else {
              GiD_WriteCalculationFile puts "*Boundary, amplitude=$amplname, $bc_type"
            }
            set node [$group selectNodes "./value\[@n = '_x_'\]"]
            set bc_magnitudex [get_domnode_attribute $node v]
            if {$bc_magnitudex == "free"} {
            } elseif {$bc_magnitudex == "fixed"} {
              GiD_WriteCalculationFile puts "$group_name, u1, 0"
            } else {
              set node [$group selectNodes "./value\[@n = '_xp_'\]"]
              set bc_magnitudexp [get_domnode_attribute $node v]
              GiD_WriteCalculationFile puts "$group_name, u1, $bc_magnitudexp"
            }
            set node [$group selectNodes "./value\[@n = '_y_'\]"]
            set bc_magnitudey [get_domnode_attribute $node v]
            if {$bc_magnitudey == "free"} {
            } elseif {$bc_magnitudey == "fixed"} {
              GiD_WriteCalculationFile puts "$group_name, u2, 0"
            } else {
              set node [$group selectNodes "./value\[@n = '_yp_'\]"]
              set bc_magnitudeyp [get_domnode_attribute $node v]
              GiD_WriteCalculationFile puts "$group_name, u2, $bc_magnitudeyp"
            }
            set node [$group selectNodes "./value\[@n = '_z_'\]"]
            set bc_magnitudez [get_domnode_attribute $node v]
            if {$bc_magnitudez == "free"} {
            } elseif {$bc_magnitudez == "fixed"} {
              GiD_WriteCalculationFile puts "$group_name, u3, 0"
            } else {
              set node [$group selectNodes "./value\[@n = '_zp_'\]"]
              set bc_magnitudezp [get_domnode_attribute $node v]
              GiD_WriteCalculationFile puts "$group_name, u3, $bc_magnitudezp"
            }  
          } elseif {$scale_type == "Linear distribution"} {
            set node [$group selectNodes "./value\[@n = '_amplitude_'\]"]
            set amplname [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_type_'\]"]
            set bc_type [get_domnode_attribute $node v]
            if {$bc_type == "displacement"} {
              GiD_WriteCalculationFile puts "*Boundary, amplitude=$amplname, type=hydrostatic"
            } else {
              GiD_WriteCalculationFile puts "*Boundary, amplitude=$amplname, $bc_type, type=hydrostatic"
            }
            set node [$group selectNodes "./value\[@n = '_dirct_'\]"]
            set dirc [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_value_'\]"]
            set linear1 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_zero_'\]"]
            set linear2 [get_domnode_attribute $node v]
            if {$dirc == "x"} {
              GiD_WriteCalculationFile puts "$group_name, u1, $linear1, $linear2"
            } elseif {$dirc == "y"} {
              GiD_WriteCalculationFile puts "$group_name, u2, $linear1, $linear2"
            } elseif {$dirc == "z"} {
              GiD_WriteCalculationFile puts "$group_name, u3, $linear1, $linear2"
            }
          } elseif {$scale_type == "Moving hydrostatic"} {
            set node [$group selectNodes "./value\[@n = '_amplitude_'\]"]
            set amplname [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_type_'\]"]
            set bc_type [get_domnode_attribute $node v]
            if {$bc_type == "displacement"} {
              GiD_WriteCalculationFile puts "*Boundary, amplitude=$amplname, type=Moving-hydrostatic"
            } else {
              GiD_WriteCalculationFile puts "*Boundary, amplitude=$amplname, $bc_type, type=Moving-hydrostatic"
            }
            set node [$group selectNodes "./value\[@n = '_MH_dir_'\]"]
            set MH1 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_MH_impliment_dir_'\]"]
            set MH2 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_MH_slope_'\]"]
            set MH3 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_MH_z0_'\]"]
            set MH4 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_MH_t0_'\]"]
            set MH5 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_MH_z1_'\]"]
            set MH6 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_MH_t1_'\]"]
            set MH7 [get_domnode_attribute $node v]
            if {$MH1 == "x"} {
              if {$MH2 == "x"} {
                GiD_WriteCalculationFile puts "$group_name, u1, 1, $MH3, $MH4, $MH5, $MH6, $MH7"
              } elseif {$MH2 == "y"} {
                GiD_WriteCalculationFile puts "$group_name, u1, 2, $MH3, $MH4, $MH5, $MH6, $MH7"
              } elseif {$MH2 == "z"} {
                GiD_WriteCalculationFile puts "$group_name, u1, 3, $MH3, $MH4, $MH5, $MH6, $MH7"
              }
            } elseif {$MH1 == "y"} {
              if {$MH1 == "x"} {
                GiD_WriteCalculationFile puts "$group_name, u2, 1, $MH3, $MH4, $MH5, $MH6, $MH7"
              } elseif {$MH2 == "y"} {
                GiD_WriteCalculationFile puts "$group_name, u2, 2, $MH3, $MH4, $MH5, $MH6, $MH7"
              } elseif {$MH2 == "z"} {
                GiD_WriteCalculationFile puts "$group_name, u2, 3, $MH3, $MH4, $MH5, $MH6, $MH7"
              }
            } elseif {$MH1 == "z"} {
              if {$MH2 == "x"} {
                GiD_WriteCalculationFile puts "$group_name, u3, 1, $MH3, $MH4, $MH5, $MH6, $MH7"
              } elseif {$MH2 == "y"} {
                GiD_WriteCalculationFile puts "$group_name, u3, 2, $MH3, $MH4, $MH5, $MH6, $MH7"
              } elseif {$MH2 == "z"} {
                GiD_WriteCalculationFile puts "$group_name, u3, 3, $MH3, $MH4, $MH5, $MH6, $MH7"
              }
            }
          }
        }
      }
	  
      #
      # Boundary conditions applied to the solid rotation
      #
      
      set xp "./container\[@n='_boundary_conditions_'\]/container\[@n='_direct_BC_'\]/condition\[@n='_solid_rotate_'\]/group"
      set groups [$istep selectNodes $xp]
      foreach group $groups {
        set group_name [get_domnode_attribute $group n]
        set node [$group selectNodes "./value\[@n = '_scalar_linear_'\]"]
        set scale_type [get_domnode_attribute $node v]
        set node [$group selectNodes "./value\[@n = '_constant_'\]"]
        set cons [get_domnode_attribute $node v]
        if {$cons == "Yes"} {
          if  {$scale_type == "Scalar"} {
          set node [$group selectNodes "./value\[@n = '_type_'\]"]
          set bc_type [get_domnode_attribute $node v]
            if {$bc_type == "displacement"} {
              GiD_WriteCalculationFile puts "*Boundary"
            } else {
              GiD_WriteCalculationFile puts "*Boundary, $bc_type"
            }
            set node [$group selectNodes "./value\[@n = '_rotation_x_'\]"]
            set bc_magnitudex [get_domnode_attribute $node v]
            if {$bc_magnitudex == "free"} {
            } elseif {$bc_magnitudex == "fixed"} {
              GiD_WriteCalculationFile puts "$group_name, r1, 0"
            } else {
              set node [$group selectNodes "./value\[@n = '_rotate_xp_'\]"]
              set bc_magnitudexp [get_domnode_attribute $node v]
              GiD_WriteCalculationFile puts "$group_name, r1, $bc_magnitudexp"
            }
            set node [$group selectNodes "./value\[@n = '_rotation_y_'\]"]
            set bc_magnitudey [get_domnode_attribute $node v]
            if {$bc_magnitudey == "free"} {
            } elseif {$bc_magnitudey == "fixed"} {
              GiD_WriteCalculationFile puts "$group_name, r2, 0"
            } else {
              set node [$group selectNodes "./value\[@n = '_rotate_yp_'\]"]
              set bc_magnitudeyp [get_domnode_attribute $node v]
              GiD_WriteCalculationFile puts "$group_name, r2, $bc_magnitudeyp"
            }
            set node [$group selectNodes "./value\[@n = '_rotation_z_'\]"]
            set bc_magnitudez [get_domnode_attribute $node v]
            if {$bc_magnitudez == "free"} {
            } elseif {$bc_magnitudez == "fixed"} {
              GiD_WriteCalculationFile puts "$group_name, r3, 0"
            } else {
              set node [$group selectNodes "./value\[@n = '_rotate_zp_'\]"]
              set bc_magnitudezp [get_domnode_attribute $node v]
              GiD_WriteCalculationFile puts "$group_name, r3, $bc_magnitudezp"
            }
          } elseif {$scale_type == "Linear distribution"} {
            set node [$group selectNodes "./value\[@n = '_type_'\]"]
            set bc_type [get_domnode_attribute $node v]
            if {$bc_type == "displacement"} {
              GiD_WriteCalculationFile puts "*Boundary, type=hydrostatic"
            } else {
              GiD_WriteCalculationFile puts "*Boundary, $bc_type, type=hydrostatic"
            }
            set node [$group selectNodes "./value\[@n = '_dirct_'\]"]
            set dirc [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_value_'\]"]
            set linear1 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_zero_'\]"]
            set linear2 [get_domnode_attribute $node v]
            if {$dirc == "x"} {
              GiD_WriteCalculationFile puts "$group_name, r1, $linear1, $linear2"
            } elseif {$dirc == "y"} {
              GiD_WriteCalculationFile puts "$group_name, r2, $linear1, $linear2"
            } elseif {$dirc == "z"} {
              GiD_WriteCalculationFile puts "$group_name, r3, $linear1, $linear2"
            }
          } elseif {$scale_type == "Moving hydrostatic"} {
            set node [$group selectNodes "./value\[@n = '_type_'\]"]
            set bc_type [get_domnode_attribute $node v]
            if {$bc_type == "displacement"} {
              GiD_WriteCalculationFile puts "*Boundary, type=Moving-hydrostatic"
            } else {
              GiD_WriteCalculationFile puts "*Boundary, $bc_type, type=Moving-hydrostatic"
            }
            set node [$group selectNodes "./value\[@n = '_MH_dir_'\]"]
            set MH1 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_MH_impliment_dir_'\]"]
            set MH2 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_MH_slope_'\]"]
            set MH3 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_MH_z0_'\]"]
            set MH4 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_MH_t0_'\]"]
            set MH5 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_MH_z1_'\]"]
            set MH6 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_MH_t1_'\]"]
            set MH7 [get_domnode_attribute $node v]
            if {$MH1 == "x"} {
              if {$MH2 == "x"} {
                GiD_WriteCalculationFile puts "$group_name, r1, 1, $MH3, $MH4, $MH5, $MH6, $MH7"
              } elseif {$MH2 == "y"} {
                GiD_WriteCalculationFile puts "$group_name, r1, 2, $MH3, $MH4, $MH5, $MH6, $MH7"
              } elseif {$MH2 == "z"} {
                GiD_WriteCalculationFile puts "$group_name, r1, 3, $MH3, $MH4, $MH5, $MH6, $MH7"
              }
            } elseif {$MH1 == "y"} {
              if {$MH1 == "x"} {
                  GiD_WriteCalculationFile puts "$group_name, r2, 1, $MH3, $MH4, $MH5, $MH6, $MH7"
              } elseif {$MH2 == "y"} {
                  GiD_WriteCalculationFile puts "$group_name, r2, 2, $MH3, $MH4, $MH5, $MH6, $MH7"
              } elseif {$MH2 == "z"} {
                  GiD_WriteCalculationFile puts "$group_name, r2, 3, $MH3, $MH4, $MH5, $MH6, $MH7"
              }
            } elseif {$MH1 == "z"} {
              if {$MH2 == "x"} {
                  GiD_WriteCalculationFile puts "$group_name, r3, 1, $MH3, $MH4, $MH5, $MH6, $MH7"
              } elseif {$MH2 == "y"} {
                  GiD_WriteCalculationFile puts "$group_name, r3, 2, $MH3, $MH4, $MH5, $MH6, $MH7"
              } elseif {$MH2 == "z"} {
                  GiD_WriteCalculationFile puts "$group_name, r3, 3, $MH3, $MH4, $MH5, $MH6, $MH7"
              }
            }
          }
        } elseif {$cons == "No"} {
          set node [$group selectNodes "./value\[@n = '_amplitude_'\]"]
          set amplname [get_domnode_attribute $node v]
          if  {$scale_type == "Scalar"} {
            set node [$group selectNodes "./value\[@n = '_type_'\]"]
            set bc_type [get_domnode_attribute $node v]
            if {$bc_type == "displacement"} {
              GiD_WriteCalculationFile puts "*Boundary, amplitude=$amplname"
            } else {
              GiD_WriteCalculationFile puts "*Boundary, amplitude=$amplname, $bc_type"
            }
            set node [$group selectNodes "./value\[@n = '_rotation_x_'\]"]
            set bc_magnitudex [get_domnode_attribute $node v]
            if {$bc_magnitudex == "free"} {
            } elseif {$bc_magnitudex == "fixed"} {
              GiD_WriteCalculationFile puts "$group_name, r1, 0"
            } else {
              set node [$group selectNodes "./value\[@n = '_rotate_xp_'\]"]
              set bc_magnitudexp [get_domnode_attribute $node v]
              GiD_WriteCalculationFile puts "$group_name, r1, $bc_magnitudexp"
            }
            set node [$group selectNodes "./value\[@n = '_rotation_y_'\]"]
            set bc_magnitudey [get_domnode_attribute $node v]
            if {$bc_magnitudey == "free"} {
            } elseif {$bc_magnitudey == "fixed"} {
              GiD_WriteCalculationFile puts "$group_name, r2, 0"
            } else {
              set node [$group selectNodes "./value\[@n = '_rotate_yp_'\]"]
              set bc_magnitudeyp [get_domnode_attribute $node v]
              GiD_WriteCalculationFile puts "$group_name, r2, $bc_magnitudeyp"
            }
            set node [$group selectNodes "./value\[@n = '_rotation_z_'\]"]
            set bc_magnitudez [get_domnode_attribute $node v]
            if {$bc_magnitudez == "free"} {
            } elseif {$bc_magnitudez == "fixed"} {
              GiD_WriteCalculationFile puts "$group_name, r3, 0"
            } else {
              set node [$group selectNodes "./value\[@n = '_rotate_zp_'\]"]
              set bc_magnitudezp [get_domnode_attribute $node v]
              GiD_WriteCalculationFile puts "$group_name, r3, $bc_magnitudezp"
            }  
          } elseif {$scale_type == "Linear distribution"} {
            set node [$group selectNodes "./value\[@n = '_amplitude_'\]"]
            set amplname [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_type_'\]"]
            set bc_type [get_domnode_attribute $node v]
            if {$bc_type == "displacement"} {
              GiD_WriteCalculationFile puts "*Boundary, amplitude=$amplname, type=hydrostatic"
            } else {
              GiD_WriteCalculationFile puts "*Boundary, amplitude=$amplname, $bc_type, type=hydrostatic"
            }
            set node [$group selectNodes "./value\[@n = '_dirct_'\]"]
            set dirc [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_value_'\]"]
            set linear1 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_zero_'\]"]
            set linear2 [get_domnode_attribute $node v]
            if {$dirc == "x"} {
              GiD_WriteCalculationFile puts "$group_name, r1, $linear1, $linear2"
            } elseif {$dirc == "y"} {
              GiD_WriteCalculationFile puts "$group_name, r2, $linear1, $linear2"
            } elseif {$dirc == "z"} {
              GiD_WriteCalculationFile puts "$group_name, r3, $linear1, $linear2"
            }
          } elseif {$scale_type == "Moving hydrostatic"} {
            set node [$group selectNodes "./value\[@n = '_amplitude_'\]"]
            set amplname [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_type_'\]"]
            set bc_type [get_domnode_attribute $node v]
            if {$bc_type == "displacement"} {
              GiD_WriteCalculationFile puts "*Boundary, amplitude=$amplname, type=Moving-hydrostatic"
            } else {
              GiD_WriteCalculationFile puts "*Boundary, amplitude=$amplname, $bc_type, type=Moving-hydrostatic"
            }
            set node [$group selectNodes "./value\[@n = '_MH_dir_'\]"]
            set MH1 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_MH_impliment_dir_'\]"]
            set MH2 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_MH_slope_'\]"]
            set MH3 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_MH_z0_'\]"]
            set MH4 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_MH_t0_'\]"]
            set MH5 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_MH_z1_'\]"]
            set MH6 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_MH_t1_'\]"]
            set MH7 [get_domnode_attribute $node v]
            if {$MH1 == "x"} {
              if {$MH2 == "x"} {
                GiD_WriteCalculationFile puts "$group_name, r1, 1, $MH3, $MH4, $MH5, $MH6, $MH7"
              } elseif {$MH2 == "y"} {
                GiD_WriteCalculationFile puts "$group_name, r1, 2, $MH3, $MH4, $MH5, $MH6, $MH7"
              } elseif {$MH2 == "z"} {
                GiD_WriteCalculationFile puts "$group_name, r1, 3, $MH3, $MH4, $MH5, $MH6, $MH7"
              }
            } elseif {$MH1 == "y"} {
              if {$MH1 == "x"} {
                GiD_WriteCalculationFile puts "$group_name, r2, 1, $MH3, $MH4, $MH5, $MH6, $MH7"
              } elseif {$MH2 == "y"} {
                GiD_WriteCalculationFile puts "$group_name, r2, 2, $MH3, $MH4, $MH5, $MH6, $MH7"
              } elseif {$MH2 == "z"} {
                GiD_WriteCalculationFile puts "$group_name, r2, 3, $MH3, $MH4, $MH5, $MH6, $MH7"
              }
            } elseif {$MH1 == "z"} {
              if {$MH2 == "x"} {
                GiD_WriteCalculationFile puts "$group_name, r3, 1, $MH3, $MH4, $MH5, $MH6, $MH7"
              } elseif {$MH2 == "y"} {
                GiD_WriteCalculationFile puts "$group_name, r3, 2, $MH3, $MH4, $MH5, $MH6, $MH7"
              } elseif {$MH2 == "z"} {
                GiD_WriteCalculationFile puts "$group_name, r3, 3, $MH3, $MH4, $MH5, $MH6, $MH7"
              }
            }
          }
        }
      }
  
      #
      # Boundary conditions applied to the pore water pressure
      #
      
      set xp "./container\[@n='_boundary_conditions_'\]/container\[@n='_direct_BC_'\]/condition\[@n='_pwp_'\]/group"
      set groups [$istep selectNodes $xp]
      foreach group $groups {
        set group_name [get_domnode_attribute $group n]
        set node [$group selectNodes "./value\[@n = '_scalar_linear_'\]"]
        set scale_type [get_domnode_attribute $node v]
        set node [$group selectNodes "./value\[@n = '_constant_'\]"]
        set cons [get_domnode_attribute $node v]
        if {$cons == "Yes"} {
          if  {$scale_type == "Scalar"} {
            set node [$group selectNodes "./value\[@n = '_type_'\]"]
            set bc_type [get_domnode_attribute $node v]
            if {$bc_type == "none"} {
              GiD_WriteCalculationFile puts "*Boundary"
            } else {
              GiD_WriteCalculationFile puts "*Boundary, $bc_type"
            }
              set node [$group selectNodes "./value\[@n = '_mag_'\]"]
              set val_wp1 [get_domnode_attribute $node v]
              GiD_WriteCalculationFile puts "$group_name, pw, $val_wp1"
          } elseif {$scale_type == "Linear distribution"} {
            set node [$group selectNodes "./value\[@n = '_type_'\]"]
            set bc_type [get_domnode_attribute $node v]
            if {$bc_type == "none"} {
              GiD_WriteCalculationFile puts "*Boundary, type=hydrostatic"
            } else {
              GiD_WriteCalculationFile puts "*Boundary, $bc_type, type=hydrostatic"
            }
              set node [$group selectNodes "./value\[@n = '_value_'\]"]
              set val_wp1 [get_domnode_attribute $node v]
              set node [$group selectNodes "./value\[@n = '_zero_'\]"]
              set val_wp2 [get_domnode_attribute $node v] 		
              GiD_WriteCalculationFile puts "$group_name, pw, $val_wp1, $val_wp2"
          } elseif {$scale_type == "Moving hydrostatic"} {
            set node [$group selectNodes "./value\[@n = '_type_'\]"]
            set bc_type [get_domnode_attribute $node v]
            if {$bc_type == "none"} {
              GiD_WriteCalculationFile puts "*Boundary, type=Moving-hydrostatic"
            } else {
              GiD_WriteCalculationFile puts "*Boundary, $bc_type, type=Moving-hydrostatic"
            }
            set node [$group selectNodes "./value\[@n = '_MH_impliment_dir_'\]"]
            set MH2 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_MH_slope_'\]"]
            set MH3 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_MH_z0_'\]"]
            set MH4 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_MH_t0_'\]"]
            set MH5 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_MH_z1_'\]"]
            set MH6 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_MH_t1_'\]"]
            set MH7 [get_domnode_attribute $node v]
            if {$MH2 == "x"} {
              GiD_WriteCalculationFile puts "$group_name, pw, 1, $MH3, $MH4, $MH5, $MH6, $MH7"
            } elseif {$MH2 == "y"} {
              GiD_WriteCalculationFile puts "$group_name, pw, 2, $MH3, $MH4, $MH5, $MH6, $MH7"
            } elseif {$MH2 == "z"} {
              GiD_WriteCalculationFile puts "$group_name, pw, 3, $MH3, $MH4, $MH5, $MH6, $MH7"
            }
          } 
        } elseif {$cons == "No"} {
          set node [$group selectNodes "./value\[@n = '_amplitude_'\]"]
          set amplname [get_domnode_attribute $node v]
          if  {$scale_type == "Scalar"} {
            set node [$group selectNodes "./value\[@n = '_type_'\]"]
            set bc_type [get_domnode_attribute $node v]
            if {$bc_type == "none"} {
              GiD_WriteCalculationFile puts "*Boundary, amplitude=$amplname"
            } else {
              GiD_WriteCalculationFile puts "*Boundary, amplitude=$amplname, $bc_type"
            }
            set node [$group selectNodes "./value\[@n = '_mag_'\]"]
            set val_wp1 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_value_'\]"]
            set val_wp2 [get_domnode_attribute $node v]  
            GiD_WriteCalculationFile puts "$group_name, pw, $val_wp1"
          } elseif {$scale_type == "Linear distribution"} {
            set node [$group selectNodes "./value\[@n = '_type_'\]"]
            set bc_type [get_domnode_attribute $node v]
            if {$bc_type == "none"} {
              GiD_WriteCalculationFile puts "*Boundary, amplitude=$amplname, type=hydrostatic"
            } else {
              GiD_WriteCalculationFile puts "*Boundary, amplitude=$amplname, $bc_type, type=hydrostatic"
            }
            set node [$group selectNodes "./value\[@n = '_mag_'\]"]
            set val_wp1 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_value_'\]"]
            set val_wp2 [get_domnode_attribute $node v]  
            GiD_WriteCalculationFile puts "$group_name, pw, $val_wp1, $val_wp2"
          } elseif {$scale_type == "Moving hydrostatic"} {
            set node [$group selectNodes "./value\[@n = '_type_'\]"]
            set bc_type [get_domnode_attribute $node v]
            if {$bc_type == "none"} {
              GiD_WriteCalculationFile puts "*Boundary, amplitude=$amplname, type=Moving-hydrostatic"
            } else {
              GiD_WriteCalculationFile puts "*Boundary, amplitude=$amplname, $bc_type, type=Moving-hydrostatic"
            }
            set node [$group selectNodes "./value\[@n = '_MH_impliment_dir_'\]"]
            set MH2 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_MH_slope_'\]"]
            set MH3 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_MH_z0_'\]"]
            set MH4 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_MH_t0_'\]"]
            set MH5 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_MH_z1_'\]"]
            set MH6 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_MH_t1_'\]"]
            set MH7 [get_domnode_attribute $node v]
            if {$MH2 == "x"} {
              GiD_WriteCalculationFile puts "$group_name, pw, 1, $MH3, $MH4, $MH5, $MH6, $MH7"
            } elseif {$MH2 == "y"} {
              GiD_WriteCalculationFile puts "$group_name, pw, 2, $MH3, $MH4, $MH5, $MH6, $MH7"
            } elseif {$MH2 == "z"} {
              GiD_WriteCalculationFile puts "$group_name, pw, 3, $MH3, $MH4, $MH5, $MH6, $MH7"
            }
          }
        }
      }

      #
      # Boundary conditions pore air pressure
      #
      
      set xp "./container\[@n='_boundary_conditions_'\]/container\[@n='_direct_BC_'\]/condition\[@n='_pap_'\]/group"
      set groups [$istep selectNodes $xp]
      foreach group $groups {
        set group_name [get_domnode_attribute $group n]
        set node [$group selectNodes "./value\[@n = '_scalar_linear_'\]"]
        set scale_type [get_domnode_attribute $node v]
        set node [$group selectNodes "./value\[@n = '_constant_'\]"]
        set cons [get_domnode_attribute $node v]
        if {$cons == "Yes"} {
          if  {$scale_type == "Scalar"} {
            set node [$group selectNodes "./value\[@n = '_type_'\]"]
            set bc_type [get_domnode_attribute $node v]
            if {$bc_type == "none"} {
              GiD_WriteCalculationFile puts "*Boundary"
            } else {
              GiD_WriteCalculationFile puts "*Boundary, $bc_type"
            }
            set node [$group selectNodes "./value\[@n = '_mag_'\]"]
            set val_wp1 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_value_'\]"]
            set val_wp2 [get_domnode_attribute $node v]  
            GiD_WriteCalculationFile puts "$group_name, pa, $val_wp1"
          } elseif {$scale_type == "Linear distribution"} {
            set node [$group selectNodes "./value\[@n = '_type_'\]"]
            set bc_type [get_domnode_attribute $node v]
            if {$bc_type == "none"} {
              GiD_WriteCalculationFile puts "*Boundary, type=hydrostatic"
            } else {
              GiD_WriteCalculationFile puts "*Boundary, $bc_type, type=hydrostatic"
            }
            set node [$group selectNodes "./value\[@n = '_mag_'\]"]
            set val_wp1 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_value_'\]"]
            set val_wp2 [get_domnode_attribute $node v]  
            GiD_WriteCalculationFile puts "$group_name, pa, $val_wp1, $val_wp2"
          } elseif {$scale_type == "Moving hydrostatic"} {
            set node [$group selectNodes "./value\[@n = '_type_'\]"]
            set bc_type [get_domnode_attribute $node v]
            if {$bc_type == "none"} {
              GiD_WriteCalculationFile puts "*Boundary, type=Moving-hydrostatic"
            } else {
              GiD_WriteCalculationFile puts "*Boundary, $bc_type, type=Moving-hydrostatic"
            }
            set node [$group selectNodes "./value\[@n = '_MH_impliment_dir_'\]"]
            set MH2 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_MH_slope_'\]"]
            set MH3 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_MH_z0_'\]"]
            set MH4 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_MH_t0_'\]"]
            set MH5 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_MH_z1_'\]"]
            set MH6 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_MH_t1_'\]"]
            set MH7 [get_domnode_attribute $node v]
            if {$MH2 == "x"} {
              GiD_WriteCalculationFile puts "$group_name, pa, 1, $MH3, $MH4, $MH5, $MH6, $MH7"
            } elseif {$MH2 == "y"} {
              GiD_WriteCalculationFile puts "$group_name, pa, 2, $MH3, $MH4, $MH5, $MH6, $MH7"
            } elseif {$MH2 == "z"} {
              GiD_WriteCalculationFile puts "$group_name, pa, 3, $MH3, $MH4, $MH5, $MH6, $MH7"
            }
          }   
        } elseif {$cons == "No"} {
          set node [$group selectNodes "./value\[@n = '_amplitude_'\]"]
          set amplname [get_domnode_attribute $node v]
          if {$scale_type == "Scalar"} {
            set node [$group selectNodes "./value\[@n = '_type_'\]"]
            set bc_type [get_domnode_attribute $node v]
            if {$bc_type == "none"} {
              GiD_WriteCalculationFile puts "*Boundary, amplitude=$amplname"
            } else {
              GiD_WriteCalculationFile puts "*Boundary, amplitude=$amplname, $bc_type"
            }
            set node [$group selectNodes "./value\[@n = '_mag_'\]"]
            set val_wp1 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_value_'\]"]
            set val_wp2 [get_domnode_attribute $node v]  
            GiD_WriteCalculationFile puts "$group_name, pa, $val_wp1"
          } elseif {$scale_type == "Linear distribution"} {
            set node [$group selectNodes "./value\[@n = '_type_'\]"]
            set bc_type [get_domnode_attribute $node v]
            if {$bc_type == "none"} {
              GiD_WriteCalculationFile puts "*Boundary, amplitude=$amplname, type=hydrostatic"
            } else {
              GiD_WriteCalculationFile puts "*Boundary, amplitude=$amplname, $bc_type, type=hydrostatic"
            }
            set node [$group selectNodes "./value\[@n = '_mag_'\]"]
            set val_wp1 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_value_'\]"]
            set val_wp2 [get_domnode_attribute $node v]  
            GiD_WriteCalculationFile puts "$group_name, pa, $val_wp1, $val_wp2"
          } elseif {$scale_type == "Moving hydrostatic"} {
            set node [$group selectNodes "./value\[@n = '_type_'\]"]
            set bc_type [get_domnode_attribute $node v]
            if {$bc_type == "none"} {
              GiD_WriteCalculationFile puts "*Boundary, amplitude=$amplname, type=Moving-hydrostatic"
            } else {
              GiD_WriteCalculationFile puts "*Boundary, amplitude=$amplname, $bc_type, type=Moving-hydrostatic"
            }
            set node [$group selectNodes "./value\[@n = '_MH_impliment_dir_'\]"]
            set MH2 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_MH_slope_'\]"]
            set MH3 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_MH_z0_'\]"]
            set MH4 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_MH_t0_'\]"]
            set MH5 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_MH_z1_'\]"]
            set MH6 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_MH_t1_'\]"]
            set MH7 [get_domnode_attribute $node v]
            if {$MH2 == "x"} {
              GiD_WriteCalculationFile puts "$group_name, pa, 1, $MH3, $MH4, $MH5, $MH6, $MH7"
            } elseif {$MH2 == "y"} {
              GiD_WriteCalculationFile puts "$group_name, pa, 2, $MH3, $MH4, $MH5, $MH6, $MH7"
            } elseif {$MH2 == "z"} {
              GiD_WriteCalculationFile puts "$group_name, pa, 3, $MH3, $MH4, $MH5, $MH6, $MH7"
            }
          }
        }
      }
  
      #
      # Boundary conditions applied to the water phase
      #
      
      set xp "./container\[@n='_boundary_conditions_'\]/container\[@n='_direct_BC_'\]/condition\[@n='_water_'\]/group"
      set groups [$istep selectNodes $xp]
      foreach group $groups {
        set group_name [get_domnode_attribute $group n]
        set node [$group selectNodes "./value\[@n = '_scalar_linear_'\]"]
        set scale_type [get_domnode_attribute $node v]
        set node [$group selectNodes "./value\[@n = '_constant_'\]"]
        set cons [get_domnode_attribute $node v]
        if {$cons == "Yes"} {
          if  {$scale_type == "Scalar"} {
            set node [$group selectNodes "./value\[@n = '_type_'\]"]
            set bc_type [get_domnode_attribute $node v]
            if {$bc_type == "none"} {
              GiD_WriteCalculationFile puts "*Boundary"
            } else {
              GiD_WriteCalculationFile puts "*Boundary, $bc_type"
            }
            set node [$group selectNodes "./value\[@n = '_dirct_'\]"]
            set bc_magnitudex [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_value_'\]"]
            set wdx1 [get_domnode_attribute $node v]
            if {$bc_magnitudex == "x"} {
              GiD_WriteCalculationFile puts "$group_name, w1, $wdx1"
            } elseif {$bc_magnitudex == "y"} {
              GiD_WriteCalculationFile puts "$group_name, w2, $wdx1"
            } elseif {$bc_magnitudex == "z"} {
              GiD_WriteCalculationFile puts "$group_name, w3, $wdx1"
            }  
          } elseif {$scale_type == "Linear distribution"} {
            set node [$group selectNodes "./value\[@n = '_type_'\]"]
            set bc_type [get_domnode_attribute $node v]
            if {$bc_type == "none"} {
              GiD_WriteCalculationFile puts "*Boundary, type=hydrostatic"
            } else {
              GiD_WriteCalculationFile puts "*Boundary, $bc_type, type=hydrostatic"
            }
            set node [$group selectNodes "./value\[@n = '_dirct_'\]"]
            set bc_magnitudex [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_value_'\]"]
            set wdx1 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_zero_'\]"]
            set wdx2 [get_domnode_attribute $node v]
            if {$bc_magnitudex == "x"} {
              GiD_WriteCalculationFile puts "$group_name, w1, $wdx1, $wdx2"
            } elseif {$bc_magnitudex == "y"} {
              GiD_WriteCalculationFile puts "$group_name, w2, $wdx1, $wdx2"
            } elseif {$bc_magnitudex == "z"} {
              GiD_WriteCalculationFile puts "$group_name, w3, $wdx1, $wdx2"
            }  
          } elseif {$scale_type == "Moving hydrostatic"} {
            set node [$group selectNodes "./value\[@n = '_type_'\]"]
            set bc_type [get_domnode_attribute $node v]
            if {$bc_type == "none"} {
              GiD_WriteCalculationFile puts "*Boundary, type=Moving-hydrostatic"
            } else {
              GiD_WriteCalculationFile puts "*Boundary, $bc_type, type=Moving-hydrostatic"
            }
            set node [$group selectNodes "./value\[@n = '_MH_dir_'\]"]
            set MH1 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_MH_impliment_dir_'\]"]
            set MH2 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_MH_slope_'\]"]
            set MH3 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_MH_z0_'\]"]
            set MH4 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_MH_t0_'\]"]
            set MH5 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_MH_z1_'\]"]
            set MH6 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_MH_t1_'\]"]
            set MH7 [get_domnode_attribute $node v]
            if {$MH1 == "x"} {
              if {$MH2 == "x"} {
                GiD_WriteCalculationFile puts "$group_name, w1, 1, $MH3, $MH4, $MH5, $MH6, $MH7"
              } elseif {$MH2 == "y"} {
                GiD_WriteCalculationFile puts "$group_name, w1, 2, $MH3, $MH4, $MH5, $MH6, $MH7"
              } elseif {$MH2 == "z"} {
                GiD_WriteCalculationFile puts "$group_name, w1, 3, $MH3, $MH4, $MH5, $MH6, $MH7"
              }
            } elseif {$MH1 == "y"} {
              if {$MH1 == "x"} {
                GiD_WriteCalculationFile puts "$group_name, w2, 1, $MH3, $MH4, $MH5, $MH6, $MH7"
              } elseif {$MH2 == "y"} {
                GiD_WriteCalculationFile puts "$group_name, w2, 2, $MH3, $MH4, $MH5, $MH6, $MH7"
              } elseif {$MH2 == "z"} {
                GiD_WriteCalculationFile puts "$group_name, w2, 3, $MH3, $MH4, $MH5, $MH6, $MH7"
              }
            } elseif {$MH1 == "z"} {
              if {$MH2 == "x"} {
                GiD_WriteCalculationFile puts "$group_name, w3, 1, $MH3, $MH4, $MH5, $MH6, $MH7"
              } elseif {$MH2 == "y"} {
                GiD_WriteCalculationFile puts "$group_name, w3, 2, $MH3, $MH4, $MH5, $MH6, $MH7"
              } elseif {$MH2 == "z"} {
                GiD_WriteCalculationFile puts "$group_name, w3, 3, $MH3, $MH4, $MH5, $MH6, $MH7"
              }
            }
          }
        } elseif {$cons == "No"} {
          set node [$group selectNodes "./value\[@n = '_amplitude_'\]"]
          set amplname [get_domnode_attribute $node v]
          if  {$scale_type == "Scalar"} {
            set node [$group selectNodes "./value\[@n = '_type_'\]"]
            set bc_type [get_domnode_attribute $node v]
            if {$bc_type == "none"} {
              GiD_WriteCalculationFile puts "*Boundary, amplitude=$amplname"
            } else {
              GiD_WriteCalculationFile puts "*Boundary, amplitude=$amplname, $bc_type"
            }
            set node [$group selectNodes "./value\[@n = '_dirct_'\]"]
            set bc_magnitudex [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_value_'\]"]
            set wdx1 [get_domnode_attribute $node v]
            if {$bc_magnitudex == "x"} {
              GiD_WriteCalculationFile puts "$group_name, w1, $wdx1"
            } elseif {$bc_magnitudex == "y"} {
              GiD_WriteCalculationFile puts "$group_name, w2, $wdx1"
            } elseif {$bc_magnitudex == "z"} {
              GiD_WriteCalculationFile puts "$group_name, w3, $wdx1"
            }
          } elseif {$scale_type == "Linear distribution"} {
            set node [$group selectNodes "./value\[@n = '_type_'\]"]
            set bc_type [get_domnode_attribute $node v]
            if {$bc_type == "none"} {
              GiD_WriteCalculationFile puts "*Boundary, amplitude=$amplname, type=hydrostatic"
            } else {
              GiD_WriteCalculationFile puts "*Boundary, $bc_type, amplitude=$amplname, type=hydrostatic"
            }
            set node [$group selectNodes "./value\[@n = '_dirct_'\]"]
            set bc_magnitudex [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_value_'\]"]
            set wdx1 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_zero_'\]"]
            set wdx2 [get_domnode_attribute $node v]
            if {$bc_magnitudex == "x"} {
              GiD_WriteCalculationFile puts "$group_name, w1, $wdx1, $wdx2"
            } elseif {$bc_magnitudex == "y"} {
              GiD_WriteCalculationFile puts "$group_name, w2, $wdx1, $wdx2"
            } elseif {$bc_magnitudex == "z"} {
              GiD_WriteCalculationFile puts "$group_name, w3, $wdx1, $wdx2"
            }
          } elseif {$scale_type == "Moving hydrostatic"} {
            set node [$group selectNodes "./value\[@n = '_type_'\]"]
            set bc_type [get_domnode_attribute $node v]
            if {$bc_type == "none"} {
              GiD_WriteCalculationFile puts "*Boundary, amplitude=$amplname, type=Moving-hydrostatic"
            } else {
              GiD_WriteCalculationFile puts "*Boundary, amplitude=$amplname, $bc_type, type=Moving-hydrostatic"
            }
            set node [$group selectNodes "./value\[@n = '_MH_dir_'\]"]
            set MH1 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_MH_impliment_dir_'\]"]
            set MH2 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_MH_slope_'\]"]
            set MH3 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_MH_z0_'\]"]
            set MH4 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_MH_t0_'\]"]
            set MH5 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_MH_z1_'\]"]
            set MH6 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_MH_t1_'\]"]
            set MH7 [get_domnode_attribute $node v]
            if {$MH1 == "x"} {
              if {$MH2 == "x"} {
                GiD_WriteCalculationFile puts "$group_name, w1, 1, $MH3, $MH4, $MH5, $MH6, $MH7"
              } elseif {$MH2 == "y"} {
                GiD_WriteCalculationFile puts "$group_name, w1, 2, $MH3, $MH4, $MH5, $MH6, $MH7"
              } elseif {$MH2 == "z"} {
                GiD_WriteCalculationFile puts "$group_name, w1, 3, $MH3, $MH4, $MH5, $MH6, $MH7"
              }
            } elseif {$MH1 == "y"} {
              if {$MH1 == "x"} {
                GiD_WriteCalculationFile puts "$group_name, w2, 1, $MH3, $MH4, $MH5, $MH6, $MH7"
              } elseif {$MH2 == "y"} {
                GiD_WriteCalculationFile puts "$group_name, w2, 2, $MH3, $MH4, $MH5, $MH6, $MH7"
              } elseif {$MH2 == "z"} {
                GiD_WriteCalculationFile puts "$group_name, w2, 3, $MH3, $MH4, $MH5, $MH6, $MH7"
              }
            } elseif {$MH1 == "z"} {
              if {$MH2 == "x"} {
                GiD_WriteCalculationFile puts "$group_name, w3, 1, $MH3, $MH4, $MH5, $MH6, $MH7"
              } elseif {$MH2 == "y"} {
                GiD_WriteCalculationFile puts "$group_name, w3, 2, $MH3, $MH4, $MH5, $MH6, $MH7"
              } elseif {$MH2 == "z"} {
                GiD_WriteCalculationFile puts "$group_name, w3, 3, $MH3, $MH4, $MH5, $MH6, $MH7"
              }
            }
          }
        }
      }
      #
      # Flexible Boundary conditions applied to the solid phase
      #
      
      set xp "./container\[@n='_boundary_conditions_'\]/container\[@n='_flexible_BC_'\]/condition\[@n='_solid_'\]/group"
      set groups [$istep selectNodes $xp]
      foreach group $groups {
        set group_name [get_domnode_attribute $group n]
        set node [$group selectNodes "./value\[@n = '_none_moving_'\]"]
        set type [get_domnode_attribute $node v]
        set node [$group selectNodes "./value\[@n = '_constant_'\]"]
        set cons [get_domnode_attribute $node v]
        if {$cons == "Yes"} {
          if {$type == "None"} {
            GiD_WriteCalculationFile puts "*Boundary-Flexible"
            set node [$group selectNodes "./value\[@n = '_x_'\]"]
            set bc_magnitudex [get_domnode_attribute $node v]
            if {$bc_magnitudex == "free"} {
            } elseif {$bc_magnitudex == "fixed"} {
              GiD_WriteCalculationFile puts "$group_name, u1, 0"
            } else {
              set node [$group selectNodes "./value\[@n = '_xp_'\]"]
              set bc_magnitudexp [get_domnode_attribute $node v]
              GiD_WriteCalculationFile puts "$group_name, u1, $bc_magnitudexp"
            }
            set node [$group selectNodes "./value\[@n = '_y_'\]"]
            set bc_magnitudey [get_domnode_attribute $node v]
            if {$bc_magnitudey == "free"} {
            } elseif {$bc_magnitudey == "fixed"} {
              GiD_WriteCalculationFile puts "$group_name, u2, 0"
            } else {
              set node [$group selectNodes "./value\[@n = '_yp_'\]"]
              set bc_magnitudeyp [get_domnode_attribute $node v]
              GiD_WriteCalculationFile puts "$group_name, u2, $bc_magnitudeyp"
            }
            set node [$group selectNodes "./value\[@n = '_z_'\]"]
            set bc_magnitudez [get_domnode_attribute $node v]
            if {$bc_magnitudez == "free"} {
            } elseif {$bc_magnitudez == "fixed"} {
              GiD_WriteCalculationFile puts "$group_name, u3, 0"
            } else {
              set node [$group selectNodes "./value\[@n = '_zp_'\]"]
              set bc_magnitudezp [get_domnode_attribute $node v]
              GiD_WriteCalculationFile puts "$group_name, u3, $bc_magnitudezp"
            }
          } elseif {$type == "Moving hydrostatic"} {
            GiD_WriteCalculationFile puts "*Boundary-Flexible, type=Moving-hydrostatic"
            set node [$group selectNodes "./value\[@n = '_MH_dir_'\]"]
            set MH1 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_MH_impliment_dir_'\]"]
            set MH2 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_MH_slope_'\]"]
            set MH3 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_MH_z0_'\]"]
            set MH4 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_MH_t0_'\]"]
            set MH5 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_MH_z1_'\]"]
            set MH6 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_MH_t1_'\]"]
            set MH7 [get_domnode_attribute $node v]
            if {$MH1 == "x"} {
              if {$MH2 == "x"} {
                GiD_WriteCalculationFile puts "$group_name, u1, 1, $MH3, $MH4, $MH5, $MH6, $MH7"
              } elseif {$MH2 == "y"} {
                GiD_WriteCalculationFile puts "$group_name, u1, 2, $MH3, $MH4, $MH5, $MH6, $MH7"
              } elseif {$MH2 == "z"} {
                GiD_WriteCalculationFile puts "$group_name, u1, 3, $MH3, $MH4, $MH5, $MH6, $MH7"
              }
            } elseif {$MH1 == "y"} {
              if {$MH1 == "x"} {
                  GiD_WriteCalculationFile puts "$group_name, u2, 1, $MH3, $MH4, $MH5, $MH6, $MH7"
              } elseif {$MH2 == "y"} {
                  GiD_WriteCalculationFile puts "$group_name, u2, 2, $MH3, $MH4, $MH5, $MH6, $MH7"
              } elseif {$MH2 == "z"} {
                  GiD_WriteCalculationFile puts "$group_name, u2, 3, $MH3, $MH4, $MH5, $MH6, $MH7"
              }
            } elseif {$MH1 == "z"} {
              if {$MH2 == "x"} {
                  GiD_WriteCalculationFile puts "$group_name, u3, 1, $MH3, $MH4, $MH5, $MH6, $MH7"
              } elseif {$MH2 == "y"} {
                  GiD_WriteCalculationFile puts "$group_name, u3, 2, $MH3, $MH4, $MH5, $MH6, $MH7"
              } elseif {$MH2 == "z"} {
                  GiD_WriteCalculationFile puts "$group_name, u3, 3, $MH3, $MH4, $MH5, $MH6, $MH7"
              }
            }
          }
        } elseif {$cons == "No"} {
          set node [$group selectNodes "./value\[@n = '_amplitude_'\]"]
          set amplname [get_domnode_attribute $node v]
          if {$type == "None"} {
            GiD_WriteCalculationFile puts "*Boundary-Flexible, amplitude=$amplname"
            set node [$group selectNodes "./value\[@n = '_x_'\]"]
            set bc_magnitudex [get_domnode_attribute $node v]
            if {$bc_magnitudex == "free"} {
            } elseif {$bc_magnitudex == "fixed"} {
              GiD_WriteCalculationFile puts "$group_name, u1, 0"
            } else {
              set node [$group selectNodes "./value\[@n = '_xp_'\]"]
              set bc_magnitudexp [get_domnode_attribute $node v]
              GiD_WriteCalculationFile puts "$group_name, u1, $bc_magnitudexp"
            }
            set node [$group selectNodes "./value\[@n = '_y_'\]"]
            set bc_magnitudey [get_domnode_attribute $node v]
            if {$bc_magnitudey == "free"} {
            } elseif {$bc_magnitudey == "fixed"} {
              GiD_WriteCalculationFile puts "$group_name, u2, 0"
            } else {
              set node [$group selectNodes "./value\[@n = '_yp_'\]"]
              set bc_magnitudeyp [get_domnode_attribute $node v]
              GiD_WriteCalculationFile puts "$group_name, u2, $bc_magnitudeyp"
            }
            set node [$group selectNodes "./value\[@n = '_z_'\]"]
            set bc_magnitudez [get_domnode_attribute $node v]
            if {$bc_magnitudez == "free"} {
            } elseif {$bc_magnitudez == "fixed"} {
              GiD_WriteCalculationFile puts "$group_name, u3, 0"
            } else {
              set node [$group selectNodes "./value\[@n = '_zp_'\]"]
              set bc_magnitudezp [get_domnode_attribute $node v]
              GiD_WriteCalculationFile puts "$group_name, u3, $bc_magnitudezp"
            }			
          } elseif {$type == "Moving hydrostatic"} {
            GiD_WriteCalculationFile puts "*Boundary-Flexible, amplitude=$amplname, type=Moving-hydrostatic"
            set node [$group selectNodes "./value\[@n = '_MH_dir_'\]"]
            set MH1 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_MH_impliment_dir_'\]"]
            set MH2 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_MH_slope_'\]"]
            set MH3 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_MH_z0_'\]"]
            set MH4 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_MH_t0_'\]"]
            set MH5 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_MH_z1_'\]"]
            set MH6 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_MH_t1_'\]"]
            set MH7 [get_domnode_attribute $node v]
            if {$MH1 == "x"} {
              if {$MH2 == "x"} {
                GiD_WriteCalculationFile puts "$group_name, u1, 1, $MH3, $MH4, $MH5, $MH6, $MH7"
              } elseif {$MH2 == "y"} {
                GiD_WriteCalculationFile puts "$group_name, u1, 2, $MH3, $MH4, $MH5, $MH6, $MH7"
              } elseif {$MH2 == "z"} {
                GiD_WriteCalculationFile puts "$group_name, u1, 3, $MH3, $MH4, $MH5, $MH6, $MH7"
              }
            } elseif {$MH1 == "y"} {
              if {$MH1 == "x"} {
                  GiD_WriteCalculationFile puts "$group_name, u2, 1, $MH3, $MH4, $MH5, $MH6, $MH7"
              } elseif {$MH2 == "y"} {
                  GiD_WriteCalculationFile puts "$group_name, u2, 2, $MH3, $MH4, $MH5, $MH6, $MH7"
              } elseif {$MH2 == "z"} {
                  GiD_WriteCalculationFile puts "$group_name, u2, 3, $MH3, $MH4, $MH5, $MH6, $MH7"
              }
            } elseif {$MH1 == "z"} {
              if {$MH2 == "x"} {
                  GiD_WriteCalculationFile puts "$group_name, u3, 1, $MH3, $MH4, $MH5, $MH6, $MH7"
              } elseif {$MH2 == "y"} {
                  GiD_WriteCalculationFile puts "$group_name, u3, 2, $MH3, $MH4, $MH5, $MH6, $MH7"
              } elseif {$MH2 == "z"} {
                  GiD_WriteCalculationFile puts "$group_name, u3, 3, $MH3, $MH4, $MH5, $MH6, $MH7"
              }
            }
          }
        }
      }
	  
      #
      # Boundary conditions applied to the solid rotation
      #
      
      set xp "./container\[@n='_boundary_conditions_'\]/container\[@n='_flexible_BC_'\]/condition\[@n='_solid_rotate_'\]/group"
      set groups [$istep selectNodes $xp]
      foreach group $groups {
        set group_name [get_domnode_attribute $group n]
        set node [$group selectNodes "./value\[@n = '_none_moving_'\]"]
        set type [get_domnode_attribute $node v]
        set node [$group selectNodes "./value\[@n = '_constant_'\]"]
        set cons [get_domnode_attribute $node v]
        if {$cons == "Yes"} {
          if {$type == "None"} {
            GiD_WriteCalculationFile puts "*Boundary-Flexible"
            set node [$group selectNodes "./value\[@n = '_rotation_x_'\]"]
            set bc_magnitudex [get_domnode_attribute $node v]
            if {$bc_magnitudex == "free"} {
            } elseif {$bc_magnitudex == "fixed"} {
              GiD_WriteCalculationFile puts "$group_name, r1, 0"
            } else {
              set node [$group selectNodes "./value\[@n = '_rotate_xp_'\]"]
              set bc_magnitudexp [get_domnode_attribute $node v]
              GiD_WriteCalculationFile puts "$group_name, r1, $bc_magnitudexp"
            }
            set node [$group selectNodes "./value\[@n = '_rotation_y_'\]"]
            set bc_magnitudey [get_domnode_attribute $node v]
            if {$bc_magnitudey == "free"} {
            } elseif {$bc_magnitudey == "fixed"} {
              GiD_WriteCalculationFile puts "$group_name, r2, 0"
            } else {
              set node [$group selectNodes "./value\[@n = '_rotate_yp_'\]"]
              set bc_magnitudeyp [get_domnode_attribute $node v]
              GiD_WriteCalculationFile puts "$group_name, r2, $bc_magnitudeyp"
            }
            set node [$group selectNodes "./value\[@n = '_rotation_z_'\]"]
            set bc_magnitudez [get_domnode_attribute $node v]
            if {$bc_magnitudez == "free"} {
            } elseif {$bc_magnitudez == "fixed"} {
              GiD_WriteCalculationFile puts "$group_name, r3, 0"
            } else {
              set node [$group selectNodes "./value\[@n = '_rotate_zp_'\]"]
              set bc_magnitudezp [get_domnode_attribute $node v]
              GiD_WriteCalculationFile puts "$group_name, r3, $bc_magnitudezp"
            }
          } elseif {$type == "Moving hydrostatic"} {
            GiD_WriteCalculationFile puts "*Boundary-Flexible, type=Moving-hydrostatic"
            set node [$group selectNodes "./value\[@n = '_MH_dir_'\]"]
            set MH1 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_MH_impliment_dir_'\]"]
            set MH2 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_MH_slope_'\]"]
            set MH3 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_MH_z0_'\]"]
            set MH4 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_MH_t0_'\]"]
            set MH5 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_MH_z1_'\]"]
            set MH6 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_MH_t1_'\]"]
            set MH7 [get_domnode_attribute $node v]
            if {$MH1 == "x"} {
              if {$MH2 == "x"} {
                GiD_WriteCalculationFile puts "$group_name, r1, 1, $MH3, $MH4, $MH5, $MH6, $MH7"
              } elseif {$MH2 == "y"} {
                GiD_WriteCalculationFile puts "$group_name, r1, 2, $MH3, $MH4, $MH5, $MH6, $MH7"
              } elseif {$MH2 == "z"} {
                GiD_WriteCalculationFile puts "$group_name, r1, 3, $MH3, $MH4, $MH5, $MH6, $MH7"
              }
            } elseif {$MH1 == "y"} {
              if {$MH1 == "x"} {
                  GiD_WriteCalculationFile puts "$group_name, r2, 1, $MH3, $MH4, $MH5, $MH6, $MH7"
              } elseif {$MH2 == "y"} {
                  GiD_WriteCalculationFile puts "$group_name, r2, 2, $MH3, $MH4, $MH5, $MH6, $MH7"
              } elseif {$MH2 == "z"} {
                  GiD_WriteCalculationFile puts "$group_name, r2, 3, $MH3, $MH4, $MH5, $MH6, $MH7"
              }
            } elseif {$MH1 == "z"} {
              if {$MH2 == "x"} {
                  GiD_WriteCalculationFile puts "$group_name, r3, 1, $MH3, $MH4, $MH5, $MH6, $MH7"
              } elseif {$MH2 == "y"} {
                  GiD_WriteCalculationFile puts "$group_name, r3, 2, $MH3, $MH4, $MH5, $MH6, $MH7"
              } elseif {$MH2 == "z"} {
                  GiD_WriteCalculationFile puts "$group_name, r3, 3, $MH3, $MH4, $MH5, $MH6, $MH7"
              }
            }
          }
        } elseif {$cons == "No"} {
          set node [$group selectNodes "./value\[@n = '_amplitude_'\]"]
          set amplname [get_domnode_attribute $node v]
          if {$type == "None"} {
            GiD_WriteCalculationFile puts "*Boundary-Flexible, amplitude=$amplname"
            set node [$group selectNodes "./value\[@n = '_rotation_x_'\]"]
            set bc_magnitudex [get_domnode_attribute $node v]
            if {$bc_magnitudex == "free"} {
            } elseif {$bc_magnitudex == "fixed"} {
              GiD_WriteCalculationFile puts "$group_name, r1, 0"
            } else {
              set node [$group selectNodes "./value\[@n = '_rotate_xp_'\]"]
              set bc_magnitudexp [get_domnode_attribute $node v]
              GiD_WriteCalculationFile puts "$group_name, r1, $bc_magnitudexp"
            }
            set node [$group selectNodes "./value\[@n = '_rotation_y_'\]"]
            set bc_magnitudey [get_domnode_attribute $node v]
            if {$bc_magnitudey == "free"} {
            } elseif {$bc_magnitudey == "fixed"} {
              GiD_WriteCalculationFile puts "$group_name, r2, 0"
            } else {
              set node [$group selectNodes "./value\[@n = '_rotate_yp_'\]"]
              set bc_magnitudeyp [get_domnode_attribute $node v]
              GiD_WriteCalculationFile puts "$group_name, r2, $bc_magnitudeyp"
            }
            set node [$group selectNodes "./value\[@n = '_rotation_z_'\]"]
            set bc_magnitudez [get_domnode_attribute $node v]
            if {$bc_magnitudez == "free"} {
            } elseif {$bc_magnitudez == "fixed"} {
              GiD_WriteCalculationFile puts "$group_name, r3, 0"
            } else {
              set node [$group selectNodes "./value\[@n = '_rotate_zp_'\]"]
              set bc_magnitudezp [get_domnode_attribute $node v]
              GiD_WriteCalculationFile puts "$group_name, r3, $bc_magnitudezp"
            }
          } elseif {$type == "Moving hydrostatic"} {
            GiD_WriteCalculationFile puts "*Boundary-Flexible, amplitude=$amplname, type=Moving-hydrostatic"
            set node [$group selectNodes "./value\[@n = '_MH_dir_'\]"]
            set MH1 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_MH_impliment_dir_'\]"]
            set MH2 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_MH_slope_'\]"]
            set MH3 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_MH_z0_'\]"]
            set MH4 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_MH_t0_'\]"]
            set MH5 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_MH_z1_'\]"]
            set MH6 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_MH_t1_'\]"]
            set MH7 [get_domnode_attribute $node v]
            if {$MH1 == "x"} {
              if {$MH2 == "x"} {
                GiD_WriteCalculationFile puts "$group_name, r1, 1, $MH3, $MH4, $MH5, $MH6, $MH7"
              } elseif {$MH2 == "y"} {
                GiD_WriteCalculationFile puts "$group_name, r1, 2, $MH3, $MH4, $MH5, $MH6, $MH7"
              } elseif {$MH2 == "z"} {
                GiD_WriteCalculationFile puts "$group_name, r1, 3, $MH3, $MH4, $MH5, $MH6, $MH7"
              }
            } elseif {$MH1 == "y"} {
              if {$MH1 == "x"} {
                  GiD_WriteCalculationFile puts "$group_name, r2, 1, $MH3, $MH4, $MH5, $MH6, $MH7"
              } elseif {$MH2 == "y"} {
                  GiD_WriteCalculationFile puts "$group_name, r2, 2, $MH3, $MH4, $MH5, $MH6, $MH7"
              } elseif {$MH2 == "z"} {
                  GiD_WriteCalculationFile puts "$group_name, r2, 3, $MH3, $MH4, $MH5, $MH6, $MH7"
              }
            } elseif {$MH1 == "z"} {
              if {$MH2 == "x"} {
                  GiD_WriteCalculationFile puts "$group_name, r3, 1, $MH3, $MH4, $MH5, $MH6, $MH7"
              } elseif {$MH2 == "y"} {
                  GiD_WriteCalculationFile puts "$group_name, r3, 2, $MH3, $MH4, $MH5, $MH6, $MH7"
              } elseif {$MH2 == "z"} {
                  GiD_WriteCalculationFile puts "$group_name, r3, 3, $MH3, $MH4, $MH5, $MH6, $MH7"
              }
            }
          }
        }
      }
	  
      #
      # Boundary conditions applied to the pore water pressure
      #
      
      set xp "./container\[@n='_boundary_conditions_'\]/container\[@n='_flexible_BC_'\]/condition\[@n='_pwp_'\]/group"
      set groups [$istep selectNodes $xp]
      foreach group $groups {
        set group_name [get_domnode_attribute $group n]
        set node [$group selectNodes "./value\[@n = '_none_moving_'\]"]
        set type [get_domnode_attribute $node v]
        set node [$group selectNodes "./value\[@n = '_constant_'\]"]
        set cons [get_domnode_attribute $node v]
        if {$cons == "Yes"} {
          if {$type == "None"} {
            GiD_WriteCalculationFile puts "*Boundary-Flexible"
            set node [$group selectNodes "./value\[@n = '_mag_'\]"]
            set val_wp1 [get_domnode_attribute $node v]
            GiD_WriteCalculationFile puts "$group_name, pw, $val_wp1"
          } elseif {$type == "Moving hydrostatic"} {
            GiD_WriteCalculationFile puts "*Boundary-Flexible, type=Moving-hydrostatic"
            set node [$group selectNodes "./value\[@n = '_MH_impliment_dir_'\]"]
            set MH2 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_MH_slope_'\]"]
            set MH3 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_MH_z0_'\]"]
            set MH4 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_MH_t0_'\]"]
            set MH5 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_MH_z1_'\]"]
            set MH6 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_MH_t1_'\]"]
            set MH7 [get_domnode_attribute $node v]
            if {$MH2 == "x"} {
              GiD_WriteCalculationFile puts "$group_name, pw, 1, $MH3, $MH4, $MH5, $MH6, $MH7"
            } elseif {$MH2 == "y"} {
              GiD_WriteCalculationFile puts "$group_name, pw, 2, $MH3, $MH4, $MH5, $MH6, $MH7"
            } elseif {$MH2 == "z"} {
              GiD_WriteCalculationFile puts "$group_name, pw, 3, $MH3, $MH4, $MH5, $MH6, $MH7"
            }
          } 
        } elseif {$cons == "No"} {
          if {$type == "None"} {
            set node [$group selectNodes "./value\[@n = '_amplitude_'\]"]
            set amplname [get_domnode_attribute $node v]
            GiD_WriteCalculationFile puts "*Boundary-Flexible, amplitude=$amplname"
            set node [$group selectNodes "./value\[@n = '_mag_'\]"]
            set val_wp1 [get_domnode_attribute $node v]
            GiD_WriteCalculationFile puts "$group_name, pw, $val_wp1"
          } elseif {$type == "Moving hydrostatic"} {
            GiD_WriteCalculationFile puts "*Boundary-Flexible, amplitude=$amplname, type=Moving-hydrostatic"
            set node [$group selectNodes "./value\[@n = '_MH_impliment_dir_'\]"]
            set MH2 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_MH_slope_'\]"]
            set MH3 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_MH_z0_'\]"]
            set MH4 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_MH_t0_'\]"]
            set MH5 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_MH_z1_'\]"]
            set MH6 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_MH_t1_'\]"]
            set MH7 [get_domnode_attribute $node v]
            if {$MH2 == "x"} {
              GiD_WriteCalculationFile puts "$group_name, pw, 1, $MH3, $MH4, $MH5, $MH6, $MH7"
            } elseif {$MH2 == "y"} {
              GiD_WriteCalculationFile puts "$group_name, pw, 2, $MH3, $MH4, $MH5, $MH6, $MH7"
            } elseif {$MH2 == "z"} {
              GiD_WriteCalculationFile puts "$group_name, pw, 3, $MH3, $MH4, $MH5, $MH6, $MH7"
            }
          }
        }
      }
  
      #
      # Boundary conditions pore air pressure
      #
      
      set xp "./container\[@n='_boundary_conditions_'\]/container\[@n='_flexible_BC_'\]/condition\[@n='_pap_'\]/group"
      set groups [$istep selectNodes $xp]
      foreach group $groups {
        set group_name [get_domnode_attribute $group n]
        set node [$group selectNodes "./value\[@n = '_none_moving_'\]"]
        set type [get_domnode_attribute $node v]
        set node [$group selectNodes "./value\[@n = '_constant_'\]"]
        set cons [get_domnode_attribute $node v]
        if {$cons == "Yes"} {
          if {$type == "None"} {
            GiD_WriteCalculationFile puts "*Boundary-Flexible"
            set node [$group selectNodes "./value\[@n = '_mag_'\]"]
            set val_wp1 [get_domnode_attribute $node v]
            GiD_WriteCalculationFile puts "$group_name, pa, $val_wp1"
          } elseif {$type == "Moving hydrostatic"} {
            GiD_WriteCalculationFile puts "*Boundary-Flexible, type=Moving-hydrostatic"
            set node [$group selectNodes "./value\[@n = '_MH_impliment_dir_'\]"]
            set MH2 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_MH_slope_'\]"]
            set MH3 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_MH_z0_'\]"]
            set MH4 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_MH_t0_'\]"]
            set MH5 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_MH_z1_'\]"]
            set MH6 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_MH_t1_'\]"]
            set MH7 [get_domnode_attribute $node v]
            if {$MH2 == "x"} {
              GiD_WriteCalculationFile puts "$group_name, pa, 1, $MH3, $MH4, $MH5, $MH6, $MH7"
            } elseif {$MH2 == "y"} {
              GiD_WriteCalculationFile puts "$group_name, pa, 2, $MH3, $MH4, $MH5, $MH6, $MH7"
            } elseif {$MH2 == "z"} {
              GiD_WriteCalculationFile puts "$group_name, pa, 3, $MH3, $MH4, $MH5, $MH6, $MH7"
            }
          } 
        } elseif {$cons == "No"} {
          set node [$group selectNodes "./value\[@n = '_amplitude_'\]"]
          set amplname [get_domnode_attribute $node v]
          if {$type == "None"} {
            GiD_WriteCalculationFile puts "*Boundary-Flexible, amplitude=$amplname"
            set node [$group selectNodes "./value\[@n = '_mag_'\]"]
            set val_wp1 [get_domnode_attribute $node v]
            GiD_WriteCalculationFile puts "$group_name, pa, $val_wp1"
          } elseif {$type == "Moving hydrostatic"} {
            GiD_WriteCalculationFile puts "*Boundary-Flexible, amplitude=$amplname, type=Moving-hydrostatic"
            set node [$group selectNodes "./value\[@n = '_MH_impliment_dir_'\]"]
            set MH2 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_MH_slope_'\]"]
            set MH3 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_MH_z0_'\]"]
            set MH4 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_MH_t0_'\]"]
            set MH5 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_MH_z1_'\]"]
            set MH6 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_MH_t1_'\]"]
            set MH7 [get_domnode_attribute $node v]
            if {$MH2 == "x"} {
              GiD_WriteCalculationFile puts "$group_name, pa, 1, $MH3, $MH4, $MH5, $MH6, $MH7"
            } elseif {$MH2 == "y"} {
              GiD_WriteCalculationFile puts "$group_name, pa, 2, $MH3, $MH4, $MH5, $MH6, $MH7"
            } elseif {$MH2 == "z"} {
              GiD_WriteCalculationFile puts "$group_name, pa, 3, $MH3, $MH4, $MH5, $MH6, $MH7"
            }
          }
        }
      }
  
      #
      # Boundary conditions applied to the water phase
      #
      
      set xp "./container\[@n='_boundary_conditions_'\]/container\[@n='_flexible_BC_'\]/condition\[@n='_water_'\]/group"
      set groups [$istep selectNodes $xp]
      foreach group $groups {
        set group_name [get_domnode_attribute $group n]
        set node [$group selectNodes "./value\[@n = '_none_moving_'\]"]
        set type [get_domnode_attribute $node v]
        set node [$group selectNodes "./value\[@n = '_constant_'\]"]
        set cons [get_domnode_attribute $node v]
        if {$cons == "Yes"} {
          if {$type == "None"} {
            GiD_WriteCalculationFile puts "*Boundary-Flexible"
            set node [$group selectNodes "./value\[@n = '_direction_'\]"]
            set bc_magnitudex [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_value_'\]"]
            set wdx1 [get_domnode_attribute $node v]
            if {$bc_magnitudex == "w1"} {
              GiD_WriteCalculationFile puts "$group_name, w1, $wdx1"
            } elseif {$bc_magnitudex == "w2"} {
              GiD_WriteCalculationFile puts "$group_name, w2, $wdx1"
            } elseif {$bc_magnitudex == "w3"} {
              GiD_WriteCalculationFile puts "$group_name, w3, $wdx1"
            }  
          } elseif {$type == "Moving hydrostatic"} {
            GiD_WriteCalculationFile puts "*Boundary-Flexible, type=Moving-hydrostatic"
            set node [$group selectNodes "./value\[@n = '_MH_dir_'\]"]
            set MH1 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_MH_impliment_dir_'\]"]
            set MH2 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_MH_slope_'\]"]
            set MH3 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_MH_z0_'\]"]
            set MH4 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_MH_t0_'\]"]
            set MH5 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_MH_z1_'\]"]
            set MH6 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_MH_t1_'\]"]
            set MH7 [get_domnode_attribute $node v]
            if {$MH1 == "x"} {
              if {$MH2 == "x"} {
                GiD_WriteCalculationFile puts "$group_name, w1, 1, $MH3, $MH4, $MH5, $MH6, $MH7"
              } elseif {$MH2 == "y"} {
                GiD_WriteCalculationFile puts "$group_name, w1, 2, $MH3, $MH4, $MH5, $MH6, $MH7"
              } elseif {$MH2 == "z"} {
                GiD_WriteCalculationFile puts "$group_name, w1, 3, $MH3, $MH4, $MH5, $MH6, $MH7"
              }
            } elseif {$MH1 == "y"} {
              if {$MH1 == "x"} {
                GiD_WriteCalculationFile puts "$group_name, w2, 1, $MH3, $MH4, $MH5, $MH6, $MH7"
              } elseif {$MH2 == "y"} {
                GiD_WriteCalculationFile puts "$group_name, w2, 2, $MH3, $MH4, $MH5, $MH6, $MH7"
              } elseif {$MH2 == "z"} {
                GiD_WriteCalculationFile puts "$group_name, w2, 3, $MH3, $MH4, $MH5, $MH6, $MH7"
              }
            } elseif {$MH1 == "z"} {
              if {$MH2 == "x"} {
                GiD_WriteCalculationFile puts "$group_name, w3, 1, $MH3, $MH4, $MH5, $MH6, $MH7"
              } elseif {$MH2 == "y"} {
                GiD_WriteCalculationFile puts "$group_name, w3, 2, $MH3, $MH4, $MH5, $MH6, $MH7"
              } elseif {$MH2 == "z"} {
                GiD_WriteCalculationFile puts "$group_name, w3, 3, $MH3, $MH4, $MH5, $MH6, $MH7"
              }
            }
          }	  
        } elseif {$cons == "No"} {
          set node [$group selectNodes "./value\[@n = '_amplitude_'\]"]
          set amplname [get_domnode_attribute $node v]
          if {$type == "None"} {
            GiD_WriteCalculationFile puts "*Boundary-Flexible, amplitude=$amplname"
            set node [$group selectNodes "./value\[@n = '_direction_'\]"]
            set bc_magnitudex [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_value_'\]"]
            set wdx1 [get_domnode_attribute $node v]
            if {$bc_magnitudex == "w1"} {
              GiD_WriteCalculationFile puts "$group_name, w1, $wdx1"
            } elseif {$bc_magnitudex == "w2"} {
              GiD_WriteCalculationFile puts "$group_name, w2, $wdx1"
            } elseif {$bc_magnitudex == "w3"} {
              GiD_WriteCalculationFile puts "$group_name, w3, $wdx1"
            }  
          } elseif {$type == "Moving hydrostatic"} {
            GiD_WriteCalculationFile puts "*Boundary-Flexible, amplitude=$amplname, type=Moving-hydrostatic"
            set node [$group selectNodes "./value\[@n = '_MH_dir_'\]"]
            set MH1 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_MH_impliment_dir_'\]"]
            set MH2 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_MH_slope_'\]"]
            set MH3 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_MH_z0_'\]"]
            set MH4 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_MH_t0_'\]"]
            set MH5 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_MH_z1_'\]"]
            set MH6 [get_domnode_attribute $node v]
            set node [$group selectNodes "./value\[@n = '_MH_t1_'\]"]
            set MH7 [get_domnode_attribute $node v]
            if {$MH1 == "x"} {
              if {$MH2 == "x"} {
                GiD_WriteCalculationFile puts "$group_name, w1, 1, $MH3, $MH4, $MH5, $MH6, $MH7"
              } elseif {$MH2 == "y"} {
                GiD_WriteCalculationFile puts "$group_name, w1, 2, $MH3, $MH4, $MH5, $MH6, $MH7"
              } elseif {$MH2 == "z"} {
                GiD_WriteCalculationFile puts "$group_name, w1, 3, $MH3, $MH4, $MH5, $MH6, $MH7"
              }
            } elseif {$MH1 == "y"} {
              if {$MH1 == "x"} {
                GiD_WriteCalculationFile puts "$group_name, w2, 1, $MH3, $MH4, $MH5, $MH6, $MH7"
              } elseif {$MH2 == "y"} {
                GiD_WriteCalculationFile puts "$group_name, w2, 2, $MH3, $MH4, $MH5, $MH6, $MH7"
              } elseif {$MH2 == "z"} {
                GiD_WriteCalculationFile puts "$group_name, w2, 3, $MH3, $MH4, $MH5, $MH6, $MH7"
              }
            } elseif {$MH1 == "z"} {
              if {$MH2 == "x"} {
                GiD_WriteCalculationFile puts "$group_name, w3, 1, $MH3, $MH4, $MH5, $MH6, $MH7"
              } elseif {$MH2 == "y"} {
                GiD_WriteCalculationFile puts "$group_name, w3, 2, $MH3, $MH4, $MH5, $MH6, $MH7"
              } elseif {$MH2 == "z"} {
                GiD_WriteCalculationFile puts "$group_name, w3, 3, $MH3, $MH4, $MH5, $MH6, $MH7"
              }
            }
          }
        }
      }

      #
      # Constraints - Equal Degree of Freedom (EqualDOF)
      #
      
      set xp "./container\[@n='_constraints_'\]/condition\[@n='_equal_dof_'\]/groupList"
      set groupLists [$istep selectNodes $xp]
      foreach groupList $groupLists {
        set xp2 "./group"
        set groups [$groupList selectNodes $xp2]
        set names {}
        foreach group $groups {
          set name [get_domnode_attribute $group n]
          lappend names $name
        }
        set master_set [lindex $names 0]
        set slave_set [lindex $names 1]
        GiD_WriteCalculationFile puts "*Equation, type=Equal DOF"
        set node [$groupList selectNodes "./value\[@n = '_dof_'\]"]
        set dof [get_domnode_attribute $node v]
        set node [$groupList selectNodes "./value\[@n = '_penalty_'\]"]
        set penalty [get_domnode_attribute $node v]
        GiD_WriteCalculationFile puts "*Penalty = $penalty"
        GiD_WriteCalculationFile puts "$master_set, $slave_set, $dof"
      }  
      
      #
      # Model change
      #
      set xp "./container\[@n='_model_change_'\]/condition\[@n='_model_change_m_'\]/group"
      set groups [$istep selectNodes $xp]
      foreach group $groups {
        set group_name [get_domnode_attribute $group n]
        set node [$group selectNodes "./value\[@n = '_method_'\]"]
        set Method [get_domnode_attribute $node v]
        set node [$group selectNodes "./value\[@n = '_material_'\]"]
        set material_name [get_domnode_attribute $node v]
        if {$Method == "...select..."} {
        } elseif {$Method == "Material"} {
          GiD_WriteCalculationFile puts "*Model change, Material" 
          GiD_WriteCalculationFile puts "$group_name, $material_name" 
        }
      }
      
      #
      # Save reaction
      #
      set xp "./container\[@n='_Rec_for_'\]/condition\[@n='_reaction_forces_'\]/group"
      set groups [$istep selectNodes $xp]
      foreach group $groups {
        set group_name [get_domnode_attribute $group n]
        set node [$group selectNodes "./value\[@n = '_x_di_'\]"]
        set x_di [get_domnode_attribute $node v]
        if {$x_di == "Yes"} {
          GiD_WriteCalculationFile puts "*SAVE Reaction force"
          GiD_WriteCalculationFile puts "$group_name, 1" 
        } else {}
        set node [$group selectNodes "./value\[@n = '_y_di_'\]"]
        set y_di [get_domnode_attribute $node v]
        if {$y_di == "Yes"} {
          GiD_WriteCalculationFile puts "*SAVE Reaction force"
          GiD_WriteCalculationFile puts "$group_name, 2" 
        } else {}
        set node [$group selectNodes "./value\[@n = '_z_di_'\]"]
        set z_di [get_domnode_attribute $node v]
        if {$z_di == "Yes"} {
          GiD_WriteCalculationFile puts "*SAVE Reaction force"
          GiD_WriteCalculationFile puts "$group_name, 3" 
        } else {}
      }
  
      #
      # Save reaction
      #
      set xp "./container\[@n='_Rec_for_'\]/condition\[@n='_USRfo_'\]/group"
      set groups [$istep selectNodes $xp]
      foreach group $groups {
        set group_name [get_domnode_attribute $group n]
        set node [$group selectNodes "./value\[@n = '_USRx_di_'\]"]
        set Ux_di [get_domnode_attribute $node v]
        if {$Ux_di == "Yes"} {
          set node [$group selectNodes "./value\[@n = '_loading_rate1_'\]"]
          set lr_1 [get_domnode_attribute $node v]
          if {$lr_1 == "instant"} {
            GiD_WriteCalculationFile puts "*Reaction force, instant"
            GiD_WriteCalculationFile puts "$group_name, 1" 
          } elseif {$lr_1 == "amplitude"} {
            set node [$group selectNodes "./value\[@n = '_amplitude1_'\]"]
            set amplname [get_domnode_attribute $node v]
            GiD_WriteCalculationFile puts "*Reaction force, amplitude=$amplname"
            GiD_WriteCalculationFile puts "$group_name, 1" 
          }
        }
        set node [$group selectNodes "./value\[@n = '_USRy_di_'\]"]
        set Uy_di [get_domnode_attribute $node v]
        if {$Uy_di == "Yes"} {
          set node [$group selectNodes "./value\[@n = '_loading_rate2_'\]"]
          set lr_2 [get_domnode_attribute $node v]
          if {$lr_2 == "instant"} {
            GiD_WriteCalculationFile puts "*Reaction force, instant"
            GiD_WriteCalculationFile puts "$group_name, 2" 
          } elseif {$lr_2 == "amplitude"} {
            set node [$group selectNodes "./value\[@n = '_amplitude1_'\]"]
            set amplname [get_domnode_attribute $node v]
            GiD_WriteCalculationFile puts "*Reaction force, amplitude=$amplname"
            GiD_WriteCalculationFile puts "$group_name, 2" 
          }
        }
        set node [$group selectNodes "./value\[@n = '_USRz_di_'\]"]
        set Uz_di [get_domnode_attribute $node v]
        if {$Uz_di == "Yes"} {
          set node [$group selectNodes "./value\[@n = '_loading_rate3_'\]"]
          set lr_3 [get_domnode_attribute $node v]
          if {$lr_3 == "instant"} {
            GiD_WriteCalculationFile puts "*Reaction force, instant"
            GiD_WriteCalculationFile puts "$group_name, 3" 
          } elseif {$lr_3 == "amplitude"} {
            set node [$group selectNodes "./value\[@n = '_amplitude3_'\]"]
            set amplname [get_domnode_attribute $node v]
            GiD_WriteCalculationFile puts "*Reaction force, amplitude=$amplname"
            GiD_WriteCalculationFile puts "$group_name, 3" 
          }
        }
      }
      
      #
      # User Boundary conditions
      #
      set xp "./container\[@n='_boundary_conditions_'\]/condition\[@n='_Uboundary_'\]/group"
      set groups [$istep selectNodes $xp]
      foreach group $groups {
        set group_name [get_domnode_attribute $group n]
        set node [$group selectNodes "./value\[@n = '_sl_pw_'\]"]
        set Ubound [get_domnode_attribute $node v]
        set node [$group selectNodes "./value\[@n = '_val_'\]"]
        set val [get_domnode_attribute $node v]
        if {$Ubound == "...select.."} {
        } elseif {$Ubound == "Displacement in x-direction"} {
          GiD_WriteCalculationFile puts "*Uboundary"
          GiD_WriteCalculationFile puts "$group_name, u1, $val"
        } elseif {$Ubound == "Displacement in y-direction"} {
          GiD_WriteCalculationFile puts "*Uboundary"
          GiD_WriteCalculationFile puts "$group_name, u2, $val"
        } elseif {$Ubound == "Displacement in z-direction"} {
          GiD_WriteCalculationFile puts "*Uboundary"
          GiD_WriteCalculationFile puts "$group_name, u3, $val"
        } elseif {$Ubound == "Pore-water pressure"} {
          GiD_WriteCalculationFile puts "*Uboundary"
          GiD_WriteCalculationFile puts "$group_name, pw, $val"
        } elseif {$Ubound == "Pore-air pressure"} {
          GiD_WriteCalculationFile puts "*Uboundary"
          GiD_WriteCalculationFile puts "$group_name, pa, $val"
        } elseif {$Ubound == "Water displacement in x-direction"} {
          GiD_WriteCalculationFile puts "*Uboundary"
          GiD_WriteCalculationFile puts "$group_name, w1, $val"
        } elseif {$Ubound == "Water displacement in y-direction"} {
          GiD_WriteCalculationFile puts "*Uboundary"
          GiD_WriteCalculationFile puts "$group_name, w2, $val"
        } elseif {$Ubound == "Water displacement in z-direction"} {
          GiD_WriteCalculationFile puts "*Uboundary"
          GiD_WriteCalculationFile puts "$group_name, w3, $val"
        } 
      }
  
      #
      # Loads (von Neumann BCs)
      #
      
      # Drainage
      set xp "./container\[@n='_loads_'\]/condition\[@n='_drain_'\]/group"
      set groups [$istep selectNodes $xp]
      foreach group $groups {
        set group_name [get_domnode_attribute $group n]
        set node [$group selectNodes "./value\[@n = '_factor_'\]"]
        set factor [get_domnode_attribute $node v]
        set node [$group selectNodes "./value\[@n = '_water_weight_'\]"]
        set weight [get_domnode_attribute $node v]
        set node [$group selectNodes "./value\[@n = '_conductivity_'\]"]
        set conductivity [get_domnode_attribute $node v]
        set drain_mag [expr $factor * $conductivity / $weight]
        GiD_WriteCalculationFile puts "*DSload, instant"
        GiD_WriteCalculationFile puts "$group_name, drainage-w, $drain_mag"
      }
      
      # Body/Gravitational forces
      set xp "./container\[@n='_loads_'\]/condition\[@n='_gravity_'\]/group"
      set groups [$istep selectNodes $xp]
      foreach group $groups {
        set group_name [get_domnode_attribute $group n]
        set node [$group selectNodes "./value\[@n = '_loading_rate_'\]"]
        set loading_rate [get_domnode_attribute $node v]
        set node [$group selectNodes "./value\[@n = '_value_'\]"]
        set magnitude [get_domnode_attribute $node v]
        set node [$group selectNodes "./value\[@n = '_direction_'\]"]
        set direction [get_domnode_attribute $node v]
        if {$loading_rate == "instant"} {
          GiD_WriteCalculationFile puts "*Body force, instant"
          GiD_WriteCalculationFile puts "$group_name, Grav, $magnitude, $direction"
        } elseif {$loading_rate == "amplitude"} {
          set node [$group selectNodes "./value\[@n = '_amplitude_'\]"]
          set amplname [get_domnode_attribute $node v]
          GiD_WriteCalculationFile puts "*Body force, amplitude=$amplname"
          GiD_WriteCalculationFile puts "$group_name, Grav, $magnitude, $direction"
        }
      }
      
      # pressure acting normal to the surface/line
      set xp "./container\[@n='_loads_'\]/condition\[@n='_surface_pressure_'\]/group"
      set groups [$istep selectNodes $xp]
      foreach group $groups {
        set group_name [get_domnode_attribute $group n]
        set node [$group selectNodes "./value\[@n = '_loading_rate_'\]"]
        set loading_rate [get_domnode_attribute $node v]
        if {$loading_rate == "instant"} {
          GiD_WriteCalculationFile puts "*DSload, instant"
        } elseif {$loading_rate == "amplitude"} {
          set node [$group selectNodes "./value\[@n = '_amplitude_'\]"]
          set amplname [get_domnode_attribute $node v]
          GiD_WriteCalculationFile puts "*DSload, amplitude=$amplname"
        }
        set node [$group selectNodes "./value\[@n = '_value_'\]"]
        set magnitude [get_domnode_attribute $node v]
        GiD_WriteCalculationFile puts "$group_name, P, $magnitude"
      }
      
      # surface water pressure acting normal to the surface/line
      set xp "./container\[@n='_loads_'\]/condition\[@n='_surface_water_pressure_'\]/group"
      set groups [$istep selectNodes $xp]
      foreach group $groups {
        set group_name [get_domnode_attribute $group n]
        GiD_WriteCalculationFile puts "*DSload, instant"
        GiD_WriteCalculationFile puts "$group_name, SWP"
      }
      
      # concentrated load (point load)
      set xp "./container\[@n='_loads_'\]/condition\[@n='_concentrated_load_'\]/group"
      set groups [$istep selectNodes $xp]
      foreach group $groups {
        set group_name [get_domnode_attribute $group n]
        set node [$group selectNodes "./value\[@n = '_loading_rate_'\]"]
        set loading_rate [get_domnode_attribute $node v]
        if {$loading_rate == "instant"} {
          GiD_WriteCalculationFile puts "*CLoad, instant"
        } elseif {$loading_rate == "amplitude"} {
          set node [$group selectNodes "./value\[@n = '_amplitude_'\]"]
          set amplname [get_domnode_attribute $node v]
          GiD_WriteCalculationFile puts "*CLoad, amplitude=$amplname"
        } 
        set node [$group selectNodes "./value\[@n = '_value_x_'\]"]
        set magnitude [get_domnode_attribute $node v]
        if {$magnitude != 0.0} {
          GiD_WriteCalculationFile puts "$group_name, 1, $magnitude"
        }
        set node [$group selectNodes "./value\[@n = '_value_y_'\]"]
        set magnitude [get_domnode_attribute $node v]
        if {$magnitude != 0.0} {
          GiD_WriteCalculationFile puts "$group_name, 2, $magnitude"
        }
        set node [$group selectNodes "./value\[@n = '_value_z_'\]"]
        set magnitude [get_domnode_attribute $node v]
        if {$magnitude != 0.0} {
          GiD_WriteCalculationFile puts "$group_name, 3, $magnitude"
        }
      }
      
      # Compliant base
      set xp "./container\[@n='_loads_'\]/condition\[@n='_compliant_base_'\]/group"
      set groups [$istep selectNodes $xp]
      foreach group $groups {
        set group_name [get_domnode_attribute $group n]
        set node [$group selectNodes "./value\[@n = '_density_'\]"]
        set density [get_domnode_attribute $node v]
        set node [$group selectNodes "./value\[@n = '_wave_vel_'\]"]
        set wave_vel [get_domnode_attribute $node v]
        set node [$group selectNodes "./value\[@n = '_direction_'\]"]
        set dir [get_domnode_attribute $node v]
        set node [$group selectNodes "./value\[@n = '_amplitude_'\]"]
        set ampl [get_domnode_attribute $node v]
        set factor [expr $density * $wave_vel]
        GiD_WriteCalculationFile puts "*DSload, amplitude=$ampl"
        GiD_WriteCalculationFile puts "$group_name, compliant, $dir, $factor"
      }

      # Flow condition to the surface/line
      set xp "./container\[@n='_loads_'\]/condition\[@n='_flow_condition_'\]/group"
      set groups [$istep selectNodes $xp]
      foreach group $groups {
        set group_name [get_domnode_attribute $group n]
        set node [$group selectNodes "./value\[@n = '_loading_rate_'\]"]
        set loading_rate [get_domnode_attribute $node v]
        if {$loading_rate == "instant"} {
          GiD_WriteCalculationFile puts "*DSload, instant"
        } elseif {$loading_rate == "amplitude"} {
          set node [$group selectNodes "./value\[@n = '_amplitude_'\]"]
          set amplname [get_domnode_attribute $node v]
          GiD_WriteCalculationFile puts "*DSload, amplitude=$amplname"
        }
        set node [$group selectNodes "./value\[@n = '_value_'\]"]
        set magnitude [get_domnode_attribute $node v]
        GiD_WriteCalculationFile puts "$group_name, flow-w, $magnitude"
      }
	  
      # Mass point
      set xp "./container\[@n='_loads_'\]/condition\[@n='_Mass_'\]/group"
      set groups [$istep selectNodes $xp]
      foreach group $groups {
        set group_name [get_domnode_attribute $group n]
        set node [$group selectNodes "./value\[@n = '_mass_dof_'\]"]
        set mdof [get_domnode_attribute $node v]
        set node [$group selectNodes "./value\[@n = '_value_'\]"]
        set mass_value [get_domnode_attribute $node v]
        set node [$group selectNodes "./value\[@n = '_loading_rate_'\]"]
        set loading_rate [get_domnode_attribute $node v]
        if {$loading_rate == "instant"} {
          GiD_WriteCalculationFile puts "*Mass point, instant"
        } elseif {$loading_rate == "amplitude"} {
          set node [$group selectNodes "./value\[@n = '_amplitude_'\]"]
          set amplname [get_domnode_attribute $node v]
          GiD_WriteCalculationFile puts "*Mass point, amplitude=$amplname"
        }
        if {$mdof == "x-direction"} {
          GiD_WriteCalculationFile puts "$group_name, 1, $mass_value"
        } elseif {$mdof == "y-direction"} {
          GiD_WriteCalculationFile puts "$group_name, 2, $mass_value"
        } elseif {$mdof == "z-direction"} {
          GiD_WriteCalculationFile puts "$group_name, 3, $mass_value"
        }
      }
      
      # Spring Damper 
      set nodeset1 {}
      set nodeset2 {}
      set xp "./container\[@n='_loads_'\]/container\[@n='_spring_damper_'\]/condition\[@n='_spring_n1_'\]/group"
      set groups [$istep selectNodes $xp]
      set node [$istep selectNodes [format_xpath {container[@n="_loads_"]/container[@n="_spring_damper_"]/value[@n="_sd_dof_"]}]]
      set sd_dof [$node getAttribute "v"]
      set node [$istep selectNodes [format_xpath {container[@n="_loads_"]/container[@n="_spring_damper_"]/value[@n="_sd_stiff_"]}]]
      set sd_stiff [$node getAttribute "v"]
      set node [$istep selectNodes [format_xpath {container[@n="_loads_"]/container[@n="_spring_damper_"]/value[@n="_sd_damp_"]}]]
      set sd_damp [$node getAttribute "v"]
      foreach group $groups {
        set group_name [get_domnode_attribute $group n]
        lappend nodeset1 $group_name
      }
      set xp "./container\[@n='_loads_'\]/container\[@n='_spring_damper_'\]/condition\[@n='_spring_n2_'\]/group"
      set groups [$istep selectNodes $xp]
      foreach group $groups {
        set group_name [get_domnode_attribute $group n]
        lappend nodeset2 $group_name
      }
      set length_node1 [llength $nodeset1]
      set length_node2 [llength $nodeset2]
      if {$length_node1 == $length_node2} {
        foreach item1 $nodeset1 item2 $nodeset2 {
          if {$sd_dof == "x-direction"} {
            if {$sd_damp == 0} {
              customlib::WriteString "*Connector element"
              GiD_WriteCalculationFile puts  "$item1, $item2, u1, $sd_stiff"
            } elseif {$sd_damp != 0} {
              customlib::WriteString "*Connector element"
              GiD_WriteCalculationFile puts  "$item1, $item2, u1, $sd_stiff, $sd_damp"
            }
          } elseif {$sd_dof == "y-direction"} {
            if {$sd_damp == 0} {
              customlib::WriteString "*Connector element"
              GiD_WriteCalculationFile puts  "$item1, $item2, u2, $sd_stiff"
            } elseif {$sd_damp != 0} {
              customlib::WriteString "*Connector element"
              GiD_WriteCalculationFile puts  "$item1, $item2, u2, $sd_stiff, $sd_damp"
            }
          } elseif {$sd_dof == "z-direction"} {
            if {$sd_damp == 0} {
              customlib::WriteString "*Connector element"
              GiD_WriteCalculationFile puts  "$item1, $item2, u3, $sd_stiff"
            } elseif {$sd_damp != 0} {
              customlib::WriteString "*Connector element"
              GiD_WriteCalculationFile puts  "$item1, $item2, u3, $sd_stiff, $sd_damp"
            }
          }
        }
      } else {
          error [= "The number of connector node sets are not correct"]
      }
      
      #
      # Visual Output
      #
      
      set node [$istep selectNodes [format_xpath {container[@n="_output_"]/container[@n="_outputs_"]/value[@n="_feq_"]}]]
      set feq [$node getAttribute "v"]
      set node [$istep selectNodes [format_xpath {container[@n="_output_"]/container[@n="_outputs_"]/value[@n="_format_"]}]]
      set format [$node getAttribute "v"]
      set node [$istep selectNodes [format_xpath {container[@n="_output_"]/container[@n="_outputs_"]/value[@n="_encoding_"]}]]
      set encoding [$node getAttribute "v"]
	  
	  # Node output
      set xp "./container\[@n='_output_'\]/container\[@n='_outputs_'\]/condition\[@n='_node_output_'\]/group"
      set node_groups [$istep selectNodes $xp]
	  
      set xp "./container\[@n='_output_'\]/container\[@n='_outputs_'\]/condition\[@n='_element_output_'\]/group"
      set element_groups [$istep selectNodes $xp]
	  
      if { [llength $node_groups] || [llength $element_groups] } {
        GiD_WriteCalculationFile puts "*output, field, $format, $encoding"
        GiD_WriteCalculationFile puts "*frequency=$feq"
      } else {
        # no field output defined
      }

      # write node output
      foreach group $node_groups {
        set group_name [get_domnode_attribute $group n]
        set node [$group selectNodes "./value\[@n = '_solid_dis_'\]"]
        set sol_dis [get_domnode_attribute $node v]
        set node [$group selectNodes "./value\[@n = '_solid_vel_'\]"]
        set sol_vel [get_domnode_attribute $node v]
        set node [$group selectNodes "./value\[@n = '_solid_acc_'\]"]
        set sol_acc [get_domnode_attribute $node v]
        set node [$group selectNodes "./value\[@n = '_po_wa_pr_'\]"]
        set po_wa [get_domnode_attribute $node v]
        set node [$group selectNodes "./value\[@n = '_water_disp_'\]"]
        set wa_dis [get_domnode_attribute $node v]
        set node [$group selectNodes "./value\[@n = '_po_ai_pr_'\]"]
        set po_ai [get_domnode_attribute $node v]
        set node [$group selectNodes "./value\[@n = '_rec_for_'\]"]
        set r_f [get_domnode_attribute $node v]
        set node [$group selectNodes "./value\[@n = '_stress_'\]"]
        set stress [get_domnode_attribute $node v]
        set node [$group selectNodes "./value\[@n = '_strain_'\]"]
        set strain [get_domnode_attribute $node v]
        set node [$group selectNodes "./value\[@n = '_sets_'\]"]
        set sets [get_domnode_attribute $node v]
        set node [$group selectNodes "./value\[@n = '_vis_stressij_'\]"]
        set mec_vis [get_domnode_attribute $node v]
        set node [$group selectNodes "./value\[@n = '_sat_eff_'\]"]
        set sat_eff [get_domnode_attribute $node v]
        set node [$group selectNodes "./value\[@n = '_sat_'\]"]
        set sat [get_domnode_attribute $node v]
        set node [$group selectNodes "./value\[@n = '_phantom_elasticity_'\]"]
        set ph_el [get_domnode_attribute $node v]
        set node [$group selectNodes "./value\[@n = '_con_f_'\]"]
        set con_f [get_domnode_attribute $node v]
        set node [$group selectNodes "./value\[@n = '_contact_'\]"]
        set con [get_domnode_attribute $node v]
        set node [$group selectNodes "./value\[@n = '_contact_sdv_'\]"]
        set con_sdv [get_domnode_attribute $node v]
        set node [$group selectNodes "./value\[@n = '_contact_diagnostic_'\]"]
        set con_dia [get_domnode_attribute $node v]
        set node [$group selectNodes "./value\[@n = '_extra_'\]"]
        set ext [get_domnode_attribute $node v]
        GiD_WriteCalculationFile puts "*node output, nset = $group_name"
        # Check each attribute and add it to the output_terms if it's 'Yes'
        if {$sol_dis == "Yes"} {append output_terms "u, "}
        if {$sol_vel == "Yes"} {append output_terms "v, "}
        if {$sol_acc == "Yes"} {append output_terms "a, "}
        if {$po_wa == "Yes"} {append output_terms "pw, "}
        if {$wa_dis == "Yes"} {append output_terms "uw, "}
        if {$po_ai == "Yes"} {append output_terms "pa, "}
        if {$r_f == "Yes"} {append output_terms "rf, "}
        if {$stress == "Yes"} {append output_terms "S, "}
        if {$strain == "Yes"} {append output_terms "e, "}
        if {$sets == "Yes"} {append output_terms "sets, "}
        if {$mec_vis == "Yes"} {append output_terms "vis_stressij, "}
        if {$sat_eff == "Yes"} {append output_terms "Sat_eff, "}
        if {$sat == "Yes"} {append output_terms "sat, "}
        if {$ph_el == "Yes"} {append output_terms "Phantom_Elasticity, "}
        if {$con_f == "Yes"} {append output_terms "Con_f, "}
        if {$con == "Yes"} {append output_terms "Contact, "}
        if {$con_sdv == "Yes"} {append output_terms "Contact_sdv, "}
        if {$con_dia == "Yes"} {append output_terms "Contact_diagnostic, "}
        # Write calculation file if there are terms to output
        if {[string length $output_terms] > 0} {
          GiD_WriteCalculationFile puts "$output_terms $ext"
        }
        unset output_terms
      }
	  
	  # write element output
      foreach group $element_groups {
        set group_name [get_domnode_attribute $group n]
        set node [$group selectNodes "./value\[@n = '_e_stress_'\]"]
        set e_stress [get_domnode_attribute $node v]
        set node [$group selectNodes "./value\[@n = '_e_strain_'\]"]
        set e_strain [get_domnode_attribute $node v]
        set node [$group selectNodes "./value\[@n = '_e_vis_stressij_'\]"]
        set e_mec_vis [get_domnode_attribute $node v]
        set node [$group selectNodes "./value\[@n = '_e_void_'\]"]
        set e_voi [get_domnode_attribute $node v]
        set node [$group selectNodes "./value\[@n = '_e_sat_eff_'\]"]
        set e_sat_eff [get_domnode_attribute $node v]
        set node [$group selectNodes "./value\[@n = '_e_sat_'\]"]
        set e_sat [get_domnode_attribute $node v]
        set node [$group selectNodes "./value\[@n = '_e_phantom_elasticity_'\]"]
        set e_ph_el [get_domnode_attribute $node v]
        set node [$group selectNodes "./value\[@n = '_e_sets_'\]"]
        set e_set [get_domnode_attribute $node v]
        set node [$group selectNodes "./value\[@n = '_e_mat_'\]"]
        set e_mat [get_domnode_attribute $node v]
        set node [$group selectNodes "./value\[@n = '_e_contact_'\]"]
        set e_con [get_domnode_attribute $node v]
        set node [$group selectNodes "./value\[@n = '_e_contact_sdv_'\]"]
        set e_con_sdv [get_domnode_attribute $node v]
        set node [$group selectNodes "./value\[@n = '_e_contact_diagnostic_'\]"]
        set e_con_dia [get_domnode_attribute $node v]
        set node [$group selectNodes "./value\[@n = '_e_extra_'\]"]
        set e_ext [get_domnode_attribute $node v]
        GiD_WriteCalculationFile puts "*Element output, elset = $group_name"
        # Check each attribute and add it to the e_output_terms if it's 'Yes'
        if {$e_stress == "Yes"} {append e_output_terms "S, "}
        if {$e_strain == "Yes"} {append e_output_terms "e, "}
        if {$e_set == "Yes"} {append e_output_terms "sets, "}
        if {$e_voi == "Yes"} {append e_output_terms "void, "}
        if {$e_mec_vis == "Yes"} {append e_output_terms "vis_stressij, "}
        if {$e_sat_eff == "Yes"} {append e_output_terms "Sat_eff, "}
        if {$e_sat == "Yes"} {append e_output_terms "sat, "}
        if {$e_ph_el == "Yes"} {append e_output_terms "Phantom_Elasticity, "}
        if {$e_mat == "Yes"} {append e_output_terms "mat, "}
        if {$e_con == "Yes"} {append e_output_terms "Contact, "}
        if {$e_con_sdv == "Yes"} {append e_output_terms "Contact_sdv, "}
        if {$e_con_dia == "Yes"} {append e_output_terms "Contact_diagnostic, "}
        # Write calculation file if there are terms to output
        if {[string length $e_output_terms] > 0} {
          GiD_WriteCalculationFile puts "$e_output_terms $e_ext"
        }
        unset e_output_terms
      }
      
      #
      # Print Output
      #
      set node [$istep selectNodes [format_xpath {container[@n="_output_"]/container[@n="_outputs_print_"]/value[@n="_feq_"]}]]
      set feq_p [$node getAttribute "v"]
      # Node output
      set xp "./container\[@n='_output_'\]/container\[@n='_outputs_print_'\]/condition\[@n='_node_output_p_'\]/group"
      set groups [$istep selectNodes $xp]
      set xp "./container\[@n='_output_'\]/container\[@n='_outputs_print_'\]/condition\[@n='_element_output_p_'\]/group"
      set ele_groups [$istep selectNodes $xp]
      set xp "./container\[@n='_output_'\]/container\[@n='_outputs_print_'\]/condition\[@n='_i_element_output_p_'\]/group"
      set int_groups [$istep selectNodes $xp]
      if {[llength $groups] > 0 || [llength $ele_groups] > 0 || [llength $int_groups] > 0} {
        GiD_WriteCalculationFile puts "*Output, print"
        GiD_WriteCalculationFile puts "*frequency=$feq_p"
      }
      foreach group $groups {
        set group_name [get_domnode_attribute $group n]
        set node [$group selectNodes "./value\[@n = '_solid_dis_p_'\]"]
        set sol_dis [get_domnode_attribute $node v]
        set node [$group selectNodes "./value\[@n = '_solid_vel_p_'\]"]
        set sol_vel [get_domnode_attribute $node v]
        set node [$group selectNodes "./value\[@n = '_solid_acc_p_'\]"]
        set sol_acc [get_domnode_attribute $node v]
        set node [$group selectNodes "./value\[@n = '_po_wa_pr_p_'\]"]
        set po_wa [get_domnode_attribute $node v]
        set node [$group selectNodes "./value\[@n = '_water_disp_p_'\]"]
        set wa_dis [get_domnode_attribute $node v]
        set node [$group selectNodes "./value\[@n = '_po_ai_pr_p_'\]"]
        set po_ai [get_domnode_attribute $node v]
        set node [$group selectNodes "./value\[@n = '_rec_for_p_'\]"]
        set r_f [get_domnode_attribute $node v]
        set node [$group selectNodes "./value\[@n = '_stress_p_'\]"]
        set stress [get_domnode_attribute $node v]
        set node [$group selectNodes "./value\[@n = '_strain_p_'\]"]
        set strain [get_domnode_attribute $node v]
        set node [$group selectNodes "./value\[@n = '_sets_p_'\]"]
        set sets [get_domnode_attribute $node v]
        set node [$group selectNodes "./value\[@n = '_vis_stressij_p_'\]"]
        set mec_vis [get_domnode_attribute $node v]
        set node [$group selectNodes "./value\[@n = '_sat_eff_p_'\]"]
        set sat_eff [get_domnode_attribute $node v]
        set node [$group selectNodes "./value\[@n = '_sat_p_'\]"]
        set sat [get_domnode_attribute $node v]
        set node [$group selectNodes "./value\[@n = '_phantom_elasticity_p_'\]"]
        set ph_el [get_domnode_attribute $node v]
        set node [$group selectNodes "./value\[@n = '_con_f_p_'\]"]
        set con_f [get_domnode_attribute $node v]
        set node [$group selectNodes "./value\[@n = '_contact_p_'\]"]
        set con [get_domnode_attribute $node v]
        set node [$group selectNodes "./value\[@n = '_contact_sdv_p_'\]"]
        set con_sdv [get_domnode_attribute $node v]
        set node [$group selectNodes "./value\[@n = '_contact_diagnostic_p_'\]"]
        set con_dia [get_domnode_attribute $node v]
        set node [$group selectNodes "./value\[@n = '_extra_p_'\]"]
        set ext_p [get_domnode_attribute $node v]
        GiD_WriteCalculationFile puts "*node output, nset = $group_name"
        # Check each attribute and add it to the output_terms_p if it's 'Yes'
        if {$sol_dis == "Yes"} {append output_terms_p "u, "}
        if {$sol_vel == "Yes"} {append output_terms_p "v, "}
        if {$sol_acc == "Yes"} {append output_terms_p "a, "}
        if {$po_wa == "Yes"} {append output_terms_p "pw, "}
        if {$wa_dis == "Yes"} {append output_terms_p "uw, "}
        if {$po_ai == "Yes"} {append output_terms_p "pa, "}
        if {$r_f == "Yes"} {append output_terms_p "rf, "}
        if {$stress == "Yes"} {append output_terms_p "S, "}
        if {$strain == "Yes"} {append output_terms_p "e, "}
        if {$sets == "Yes"} {append output_terms_p "sets, "}
        if {$mec_vis == "Yes"} {append output_terms_p "vis_stressij, "}
        if {$sat_eff == "Yes"} {append output_terms_p "Sat_eff, "}
        if {$sat == "Yes"} {append output_terms_p "sat, "}
        if {$ph_el == "Yes"} {append output_terms_p "Phantom_Elasticity, "}
        if {$con_f == "Yes"} {append output_terms_p "Con_f, "}
        if {$con == "Yes"} {append output_terms_p "Contact, "}
        if {$con_sdv == "Yes"} {append output_terms_p "Contact_sdv, "}
        if {$con_dia == "Yes"} {append output_terms_p "Contact_diagnostic, "}
        # Write calculation file if there are terms to output
        if {[string length $output_terms_p] > 0} {
          GiD_WriteCalculationFile puts "$output_terms_p $ext_p"
        }
        unset output_terms_p
      }
      set xp "./container\[@n='_output_'\]/container\[@n='_outputs_print_'\]/condition\[@n='_element_output_p_'\]/group"
      set groups [$istep selectNodes $xp]
      foreach group $groups {
        set group_name [get_domnode_attribute $group n]
        set node [$group selectNodes "./value\[@n = '_e_stress_p_'\]"]
        set e_stress [get_domnode_attribute $node v]
        set node [$group selectNodes "./value\[@n = '_e_strain_p_'\]"]
        set e_strain [get_domnode_attribute $node v]
        set node [$group selectNodes "./value\[@n = '_e_vis_stressij_p_'\]"]
        set e_mec_vis [get_domnode_attribute $node v]
        set node [$group selectNodes "./value\[@n = '_e_void_p_'\]"]
        set e_voi [get_domnode_attribute $node v]
        set node [$group selectNodes "./value\[@n = '_e_sat_eff_p_'\]"]
        set e_sat_eff [get_domnode_attribute $node v]
        set node [$group selectNodes "./value\[@n = '_e_sat_p_'\]"]
        set e_sat [get_domnode_attribute $node v]
        set node [$group selectNodes "./value\[@n = '_e_phantom_elasticity_p_'\]"]
        set e_ph_el [get_domnode_attribute $node v]
        set node [$group selectNodes "./value\[@n = '_e_sets_p_'\]"]
        set e_set [get_domnode_attribute $node v]
        set node [$group selectNodes "./value\[@n = '_e_mat_p_'\]"]
        set e_mat [get_domnode_attribute $node v]
        set node [$group selectNodes "./value\[@n = '_e_contact_p_'\]"]
        set e_con [get_domnode_attribute $node v]
        set node [$group selectNodes "./value\[@n = '_e_contact_sdv_p_'\]"]
        set e_con_sdv [get_domnode_attribute $node v]
        set node [$group selectNodes "./value\[@n = '_e_contact_diagnostic_p_'\]"]
        set e_con_dia [get_domnode_attribute $node v]
        set node [$group selectNodes "./value\[@n = '_e_extra_p_'\]"]
        set e_ext_p [get_domnode_attribute $node v]
        GiD_WriteCalculationFile puts "*Element output, elset = $group_name"
        # Check each attribute and add it to the e_output_terms_p if it's 'Yes'
        if {$e_stress == "Yes"} {append e_output_terms_p "S, "}
        if {$e_strain == "Yes"} {append e_output_terms_p "e, "}
        if {$e_set == "Yes"} {append e_output_terms_p "sets, "}
        if {$e_voi == "Yes"} {append e_output_terms_p "void, "}
        if {$e_mec_vis == "Yes"} {append e_output_terms_p "vis_stressij, "}
        if {$e_sat_eff == "Yes"} {append e_output_terms_p "Sat_eff, "}
        if {$e_sat == "Yes"} {append e_output_terms_p "sat, "}
        if {$e_ph_el == "Yes"} {append e_output_terms_p "Phantom_Elasticity, "}
        if {$e_mat == "Yes"} {append e_output_terms_p "mat, "}
        if {$e_con == "Yes"} {append e_output_terms_p "Contact, "}
        if {$e_con_sdv == "Yes"} {append e_output_terms_p "Contact_sdv, "}
        if {$e_con_dia == "Yes"} {append e_output_terms_p "Contact_diagnostic, "}
        # Write calculation file if there are terms to output
        if {[string length $e_output_terms_p] > 0} {
          GiD_WriteCalculationFile puts "$e_output_terms_p $e_ext_p"
        }
        unset e_output_terms_p
      }
      set xp "./container\[@n='_output_'\]/container\[@n='_outputs_print_'\]/condition\[@n='_i_element_output_p_'\]/group"
      set groups [$istep selectNodes $xp]
      foreach group $groups {
        set group_name [get_domnode_attribute $group n]
        set node [$group selectNodes "./value\[@n = '_i_e_stress_p_'\]"]
        set e_stress [get_domnode_attribute $node v] 
        set node [$group selectNodes "./value\[@n = '_i_e_strain_p_'\]"]
        set e_strain [get_domnode_attribute $node v] 
        set node [$group selectNodes "./value\[@n = '_i_e_vis_stressij_p_'\]"]
        set e_mec_vis [get_domnode_attribute $node v]
        set node [$group selectNodes "./value\[@n = '_i_e_void_p_'\]"]
        set e_voi [get_domnode_attribute $node v]  
        set node [$group selectNodes "./value\[@n = '_i_e_sat_eff_p_'\]"]
        set e_sat_eff [get_domnode_attribute $node v]
        set node [$group selectNodes "./value\[@n = '_i_e_sat_p_'\]"]
        set e_sat [get_domnode_attribute $node v]  
        set node [$group selectNodes "./value\[@n = '_i_e_phantom_elasticity_p_'\]"]
        set e_ph_el [get_domnode_attribute $node v]  
        set node [$group selectNodes "./value\[@n = '_i_e_sets_p_'\]"]
        set e_set [get_domnode_attribute $node v]  
        set node [$group selectNodes "./value\[@n = '_i_e_mat_p_'\]"]
        set e_mat [get_domnode_attribute $node v]  
        set node [$group selectNodes "./value\[@n = '_i_e_contact_p_'\]"]
        set e_con [get_domnode_attribute $node v]  
        set node [$group selectNodes "./value\[@n = '_i_e_contact_sdv_p_'\]"]
        set e_con_sdv [get_domnode_attribute $node v]
        set node [$group selectNodes "./value\[@n = '_i_e_contact_diagnostic_p_'\]"]
        set e_con_dia [get_domnode_attribute $node v]
        set node [$group selectNodes "./value\[@n = '_i_e_extra_'\]"]
        set i_e_ext [get_domnode_attribute $node v]
        GiD_WriteCalculationFile puts "*Integration point, elset = $group_name"
        # Check each attribute and add it to the _i_e_output_terms_p if it's 'Yes'
        if {$e_stress == "Yes"} {append _i_e_output_terms_p "S, "}
        if {$e_strain == "Yes"} {append _i_e_output_terms_p "e, "}
        if {$e_set == "Yes"} {append _i_e_output_terms_p "sets, "}
        if {$e_voi == "Yes"} {append _i_e_output_terms_p "void, "}
        if {$e_mec_vis == "Yes"} {append _i_e_output_terms_p "vis_stressij, "}
        if {$e_sat_eff == "Yes"} {append _i_e_output_terms_p "Sat_eff, "}
        if {$e_sat == "Yes"} {append _i_e_output_terms_p "sat, "}
        if {$e_ph_el == "Yes"} {append _i_e_output_terms_p "Phantom_Elasticity, "}
        if {$e_mat == "Yes"} {append _i_e_output_terms_p "mat, "}
        if {$e_con == "Yes"} {append _i_e_output_terms_p "Contact, "}
        if {$e_con_sdv == "Yes"} {append _i_e_output_terms_p "Contact_sdv, "}
        if {$e_con_dia == "Yes"} {append _i_e_output_terms_p "Contact_diagnostic, "}
        # Write calculation file if there are terms to output
        if {[string length $_i_e_output_terms_p] > 0} {
          GiD_WriteCalculationFile puts "$_i_e_output_terms_p $i_e_ext"
        }
        unset _i_e_output_terms_p
      }
      GiD_WriteCalculationFile puts "*End Step"
    } elseif {$skipstep == "No"} {
      GiD_WriteCalculationFile puts "** Step skipped"
    }
  } 
  customlib::WriteString ""  
  customlib::WriteString "**"
  customlib::WriteString "** End"
  customlib::WriteString "**"
  GiD_WriteCalculationFile puts "*End Input"
  customlib::EndWriteFile ;#finish writting
}