Scheduled Downtime
On Friday 21 April 2023 @ 5pm MT, this website will be down for maintenance and expected to return online the morning of 24 April 2023 at the latest

Starting Cost Function Gradient is NaN

This post was from a previous version of the WRF&MPAS-A Support Forum. New replies have been disabled and if you have follow up questions related to this post, then please start a new thread from the forum home page.


New member
Hi all,

I've finally got WRFDA running in 4DVAR mode, but it's failing to converge because of a cost function calculation issue. After the first round I get:
Loop Iter Cost Function Gradient Step
minimize_cg 1 0 2.059757428430507D+03 NaN 0.000000000000000D+00

After the second round, it's
minimize_cg 1 1 NaN NaN 0.000000000000000D

I've attached the full rsl.error and rs.out files, as well as the namelist, in case those are helpful.

Any thoughts about what would cause the cost function calculation to blow up?



  • rsl.out.0000.txt
    297.5 KB · Views: 88
  • rsl.error.0000.txt
    293.4 KB · Views: 87
  • namelist.input
    2.1 KB · Views: 98
Hi Dan...

I'm not a WRFDA user, however, I did notice something. If you look at the timestep times in rsl.out.0000,
there seems to be a lot of bouncing around, especially to higher numbers, then fall back to lower numbers.

This suggests to me that there may be a numerical instability somewhere. If something is marginally unstable,
it *might* be a reason for the NaN problem.

Check all the rsl.out* and rsl.error* files for complaints.

You didn't way what version you are using. If it isn't current, you might try upgrading to see if that helps.
HI Kevin,

Thanks, that's worth checking- I could drop the timestep down to 10 or 15 seconds (though it'll cost me...). This is version 4.0.1.

Hi Dan,
Have you fixed this problem?
I am facing the same problem with WRFDA V 4.3.3. Changing the timestep to smaller values is not fixing it either.
The timestep times keep becoming larger and smaller again.
If you have found a solution, please help me out.