CESM2 实验笔记

一:关于重启、运行方式(重启文件、初始文件)

1. 重新启动 RESTART

参考:
https://bb.cgd.ucar.edu/cesm/threads/how-to-restart-cesm2-1-3-fhist-from-a-backup.5245/#post-36275

适用情况:模型运行因时间不足或其它原因中断,需要继续运行,有restart文件。
方法1:将CONTINUE_RUN改为TRUE,其它保持不变。

./xmlchange CONTINUE_RUN=TRUE

If you are trying to simply continue a stopped run, then all you should set is CONTINUE_RUN to TRUE, while leaving everything else as it was originally.

注意:/run目录下的rpointer文件中的日期要与重启文件的日期一致。

方法2:
可以新建一个 hybrid 或者branch run。需要设置相应的日期变量。但是CONTINUE_RUN应该设为FALSE。因为hybrid或者branch run是一个新的拟合案例。

If, however, you are trying to create a new hybrid run, as your RUN_TYPE indicates, then you will want to modify all of the date variables like you have done, but set CONTINUE_RUN to FALSE, as a hybrid (or branch) run will be considered a new simulation.

1.1 关于重启文件

每个活动组件和部分数据组件会定期地写入重启文件,间隔时长由env_run.xml中的$REST_OPTION 和 $REST_N指定。重启文件允许模型停下来然后在重新开始,就像没有停下来过一样。所有的组件都会从驱动处接收重启和停止信息,以及通过驱动写入指定的重启和停止文件。
Restart files are written by each active component (and some data components) at intervals dictated by the driver via the setting of the env_run.xml variables, $REST_OPTION and $REST_N. Restart files allow the model to stop and then start again with bit-for-bit exact capability (i.e. the model output is exactly the same as if it had never been stopped). The driver coordinates the writing of restart files as well as the time evolution of the model. All components receive restart and stop information from the driver and write restarts or stop as specified by the driver.
在这里插入图片描述

组件写入重启文件的时候,也会写入一个重启指向文件a restart pointer file,形式为rpointer.$component。重启指向文件包含了重启文件的目录。
Whenever a component writes a restart file, it also writes a restart pointer file of the form, rpointer.$component. The restart pointer file contains the restart filename that was just written by the component. Upon a restart, each component reads its restart pointer file to determine the filename(s) to read in order to continue the model run. As examples, the following pointer files will be created for a component set using full active model components.

  • rpointer.atm
  • rpointer.drv
  • rpointer.ice
  • rpointer.lnd
  • rpointer.rof
  • rpointer.cism
  • rpointer.ocn.ovf
  • rpointer.ocn.restart

如果开启了短期归档,重启数据和指向文件会在$DOUT_S_ROOT/rest/yyyy-mm-dd-sssss目录下。

If short-term archiving is turned on, then the model archives the component restart datasets and pointer files into $DOUT_S_ROOT/rest/yyyy-mm-dd-sssss, where yyyy-mm-dd-sssss is the model date at the time of the restart (see below for more details).
If long-term archiving these restart then archived in $DOUT_L_MSROOT/rest. DOUT_S_ROOT and DOUT_L_MSROOT are set in env_run.xml, and can be changed at any time during the run.

2. RUN_TYPE 初始化运行方式

参考:https://bb.cgd.ucar.edu/cesm/threads/suggestions-for-modifying-the-start-date-cesm2.4921/#post-35058

case的初始化类型可通过env_run.xml文件中的 $RUN_TYPE 变量设置。初始化类型共有三种:

  • startup

In a startup run (the default), all components are initialized using baseline states. These states are set independently by each component and can include the use of restart files, initial files, external observed data files, or internal initialization (that is, a “cold start”). In a startup run, the coupler sends the start date to the components at initialization. In addition, the coupler does not need an input data file. In a startup initialization, the ocean model does not start until the second ocean coupling step.

  • branch

In a branch run, all components are initialized using a consistent set of restart files from a previous run (determined by the $RUN_REFCASE and $RUN_REFDATE variables in env_run.xml). The case name generally is changed for a branch run, but it does not have to be. In a branch run, the $RUN_STARTDATE setting is ignored because the model components obtain the start date from their restart data sets. Therefore, the start date cannot be changed for a branch run. This is the same mechanism that is used for performing a restart run (where $CONTINUE_RUN is set to TRUE in the env_run.xml file). Branch runs typically are used when sensitivity or parameter studies are required, or when settings for history file output streams need to be modified while still maintaining bit-for-bit reproducibility. Under this scenario, the new case is able to produce an exact bit-for-bit restart in the same manner as a continuation run if no source code or component namelist inputs are modified. All models use restart files to perform this type of run. $RUN_REFCASE and $RUN_REFDATE are required for branch runs. To set up a branch run, locate the restart tar file or restart directory for $RUN_REFCASE and $RUN_REFDATE from a previous run, then place those files in the $RUNDIR directory. See setting up a branch run.

  • hybrid

A hybrid run is initialized like a startup but it uses initialization data sets from a previous case. It is similar to a branch run with relaxed restart constraints. A hybrid run allows users to bring together combinations of initial/restart files from a previous case (specified by $RUN_REFCASE) at a given model output date (specified by $RUN_REFDATE). Unlike a branch run, the starting date of a hybrid run (specified by $RUN_STARTDATE) can be modified relative to the reference case. In a hybrid run, the model does not continue in a bit-for-bit fashion with respect to the reference case. The resulting climate, however, should be continuous provided that no model source code or namelists are changed in the hybrid run. In a hybrid initialization, the ocean model does not start until the second ocean coupling step, and the coupler does a “cold start” without a restart file.

  • hybrid vs. branch
    如果我们要跑一个和控制实验(control run)仅有些微差别的实验,比如我们只是想做一些微小调整,增加历史输出(history output),或者从一个CESM spun-up的初始态来开始模拟并保持精确的重新启动(restart)(这与重启是一致的),在这些情况下,hybrid和branch runs非常有用。
    使用hybrid run: 对于大多数不需要逐位重新启动(bit for bit restart)的应用。可以为模式运行指定新的开始日期。
    使用branch run:仅适用于需要完全重新启动的应用。不能为模型运行指定新的开始日期。它将由参考案例分配(run_refdate)。

  • GET_REFCASE: default=TRUE;如果是TRUE,数据需要预先暂存在可执行目录中(这与去年的CESM2.0不同)。

相关参数/变量

  • RUN_TYPE 初始化类型
  • RUN_REFCASE 参考案例
  • RUN_REFDATE 参考案例的运行结束时间
  • RUN_STARTDATE 当前实际案例的运行开始时间
  • GET_REFCASE TRUE or FALSE 是否自动copy重启文件

startup

重新预热,模型从零开始运行,需要经历较长时间达到平衡状态。

  • RUN_TYPE=startup
  • RUN_REFCASE:无效
  • RUN_REFDATE:无效
  • RUN_STARTDATE:可以任意指定,例如1850-01-01,或者1901-01-01
  • GET_REFCASE=FALSE

branch

  • RUN_TYPE=branch
  • RUN_REFCASE=自己指定
  • RUN_REFDATE=自己指定,参考案例的运行结束日期
  • RUN_STARTDATE=无效,branch run 会自动从重启文件中读取运行开始时间,只能接着重启文件接着跑,由参考案例分配(run_refdate)
  • GET_REFCASE=FALSE

hybrid

  • RUN_TYPE=hybrid
  • RUN_REFCASE=自己指定
  • RUN_REFDATE=自己指定,参考案例的运行结束日期
  • RUN_STARTDATE=自己指定,但和重启文件的日期应当是一致的,即RUN_STARTDATE=RUN_REFDATE
  • GET_REFCASE=FALSE

注意:实际上,无论是branch还是hybrid,RUN_STARTDATE和RUN_REFDATE原理上始终是相等的,尽管branch中无需设置RUN_STARTDATE。
重启文件中的日期必须要和设置的运行开始日期RUN_STARTDATE相等,否则便会报错。
要想branc或hybrid运行,必须要提供相应日期的重启文件才可。
在这里插入图片描述

# 查询
./xmlquery RUN_TYPE,CONTINUE_RUN,RUN_REFCASE,RUN_REFDATE,RUN_STARTDATE,RUN_REFDIR,GET_REFCASE

./xmlquery STOP_OPTION,STOP_N,RUN_TYPE,CONTINUE_RUN,RUN_REFCASE,RUN_REFDATE,RESUBMIT,RUN_STARTDATE,RUN_REFDIR,DOUT_S,DOUT_S_ROOT,JOB_WALLCLOCK_TIME,GET_REFCASE

# 修改
./xmlchange RUN_TYPE=startup,RUN_REFCASE=case.std,RUN_REFDATE=0001-01-01,RUN_STARTDATE=1850-01-01,GET_REFCASE=FALSE

3. branch 或者 hybrid运行的示例

CESM1.1 用户指南:How do I set up a branch or hybrid run?

应用:已有案例B1850用于预热20年,新建案例BHIST用于历史输出1901-2000年,利用B1850的预热结果

