-
Notifications
You must be signed in to change notification settings - Fork 368
Chemistry stub modules for MUSICA MICM #1360
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
dwfncar
wants to merge
8
commits into
MPAS-Dev:develop
Choose a base branch
from
NCAR:musica_micm_stubs
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
ac54204
Added subdirs core_atmosphere/chemistry and core_atmosphere/chemistry…
dwfncar 4bfc3f0
Hardcode MICM config filepath in init_chemistry. Call init_chemistry…
dwfncar 808ffb7
Added #ifdef MPAS_USE_MUSICA cpp checks.
dwfncar 3c88e75
Added call to finalize_chemistry.
dwfncar a67ad39
Added call to finalize_chemistry.
dwfncar 4601862
In mpas_atm_chemistry module, renamed init_chemistry to chemistry_ini…
dwfncar aac38fb
Moved #ifdef MPAS_USE_MUSICA from module mpas_atm_core to module mpas…
dwfncar 7cd3abc
Call chemistry_step in mpas_atm_core atm_do_timestep.
dwfncar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
.SUFFIXES: .F .o | ||
|
||
ifeq ($(CORE),atmosphere) | ||
COREDEF = -Dmpas | ||
endif | ||
|
||
all: | ||
./../tools/manage_externals/checkout_externals --externals ./../Externals.cfg | ||
$(MAKE) core_mpas_musica core_chemistry | ||
|
||
dummy: | ||
echo "****** compiling chemistry ******" | ||
|
||
OBJS = \ | ||
mpas_atm_chemistry.o | ||
|
||
core_mpas_musica: | ||
(cd musica; $(MAKE) all COREDEF="$(COREDEF)") | ||
|
||
core_chemistry: core_mpas_musica | ||
($(MAKE) chem_interface COREDEF="$(COREDEF)") | ||
ar -ru libchem.a $(OBJS) | ||
($(MAKE) -C ./musica mpas_musica_lib) | ||
|
||
chem_interface: $(OBJS) | ||
|
||
clean: | ||
$(RM) *.o *.mod *.f90 libchem.a | ||
( cd musica; $(MAKE) clean ) | ||
@# Certain systems with intel compilers generate *.i files | ||
@# This removes them during the clean process | ||
$(RM) *.i | ||
|
||
.F.o: | ||
$(RM) $@ $*.mod | ||
ifeq "$(GEN_F90)" "true" | ||
$(CPP) $(CPPFLAGS) $(COREDEF) $(HYDROSTATIC) $(CPPINCLUDES) $< > $*.f90 | ||
$(FC) $(FFLAGS) -c $*.f90 $(FCINCLUDES) -I./musica -I.. -I../../framework -I../../../external/esmf_time_f90 | ||
else | ||
$(FC) $(CPPFLAGS) $(COREDEF) $(HYDROSTATIC) $(FFLAGS) -c $*.F $(CPPINCLUDES) $(FCINCLUDES) -I./musica -I.. -I../../framework -I../../../external/esmf_time_f90 | ||
endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
! Copyright (c) 2025 The University Corporation for Atmospheric Research (UCAR). | ||
! | ||
! Unless noted otherwise source code is licensed under the BSD license. | ||
! Additional copyright and license information can be found in the LICENSE file | ||
! distributed with this code, or at https://mpas-dev.github.io/license.html . | ||
! | ||
!----------------------------------------------------------------------- | ||
! mpas_atm_chemistry | ||
! | ||
!> \brief Manages interactions with chemistry packages | ||
!> \author CheMPAS-A Developers | ||
!> \date 20 August 2025 | ||
!> \details | ||
!> This module manages the interactions with chemistry packages, | ||
!> including initialization, time-stepping, and finalization. | ||
!> It provides a framework for integrating various chemistry models | ||
!> into the CheMPAS-A system. | ||
! | ||
!------------------------------------------------------------------------- | ||
module mpas_atm_chemistry | ||
|
||
implicit none | ||
|
||
private | ||
|
||
public :: chemistry_init, chemistry_step, chemistry_finalize | ||
|
||
contains | ||
|
||
!------------------------------------------------------------------------ | ||
! routine mpas_atm_chemistry_init | ||
! | ||
!> \brief Initializes the chemistry packages | ||
!> \author CheMPAS-A Developers | ||
!> \date 20 August 2025 | ||
!> \details | ||
!> This routine initializes the chemistry packages, setting up | ||
!> necessary parameters and data structures for the simulation. | ||
!------------------------------------------------------------------------ | ||
! subroutine chemistry_init(configs, number_of_grid_cells) | ||
subroutine chemistry_init(number_of_grid_cells) | ||
|
||
#ifdef MPAS_USE_MUSICA | ||
use mpas_musica, only: musica_init | ||
#endif | ||
use mpas_log, only : mpas_log_write | ||
use mpas_derived_types, only: mpas_pool_type | ||
use mpas_kind_types, only: StrKIND | ||
use mpas_pool_routines, only: mpas_pool_get_config | ||
|
||
! type (mpas_pool_type), intent(in) :: configs | ||
integer, intent(in) :: number_of_grid_cells | ||
|
||
integer :: error_code | ||
character(len=:), allocatable :: error_message | ||
! character(len=StrKIND), pointer :: filepath | ||
character(len=StrKIND) :: filepath | ||
|
||
#ifdef MPAS_USE_MUSICA | ||
! call mpas_pool_get_config(configs, 'config_micm_file', filepath) | ||
filepath = 'chapman.json' | ||
|
||
call mpas_log_write('Initializing chemistry packages...') | ||
call musica_init(filepath, number_of_grid_cells, error_code, error_message) | ||
|
||
! TODO check error_code and generate MPAS error log message | ||
#endif | ||
|
||
end subroutine chemistry_init | ||
|
||
|
||
!------------------------------------------------------------------------ | ||
! routine mpas_atm_chemistry_step | ||
! | ||
!> \brief Steps the chemistry packages | ||
!> \author CheMPAS-A Developers | ||
!> \date 20 August 2025 | ||
!> \details | ||
!> This routine steps the chemistry packages, updating their state | ||
!> based on the current simulation time and conditions. | ||
!------------------------------------------------------------------------ | ||
subroutine chemistry_step() | ||
|
||
#ifdef MPAS_USE_MUSICA | ||
use mpas_musica, only: musica_step | ||
#endif | ||
use mpas_log, only : mpas_log_write | ||
|
||
#ifdef MPAS_USE_MUSICA | ||
call mpas_log_write('Stepping chemistry packages...') | ||
! call musica_step() | ||
#endif | ||
|
||
end subroutine chemistry_step | ||
|
||
|
||
!------------------------------------------------------------------------ | ||
! routine mpas_atm_chemistry_finalize | ||
! | ||
!> \brief Finalizes the chemistry packages | ||
!> \author CheMPAS-A Developers | ||
!> \date 20 August 2025 | ||
!> \details | ||
!> This routine finalizes the chemistry packages, cleaning up | ||
!> any resources and data structures used during the simulation. | ||
!------------------------------------------------------------------------ | ||
subroutine chemistry_finalize() | ||
|
||
#ifdef MPAS_USE_MUSICA | ||
use mpas_musica, only: musica_finalize | ||
#endif | ||
use mpas_log, only : mpas_log_write | ||
|
||
#ifdef MPAS_USE_MUSICA | ||
call mpas_log_write('Finalizing chemistry packages...') | ||
call musica_finalize() | ||
#endif | ||
|
||
end subroutine chemistry_finalize | ||
|
||
end module mpas_atm_chemistry |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
.SUFFIXES: .F .o | ||
|
||
.PHONY: mpas_musica mpas_musica_lib | ||
|
||
all: dummy mpas_musica | ||
|
||
dummy: | ||
echo "****** compiling mpas_musica ******" | ||
|
||
OBJS = \ | ||
mpas_musica.o | ||
|
||
mpas_musica: $(OBJS) | ||
|
||
mpas_musica_lib: | ||
ar -ru ./../libchem.a $(OBJS) | ||
|
||
clean: | ||
$(RM) *.f90 *.o *.mod | ||
@# Certain systems with intel compilers generate *.i files | ||
@# This removes them during the clean process | ||
$(RM) *.i | ||
|
||
.F.o: | ||
ifeq "$(GEN_F90)" "true" | ||
$(CPP) $(CPPFLAGS) $(COREDEF) $(CPPINCLUDES) $< > $*.f90 | ||
$(FC) $(FFLAGS) -c $*.f90 $(FCINCLUDES) -I.. -I../../../framework -I../../../external/esmf_time_f90 | ||
else | ||
$(FC) $(CPPFLAGS) $(COREDEF) $(FFLAGS) -c $*.F $(CPPINCLUDES) $(FCINCLUDES) -I.. -I../../../framework -I../../../external/esmf_time_f90 | ||
endif |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have you tested with w/o including MUSICA library in the build? I think we should exclude the
mpas_musica.F
file in the build when MUSICA is not linked.