forked from ESCOMP/CAM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigure
executable file
·2722 lines (2257 loc) · 92.4 KB
/
configure
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 perl
#-----------------------------------------------------------------------------------------------
#
# configure
#
#
# This utility allows the CAM user to specify compile-time configuration
# options via a commandline interface. The output from configure is a
# Makefile and a cache file that contains all configuration parameters
# required to produce the Makefile. A subsequent invocation of configure
# can use the cache file as input (via the -defaults argument) to reproduce
# the CAM configuration contained in it. Note that when a cache file is
# used to set default values only the model parameters are used. The
# parameters that are platform dependent (e.g., compiler options, library
# locations, etc) are ignored.
#
# As the build time configurable options of CAM are changed, this script
# must also be changed. Thus configure is maintained under revision
# control in the CAM source tree and it is assumed that only the version of
# configure in the source tree will be used to build CAM. Thus we assume
# that the root of the source tree can be derived from the location of this
# script.
#
use strict;
#use warnings;
#use diagnostics;
use Cwd;
use English;
use Getopt::Long;
use IO::File;
use IO::Handle;
use FindBin qw($Bin);
use lib "$Bin/perl5lib";
use Build::ChemPreprocess qw(chem_preprocess chem_number_adv);
use File::Copy;
#-----------------------------------------------------------------------------------------------
sub usage {
die <<EOF;
SYNOPSIS
configure [options]
OPTIONS
User supplied values are denoted in angle brackets (<>). Any value that contains
white-space must be quoted. Long option names may be supplied with either single
or double leading dashes. A consequence of this is that single letter options may
NOT be bundled.
Options used to determine the CAM model configuration. These options will have an
effect whether running CAM from CESM scripts or running via CAM standalone scripts:
-[no]age_of_air_trcs Switch on [off] age of air tracers. Default: on for waccm_phys, otherwise off.
-analytic_ic Enables the (namelist controlled) dycore testing infrastructure
-aquaplanet Switch on aqua-planet mode.
-build_chem_proc Switch forces the build of the chemistry preprocessor (primarily for testing).
-carma <name> Build CAM with specified CARMA microphysics model
[ none | bc_strat | cirrus | cirrus_dust | dust | meteor_impact |
meteor_smoke | mixed_sulfate | pmc | pmc_sulfate | sea_salt | sulfate | tholin |
test_detrain | test_growth | test_passive | test_radiative | test_swelling |
test_tracers, test_tracers2].
Default: none.
-chem <name> Build CAM with specified prognostic chemistry package
[ none | ghg_mam4 | terminator | trop_mam3 | trop_mam4 | trop_mam7 | trop_mozart | trop_strat_mam4_ts2 |
trop_strat_mam4_vbs | trop_strat_mam4_vbsext | trop_strat_mam5_ts2 | trop_strat_mam5_vbs |
trop_strat_mam5_vbsext | waccm_ma | waccm_mad | waccm_ma_sulfur | waccm_sc | waccm_sc_mam4 |
waccm_mad_mam4 | waccm_ma_mam4 | waccm_tsmlt_mam4 | waccm_tsmlt_mam4_vbsext | waccm_mad_mam5 |
waccm_ma_mam5 | waccm_tsmlt_mam5 | waccm_tsmlt_mam5_vbsext | geoschem_mam4 ].
Default: trop_mam4 for cam6 and trop_mam3 for cam5.
-[no]clubb_sgs Switch on [off] CLUBB_SGS. Default: on for cam6, otherwise off.
-clubb_opts <list> Comma separated list of CLUBB options to turn on/off. By default they are all off.
Current option is: clubb_do_adv (Advect CLUBB moments)
-co2_cycle This option modifies the CAM configuration by
increasing the number of advected constituents by 4.
-cosp Enable the COSP simulator.
-cppdefs <string> A string of user specified CPP defines. Appended to
Makefile defaults. E.g. -cppdefs '-DVAR1 -DVAR2'
-cpl Coupling framework [mct | nuopc]. Default: mct.
-dyn <name> Dynamical core option: [eul | fv | se | fv3 | mpas]. Default: fv.
-edit_chem_mech Invokes CAMCHEM_EDITOR to allow the user to edit the chemistry mechanism file
-hgrid <name> Specify horizontal grid. Use nlatxnlon for spectral grids;
dlatxdlon for fv grids (dlat and dlon are the grid cell size
in degrees for latitude and longitude respectively); nexnp for
se grids.
-ionosphere Ionophere module used in WACCMX [ none | wxie ].
-macrophys <name> Specify the macrophysics option [rk | park | clubb_sgs].
-max_n_rad_cnst <n> Maximum number of constituents that are either radiatively
active, or in any single diagnostic list for the radiation.
-microphys <name> Specify the microphysics option [mg1 | mg2 | mg3| rk | pumas].
-model_top <name> Specify the model_top option [ lt | mt ].
-nadv <n> Set total number of advected species to <n>.
-nadv_tt <n> Set number of advected test tracers <n>.
-nlev <n> Set number of levels to <n>.
-offline_dyn Switch enables the use of offline driver for FV dycore.
-pbl <name> Specify the PBL option [uw | hb | hbr].
-pcols <n> Set maximum number of columns in a chunk to <n>.
-pergro Switch enables building CAM for perturbation growth tests.
-phys <name> Physics option [cam3 | cam4 | cam5 | cam6 | cam_dev |
held_suarez | adiabatic | kessler | tj2016 | grayrad
spcam_sam1mom | spcam_m2005]. Default: cam6
-prog_species <list>Comma-separate list of prognostic mozart species packages.
Currently available: DST,SSLT,SO4,GHG,OC,BC,CARBON16
-psubcols <n> Maximum number of sub-columns in a run - set to 1 if not using sub-columns (default)
-rad <name> Specify the radiation package [rrtmg | rrtmgp | rrtmgp_gpu | camrt]
-silhs Switch on SILHS.
-spcam_clubb_sgs Turn on the SPCAM version of CLUBB
-spcam_nx <n> SPCAM x-grid. - defaults to 4 (note the CRM requires spcam_nx to be greater than or equal to 4)
-spcam_ny <n> SPCAM y-grid. - defaults to 1
-spcam_dx <n> SPCAM horizontal grid spacing.
-spcam_dt <n> SPCAM timestep.
-unicon Switch to turn on the UNICON scheme. Default: off.
-usr_mech_infile Path and file name of the user supplied chemistry mechanism file.
-waccm_phys Switch enables the use of WACCM physics in any chemistry configuration.
The user does not need to set this if one of the waccm chemistry options
is chosen.
-waccmx Build CAM/WACCM with WACCM upper Thermosphere/Ionosphere extended package
-zmconv_org Include parameterization for sub-grid scale convective organization for the ZM deep convective scheme based
on Mapes and Neale (2011)
Options relevent to SCAM mode:
-camiop Configure CAM to generate an IOP file that can be used to drive SCAM.
This switch only works with the Eulerian dycore.
-scam Compiles model in single column mode. Only works with Eulerian dycore.
CAM parallelization:
-[no]smp Switch on [off] SMP parallelism.
-[no]spmd Switch on [off] SPMD parallelism.
Configure options:
-cache <file> Name of output cache file (default: config_cache.xml).
-cachedir <file> Name of directory where output cache file is written (default: CAM build directory).
-help [or -h] Print usage to STDOUT.
-silent [or -s] Turns on silent mode - only fatal messages issued.
-verbose [or -v] Turn on verbose echoing of settings made by configure.
-version Echo the CVS tag name used to check out this CAM distribution.
Options for building CAM via standalone scripts:
-cam_bld <dir> Directory where CAM will be built. This is where configure will write the
output files it generates (Makefile, Filepath, etc...)
-cam_exe <name> Name of the CAM executable (default: cam).
-cam_exedir <dir> Directory where CAM executable will be created (default: CAM build directory).
-cc <name> User specified C compiler (linux only). Overrides Makefile default.
-cflags <string> A string of user specified C compiler options. Appended to
Makefile defaults.
-debug Switch to turn on building CAM with debugging compiler options.
-cosp_libdir <dir> Directory containing COSP library.
-esmf_libdir <dir> Directory containing ESMF library and esmf.mk file.
-fv3core_libdir <dir> Directory containing FV3 library.
-fc <name> User specified Fortran compiler. Overrides Makefile default.
-fc_type <name> Type of Fortran compiler [pgi | intel | gnu | pathscale
| ibm | nag]. This argument is used in conjunction
with the -fc argument when the name of the fortran
compiler refers to a wrapper script (e.g., mpif90
or ftn). In this case the user needs to specify
the type of Fortran compiler that is being invoked
by the wrapper script. Default: pgi
-fflags <string> A string of user specified Fortran compiler flags. Appended to
Makefile defaults. See -fopt to override optimization flags.
-fopt <string> A string of user specified Fortran compiler optimization flags.
Overrides Makefile defaults.
-gmake <name> Name of the GNU make program on your system. Supply the absolute
pathname if the program is not in your path (or fix your path).
-lapack_libdir <dir>
Directory containing LAPACK library.
-ldflags <string> A string of user specified load options. Appended to
Makefile defaults.
-linker <name> User specified linker. Overrides Makefile default of \$(FC).
-mpas_libdir <dir> Directory containing MPAS library.
-mct_libdir <dir> Directory containing MCT library. Default: build the library from source
in a subdirectory of \$cam_bld.
-mpi_inc <dir> Directory containing MPI include files.
-mpi_lib <dir> Directory containing MPI library.
-nc_inc <dir> Directory containing netCDF include files.
-nc_lib <dir> Directory containing netCDF library.
-nc_mod <dir> Directory containing netCDF module files.
-pio2 Switch to turn on building PIO2. PIO2 is built as a separate library.
Default: Use PIO1 and build as part of cam executable.
-pio2_install_dir <dir> Directory to install PIO2 libraries and include files. If the libraries
already exist then configure will use them in the build.
-pnc_inc <dir> Directory containing PnetCDF include files.
-pnc_lib <dir> Directory containing PnetCDF library.
-target_os Override the os setting for cross platform compilation [aix | darwin | dec_osf |
irix | linux | solaris | super-ux | unicosmp | bgl | bgp | bgq].
Default: OS on which configure is executing as defined by the
perl \$OSNAME variable.
-usr_src <dir1>[,<dir2>[,<dir3>[...]]]
Directories containing user source code.
-offline_drv <name> Specify offline unit driver [ aur | rad | stub ]
EOF
}
#-----------------------------------------------------------------------------------------------
# Setting autoflush (an IO::Handle method) on STDOUT helps in debugging. It forces the test
# descriptions to be printed to STDOUT before the error messages start.
*STDOUT->autoflush();
#-----------------------------------------------------------------------------------------------
# Set the directory that contains the CAM configuration scripts. If the configure command was
# issued using a relative or absolute path, that path is in $ProgDir. Otherwise assume the
# command was issued from the current working directory.
(my $ProgName = $0) =~ s!(.*)/!!; # name of this script
my $ProgDir = $1; # name of directory containing this script -- may be a
# relative or absolute path, or null if the script is in
# the user's PATH
my $cwd = getcwd(); # current working directory
my $cfgdir; # absolute pathname of directory that contains this script
if ($ProgDir) {
$cfgdir = absolute_path($ProgDir);
} else {
$cfgdir = $cwd;
}
#-----------------------------------------------------------------------------------------------
# Save commandline
my $commandline = "$cfgdir/configure @ARGV";
#-----------------------------------------------------------------------------------------------
# Parse command-line options.
my %opts = (
cache => "config_cache.xml",
);
GetOptions(
"age_of_air_trcs!" => \$opts{'age_of_air_trcs'},
"analytic_ic" => \$opts{'analytic_ic'},
"aquaplanet" => \$opts{'aquaplanet'},
"build_chem_proc" => \$opts{'build_chem_proc'},
"cache=s" => \$opts{'cache'},
"cachedir=s" => \$opts{'cachedir'},
"carma=s" => \$opts{'carma'},
"cam_bld=s" => \$opts{'cam_bld'},
"cam_exe=s" => \$opts{'cam_exe'},
"cam_exedir=s" => \$opts{'cam_exedir'},
"camiop" => \$opts{'camiop'},
"cc=s" => \$opts{'cc'},
"cflags=s" => \$opts{'cflags'},
"chem=s" => \$opts{'chem'},
"clubb_sgs!" => \$opts{'clubb_sgs'},
"clubb_opts=s" => \$opts{'clubb_opts'},
"co2_cycle" => \$opts{'co2_cycle'},
"cosp" => \$opts{'cosp'},
"cosp_libdir=s" => \$opts{'cosp_libdir'},
"cppdefs=s" => \$opts{'cppdefs'},
"cpl=s" => \$opts{'cpl'},
"spcam_clubb_sgs" => \$opts{'spcam_clubb_sgs'},
"debug" => \$opts{'debug'},
"dyn=s" => \$opts{'dyn'},
"edit_chem_mech" => \$opts{'edit_chem_mech'},
"esmf_libdir=s" => \$opts{'esmf_libdir'},
"fc=s" => \$opts{'fc'},
"fc_type=s" => \$opts{'fc_type'},
"fflags=s" => \$opts{'fflags'},
"fopt=s" => \$opts{'fopt'},
"fv3core_libdir=s" => \$opts{'fv3core_libdir'},
"gmake=s" => \$opts{'gmake'},
"h|help" => \$opts{'help'},
"hgrid=s" => \$opts{'hgrid'},
"ionosphere=s" => \$opts{'ionosphere'},
"lapack_libdir=s" => \$opts{'lapack_libdir'},
"ldflags=s" => \$opts{'ldflags'},
"linker=s" => \$opts{'linker'},
"macrophys=s" => \$opts{'macrophys'},
"max_n_rad_cnst=s" => \$opts{'max_n_rad_cnst'},
"mct_libdir=s" => \$opts{'mct_libdir'},
"microphys=s" => \$opts{'microphys'},
"model_top=s" => \$opts{'model_top'},
"mpas_libdir=s" => \$opts{'mpas_libdir'},
"mpi_inc=s" => \$opts{'mpi_inc'},
"mpi_lib=s" => \$opts{'mpi_lib'},
"nadv=s" => \$opts{'nadv'},
"nadv_tt=s" => \$opts{'nadv_tt'},
"nc_inc=s" => \$opts{'nc_inc'},
"nc_lib=s" => \$opts{'nc_lib'},
"nc_mod=s" => \$opts{'nc_mod'},
"nlev=s" => \$opts{'nlev'},
"ocn=s" => \$opts{'ocn'},
"offline_dyn" => \$opts{'offline_dyn'},
"pbl=s" => \$opts{'pbl'},
"pcols=s" => \$opts{'pcols'},
"p|pergro" => \$opts{'pergro'},
"phys=s" => \$opts{'phys'},
"pio2" => \$opts{'pio2'},
"pio2_install_dir=s" => \$opts{'pio2_install_dir'},
"pnc_inc=s" => \$opts{'pnc_inc'},
"pnc_lib=s" => \$opts{'pnc_lib'},
"prog_species=s" => \$opts{'prog_species'},
"psubcols=s" => \$opts{'psubcols'},
"rad=s" => \$opts{'rad'},
"offline_drv=s" => \$opts{'offline_drv'},
"scam" => \$opts{'scam'},
"silhs" => \$opts{'silhs'},
"s|silent" => \$opts{'silent'},
"smp!" => \$opts{'smp'},
"spcam_nx=s" => \$opts{'spcam_nx'},
"spcam_ny=s" => \$opts{'spcam_ny'},
"spcam_dx=s" => \$opts{'spcam_dx'},
"spcam_dt=s" => \$opts{'spcam_dt'},
"spmd!" => \$opts{'spmd'},
"target_os=s" => \$opts{'target_os'},
"unicon" => \$opts{'unicon'},
"usr_mech_infile=s" => \$opts{'usr_mech_infile'},
"usr_src=s" => \$opts{'usr_src'},
"v|verbose" => \$opts{'verbose'},
"version" => \$opts{'version'},
"waccm_phys" => \$opts{'waccm_phys'},
"waccmx" => \$opts{'waccmx'},
"zmconv_org" => \$opts{'zmconv_org'},
) or usage();
# Give usage message.
usage() if $opts{'help'};
# Echo version info.
version($cfgdir) if $opts{'version'};
# Check for unparsed argumentss
if (@ARGV) {
print "ERROR: unrecognized arguments: @ARGV\n";
usage();
}
# Define 3 print levels:
# 0 - only issue fatal error messages
# 1 - only informs what files are created (default)
# 2 - verbose
my $print = 1;
if ($opts{'silent'}) { $print = 0; }
if ($opts{'verbose'}) { $print = 2; }
my $eol = "\n";
my %cfg = (); # build configuration
#-----------------------------------------------------------------------------------------------
# Make sure we can find required perl modules and configuration files.
# Look for them in the directory that contains the configure script.
# Check for the configuration definition file.
my $config_def_file = "config_files/definition.xml";
(-f "$cfgdir/$config_def_file") or die <<"EOF";
** Cannot find configuration definition file \"$config_def_file\" in directory \"$cfgdir\" **
EOF
# Horizontal grid and spectral resolution parameters.
my $horiz_grid_file = 'config_files/horiz_grid.xml';
(-f "$cfgdir/$horiz_grid_file") or die <<"EOF";
** Cannot find horizonal grid parameters file \"$horiz_grid_file\" in directory \"$cfgdir\" **
EOF
# The XML::Lite module is required to parse the XML configuration files.
(-f "$cfgdir/perl5lib/XML/Lite.pm") or die <<"EOF";
** Cannot find perl module \"XML/Lite.pm\" in directory \"$cfgdir/perl5lib\" **
EOF
# The Build::Config module provides utilities to store and manipulate the configuration.
(-f "$cfgdir/perl5lib/Build/Config.pm") or die <<"EOF";
** Cannot find perl module \"Build/Config.pm\" in directory \"$cfgdir/perl5lib\" **
EOF
if ($print>=2) { print "CAM configuration script directory: $cfgdir$eol"; }
#-----------------------------------------------------------------------------------------------
# Add $cfgdir/perl5lib to the list of paths that Perl searches for modules
unshift @INC, "$cfgdir/perl5lib";
unshift @INC, "$cfgdir";
require XML::Lite;
require Build::Config;
# Initialize the configuration. The $config_def_file provides the definition of a CAM
# configuration. $cfg_ref is a reference to the new configuration object.
my $cfg_ref = Build::Config->new("$cfgdir/$config_def_file");
#-----------------------------------------------------------------------------------------------
# CAM root directory.
# Check for standalone or CESM checkout
my $cam_root = absolute_path("$cfgdir/..");
my $cam_dir = $cam_root;
if (! -d "$cam_root/cime") {
$cam_root = absolute_path("$cfgdir/../../..");
}
if (-d "$cam_root/components/cam/src") {
$cfg_ref->set('cam_root', $cam_root);
$cam_dir = "$cam_root/components/cam";
$cfg_ref->set('cam_dir', $cam_dir);
}
elsif (-d "$cam_root/src") {
$cfg_ref->set('cam_root', $cam_root);
$cfg_ref->set('cam_dir', $cam_dir);
} else {
die <<"EOF";
** Invalid CAM root directory: $cam_root
**
** The CAM root directory must contain the subdirectory components/cam/src/
** (CESM checkout) or the subdirectory src (standalone checkout).
** For CESM checkouts, it is derived from "config_dir/../../..".
** For CAM standalone checkouts, it is derived from"config_dir/..",
** where config_dir is the directory in the CAM distribution that
** contains the configuration scripts.
** scripts.
EOF
}
if ($print>=2) { print "CAM root directory: $cam_root$eol"; }
#-----------------------------------------------------------------------------------------------
# CAM build directory.
my $cam_bld;
if (defined $opts{'cam_bld'}) {
$cam_bld = absolute_path($opts{'cam_bld'});
}
else { # use default value
$cam_bld = absolute_path($cfg_ref->get('cam_bld'));
}
if (-d $cam_bld or mkdirp($cam_bld)) {
# If the build directory exists or can be made then set the value...
$cfg_ref->set('cam_bld', $cam_bld);
}
else {
die <<"EOF";
** Could not create the specified CAM build directory: $cam_bld
EOF
}
if ($print>=2) { print "CAM build directory: $cam_bld$eol"; }
#-----------------------------------------------------------------------------------------------
# CAM install directory.
my $cam_exedir;
if (defined $opts{'cam_exedir'}) {
$cam_exedir = absolute_path($opts{'cam_exedir'});
}
else { # use default value
$cam_exedir = absolute_path($cfg_ref->get('cam_exedir'));
}
#-----------------------------------------------------------------------------------------------
# User source directories.
my $usr_src = '';
if (defined $opts{'usr_src'}) {
my @dirs = split ',', $opts{'usr_src'};
my @adirs;
while ( my $dir = shift @dirs ) {
if (-d "$dir") {
push @adirs, absolute_path($dir);
} else {
die "** User source directory does not exist: $dir\n";
}
}
$usr_src = join ',', @adirs;
$cfg_ref->set('usr_src', $usr_src);
}
if ($print>=2) { print "User source directories: $usr_src$eol"; }
#-----------------------------------------------------------------------------------------------
# configuration cache directory and file.
my $config_cache_dir;
my $config_cache_file;
if (defined $opts{'cachedir'}) {
$config_cache_dir = absolute_path($opts{'cachedir'});
}
else {
$config_cache_dir = $cfg_ref->get('cam_bld');
}
if (-d $config_cache_dir or mkdirp($config_cache_dir)) {
$config_cache_file = "$config_cache_dir/$opts{'cache'}";
} else {
die <<"EOF";
** Could not create the specified directory for configuration cache file: $config_cache_dir
EOF
}
if ($print>=2) { print "Configuration cache file: $config_cache_file$eol"; }
#-----------------------------------------------------------------------------------------------
# Platform properties ##########################################################################
#-----------------------------------------------------------------------------------------------
#-----------------------------------------------------------------------------------------------
# Determine target OS -- allow cross compilation only if target_os is specified on commandline.
my $target_os = $OSNAME;
if (defined $opts{'target_os'}) {
$target_os = $opts{'target_os'};
}
$cfg_ref->set('target_os', $target_os);
if ($print>=2) { print "Target OS: $target_os$eol"; }
#-----------------------------------------------------------------------------------------------
# SPMD
my $spmd_val = 0;
if (defined $opts{'spmd'}) {
$spmd_val = $opts{'spmd'};
}
$cfg_ref->set('spmd', $spmd_val);
my $spmd = $spmd_val ? 'ON': 'OFF';
if ($print>=2) { print "SPMD parallelism: $spmd$eol";}
#-----------------------------------------------------------------------------------------------
# SMP
my $smp_val = 0;
if (defined $opts{'smp'}) {
$smp_val = $opts{'smp'}
}
$cfg_ref->set('smp', $smp_val);
my $smp = $smp_val ? 'ON': 'OFF';
if ($print>=2) { print "SMP parallelism: $smp$eol";}
#-----------------------------------------------------------------------------------------------
# Determine which packages/component to include ###############################################
#-----------------------------------------------------------------------------------------------
# Coupling framework
if (defined $opts{'cpl'}) {
$cfg_ref->set('cpl', $opts{'cpl'});
}
my $cpl = $cfg_ref->get('cpl');
if ($print>=2) { print "Coupling framework: $cpl$eol"; }
#-----------------------------------------------------------------------------------------------
# Physics package
#
# The default physics package is cam6. Physics packages >=cam5 use chemistry packages
# that include modal aerosols, i.e., the -chem value matches /_mam/. If the chem_pkg
# name doesn't match /_mam/ then set the default physics package to cam4.
my $phys_pkg = 'cam6';
if (defined $opts{'chem'} and $opts{'chem'} !~ /_mam/) {
$phys_pkg = 'cam4';
}
elsif (defined $opts{'waccmx'}) {
$phys_pkg = 'cam4';
}
# user override
if (defined $opts{'phys'}) {
$phys_pkg = lc($opts{'phys'});
}
# Add to the config object.
$cfg_ref->set('phys', $phys_pkg);
if ($print>=2) { print "Physics package: $phys_pkg$eol"; }
# Set flag to indicate a simple physics option
my $simple_phys = 0;
if ($phys_pkg =~ m/^adiabatic$|^held_suarez$|^kessler$|^tj2016$|^grayrad$/) {
$simple_phys = 1;
}
#-----------------------------------------------------------------------------------------------
# Chemistry package
my $chem_pkg = 'trop_mam4';
# defaults based on physics package
if ($simple_phys or $phys_pkg =~ m/^cam[34]$/ or $phys_pkg eq 'spcam_sam1mom') {
$chem_pkg = 'none';
}
elsif ($phys_pkg eq 'cam5' or $phys_pkg eq 'spcam_m2005') {
$chem_pkg = 'trop_mam3';
}
# some overrides for special configurations
if (defined $opts{'prog_species'}) {
$chem_pkg = 'none';
}
elsif (defined $opts{'waccmx'}) {
$chem_pkg = 'waccm_ma';
}
# Allow the user to override the default chemistry via the commandline.
if (defined $opts{'chem'}) {
$chem_pkg = lc($opts{'chem'});
# But do some consistency checks...
# If the user has specified a simple physics package...
if ($simple_phys) {
if (($chem_pkg ne 'none') and ($chem_pkg ne 'terminator')) {
die "configure ERROR: -phys=$phys_pkg -chem=$chem_pkg\n".
" -chem can only be set to 'none' or 'terminator'.\n";
}
}
elsif ($phys_pkg =~ m/^cam3$|^cam4$|^spcam_sam1mom$/) {
# The modal aerosols are not valid with cam3 or cam4 physics
if ($chem_pkg =~ /_mam/) {
die "configure ERROR: -phys=$phys_pkg -chem=$chem_pkg\n".
" -chem cannot be set to a modal aerosol option.\n";
}
}
if (defined $opts{'prog_species'}) {
if ($chem_pkg !~ /none/) {
die "configure ERROR: -prog_species=$opts{'prog_species'} -chem=$chem_pkg\n".
" -chem must be set 'none' with the prog_species option.\n";
}
}
if (defined $opts{'waccmx'}) {
if ($chem_pkg !~ /waccm_ma/) {
die "configure ERROR: -waccmx=$opts{'waccmx'} -chem=$chem_pkg\n".
" -chem must be set 'waccm_ma*' with the waccmx option.\n";
}
}
}
# Add to the config object.
$cfg_ref->set('chem', $chem_pkg);
if ($print>=2) { print "Chemistry package: $chem_pkg$eol"; }
#-----------------------------------------------------------------------------------------------
# Dynamics package
$cfg_ref->set('dyn', 'fv');
if (defined $opts{'dyn'}) {
$cfg_ref->set('dyn', lc($opts{'dyn'}) );
}
my $dyn_pkg = $cfg_ref->get('dyn');
if ($dyn_pkg eq 'fv3' and $spmd eq 'OFF') {
die "configure: FATAL: the fv3 dycore requires at least 6 tasks SPMD must not be switched off.$eol";
}
if ($print>=2) { print "Dynamics package: $dyn_pkg$eol"; }
$cfg_ref->set('analytic_ic', (defined $opts{'analytic_ic'}) ? $opts{'analytic_ic'} : 0);
# offline driver
if (defined $opts{'offline_dyn'}) {
$cfg_ref->set('offline_dyn', $opts{'offline_dyn'});
}
my $offline_dyn = $cfg_ref->get('offline_dyn');
# offline driver only runs with FV dycore
if ( ($offline_dyn) and ($dyn_pkg ne 'fv') ) {
die <<"EOF";
** ERROR: Offline driver only applicable to the FV dycore.
EOF
}
#-----------------------------------------------------------------------------------------------
# Test tracer package
if (defined $opts{'nadv_tt'}) {
$cfg_ref->set('nadv_tt', $opts{'nadv_tt'});
}
my $ttrac_nadv = $cfg_ref->get('nadv_tt');
if ($print>=2) { print "Number of user requested test tracers: $ttrac_nadv$eol"; }
#-----------------------------------------------------------------------------------------------
# Radiatively active constituents.
if (defined $opts{'max_n_rad_cnst'}) {
$cfg_ref->set('max_n_rad_cnst', $opts{'max_n_rad_cnst'});
}
my $max_n_rad_cnst = $cfg_ref->get('max_n_rad_cnst');
if ($print>=2) { print "Maximum radiatively active tracers: $max_n_rad_cnst$eol"; }
#-----------------------------------------------------------------------------------------------
# model_top - not set by default
my $model_top = 'none';
$cfg_ref->set('model_top', $model_top);
# user override
if (defined $opts{'model_top'}) {
$cfg_ref->set('model_top', $opts{'model_top'});
}
if ($print>=2) { print "model_top: $model_top$eol"; }
#-----------------------------------------------------------------------------------------------
# waccm physics
my $waccm_phys = 0;
if ($chem_pkg =~ /waccm_/) {
$waccm_phys = 1;
}
$cfg_ref->set('waccm_phys', $waccm_phys);
# user override
if (defined $opts{'waccm_phys'}) {
$cfg_ref->set('waccm_phys', $opts{'waccm_phys'});
}
$waccm_phys = $cfg_ref->get('waccm_phys');
if ($print>=2) { print "WACCM physics: $waccm_phys$eol"; }
# WACCM physics only runs with FV, SE and FV3 dycores
if ( ($waccm_phys) and ($dyn_pkg eq 'eul') ) {
die <<"EOF";
** ERROR: WACCM physics does not run with the Eulerian spectral dycore.
EOF
}
# WACCM includes 4 age of air tracers by default
if ($chem_pkg =~ /waccm_ma/ or $chem_pkg =~ /waccm_tsmlt/) {
$cfg_ref->set('age_of_air_trcs', 1);
}
# Allow user to override WACCM default, or turn on the age of air tracers
# in non-WACCM runs.
if (defined $opts{'age_of_air_trcs'}) {
$cfg_ref->set('age_of_air_trcs', $opts{'age_of_air_trcs'});
}
my $age_of_air_trcs = $cfg_ref->get('age_of_air_trcs') ? "ON" : "OFF";
if ($print>=2) { print "Age of air tracer package: $age_of_air_trcs$eol"; }
# waccmx option
if (defined $opts{'waccmx'}) {
$cfg_ref->set('waccmx', $opts{'waccmx'});
if (defined $opts{'ionosphere'}) {
$cfg_ref->set('ionosphere', $opts{'ionosphere'});
}
}
my $waccmx = $cfg_ref->get('waccmx');
my $ionos = $cfg_ref->get('ionosphere');
#-----------------------------------------------------------------------------------------------
# Prognostic species package(s)
if (defined $opts{'prog_species'}) {
$cfg_ref->set('prog_species', $opts{'prog_species'});
if ($chem_pkg ne 'none'){
die "ERROR: chem and prog_species cannot be both specified.\n";
}
}
if (defined $opts{'edit_chem_mech'}) {
$cfg_ref->set('edit_chem_mech', $opts{'edit_chem_mech'});
}
if (defined $opts{'usr_mech_infile'}) {
$cfg_ref->set('usr_mech_infile', $opts{'usr_mech_infile'});
}
#-----------------------------------------------------------------------------------------------
# Prognostic aerosol/GHG package(s)
my $prog_species = $cfg_ref->get('prog_species');
if (($waccm_phys) and ($chem_pkg eq 'none') and !($prog_species)) {
die <<"EOF";
** ERROR: WACCM physics only runs with chemistry.
EOF
}
#-----------------------------------------------------------------------------------------------
# Biogeochemistry option
if (defined $opts{'co2_cycle'}) {
$cfg_ref->set('co2_cycle', $opts{'co2_cycle'});
}
my $co2_cycle = $cfg_ref->get('co2_cycle');
if ($co2_cycle and $print>=2) { print "co2_cycle option: ON$eol"; }
#-----------------------------------------------------------------------------------------------
# Superparameterization mode (SPCAM)
#
# These values all default to 1 unless specified by the user during configure
if ($phys_pkg eq 'spcam_sam1mom' or $phys_pkg eq 'spcam_m2005') {
if ($smp eq 'ON') {
die "ERROR: SPCAM may not be used with threading $eol";
}
if ($print>=2) {print "Configure CAM for SPCAM (superparameterization) mode: $phys_pkg.$eol"; }
if (defined $opts{'spcam_nx'}) {
$cfg_ref->set('spcam_nx', $opts{'spcam_nx'});
my $spcam_nx = $cfg_ref->get('spcam_nx');
if ($spcam_nx < 4) {
die "configure ERROR: spcam_nx must be greater than or equal to 4\n";
}
if ($print>=2) {print "spcam_nx= $spcam_nx $eol"; }
}
if (defined $opts{'spcam_ny'}) {
$cfg_ref->set('spcam_ny', $opts{'spcam_ny'});
my $spcam_ny = $cfg_ref->get('spcam_ny');
if ($print>=2) {print "spcam_ny= $spcam_ny $eol"; }
}
if (defined $opts{'spcam_dx'}) {
$cfg_ref->set('spcam_dx', $opts{'spcam_dx'});
my $spcam_dx = $cfg_ref->get('spcam_dx');
if ($print>=2) {print "spcam_nx= $spcam_dx $eol"; }
}
if (defined $opts{'spcam_dt'}) {
$cfg_ref->set('spcam_dt', $opts{'spcam_dt'});
my $spcam_dt = $cfg_ref->get('spcam_dt');
if ($print>=2) {print "spcam_nt= $spcam_dt $eol"; }
}
}
#-----------------------------------------------------------------------------------------------
# Micro-physics package
# Set default
my $microphys_pkg = 'none';
if ($phys_pkg =~ m/^cam[34]$/) {
$microphys_pkg = 'rk';
}
elsif ($phys_pkg eq 'cam5') {
$microphys_pkg = 'mg1';
}
elsif ($phys_pkg eq 'cam6') {
$microphys_pkg = 'mg2';
}
elsif ($phys_pkg eq 'cam_dev') {
$microphys_pkg = 'mg3';
}
elsif ($phys_pkg eq 'spcam_sam1mom') {
$microphys_pkg = 'spcam_sam1mom';
}
elsif ($phys_pkg eq 'spcam_m2005') {
$microphys_pkg = 'spcam_m2005';
}
# Allow the user to override the default via the commandline.
if (defined $opts{'microphys'}) {
$microphys_pkg = lc($opts{'microphys'});
}
if($microphys_pkg eq 'pumas') {
$microphys_pkg = 'mg3';
}
$cfg_ref->set('microphys', $microphys_pkg);
if ($print>=2) { print "Microphysics package: $microphys_pkg$eol"; }
#-----------------------------------------------------------------------------------------------
# CARMA sectional microphysics package
# The default for the current physics package is:
my $carma_pkg = 'none';
# Allow the user to override the default via the commandline.
if (defined $opts{'carma'}) {
$carma_pkg = lc($opts{'carma'});
}
if ($carma_pkg =~ m/cirrus/i) {
unless ($microphys_pkg =~ /^mg/) {
die <<"EOF";
** ERROR: microphysics package set to: $microphys_pkg
** The CARMA cirrus model only works with MG or PUMAS microphysics.
EOF
}
}
$cfg_ref->set('carma', $carma_pkg);
if ($print>=2) { print "CARMA microphysical model: $carma_pkg$eol"; }
#-----------------------------------------------------------------------------------------------
# CLUBB
my $clubb_sgs = 0;
if ($phys_pkg eq 'cam6' or $phys_pkg eq 'cam_dev') {
$clubb_sgs = 1;
}
# user override
if (defined $opts{'clubb_sgs'}) {
$clubb_sgs = $opts{'clubb_sgs'};
}
# consistency checks...
# CLUBB_SGS only works with mg microphysics
if ($clubb_sgs and not ($microphys_pkg =~ m/^mg/ )) {
die <<"EOF";
** ERROR: microphysics package set to: $microphys_pkg
** CLUBB_SGS only works with MG or PUMAS microphysics.
EOF
}
$cfg_ref->set('clubb_sgs', $clubb_sgs);
if ($print>=2) { print "clubb_sgs: $clubb_sgs$eol"; }
#-----------------------------------------------------------------------------------------------
# SILHS
my $silhs = 0;
# user override
if (defined $opts{'silhs'}) {
$silhs = $opts{'silhs'};
}
# SILHS only works with CLUBB_SGS
if ($silhs and not ($clubb_sgs )) {
die <<"EOF";
** ERROR: SILHS is turned on, but CLUBB_SGS is not
EOF
}
$cfg_ref->set('silhs', $silhs);
if ($print>=2) { print "silhs: $silhs$eol"; }
#-----------------------------------------------------------------------------------------------
# SPCAM version of CLUBB
if (defined $opts{'spcam_clubb_sgs'}) {
$cfg_ref->set('spcam_clubb_sgs', $opts{'spcam_clubb_sgs'});
}
my $spcam_clubb_sgs = $cfg_ref->get('spcam_clubb_sgs');
#-----------------------------------------------------------------------------------------------
# Break apart CLUBB options into separate fields
if (defined $opts{'clubb_opts'}) {
my @clubb_temp_opts = split /,/, $opts{'clubb_opts'};
foreach (@clubb_temp_opts) {
$cfg_ref->set("$_", '1');
}
}
my $clubb_do_adv = $cfg_ref->get('clubb_do_adv');
if ($print>=2) { print "clubb_do_adv: $clubb_do_adv$eol"; }
#-----------------------------------------------------------------------------------------------
# ZM convective organization
if (defined $opts{'zmconv_org'}) {
$cfg_ref->set('zmconv_org', $opts{'zmconv_org'});
}
my $zmconv_org = $cfg_ref->get('zmconv_org');
if ($print>=2) { print "zmconv_org: $zmconv_org$eol"; }
#-----------------------------------------------------------------------------------------------
# Macro-physics package
# Set default
my $macrophys_pkg = 'none';
if ($phys_pkg =~ /cam[34]/) {
$macrophys_pkg = 'rk';
}
elsif ($phys_pkg =~ /cam5/) {
$macrophys_pkg = 'park';
}
elsif ($phys_pkg =~ /cam6/ and $clubb_sgs) {
$macrophys_pkg = 'clubb_sgs';
}
elsif ($phys_pkg =~ /cam6/ and !$clubb_sgs) {
$macrophys_pkg = 'park';
}
elsif ($phys_pkg =~ /cam_dev/ and $clubb_sgs) {
$macrophys_pkg = 'clubb_sgs';
}
elsif ($phys_pkg eq 'spcam_sam1mom') {
$macrophys_pkg = 'spcam_sam1mom';
}
elsif ($phys_pkg eq 'spcam_m2005') {
$macrophys_pkg = 'spcam_m2005';
}
# user overrides
if ($clubb_sgs or $spcam_clubb_sgs) {
$macrophys_pkg = 'clubb_sgs';
}
if (defined $opts{'macrophys'}) {
$macrophys_pkg = lc($opts{'macrophys'});
}
$cfg_ref->set('macrophys', $macrophys_pkg);
if ($print>=2) { print "Macrophysics package: $macrophys_pkg$eol"; }
#-----------------------------------------------------------------------------------------------
# PBL package
# Set default:
my $pbl_pkg = 'none';
if ($phys_pkg =~ m/^cam[34]$/) {
$pbl_pkg = 'hb';
}
elsif ($phys_pkg =~ /cam5/) {
$pbl_pkg = 'uw';
}
elsif ($phys_pkg =~ /cam6/ and $clubb_sgs) {
$pbl_pkg = 'clubb_sgs';