forked from dmricciuto/OLMT
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathruncase.py
executable file
·2002 lines (1837 loc) · 95.1 KB
/
runcase.py
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
#!/usr/bin/env python
import netcdf4_functions as nffun
import socket, os, sys, csv, time, math, numpy
import re, subprocess
from optparse import OptionParser
#from Numeric import *
#runcase.py does the following:
#
# 1. Call routines to create surface and domain data (makepointdata.py)
# 2. Use create_newcase to build the new case with specified options
# 3. Set point and case-epecific namelist options
# 4. configure case
# 5. build (compile) ACME with clean_build first if requested
# 6. apply user-specified PBS and submit information
# 7. submit single run or parameter ensemble job to PBS queue.
#
#-------------------Parse options-----------------------------------------------
parser = OptionParser()
# general OLMT options
parser.add_option("--caseidprefix", dest="mycaseid", default="", \
help="Unique identifier to include as a prefix to the case name")
parser.add_option("--caseroot", dest="caseroot", default='', \
help = "case root directory (default = '', i.e., under model_root/cime/scripts/)")
parser.add_option("--runroot", dest="runroot", default="", \
help="Directory where the run would be created")
parser.add_option("--model_root", dest="csmdir", default='', \
help = "base model directory")
parser.add_option("--ccsm_input", dest="ccsm_input", default='', \
help = "input data directory for CESM (required)")
parser.add_option('--project', dest='project',default='', \
help='Set project')
parser.add_option("--exeroot", dest="exeroot", default="", \
help="Location of executable")
parser.add_option("--constraints", dest="constraints", default="", \
help="Directory containing model constraints")
parser.add_option("--metdata_dir", dest="metdata_dir", default='', \
help = 'Directory containing cpl_bypass met data (site only)')
parser.add_option("--pft", dest="mypft", default=-1, \
help = 'Use this PFT for all gridcells')
parser.add_option("--parm_file", dest="parm_file", default='',
help = 'file for parameter modifications')
parser.add_option("--parm_vals", dest="parm_vals", default="", \
help = 'User specified parameter values')
parser.add_option("--parm_file_P", dest="parm_file_P", default='',
help = 'file for P parameter modifications')
# general model build options
parser.add_option("--machine", dest="machine", default = '', \
help = "machine to\n")
parser.add_option("--compiler", dest="compiler", default='', \
help = "compiler to use (pgi, gnu)")
parser.add_option("--mpilib", dest="mpilib", default="mpi-serial", \
help = "mpi library (openmpi, mpich, ibm, mpi-serial)")
parser.add_option("--diags", dest="diags", default=False, \
action="store_true", help="Write special outputs for diagnostics")
parser.add_option("--debugq", dest="debug", default=False, \
action="store_true", help='Use debug queue')
parser.add_option("--srcmods_loc", dest="srcmods_loc", default='', \
help = 'Copy sourcemods from this location')
parser.add_option("--pio_version", dest="pio_version", default='2', \
help = "PIO version (1 or 2)")
# CASE options
parser.add_option("--coldstart", dest="coldstart", default=False, \
help = "set cold start (mutually exclusive w/finidat)", \
action="store_true")
parser.add_option("--compset", dest="compset", default='I1850CNPRDCTCBC', \
help = "component set to use (required)\n"
"Currently supports ONLY *CLM45(CN) compsets")
parser.add_option("--istrans", dest="istrans", default=False, action="store_true",\
help="Force compset to act like transient")
parser.add_option("--lat_bounds", dest="lat_bounds", default='-999,-999', \
help = 'latitude range for regional run')
parser.add_option("--lon_bounds", dest="lon_bounds", default='-999,-999', \
help = 'longitude range for regional run')
parser.add_option("--humhol", dest="humhol", default=False, \
help = 'Use hummock/hollow microtopography', action="store_true")
parser.add_option("--marsh", dest="marsh", default=False, \
help = 'Use marsh hydrology/elevation', action="store_true")
parser.add_option("--tide_components_file", dest="tide_components_file", default='', \
help = 'NOAA tide components file')
parser.add_option("--mask", dest="mymask", default='', \
help = 'Mask file to use (regional only)')
parser.add_option("--model", dest="mymodel", default='', \
help = 'Model to use (ELM,CLM5)')
parser.add_option("--namelist_file", dest="namelist_file", default='', \
help="File containing custom namelist options for user_nl_clm")
parser.add_option("--ilambvars", dest="ilambvars", default=False, \
action="store_true", help="Write special outputs for diagnostics")
parser.add_option("--dailyvars", dest="dailyvars", default=False, \
action="store_true", help="Write daily ouptut variables")
parser.add_option("--res", dest="res", default="CLM_USRDAT", \
help='Resoultion for global simulation')
parser.add_option("--point_list", dest="point_list", default='', \
help = 'File containing list of points to run')
# model input options
parser.add_option("--point_area_kmxkm", dest="point_area_kmxkm", default=None, \
help = 'user-specific area in kmxkm of each point in point list (unstructured')
parser.add_option("--point_area_degxdeg", dest="point_area_degxdeg", default=None, \
help = 'user-specific area in degreeXdegree of each point in point list (unstructured')
parser.add_option("--sitegroup", dest="sitegroup", default="AmeriFlux", \
help = "site group to use (default AmeriFlux)")
parser.add_option("--site", dest="site", default='', \
help = '6-character FLUXNET code to run (required)')
parser.add_option("--site_forcing", dest="site_forcing", default='', \
help = '6-character FLUXNET code for forcing data')
parser.add_option("--metdir", dest="metdir", default="none", \
help = 'subdirectory for met data forcing')
# metdata
parser.add_option("--cruncep", dest="cruncep", default=False, \
help = "use cru-ncep data", action="store_true")
parser.add_option("--cruncepv8", dest="cruncepv8", default=False, \
help = "use cru-ncep data", action="store_true")
parser.add_option("--crujra", dest="crujra", default=False, \
help = "use crujra data", action="store_true")
parser.add_option("--cplhist", dest="cplhist", default=False, \
help= "use CPLHIST forcing", action="store_true")
parser.add_option("--gswp3", dest="gswp3", default=False, \
help= "use GSWP3 forcing", action="store_true")
parser.add_option("--gswp3_w5e5", dest="gswp3_w5e5", default=False, action="store_true", \
help = 'Use GSWP3 w5e5 meteorology')
parser.add_option("--princeton", dest="princeton", default=False, \
help= "use Princecton forcing", action="store_true")
parser.add_option("--livneh", dest="livneh", default=False, \
action="store_true", help = "Livneh correction to CRU precip (CONUS only)")
parser.add_option("--daymet", dest="daymet", default=False, \
action="store_true", help = "Daymet correction to GSWP3 precip (CONUS only)")
parser.add_option("--monthly_metdata", dest="monthly_metdata", default = '', \
help = "File containing met data (cpl_bypass only)")
parser.add_option("--add_temperature", dest="addt", default=0.0, \
help = 'Temperature to add to atmospheric forcing')
parser.add_option("--co2_file", dest="co2_file", default="fco2_datm_rcp4.5_1765-2500_c130312.nc", \
help = 'CLM timestep (hours)')
parser.add_option("--add_co2", dest="addco2", default=0.0, \
help = 'CO2 (ppmv) to add to atmospheric forcing')
parser.add_option("--startdate_add_temperature", dest="sd_addt", default="99991231", \
help = 'Date (YYYYMMDD) to begin addding temperature')
parser.add_option("--startdate_add_co2", dest="sd_addco2", default="99991231", \
help = 'Date (YYYYMMDD) to begin addding CO2')
# surface data
parser.add_option("--daymet4", dest="daymet4", default=False, \
action="store_true", help = "Daymet v4 downscaled GSWP3-v2 forcing with user-provided domain and surface data)")
parser.add_option("--ad_spinup", action="store_true", \
dest="ad_spinup", default=False, \
help = 'Run accelerated decomposition spinup')
parser.add_option("--exit_spinup", action="store_true", \
dest="exit_spinup", default=False, \
help = 'Run exit spinup (CLM 4.0 only)')
parser.add_option("--finidat_case", dest="finidat_case", default='', \
help = "case containing initial data file to use" \
+" (should be in your run directory)")
parser.add_option("--finidat", dest="finidat", default='', \
help = "initial data file to use" \
+" (should be in your run directory)")
parser.add_option("--finidat_year", dest="finidat_year", default=-1, \
help = "model year of initial data file (default is" \
+" last available)")
parser.add_option("--run_units", dest="run_units", default='nyears', \
help = "run length units (ndays, nyears)")
parser.add_option("--run_n", dest="run_n", default=50, \
help = "run length (in run units)")
parser.add_option("--rest_n", dest="rest_n", default=-1, \
help = "restart interval (in run units)")
parser.add_option("--run_startyear", dest="run_startyear",default=-1, \
help='Starting year for model output')
parser.add_option("--rmold", dest="rmold", default=False, action="store_true", \
help = 'Remove old case directory with same name' \
+" before proceeding")
# model output options
parser.add_option("--dailyrunoff", dest="dailyrunoff", default=False, \
action="store_true", help="Write daily output for hydrology")
parser.add_option("--hist_mfilt", dest="hist_mfilt", default=-1, \
help = 'number of output timesteps per file')
parser.add_option("--hist_nhtfrq", dest="hist_nhtfrq", default=-999, \
help = 'output file timestep')
parser.add_option("--hist_vars", dest="hist_vars", default='', \
help = 'Output only selected variables in h0 file (comma delimited)')
#parser.add_option("--queue", dest="queue", default='essg08q', \
# help = 'PBS submission queue')
parser.add_option("--clean_config", dest="clean_config", default=False, \
help = 'Run cesm_setup -clean script')
parser.add_option("--clean_build", dest="clean_build", default=False, \
help = 'Perform clean build before building', \
action="store_true")
parser.add_option("--no_config", dest="no_config", default=False, \
help = 'do NOT configure case', action="store_true")
parser.add_option("--no_build", dest="no_build", default=False, \
help = 'do NOT build model', action="store_true")
parser.add_option("--no_submit", dest="no_submit", default=False, \
help = 'do NOT submit built model to queue, i.e. build only', action="store_true")
parser.add_option("--align_year", dest="align_year", default=-999, \
help = 'Alignment year (transient run only)')
parser.add_option("--np", dest="np", default=1, \
help = 'number of processors')
parser.add_option("--ninst", dest="ninst", default=1, \
help = 'number of land model instances')
parser.add_option("--ng", dest="ng", default=64, \
help = 'number of groups to run in ensmble mode')
parser.add_option("--tstep", dest="tstep", default=0.5, \
help = 'model timestep (hours)')
parser.add_option("--nyears_ad_spinup", dest="ny_ad", default=250, \
help = 'number of years to run ad_spinup')
parser.add_option("--nopointdata", action="store_true", \
dest="nopointdata", help="Do NOT make point data (use data already created)", \
default=False)
parser.add_option("--makepointdata_only", action="store_true", \
dest="makepointdata_only", \
help="make point data for later use ONLY, i.e. no model config/build/submit)", \
default=False)
#parser.add_option("--cleanlogs",dest="cleanlogs", help=\
# "Removes temporary and log files that are created",\
# default=False,action="store_true")
parser.add_option("--nofire", action="store_true", dest="nofire", default=False, \
help="To turn off wildfires")
parser.add_option("--nopftdyn", action="store_true", dest="nopftdyn", \
default = False, help='Do not use dynamic PFT file')
parser.add_option("--harvmod", action="store_true", dest="harvmod", \
default=False, help = "Turn on harvest modificaton" \
"All harvest is performed in first timestep")
parser.add_option("--no_dynroot", dest="no_dynroot", default=False, \
help = 'Turn off dynamic root distribution', action="store_true")
parser.add_option("--vertsoilc", dest="vsoilc", default=False, \
help = 'To turn on CN with multiple soil layers, excluding CENTURY C module (CLM4ME on as well)', action="store_true")
parser.add_option("--centbgc", dest="centbgc", default=False, \
help = 'To turn on CN with multiple soil layers, CENTURY C module (CLM4ME on as well)', action="store_true")
parser.add_option("--CH4", dest="CH4", default=False, \
help = 'To turn on CN with CLM4me', action="store_true")
parser.add_option("--1850_ndep", dest="ndep1850", default=False, \
help = 'Use constant 1850 N deposition', action="store_true")
parser.add_option("--ndep_rcp85", dest="ndeprcp85", default=False, \
help = 'Use RCP8.5 N deposition', action="store_true")
parser.add_option("--1850_aero", dest="aero1850", default=False, \
help = 'Use constant 1850 aerosol deposition', action="store_true")
parser.add_option("--aero_rcp85", dest="aerorcp85", default=False, \
help = 'Use RCP8.5 aerosol deposition', action="store_true")
parser.add_option("--1850_co2", dest="co21850", default=False, \
help = 'Use constant 1850 CO2 concentration', action="store_true")
parser.add_option("--C13", dest="C13", default=False, \
help = 'Switch to turn on C13', action="store_true")
parser.add_option("--C14", dest="C14", default=False, \
help = 'Use C14 as C13 (no decay)', action="store_true")
parser.add_option("--branch", dest="branch", default=False, \
help = 'Switch for branch run', action="store_true")
parser.add_option("--makemetdata", dest="makemet", default=False, \
help = 'Generate meteorology', action="store_true")
parser.add_option("--surfdata_grid", dest="surfdata_grid", default=False, \
help = 'Use gridded surface data instead of site data', action="store_true")
parser.add_option("--include_nonveg", dest="include_nonveg", default=False, \
help = 'Include non-vegetated columns/Landunits in surface data')
parser.add_option("--trans2", dest="trans2", default=False, action="store_true", \
help = 'Transient phase 2 (1901-2010) - CRUNCEP only')
parser.add_option("--transtag", dest="transtag", default="", \
help = 'Transient experiment runs, generally any tag to append to a casename')
parser.add_option("--spinup_vars", dest="spinup_vars", default=False, \
help = 'Limit output vars in spinup runs', action="store_true")
parser.add_option("--trans_varlist", dest = "trans_varlist", default='', help = "Transient outputs")
parser.add_option("--c_only", dest="c_only", default=False, \
help="Carbon only (supplemental P and N)", action="store_true")
parser.add_option("--cn_only", dest="cn_only", default=False, \
help = 'Carbon/Nitrogen only (supplemental P)', action="store_true")
parser.add_option("--cp_only", dest="cp_only", default=False, \
help = 'Carbon/Phosphorus only (supplemental N)', action = "store_true")
parser.add_option("--ensemble_file", dest="ensemble_file", default='', \
help = 'Parameter sample file to generate ensemble')
parser.add_option("--mc_ensemble", dest="mc_ensemble", default=-1, \
help = 'Monte Carlo ensemble (argument is # of simulations)')
parser.add_option("--ensemble_nocopy", dest="ensemble_nocopy", default=False, \
help = 'Do not copy files to ensemble directories', action="store_true")
parser.add_option("--surffile", dest="surffile", default="", \
help = 'Surface file to use')
parser.add_option("--domainfile", dest="domainfile", default="", \
help = 'Domain file to use')
parser.add_option("--fates_hydro", dest="fates_hydro", default=False, action="store_true", \
help = 'Set fates hydro to true')
parser.add_option("--fates_nutrient", dest="fates_nutrient", default="", \
help = 'Which version of fates_nutrient to use (RD or ECA)')
parser.add_option("--fates_paramfile", dest="fates_paramfile", default="", \
help = 'Fates parameter file to use')
parser.add_option("--var_soilthickness", dest="var_soilthickness", default=False, \
help = 'Use variable soil thickness from surface data', action="store_true")
parser.add_option("--no_budgets", dest="no_budgets", default=False, \
help = 'Turn off CNP budget calculations', action='store_true')
parser.add_option("--use_hydrstress", dest="use_hydrstress", default=False, \
help = 'Turn on hydraulic stress', action='store_true')
parser.add_option("--spruce_treatments", dest="spruce_treatments", default=False, \
help = 'Run SPRUCE treatment simulations (ensemble mode)', action='store_true')
#Changed by Ming for mesabi
parser.add_option("--archiveroot", dest="archiveroot", default='', \
help = "archive root directory only for mesabi")
#Added by Kirk to include the modified parameter file
parser.add_option("--mod_parm_file", dest="mod_parm_file", default='', \
help = "adding the path to the modified parameter file")
parser.add_option("--mod_parm_file_P", dest="mod_parm_file_P", default='', \
help = "adding the path to the modified parameter file")
parser.add_option("--parm_list", dest="parm_list", default='parm_list', \
help = 'File containing list of parameters to vary')
parser.add_option("--postproc_file", dest="postproc_file", default="", \
help = 'File for ensemble post processing')
parser.add_option("--walltime", dest="walltime", default=6, \
help = "desired walltime for each job (hours)")
parser.add_option("--lai", dest="lai", default=-999, \
help = 'Set constant LAI (SP mode only)')
parser.add_option("--maxpatch_pft", dest="maxpatch_pft", default=17, \
help = "user-defined max. patch PFT number, default is 17")
parser.add_option("--landusefile", dest="pftdynfile", default='', \
help='user-defined dynamic PFT file')
parser.add_option("--var_list_pft", dest="var_list_pft", default="",help='Comma-separated list of vars to output at PFT level')
(options, args) = parser.parse_args()
#-------------------------------------------------------------------------------
# If only make point(s) data, reset relevant options.
if (options.makepointdata_only):
options.no_config = True
options.no_build = True
options.no_submit = True
options.nopointdata = False
options.domainfile = ""
options.surffile = ""
options.pftdynfile=""
options.nopftdyn = False
elif(options.domainfile!="" and options.surffile!="" and \
(options.nopftdyn or options.pftdynfile!="")):
options.nopointdata = True
#Set default model root
if (options.csmdir == ''):
if (os.path.exists('../E3SM')):
options.csmdir = os.path.abspath('../E3SM')
print('Model root not specified. Defaulting to '+options.csmdir)
else:
print('Error: Model root not specified. Please set using --model_root')
sys.exit(1)
elif (not os.path.exists(options.csmdir)):
print('Error: Model root '+options.csmdir+' does not exist.')
sys.exit(1)
#check whether model named clm or elm
if (os.path.exists(options.csmdir+'/components/elm')):
mylsm='ELM'
model_name='elm'
if (options.res == 'CLM_USRDAT'):
options.res = 'ELM_USRDAT'
else:
mylsm='CLM'
model_name='clm2'
#machine info: cores per node
ppn=1
if ('titan' in options.machine):
ppn=16
if (int(options.walltime) > 2 and int(options.ng) < 2048):
print('Requested walltime too long')
print('Setting to 2 hours.')
options.walltime=2
elif ('metis' in options.machine):
ppn=16
elif ('oic2' in options.machine):
ppn=8
elif ('oic5' in options.machine or 'cori-haswell' in options.machine or 'eos' in options.machine \
or 'cades' in options.machine):
ppn=32
elif ('cori-knl' in options.machine):
ppn=64
elif ('edison' in options.machine):
ppn=24
elif ('anvil' in options.machine):
ppn=36
elif ('compy' in options.machine):
ppn=40
elif ('chrysalis' in options.machine):
ppn=64
elif ('pm-cpu' in options.machine):
ppn=128
elif ('docker' in options.machine):
ppn=4
if (options.ensemble_file == ''):
ppn=min(ppn, int(options.np))
PTCLMdir = os.getcwd()
#if (options.hist_vars != ''):
# hist_vars = os.path.abspath(options.hist_vars)
#set model if not specified
if (options.mymodel == ''):
if ('clm5' in options.csmdir):
options.mymodel = 'CLM5'
elif ('E3SM' in options.csmdir or 'e3sm' in options.csmdir or 'ACME' in options.csmdir):
options.mymodel = 'ELM'
else:
print('Error: Model not specified')
sys.exit(1)
#check for valid csm directory
if (os.path.exists(options.csmdir) == False):
print('Error: invalid model root directory. Please specify with --model_root')
sys.exit(1)
else:
csmdir = options.csmdir
scriptsdir = csmdir+'/cime/scripts'
#case directory
if (options.caseroot == '' or (os.path.exists(options.caseroot) == False)):
caseroot = csmdir+'/cime/scripts'
else:
caseroot = os.path.abspath(options.caseroot)
#case run root directory
runroot = os.path.abspath(options.runroot)
#check for valid input data directory
if (options.ccsm_input == '' or (os.path.exists(options.ccsm_input) \
== False)):
print('Error: invalid input data directory')
sys.exit(1)
else:
options.ccsm_input = os.path.abspath(options.ccsm_input)
#----------------------------------------------------------------------------------
# check for a specific forcing data, GSWP3-Daymet4, to offline ELM
# This is high-resolution dataset, usually together with user-defined domain and surface data
if (options.daymet4):
if (not options.gswp3): options.gswp3 = True
if (options.metdir=='none'):
print('Error: must provide user-defined " --metdir " for " --daymet4"')
sys.exit(1)
if (options.domainfile==''):
print('Error: must provide user-defined " --domainfile " for " --daymet4"')
sys.exit(1)
if (options.surffile==''):
print('Error: must provide user-defined " --surffile " for " --daymet4"')
sys.exit(1)
if (options.istrans or '20TR' in options.compset):
if(options.pftdynfile=='' and not options.nopftdyn):
print('Error: must provide user-defined " --pftdynfile " for " --daymet4"')
sys.exit(1)
#----------------------------------------------------------------------------------
compset = options.compset
isglobal = False
if (options.site == ''):
isglobal = True
options.site=options.res
if ('CBCN' in compset or 'ICB' in compset or 'CLM45CB' in compset):
cpl_bypass = True
else:
cpl_bypass = False
surfdir = 'surfdata_map'
if (options.mymodel == 'ELM'):
if ('ECA' in compset or 'ECA' in options.fates_nutrient):
parm_file = 'clm_params.c180713.nc'
elif('RD' in compset or 'RD' in options.fates_nutrient):
parm_file = 'clm_params_c180524.nc'
else:
parm_file = 'clm_params_c180301.nc' #FATES/CROP
if (options.mymodel == 'CLM5'):
parm_file = 'clm5_params.c171117.nc'
#pftphys_stamp = '_c160711' #'c160711_root'
#pftphys_stamp = '_c160711_test170303'
#CNPstamp = 'c131108'
CNPstamp = 'c180529'
#check consistency of options
if (options.istrans or '20TR' in compset):
#ignore spinup option if transient compset
if (options.ad_spinup or options.exit_spinup):
print('Spinup options not available for transient compset.')
sys.exit(1)
#finidat is required for transient compset
if (options.finidat_case == '' and options.finidat == ''):
print('Error: must provide initial data file for I20TR compsets')
sys.exit(1)
#get full path of finidat file
finidat=''
finidat_year=int(options.finidat_year)
if ('CN' in compset or 'ECA' in compset):
mybgc = 'CN'
elif ('ED' in compset):
mybgc = 'ED'
else:
mybgc = 'none'
if (options.exit_spinup):
if (options.mycaseid != ''):
finidat = options.mycaseid+'_'+options.site+'_I1850'+mybgc+'_ad_spinup'
else:
finidat = options.site+'_I1850'+mybgc+'_ad_spinup'
finidat_year = int(options.ny_ad)+1
if (options.finidat == '' and options.finidat_case == ''): #not user-defined
if (options.coldstart==False and compset == "I1850CLM45"+mybgc and options.ad_spinup == False):
if (options.mycaseid != ''):
options.finidat_case = options.mycaseid+'_'+options.site+ \
'_I1850CLM45'+mybgc+'_ad_spinup'
else:
options.finidat_case = options.site+'_I1850CLM45'+mybgc+'_ad_spinup'
if (options.finidat_year == -1):
finidat_year = int(options.ny_ad)+1
if (compset == "I20TRCLM45"+mybgc or compset == "I20TRCRUCLM45"+mybgc):
if (options.mycaseid != ''):
options.finidat_case = options.mycaseid+'_'+options.site+ \
'_I1850CLM45'+mybgc
else:
options.finidat_case = options.site + '_I1850CLM45'+mybgc
if (options.finidat_year == -1):
finidat_year=1850
if (compset == "I20TR"+mybgc):
if (options.mycaseid != ''):
options.finidat_case = options.mycaseid+'_'+options.site+ \
'_I1850'+mybgc
else:
options.finidat_case = options.site + '_I1850'+mybgc
if (options.finidat_year == -1):
finidat_year = 1850
#finidat is required for transient compset
if (os.path.exists(runroot+'/'+options.finidat_case) == False):
print('Error: must provide initial data file for I20TRCLM45CN/BGC compset OR '+ \
runroot+'/'+options.finidat_case+' existed as refcase')
sys.exit(1)
if (options.finidat_case != ''):
finidat_yst = str(10000+finidat_year)
if (mylsm == 'ELM'):
finidat = runroot+'/'+options.finidat_case+'/run/'+ \
options.finidat_case+'.elm.r.'+finidat_yst[1:]+ \
'-01-01-00000.nc'
else:
finidat = runroot+'/'+options.finidat_case+'/run/'+ \
options.finidat_case+'.clm2.r.'+finidat_yst[1:]+ \
'-01-01-00000.nc'
if (options.finidat != ''):
finidat = options.finidat
finidat_year = int(finidat[-19:-15])
finidat_yst = str(10000+finidat_year)
#construct default casename
casename = options.site+"_"+compset
if (options.mycaseid != ""):
casename = options.mycaseid+'_'+casename
if (options.metdir!='none'):# obviously user-provided met forcing is not reanalysis type
use_reanalysis = False
#CRU-NCEP 2 transient phases
elif ('CRU' in compset or options.cruncep or options.gswp3 or options.gswp3_w5e5 or \
options.crujra or options.cruncepv8 or options.princeton or options.cplhist):
use_reanalysis = True
else:
use_reanalysis = False
if ('20TR' in compset and use_reanalysis and (not cpl_bypass)):
if options.trans2:
casename = casename+'_phase2'
else:
casename = casename+'_phase1'
if (options.ad_spinup):
casename = casename+'_ad_spinup'
if (options.exit_spinup):
casename = casename+'_exit_spinup'
if (options.istrans and not "20TR" in compset):
casename = casename+'_trans'
if (options.transtag != ""):
casename = casename+'_'+options.transtag
PTCLMfiledir = options.ccsm_input+'/lnd/clm2/PTCLM'
#if (caseroot == runroot):
# casedir=caseroot+"/"+casename+'/case'
# os.system('mkdir -p '+casedir)
#elif (caseroot != "./"):
if (caseroot != "./"):
casedir=os.path.abspath(caseroot+"/"+casename)
else:
casedir=os.path.abspath(casename)
print('Machine is: '+options.machine)
#Check for existing case directory
if (os.path.exists(casedir)):
print('Warning: Case directory exists')
if (options.rmold):
print('--rmold specified. Removing old case ')
os.system('rm -rf '+casedir)
else:
var = input('proceed (p), remove old (r), or exit (x)? ')
if var[0] == 'r':
os.system('rm -rf '+casedir)
if var[0] == 'x':
sys.exit(1)
print("CASE directory is: "+casedir)
#Construct case build and run directory
if (options.exeroot == '' or (os.path.exists(options.exeroot) == False)):
exeroot = runroot+'/'+casename+'/bld'
#if ('titan' in options.machine or 'eos' in options.machine):
# exeroot = os.path.abspath(os.environ['HOME']+ \
# '/acme_scratch/pointclm/'+casename+'/bld')
else:
options.no_build=True
exeroot=options.exeroot
print("CASE exeroot is: "+exeroot)
rundir=runroot+'/'+casename+'/run'
print("CASE rundir is: "+rundir)
if (options.rmold):
if (options.no_build == False):
print('Removing build directory: '+exeroot)
os.system('rm -rf '+exeroot)
print('Removing run directory: '+rundir)
os.system('rm -rf '+rundir)
#------Make domain, surface data and pftdyn files ------------------
mysimyr=1850
#if (('1850' not in compset and '20TR' not in compset) or 'ED' in compset or 'FATES' in compset):
# #note - spinup with 2000 conditions for FATES
# mysimyr=2000
if (options.nopointdata == False):
ptcmd = 'python makepointdata.py --ccsm_input '+options.ccsm_input+ \
' --keep_duplicates --lat_bounds '+options.lat_bounds+' --lon_bounds '+ \
options.lon_bounds+' --mysimyr '+str(mysimyr)+' --model '+options.mymodel
if (options.metdir != 'none'):
ptcmd = ptcmd + ' --metdir '+options.metdir
if (options.makemet):
ptcmd = ptcmd + ' --makemetdata'
if (options.surfdata_grid):
ptcmd = ptcmd + ' --surfdata_grid'
if (options.include_nonveg):
ptcmd = ptcmd + ' --include_nonveg'
if (options.nopftdyn):
ptcmd = ptcmd + ' --nopftdyn'
if (options.mymask != ''):
ptcmd = ptcmd + ' --mask '+options.mymask
if (float(options.lai) > 0):
ptcmd = ptcmd + ' --lai '+str(options.lai)
if (int(options.mypft) >= 0):
ptcmd = ptcmd + ' --pft '+str(options.mypft)
if ('CROP' in compset):
ptcmd = ptcmd + ' --crop'
if (isglobal):
ptcmd = ptcmd + ' --res '+options.res
# if using global dataset to extract for running at a list of grid-points
if (options.point_list != ''):
ptcmd = ptcmd+' --point_list '+options.point_list
# changing resolution of extracted grid point area
if(options.point_area_kmxkm!=None):# area in a square measured by kmxkm
ptcmd = ptcmd+' --point_area_kmxkm '+options.point_area_kmxkm
elif(options.point_area_degxdeg!=None):# area in a square measured by degreexdegree
ptcmd = ptcmd+' --point_area_degxdeg '+options.point_area_degxdeg
else:
ptcmd = ptcmd + ' --site '+options.site+' --sitegroup '+options.sitegroup
#if(options.domainfile != ''):
# ptcmd = ptcmd + ' --nodomain '
#if(options.surffile !=''):
# ptcmd = ptcmd + ' --nosurfdata '
if(options.marsh):
ptcmd = ptcmd + ' --marsh'
if(options.humhol):
ptcmd = ptcmd + ' --humhol'
if (options.machine == 'eos' or options.machine == 'titan'):
os.system('rm temp/*.nc')
print('Note: NCO operations are slow on eos and titan.')
print('Submitting PBS script to make surface and domain data on rhea')
pbs_rhea=open('makepointdata_rhea.pbs','w')
pbs_rhea.write('#PBS -l walltime=00:30:00\n')
pbs_rhea.write('#PBS -l nodes=1\n')
pbs_rhea.write('#PBS -A cli112\n')
pbs_rhea.write('#PBS -q rhea\n')
pbs_rhea.write('#PBS -l gres=atlas1%atlas2\n\n')
pbs_rhea.write(' module load nco\n')
pbs_rhea.write(' cd '+os.getcwd()+'\n')
pbs_rhea.write(' rm temp/*.nc\n')
pbs_rhea.write(' module unload PE-intel\n')
pbs_rhea.write(' module load PE-gnu\n')
pbs_rhea.write(' module load python\n')
pbs_rhea.write(' module load python_numpy\n')
pbs_rhea.write(' module load python_scipy\n')
pbs_rhea.write(ptcmd+'\n')
pbs_rhea.close()
os.system('qsub makepointdata_rhea.pbs')
n_nc_files = 3
if (options.nopftdyn):
n_nc_files = 2
n=0
while (n < n_nc_files):
#Wait until files have been generated on rhea to proceed
list_dir = os.listdir('./temp')
n=0
for file in list_dir:
if file.endswith('.nc'):
n=n+1
os.system('sleep 10')
#Clean up
os.system('rm makepointdata_rhea*')
else:
print(ptcmd)
result = os.system(ptcmd)
if (result > 0):
print ('PointCLM: Error creating point data. Aborting')
sys.exit(1)
if(options.makepointdata_only):
print ('PointCLM: Successfully creating point data ONLY, i.e. no further config/build/run CLM/ELM')
print ('PointCLM: Files are in ./temp/*.nc, which you may save/rename properly for later use')
sys.exit(0)
if(options.domainfile != ''):
print('\n -----INFO: using user-provided DOMAIN')
print('domain file: '+ options.domainfile)
if(options.surffile !=''):
print('\n -----INFO: using user-provided SURFDATA')
print('surface data file: '+ options.surffile)
if(options.pftdynfile !='' or options.nopftdyn):
print('\n -----INFO: using user-provided 20th landuse data file')
print('20th landuse data file: '+ options.pftdynfile+"'\n")
if(options.metdir != 'none'):
print('\n -----INFO: using user-provided forcing data')
print('Under directory: '+ options.metdir)
#get site year information
sitedatadir = os.path.abspath(PTCLMfiledir)
os.chdir(sitedatadir)
if (isglobal == False):
AFdatareader = csv.reader(open(options.sitegroup+'_sitedata.txt',"r"))
for row in AFdatareader:
if row[0] == options.site:
if (use_reanalysis):
if ('CN' in compset or 'BGC' in compset):
if (options.trans2):
startyear = 1921
endyear = int(row[7])
else:
startyear = 1901
endyear = 1920
else:
startyear = int(row[6]) #1901
endyear = int(row[7])
else:
startyear=int(row[6])
endyear=int(row[7])
alignyear = int(row[8])
if (options.diags):
timezone = int(row[9])
if (options.humhol or options.marsh):
numxpts=2
else:
numxpts=1
numypts=1
else:
if (use_reanalysis):
startyear=1901
if ('20TR' in compset or options.istrans):
endyear = 2010
if (options.trans2):
startyear = 1921
else:
endyear = 1920
else: #Global default to Qian
startyear=1948
if ('20TR' in compset or options.istrans):
endyear = 2004
if (options.trans2):
startyear = 1973
else:
endyear = 1972
ptstr=''
if (isglobal == False):
ptstr = str(numxpts)+'x'+str(numypts)+'pt'
os.chdir(csmdir+'/cime/scripts')
#parameter (pft-phys) modifications if desired
tmpdir = PTCLMdir+'/temp'
if (options.mycaseid == ''):
myscriptsdir = 'none'
else:
myscriptsdir = options.mycaseid
os.system('mkdir -p '+tmpdir)
if (options.mod_parm_file != ''):
print('nccopy -3 '+options.mod_parm_file+' '+tmpdir+'/clm_params.nc')
os.system('nccopy -3 '+options.mod_parm_file+' '+tmpdir+'/clm_params.nc')
else:
print(parm_file)
print('nccopy -3 '+options.ccsm_input+'/lnd/clm2/paramdata/'+parm_file+' '+tmpdir+'/clm_params.nc')
os.system('nccopy -3 '+options.ccsm_input+'/lnd/clm2/paramdata/'+parm_file+' ' \
+tmpdir+'/clm_params.nc')
myncap = 'ncap'
if ('cades' in options.machine or 'chrysalis' in options.machine or 'compy' in options.machine or 'ubuntu' in options.machine \
or 'mymac' in options.machine or 'anvil' in options.machine):
myncap='ncap2'
flnr = nffun.getvar(tmpdir+'/clm_params.nc','flnr')
if (options.humhol or options.marsh):
print('Adding hummock-hollow parameters (default for SPRUCE site)')
# print('humhol_ht = 0.15m')
# print('humhol_dist = 1.0m')
print('setting rsub_top_globalmax = 1.2e-5')
print('Making br_mr a PFT-specific parameter')
os.system(myncap+' -O -s "humhol_ht = br_mr*0+0.15" '+tmpdir+'/clm_params.nc '+tmpdir+'/clm_params.nc')
if options.marsh:
os.system(myncap+' -O -s "hum_frac = br_mr*0+0.50" '+tmpdir+'/clm_params.nc '+tmpdir+'/clm_params.nc')
print('hum_frac = 0.50')
else:
os.system(myncap+' -O -s "hum_frac = br_mr*0+0.64" '+tmpdir+'/clm_params.nc '+tmpdir+'/clm_params.nc')
print('hum_frac = 0.64')
os.system(myncap+' -O -s "humhol_dist = br_mr*0+1.0" '+tmpdir+'/clm_params.nc '+tmpdir+'/clm_params.nc')
if options.marsh:
print('qflx_h2osfc_surfrate = 0.0')
os.system(myncap+' -O -s "qflx_h2osfc_surfrate = br_mr*0+0.0" '+tmpdir+'/clm_params.nc '+tmpdir+'/clm_params.nc')
else:
print('qflx_h2osfc_surfrate = 1.0e-7')
os.system(myncap+' -O -s "qflx_h2osfc_surfrate = br_mr*0+1.0e-7" '+tmpdir+'/clm_params.nc '+tmpdir+'/clm_params.nc')
os.system(myncap+' -O -s "moss_swc_adjust=scalar(0)" '+tmpdir+'/clm_params.nc '+tmpdir+'/clm_params.nc')
os.system(myncap+' -O -s "rsub_top_globalmax = br_mr*0+1.2e-5" '+tmpdir+'/clm_params.nc '+tmpdir+'/clm_params.nc')
os.system(myncap+' -O -s "h2osoi_offset = br_mr*0" '+tmpdir+'/clm_params.nc '+tmpdir+'/clm_params.nc')
flnr = nffun.getvar(tmpdir+'/clm_params.nc','flnr')
os.system(myncap+' -O -s "br_mr = flnr" '+tmpdir+'/clm_params.nc '+tmpdir+'/clm_params.nc')
ierr = nffun.putvar(tmpdir+'/clm_params.nc','br_mr', flnr*0.0+2.52e-6)
#os.system(myncap+' -O -s "vcmaxse = flnr" '+tmpdir+'/clm_params.nc '+tmpdir+'/clm_params.nc')
#ierr = nffun.putvar(tmpdir+'/clm_params.nc','vcmaxse', flnr*0.0+670)
if (options.marsh and options.tide_components_file != ''):
print('Adding tidal cycle components from file %s'%options.tide_components_file)
print('Assuming file is in NOAA tide component format, degrees and meters units (e.g.: https://tidesandcurrents.noaa.gov/harcon.html?id=8441241&unit=0)')
print('Tide datum (tide_baseline parameter) needs to be specified separately. Default is 800 mm')
import pandas
tidecomps=pandas.read_csv(options.tide_components_file)
for comp in range(len(tidecomps)):
os.system(myncap+' -O -s "tide_coeff_amp_%d = humhol_ht*0+%1.4e" '%(comp+1,tidecomps['Amplitude'].iloc[comp]*1000)+tmpdir+'/clm_params.nc '+tmpdir+'/clm_params.nc')
os.system(myncap+' -O -s "tide_coeff_period_%d = humhol_ht*0+%1.4e" '%(comp+1,360*3600/tidecomps['Speed'].iloc[comp])+tmpdir+'/clm_params.nc '+tmpdir+'/clm_params.nc')
os.system(myncap+' -O -s "tide_coeff_phase_%d = humhol_ht*0+%1.4e" '%(comp+1,tidecomps['Phase'].iloc[comp]*math.pi/180)+tmpdir+'/clm_params.nc '+tmpdir+'/clm_params.nc')
os.system(myncap+' -O -s "tide_baseline = humhol_ht*0+800.0" '+tmpdir+'/clm_params.nc '+tmpdir+'/clm_params.nc')
elif options.marsh:
print('Tidal cycle coefficients not specified. Model will use GCREW defaults. Can also edit in parm file.')
#os.system(myncap+' -O -s "crit_gdd1 = flnr" '+tmpdir+'/clm_params.nc '+tmpdir+'/clm_params.nc')
#os.system(myncap+' -O -s "crit_gdd2 = flnr" '+tmpdir+'/clm_params.nc '+tmpdir+'/clm_params.nc')
#os.system(myncap+' -O -s "crit_onset_gdd = ndays_on" '+tmpdir+'/clm_params.nc '+tmpdir+'/clm_params.nc')
#ierr = nffun.putvar(tmpdir+'/clm_params.nc','crit_gdd1', flnr*0.0+4.8)
#ierr = nffun.putvar(tmpdir+'/clm_params.nc','crit_gdd2', flnr*0.0+0.13)
#ndays_on = nffun.getvar(tmpdir+'/clm_params.nc','ndays_on')
#ierr = nffun.putvar(tmpdir+'/clm_params.nc','crit_onset_gdd', ndays_on*0.0+200.0)
# BSulman: These Nfix constants can break the model if they don't have the right length.
#os.system(myncap+' -O -s "Nfix_NPP_c1 = br_mr*+1.8" '+tmpdir+'/clm_params.nc '+tmpdir+'/clm_params.nc')
#os.system(myncap+' -O -s "Nfix_NPP_c2 = br_mr*0.003" '+tmpdir+'/clm_params.nc '+tmpdir+'/clm_params.nc')
#os.system(myncap+' -O -s "nfix_timeconst = br_mr*10.0" '+tmpdir+'/clm_params.nc '+tmpdir+'/clm_params.nc')
os.system('chmod u+w ' +tmpdir+'/clm_params.nc')
if (options.parm_file != ''):
pftfile = tmpdir+'/clm_params.nc'
if ('/' not in options.parm_file):
#assume in pointclm directory
input = open(PTCLMdir+'/'+options.parm_file)
else: #assume full path given
input = open(os.path.abspath(options.parm_file))
for s in input:
if s[0:1] != '#':
values = s.split()
try:
thisvar = nffun.getvar(pftfile, values[0])
if (len(values) == 2):
thisvar[...] = float(values[1])
elif (len(values) == 3):
if (float(values[1]) > 0):
thisvar[int(values[1])] = float(values[2])
else:
thisvar[...] = float(values[2])
ierr = nffun.putvar(pftfile, values[0], thisvar)
except ValueError:
print('Parameter %s not found in clm_params.nc. Adding.'%values[0])
if (len(values) == 2):
print('No PFT specified. Assuming universal parameter')
os.system(myncap+' -O -s "%s = q10_mr*0+%1.4e" '%(values[0],values[1])+tmpdir+'/clm_params.nc '+tmpdir+'/clm_params.nc')
elif (len(values) == 3):
if (float(values[1]) > 0):
print('PFT specified. Setting value for all PFTs')
os.system(myncap+' -O -s "%s = flnr*0+%s" '%(values[0],values[2])+tmpdir+'/clm_params.nc '+tmpdir+'/clm_params.nc')
else:
print('No PFT specified. Assuming universal parameter')
os.system(myncap+' -O -s "%s = q10_mr*0+%s" '%(values[0],values[2])+tmpdir+'/clm_params.nc '+tmpdir+'/clm_params.nc')
input.close()
if (options.parm_vals != ''):
pftfile = tmpdir+'/clm_params.nc'
parms = options.parm_vals.split('/')
nparms = len(parms)
for n in range(0,nparms):
parm_data=parms[n].split(',')
thisvar = nffun.getvar(pftfile, parm_data[0])
if (len(parm_data) == 2):
thisvar[...] = float(parm_data[1])
elif (len(parm_data) == 3):
if (float(parm_data[1]) >= 0):
thisvar[int(parm_data[1])] = float(parm_data[2])
else:
thisvar[...] = float(parm_data[2])
ierr = nffun.putvar(pftfile, parm_data[0], thisvar)
#parameter (soil order dependent) modifications if desired ::X.YANG
if (options.mymodel == 'ELM'):
if (options.mod_parm_file_P != ''):
os.system('cp '+options.mod_parm_file_P+' '+tmpdir+'/CNP_parameters.nc')
else:
os.system('cp '+options.ccsm_input+'/lnd/clm2/paramdata/CNP_parameters_'+CNPstamp+'.nc ' \
+tmpdir+'/CNP_parameters.nc')
os.system('chmod u+w ' +tmpdir+'/CNP_parameters.nc')
if (options.parm_file_P != ''):
soilorderfile = tmpdir+'/CNP_parameters.nc'
if ('/' not in options.parm_file_P):
#assume in pointclm directory
input = open(PTCLMdir+'/'+options.parm_file_P)
else: #assume full path given
input = open(os.path.abspath(options.parm_file_P))
input = open(os.path.abspath(options.parm_file_P))
for s in input:
if s[0:1] != '#':
values = s.split()
thisvar = nffun.getvar(soilorderfile, values[0])
if (len(values) == 2):
thisvar[...] = float(values[1])
elif (len(values) == 3):
if (float(values[1]) >= 0):
thisvar[int(values[1])] = float(values[2])
else:
thisvar[...] = float(values[2])
ierr = nffun.putvar(soilorderfile, values[0], thisvar)
input.close()
#set number of run years for ad, exit spinup cases
if (options.ny_ad != options.run_n and options.ad_spinup):
options.run_n = options.ny_ad
elif (options.exit_spinup):
options.run_n = 1
#create new case
timestr=str(int(float(options.walltime)))+':'+str(int((float(options.walltime)- \
int(float(options.walltime)))*60))+':00'
cmd = './create_newcase --case '+casedir+' --mach '+options.machine+' --compset '+ \
options.compset+' --res '+options.res+' --mpilib '+ \
options.mpilib+' --walltime '+timestr+' --handle-preexisting-dirs u'
if (options.mymodel == 'CLM5'):
cmd = cmd+' --run-unsupported'
if (options.project != ''):
cmd = cmd+' --project '+options.project
if (options.compiler != ''):
cmd = cmd+' --compiler '+options.compiler
cmd = cmd+' > create_newcase.log'
print(cmd)
result = os.system(cmd)
if (os.path.isdir(casedir)):
print(casename+' created. See create_newcase.log for details')
#os.system('mv create_newcase.log '+casename)
os.system('mv create_newcase.log '+casedir)