refactor nudging code to use cdeps on line remapping and interpolation#243
refactor nudging code to use cdeps on line remapping and interpolation#243mvertens wants to merge 23 commits intoNorESMhub:noresm_developfrom
Conversation
…r.F90 for model_mesh and model_clock
…sh and model_clock from outside the nuopc cap
…refactor_nudging2
…refactor_nudging2
…refactor_nudging2
…o feature/refactor_nudging3
40ad302 to
875a455
Compare
gold2718
left a comment
There was a problem hiding this comment.
This work will be a great improvement to NorESM/CAM!
- I have a few questions and a bunch of (hopefully easy) change requests.
- I have included a set of change requests to refactor how the model is aligned with the nudging data. This is to allow nudging to be turned on and off during a model run while independently choosing which nudging data to use.
- Consider moving the
cnst_get_indcall in timestep_init to init and make theQindex a module variable. Then, you can remove the call innudging_timestep_tend(it is not the cheapest function).
| <entry id="Nudge_lev_dimname" type="char*256" category="nudging" | ||
| group="nudging_nl" valid_values="" > | ||
| Name of vertical dimension in file. | ||
| Default: none | ||
| </entry> |
There was a problem hiding this comment.
Do we need this if we have Nudge_levname (introduced below)? You can easily find the dimension name from the variable name if needed (they should be the same for a coordinate variable).
In addition, it is not used anywhere in the code.
Please remove.
| use spmd_utils, only: mpi_integer, mpi_real8, mpi_logical, mpi_character | ||
| use cam_logfile, only: iulog | ||
| use zonal_mean_mod, only: ZonalMean_t | ||
| use ESMF |
There was a problem hiding this comment.
Please dress this naked use statement.
| use ESMF , only : ESMF_DistGrid, ESMF_DistGridCreate | ||
| use ESMF , only : ESMF_Mesh, ESMF_MeshCreate, ESMF_MeshGet, ESMF_FILEFORMAT_ESMFMESH | ||
| use ESMF , only : ESMF_Clock, ESMF_ClockGet, ESMF_ClockSet, ESMF_ClockGetNextTime, ESMF_ClockAdvance | ||
| use ESMF , only : ESMF_CLockCreate |
There was a problem hiding this comment.
This is not used anymore, please remove
| ! Nudging will never occur, so switch it off | ||
| Nudge_Model = .false. | ||
| write(iulog,*) ' ' | ||
| write(iulog,*) 'NUDGING: WARNING - Nudging has been requested by it will' |
There was a problem hiding this comment.
Typo?
| write(iulog,*) 'NUDGING: WARNING - Nudging has been requested by it will' | |
| write(iulog,*) 'NUDGING: WARNING - Nudging has been requested but it will' |
| allocate(Nudge_PStau(pcols,begchunk:endchunk),stat=istat) | ||
| call alloc_err(istat,'nudging_init','Nudge_PStau',pcols*((endchunk-begchunk)+1)) | ||
| allocate(Nudge_Utau0(pcols,pver,begchunk:endchunk),stat=istat) | ||
| call alloc_err(istat,subname,'Nudge_Utau',size3d) |
There was a problem hiding this comment.
Please correct the error strings here and below?
| call alloc_err(istat,subname,'Nudge_Utau',size3d) | |
| call alloc_err(istat,subname,'Nudge_Utau0',size3d) |
There was a problem hiding this comment.
I think that since the Nudge_begin and Nudge_end variables are model times, we need begin and end variables that are specific to the nudging dataset being used (similar to other uses of CDEPS stream info):
<entry id="nudge_data_year_first" type="integer" category="nudging"
group="nudging_nl" valid_values="" >
First year to use in Nudge_Filenames dataset.
Default: none
<entry id="nudge_data_year_last" type="integer" category="nudging"
group="nudging_nl" valid_values="" >
Last year to use in Nudge_Filenames dataset.
Default: none
</entry>
| Nudge_Force_Opt, Nudge_TimeScale_Opt, & | ||
| Nudge_Beg_Year, Nudge_Beg_Month, Nudge_Beg_Day, & | ||
| Nudge_End_Year, Nudge_End_Month, Nudge_End_Day, & | ||
| Nudge_Align_Year, Nudge_Mapalgo, Nudge_Taxmode, & |
There was a problem hiding this comment.
Based on my comments in namelist_definition.xml, I think this should be:
| Nudge_Align_Year, Nudge_Mapalgo, Nudge_Taxmode, & | |
| Nudge_Year_Align, nudge_data_year_first, nudge_data_year_last, Nudge_Mapalgo, Nudge_Taxmode, & |
Also, nudge_data_year_first and nudge_data_year_last have to be declared above, and initialized and broadcast below.``
|
|
||
| <entry id="Nudge_Align_Year" type="integer" category="nudging" | ||
| group="nudging_nl" valid_values="" > | ||
| Model year to align with Nudge_Beg_Year. |
There was a problem hiding this comment.
Based on comments above, I think this could be clarified:
| Model year to align with Nudge_Beg_Year. | |
| Model (simulation) year to align with nudge_data_year_first. | |
| If this is set to Nudge_Beg_Year, then nudging will begin with the beginning of the dataset. | |
| If this is set to some other year, there will be an offset between the model year and the year in the nudging data currently being used. |
| stream_yearFirst = nudge_year_first, & | ||
| stream_yearLast = nudge_year_last, & |
There was a problem hiding this comment.
Based on comments above, I think this should be:
| stream_yearFirst = nudge_year_first, & | |
| stream_yearLast = nudge_year_last, & | |
| stream_yearFirst = nudge_data_year_first, & | |
| stream_yearLast = nudge_data_year_first, & |
| stream_yearFirst = nudge_year_first, & | ||
| stream_yearLast = nudge_year_last, & |
There was a problem hiding this comment.
Based on comments above, I think this should be:
| stream_yearFirst = nudge_year_first, & | |
| stream_yearLast = nudge_year_last, & | |
| stream_yearFirst = nudge_data_year_first, & | |
| stream_yearLast = nudge_data_year_first, & |
gold2718
left a comment
There was a problem hiding this comment.
This work will be a great improvement to NorESM/CAM!
- I have a few questions and a bunch of (hopefully easy) change requests.
- I have included a set of change requests to refactor how the model is aligned with the nudging data. This is to allow nudging to be turned on and off during a model run while independently choosing which nudging data to use.
- Consider moving the
cnst_get_indcall in timestep_init to init and make theQindex a module variable. Then, you can remove the call innudging_timestep_tend(it is not the cheapest function).

Summary: refactor nudging code to use cdeps on line remapping and interpolation
Contributors: @gold2718
Reviewers: @gold2718
Purpose of changes:
The current nudging code (nudging.F90) requires a single file for every time sample - and often this is every 6 hours. In addition it does not do any mapping from the forcing data to the model grid. Using the CDEPS inline functionality along with its capability to do online horizontal regridding (including for multiple vertical levels) and time interpolation the nudging code has been completely refactored. With this new code - monthly nudging data can be read at just one resolution and the model vertical levels and used with any model grid.
The one change that comes with this is if there is missing data. In the original scheme, if missing data was encountered then the model 'coasted' through the forcing interval and was not nudged. In the new scheme, the time interpolation (linear or upper) is used with the actual data that is available.
To see more details of the inline functionality from CDEPS used here see: https://escomp.github.io/CDEPS/versions/master/html/index.html and in particular https://escomp.github.io/CDEPS/versions/master/html/streams.html#data-model-stream-inline-api
Changes made to build system: None
Changes made to the namelist: The following new namelist variables were introduced:
Nudge_Filenames, Nudge_Meshfile, Nugde_beg_day, Nudge_beg_month, Nudge_beg_year, Nudge_end_day, Nudge_end_month, Nudge_end_year, Nudge_file_times_per_day, Model_update_times_per_dayChanges to the defaults for the boundary datasets: None
Substantial timing or memory changes: TODO - the expectation is that the new code should be faster than the old one since a new file does not have to be opened and closed at every nudging time step. This needs to be confirmed.
Validation:
The following validation was run. using a noresm3_0_beta09 sandbox with this PR and the CDEPS PR NorESMhub/CDEPS#26. Two simulations were done - a reference simulation and a nudging to the reference simulation.
Reference Simulation:
with the following user_nl_cam
Nudging Simulation:
The following was set in
user_nl_cam:Following is the nudging validation:
[ List each test suite run. For each suite, include machine, compiler, and any test failures.
For each failure, include the contents of TestStatus or the output from cs.status.testid for that test ]
Issues addressed by this PR: [ For each issue include a GitHub issue entry, one per line. ]