I wrote to the FVS Helpdesk a month ago regarding a strange crash I observe when running the OP (Organon) variant of FVS. I do not observe this crash while running the same keyword file through the WC or PN variants of FVS.
The OP variant crashes due to a floating-point exception:
Program received signal SIGFPE: Floating-point exception - erroneous arithmetic operation
Another thing I noticed is that this crash occurs only if the length of my simulation exceeds 16 cycles. (Odd, yes?)
Anyway, I’m not much of a Fortran programmer, but I just couldn’t let it be without at least making an attempt to narrow down the source of the problem. So I fired up a debugger and found the line that leads to the SIGFPE. It turns out this is line 942 in FVSmodel/trunk/organon/htgrowth.f:
FERTX2=EXP(PF3*(XTIME-YF(1))+PF4*(SI_1/100.0)**PF5)
This particular floating-point exception is the result of underflow. It seems to come about in the call to the EXP function. The argument to EXP here is negative. Trying to raise e to a negative power of this magnitude evidently results in a value so tiny that underflow occurs.
Moreover, it seems that since the value of XTIME increases as the cycle number increases, therefore the negative number passed to EXP gets more and more negative as cycles pass. This probably explains why the crash only comes about with a certain number of cycles in the simulation.
Whether or not this is the best approach to take, it seems the crash at least can be made to go away by treating some intermediate results as doubles (REAL*8
) instead of the REAL*4
values they are now.
Widening the argument to EXP fixes the problem I first identified, and widening the intermediate variable FERTX2 fixes a problem that is revealed in the subsequent line if the result of the call to EXP is narrowed again too soon. Finally, we can explicitly convert the value of FERTADJ back to REAL*4
to avoid a compiler warning.
I've attached a copy of the file with my proposed changes for your review.
I don't know if it might make sense to change
REAL*4
toREAL*8
everywhere in Organon?This kind of math bug might mean that the routine has not been exercised over a broad range of inputs and species. I know that the R-tools Fortran compiler is less forgiving than the Intel compiler, but it is the standard compiler for FVS. I think that changing to double precision isn't the first thing to try. If I were in your place I'd pull apart the equation (which you did) and then see if you can choose a lower bound on the input value that will not break when passed to exp(). You could compute it in advance and then bound it if needed so it doesn't underflow. Good luck!
Last edit: Donald Robinson 2022-05-13
I completely agree with Don. If you can change the logic to trap the
condition that is causing the underflow, please post the code here and it
will likely be incorporated into the program.
On Fri, May 13, 2022 at 7:55 AM Donald Robinson donrobinson@users.sourceforge.net wrote:
--
Nicholas L. Crookston
Forestry Research Consultant
Moscow Idaho USA
Related
Tickets:
#64OK, that makes sense. I'll work on finding the lower bound and preventing anything smaller from heading into exp().
FWIW, my thinking around making everything doubles is just that what if there are other timebombs of this nature strewn around the codebase just waiting for a value slightly too big or too small to come along. But I guess we can identify them if and when they crop up and do similar bounding on the values if needed.
I've found that underflow starts to occur when the value passed to
exp
is less than -87 (actually about -87.3, but I rounded), so I went ahead and prevented that from happening. I hope I've understood correctly and this is what you had in mind. I've attached a file that incorporates my changes.Edit: Well, it's been an interested google rabbit hole, but I found that at least one reason not to use subnormal/denormal numbers is that they can require a lot more clock cycles to work with as compared with normal numbers. So maybe just go ahead with the bounding and ignore the rest of what I wrote.
I had another idea. Let me know what you think.
By default floating-point underflow isn't a fatal error. In fact, at least at lower compiler optimization levels, the default behavior is "gradual underflow," whereby, using so-called "subnormal numbers," values that are normally too small to represent may still be represented with some loss of precision. (I'm far from an expert, but this is what I discovered in my googling.)
It seems that the only reason FVS stops on underflow is due to the settings that are passed to the compiler with the
-ffpe-trap
switch (see line 63 of the makefile). If this switch is modified to omit theunderflow
and thedenormal
options, then the program does not stop at the location I identified earlier, even without my adding a lower bound on the argument toexp
.Instead, all that we see is a note printed to the console when the program terminates, indicating that the underflow flag had been set--meaning underflow occurred somewhere in the program. (This is required by the Fortran standard.)
Perhaps there's a reason FVS is compiled to terminate on underflow. On the other hand, although I wasn't able to find anything definitive as to best practices, some of the answers I found on StackOverflow indicated that it may not always be the right move. For its part, the gfortran documentation simply indicates that
invalid
,zero
, andoverflow
exceptions probably ought to be trapped because they indicate serious errors, while it omitsunderflow
from the list, suggesting it isn't a serious error. This makes sense if gradual underflow fills the gap.I did a few comparisons, looking at the results I get for the
FERTX2
variable at the first cycle where the underflow crash was occurring. I tried three different approaches for avoiding program termination: widen to double-precision floating point; make no changes to the code but revise the compiler switch as described above; or add a lower bound on the value passed toexp
.Here are the results:
6.1969737521332938E-040
(changed to double-precision)6.19697621E-40
(removed compiler switch, allowing gradual underflow without crashing)1.64581145E-38
(applied a lower bound)Note how similar the second result is to the first. This suggests that allowing the default "muddling through by gradual underflow" behavior may give us adequate results.
I mean, I know we're talking about infinitesimal values in any case, so maybe I'm making too much of this. But it's a thought.
Last edit: Erin Crosland 2022-05-17
Erin,
First, thanks for looking into this so thoroughly and identifying the exact cause of the issue. Based on the edit to your last post, I think you came to this conclusion anyway, but the simple solution of preventing the mathematical issue (an underflow in this case) is often the best fix. It prevents the issue rather than reducing its probability, and it essentially eliminates unintended consequences elsewhere in the code. I know you understand this well, but we’re trying to approximate natural systems with equations that often don’t behave well at the extremes, so there are lots of instances where logical bounds are necessary. Thanks again for your efforts on this.
Yeah, thanks for the explanation. That makes sense, particularly the part about avoiding unintended consequences elsewhere.
I'm just grateful for the opportunity to learn a little more about floating-point numbers. :)
I just downloaded the latest FVS executables from the Forest Service (the installer is dated 7/1/2022), but OP crashes like it used to before this fix. Is there anything more I can do to help get this into a release?
Due to the USA long weekend, there may not be a timely response today. I hope this response helps, even if it isn't fully satisfying.
The FVS staff are currently working to port the SourceForge repository to GitHub. That may be the reason you are not seeing a patch in the SourceForge repo, even though the date may be updated. My understanding is that as soon as the port is complete (in the next week or so) the Summer 2022 release will be available and current, in GitHub. Hopefully the fix will be present in the new release.
Last edit: Donald Robinson 2022-07-05
Thanks. I'm happy to hear about the change to GitHub :) Meanwhile, I'll just keep using the OP executable that I built a while ago.
Hello Erin,
Regarding the FVS ticket #64 with the underflow error at 16 cycles.
I have added code for the FVSop variant, but I have no data or keywords that would cause that error. I would like to process your failing run with current release and confirm the error happens for me and then test the new code to make sure the error has been averted. Can you provide the keyword file and data that caused the crash?
Thank you
Lance
From: tickets@open-fvs.p.re.sourceforge.net tickets@open-fvs.p.re.sourceforge.net On Behalf Of Erin Crosland
Sent: Tuesday, July 5, 2022 3:52 PM
To: [open-fvs:tickets] 64@tickets.open-fvs.p.re.sourceforge.net
Subject: [External Email][open-fvs:tickets] Re: #64 OP variant stops with fatal floating-point exception
[External Email]
If this message comes from an unexpected sender or references a vague/unexpected topic;
Use caution before clicking links or opening attachments.
Please send any concerns or suspicious messages to: Spam.Abuse@usda.govSpam.Abuse@usda.gov
Thanks. I'm happy to hear about the change to GitHub :) Meanwhile, I'll just keep using the OP executable that I built a while ago.
[tickets:#64]https://gcc02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fsourceforge.net%2Fp%2Fopen-fvs%2Ftickets%2F64%2F&data=05%7C01%7C%7C084eb9ccabf840a2421d08da5ed0a2d5%7Ced5b36e701ee4ebc867ee03cfa0d4697%7C0%7C0%7C637926547423699578%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=3ln6QrDecP3ce%2F0h7pBJ25sNgUai7sHj%2B5ewbYdL1uM%3D&reserved=0 OP variant stops with fatal floating-point exception
Status: Done
Created: Fri May 13, 2022 02:20 AM UTC by Erin Crosland
Last Updated: Tue Jul 05, 2022 09:49 PM UTC
Owner: nobody
Attachments:
I wrote to the FVS Helpdesk a month ago regarding a strange crash I observe when running the OP (Organon) variant of FVS. I do not observe this crash while running the same keyword file through the WC or PN variants of FVS.
The OP variant crashes due to a floating-point exception:
Program received signal SIGFPE: Floating-point exception - erroneous arithmetic operation
Another thing I noticed is that this crash occurs only if the length of my simulation exceeds 16 cycles. (Odd, yes?)
Anyway, I'm not much of a Fortran programmer, but I just couldn't let it be without at least making an attempt to narrow down the source of the problem. So I fired up a debugger and found the line that leads to the SIGFPE. It turns out this is line 942 in FVSmodel/trunk/organon/htgrowth.f:
FERTX2=EXP(PF3(XTIME-YF(1))+PF4(SI_1/100.0)**PF5)
This particular floating-point exception is the result of underflow. It seems to come about in the call to the EXP function. The argument to EXP here is negative. Trying to raise e to a negative power of this magnitude evidently results in a value so tiny that underflow occurs.
Moreover, it seems that since the value of XTIME increases as the cycle number increases, therefore the negative number passed to EXP gets more and more negative as cycles pass. This probably explains why the crash only comes about with a certain number of cycles in the simulation.
Whether or not this is the best approach to take, it seems the crash at least can be made to go away by treating some intermediate results as doubles (REAL8) instead of the REAL4 values they are now.
Widening the argument to EXP fixes the problem I first identified, and widening the intermediate variable FERTX2 fixes a problem that is revealed in the subsequent line if the result of the call to EXP is narrowed again too soon. Finally, we can explicitly convert the value of FERTADJ back to REAL*4 to avoid a compiler warning.
I've attached a copy of the file with my proposed changes for your review.
Sent from sourceforge.net because you indicated interest in https://sourceforge.net/p/open-fvs/tickets/64/https://gcc02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fsourceforge.net%2Fp%2Fopen-fvs%2Ftickets%2F64%2F&data=05%7C01%7C%7C084eb9ccabf840a2421d08da5ed0a2d5%7Ced5b36e701ee4ebc867ee03cfa0d4697%7C0%7C0%7C637926547423699578%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=3ln6QrDecP3ce%2F0h7pBJ25sNgUai7sHj%2B5ewbYdL1uM%3D&reserved=0
To unsubscribe from further messages, please visit https://sourceforge.net/auth/subscriptions/https://gcc02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fsourceforge.net%2Fauth%2Fsubscriptions%2F&data=05%7C01%7C%7C084eb9ccabf840a2421d08da5ed0a2d5%7Ced5b36e701ee4ebc867ee03cfa0d4697%7C0%7C0%7C637926547423699578%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=otUilougmmY1N72IOUNfxRCtS5TapFRujGRKwCqIsFg%3D&reserved=0
This electronic message contains information generated by the USDA solely for the intended recipients. Any unauthorized interception of this message or the use or disclosure of the information it contains may violate the law and subject the violator to civil or criminal penalties. If you believe you have received this message in error, please notify the sender and delete the email immediately.
Related
Tickets:
#64Hi, Lance. I tried to reply to you via email. Let me know if that didn't work and I'll post it here.
Ah, I see the message wasn't delivered. I've attached a copy of the keyword file and input dataset to this post. I checked that it still fails with the underflow with the OP build that I downloaded from the FVS website the other day.
Thank you, Erin.
I got your TestRun.zip.
Lance
From: tickets@open-fvs.p.re.sourceforge.net tickets@open-fvs.p.re.sourceforge.net On Behalf Of Erin Crosland
Sent: Tuesday, July 12, 2022 3:25 PM
To: [open-fvs:tickets] 64@tickets.open-fvs.p.re.sourceforge.net
Subject: [External Email][open-fvs:tickets] Re: #64 OP variant stops with fatal floating-point exception
[External Email]
If this message comes from an unexpected sender or references a vague/unexpected topic;
Use caution before clicking links or opening attachments.
Please send any concerns or suspicious messages to: Spam.Abuse@usda.govSpam.Abuse@usda.gov
Ah, I see the message wasn't delivered. I've attached a copy of the keyword file and input dataset to this post. I checked that it still fails with the underflow with the OP build that I downloaded from the FVS website the other day.
Attachments:
[tickets:#64]https://gcc02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fsourceforge.net%2Fp%2Fopen-fvs%2Ftickets%2F64%2F&data=05%7C01%7C%7Cb922042773eb4f7667e508da644d1148%7Ced5b36e701ee4ebc867ee03cfa0d4697%7C0%7C0%7C637932579426414998%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=mYlwIdFGaefFLLl6e%2FFiibhSs0%2F0uezO5ryUHbSab4I%3D&reserved=0 OP variant stops with fatal floating-point exception
Status: Done
Created: Fri May 13, 2022 02:20 AM UTC by Erin Crosland
Last Updated: Tue Jul 12, 2022 09:02 PM UTC
Owner: nobody
Attachments:
I wrote to the FVS Helpdesk a month ago regarding a strange crash I observe when running the OP (Organon) variant of FVS. I do not observe this crash while running the same keyword file through the WC or PN variants of FVS.
The OP variant crashes due to a floating-point exception:
Program received signal SIGFPE: Floating-point exception - erroneous arithmetic operation
Another thing I noticed is that this crash occurs only if the length of my simulation exceeds 16 cycles. (Odd, yes?)
Anyway, I'm not much of a Fortran programmer, but I just couldn't let it be without at least making an attempt to narrow down the source of the problem. So I fired up a debugger and found the line that leads to the SIGFPE. It turns out this is line 942 in FVSmodel/trunk/organon/htgrowth.f:
FERTX2=EXP(PF3(XTIME-YF(1))+PF4(SI_1/100.0)**PF5)
This particular floating-point exception is the result of underflow. It seems to come about in the call to the EXP function. The argument to EXP here is negative. Trying to raise e to a negative power of this magnitude evidently results in a value so tiny that underflow occurs.
Moreover, it seems that since the value of XTIME increases as the cycle number increases, therefore the negative number passed to EXP gets more and more negative as cycles pass. This probably explains why the crash only comes about with a certain number of cycles in the simulation.
Whether or not this is the best approach to take, it seems the crash at least can be made to go away by treating some intermediate results as doubles (REAL8) instead of the REAL4 values they are now.
Widening the argument to EXP fixes the problem I first identified, and widening the intermediate variable FERTX2 fixes a problem that is revealed in the subsequent line if the result of the call to EXP is narrowed again too soon. Finally, we can explicitly convert the value of FERTADJ back to REAL*4 to avoid a compiler warning.
I've attached a copy of the file with my proposed changes for your review.
Sent from sourceforge.net because you indicated interest in https://sourceforge.net/p/open-fvs/tickets/64/https://gcc02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fsourceforge.net%2Fp%2Fopen-fvs%2Ftickets%2F64%2F&data=05%7C01%7C%7Cb922042773eb4f7667e508da644d1148%7Ced5b36e701ee4ebc867ee03cfa0d4697%7C0%7C0%7C637932579426414998%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=mYlwIdFGaefFLLl6e%2FFiibhSs0%2F0uezO5ryUHbSab4I%3D&reserved=0
To unsubscribe from further messages, please visit https://sourceforge.net/auth/subscriptions/https://gcc02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fsourceforge.net%2Fauth%2Fsubscriptions%2F&data=05%7C01%7C%7Cb922042773eb4f7667e508da644d1148%7Ced5b36e701ee4ebc867ee03cfa0d4697%7C0%7C0%7C637932579426414998%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=vhpxfO%2Btscqf6LjKEMVuoS9Xx3Ba21%2BrbYVgPqVOPjY%3D&reserved=0
This electronic message contains information generated by the USDA solely for the intended recipients. Any unauthorized interception of this message or the use or disclosure of the information it contains may violate the law and subject the violator to civil or criminal penalties. If you believe you have received this message in error, please notify the sender and delete the email immediately.
Related
Tickets:
#64Good morning Erin,
Thank you for providing your data and keywords for my testing. The modification I have placed in the code does alleviate the underflow error and the run did crash for me as well using the current release FVSop. The way the timing for the run is set up in the keyword file is incorrect and I am actually a little surprised that it did not trigger an error, but the CycleAt keywords make FVS reassign number of cycles and cycle lengths overriding the error of assigning a single cycle with a growth period length of 84.
The keywords I would use to set up this particular run are shown below and then the image shows the new timing keywords (on the left) generate the same timing as the old (on the right).
InvYear 2021
NumCycle 18
Setting all cycles time interval to 5 years (not actually necessary for OP
because the default time interval for the variant is 5 years.)
TimeInt 0 5
*** Grow from inventory year 2021 to common start year 2022
TimeInt 1 1
*** Last cycle is a sinlge year 2102 to 2103
TimeInt 18 1
[cid:image001.png@01D8968F.33169F80]
Thanks again because I was unable to trigger that error with the data I had. This update will be included in our next FVS release.
Cheers,
Lance
From: tickets@open-fvs.p.re.sourceforge.net tickets@open-fvs.p.re.sourceforge.net On Behalf Of Erin Crosland
Sent: Tuesday, July 12, 2022 3:25 PM
To: [open-fvs:tickets] 64@tickets.open-fvs.p.re.sourceforge.net
Subject: [External Email][open-fvs:tickets] Re: #64 OP variant stops with fatal floating-point exception
[External Email]
If this message comes from an unexpected sender or references a vague/unexpected topic;
Use caution before clicking links or opening attachments.
Please send any concerns or suspicious messages to: Spam.Abuse@usda.govSpam.Abuse@usda.gov
Ah, I see the message wasn't delivered. I've attached a copy of the keyword file and input dataset to this post. I checked that it still fails with the underflow with the OP build that I downloaded from the FVS website the other day.
Attachments:
[tickets:#64]https://gcc02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fsourceforge.net%2Fp%2Fopen-fvs%2Ftickets%2F64%2F&data=05%7C01%7C%7Cb922042773eb4f7667e508da644d1148%7Ced5b36e701ee4ebc867ee03cfa0d4697%7C0%7C0%7C637932579426414998%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=mYlwIdFGaefFLLl6e%2FFiibhSs0%2F0uezO5ryUHbSab4I%3D&reserved=0 OP variant stops with fatal floating-point exception
Status: Done
Created: Fri May 13, 2022 02:20 AM UTC by Erin Crosland
Last Updated: Tue Jul 12, 2022 09:02 PM UTC
Owner: nobody
Attachments:
I wrote to the FVS Helpdesk a month ago regarding a strange crash I observe when running the OP (Organon) variant of FVS. I do not observe this crash while running the same keyword file through the WC or PN variants of FVS.
The OP variant crashes due to a floating-point exception:
Program received signal SIGFPE: Floating-point exception - erroneous arithmetic operation
Another thing I noticed is that this crash occurs only if the length of my simulation exceeds 16 cycles. (Odd, yes?)
Anyway, I'm not much of a Fortran programmer, but I just couldn't let it be without at least making an attempt to narrow down the source of the problem. So I fired up a debugger and found the line that leads to the SIGFPE. It turns out this is line 942 in FVSmodel/trunk/organon/htgrowth.f:
FERTX2=EXP(PF3(XTIME-YF(1))+PF4(SI_1/100.0)**PF5)
This particular floating-point exception is the result of underflow. It seems to come about in the call to the EXP function. The argument to EXP here is negative. Trying to raise e to a negative power of this magnitude evidently results in a value so tiny that underflow occurs.
Moreover, it seems that since the value of XTIME increases as the cycle number increases, therefore the negative number passed to EXP gets more and more negative as cycles pass. This probably explains why the crash only comes about with a certain number of cycles in the simulation.
Whether or not this is the best approach to take, it seems the crash at least can be made to go away by treating some intermediate results as doubles (REAL8) instead of the REAL4 values they are now.
Widening the argument to EXP fixes the problem I first identified, and widening the intermediate variable FERTX2 fixes a problem that is revealed in the subsequent line if the result of the call to EXP is narrowed again too soon. Finally, we can explicitly convert the value of FERTADJ back to REAL*4 to avoid a compiler warning.
I've attached a copy of the file with my proposed changes for your review.
Sent from sourceforge.net because you indicated interest in https://sourceforge.net/p/open-fvs/tickets/64/https://gcc02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fsourceforge.net%2Fp%2Fopen-fvs%2Ftickets%2F64%2F&data=05%7C01%7C%7Cb922042773eb4f7667e508da644d1148%7Ced5b36e701ee4ebc867ee03cfa0d4697%7C0%7C0%7C637932579426414998%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=mYlwIdFGaefFLLl6e%2FFiibhSs0%2F0uezO5ryUHbSab4I%3D&reserved=0
To unsubscribe from further messages, please visit https://sourceforge.net/auth/subscriptions/https://gcc02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fsourceforge.net%2Fauth%2Fsubscriptions%2F&data=05%7C01%7C%7Cb922042773eb4f7667e508da644d1148%7Ced5b36e701ee4ebc867ee03cfa0d4697%7C0%7C0%7C637932579426414998%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=vhpxfO%2Btscqf6LjKEMVuoS9Xx3Ba21%2BrbYVgPqVOPjY%3D&reserved=0
This electronic message contains information generated by the USDA solely for the intended recipients. Any unauthorized interception of this message or the use or disclosure of the information it contains may violate the law and subject the violator to civil or criminal penalties. If you believe you have received this message in error, please notify the sender and delete the email immediately.
Related
Tickets:
#64OK, thank you, Lance. I'm happy to hear the change will be integrated into the next release.
There is no error in the keyword file, though. If it looks unusual, it's because it was machine generated. It works fine under all other variants I've tried it with, and will do under OP with the change I proposed a while ago.
The idea of using CycleAt keywords to break up a large cycle goes back at least to my old boss, who was something of an FVS expert. As your comparison shows, doing it the one way (as I have done) or doing it the other way (as you have done) is six of one, half dozen of the other.