-
Notifications
You must be signed in to change notification settings - Fork 372
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
1
commit 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
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
Some comments aren't visible on the classic Files Changed page.
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,47 @@ | ||
| .SUFFIXES: .F .o | ||
|
|
||
| all: | ||
| ifeq ($(MUSICA),true) | ||
| echo "****** building MUSICA ******" | ||
| $(MAKE) core_mpas_musica core_chemistry | ||
| else | ||
| echo "****** not building MUSICA ******" | ||
| $(MAKE) core_chemistry | ||
| endif | ||
|
|
||
| dummy: | ||
| echo "****** compiling chemistry ******" | ||
|
|
||
| OBJS = \ | ||
| mpas_atm_chemistry.o | ||
|
|
||
| ifeq ($(MUSICA),true) | ||
| core_mpas_musica: | ||
| echo "****** building CORE MPAS MUSICA ******" | ||
| (cd musica; $(MAKE) all) | ||
| endif | ||
|
|
||
| core_chemistry: $(if $(filter true,$(MUSICA)),core_mpas_musica) | ||
| ($(MAKE) chem_interface) | ||
| ar -ru libchem.a $(OBJS) | ||
| ifeq ($(MUSICA),true) | ||
| ($(MAKE) -C ./musica mpas_musica_lib) | ||
| endif | ||
|
|
||
| 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) $(CPPINCLUDES) $< > $*.f90 | ||
| $(FC) $(FFLAGS) -c $*.f90 $(FCINCLUDES) -I./musica -I.. -I../../framework -I../../../external/esmf_time_f90 | ||
| else | ||
| $(FC) $(CPPFLAGS) $(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,126 @@ | ||
| ! 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 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, dimensions) | ||
|
|
||
| #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, mpas_pool_get_dimension | ||
|
|
||
| type (mpas_pool_type), intent(in) :: configs | ||
| type (mpas_pool_type), intent(in) :: dimensions | ||
|
|
||
| #ifdef MPAS_USE_MUSICA | ||
| integer :: error_code | ||
| character(len=:), allocatable :: error_message | ||
| integer :: nVertLevels | ||
| integer, pointer :: nVertLevels_ptr | ||
| ! MUSICA will get the MICM JSON config from a namelist | ||
| ! hardcode filepath for now | ||
| character(len=StrKIND) :: filepath = 'chapman.json' | ||
| #endif | ||
|
|
||
| call mpas_log_write('Initializing chemistry packages...') | ||
|
|
||
| #ifdef MPAS_USE_MUSICA | ||
| call mpas_pool_get_dimension(dimensions, 'nVertLevels', nVertLevels_ptr) | ||
| nVertLevels = nVertLevels_ptr | ||
|
|
||
| call musica_init(filepath, nVertLevels, error_code, error_message) | ||
|
|
||
| ! TODO check error_code and generate MPAS error log message | ||
| #endif | ||
|
|
||
| end subroutine chemistry_init | ||
|
|
||
|
|
||
| !------------------------------------------------------------------------ | ||
| ! routine 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 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,31 @@ | ||
| .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.
Uh oh!
There was an error while loading. Please reload this page.