forked from E3SM-Project/E3SM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_e3sm.template.csh
executable file
·1433 lines (1194 loc) · 68.9 KB
/
run_e3sm.template.csh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#! /bin/csh -fe
### This script was created 2015-11-15 by Philip Cameron-Smith ([email protected]) and Peter Caldwell
### and incorporates some features originally from Hui Wan, Kai Zhang, and Balwinder Singh.
### Significant improvements from Michael Deakin and Chris Golaz.
###
###===================================================================
### THINGS USERS USUALLY CHANGE (SEE END OF SECTION FOR GUIDANCE)
###===================================================================
### BASIC INFO ABOUT RUN
set job_name = A_WCYCL1850_template
set compset = A_WCYCL1850
set resolution = ne4_oQU240
set machine = default
set walltime = default
setenv project default
### SOURCE CODE OPTIONS
set fetch_code = false
set e3sm_tag = master
set tag_name = default
### CUSTOM CASE_NAME
set case_name = ${machine}.${tag_name}.${job_name}.${resolution}
### BUILD OPTIONS
set debug_compile = false
set old_executable = false
### AUTOMATIC DELETION OPTIONS
set seconds_before_delete_source_dir = -1
set seconds_before_delete_case_dir = 10
set seconds_before_delete_bld_dir = -1
set seconds_before_delete_run_dir = -1
### SUBMIT OPTIONS
set submit_run = true
set debug_queue = true
### PROCESSOR CONFIGURATION
set processor_config = S
### STARTUP TYPE
set model_start_type = initial
set restart_files_dir = none
### DIRECTORIES
set code_root_dir = default
set e3sm_simulations_dir = default
set case_build_dir = default
set case_run_dir = default
set short_term_archive_root_dir = default
### LENGTH OF SIMULATION, RESTARTS, AND ARCHIVING
set stop_units = ndays
set stop_num = 1
set restart_units = $stop_units
set restart_num = $stop_num
set num_resubmits = 0
set do_short_term_archiving = false
### SIMULATION OPTIONS
set atm_output_freq = -24
set records_per_atm_output_file = 40
set start_date = default
### COUPLER HISTORY FILES
set do_cpl_hist = true
set cpl_hist_units = ndays
set cpl_hist_num = 1
#==============================
#EXPLANATION FOR OPTIONS ABOVE:
#==============================
### BASIC INFO ABOUT RUN (1)
#job_name: This is only used to name the job in the batch system. The problem is that batch systems often only
# provide the first few letters of the job name when reporting on jobs in the queue, which may not be enough
# to distinguish simultaneous jobs.
#compset: indicates which model components and forcings to use. List choices by typing `create_newcase -list compsets`.
# An (outdated?) list of options is available at http://www.cesm.ucar.edu/models/cesm1.0/cesm/cesm_doc_1_0_4/a3170.html
#resolution: Model resolution to use. Type `create_newcase -list grids` for a list of options or see
# http://www.cesm.ucar.edu/models/cesm1.0/cesm/cesm_doc_1_0_4/a3714.htm. Note that E3SM always uses ne30 or ne120 in the atmosphere.
#machine: what machine you are going to run on. This should be 'default' for most machines, and only changed for machines with multiple queues, such as cori.
# Valid machine names can also be listed via `create_newcase -list machines`
#walltime: How long to reserve the nodes for. The format is HH:MM(:SS); ie 00:10 -> 10 minutes.
# Setting this to 'default' has the script determine a reasonable value for most runs.
#project: what bank to charge for your run time. May not be needed on some machines.
# Setting this to 'default' has CIME determine what project to use
# NOTE: project must be an *environment* variable on some systems.
### SOURCE CODE OPTIONS (2)
#fetch_code: If True, downloads code from github. If False, code is assumed to exist already.
# NOTE: it is assumed that you have access to the E3SM git repository. To get access, see:
# https://acme-climate.atlassian.net/wiki/display/Docs/Installing+the+ACME+Model
#e3sm_tag: E3SM tagname in github. Can be 'master', a git hash, a tag, or a branch name. Only used if fetch_code=True.
# NOTE: If e3sm_tag=master or master_detached, then this script will provide the latest master version, but detach from the head,
# to minimize the risk of a user pushing something to master.
#tag_name: Short name for the E3SM branch used. If fetch_code=True, this is a shorter replacement for e3sm_tag
# (which could be a very long hash!). Otherwise, this is a short name for the branch used. You can
# choose TAG_NAME to be whatever you want.
### BUILD OPTIONS (3)
#debug_compile: If TRUE, then compile with debug flags
# Compiling in debug mode will stop the run at the actual location an error occurs, and provide more helpful output.
# However, it runs about 10 times slower, and is not bit-for-bit the same because some optimizations make tiny change to the
# numerics.
#old_executable: If this is a path to an executable, then it is used instead of recompiling (it is copied across).
# If TRUE then skip the build step entirely.
# If FALSE then build a new executable (using any already compiled files). If you want a clean build then
# set seconds_before_delete_bld_dir>=0.
# NOTE: The executable that will be copied should be the same as would be created by compiling (for provenance).
# NOTE: The path should either be an absolute path, or a path relative to the case_scripts directory.
# NOTE: old_executable=true is a risk to provenance, so this feature may be removed in the future.
# However the build system currently rebuilds a few files every time which takes several minutes.
# When this gets fixed the cost of deleting this feature will be minor.
### AUTOMATIC DELETION OPTIONS (4)
#seconds_before_delete_source_dir : If seconds_before_delete_source_dir>=0 and fetch_code=true, this script automatically deletes
# the old source code directory after waiting seconds_before_delete_source_dir seconds (to give you the opportunity to cancel
# by pressing ctrl-C). To turn off the deletion (default behavior), set $num_seconds_before_deleting_source_dir to be negative.
#seconds_before_delete_case_dir : Similar to above, but remove the old case_scripts directory. Since create_newcase dies whenever
# the case_scripts directory exists, it only makes sense to use $seconds_before_delete_case_dir<0 if you want to be extra careful and
# only delete the case_scripts directory manually.
#seconds_before_delete_bld_dir : As above, but the old bld directory will be deleted. This makes for a clean start.
#seconds_before_delete_run_dir : As above, but the old run directory will be deleted. This makes for a clean start.
### SUBMIT OPTIONS (5)
#submit_run: If True, then submit the batch job to start the simulation.
#debug_queue: If True, then use the debug queue, otherwise use the queue specified in the section on QUEUE OPTIONS.
### PROCESSOR CONFIGURATION (6)
#processor_config: Indicates what processor configuration to use.
# 1=single processor, S=small, M=medium, L=large, X1=very large, X2=very very large, CUSTOM=defined below.
# The actual configurations for S,M,L,X1,X2 are dependent on the machine.
### STARTUP TYPE (7)
#model_start_type: Specify how this script should initialize the model: initial, continue, branch.
# These options are not necessarily related to the CESM run_type options.
# 'initial' means the intial files will be copied into the run directory,
# and the E3SM run_type can be 'initial', 'hybrid', or 'restart', as specified by this script below.
# 'continue' will do a standard restart, and assumes the restart files are already in the run directory.
# 'branch' is almost the same, but will set RUN_TYPE='branch', and other options as specified by this script below.
# NOTE: To continue an existing simulation, it may be easier to edit env_run and [case].run manually in the
# case_scripts directory. The biggest difference is that doing it with this script
# may delete the previous case_scripts directory, and will provide a way to pass a simulation to someone else.
### DIRECTORIES (8)
#code_root_dir: The directory that contains (or will contain) the source code and other code files. (formerly $CCSMROOT)
# If fetch_code=false, this is the location where the code already resides.
# If fetch_code=true, this is where to put the code.
### LENGTH OF SIMULATION, RESTARTS, AND ARCHIVING (9)
#stop_units: The units for the length of run, eg nhours, ndays, nmonths, nyears.
#stop_num: The simulation length for each batch submission, in units of $stop_units.
#restart_units: The units for how often restart files are written, eg nhours, ndays, nmonths, nyears.
#restart_num: How often restart files are written, in units of $restart_units.
#num_resubmits: After a batch job finishes successfully, a new batch job will automatically be submitted to
# continue the simulation. num_resubmits is the number of times to submit after initial completion.
# After the first submission, the CONTINUE_RUN flage in env_run.xml will be changed to TRUE.
#do_short_term_archiving: If TRUE, then move simulation output to the archive directory in your scratch directory.
### SIMULATION OPTIONS (10)
#atm_output_freq (the namelist variable is nhtfrq) : The frequency with which the atmosphere writes its output.
# 0=monthly, +N=every N timesteps, -N=every N hours
# For more information: http://www.cesm.ucar.edu/models/atm-cam/docs/usersguide/node45.html
#records_per_atm_output_file (the namelist variable is mfilt): The number of time records in each netCDF output file
# from the atmosphere model. If atm_output_freq=0, then there will only be one time record per file.
#NOTE: If there will be more than one 'history tape' defined in the atm namelist, then
# atm_output_freq and records_per_atm_output_file should be a comma-separated list of numbers
# (specifying the option for each history tape).
#start_date: The day that the simulation starts
### GENERAL NOTES:
# 1. capitalization doesn't matter on most of the variables above because we lowercase variables before using them.
# 2. most of the code below does things you probably never want to change. However, users will often make settings
# in the "USER_NL" and "RUN CONFIGURATION OPTIONS" sections below.
### PROGRAMMING GUIDELINES
#
# +) The exit error numbers are sequential through the code:
# 0-099 are before create_newcase
# 100-199 are between create_newcase and cesm_setup
# 200-299 are between cesm_setup and case_scripts.build
# 300-399 are between case_scripts.build and case_scripts.submit
# 400-499 are after case_scripts.submit
# If this script dies, then print out the exit code.
# (in csh: use 'echo $status' immediatedly after the script exits)
#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
# END OF COMMON OPTIONS - you may need to change things below here to access advanced
# capabilities, but if you do you should know what you're doing.
#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
#===========================================
# VERSION OF THIS SCRIPT
#===========================================
set script_ver = 3.0.22
#===========================================
# DEFINE ALIASES
#===========================================
alias lowercase "echo \!:1 | tr '[A-Z]' '[a-z]'" #make function which lowercases any strings passed to it.
alias uppercase "echo \!:1 | tr '[a-z]' '[A-Z]'" #make function which uppercases any strings passed to it.
alias e3sm_print 'echo run_e3sm: \!*'
alias e3sm_newline "echo ''"
#===========================================
# ALERT THE USER IF THEY TRY TO PASS ARGUMENTS
#===========================================
set first_argument = $1
if ( $first_argument != '' ) then
echo 'This script does everything needed to configure/compile/run a case. As such, it'
echo 'provides complete provenance for each run and makes sharing simulation configurations easy.'
echo 'Users should make sure that everything required for a run is in this script, the E3SM'
echo 'git repo, and/or the inputdata svn repo.'
echo '** This script accepts no arguments. Please edit the script as needed and resubmit without arguments. **'
exit 5
endif
e3sm_newline
e3sm_print '++++++++ run_e3sm starting ('`date`'), version '$script_ver' ++++++++'
e3sm_newline
#===========================================
# DETERMINE THE LOCATION AND NAME OF THE SCRIPT
#===========================================
# NOTE: CIME 5 and git commands are not cwd agnostic, so compute the absolute paths, then cd to the directories as needed
set this_script_name = `basename $0`
set relative_dir = `dirname $0`
set this_script_dir = `cd $relative_dir ; pwd -P`
set this_script_path = $this_script_dir/$this_script_name
#===========================================
# SETUP DEFAULTS
#===========================================
if ( `lowercase $code_root_dir` == default ) then
set code_root_dir = `cd $this_script_dir/..; pwd -P`
endif
if ( `lowercase $tag_name` == default ) then
set pwd_temp = `pwd`
set tag_name = ${pwd_temp:t}
e3sm_print '$tag_name = '$tag_name
endif
#===========================================
# BASIC ERROR CHECKING
#===========================================
set seconds_after_warning = 10
if ( `lowercase $old_executable` == true ) then
if ( $seconds_before_delete_source_dir >= 0 ) then
e3sm_newline
e3sm_print 'ERROR: It is unlikely that you want to delete the source code and then use the existing compiled executable.'
e3sm_print ' Hence, this script will abort to avoid making a mistake.'
e3sm_print ' $seconds_before_delete_source_dir = '$seconds_before_delete_source_dir' $old_executable = '$old_executable
exit 11
endif
if ( $seconds_before_delete_bld_dir >= 0 ) then
e3sm_newline
e3sm_print 'ERROR: It makes no sense to delete the source-compiled code and then use the existing compiled executable.'
e3sm_print ' Hence, this script will abort to avoid making a mistake.'
e3sm_print ' $seconds_before_delete_bld_dir = '$seconds_before_delete_bld_dir' $old_executable = '$old_executable
exit 12
endif
endif
if ( `lowercase $case_build_dir` == default && $seconds_before_delete_bld_dir >= 0 ) then
e3sm_print 'ERROR: run_e3sm cannot delete the build directory when CIME chooses it'
e3sm_print ' To remedy this, either set $case_build_dir to the path of the executables or disable deleting the directory'
exit 14
endif
if ( `lowercase $case_run_dir` == default && $seconds_before_delete_run_dir >= 0 ) then
e3sm_print 'ERROR: run_e3sm cannot delete the run directory when CIME chooses it'
e3sm_print ' To remedy this, either set $case_run_dir to the path of the executables or disable deleting the directory'
exit 15
endif
if ( `lowercase $debug_queue` == true && ( $num_resubmits >= 1 || `lowercase $do_short_term_archiving` == true ) ) then
e3sm_print 'ERROR: Supercomputer centers generally do not allow job chaining in debug queues'
e3sm_print ' You should either use a different queue, or submit a single job without archiving.'
e3sm_print ' $debug_queue = '$debug_queue
e3sm_print ' $num_resubmits = '$num_resubmits
e3sm_print ' $do_short_term_archiving = '$do_short_term_archiving
exit 16
endif
if ( $restart_num != 0 ) then
@ remaining_periods = $stop_num - ( $stop_num / $restart_num ) * $restart_num
if ( $num_resubmits >= 1 && ( $stop_units != $restart_units || $remaining_periods != 0 ) ) then
e3sm_print 'WARNING: run length is not divisible by the restart write frequency, or the units differ.'
e3sm_print 'If restart write frequency doesnt evenly divide the run length, restarts will simulate the same time period multiple times.'
e3sm_print ' $stop_units = '$stop_units
e3sm_print ' $stop_num = '$stop_num
e3sm_print ' $restart_units = '$restart_units
e3sm_print ' $restart_num = '$restart_num
e3sm_print ' $remaining_periods = '$remaining_periods
e3sm_print ' $num_resubmits = '$num_resubmits
sleep $seconds_after_warning
endif
endif
#===========================================
# DOWNLOAD SOURCE CODE IF NEEDED:
#===========================================
### NOTE: you must be setup with access to the E3SM repository before you can clone the repository. For access, see
### https://acme-climate.atlassian.net/wiki/display/Docs/Installing+the+ACME+Model
if ( `lowercase $fetch_code` == true ) then
e3sm_print 'Downloading code from the E3SM git repository.'
if ( -d $code_root_dir/$tag_name ) then
if ( $seconds_before_delete_source_dir >= 0 ) then
set num_seconds_until_delete = $seconds_before_delete_source_dir
e3sm_print 'Removing old code directory '$code_root_dir/$tag_name' in '$num_seconds_until_delete' seconds.'
e3sm_print 'To abort, press ctrl-C'
while ( ${num_seconds_until_delete} > 0 )
e3sm_print ' '${num_seconds_until_delete}' seconds until deletion.'
sleep 1
@ num_seconds_until_delete = ${num_seconds_until_delete} - 1
end
rm -fr $code_root_dir/$tag_name
e3sm_print 'Deleted '$code_root_dir/$tag_name
else
e3sm_print 'ERROR: Your branch tag already exists, so dying instead of overwriting.'
e3sm_print ' You likely want to either set fetch_code=false, change $tag_name, or'
e3sm_print ' change seconds_before_delete_source_dir.'
e3sm_print ' Note: $fetch_code = '$fetch_code
e3sm_print ' $code_root_dir/$tag_name = '$code_root_dir/$tag_name
e3sm_print ' $seconds_before_delete_source_dir = '$seconds_before_delete_source_dir
exit 20
endif #$seconds_before_delete_source_dir >=0
endif #$code_root_dir exists
e3sm_print 'Cloning repository into $tag_name = '$tag_name' under $code_root_dir = '$code_root_dir
mkdir -p $code_root_dir
git clone [email protected]:ACME-Climate/ACME.git $code_root_dir/$tag_name # This will put repository, with all code, in directory $tag_name
## Setup git hooks
rm -rf $code_root_dir/$tag_name/.git/hooks
git clone [email protected]:ACME-Climate/ACME-Hooks.git $code_root_dir/$tag_name/.git/hooks # checkout with write permission.
# git clone git://github.com/ACME-Climate/ACME-Hooks.git .git/hooks # checkout read-only.
cd $code_root_dir/$tag_name
git config commit.template $code_root_dir/$tag_name/.git/hooks/commit.template
## Bring in MPAS ocean/ice repo
git submodule update --init
if ( `lowercase $e3sm_tag` == master ) then
e3sm_newline
##e3sm_print 'Detaching from the master branch to avoid accidental changes to master by user.'
##git checkout --detach
echo 'KLUDGE: git version on anvil (1.7.1) is too old to be able to detach'
echo 'edison uses git version 1.8.5.6 and it can git checkout --detach'
else
e3sm_newline
e3sm_print 'Checking out branch ${e3sm_tag} = '${e3sm_tag}
git checkout ${e3sm_tag}
endif
endif
e3sm_newline
e3sm_print '$case_name = '$case_name
#============================================
# DETERMINE THE SCRATCH DIRECTORY TO USE
#============================================
if ( $e3sm_simulations_dir == default ) then
### NOTE: csh doesn't short-circuit; so we can't check whether $SCRATCH exists or whether it's empty in the same condition
if ( ! $?SCRATCH ) then
e3sm_newline
e3sm_print 'WARNING: Performing science runs while storing run output in your home directory is likely to exceed your quota'
e3sm_print ' To avoid any issues, set $e3sm_simulations_dir to a scratch filesystem'
set e3sm_simulations_dir = ${HOME}/E3SM_simulations
else
### Verify that $SCRATCH is not an empty string
if ( "${SCRATCH}" == "" ) then
set e3sm_simulations_dir = ${HOME}/E3SM_simulations
e3sm_newline
e3sm_print 'WARNING: Performing science runs while storing run output in your home directory is likely to exceed your quota'
e3sm_print ' To avoid any issues, set $e3sm_simulations_dir to a scratch filesystem'
else
set e3sm_simulations_dir = ${SCRATCH}/E3SM_simulations
endif
endif
endif
#============================================
# DELETE PREVIOUS DIRECTORIES (IF REQUESTED)
#============================================
### Determine the case_scripts directory
### Remove existing case_scripts directory (so it doesn't have to be done manually every time)
### Note: This script causes create_newcase to generate a temporary directory (part of a workaround to put the case_name into the script names)
### If something goes wrong, this temporary directory is sometimes left behind, so we need to delete it too.
### Note: To turn off the deletion, set $num_seconds_until_delete to be negative.
### To delete immediately, set $num_seconds_until_delete to be zero.
set case_scripts_dir = ${e3sm_simulations_dir}/${case_name}/case_scripts
if ( -d $case_scripts_dir ) then
if ( ${seconds_before_delete_case_dir} >= 0 ) then
set num_seconds_until_delete = $seconds_before_delete_case_dir
e3sm_newline
e3sm_print 'Removing old $case_scripts_dir directory for '${case_name}' in '${num_seconds_until_delete}' seconds.'
e3sm_print 'To abort, press ctrl-C'
while ( ${num_seconds_until_delete} > 0 )
e3sm_print ' '${num_seconds_until_delete}' seconds until deletion.'
sleep 1
@ num_seconds_until_delete = ${num_seconds_until_delete} - 1
end
rm -fr $case_scripts_dir
e3sm_print ' Deleted $case_scripts_dir directory for : '${case_name}
else
e3sm_print 'WARNING: $case_scripts_dir='$case_scripts_dir' exists '
e3sm_print ' and is not being removed because seconds_before_delete_case_dir<0.'
e3sm_print ' But create_newcase always fails when the case directory exists, so this script will now abort.'
e3sm_print ' To fix this, either delete the case_scripts directory manually, or change seconds_before_delete_case_dir'
exit 35
endif
endif
### Remove existing build directory (to force a clean compile). This is good for a new run, but not usually necessary while developing.
if ( `lowercase $case_build_dir` != default && -d $case_build_dir ) then
if ( ${seconds_before_delete_bld_dir} >= 0 ) then
set num_seconds_until_delete = $seconds_before_delete_bld_dir
e3sm_newline
e3sm_print 'Removing old $case_build_dir directory for '${case_name}' in '${num_seconds_until_delete}' seconds.'
e3sm_print 'To abort, press ctrl-C'
while ( ${num_seconds_until_delete} > 0 )
e3sm_print ' '${num_seconds_until_delete}' seconds until deletion.'
sleep 1
@ num_seconds_until_delete = ${num_seconds_until_delete} - 1
end
rm -fr $case_build_dir
e3sm_print ' Deleted $case_build_dir directory for '${case_name}
else
e3sm_print 'NOTE: $case_build_dir='$case_build_dir' exists '
e3sm_print ' and is not being removed because seconds_before_delete_bld_dir<0.'
endif
endif
### Remove existing run directory (for a clean start). This is good for a new run, but often not usually necessary while developing.
if ( `lowercase $case_run_dir` != default && -d $case_run_dir ) then
if ( ${seconds_before_delete_run_dir} >= 0 ) then
set num_seconds_until_delete = $seconds_before_delete_run_dir
e3sm_newline
e3sm_print 'Removing old $case_run_dir directory for '${case_name}' in '${num_seconds_until_delete}' seconds.'
e3sm_print 'To abort, press ctrl-C'
while ( ${num_seconds_until_delete} > 0 )
e3sm_print ' '${num_seconds_until_delete}' seconds until deletion.'
sleep 1
@ num_seconds_until_delete = ${num_seconds_until_delete} - 1
end
rm -fr $case_run_dir
e3sm_print ' Deleted $case_run_dir directory for '${case_name}
else
e3sm_print 'NOTE: $case_run_dir='$case_run_dir' exists '
e3sm_print ' and is not being removed because seconds_before_delete_run_dir<0.'
endif
endif
#=============================================================
# HANDLE STANDARD PROCESSOR CONFIGURATIONS
#=============================================================
# NOTE: Some standard PE configurations are available (S,M,L,X1,X2).
# If the requested configuration is 1 or CUSTOM, then set to M here, and handle later.
set lower_case = `lowercase $processor_config`
switch ( $lower_case )
case 's':
set std_proc_configuration = 'S'
breaksw
case 'm':
set std_proc_configuration = 'M'
breaksw
case 'l':
set std_proc_configuration = 'L'
breaksw
case 'x1':
set std_proc_configuration = 'X1'
breaksw
case 'x2':
set std_proc_configuration = 'X2'
breaksw
case '1':
set std_proc_configuration = 'M'
breaksw
case 'custom*':
# Note: this is just a placeholder so create_newcase will work.
# The actual configuration should be set under 'CUSTOMIZE PROCESSOR CONFIGURATION'
set std_proc_configuration = 'M'
breaksw
default:
e3sm_print 'ERROR: $processor_config='$processor_config' is not recognized'
exit 40
breaksw
endsw
#================================================================================
# MAKE FILES AND DIRECTORIES CREATED BY THIS SCRIPT READABLE BY EVERYONE IN GROUP
#================================================================================
# Note: we also want to change the group id for the files.
# But this can only be done once the run_root_dir has been created,
# so it is done later.
umask 022
set cime_dir = ${code_root_dir}/${tag_name}/cime
set create_newcase_exe = $cime_dir/scripts/create_newcase
if ( -f ${create_newcase_exe} ) then
set e3sm_exe = e3sm.exe
set case_setup_exe = $case_scripts_dir/case.setup
set case_build_exe = $case_scripts_dir/case.build
set case_run_exe = $case_scripts_dir/.case.run
set case_submit_exe = $case_scripts_dir/case.submit
set xmlchange_exe = $case_scripts_dir/xmlchange
set xmlquery_exe = $case_scripts_dir/xmlquery
set shortterm_archive_script = $case_scripts_dir/case.st_archive
set preview_namelists_exe = $case_scripts_dir/preview_namelists
else # No version of create_newcase found
e3sm_print 'ERROR: ${create_newcase_exe} not found'
e3sm_print ' This is most likely because fetch_code should be true.'
e3sm_print ' At the moment, $fetch_code = '$fetch_code
exit 45
endif
#=============================================================
# DETERMINE THE OPTIONS FOR CREATE_NEWCASE
#=============================================================
set configure_options = "--case ${case_name} --compset ${compset} --script-root ${case_scripts_dir} --res ${resolution} --pecount ${std_proc_configuration} --handle-preexisting-dirs u"
if ( `lowercase $machine` != default ) then
set configure_options = "${configure_options} --mach ${machine}"
endif
if ( `lowercase $case_build_dir` == default ) then
set case_build_dir = ${e3sm_simulations_dir}/${case_name}/build
endif
if ( `lowercase $case_run_dir` == default ) then
set case_run_dir = ${e3sm_simulations_dir}/${case_name}/run
endif
# Default group and permissions on NERSC can be a pain for sharing data
# within the project. This should take care of it. Create top level
# directory and set the default group to 'acme', permissions for
# group read access for top level and all files underneath (Chris Golaz).
if ( $machine == 'cori*' || $machine == 'edison' ) then
mkdir -p ${e3sm_simulations_dir}/${case_name}
cd ${e3sm_simulations_dir}
chgrp acme ${case_name}
chmod 750 ${case_name}
chmod g+s ${case_name}
setfacl -d -m g::rx ${case_name}
endif
mkdir -p ${case_build_dir}
set build_root = `cd ${case_build_dir}/..; pwd -P`
mkdir -p ${case_run_dir}
set run_root = `cd ${case_run_dir}/..; pwd -P`
if ( ${build_root} == ${run_root} ) then
set configure_options = "${configure_options} --output-root ${build_root}"
endif
if ( `lowercase $project` == default ) then
unsetenv project
else
set configure_options = "${configure_options} --project ${project}"
endif
#=============================================================
# CREATE CASE_SCRIPTS DIRECTORY AND POPULATE WITH NEEDED FILES
#=============================================================
e3sm_newline
e3sm_print '-------- Starting create_newcase --------'
e3sm_newline
e3sm_print ${create_newcase_exe} ${configure_options}
${create_newcase_exe} ${configure_options}
cd ${case_scripts_dir}
e3sm_newline
e3sm_print '-------- Finished create_newcase --------'
e3sm_newline
#================================================
# UPDATE VARIABLES WHICH REQUIRE A CASE TO BE SET
#================================================
if ( `lowercase $machine` == default ) then
set machine = `$xmlquery_exe MACH --value`
endif
# machine is a commonly used variable; so make certain it's lowercase
set machine = `lowercase $machine`
if ( `lowercase $case_build_dir` == default ) then
set case_build_dir = ${e3sm_simulations_dir}/${case_name}/bld
endif
${xmlchange_exe} EXEROOT=${case_build_dir}
if ( `lowercase $case_run_dir` == default ) then
set case_run_dir = ${case_scripts_dir}/${case_name}/run
endif
${xmlchange_exe} RUNDIR=${case_run_dir}
if ( ! $?project ) then
setenv project `$xmlquery_exe PROJECT --subgroup case.run --value`
else
if ( $project == "" ) then
setenv project `$xmlquery_exe PROJECT --subgroup case.run --value`
endif
endif
e3sm_print "Project used for submission: ${project}"
#================================
# SET WALLTIME FOR CREATE_NEWCASE
#================================
if ( `lowercase $walltime` == default ) then
if ( `lowercase $debug_queue` == true ) then
set walltime = '0:30:00'
else
if ( $machine == 'quartz' || $machine == 'syrah' ) then
set walltime = '1:29:00'
else
set walltime = '2:00:00'
endif
endif
endif
# Allow the user to specify how long the job taks
$xmlchange_exe JOB_WALLCLOCK_TIME=$walltime
#================================
# SET THE STARTDATE FOR THE SIMULATION
#================================
if ( `lowercase $start_date` != 'default' ) then
$xmlchange_exe RUN_STARTDATE=$start_date
endif
#NOTE: Details of the configuration setup by create_newcase are in $case_scripts_dir/env_case.xml, which should NOT be edited.
# It will be used by cesm_setup (formerly 'configure -case').
#NOTE: To get verbose output from create_newcase, add '-v' to the argument list.
#============================================================
#COPY STUFF TO SourceMods IF NEEDED:
#============================================================
#note: SourceMods is a horrible thing to do from a provenance perspective
# it is much better to make changes to the code and to put those changes
# into a git branch, which you then check out to do your run. Nonetheless,
# it is useful for debugging so here's an example of how to use it...
#echo 'KLUDGE: Putting streams.ocean in SourceMods'
#cp /global/u1/p/petercal/junk/streams.ocean $case_scripts_dir/SourceMods/src.mpaso/
#============================================================
# COPY THIS SCRIPT TO THE CASE DIRECTORY TO ENSURE PROVENANCE
#============================================================
set script_provenance_dir = $case_scripts_dir/run_script_provenance
set script_provenance_name = $this_script_name.`date +%F_%T_%Z`
mkdir -p $script_provenance_dir
cp -f $this_script_path $script_provenance_dir/$script_provenance_name
#=============================================
# CUSTOMIZE PROCESSOR CONFIGURATION
# ============================================
#NOTE: Changes to the processor configuration should be done by an expert. \
# Not all possible options will work.
if ( `lowercase $processor_config` == '1' ) then
set ntasks = 1
set nthrds = 1
set sequential_or_concurrent = 'sequential'
foreach ntasks_name ( NTASKS_ATM NTASKS_LND NTASKS_ICE NTASKS_OCN NTASKS_CPL NTASKS_GLC NTASKS_ROF NTASKS_WAV )
$xmlchange_exe --id $ntasks_name --val $ntasks
end
foreach nthrds_name ( NTHRDS_ATM NTHRDS_LND NTHRDS_ICE NTHRDS_OCN NTHRDS_CPL NTHRDS_GLC NTHRDS_ROF NTHRDS_WAV )
$xmlchange_exe --id $nthrds_name --val $nthrds
end
foreach rootpe_name ( ROOTPE_ATM ROOTPE_LND ROOTPE_ICE ROOTPE_OCN ROOTPE_CPL ROOTPE_GLC ROOTPE_ROF ROOTPE_WAV )
$xmlchange_exe --id $rootpe_name --val 0
end
foreach layout_name ( NINST_ATM_LAYOUT NINST_LND_LAYOUT NINST_ICE_LAYOUT NINST_OCN_LAYOUT NINST_GLC_LAYOUT NINST_ROF_LAYOUT NINST_WAV_LAYOUT )
$xmlchange_exe --id $layout_name --val $sequential_or_concurrent
end
else if ( `lowercase $processor_config` == 'customknl' ) then
e3sm_print 'using custom layout for cori-knl because $processor_config = '$processor_config
${xmlchange_exe} MAX_TASKS_PER_NODE="64"
${xmlchange_exe} PES_PER_NODE="256"
${xmlchange_exe} NTASKS_ATM="5400"
${xmlchange_exe} ROOTPE_ATM="0"
${xmlchange_exe} NTASKS_LND="320"
${xmlchange_exe} ROOTPE_LND="5120"
${xmlchange_exe} NTASKS_ICE="5120"
${xmlchange_exe} ROOTPE_ICE="0"
${xmlchange_exe} NTASKS_OCN="3840"
${xmlchange_exe} ROOTPE_OCN="5440"
${xmlchange_exe} NTASKS_CPL="5120"
${xmlchange_exe} ROOTPE_CPL="0"
${xmlchange_exe} NTASKS_GLC="320"
${xmlchange_exe} ROOTPE_GLC="5120"
${xmlchange_exe} NTASKS_ROF="320"
${xmlchange_exe} ROOTPE_ROF="5120"
${xmlchange_exe} NTASKS_WAV="5120"
${xmlchange_exe} ROOTPE_WAV="0"
${xmlchange_exe} NTHRDS_ATM="1"
${xmlchange_exe} NTHRDS_LND="1"
${xmlchange_exe} NTHRDS_ICE="1"
${xmlchange_exe} NTHRDS_OCN="1"
${xmlchange_exe} NTHRDS_CPL="1"
${xmlchange_exe} NTHRDS_GLC="1"
${xmlchange_exe} NTHRDS_ROF="1"
${xmlchange_exe} NTHRDS_WAV="1"
endif
#============================================
# SET PARALLEL I/O (PIO) SETTINGS
#============================================
#Having bad PIO_NUMTASKS and PIO_STRIDE values can wreck performance
#See https://acme-climate.atlassian.net/wiki/display/ATM/How+to+Create+a+New+PE+Layout
#$xmlchange_exe -file env_run.xml -id PIO_NUMTASKS -val 128
#============================================
# SET MODEL INPUT DATA DIRECTORY
#============================================
# NOTE: This section was moved from later in script, because sometimes it is needed for cesm_setup.
# The model input data directory should default to the managed location for your system.
# However, if this does not work properly, or if you want to use your own data, then
# that should be setup here (before case_scripts.build because it checks the necessary files exist)
# NOTE: This code handles the case when the default location is wrong.
# If you want to use your own files then this code will need to be modified.
# NOTE: For information on the E3SM input data repository, see:
# https://acme-climate.atlassian.net/wiki/display/WORKFLOW/ACME+Input+Data+Repository
#set input_data_dir = 'input_data_dir_NOT_SET'
#if ( $machine == 'cori*' || $machine == 'edison' ) then
# set input_data_dir = '/project/projectdirs/m411/ACME_inputdata' # PJC-NERSC
## set input_data_dir = '/project/projectdirs/ccsm1/inputdata' # NERSC
#else if ( $machine == 'titan' || $machine == 'eos' ) then
# set input_data_dir = '/lustre/atlas/proj-shared/cli112/pjcs/ACME_inputdata' # PJC-OLCF
#endif
#if ( -d $input_data_dir ) then
# $xmlchange_exe --id DIN_LOC_ROOT --val $input_data_dir
#else
# echo 'run_e3sm ERROR: User specified input data directory does NOT exist.'
# echo ' $input_data_dir = '$input_data_dir
# exit 270
#endif
### The following command extracts and stores the input_data_dir in case it is needed for user edits to the namelist later.
### NOTE: The following line may be necessary if the $input_data_dir is not set above, and hence defaults to the E3SM default.
#NOTE: the following line can fail for old versions of the code (like v0.3) because
#"-value" is a new option in xmlquery. If that happens, comment out the next line and
#hardcode in the appropriate DIN_LOC_ROOT value for your machine.
set input_data_dir = `$xmlquery_exe DIN_LOC_ROOT --value`
#============================================
# COMPONENT CONFIGURATION OPTIONS
#============================================
#NOTE: This section is for making specific component configuration selections.
#NOTE: The input_data directory is best set in the section for it above.
#NOTE: Setting CAM_CONFIG_OPTS will REPLACE anything set by the build system.
# To add on instead, add '-append' to the xmlchange command.
#NOTE: CAM_NAMELIST_OPTS should NOT be used. Instead, use the user_nl section after case_scripts.build
#$xmlchange_exe --id CAM_CONFIG_OPTS --val "-phys cam5 -chem linoz_mam3"
## Chris Golaz: build with COSP
#NOTE: The xmlchange will fail if CAM is not active, so test whether a data atmosphere (datm) is used.
if ( `$xmlquery_exe --value COMP_ATM` == 'datm' ) then
e3sm_newline
e3sm_print 'The specified configuration uses a data atmosphere, so cannot activate COSP simulator.'
e3sm_newline
else
e3sm_newline
e3sm_print 'Configuring E3SM to use the COSP simulator.'
e3sm_newline
$xmlchange_exe --id CAM_CONFIG_OPTS --append --val='-cosp'
endif
#===========================
# SET THE PARTITION OF NODES
#===========================
if ( `lowercase $debug_queue` == true ) then
if ( $machine == quartz || $machine == syrah ) then
$xmlchange_exe --id JOB_QUEUE --val 'pdebug'
else if ($machine != sandiatoss3 && $machine != bebop && $machine != blues) then
$xmlchange_exe --id JOB_QUEUE --val 'debug'
endif
endif
#============================================
# CONFIGURE
#============================================
#note configure -case turned into cesm_setup in cam5.2
e3sm_newline
e3sm_print '-------- Starting case.setup --------'
e3sm_newline
e3sm_print ${case_setup_exe}
${case_setup_exe} --reset
e3sm_newline
e3sm_print '-------- Finished case.setup --------'
e3sm_newline
#============================================================
#MAKE GROUP PERMISSIONS to $PROJECT FOR THIS DIRECTORY
#============================================================
#this stuff, combined with the umask command above, makes
#stuff in $run_root_dir readable by everyone in e3sm group.
set run_root_dir = `cd $case_run_dir/..; pwd -P`
#both run_root_dir and case_scripts_dir are created by create_newcase,
#so run_root_dir group isn't inherited for case_scripts_dir
#========================================================
# CREATE LOGICAL LINKS BETWEEN RUN_ROOT & THIS_SCRIPT_DIR
#========================================================
#NOTE: This is to make it easy for the user to cd to the case directory
#NOTE: Starting the suffix wit 'a' helps to keep this near the script in ls
# (but in practice the behavior depends on the LC_COLLATE system variable).
e3sm_print 'Creating logical links to make navigating easier.'
e3sm_print 'Note: Beware of using ".." with the links, since the behavior of shell commands can vary.'
# Customizations from Chris Golaz
# Link in this_script_dir case_dir
set run_dir_link = $this_script_dir/$this_script_name=a_run_link
e3sm_print ${run_dir_link}
if ( -l $run_dir_link ) then
rm -f $run_dir_link
endif
e3sm_print "run_root ${run_root_dir}"
e3sm_print "run_dir ${run_dir_link}"
ln -s $run_root_dir $run_dir_link
#============================================
# SET BUILD OPTIONS
#============================================
if ( `uppercase $debug_compile` != 'TRUE' && `uppercase $debug_compile` != 'FALSE' ) then
e3sm_print 'ERROR: $debug_compile can be true or false but is instead '$debug_compile
exit 220
endif
if ( $machine == 'edison' && `uppercase $debug_compile` == 'TRUE' ) then
e3sm_print 'ERROR: Edison currently has a compiler bug and crashes when compiling in debug mode (Nov 2015)'
exit 222
endif
$xmlchange_exe --id DEBUG --val `uppercase $debug_compile`
#Modify/uncomment the next line to change the number of processors used to compile.
#$xmlchange_exe --id GMAKE_J --val 4
#=============================================
# CREATE NAMELIST MODIFICATION FILES (USER_NL)
#=============================================
# Append desired changes to the default namelists generated by the build process.
#
# NOTE: It doesn't matter which namelist an option is in for any given component, the system will sort it out.
# NOTE: inputdata directory ($input_data_dir) is set above (before cesm_setup).
# NOTE: The user_nl files need to be set before the build, because case_scripts.build checks whether input files exist.
# NOTE: $atm_output_freq and $records_per_atm_output_file are so commonly used, that they are set in the options at the top of this script.
cat <<EOF >> user_nl_cam
nhtfrq = $atm_output_freq
mfilt = $records_per_atm_output_file
EOF
cat <<EOF >> user_nl_clm
! finidat=''
EOF
### NOTES ON COMMON NAMELIST OPTIONS ###
### ATMOSPHERE NAMELIST ###
#NHTFRQ : The frequency with which the atmosphere writes its output.
# 0=monthly, +N=every N timesteps, -N=every N hours
# For more information: http://www.cesm.ucar.edu/models/atm-cam/docs/usersguide/node45.html
#MFILT : The number of time records in each netCDF output file from the atmosphere model.
# If mfilt is 0, then there will only be one time record per file.
#NOTE: nhtfrq and mfilt can be a comma-separated list of numbers, corresponding to the 'history tapes' defined in the namelist.
#============================================
# BUILD CODE
#============================================
#NOTE: This will either build the code (if needed and $old_executable=false) or copy an existing executable.
if ( `lowercase $old_executable` == false ) then
e3sm_newline
e3sm_print '-------- Starting Build --------'
e3sm_newline
e3sm_print 'WARNING: Make sure there are no double-slashes (//) in the build command below: => Will cause a build error'
e3sm_print ${case_build_exe}
${case_build_exe}
e3sm_newline
e3sm_print '-------- Finished Build --------'
e3sm_newline
else if ( `lowercase $old_executable` == true ) then
if ( -x $case_build_dir/$e3sm_exe ) then #use executable previously generated for this case_name.
e3sm_print 'Skipping build because $old_executable='$old_executable
e3sm_newline
#create_newcase sets BUILD_COMPLETE to FALSE. By using an old executable you're certifying
#that you're sure the old executable is consistent with the new case... so be sure you're right!
#NOTE: This is a risk to provenance, so this feature may be removed in the future [PJC].
# However the build system currently rebuilds several files every time which takes many minutes.
# When this gets fixed the cost of deleting this feature will be minor.
# (Also see comments for user options at top of this file.)
e3sm_print 'WARNING: Setting BUILD_COMPLETE = TRUE. This is a little risky, but trusting the user.'
$xmlchange_exe --id BUILD_COMPLETE --val TRUE
else
e3sm_print 'ERROR: $old_executable='$old_executable' but no executable exists for this case.'
e3sm_print ' Expected to find executable = '$case_build_dir/$e3sm_exe
exit 297
endif
else
if ( -x $old_executable ) then #if absolute pathname exists and is executable.
#create_newcase sets BUILD_COMPLETE to FALSE. By copying in an old executable you're certifying
#that you're sure the old executable is consistent with the new case... so be sure you're right!
#NOTE: This is a risk to provenance, so this feature may be removed in the future [PJC].
# However the build system currently rebuilds several files every time which takes many minutes.
# When this gets fixed the cost of deleting this feature will be minor.
# (Also see comments for user options at top of this file.)
#
#NOTE: The alternative solution is to set EXEROOT in env_build.xml.
# That is cleaner and quicker, but it means that the executable is outside this directory,
# which weakens provenance if this directory is captured for provenance.
e3sm_print 'WARNING: Setting BUILD_COMPLETE = TRUE. This is a little risky, but trusting the user.'
$xmlchange_exe --id BUILD_COMPLETE --val TRUE
cp -fp $old_executable $case_build_dir/
else
e3sm_print 'ERROR: $old_executable='$old_executable' does not exist or is not an executable file.'