Scheduled Downtime
On Tuesday 24 October 2023 @ 5pm MT the forums will be in read only mode in preparation for the downtime. On Wednesday 25 October 2023 @ 5am MT, this website will be down for maintenance and expected to return online later in the morning.
Normal Operations
The forums are back online with normal operations. If you notice any issues or errors related to the forums, please reach out to help@ucar.edu

Regarding Dynamic Parameter File Input

lucia

luyaohuang
Member
Hello everyone, I am currently running CLM5.0. I am facing an issue. CLM5.0 requires an input parameter file, clm5_params.c171117.nc, during the simulation. However, I now want to dynamically change this file every year. I have made changes to the atmch4 parameter in the file for each year from 1979 to 2018, and therefore, I have generated 30 different parameter files. Now, while running the model, I want to modify this file each year in the user_nl_clm by using a file name like paramfile = 'params$YEAR.nc'. I have been trying for a long time but have not found an appropriate solution yet. If anyone has any suggestions, I would greatly appreciate it!
 

katec

CSEG and Liaisons
Staff member
Are you trying to do this while the model is running or are you stopping each run after a year, updating the user_nl_clm file, and then starting the run again? The first approach won't really work. We could maybe hack the second one with some scripting. It would be easiest to do if you are using a recent version of CESM. Do you know what version of CESM you are using to run your simulations?

I wonder if there might be a way to update this variable at runtime, and not need the 30 paramfiles. Simply hardcoding an array of values in CLM that updates the parameter at the year change. This bit of code modification probably wouldn't be too difficult with some guidance from the CLM scientists. Please answer my two questions above and then I will direct this question to the right place. Thanks!
 
Vote Upvote 0 Downvote

lucia

luyaohuang
Member
Hello, thank you for your response! I plan to update dynamically during the model run because if I stop the model each year, I would need to recreate the case for the new year. If I want to run for 1000 years, would I need to create 1000 cases? I am using release-clm5.0.01 in CESM2.0.0. Regarding simply hardcoding an array of values in CLM to update the parameter at the year change, I wonder if it can be updated through a stream file? However, I am not very familiar with the specific stream file mechanism and am unsure how to match the time with the stream.
 
Vote Upvote 0 Downvote

katec

CSEG and Liaisons
Staff member
Hi @lucia , you wouldn't need a 1000 cases if you did an in-case branch or hybrid restart each time. But that can be complicated, error prone, and reduces the nice documentation that each case directory gives for your experiments. At any rate, I think @slevis agrees with me that hard-coding your values is likely easier than trying to change the stream files. I'm going to move this thread into the CLM board to hopefully get input from CLM experts, but here's my general thinking. This atmch4 variable is only used in one file in CLM: ch4Mod.F90. This module includes the get_nstep function already, so we should be able to calculate the current time step. Here's what I would try first. Make the "atmch4" parameter of the params_type an array. In the readParams function, where the code looks like:
params_inst%atmch4=tempr
instead set params_inst to your hard-coded array of values. Something like:
params_inst%atmch4=[0,10,20,30,40,50,60,70,80,90,100]
Then, each place where params_inst%atmch4 is accessed, instead you will need to calculate the year index like:
iYr = floor(get_nstep()/17520.0_r8)
where 17520 is the number of 30 minute time steps in a 365 day year. If your time step is different, you may need a different number there.
Then access the array like:
atmch4=params_inst%atmch4[iYr]

And you're done!
 
Vote Upvote 0 Downvote

lucia

luyaohuang
Member
Thank you for your reply. I have now made atmch4 into a stream file like carbon dioxide. Actually, I have tried this method before, but I found that I changed the global variable forc_pch4 during the modification process, which caused some errors. Now I have solved this problem
 
Vote Upvote 0 Downvote
Top