-
Notifications
You must be signed in to change notification settings - Fork 92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fates-host parameter interface #188
Conversation
In summer 2016, the clm-ed and clm parameter files diverged wrt the fnitr parameter. This points to a new default clm-ed parameter file with fnitr the same as the clm values. This is necessary to ensure future refactoring is bit for bit when the clm and ed parameters are moved into separate files. Fixes: [NGT-ED Github issue #] User interface changes?: Yes. New default parameter file for clm-ed runs. This will primarily affect testing. Science users with their own parameter files should not see differences. Code review: andre Test suite: ed - yellowstone gnu, intel, pgi Test baseline: ed-clm-d116008 Test namelist changes: yes, new default parameterfile when ed is on Test answer changes: yes, when ed is on. clm should be unchanged Test summary: all functionality tests pass. answer changing for ed tests. Test suite: clm_short - yellowstone gnu, intel, pgi Test baseline: clm4_5_12_r195 Test namelist changes: no Test answer changes: no, bit for bit for clm compsets without ed Test summary: all functionality tests pass bit for bit.
The fates parameter file is now specified via a separate namelist fates_paramfile. This variable may or may not point to the same netcdf file as the host parameter file. All fates parameters are read from this file, including the pft level variables, which are now stored in EDpftvarcon instead of pftcon. Note that some parameters are shared between the host and fates. These are 'host' parameters, not fates parameters and are read from the host file. Work for NGT-ED Github issue #155 User interface changes?: Yes. Users who have custom parameter files will need to set namelist varible 'fates_paramfile' to point to their file instead. Host parameters are still read from the file specified by namelist variable 'paramfile'. If users have modified host parameters in addition to fates parameters, they will need to update both namelist variables. Code review: andre Test suite: clm_short Test baseline: clm4_5_12_r195 Test namelist changes: none Test answer changes: bit for bit Test summary: all tests pass Test suite: ed - yellowstone gnu, intel, pgi Test baseline: a651a4f Test namelist changes: yes, new namilest var fates_paramfile Test answer changes: bit for bit Test summary: all tests pass
First implementation of FatesParametersInterface to allow fates to request a parameter set be read by the host. Implementation is used for scalar parameters. Initial implementation of 1d and 2d arrays is done, but not used (and not expected to work) until further refinement of array dimension bounds is implemented. User interface changes?: No Code review: andre Test suite: ed - yellowstone gnu, intel, pgi Test baseline: a651a4f Test namelist changes: yes, addition of fates_paramfile Test answer changes: bit for bit Test summary: all tests pass Test suite: clm_short - yellowstone gnu, intel, pgi Test baseline: clm4_5_1_r195 Test namelist changes: no Test answer changes: bit for bit Test summary: all tests pass
EDParams is primarily scalar values, grperc was the only pft parameter. This moves grperc into EDPftvarcon with the other pft parameters. User interface changes?: No Code review: andre Test suite: ed - yellowstone gnu, intel, pgi Test baseline: a651a4f Test namelist changes: yes, addition of fates_paramfile Test answer changes: bit for bit Test summary: all tests pass
User interface changes?: no Test: ERS_D_Ld5.f10_f10.ICLM45ED.yellowstone_gnu.clm-edFire Test baseline: a651a4f Test namelist changes: fates_paramfile Test answer changes: bit for bit Test summary: pass
Register and receive array parameters in fates with the host reading. Host allocates the data buffer based on the size of the largest used parameter dimension. Tested with spitfire array parameters. Some error checking of dimension sizes read from file vs memory size that fates is expecting. User interface changes?: no Test suite: ed - yellowstone gnu, intel, pgi Test baseline: a651a4f Test namelist changes: fates_paramfile Test answer changes: bit for bit Test summary: all tests pass Test suite: clm_short - yellowstone gnu, intel, pgi Test baseline: clm4_5_12_r195 Test namelist changes: none Test answer changes: bit for bit Test summary: all tests pass
Move control logic for read of fates parameters out of readParamsMod into clm_fates_interfacemod so that it can be reused for pft reads. User interface changes?: no Test: SMS_D_Ld5.f10_f10.ICLM45ED.yellowstone_intel.clm-edTest Test baseline: a651a4f Test namelist changes: addition of fates_paramfile Test answer changes: bit for bit Test summary: pass
Add logical flags to read infrastructure to distinguish between host files and fates files. Host and fates parameters are read from the correct file to avoid read errors with invalid dimension ids. Read EDSharedParams with new infrastructure. User interface changes?: no Test: SMS_D_Ld5.f10_f10.ICLM45ED.yellowstone_intel.clm-edTest Test baseline: a651a4f Test namelist changes: addition of fates_paramfile Test answer changes: bit for bit Test summary: pass
avoid circular depencies with pftcon. User interface changes?: No Test: SMS_D_Ld5.f10_f10.ICLM45ED.yellowstone_intel.clm-edTest Test baseline: ed-clm-a651a4 Test namelist changes: add fates_paramfile Test answer changes: bit for bit Test summary: pass
Test suite: ed - yellowstone gnu, intel, pgi Test baseline: a651a4f Test namelist changes: fates_paramfile Test answer changes: bit for bit Test summary: all tests pass Test suite: clm_short - yellowstone gnu, intel, pgi Test baseline: clm4_5_12_r195 Test namelist changes: none Test answer changes: bit for bit Test summary: all tests pass
The fates input file has two ways of indicating scalars, true scalars and 1-D arays with length 1. Inorder to check dimensions and compare code expectations vs what is on the file, we need to more clearly distinguish between these two ways or represeting scalars. Test suite: SMS_D_Ld5.f10_f10.ICLM45ED.yellowstone_intel.clm-edTest Test baseline: a651a4f Test namelist changes: addition of fates_paramfile Test answer changes: bit for bit Test summary: pass
Automatically check the number of dimensions and their names when reading fates parameters from the file. Compare the data on file against what is expected by the code. Test suite: ed - yellowstone gnu, intel, pgi Test baseline: a651a4f Test namelist changes: add fates_paramfile Test answer changes: bit for bit Test summary: all tests pass
Dynamically allocate pft parameters based on the input data size from the parameter file instead of a hard coded dimension size.. Test suite: ed - yellowstone gnu, intel, pgi - hobart nag Test baseline: a651a4f Test namelist changes: add fates_paramfile Test answer changes: bit for bit Test summary: all tests pass. Test suite: clm_short - yellowstone gnu, intel, pgi Test baseline: clm4_5_12_r195 Test namelist changes: none Test answer changes: bit for bit Test summary: all tests pass.
Fates parameters and dimensions have are now namespaced with 'fates_' in the input parameter file. This allows fates and clm to share an input file without name collisions. Update to new default parameter file with proper namespace. User interface changes?: yes, all fates input via the netcdf input parameter file must be namespaced with 'fates_' for both parameter and dimension names. Test suite: ed - yellowstone gnu, intel, pgi - hobart nag Test baseline: a651a4f Test namelist changes: yes, add fates_paramfile Test answer changes: bit for bit Test summary: all tests pass Test suite: clm_short - yellowstone gnu, intel, pgi Test baseline: clm4_5_12_r195 Test namelist changes: none Test answer changes: bit for bit Test summary: all tests pass
Note: both the branch and master have changed answers, so there is no easy way to test the merge against a baseline. Test suite: ed - yellowstone gnu, intel, pgi - hobart nag Test baseline: none Test namelist changes: yes, add fates_paramfile Test answer changes: yes Test summary: all tests pass Test suite: clm_short - yellowstone gnu, intel, pgi Test baseline: clm4_5_12_r195 Test namelist changes: none Test answer changes: bit for bit Test summary: all tests pass
EDpftconrd was commented out in a previous commit, but it is no longer needed and should have been completely removed. Test suite: ed - yellowstone gnu, intel, pgi Test baseline: ed-clm-3f3f16f Test namelist changes: none Test answer changes: bit for bit Test summary: all tests pass
awesome @bandre-ucar , looking forward to checking this out! |
great, @bandre-ucar. thanks- |
@bandre-ucar : I'm only starting to digest the changes, so bare with me. First off the design looks nice and clean, I like the generic register/recieve functions. One question to start off:
|
@rgknox The numrad stuff is a mess. It is stored in the netcdf as a set of hard coded 1-d arrays, but then stored in fortran as 2d arrays. It really should be cleaned up, but I'd prefer that be done as part of the data cleanup and not this PR. Maybe I'm not understanding the second part of your question but.... The 'use numrad' value can come from fates globals instead of clm as long as it's been initialized by the time it's needed. Most of the fates infrastructure get initialized long after pft parameters are read. Regardless of the source, the value gets used in allocating memory and dimension checks the same way. I don't think there are any additional checks that can be done until the hard coded 1d --> 2d arrays have been cleaned up. Or maybe I just don't understand your concern. |
Ah your right, I forgot that the hlm->fates transfer of those control parameters happens after the pft-parameter read-in. I think your echo'ing my point correctly, in that we need some FATES defined size of the dimension on those radiation arrays. |
I think there is already an example of what you want with rootprof_beta(pft, variants)? It's a 2d variable where we don't specify the exact size of either dimension in the read code. It all comes from the file. If the numrad variabes are combined into pft x numrad on the netcdf file instead of 2 pft x 1 arrays, then the dynamic allocation in fates parameters infrastructure will handle things correctly without specifying numrad at all. Then it's easy to add a dimension check after the control vars are available during fates initialization. |
ok right, I think I'm getting up to speed on what is happening. I can see in SetDimensionSizes() and its argument dimension_sizes() (which comes from the CLM side of the interface after querying the nc file) that array allocation of the parameter%data structures is dynamic and based on the array sizes in file. So the reason we are using numrad is because the radiation variables in the file themselves are not structured as 2d arrays, but we want to use the model variables as such. If we did have them as 2d arrays in the file, then we could use the *PFT_nvariants structure, which calls RetreiveParameter2DAllocate() via generic procedure. |
do we save the size of the pft dimension anywhere to a explicitly named global variable? I can't find if/where we store that number (aside from the arrays used_dimension_sizes in SetParameterDimensions() and the fates_params%parameter%dimension_sizes arrays). If we don't, can you recommend or implement that @bandre-ucar ? |
ok nevermind, I see above that this PR is an incremental step towards that goal: "This introduces dynamic allocation of pft level parameter in preparation for setting the number of pfts at run time, but still requires a hard coded number of pfts until the host code can be modified." |
One next step that I think we had mentioned in our last SE meeting was to eventually get the shared parameters, the two q10's, in with the other parameters and break from the concept of shared parameters. Maybe this something I could implement after the bulk of the parameter interface is committed to help get more familiar with this new code. |
@rgknox It depends on what you mean by "breaking with the concept of shared parameters". Fates absolutely needs to namespace it's parameters and stop reusing host variables for different purposes/values. In this PR 'shared parameters' are values which are synchronized between the host and fates. e.g. physical constants or parameters where it would cause numerical inconsistency by having different values on both sides of the interface. Leveraging the new synchronized parameters infrastructure is going to be much less error prone than duplicating information in different places. It also provides a stable API that will require fewer backward incompatible changes than manually passing values between the host and fates in code. I think what we discussed in the last SE meeting was that the q10 values don't meet that criteria, but other things do. Should we rename 'shared' to 'synchronized'? |
@bandre-ucar, I think synchronized is maybe a better word, and I think your right there may exist parameters that should be synchronized between the HLM and FATES. If we can't come up with any now, that may be true in the future. I can't think of any good examples right now though, aside from physical constants. Maybe I am missing something though. |
@rgknox Name spacing every parameter, including the host parameters, is a great idea. I'm not sure how to propose that change to alm and clm though.... We'd need to come up with a good common naming convention, lm_ or hlm_...? If we want to work out some details I'll start the discussion with clm. I'll change EDSharedParams to FatesSynchronizedHostParams or something. Let me know if you have an idea for a better name. |
RE name-spacing, some of the dimensions and non-parameter globals being sent from HLM to FATES in ED/main/FatesInterfaceMod.F90:set_fates_ctrlparms() will have the "hlm_" string prepended to all names. Although this is added with PR #180. |
@bandre-ucar, I don't really have much more to comment on for my review. Its nice work and I think things look good. I will run tests on lawrencium. I have a few general final questions just to get a handle on the design and where its going:
|
|
FYI, I added the parameter interface calls to my evolving interface call-graph: https://www.lucidchart.com/documents/edit/cfe46676-b785-4443-8aba-288b1eca76c8/2 |
@bandre-ucar these changes look good to me. Also, I've started working from this PR to add the new parameters. A couple questions: when I add the new params, should I add them to a new netcdf file based off the file fates_params.c170209.nc that you've made? If so, and while there, should I cull the non-FATES variables from that file, or is that something you are planning to do? |
@bandre-ucar ok, thanks. yeah, i talked to @rgknox. is this PR as it currently stands meant to be bit-for-bit with respect to master if we were to put the current default FATES master parameter set into the new file format? |
@ckoven None of the source code changes are expected to change answers. I did a lot of bit for bit testing to try to prevent that. But it's not going to be bit for bit with master. The clm_paramas_ed file had diverged from the clm_params file in some parameters. The files were split to have fates parameters come from the fates file and clm parameters come from the clm file, which changes answers compared to master. |
@bandre-ucar ok, great. so then the obvious/required test is to construct a new a new parameter file in the new format but with the same values as the one we are currently using to test master, make that our new default parameter file, and confirm bit-for-bitness. who is doing that? |
As per discussions offline with @bandre-ucar, we identified that fnitr in the new parameter file needs to be corrected to reflect he values in 160808, as well as BB_slope. |
At some point, not necessarily as part of this, we should retire fnitr and
replace it with a real 'vcmax25' parameter, since thatst what it really
does...
On Mar 7, 2017 4:12 PM, "Ryan Knox" <[email protected]> wrote:
As per discussions offline with @bandre-ucar
<https://github.com/bandre-ucar>, we identified that fnitr in the new
parameter file needs to be corrected to reflect he values in 160808, as
well as BB_slope.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#188 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AMWsQy5s_K2ELkdXBARgejt-jiGIBcqUks5rjeRGgaJpZM4MJQVc>
.
|
good point @rosiealice |
call fates_params%RegisterParameter(name=name, dimension_shape=dimension_shape_1d, & | ||
dimension_names=dim_names, lower_bounds=dim_lower_bound) | ||
|
||
name = 'fates_BB_slope' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rgknox I'm creating a new params file. In our off line discussion you mentioned the BB_slope and bb_slope parameters in the file. I thought you wanted me to switch to using the BB_slope value, but it is already being used. Can you clarify what change you wanted?
Also, there is a pesky artifact that is somehow still in the 160808 netcdf file, probably my fault, but ... there
as a BB_slope and a bb_slope in the parameter file. Note that the master version of the code was using the
"BB_slope" value, not the lower case (crazy annoying, I know, its just silly). So many things to do...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure thing,
I double checked the new file you made, and I see it contains both fates_BB_slope and fates_bb_slope. We only need one.
ncdump -h fates_params.c170209.nc | grep -i bb_slope
double fates_BB_slope(fates_pft) ;
double fates_bb_slope(fates_pft) ;
As far as I can tell, fates_BB_slope is the new namespace for the old "BB_slope" from netcdf 160808. That is the variable that should actually be used. So please drop fates_bb_slope (lowercase) from the new file, and double check that we are indeed using the upper-case named variable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, fates_bb_slope lower case has been removed from fates_params_c170308.nc
Update to new parameter file with the fnitr values reverted to the values in clm_params_ed.c160808.nc Test: SMS_D_Ld5.f10_f10.ICLM45ED.yellowstone_intel.clm-edTest Test baseline: ed-clm-cdb9db7 Test: status - answer changing
will do! |
New data point: I substituted the c170308 fates parameter file (revert fnitr changes) into 509fafa. A test with 509fafa is bit for bit with branch parent, d11608. So it looks like the merge to PR 174 in 3f3f16f to update with the trunk introduced an answer change. edit - confirmed that the merge is the source of the answer change. I think the problem was that the new file FatesParameterDerivedMod.F90 was still pointing to the host pftcon directly, and was using the host version of fnitr. Retesting. |
ok, thats helpful, I was in the middle of writing you an email mentioning that the 20 year diagnostics at 1x1 brazil were generating much different results than master. I will try and track down what happened on the merge as well. I'm guessing that it has something to do with the re-labelling of some of these dimension variables? |
FatesParameterderivedMod was introduced during a merge, and was using the host verison of fnitr from pftcon. It needed no be updated to point to the fates version in EDPftvarcon. Testing: Manual testing of fates_params_c170308.nc in an SMS_D_Ld5.f10_f10.ICLM45ED.yellowstone_intel.clm-edTest is bit for bit with cdb9db7.
Merge branch 'fnitr-bugfix' into andre-ed-params Test suite: ed - yellowstone gnu, intel, pgi Test baseline: cdb9db7 Test namelist: add fats_paramfile to namelist. Test status: running expect all tests pass Test suite: clm_short - yellowstone gnu, intel, pgi Test baseline: clm4_5_12_r195 Test namelist: none Test status: running expect all tests pass
It looks like you found the likely culprit, I will hold off on bug hunting until those tests are done. |
@bandre-ucar , I ran a 20 year cold-start regression test for the 1x1 brazil, updating the test to include the bug you caught in FatesParameterDerivedMod.F90 and your branch now generates indistinguishable results from master: |
@bandre-ucar , is there meant to be a distinction in usage between EDecophyscon and EDPftvarcon_inst? My reading of the code as it currently stands in this PR is that both are used pretty interchangeably to pass the PFT parameters into the code. Is that just a transient thing, or am I not perceiving an important difference between the two? |
@ckoven It's a remnant of the original implementation. I personally would consolidate everything into EDPftvarcon_inst, but it was marked as being scheduled for removal. Either way, consolidation was vary invasive to the science code and wasn't appropriate for this PR. |
@bandre-ucar ok, thanks. |
Test suite: ed - yellowstone gnu, intel, pgi hobart nag Test baseline: ed-clm-cdb9db7 Test namelist changes: add fates_paramfile Test answer changes: bit for bit Test summary: all tests pass Test suite: clm_short - yellowstone gnu, intel, pgi Test baseline: clm4_5_12_r195 Test namelist changes: none Test answer changes: bit for bit Test summary: all tests pass
Testing: Test suite: ed - yellowstone gnu, intel, pgi hobart nag Test baseline: 0ea3fed Test namelist changes: addition of fates_paramfile Test answer changes: bit for bit Test status: all tests pass Test suite: clm_short - yellowstone gnu, intel, pgi Test baseline: clm4_5_12_r195 Test namelist changes: none Test answer changes: bit for bit Test status: all tests pass
Introduce fates-host parameter interface
Introduce an interface to pass parameter information from the host to fates. Fates registers a set of parameters that it needs read in, and indicates if they are fates only parameters, or need to be synced with values from the host. The host reads the parameters and returns them to fates.
This refactor attempted to be as minimally invasive as possible to the fates science code. All existing storage and conventions for fates parameters were left in place. The only exception was the consolidation of all pft dimensioned parameters into the EDpftvarcon type. Fates no longer uses variables from the host pftcon type.
This introduces dynamic allocation of pft level parameter in preparation for setting the number of pfts at run time, but still requires a hard coded number of pfts until the host code can be modified.
Note that the default clm and old clm-ed parameter files have diverged before this work began. To do this development in a bit for bit way, the clm-ed parameter file was updated to agree with the clm default parameter file. This is answer changing compared to the fates master branch, but code was refactored in a bit for bit way. No netcdf variables were added or removed in this PR.
Fixes: #155, #156
User interface changes?: Yes.
Users will need to update custom parameter files. This introduces a new namelist variable, fates_paramfile. The fates parameters are always read from the netcdf file pointed to by fates_paramfile. All host parameters are always read from the netcdf file pointed to by paramfile. The host paramfile and fates paramfile may point to the same netcdf file.
All fates parameters and dimensions are now name spaced by 'fates_'. The variable names have remained the same, but the dimension 'param' is now 'fates_scalar'. A new default parameter file with the required changes is available. See fates_params.c170308.nc in the input data repo.
Code review: self. Discussion with clm-cmt, code walk through with ckoven, rgknox, rosie
Testing: