Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
135 commits
Select commit Hold shift + click to select a range
61e6a67
SVN MPAS branch merged to CAM in git
brian-eaton Oct 21, 2019
d4d1e0b
Provide simple dynamics export state to test d_p_coupling for CAM-MPAS
mgduda Nov 7, 2019
381ad71
Memory for the dynamics import and export state now comes from MPAS p…
mgduda Nov 9, 2019
8297307
Add MPAS-A 60, 30, 15, and 15-3 km meshes for CAM-MPAS
mgduda Dec 5, 2019
46b9fe7
Redefine CAM-MPAS dynamics import/export states to match dycore progn…
mgduda Dec 19, 2019
43c0ad9
fixes to grid object
brian-eaton Dec 19, 2019
77906da
merge fixes for grid object
brian-eaton Dec 26, 2019
af2c991
Read all time-invariant fields for MPAS-A in dyn_grid_init
mgduda Jan 7, 2020
a21eb5e
dyn_grid mods to use rdzw
brian-eaton Jan 10, 2020
884f8f9
Update halos for all time-invariant MPAS-A fields at init
mgduda Jan 11, 2020
b74fd60
Add 'zz' the MPAS-A dynamics import state
mgduda Jan 11, 2020
b9df05f
Add more time-invariant fields to MPAS-A dynamics state
mgduda Jan 14, 2020
37e8426
define edge grid object; output test data in uperp
brian-eaton Jan 14, 2020
103cca6
Merge branch 'dycore_static_fields' into mpas_cam6_2_001
mgduda Jan 15, 2020
42f311b
Update MPAS externals to the v6.1-cam.015 tag
mgduda Jan 16, 2020
024aa45
remove test code from dyn_comp
brian-eaton Jan 16, 2020
a3b17df
merge up to mpas038_cam6_2_001
brian-eaton Jan 16, 2020
89d1aa6
Convert MPAS indexing arrays from global to local index space
mgduda Jan 16, 2020
fa92b1a
Set up unit vectors needed for projecting cell-centered winds to edges
mgduda Jan 16, 2020
4fb7995
Add new routine cam_mpas_update_halo to cam_mpas_subdriver module
mgduda Jan 17, 2020
db6a935
Add new routine cam_mpas_cell_to_edge_winds to cam_mpas_subdriver
mgduda Jan 17, 2020
af29163
add grid object of edge nodes; compute zw
brian-eaton Jan 22, 2020
75c52f8
merge mgduda:cell_to_edge_winds
brian-eaton Jan 22, 2020
0f0d2e1
Implement computation of dry hydrostatic pressure for dycore export s…
mgduda Feb 19, 2020
a3d1ac3
merge mgduda:dry_hydrostatic_pressure
brian-eaton Feb 19, 2020
0d5aefc
init dyn_in using analytic IC code
brian-eaton Feb 22, 2020
3c381f3
dyn_comp cleanup
brian-eaton Feb 22, 2020
badff2b
init dyn_out from dyn_in
brian-eaton Feb 25, 2020
f57e1bd
mods from mgduda:fix_dycore_recompile
brian-eaton Feb 25, 2020
642b0e1
mods to dp_coupling
brian-eaton Feb 27, 2020
457e722
some cleanup in dp_coupling
brian-eaton Feb 28, 2020
9ab8162
Initialize base-state fields for MPAS-A dycore
mgduda Feb 28, 2020
0f0b3fd
Update halos for initial dynamics import fields
mgduda Feb 29, 2020
14e22c5
Add calls to cam_mpas_init_phase4, cam_mpas_run, and cam_mpas_finalize
mgduda Feb 28, 2020
e5e655c
mods to p_d_coupling
brian-eaton Mar 3, 2020
897c4d0
merge mgduda:base_state_and_dyn_run
brian-eaton Mar 9, 2020
a9d73f5
merge mpas_dev05
brian-eaton Mar 10, 2020
903cb4a
update ChangeLog
brian-eaton Mar 10, 2020
16d8e98
Fix segfault at line 376 of mpas_atm_core.F
mgduda Mar 11, 2020
384f48b
merge mgduda:config_do_DAcycling_segfault
brian-eaton Mar 12, 2020
937266c
Check that dycore time step evenly divides CAM time step
mgduda Mar 13, 2020
a9895f8
update mpas_dt defaults and ChangeLog
brian-eaton Mar 24, 2020
b29b206
Reconstruct cell-centered winds at the end of read_inidat
mgduda Apr 2, 2020
efebd5f
merge mgduda:reconstruct_initial_winds
brian-eaton Apr 7, 2020
e50401a
Update to MPAS-A v6.1-cam.016 tag
mgduda Apr 9, 2020
da36e21
Compute coupled physics tendencies for use by MPAS-A dycore
mgduda Apr 9, 2020
306a122
enable CAM to read MPAS initial file
brian-eaton Apr 10, 2020
09e7649
merge mgduda:physics_tendencies
brian-eaton Apr 13, 2020
4d841ac
updates to read MPAS initial file
brian-eaton Apr 13, 2020
b5c1e69
fix physics grid area attribute
brian-eaton Apr 13, 2020
8b314e1
add output for mpas prognostic state
brian-eaton Apr 14, 2020
c23279d
update pointers in dyn_in/dyn_out objects
brian-eaton Apr 16, 2020
e1975e4
Add routine cam_mpas_debug_stream to cam_mpas_subdriver module
mgduda Apr 17, 2020
73f0138
Read Coriolis parameter in cam_mpas_read_static
mgduda Apr 17, 2020
46e7484
merge mgduda:coriolis_fix
brian-eaton Apr 20, 2020
85c0626
Update cam_mpas_debug_stream to handle different time levels
mgduda Apr 21, 2020
6057d21
Update MPAS externals to v6.1-cam.017 to fix constant values
mgduda Apr 21, 2020
93587f4
merge mgduda:coriolis_fix; fix time levels; fix adiabatic physics tend
brian-eaton Apr 22, 2020
bbf4b39
fix time levels; fix rho
brian-eaton Apr 27, 2020
47ae57a
Add vorticity and divergence, compute diagnostics in cam_mpas_run
mgduda Apr 28, 2020
77c347d
add vorticity, divergence to output
brian-eaton Apr 29, 2020
b20c264
Compute temperature from theta and exner in d_p_coupling
mgduda May 4, 2020
70c2105
Use consistent values for constants in MPAS-A dycore
mgduda May 12, 2020
48e9eee
merge mgduda:t_calc
brian-eaton May 14, 2020
1f72362
merge mgduda:consistent_constants
brian-eaton May 15, 2020
97dbd51
Enable runtime allocation and assignment of scalar constituents
mgduda May 27, 2020
6060473
Print a table of the mapping between constituents in CAM and MPAS-A t…
mgduda Jun 4, 2020
48c80f3
Map between constituent indices in CAM physics and MPAS-A dycore
mgduda Jun 4, 2020
c0a780d
merge mgduda:runtime_constituents
brian-eaton Jun 12, 2020
5ee73ca
merge to cam6_2_036
brian-eaton Jul 17, 2020
3ecb343
start bc_wav_set_ic mods
brian-eaton Jul 23, 2020
80a9721
merge to cam6_2_037, add ChangeLog_MPAS
brian-eaton Jul 23, 2020
7797343
add ChangeLog_MPAS
brian-eaton Jul 24, 2020
164040e
remove MPAS entries from ChangeLog
brian-eaton Jul 24, 2020
74dd69a
read_inidat mods for reading tracers
brian-eaton Jul 25, 2020
999fa0c
fix tracer initialization
brian-eaton Jul 27, 2020
f9c494f
Merge branch 'mpas_cam6_2_036' into height_coord
brian-eaton Jul 27, 2020
5f91cb4
add height coord to analytic baroclinic wave ICs
brian-eaton Jul 28, 2020
96d0fe2
add height coord to analytic US std atm ICs
brian-eaton Jul 29, 2020
f5c71d1
cleanup in dyn_grid and dp_coupling
brian-eaton Aug 1, 2020
e58bdf7
update ChangeLog
brian-eaton Aug 10, 2020
9906db4
more interface cleanup
brian-eaton Aug 21, 2020
b240e6f
merge in cleanup mods
brian-eaton Aug 21, 2020
7bfe789
update to cam6_2_043
brian-eaton Aug 25, 2020
df86a5a
update ChangeLog_MPAS
brian-eaton Aug 25, 2020
24b39b1
merge mgduda:fix_base_state_rho
brian-eaton Aug 26, 2020
d3f4593
Progress towards restart capability for MPAS-A dycore
mgduda Aug 27, 2020
e4827d0
Update to the v6.1-cam.021 MPAS tag to fix restart attribute errors
mgduda Sep 1, 2020
88bb301
Obtain bit-identical restarts - skip time level shift on first restar…
mgduda Sep 1, 2020
7192ae4
merge mgduda:restart_capability
brian-eaton Sep 3, 2020
b1c6fe7
Makefile mods for GCC-10.2
brian-eaton Sep 18, 2020
eaa4839
start mods to read phis from topo file
brian-eaton Sep 21, 2020
5bc1d86
more mods to read phis from topo file
brian-eaton Sep 22, 2020
3f2badb
update ChangeLog_MPAS
brian-eaton Sep 23, 2020
5fbb97a
update to cam6_3_000
brian-eaton Sep 23, 2020
ceda9f0
refactor mpas use of inic_analytic module
brian-eaton Oct 7, 2020
a5cf054
mpas branch tracking ESCOMP:cam_development
brian-eaton Oct 7, 2020
afaa7c1
Merge remote-tracking branch 'origin/mpas_anic' into mpas_simple
brian-eaton Oct 7, 2020
2fee009
ChangeLog updates
brian-eaton Oct 7, 2020
98b71b5
cleanup and ChangeLog updates
brian-eaton Oct 9, 2020
0623dc9
update to cam6_3_002
brian-eaton Oct 9, 2020
cb95c09
move functions to string_utils; update ChangeLog
brian-eaton Oct 15, 2020
453010b
fix missing constant types, typos, misc
brian-eaton Oct 16, 2020
6506bdc
changes to namelist defs, defaults, build-namelist, read code
brian-eaton Oct 20, 2020
70ca712
more namelist read refactoring
brian-eaton Oct 20, 2020
b6d71e1
address more review comments
brian-eaton Oct 22, 2020
c72abe3
Update MPAS-A dycore external to pull from MPAS-Dev/MPAS-Model
mgduda Oct 23, 2020
f0a5733
address more review comments
brian-eaton Oct 23, 2020
817e1d4
Merge remote-tracking branch 'mgduda/mpas-dev_external' into mpas_simple
brian-eaton Oct 23, 2020
1aeb92e
remove 4 namelist variables; address more review comments
brian-eaton Oct 24, 2020
3c8f4f5
address more review comments
brian-eaton Oct 27, 2020
ceb4517
Remove unused MPAS_USE_STREAMS code from cam_mpas_subdriver.F90
mgduda Oct 27, 2020
730a25a
Use 'implicit none' at the module level in cam_mpas_subdriver.F90
mgduda Oct 27, 2020
e6d0b9d
Add README in src/dynamics/mpas/driver
mgduda Oct 27, 2020
17f55f6
Handle errors in cam_mpas_update_halo with calls to endrun
mgduda Oct 28, 2020
4478306
Simplify loop for assigning passive scalars in cam_mpas_define_scalars
mgduda Oct 28, 2020
416e3f2
Use subroutine name string parameter in error messages in cam_mpas_de…
mgduda Oct 28, 2020
9c961cc
Check that (size(cnst_name) == num_scalars) in cam_mpas_define_scalars
mgduda Oct 28, 2020
2e29b0d
update default datasets
brian-eaton Oct 28, 2020
ce0b743
Merge remote-tracking branch 'mgduda/cam_mpas_subdriver_cleanup' into…
brian-eaton Oct 28, 2020
88c28e0
refactor cell area normalization
brian-eaton Oct 29, 2020
f0e1f6b
check for real kind consistency; misc cleanup
brian-eaton Oct 29, 2020
fd8ddc2
add 2 aux_cam tests
brian-eaton Oct 30, 2020
32f5075
back out changes to cam_map_utils.F90
brian-eaton Nov 2, 2020
74ae350
Make several changes requested by reviewers of CAM PR #246
mgduda Nov 4, 2020
485e3f9
Convert cam_mpas_define_scalars from a function to a subroutine
mgduda Nov 4, 2020
204ada9
restore changes to cam_map_utils.F90
brian-eaton Nov 6, 2020
a0ef1b6
Update the MPAS external to d059bdf, which supports building with NAG…
mgduda Nov 6, 2020
82d14eb
Merge remote-tracking branch 'mgduda/subdriver_cleanup_pt2' into mpas…
brian-eaton Nov 6, 2020
e7c0a43
update to cam6_3_003; update to use ESMCI cime tag
brian-eaton Nov 9, 2020
4030b1b
fix for SE/CSLAM
brian-eaton Nov 10, 2020
1ec9e79
fix for FV3
brian-eaton Nov 14, 2020
096cdad
update to cime5.8.34
brian-eaton Nov 16, 2020
f047ed3
mods for final round of comments
brian-eaton Nov 18, 2020
6102db7
Update ChangeLog
brian-eaton Nov 19, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ src/physics/pumas
src/dynamics/fv3/atmos_cubed_sphere
libraries/FMS
src/atmos_phys
src/dynamics/mpas/dycore

# Ignore compiled python
buildnmlc
Expand Down
2 changes: 1 addition & 1 deletion Externals.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ local_path = components/cice
required = True

[cime]
tag = cime5.8.32
tag = cime5.8.34
protocol = git
repo_url = https://github.com/ESMCI/cime
local_path = cime
Expand Down
8 changes: 8 additions & 0 deletions Externals_CAM.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,14 @@ repo_url = https://github.com/ESCOMP/FV3_CESM.git
local_path = src/dynamics/fv3/atmos_cubed_sphere
required = True

[mpas]
local_path = src/dynamics/mpas/dycore
protocol = git
repo_url = https://github.com/MPAS-Dev/MPAS-Model.git
sparse = ../.mpas_sparse_checkout
hash = d059bdf
required = True

[externals_description]
schema_version = 1.0.0

82 changes: 81 additions & 1 deletion bld/build-namelist
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,7 @@ if ( ($chem ne 'none') or ( $prog_species ) ){
if ($chem) {
# drydep_srf_file is only needed for prognostic MAM when the grid is unstructured.
# structured grids can do interpolation on the fly.
if ($chem =~ /_mam/ and ($dyn =~ /se/ or $dyn =~ /fv3/)) {
if ($chem =~ /_mam/ and ($dyn =~ /se|fv3|mpas/)) {
add_default($nl, 'drydep_srf_file');
}
}
Expand Down Expand Up @@ -3637,6 +3637,78 @@ if ($dyn =~ /se/) {
}
}

# MPAS-Atmosphere dycore
# ======================

if ($dyn =~ /mpas/) {

####################################################
# namelist group: dyn_mpas #
####################################################

add_default($nl, 'mpas_time_integration');
add_default($nl, 'mpas_time_integration_order');
add_default($nl, 'mpas_dt');
add_default($nl, 'mpas_split_dynamics_transport');
add_default($nl, 'mpas_number_of_sub_steps');
add_default($nl, 'mpas_dynamics_split_steps');
add_default($nl, 'mpas_h_mom_eddy_visc2');
add_default($nl, 'mpas_h_mom_eddy_visc4');
add_default($nl, 'mpas_v_mom_eddy_visc2');
add_default($nl, 'mpas_h_theta_eddy_visc2');
add_default($nl, 'mpas_h_theta_eddy_visc4');
add_default($nl, 'mpas_v_theta_eddy_visc2');
add_default($nl, 'mpas_horiz_mixing');
add_default($nl, 'mpas_len_disp');
add_default($nl, 'mpas_visc4_2dsmag');
add_default($nl, 'mpas_del4u_div_factor');
add_default($nl, 'mpas_w_adv_order');
add_default($nl, 'mpas_theta_adv_order');
add_default($nl, 'mpas_scalar_adv_order');
add_default($nl, 'mpas_u_vadv_order');
add_default($nl, 'mpas_w_vadv_order');
add_default($nl, 'mpas_theta_vadv_order');
add_default($nl, 'mpas_scalar_vadv_order');
add_default($nl, 'mpas_scalar_advection');
add_default($nl, 'mpas_positive_definite');
add_default($nl, 'mpas_monotonic');
add_default($nl, 'mpas_coef_3rd_order');
add_default($nl, 'mpas_smagorinsky_coef');
add_default($nl, 'mpas_mix_full');
add_default($nl, 'mpas_epssm');
add_default($nl, 'mpas_smdiv');
add_default($nl, 'mpas_apvm_upwinding');
add_default($nl, 'mpas_h_ScaleWithMesh');
add_default($nl, 'mpas_zd');
add_default($nl, 'mpas_xnutr');
add_default($nl, 'mpas_do_restart');
add_default($nl, 'mpas_print_global_minmax_vel');
add_default($nl, 'mpas_print_detailed_minmax_vel');
add_default($nl, 'mpas_print_global_minmax_sca');

# mpas_block_decomp_file_prefix should only be set when more than one task is used.
# Otherwise the file is not used and should not be added to the input dataset file.
if ($opts{'ntasks'} > 1) {
add_default($nl, 'mpas_block_decomp_file_prefix');
}

# invoke MPAS utility to generate streams files
my $mpas_libdir = $cfg->get('mpas_libdir');

# Check that the executable file streams_gen is present. streams_gen is built
# at the same time as the MPAS library. This allows build-namelist
# to be called before the MPAS library is built (via CESM scripts).
if ( -x "$mpas_libdir/streams_gen") {

my $cmnd = "$mpas_libdir/streams_gen $mpas_libdir/Registry_processed.xml ".
"streams.atmosphere stream_list.atmosphere. listed ";

system($cmnd) == 0 or die
"$ProgName - ERROR: generating MPAS streams files via command:\n".
"$cmnd";
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't there be a warning or die if the executable is not found?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I'm understanding the comment, the purpose of the conditional checking for the streams_gen executable is to allow build-namelist to be called before that executable exists. If that's correct, then it wouldn't make sense to die if it's not found. I'm guessing this is related to how the cesm scripts do things like call build-namelist for namelist previews before things are built?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I did not realize that the executable was created during the build, perhaps a comment to that effect would help?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added more detail to comment.

}

# Defaults for history output
add_default($nl, 'history_amwg');
add_default($nl, 'history_vdiag');
Expand Down Expand Up @@ -4183,6 +4255,14 @@ sub check_input_files {

if ($input_pathname_type eq 'abs') {
if ($inputdata_rootdir) {

# Special cases:
# The file referenced by mpas_block_decomp_file_prefix needs to have the
# task count appended before being added to the inputdata file.
if ($var eq 'mpas_block_decomp_file_prefix') {
$pathname = "$pathname$opts{'ntasks'}";
}

print $fh "$var = $pathname\n";
}
else {
Expand Down
7 changes: 5 additions & 2 deletions bld/config_files/definition.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ Switch specifies whether CAM is being built by the CCSM sequential scripts. 0 =
<entry id="cpl" valid_values="mct,nuopc" value="mct" >
Coupling framework: mct or nuopc. Default: mct.
</entry>
<entry id="dyn" valid_values="eul,fv,fv3,se" value="">
Dynamics package: eul, fv, fv3, or se.
<entry id="dyn" valid_values="eul,fv,fv3,se,mpas" value="">
Dynamics package: eul, fv, fv3, se, or mpas.
</entry>
<entry id="waccm_phys" valid_values="0,1" value="0">
Switch to turn on waccm physics: 0 => no, 1 => yes.
Expand Down Expand Up @@ -292,6 +292,9 @@ Directory containing COSP library.
<entry id="fv3core_libdir" value="">
Directory containing FV3CORE library.
</entry>
<entry id="mpas_libdir" value="">
Directory containing MPAS library.
</entry>
<entry id="target_os" value="">
OS for which CAM is being built. The default value is the name contained
in Perl's $OSNAME variable. This parameter allows the user to override
Expand Down
76 changes: 70 additions & 6 deletions bld/configure
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ OPTIONS
-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]. Default: fv.
-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
Expand Down Expand Up @@ -175,6 +175,7 @@ OPTIONS
-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.
Expand Down Expand Up @@ -274,6 +275,7 @@ GetOptions(
"max_n_rad_cnst=s" => \$opts{'max_n_rad_cnst'},
"mct_libdir=s" => \$opts{'mct_libdir'},
"microphys=s" => \$opts{'microphys'},
"mpas_libdir=s" => \$opts{'mpas_libdir'},
"mpi_inc=s" => \$opts{'mpi_inc'},
"mpi_lib=s" => \$opts{'mpi_lib'},
"nadv=s" => \$opts{'nadv'},
Expand Down Expand Up @@ -694,9 +696,9 @@ 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 ne 'fv') and ($dyn_pkg ne 'se') and ($dyn_pkg ne 'fv3') ) {
if ( ($waccm_phys) and ($dyn_pkg eq 'eul') ) {
die <<"EOF";
** ERROR: WACCM physics only runs with FV, Spectral Element and FV3 as the dycore.
** ERROR: WACCM physics does not run with the Eulerian spectral dycore.
EOF
}

Expand Down Expand Up @@ -1211,6 +1213,9 @@ elsif ($dyn_pkg eq 'eul') {
elsif ($dyn_pkg eq 'se') {
$hgrid = 'ne16np4';
}
elsif ($dyn_pkg eq 'mpas') {
$hgrid = 'mpasa480';
}
$cfg_ref->set('hgrid', $hgrid);

# User override.
Expand Down Expand Up @@ -1979,6 +1984,37 @@ if ($dyn_pkg eq 'fv3') {
write_fv3_makefile("$cam_dir/src/dynamics/fv3/Makefile.in.fv3", "$fv3core_libdir/Makefile");
}

#-----------------------------------------------------------------------------------------------
# MPAS library.
if ($dyn_pkg eq 'mpas') {

# Set the directory used to build MPAS. Add location and library name
# to the user specified load flags.
my $mpas_libdir = '';
if (defined $opts{'mpas_libdir'}) {
$mpas_libdir = $opts{'mpas_libdir'};
} else
{
$mpas_libdir = "$cam_bld/mpas";
}

$cfg_ref->set('mpas_libdir', "$mpas_libdir");

my $ldflags = $cfg_ref->get('ldflags');
$ldflags .= " -L$mpas_libdir -lmpas ";
$cfg_ref->set('ldflags', $ldflags);

# create the build directory for mpas
my $bld_dir = $mpas_libdir;
unless (-d $bld_dir or mkdirp($bld_dir)) {
die "** Could not create the mpas build directory: $bld_dir\n";
}

# Create the MPAS Makefile from a template and copy it into the mpas bld directory
write_mpas_makefile("$cfgdir/../src/dynamics/mpas/Makefile", "$mpas_libdir/Makefile");
if ($print) { print "creating $mpas_libdir/Makefile\n"; }
}

#-----------------------------------------------------------------------------------------------
# Write configuration files ####################################################################
#-----------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -2259,6 +2295,34 @@ EOF
}


#-------------------------------------------------------------------------------

sub write_mpas_makefile
{

my ($file_in, $file_out) = @_;
my $fh_in = new IO::File;
my $fh_out = new IO::File;

$fh_out->open(">$file_out") or die "** can't open file: $file_out\n";

print $fh_out <<"EOF";

MPAS_SRC_ROOT := $cam_root/src/dynamics/mpas

EOF

# Copy the "template" makefile to the new makefile.
$fh_in->open("<$file_in") or die "** can't open file: $file_in\n";
while (<$fh_in>) {
print $fh_out $_;
}

$fh_out->close;
$fh_in->close;
}


#-------------------------------------------------------------------------------

sub write_config_h
Expand Down Expand Up @@ -2291,7 +2355,7 @@ sub set_horiz_grid

my ($hgrid_file, $cfg_ref) = @_;

# Get dycore/grid from the package's configuration
# Get dycore/grid from the configuration object
my $dyn_pkg = $cfg_ref->get('dyn');
my $hgrid = $cfg_ref->get('hgrid');

Expand Down Expand Up @@ -2321,9 +2385,9 @@ sub set_horiz_grid
$hgrid =~ m/C(\d+)/;
$cfg_ref->set('hgrid', $hgrid);
}
else {
elsif ($dyn_pkg =~ m/^eul$|^fv/) {

# For non-SE dycores the parameters are read from an input file,
# For EUL and FV dycores the parameters are read from an input file,
# and if no dycore/grid matches are found then issue error message.

my $xml = XML::Lite->new( $hgrid_file );
Expand Down
Loading