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 #871

Merged
merged 18 commits into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from 14 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
88 changes: 15 additions & 73 deletions GEOS_GcmGridComp.F90
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ subroutine SetServices ( GC, RC )
endif

call MAPL_GetResource ( MAPL, DO_OBIO, Label="USE_OCEANOBIOGEOCHEM:",DEFAULT=0, _RC)
call MAPL_GetResource ( MAPL, DO_DATA_ATM4OCN, Label="USE_DATAATM:" , DEFAULT=0, _RC)
call MAPL_GetResource ( MAPL, DO_DATA_ATM4OCN, Label="USE_DATA_ATM4OCN:" , DEFAULT=0, _RC)
call MAPL_GetResource ( MAPL, DO_DATASEA, Label="USE_DATASEA:" , DEFAULT=1, _RC)
call MAPL_GetResource ( MAPL, seaIceT_extData, Label="SEAICE_THICKNESS_EXT_DATA:", DEFAULT=.FALSE., _RC ) ! .TRUE. or .FALSE.

Expand Down Expand Up @@ -593,10 +593,6 @@ subroutine SetServices ( GC, RC )
_RC)
endif

if (DO_OBIO/=0) then
call OBIO_TerminateImports(DO_DATA_ATM4OCN, RC)
end if

if (DO_CICE_THERMO == 1) then
call MAPL_TerminateImport ( GC, &
SHORT_NAME = (/ &
Expand All @@ -606,6 +602,10 @@ subroutine SetServices ( GC, RC )
_RC)
endif

if (DO_OBIO/=0) then
call OBIO_TerminateImports(DO_DATA_ATM4OCN, RC)
end if

! Allocate this instance of the internal state and put it in wrapper.
! -------------------------------------------------------------------

Expand Down Expand Up @@ -706,30 +706,17 @@ subroutine OBIO_TerminateImports(DO_DATA_ATM4OCN, RC)
RC=STATUS )
VERIFY_(STATUS)

call MAPL_TerminateImport( GC, &
SHORT_NAME = (/'CCOVM ', 'CDREM ', 'RLWPM ', 'CLDTCM', &
'RH ', 'OZ ', 'WV '/), &
CHILD = OGCM, &
RC=STATUS )
VERIFY_(STATUS)

call MAPL_TerminateImport ( GC, &
SHORT_NAME = (/'UU'/), &
CHILD = OGCM, &
RC=STATUS )
VERIFY_(STATUS)

do k=1, 33
write(unit = suffix, fmt = '(i2.2)') k
call MAPL_TerminateImport( GC, &
SHORT_NAME = [ character(len=(8)) :: &
'TAUA_'//suffix, &
'ASYMP_'//suffix, &
'SSALB_'//suffix ], &
CHILD = OGCM, &
RC=STATUS )
VERIFY_(STATUS)
enddo
call MAPL_TerminateImport ( GC, &
SHORT_NAME = (/'DRBAND', 'DFBAND'/), &
CHILD = OGCM, &
RC=STATUS )
VERIFY_(STATUS)

if(DO_DATA_ATM4OCN==0) then
call MAPL_TerminateImport ( GC, &
Expand All @@ -738,11 +725,6 @@ subroutine OBIO_TerminateImports(DO_DATA_ATM4OCN, RC)
RC=STATUS )
VERIFY_(STATUS)

call MAPL_TerminateImport ( GC, &
SHORT_NAME = (/'FSWBAND ', 'FSWBANDNA'/), &
CHILD = OGCM, &
RC=STATUS )
VERIFY_(STATUS)
end if

RETURN_(ESMF_SUCCESS)
Expand Down Expand Up @@ -1490,26 +1472,14 @@ subroutine AllocateExports_OBIO(DO_DATA_ATM4OCN, RC)
RC=STATUS )
VERIFY_(STATUS)

do k=1, 33
write(unit = suffix, fmt = '(i2.2)') k
call AllocateExports(GCM_INTERNAL_STATE%expSKIN, &
[ character(len=8) :: &
'TAUA_'//suffix, &
'ASYMP_'//suffix, &
'SSALB_'//suffix] , &
RC=STATUS)
VERIFY_(STATUS)
enddo

call AllocateExports_UGD( GCM_INTERNAL_STATE%expSKIN, &
(/'DUDP', 'DUWT', 'DUSD'/), &
RC=STATUS )
VERIFY_(STATUS)

call AllocateExports(GCM_INTERNAL_STATE%expSKIN, &
(/'CCOVM ', 'CDREM ', 'RLWPM ', 'CLDTCM', 'RH ', &
'OZ ', 'WV '/), &
RC=STATUS)
call AllocateExports_UGD( GCM_INTERNAL_STATE%expSKIN, &
(/'DRBAND', 'DFBAND'/), &
RC=STATUS )
VERIFY_(STATUS)

if(DO_DATA_ATM4OCN==0) then
Expand All @@ -1518,10 +1488,6 @@ subroutine AllocateExports_OBIO(DO_DATA_ATM4OCN, RC)
RC=STATUS )
VERIFY_(STATUS)

call AllocateExports_UGD( GCM_INTERNAL_STATE%expSKIN, &
(/'FSWBAND ', 'FSWBANDNA'/), &
RC=STATUS )
VERIFY_(STATUS)
endif

RETURN_(ESMF_SUCCESS)
Expand Down Expand Up @@ -2226,36 +2192,16 @@ subroutine OBIO_A2O(DO_DATA_ATM4OCN, RC)
call DO_A2O(GIM(OGCM),'CO2SC' ,expSKIN,'CO2SC' , RC=STATUS)
VERIFY_(STATUS)

do k=1, 33
write(unit = suffix, fmt = '(i2.2)') k
call DO_A2O(GIM(OGCM), 'TAUA_'//suffix, expSKIN, 'TAUA_'//suffix, RC=STATUS)
VERIFY_(STATUS)
call DO_A2O(GIM(OGCM), 'SSALB_'//suffix, expSKIN, 'SSALB_'//suffix, RC=STATUS)
VERIFY_(STATUS)
call DO_A2O(GIM(OGCM), 'ASYMP_'//suffix, expSKIN, 'ASYMP_'//suffix, RC=STATUS)
VERIFY_(STATUS)
enddo

call DO_A2O_UGD(GIM(OGCM), 'DUDP', expSKIN, 'DUDP', RC=STATUS)
VERIFY_(STATUS)
call DO_A2O_UGD(GIM(OGCM), 'DUWT', expSKIN, 'DUWT', RC=STATUS)
VERIFY_(STATUS)
call DO_A2O_UGD(GIM(OGCM), 'DUSD', expSKIN, 'DUSD', RC=STATUS)
VERIFY_(STATUS)

call DO_A2O(GIM(OGCM), 'CCOVM', expSKIN, 'CCOVM', RC=STATUS)
VERIFY_(STATUS)
call DO_A2O(GIM(OGCM), 'CDREM', expSKIN, 'CDREM', RC=STATUS)
VERIFY_(STATUS)
call DO_A2O(GIM(OGCM), 'RLWPM', expSKIN, 'RLWPM', RC=STATUS)
VERIFY_(STATUS)
call DO_A2O(GIM(OGCM), 'CLDTCM', expSKIN, 'CLDTCM', RC=STATUS)
call DO_A2O_UGD(GIM(OGCM), 'DRBAND', expSKIN, 'DRBAND', RC=STATUS)
VERIFY_(STATUS)
call DO_A2O(GIM(OGCM), 'RH', expSKIN, 'RH', RC=STATUS)
VERIFY_(STATUS)
call DO_A2O(GIM(OGCM), 'OZ', expSKIN, 'OZ', RC=STATUS)
VERIFY_(STATUS)
call DO_A2O(GIM(OGCM), 'WV', expSKIN, 'WV', RC=STATUS)
call DO_A2O_UGD(GIM(OGCM), 'DFBAND', expSKIN, 'DFBAND', RC=STATUS)
VERIFY_(STATUS)

if(DO_DATA_ATM4OCN==0) then
Expand All @@ -2268,10 +2214,6 @@ subroutine OBIO_A2O(DO_DATA_ATM4OCN, RC)
call DO_A2O_UGD(GIM(OGCM), 'OCWT', expSKIN, 'OCWT', RC=STATUS)
VERIFY_(STATUS)

call DO_A2O_UGD(GIM(OGCM), 'FSWBAND', expSKIN, 'FSWBAND', RC=STATUS)
VERIFY_(STATUS)
call DO_A2O_UGD(GIM(OGCM), 'FSWBANDNA', expSKIN, 'FSWBANDNA', RC=STATUS)
VERIFY_(STATUS)
endif

RETURN_(ESMF_SUCCESS)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1164,20 +1164,22 @@ subroutine SetServices ( GC, RC )
VERIFY_(STATUS)
ENDIF

IF (DO_OBIO /= 0) THEN
call MAPL_AddConnectivity ( GC, &
SHORT_NAME = (/'DROBIO', 'DFOBIO'/), &
SRC_ID = RAD, &
DST_ID = SURF, &
RC=STATUS )
VERIFY_(STATUS)
ENDIF

call MAPL_AddConnectivity ( GC, &
SHORT_NAME = (/'AERO_DP'/), &
SRC_ID = CHEM, &
DST_ID = SURF, &
RC=STATUS )
VERIFY_(STATUS)

call MAPL_AddConnectivity ( GC, &
SHORT_NAME = (/'FSWBAND ', 'FSWBANDNA'/), &
SRC_ID = RAD, &
DST_ID = SURF, &
RC=STATUS )
VERIFY_(STATUS)

! Imports for GWD
!----------------
call MAPL_AddConnectivity ( GC, &
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ module GEOS_SurfaceGridCompMod
integer, parameter :: NB_CHOU_UV = 5 ! Number of UV bands
integer, parameter :: NB_CHOU_NIR = 3 ! Number of near-IR bands
integer, parameter :: NB_CHOU = NB_CHOU_UV + NB_CHOU_NIR ! Total number of bands
integer, parameter :: NB_OBIO = 33 !total number of bands for OradBio
integer, parameter :: ATM_CO2_FOUR = 4
!

Expand Down Expand Up @@ -232,7 +233,7 @@ subroutine SetServices ( GC, RC )

! Are we running DataAtm?
!------------------------
call MAPL_GetResource ( MAPL, DO_DATA_ATM4OCN, Label="USE_DATAATM:" , DEFAULT=0, RC=STATUS)
call MAPL_GetResource ( MAPL, DO_DATA_ATM4OCN, Label="USE_DATA_ATM4OCN:" , DEFAULT=0, RC=STATUS)
mfmehari marked this conversation as resolved.
Show resolved Hide resolved
VERIFY_(STATUS)

! Create Surface Config
Expand Down Expand Up @@ -263,9 +264,9 @@ subroutine SetServices ( GC, RC )
call ESMF_ConfigDestroy(SCF, __RC__ )

if ((catchswim/=0) .or. (landicegoswim/=0) .or. (DO_OBIO/=0)) then
do_goswim=.true.
DO_GOSWIM=.true.
else
do_goswim=.false.
DO_GOSWIM=.false.
endif

! Set the Run entry point
Expand Down Expand Up @@ -3400,26 +3401,26 @@ subroutine OBIO_setServices(NB_CHOU, RC)
VLOCATION = MAPL_VLocationNone, &
RC=STATUS )
VERIFY_(STATUS)

call MAPL_AddImportSpec(GC, &
SHORT_NAME = 'FSWBAND', &
LONG_NAME = 'net_surface_downward_shortwave_flux_per_band_in_air', &
UNITS = 'W m-2', &
DIMS = MAPL_DimsHorzOnly, &
UNGRIDDED_DIMS = (/NB_CHOU/), &
VLOCATION = MAPL_VLocationNone, &
RC=STATUS )
VERIFY_(STATUS)

call MAPL_AddImportSpec(GC, &
SHORT_NAME = 'FSWBANDNA', &
LONG_NAME = 'net_surface_downward_shortwave_flux_per_band_in_air_assuming_no_aerosol', &
UNITS = 'W m-2', &
DIMS = MAPL_DimsHorzOnly, &
UNGRIDDED_DIMS = (/NB_CHOU/), &
VLOCATION = MAPL_VLocationNone, &
RC=STATUS )
VERIFY_(STATUS)
call MAPL_AddImportSpec(GC, &
SHORT_NAME = 'DROBIO', &
LONG_NAME = 'surface_downwelling_shortwave_beam_flux_per_OBIO_band', &
UNITS = 'W m-2', &
DIMS = MAPL_DimsHorzOnly, &
UNGRIDDED_DIMS = (/NB_OBIO/), &
VLOCATION = MAPL_VLocationNone, &
RC=STATUS )
VERIFY_(STATUS)

call MAPL_AddImportSpec(GC, &
SHORT_NAME = 'DFOBIO', &
LONG_NAME = 'surface_downwelling_shortwave_diffuse_flux_per_OBIO_band', &
UNITS = 'W m-2', &
DIMS = MAPL_DimsHorzOnly, &
UNGRIDDED_DIMS = (/NB_OBIO/), &
VLOCATION = MAPL_VLocationNone, &
RC=STATUS )
VERIFY_(STATUS)

RETURN_(ESMF_SUCCESS)
end subroutine OBIO_setServices
Expand Down Expand Up @@ -5772,13 +5773,13 @@ subroutine RUN2 ( GC, IMPORT, EXPORT, CLOCK, RC )
! following three active only when DO_OBIO==1 or ATM_CO2 == ATM_CO2_FOUR (=4)
! IMPORTS
real, pointer, dimension(:,:) :: CO2SC => NULL()
real, pointer, dimension(:,:,:) :: FSWBAND => NULL()
real, pointer, dimension(:,:,:) :: FSWBANDNA => NULL()
real, pointer, dimension(:,:,:) :: DRBAND => NULL()
real, pointer, dimension(:,:,:) :: DFBAND => NULL()

! tiled versio of IMPORTS
real, pointer, dimension(:) :: CO2SCTILE => NULL()
real, pointer, dimension(:,:) :: FSWBANDTILE => NULL()
real, pointer, dimension(:,:) :: FSWBANDNATILE => NULL()
real, pointer, dimension(:,:) :: DRBANDTILE => NULL()
real, pointer, dimension(:,:) :: DFBANDTILE => NULL()
!
real, pointer, dimension(:,:) :: DISCHARGE_IM => NULL()

Expand Down Expand Up @@ -8396,18 +8397,17 @@ subroutine RUN2 ( GC, IMPORT, EXPORT, CLOCK, RC )

! Fill imports/exports for OBIO
!-------------------------------
if((DO_OBIO/=0) .OR. (ATM_CO2 == ATM_CO2_FOUR)) then
call OBIO_fillExports(OCEAN, IMPORT,&
LOCSTREAM, GIM,&
surf_internal_state%xform_in(OCEAN), &
if((DO_OBIO/=0) .OR. (ATM_CO2 == ATM_CO2_FOUR)) then
call OBIO_fillExports(OCEAN, IMPORT,&
LOCSTREAM, GIM,&
surf_internal_state%xform_in(OCEAN), &
NT, NB_CHOU,&
CO2SC, FSWBAND, FSWBANDNA,&
CO2SCTILE, FSWBANDTILE, FSWBANDNATILE,&
RC)
CO2SC, DRBAND, DFBAND, &
CO2SCTILE, DRBANDTILE, DFBANDTILE, RC)
else
nullify( CO2SCTILE )
nullify( FSWBANDTILE )
nullify(FSWBANDNATILE )
nullify( DRBANDTILE )
nullify( DFBANDTILE )
endif

! Moved change of units for soil temperature export variables down to Catch[CN] Gridcomp.
Expand Down Expand Up @@ -8516,8 +8516,8 @@ subroutine RUN2 ( GC, IMPORT, EXPORT, CLOCK, RC )
if(associated( SSSVTILE )) deallocate( SSSVTILE )
if(associated( SSWTTILE )) deallocate( SSWTTILE )
if(associated( SSSDTILE )) deallocate( SSSDTILE )
if(associated( FSWBANDTILE)) deallocate( FSWBANDTILE)
if(associated(FSWBANDNATILE)) deallocate(FSWBANDNATILE)
if(associated( DRBANDTILE )) deallocate( DRBANDTILE )
if(associated( DFBANDTILE )) deallocate( DFBANDTILE )

if(associated( DTSDTTILE)) deallocate( DTSDTTILE)

Expand Down Expand Up @@ -10421,10 +10421,9 @@ end subroutine RouteRunoff
subroutine OBIO_fillExports(type, IMPORT, &
LOCSTREAM, GIM, &
XFORM, &
NT, NB_CHOU, &
CO2SC, FSWBAND, FSWBANDNA,&
CO2SCTILE, FSWBANDTILE, FSWBANDNATILE,&
RC)
NT, NB_CHOU, &
CO2SC, DRBAND, DFBAND, &
CO2SCTILE, DRBANDTILE, DFBANDTILE, RC)

integer, intent( IN ) :: TYPE
type(ESMF_State), intent(inout) :: IMPORT ! Import state
Expand All @@ -10437,8 +10436,8 @@ subroutine OBIO_fillExports(type, IMPORT, &
integer, optional, intent( OUT) :: RC

real, pointer :: CO2SCTILE(:), CO2SC(:,:),&
FSWBANDTILE(:,:), FSWBAND(:,:,:),&
FSWBANDNATILE(:,:), FSWBANDNA(:,:,:)
DRBANDTILE(:,:), DRBAND(:,:,:),&
DFBANDTILE(:,:), DFBAND(:,:,:)

character(len=ESMF_MAXSTR), parameter :: IAm="OBIO_fillExports"
integer :: STATUS
Expand All @@ -10450,28 +10449,28 @@ subroutine OBIO_fillExports(type, IMPORT, &
! type (MAPL_LocStreamXFORM) :: XFORM

call MAPL_GetPointer(IMPORT , CO2SC , 'CO2SC' , RC=STATUS); VERIFY_(STATUS)
call MAPL_GetPointer(IMPORT, FSWBAND , 'FSWBAND' , RC=STATUS); VERIFY_(STATUS)
call MAPL_GetPointer(IMPORT, FSWBANDNA , 'FSWBANDNA', RC=STATUS); VERIFY_(STATUS)
call MAPL_GetPointer(IMPORT, DRBAND , 'DROBIO' , RC=STATUS); VERIFY_(STATUS)
call MAPL_GetPointer(IMPORT, DFBAND , 'DFOBIO' , RC=STATUS); VERIFY_(STATUS)

allocate(CO2SCTILE(NT), STAT=STATUS)
VERIFY_(STATUS)
allocate(FSWBANDTILE( NT,NB_CHOU), STAT=STATUS)
allocate(DRBANDTILE( NT,NB_OBIO), STAT=STATUS)
VERIFY_(STATUS)
allocate(FSWBANDNATILE(NT,NB_CHOU), STAT=STATUS)
allocate(DFBANDTILE( NT,NB_OBIO), STAT=STATUS)
VERIFY_(STATUS)

call MAPL_LocStreamTransform(LOCSTREAM, CO2SCTILE, CO2SC, RC=STATUS); VERIFY_(STATUS)
do K = 1, NB_CHOU
call MAPL_LocStreamTransform(LOCSTREAM, FSWBANDTILE( :,K), FSWBAND( :,:,K), RC=STATUS)
VERIFY_(STATUS)
call MAPL_LocStreamTransform(LOCSTREAM, FSWBANDNATILE(:,K), FSWBANDNA(:,:,K), RC=STATUS)
VERIFY_(STATUS)
do K = 1, NB_OBIO
call MAPL_LocStreamTransform(LOCSTREAM, DRBANDTILE(:,K), DRBAND(:,:,K), RC=STATUS)
VERIFY_(STATUS)
call MAPL_LocStreamTransform(LOCSTREAM, DFBANDTILE(:,K), DFBAND(:,:,K), RC=STATUS)
VERIFY_(STATUS)
end do

! XFORM = surf_internal_state%xform_in(type)
call FILLIN_TILE(GIM(type), 'CO2SC', CO2SCTILE, XFORM, RC=STATUS); VERIFY_(STATUS)
call FILLIN_TILE(GIM(type), 'FSWBAND' , FSWBANDTILE , XFORM, RC=STATUS); VERIFY_(STATUS)
call FILLIN_TILE(GIM(type), 'FSWBANDNA', FSWBANDNATILE, XFORM, RC=STATUS); VERIFY_(STATUS)
call FILLIN_TILE(GIM(type), 'DRBAND', DRBANDTILE, XFORM, RC=STATUS); VERIFY_(STATUS)
call FILLIN_TILE(GIM(type), 'DFBAND', DFBANDTILE, XFORM, RC=STATUS); VERIFY_(STATUS)

RETURN_(ESMF_SUCCESS)
end subroutine OBIO_fillExports
Expand Down
Loading
Loading