CESM uses parallel computing. In general, the more CPUs, the faster the computingis, but not necessary. At some point, the computing speed doesn’t change thatmuch when more cores are used. Because more cores mean more blocks, it takesmore time to exchange data from block to block (communicating), which takesmore time.
Before running “./cesm_setup”, open env_mach_pes.xml, change NTASKS for eachcomponent. Then run “./cesm_setup”. Check if TOTALPES changes accordingly. If it doesn’t, run “./cesm_setup –clean” and rerun “./cesm_setup”.
Hybridis more flexible than branch, not very strict, less chance for errors.
Open env_run.xml, change "RUN_TYPE" to “hybrid”, change"RUN_REFCASE" to your reference case name(b.e11.B1850C5CN.f09_g16.005 in my case), change "RUN_REFDATE" to thedate of the reference case from which you want to start your own case (Myreference case has 2200 years. I want to start my case from 1201-01-01, so Iset the value as “1201-01-01”, so this time will be the initial value of myhybrid run)
Copy the initial files to the run directory, i.e./glade/scratch/username/GIAF_wind_fw1/run. Change the repointer files for each component, so the model know where to find the initial files.
4 How to change env_run.xml to control your run
If you want to run a 2-month case, set "STOP_OPTION" to nmonths,"STOP_N" to 2
If you want to run a 2-year case, set "STOP_OPTION" to nyears,"STOP_N" to 2; or "STOP_OPTION" to nmonths, "STOP_N" to 24
If you want to run a 100-year case, DO NOT set "STOP_OPTION" to nyears,"STOP_N" to 100, because it will exceed the maximum clock hours (12hours for cheyenne) set by the system for each job; instead, set"STOP_OPTION" to nyears, "STOP_N" to 20, "CONTINUE_RUN"to FALSE, "RESUBMIT" to 4 (resubmit the job 4 times, plus the fistrun there will be five times in total, which makes it 100 years); if you like,you can also set "STOP_N" to 10, "CONTINUE_RUN" to FALSE,"RESUBMIT" to 9. The wall clock time varies from case to case. Youcan make some test runs to make sure your wall clock time for your own case.
If you have had a 100-year run already, you want another 100 years, i.e. 101-200,set "STOP_N" to 20, "CONTINUE_RUN" to TRUE,"RESUBMIT" to 4
Because of a bug, this version cannot resubmit jobs. Add “cd $CASEROOT” in front of “if($RESUBMIT > 0) then” in both “GIAF_wind_fw1.run” and “Tools/cesm_postrun_setup”. Or other wise the script cannot find command“./xmlchange”
Make sure "DOUT_S" is "TRUE", so the short term archiving is on,and the archiving directory is the value of “DOUT_S_ROOT”.
5 How to control wall clock time for each job
Open GIAF_wind_fw1.run. Change “#PBS -l walltime=8:00:00”. The specific parametername may vary from server to server. Change the project number “#PBS –A ” if necessary. After the code is built successfully, you can submit your job. Don’t submit the job with your own command. Use the submit script.
6 How to change POP2 model parameters
All the model parameters are in “~/cases/GIAF_wind_fw1/CaseDocs/pop2_in”, such astime steps numbers “dt_count”, interpolation type for wind stress “ws_interp_type”. The list of these parameters that controls the model iscalled namelist (nl). DO NOT change it directly in “~/cases/GIAF_wind_fw1/CaseDocs/pop2_in”.Change it in “~/cases/GIAF_wind_fw1/user_nl_pop2”. Then run “./preview_namelists” to update your modification. Then check“~/cases/GIAF_wind_fw1/CaseDocs/pop2_in” and“/glade/scratch/username/GIAF_wind_fw1/run/pop2_in” the parameter has been changed indeed.
7 How to use your own atm forcing data to force POP2
There are ten variables from the atmosphere forcing the ocean, i.e.
PREC(precipitation)
LWDN(long wave downward)
SWDN(short wave downward)
SWUP(short wave upward)
DN10(air density at 10 m) 
Q_10 (specifichumidity at 10 m)
SLP(sea level pressure)
T_10(air temperature at 10 m)
U_10(zonal wind at 10 m)
V_10(moridional wind at 10 m)
Say I want to change precipitation.
“cp ~/cases/GIAF_wind_fw1/CaseDocs/datm.streams.txt.CORE2_IAF.GCGCS.PREC~/cases/GIAF_wind_fw1/user_datm.streams.txt.CORE2_IAF.GCGCS.PREC”
***note that add “user_” in the front of the file name ***
Open file “user_datm.streams.txt.CORE2_IAF.GCGCS.PREC”. Change the second file pathto your forcing data file path.
Change the listed data filename to your own data file name. Prepare your own data assimilar to the original data as possible. For example, use annual data and ncfile format and same resolution.
Open “~/cases/GIAF_wind_fw1/user_nl_datm”, copy “stream = … , … , … , … ” from “~/cases/GIAF_wind_fw1/CaseDocs/datm_atm_in” to user_nl_datm, then change the variable and year range you want to change.
After building the case, check “/glade/scratch/username/GIAF_wind_fw1/run/datm.streams.txt.CORE2_IAF.GCGCS.PREC” and “~/cases/GIAF_wind_fw1/CaseDocs/datm.streams.txt.CORE2_IAF.GCGCS.PREC” to make sure it is changed successfully.
8 How to read in your own data by changing the code
POP2’s code is in ~/cesm1_2_2_1/models/ocn/pop2/source/. The driver of POP2 is ~/cesm1_2_2_1/models/ocn/pop2/drivers/cpl_mct/ocn_comp_mct.F90. This file controls the process of the ocean model and sends/receives data to/from the coupler. Copy the f90 file you want to change to “GIAF_wind_fw1/SourceMods/src.pop2”. NEVER change the code file in“~/cesm1_2_2_1/models/ocn/pop2/source/”, or other wise all the new cases will change.
I created a new f90 file in “GIAF_wind_fw1/SourceMods/src.pop2/” as my ownmodule. This file is copied from forcing_shf.f90, therefore at the beginning using the same modules as forcing_shf.f90. Add more modules at the beginning if necessary.
Define variables, for example
“real(r8),dimension(nx_block,ny_block,max_blocks_clinic),public:: clmt_sst_cesm”
Parallel computing cuts the entire domain into small blocks, nx_block is the grid number for one block in x-axis, ny_block is similar but in y direction. I don’t know the meaning of max_blocks_clinic. Define a “public” variable so other files or modules can use it.
Define a subroutine in my own module to read the data:
427 subroutine read2_clmt(CLMT_DATA,input_filename,variable_name)
428 integer (kind=int_kind) :: nu1 !unit number
429 character (*), intent(in) :: variable_name, input_filename
430 real(r8) :: tx_g(nx_global,ny_global) !global means the data domain isthe entire region.
431 real(r8), dimension(nx_block,ny_block,max_blocks_clinic), &
432 intent(inout) :: &
433 CLMT_DATA ! data you want toread
434
435 !read in global data
! For parallel computing, there aremany tasks at the same time. only use the master_task to read data
436 if (my_task == master_task) then
437
438 call get_unit(nu1) !use this function to get unit number, don’tuse your self-defined unit number
439 open(nu1,file=input_filename,form='unformatted', convert='little_endian', &
440 access='direct',recl=nx_global*ny_global*8,status='old',action='read')!data is double
441 read(nu1, rec=1) tx_g
442 close(nu1)
443 call release_unit(nu1)
444 !output the data, make sure it is readcorrectly
445 !write(stdout,*) "read2_clmt,nx_global, ny_global: ",nx_global,ny_global,input_filename
446 !write(stdout,*)"read2_clmt",tx_g(:,70)
447 end if
448
449 !distribute global data to each processor,cut the entire domain into blocks
450 call scatter_global(CLMT_DATA, tx_g,master_task, distrb_clinic,&
451 field_loc_center,field_type_scalar)
452
453 end subroutine read2_clmt
• get_unit, release_unit andscatter_global are defined in other modules, use that module at the beginning.To find out which module defines the subroutine you need, use “grep”
• some variables, such as master_taskand distrb_clinic, are also defined inother modules. Use them at the beginning.
The data I used is monthly data, I needed to interpolate the data to each timestep. Use “interpolate_forcing” in forcing_tools.f90 to interpolate the monthly data into current time step. See how to use it in forcing_shf.f90. If you need other subroutine, read the code, find a similar one and modify it.
Now my data is ready to use. Say the variable name is taux_cesm. It is the current TAUX interpolated from my own monthly data. It is public. So how to use it? I want to change the input wind stress. Ocn_comp_mct.f90 receives data from coupler. I add “use my_own_module” at the beginning of ocn_comp_mct.f90 to use my own module. Since taux_cesm is a public variable, I can use it directly inthe subroutine ocn_import_mct where reads in TAUX from the coupler.
9 How to save any variables in POP2
Say I want to save the advection term in heat budget equation below:
HC_tendency= advection + diffusion + surface_heat_flux
Open baroclinic.f90, define a variable for the advection term
“real(r8),dimension(nx_block,ny_block,km,max_blocks_clinic),public:: Cadv”
Then read the code, find out how the model saves other variables, say “TEMP”, followit. For example, define tavg_Cadv similar to tavg_TEMP, call define_tavg_field,call accumulate_tavg_field, Get the advection value Cadv(:,:,k,bid)=-WORKN(:,:,1) in line 1873 in baroclinic.f90.
Last step: copy “~/cases/GIAF_wind_fw1/Buildconf/pop2conf/gx1v6_tavg_contents” to “~/cases/GIAF_wind_fw1/SourceMods/src.pop2/”.
Then go to “~/cases/GIAF_wind_fw1/SourceMods/src.pop2”, open “gx1v6_tavg_contents”add the variable name, stream number (add “1 Cadv” in my case).
You don’t have to do this for every variable. For some variables, they are already set up and ready for output. All you need to do is to modify “gx1v6_tavg_contents”. Check the POP2 website for more information.
10 Postscript.
I am not an expert about POP2. I cannot guarantee every thing I mentioned above is correct. This is only my experiences using this model during my PhD period. Hope it is helpful and have fun running your model!