第一步:newcase BHIST (克隆案例是一个更好的选择,能够保证设置一模一样,避免二次设置)
./careate_newcase --compset=BHIST --res=f09_g17 --case ~/CESM2/scratch/BHIST

第二步:修改env_run.xml文件中的运行方式
for branch run:

./xmlchange RUN_TYPE=branch
./xmlchange RUN_REFCASE=B1850
./xmlchange RUN_REFDATE=0001-02-01    # 视情况而定,一般选用最近的重启文件的日期 
./xmlchange GET_REFCASE=FALSE

for a branch run, BHIST案例的env_run.xml文件应该和B1850案例的env_run.xml文件一模一样,除了RUN_TYPE设置外。在案例B1850中user_nl_xxx所做的任何修改应该在案例BHIST中user_nl_xxx一致。
branch run 中, RUN_STARTDATE 这一参数会被忽略.

for hybird run:

./xmlchange RUN_TYPE=hybird
./xmlchange RUN_REFCASE=B1850
./xmlchange RUN_REFDATE=0001-02-01    # 视情况而定,一般选用最近的重启文件的日期 
./xmlchange GET_REFCASE=FALSE

hybird run 中,开始模拟的日期可以用 RUN_STARTDATE 设置。
第三步:setup and build

./case.setup
./case.build --skip-provenance-check &> FHIST_BGC.build.spinup.log

第四步:复制初始和重启文件
如果想接着0001-02-01后跑,那么把B1850中的0001-02-01初始和重启文件复制到案例BHIST的/run/目录下。

cp -r /BIGDATA1/sysu_syli_3/CESM2/scratch/B1850test/archive/rest/0001-01-03-00000/* /BIGDATA1/sysu_syli_3/CESM2/scratch/BHIST/run/    # 复制,将0001-01-03-00000文件夹下的所有文件复制到run/目录下。
# or =
cp -r /BIGDATA1/sysu_syli_3/CESM2/scratch/B1850test/archive/rest/0001-01-03-00000/* /BIGDATA1/sysu_syli_3/CESM2/scratch/BHIST/run
# 或者
./xmlchange GET_REFCASE=TRUE  # 是否会自动复制重启文件,会在inputdata/init2中新建一个FHIST_BGC目录,将文件拷贝至改目录,随后在caseroot/run/目录中创建rpointer文件,指向init2/FHIST_BGC/目录
# 但问题是天河2没网,没办法拷贝

第五步:设置运行时长,短期归档,CPU时长等

./xmlchange DOUT_S=TRUE
./xmlchange STOP_N=1,STOP_OPTION=nyears
./xmlchange JOB_WALLCLOCK_TIME=12:00:00   # 依据模型运行速度而定,含义是一次提交最多运行12小时。如果在设定的时间内模型没有跑完,会报超时错误

第六步:submit

./case.submit

第七步:resubmit

./xmlchange CONTINUE_RUN=TRUE
./xmlchange RESUBMIT=10   # 再次重复提交10次,一次一年,则共运行11年
./case.submit

4. 其他声明

  • 控制实验
    控制实验:驱动不随时间变化,不断重复。例如B1850,用1850年的驱动不断循环重复运行,直至模型达到平衡状态,称之为工业化前的控制实验(a pre-industrial control run)。
    历史实验:驱动随时间变化。例如BHIST,利用1850-2015年的驱动运行模型,输出1850-2015年的历史输出。

b.e21.B1850.f09_g17.CMIP6-piControl.001
B1850的控制实验,会一致重复运行1850年。如果想获取2000年或其他年份的重启文件,应当选用BHIST实验。
When we run a B1850, it cycles over pre-industrial conditions. Basically, the model perpe

  • 19
    点赞
  • 65
    收藏
    觉得还不错? 一键收藏
  • 4
    评论
CESM是全球气候模型系统 (Community Earth System Model) 的一个版本。它是一个由多个组件组成的集合,包括大气、海洋、陆地和海冰模型。CESM的python版本称为python CESM。要了解更多关于python CESM的信息,您可以查看 "Downloading CESM2 (CESM2.1) — CESM CESM2.1 documentation"。此外,您还可以访问 "CESM_postprocessing"项目存储库,该存储库包含了基于CESM python的后处理代码,并提供了相关的文档和问题跟踪信息。如果您是NCAR用户,您可以在林间空地上访问这些数据集的说明。同时,您可以查看"BATCH_SYSTEM"来了解在该机器上使用的批处理系统。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *3* [安装CESM记录](https://blog.csdn.net/mayubins/article/details/122190826)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] - *2* [CESM_postprocessing:基于CESM python的后处理代码,文档和问题跟踪的项目存储库](https://download.csdn.net/download/weixin_42123191/18386442)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值