# Early step termination

**URL:** <https://calculix.discourse.group/t/early-step-termination/2690>\
**Category:** Uncategorized\
**Created:** [April 18, 2025, 10:30pm UTC](https://calculix.discourse.group/t/early-step-termination/2690 "2025-04-18T22:30:41Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![PGA](https://avatars.discourse-cdn.com/v4/letter/p/df705f/32.png) [@PGA](https://calculix.discourse.group/u/PGA)\
**Post date:** [April 18, 2025, 10:30pm UTC](https://calculix.discourse.group/t/early-step-termination/2690/1 "2025-04-18T22:30:41Z")

</div>

Hi I am running a coupled temperature-displacement, I want to cool down the part, but I want to cut the step 2, if the temperature is near 200 degrees, is that option possible? it is not like a termination of the job, I want to jump to step 3.

thank you.

---

<div class="post-metadata">

**Author:** ![jbr](https://avatars.discourse-cdn.com/v4/letter/j/ecccb3/32.png) [@jbr](https://calculix.discourse.group/u/jbr)\
**Post date:** [April 19, 2025, 2:15am UTC](https://calculix.discourse.group/t/early-step-termination/2690/2 "2025-04-19T02:15:21Z")

</div>

I’m not sure if there is an option like that in ccx at the moment. However, you could probably use a fortran subroutine to do this.

---

<div class="post-metadata">

**Author:** ![PGA](https://avatars.discourse-cdn.com/v4/letter/p/df705f/32.png) [@PGA](https://calculix.discourse.group/u/PGA)\
**Post date:** [April 21, 2025, 3:30pm UTC](https://calculix.discourse.group/t/early-step-termination/2690/3 "2025-04-21T15:30:33Z")

</div>

any recommendation to implement that subroutine?

---

<div class="post-metadata">

**Author:** ![jbr](https://avatars.discourse-cdn.com/v4/letter/j/ecccb3/32.png) [@jbr](https://calculix.discourse.group/u/jbr)\
**Post date:** [April 22, 2025, 7:07am UTC](https://calculix.discourse.group/t/early-step-termination/2690/4 "2025-04-22T07:07:41Z")

</div>

Yes, what you’re trying to do is possible — while you can’t directly “jump” to the next step from within `utemp.f`, you _can_ force CalculiX to **terminate Step 2 early** when a certain temperature condition is met. This will cause it to move on to Step 3 if it’s defined in your input file.

You can do this by adding a temperature check inside the `utemp.f` subroutine and forcing a condition to trigger early step termination. Here’s a Fortran pseudo-code example to get you started:

```python
      real*8 avg_temp, threshold
      integer ntemp_nodes, i

      if (kstep .eq. 2) then
         threshold = 200.d0
         # Monitor temperature at node 100
         if (node .eq. 100) then
            avg_temp = vold(0, node)
            if (avg_temp .ge. threshold) then
               # Force to terminate the step -- Add something meaningful below
               write(*,*) '>>> Early termination triggered: T >= 200C at node 100'
            endif
         endif
      endif

```

Just swap in the node number(s) you care about. You could also average multiple nodes if needed.

⚠ This won’t _gracefully_ exit the step — it causes a controlled failure, but CalculiX will move to Step 3 as long as it’s set up correctly in your `.inp` file.
