Hi! I'm working with Professors Quinn Thomas and Cayelan Carey at Virginia Tech, and I've developed some bug fixes regarding time that you might be interested in. Currently, GLM seems to have bugs that arise when we try to run it from any time except midnight to midnight, and we wanted to be able to run it at other times of day. We believe these bug fixes allow GLM to be run from any time of day to any time of day. I've added a list explaining the changes we made below, as well as some testing results that appear to show the correctness of these changes.
Changes
Commit 1049231
Problem: if timefmt==2 and the times given span a non-integer number of days, then the variable nDays will be rounded inconsistently (down to 0 if the span is less than 1 day, and up to the next-highest integer if the span is greater than 1 day)
now nDays is always rounded down to the next-lowest integer if the timespan is a non-integer number of days
also solves a pointer error with nDays
Commit 36999f9
Problem: if timefmt==3, variable secs2 is always set equal to 0 even when the stop time should not be midnight
secs2 should equal secs1, because with timefmt==3 the stop time is an integer number of full days after the start time
Commit 7811929
Problem: the NetCDF output lists the units for time as hours since midnight of the start day, rather than hours since the given start time. The variable START_TOD is not visible here, where it is needed. In addition, it is capitalized like a constant, which it is not.
Commit 06ead88
Problem: START_ICLOCK is being set to approximately the start time of day (variable startTOD) divided by the timestep (dt), but it is later used as the start time of day. This means that unless dt==1, the start time of the model is earlier than it should be. It doesn't seem like there's any reason for not simply setting START_ICLOCK equal to startTOD, as it isn't used anywhere else.
Commit 13935ac
Problem: the program runs by days and doesn't keep track of the stop time for the last day. This means it always runs until the end of the final day and can't stop at a different time of day.
my solution also allows for running the simulation for finer-grained spans of time than multiples of 24 hours
[ ] ISSUE: I implemented my solution in all three functions (do_model, do_model_non_avg, and do_model_coupled), but I only checked its accuracy in do_model and do_model_non_avg (not in do_model_coupled), as I'm not familiar with do_model_coupled.
Commit 142522b
Problem: if the meteorology data file does not start at midnight, then data for the first day will be read incorrectly, because the variable idx will be reset to equal a different counter variable that does start at 0, causing the variable met to be returned with meteorology data shifted to start at midnight
[ ] ISSUE: I'm not sure what problem the code I deleted was intended to prevent. That should be checked by someone who does know its original intent.
Testing
I ran several tests comparing results from my modified code and the unmodified code; here are just three tests (with non_avg = .true.) demonstrating that this appears to be correct. For each, I've included a graph of shortwave radiation (I_0), which is read directly from an input file, and a graph of surface temperature, which is derived from calculations. Green represents results from my modified GLM code, and red is results from the original unmodified GLM code. Although these tests are with AED off, Professor Thomas has also tested the modifications with AED on and confirmed that it seems to work.
Test 1: 1 day, 12am to 12am on both unmodified and modified code. Results match up perfectly, as expected.
Test 2: 15 days, 12am to 12am on unmodified code, 12pm to 12pm on modified code. I_0 matches up, as expected, while surface temp starts off relatively different (as the unmodified code has had an extra 12 hours to run) but converges after both models have had some time to run.
Test 3: 1 day, 12am to 12am on unmodified code, 12pm to 12pm on modified code. This is identical to the beginning of Test 2, but it shows clearly that I_0 matches up, even with the time difference.
We conclude that the changes I made seem to lead to correct results. I'm happy to answer questions or make any corrections.
Hi! I'm working with Professors Quinn Thomas and Cayelan Carey at Virginia Tech, and I've developed some bug fixes regarding time that you might be interested in. Currently, GLM seems to have bugs that arise when we try to run it from any time except midnight to midnight, and we wanted to be able to run it at other times of day. We believe these bug fixes allow GLM to be run from any time of day to any time of day. I've added a list explaining the changes we made below, as well as some testing results that appear to show the correctness of these changes.
Changes
Commit 1049231
Commit 36999f9
Commit 7811929
Commit 06ead88
Commit 13935ac
Commit 142522b
Testing
I ran several tests comparing results from my modified code and the unmodified code; here are just three tests (with non_avg = .true.) demonstrating that this appears to be correct. For each, I've included a graph of shortwave radiation (I_0), which is read directly from an input file, and a graph of surface temperature, which is derived from calculations. Green represents results from my modified GLM code, and red is results from the original unmodified GLM code. Although these tests are with AED off, Professor Thomas has also tested the modifications with AED on and confirmed that it seems to work.
Test 1: 1 day, 12am to 12am on both unmodified and modified code. Results match up perfectly, as expected.
Test 2: 15 days, 12am to 12am on unmodified code, 12pm to 12pm on modified code. I_0 matches up, as expected, while surface temp starts off relatively different (as the unmodified code has had an extra 12 hours to run) but converges after both models have had some time to run.
Test 3: 1 day, 12am to 12am on unmodified code, 12pm to 12pm on modified code. This is identical to the beginning of Test 2, but it shows clearly that I_0 matches up, even with the time difference.
We conclude that the changes I made seem to lead to correct results. I'm happy to answer questions or make any corrections.