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

Feature/mfmehari/krok obio #259

Merged
merged 9 commits into from
Aug 12, 2024
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased] - 2024-05-14

### Added

- Required attributes for the 2D GOCART export fields in AERO_DP bundle have been set in subroutine append_to_bundle in Chem_AeroGeneric.F90. These export fields are imported by OBIO via Surface GC, and the missing of the attributes was causing the writing of surface import checkpoint to fail. The issue has been explained in detail on https://github.com/GEOS-ESM/GOCART/issues/258

## [Unreleased] - 2023-07-24

### Fixed
Expand Down
55 changes: 37 additions & 18 deletions ESMF/Shared/Chem_AeroGeneric.F90
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
!BOP
!

! !MODULE: Chem_AeroGeneric - Utilitarian subroutines used by GOCART2G children.
!
! !MODULE: Chem_AeroGeneric - Utilitarian subroutines used by GOCART2G children.
!
!
! !INTERFACE:
!
Expand Down Expand Up @@ -48,7 +48,7 @@ module Chem_AeroGeneric
!====================================================================================
subroutine add_aero (state, label, label2, grid, typekind, ptr, rc)

! Description: Adds fields to aero state for aerosol optics calcualtions.
! Description: Adds fields to aero state for aerosol optics calcualtions.

implicit none

Expand Down Expand Up @@ -109,7 +109,7 @@ recursive subroutine determine_data_driven(COMP_NAME, data_driven, RC)

__Iam__('determine_data_driven')

! Begin...
! Begin...

! Is DU data driven?
! ------------------
Expand Down Expand Up @@ -142,7 +142,7 @@ subroutine append_to_bundle(varName, providerState, prefix, bundle, rc)
integer :: dimCount, i
real, pointer :: orig_ptr(:,:,:)
real, pointer :: ptr2d(:,:)
character(len=ESMF_MAXSTR) :: bin_index, varNameNew
character(len=ESMF_MAXSTR) :: bin_index, varNameNew, units, longname

! Description: Adds deposition variables to deposition bundle

Expand All @@ -155,27 +155,38 @@ subroutine append_to_bundle(varName, providerState, prefix, bundle, rc)
call ESMF_FieldGet (field, dimCount=dimCount, __RC__)

if (dimCount == 2) then ! this handles data instances
call MAPL_FieldBundleAdd (bundle, field, __RC__)
call MAPL_FieldBundleAdd (bundle, field, __RC__)

else if (dimCount == 3) then ! this handles computational instances
call ESMF_FieldGet (field, grid=grid, __RC__)
call MAPL_GetPointer (providerState, orig_ptr, trim(prefix)//trim(varName), __RC__)
call ESMF_AttributeGet(field, name='UNITS', value=units, __RC__)
call ESMF_AttributeGet(field, name='LONG_NAME', value=longname, __RC__)
longname=longname(1:index(trim(longname), '(Bin')-1)

if ((index(trim(varname), 'DU') > 0) .or. (index(trim(varname), 'SS') > 0)) then
do i = 1, size(orig_ptr, 3)
write (bin_index,'(A, I0.3)') '', i
ptr2d => orig_ptr(:,:,i)
field2D = ESMF_FieldCreate(grid=grid, datacopyflag=ESMF_DATACOPY_REFERENCE, farrayPtr=ptr2d,&
name=trim(varName)//trim(bin_index) , __RC__)
field2D = ESMF_FieldCreate(grid=grid, datacopyflag=ESMF_DATACOPY_REFERENCE, farray=ptr2d,&
name=trim(varName)//trim(bin_index) , indexflag=ESMF_INDEX_DELOCAL, __RC__)
call ESMF_AttributeSet(field2d, name='DIMS', value=MAPL_DimsHorzOnly, _RC)
call ESMF_AttributeSet(field2d, name='VLOCATION', value=MAPL_VLocationNone, _RC)
call ESMF_AttributeSet(field2d, name='UNITS', value=trim(units), _RC)
call ESMF_AttributeSet(field2d, name='LONG_NAME', value=trim(longname)//' Bin '//trim(bin_index), _RC)
call MAPL_AllocateCoupling (field2D, __RC__)
call MAPL_FieldBundleAdd (bundle, field2D, __RC__)
end do
end if

if (index(trim(varname), 'SU') > 0) then ! only use SO4, which is the 3rd index
ptr2d => orig_ptr(:,:,3)
field2D = ESMF_FieldCreate(grid=grid, datacopyflag=ESMF_DATACOPY_REFERENCE, farrayPtr=ptr2d,&
name=trim(varName)//'003' , __RC__)
field2D = ESMF_FieldCreate(grid=grid, datacopyflag=ESMF_DATACOPY_REFERENCE, farray=ptr2d,&
name=trim(varName)//'003' , indexflag=ESMF_INDEX_DELOCAL, __RC__)
call ESMF_AttributeSet(field2d, name='DIMS', value=MAPL_DimsHorzOnly, _RC)
call ESMF_AttributeSet(field2d, name='VLOCATION', value=MAPL_VLocationNone, _RC)
call ESMF_AttributeSet(field2d, name='UNITS', value=units, _RC)
call ESMF_AttributeSet(field2d, name='LONG_NAME', value=trim(longname)//' Bin 003', _RC)
call MAPL_AllocateCoupling (field2D, __RC__)
call MAPL_FieldBundleAdd (bundle, field2D, __RC__)
end if
Expand All @@ -185,8 +196,12 @@ subroutine append_to_bundle(varName, providerState, prefix, bundle, rc)
write (bin_index,'(A, I0.3)') '', i
ptr2d => orig_ptr(:,:,i)
varNameNew = 'OC'//varName(6:7)
field2D = ESMF_FieldCreate(grid=grid, datacopyflag=ESMF_DATACOPY_REFERENCE, farrayPtr=ptr2d,&
name=trim(varNameNew)//trim(bin_index) , __RC__)
field2D = ESMF_FieldCreate(grid=grid, datacopyflag=ESMF_DATACOPY_REFERENCE, farray=ptr2d,&
name=trim(varNameNew)//trim(bin_index) , indexflag=ESMF_INDEX_DELOCAL, __RC__)
call ESMF_AttributeSet(field2d, name='DIMS', value=MAPL_DimsHorzOnly, _RC)
call ESMF_AttributeSet(field2d, name='VLOCATION', value=MAPL_VLocationNone, _RC)
call ESMF_AttributeSet(field2d, name='UNITS', value=units, _RC)
call ESMF_AttributeSet(field2d, name='LONG_NAME', value=trim(longname)//' Bin '//trim(bin_index), _RC)
call MAPL_AllocateCoupling (field2D, __RC__)
call MAPL_FieldBundleAdd (bundle, field2D, __RC__)
end do
Expand All @@ -197,16 +212,20 @@ subroutine append_to_bundle(varName, providerState, prefix, bundle, rc)
write (bin_index,'(A, I0.3)') '', i
ptr2d => orig_ptr(:,:,i)
varNameNew = 'BC'//varName(6:7)
field2D = ESMF_FieldCreate(grid=grid, datacopyflag=ESMF_DATACOPY_REFERENCE, farrayPtr=ptr2d,&
name=trim(varNameNew)//trim(bin_index) , __RC__)
field2D = ESMF_FieldCreate(grid=grid, datacopyflag=ESMF_DATACOPY_REFERENCE, farray=ptr2d,&
name=trim(varNameNew)//trim(bin_index) , indexflag=ESMF_INDEX_DELOCAL, __RC__)
call ESMF_AttributeSet(field2d, name='DIMS', value=MAPL_DimsHorzOnly, _RC)
call ESMF_AttributeSet(field2d, name='VLOCATION', value=MAPL_VLocationNone, _RC)
call ESMF_AttributeSet(field2d, name='UNITS', value=units, _RC)
call ESMF_AttributeSet(field2d, name='LONG_NAME', value=trim(longname)//' Bin '//trim(bin_index), _RC)
call MAPL_AllocateCoupling (field2D, __RC__)
call MAPL_FieldBundleAdd (bundle, field2D, __RC__)
end do
end if

else if (dimCount > 3) then
if(mapl_am_i_root()) print*,'Chem_AeroGenric::append_to_bundle does not currently support fields greater than 3 dimensions'
VERIFY_(824)
VERIFY_(824)
end if

RETURN_(ESMF_SUCCESS)
Expand All @@ -232,7 +251,7 @@ subroutine setZeroKlid(km, klid, int_ptr)
!
! !REVISION HISTORY:
!
! 25Aug2020 E.Sherman - Written
! 25Aug2020 E.Sherman - Written
!
! !Local Variables
integer :: k
Expand Down Expand Up @@ -269,7 +288,7 @@ subroutine setZeroKlid4d (km, klid, int_ptr)
!
! !REVISION HISTORY:
!
! 25Aug2020 E.Sherman - Written
! 25Aug2020 E.Sherman - Written
!
! !Local Variables
integer :: k, n
Expand Down Expand Up @@ -312,7 +331,7 @@ subroutine findKlid (klid, plid, ple, rc)
!
! !REVISION HISTORY:
!
! 25Aug2020 E.Sherman - Written
! 25Aug2020 E.Sherman - Written
!
! !Local Variables
integer :: k, j, i
Expand Down
Loading