Skip to content

Commit

Permalink
Merge pull request #259 from GEOS-ESM/feature/mfmehari/Krok_Obio
Browse files Browse the repository at this point in the history
Feature/mfmehari/krok obio
  • Loading branch information
jrjoshi1 authored Aug 12, 2024
2 parents bfdb1af + 7dd09f1 commit 3c84363
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 18 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ 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


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

0 comments on commit 3c84363

Please sign in to comment.