Skip to content
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

initialization of cpl_scalars #478

Open
DeniseWorthen opened this issue Jul 8, 2024 · 0 comments
Open

initialization of cpl_scalars #478

DeniseWorthen opened this issue Jul 8, 2024 · 0 comments

Comments

@DeniseWorthen
Copy link
Collaborator

DeniseWorthen commented Jul 8, 2024

I've been debugging an issue in UFS where adding a new configuration setting (write_restart_at_endofrun) caused an intel debug test on only derecho to fail in med.F90, during the creation of the component dimemsions

CMEPS/mediator/med.F90

Lines 2117 to 2119 in 47fb4e6

!---------------------------------------
! Create component dimensions in mediator internal state
!---------------------------------------

The fact that the failure was triggered by adding an unrelated config variable led me to believe the cause was access of some different (garbage) memory location. I traced the failure to the initialization of the cpl_scalar fields in the MOM6 cap.

All the caps I am aware of which utilize CMEPS use the same SetScalarField routine, including CMEPS

call SetScalarField(field, flds_scalar_name, flds_scalar_num, rc=rc)

In MOM6, I was able to resolve the issue with

! num of scalar values
    field = ESMF_FieldCreate(name=trim(scalar_field_name), grid=grid, typekind=ESMF_TYPEKIND_R8, &
         ungriddedLBound=(/1/), ungriddedUBound=(/scalar_field_count/), gridToFieldMap=(/2/), rc=rc)
    if (ChkErr(rc,__LINE__,u_FILE_u)) return

    ! initialize fldptr to zero
    call ESMF_FieldGet(field, farrayPtr=fldptr2d, rc=rc)
    if (ChkErr(rc,__LINE__,u_FILE_u)) return
    fldptr2d(:,:) = 0.0

Should this change also be made in CMEPS (as well as all other caps utilizing cpl_scalars)? I don't think that ESMF automatically initializes a field when it is created (?).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant