Skip to content

WACCMX-MAGE 2-way coupling - #1649

Open
fvitt wants to merge 2 commits into
ESCOMP:cam_developmentfrom
fvitt:waccmx_mage_cplng
Open

WACCMX-MAGE 2-way coupling#1649
fvitt wants to merge 2 commits into
ESCOMP:cam_developmentfrom
fvitt:waccmx_mage_cplng

Conversation

@fvitt

@fvitt fvitt commented Aug 17, 2026

Copy link
Copy Markdown
Collaborator

This enables 2-way coupling between WACCM-X and MAGE magnetosphere model.

Closes #1647

fvitt added 2 commits July 26, 2026 12:21
	modified:   bld/namelist_files/namelist_definition.xml
	modified:   src/ionosphere/waccmx/dpie_coupling.F90
	modified:   src/ionosphere/waccmx/edynamo.F90
	modified:   src/ionosphere/waccmx/ionosphere_interface.F90
	new file:   src/ionosphere/waccmx/mage_module.F90
@fvitt fvitt self-assigned this Aug 17, 2026
@fvitt fvitt added the BFB bit for bit tag label Aug 17, 2026
@cacraigucar
cacraigucar self-requested a review August 18, 2026 15:43

@cacraigucar cacraigucar left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I have not done a thorough review of mage_module.F90 as it feels like it is not ready for CAM. Should we be using ESMF instead of these MPI calls (with comments which do not instill confidence)?

A regression test for this needs to be added (or even better modify a WACCMX test to include testing it).

@@ -0,0 +1,556 @@
module mage_module
!
! Module used to exchange data back and forth with MAGE

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Is there a DOI or other reference which describes what MAGE is?


<entry id="ionos_epotential_mage" type="logical" category="waccmx"
group="ionosphere_nl" valid_values="">
For 2-way coupling WACCM-X with MAGE magnetosphere

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Is MAGE a welknown acronym, or should the namelist description give a little more information?

mage_inputs=.false.
if (present(amie_in)) amie_inputs=amie_in
if (present(ltr_in)) ltr_inputs= ltr_in
if (present(ltr_in)) mage_inputs= mage_in

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Should this be if (present(mage_in))?

write(iulog,"('After Calling getamie >>> iamie = ', i2)") iamie
end if
prescribed_period = iamie == 1
else if (mage_inputs) then

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This logic indicates that only one of amie_inputs or mage_inputs is used. Should there be a check during namelist setting to exit with an error if both are set to true?

Comment on lines +406 to +407
call addfld ('Early_AZIGM2', horiz_only, 'I', ' ','EDYN_ZIGM2' ,gridname='gmag_grid')
call addfld ('Early_AZIGM1', horiz_only, 'I', ' ','EDYN_ZIGM2' ,gridname='gmag_grid')

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Both of these have EDYN_ZIGM2. Is this correct?

Comment on lines +267 to +268
! This Bcast is causing a lot of issues. I don't know if this is needed or
! if it will cause problems for voltron and other models. The behavior here is odd.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Another comment which does not instill confidence in this module

Comment on lines +334 to +337
!if (avar2d(j,i,2) .ne. avar2d(j,i,2)) write(*,*) "AVAR2?? ",avar2d(j,i,2),j,i
!if (avar2d(j,i,3) .ne. avar2d(j,i,3)) write(*,*) "AVAR3?? ",avar2d(j,i,3),j,i
!if (avar2d(j,i,2) .lt. 0) write(*,*) "AVAR4?? ",avar2d(j,i,2),j,i
!if (avar2d(j,i,3) .lt. 0) write(*,*) "AVAR5?? ",avar2d(j,i,3),j,i

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Delete unused code

if (nmixinapex .ne. 0) then
call MPI_BCAST(avar2d, nmlat*nmlonp1*nmixinapex, MPI_DOUBLE_PRECISION, mixCplRank, CplComm, ierr)
if (ierr == MPI_ERROR) then
write(6,"('>>> Error from MPI_BCAST: ierr=',i4)") ierr

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

All writes should use iulog

! Prepare the export data
hidra_prep = .false.
nreq = 0
!if (mytid == 0) write(iulog,*) "W Starting Export Prep"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Delete all commened out code throughout this module

Comment on lines +25 to +34
integer, parameter :: &! For MPI-based coupling tag
myAppId = 67, &! waccmxID
voltId = 116, &! voltronID
gamId = 45, &! gameraID
rcmId = 34, &! rcmID
mageId = 26, &! mageID
hidraId = 40, &! hidraID
hidraNId = 54, &! hidraNID
hidraSId = 59, &! hidraSID
tiegcmId = 57 ! tiegcmID

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I am not a MPI expert, but this feels clunky (assigning IDs to set numbers)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

BFB bit for bit tag Must have CESM3

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants