#include "../ESMFVersionDefine.h" !----------------------------------------------------------------------- ! MODULE module_ATM_GRID_COMP ! !----------------------------------------------------------------------- !*** This module contains codes directly related to the ATM component. !----------------------------------------------------------------------- ! !*** The ATM component lies in the hierarchy seen here: ! ! Main program ! | ! | ! NEMS component ! | |________________________. ! | | ! EARTH component Ensemble Coupler component ! /|\ ! / | \ ! ATM/OCN/ICE components ! | | ! | | ! | | ! | (MOM5, HYCOM, etc.) ! | ! CORE component (GSM, NMM, FIM, GEN, etc.) ! !----------------------------------------------------------------------- ! 2011-05-11 Theurich & Yang - Modified for using the ESMF 5.2.0r_beta_snapshot_07. ! 2011-10/04 Yang - Modified for using the ESMF 5.2.0r library. ! 2013-07 Theurich - NUOPC option to be compliant with ESMF 6.2.0 reference. !----------------------------------------------------------------------- ! USE esmf_mod #ifdef WITH_NUOPC use NUOPC use NUOPC_Model, only: & model_routine_SS => routine_SetServices, & model_label_DataInitialize => label_DataInitialize, & model_label_Advance => label_Advance use module_CPLFIELDS #endif ! USE module_ATM_INTERNAL_STATE,ONLY: ATM_INTERNAL_STATE & ,WRAP_ATM_INTERNAL_STATE ! USE module_NMM_GRID_COMP,ONLY: NMM_REGISTER USE module_GFS_GRID_COMP,ONLY: GFS_REGISTER USE module_FIM_GRID_COMP,ONLY: FIM_REGISTER USE module_GEN_GRID_COMP,ONLY: GEN_REGISTER ! For the "Generic Core" gridded component. ! USE module_ERR_MSG,ONLY: ERR_MSG,MESSAGE_CHECK ! !----------------------------------------------------------------------- ! IMPLICIT NONE ! !----------------------------------------------------------------------- ! PRIVATE ! PUBLIC :: ATM_REGISTER ! !----------------------------------------------------------------------- ! TYPE(ATM_INTERNAL_STATE),POINTER,SAVE :: ATM_INT_STATE TYPE(WRAP_ATM_INTERNAL_STATE) ,SAVE :: WRAP ! TYPE(ESMF_Clock),SAVE :: CLOCK_ATM !<-- The Clock of the ATM component ! #ifdef WITH_NUOPC character(len=160) :: nuopcMsg #endif !----------------------------------------------------------------------- ! CONTAINS ! !----------------------------------------------------------------------- !####################################################################### !----------------------------------------------------------------------- ! SUBROUTINE ATM_REGISTER(ATM_GRID_COMP,RC_REG) ! !----------------------------------------------------------------------- !*** Register the Init, Run, and Finalize routines of !*** the ATM component. !----------------------------------------------------------------------- ! !------------------------ !*** Argument Variables !------------------------ ! TYPE(ESMF_GridComp) :: ATM_GRID_COMP !<-- The ATM component INTEGER ,INTENT(OUT) :: RC_REG !<-- Error return code ! !--------------------- !*** Local Variables !--------------------- ! INTEGER :: RC ! !----------------------------------------------------------------------- !*********************************************************************** !----------------------------------------------------------------------- #ifdef WITH_NUOPC ! the NUOPC model component will register the generic methods call NUOPC_CompDerive(ATM_GRID_COMP, model_routine_SS, rc=RC_REG) if (ESMF_LogFoundError(rcToCheck=RC_REG, msg=ESMF_LOGERR_PASSTHRU, & line=__LINE__, & file=__FILE__)) & return ! bail out ! Provide InitP0 to overwrite the default IPD00 with IPD02 call ESMF_GridCompSetEntryPoint(ATM_GRID_COMP, ESMF_METHOD_INITIALIZE, & InitializeP0, phase=0, rc=RC_REG) if (ESMF_LogFoundError(rcToCheck=RC_REG, msg=ESMF_LOGERR_PASSTHRU, & line=__LINE__, & file=__FILE__)) & return ! bail out ! IPDv02 requires InitP1, where Fields should be advertised CALL ESMF_GridCompSetEntryPoint(ATM_GRID_COMP, ESMF_METHOD_INITIALIZE, & InitializeP1, phase=1, rc=RC_REG) if (ESMF_LogFoundError(rcToCheck=RC_REG, msg=ESMF_LOGERR_PASSTHRU, & line=__LINE__, & file=__FILE__)) & return ! bail out ! IPDv02 requires InitP2, where Fields should be realized, CALL ESMF_GridCompSetEntryPoint(ATM_GRID_COMP, ESMF_METHOD_INITIALIZE, & InitializeP2, phase=2, rc=RC_REG) if (ESMF_LogFoundError(rcToCheck=RC_REG, msg=ESMF_LOGERR_PASSTHRU, & line=__LINE__, & file=__FILE__)) & return ! bail out ! attach specializing method(s) call NUOPC_CompSpecialize(ATM_GRID_COMP, & specLabel=model_label_DataInitialize, specRoutine=ATM_DATAINIT, & rc=RC_REG) if (ESMF_LogFoundError(rcToCheck=RC_REG, msg=ESMF_LOGERR_PASSTHRU, & line=__LINE__, & file=__FILE__)) & return ! bail out call NUOPC_CompSpecialize(ATM_GRID_COMP, & specLabel=model_label_Advance, specRoutine=ATM_ADVANCE, rc=RC_REG) if (ESMF_LogFoundError(rcToCheck=RC_REG, msg=ESMF_LOGERR_PASSTHRU, & line=__LINE__, & file=__FILE__)) & return ! bail out ! Overwrite generic NUOPC_Model Finalize method CALL ESMF_GridCompSetEntryPoint(ATM_GRID_COMP, ESMF_METHOD_FINALIZE, & ATM_FINALIZE, phase=1, rc=RC_REG) if (ESMF_LogFoundError(rcToCheck=RC_REG, msg=ESMF_LOGERR_PASSTHRU, & line=__LINE__, & file=__FILE__)) & return ! bail out #else ! ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ MESSAGE_CHECK="Set Entry Point for ATM Initialize" ! CALL ESMF_LogWrite(MESSAGE_CHECK,ESMF_LOGMSG_INFO,rc=RC) ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ! CALL ESMF_GridCompSetEntryPoint(ATM_GRID_COMP & !<-- The ATM component ,ESMF_METHOD_INITIALIZE & !<-- Subroutine type (Initialize) ,ATM_INITIALIZE & !<-- User's subroutine name ,phase=1 & ,rc=RC) ! ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ CALL ERR_MSG(RC,MESSAGE_CHECK,RC_REG) ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ! !----------------------------------------------------------------------- ! ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ MESSAGE_CHECK="Set Entry Point for ATM Run" ! CALL ESMF_LogWrite(MESSAGE_CHECK,ESMF_LOGMSG_INFO,rc=RC) ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ! CALL ESMF_GridCompSetEntryPoint(ATM_GRID_COMP & !<-- The ATM component ,ESMF_METHOD_RUN & !<-- Subroutine type (Run) ,ATM_RUN & !<-- User's subroutine name ,phase=1 & ,rc=RC) ! ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ CALL ERR_MSG(RC,MESSAGE_CHECK,RC_REG) ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ! !----------------------------------------------------------------------- ! ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ MESSAGE_CHECK="Set Entry Point for ATM Finalize" ! CALL ESMF_LogWrite(MESSAGE_CHECK,ESMF_LOGMSG_INFO,rc=RC) ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ! CALL ESMF_GridCompSetEntryPoint(ATM_GRID_COMP & !<-- The ATM component ,ESMF_METHOD_FINALIZE & !<-- Subroutine type (Finalize) ,ATM_FINALIZE & !<-- User's subroutine name ,phase=1 & ,rc=RC) ! ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ CALL ERR_MSG(RC,MESSAGE_CHECK,RC_REG) ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ! #endif !----------------------------------------------------------------------- ! IF(RC_REG==ESMF_SUCCESS)THEN ! WRITE(0,*)' ATM_REGISTER succeeded' ELSE WRITE(0,*)' ATM_REGISTER failed RC_REG=',RC_REG ENDIF ! !----------------------------------------------------------------------- ! END SUBROUTINE ATM_REGISTER ! !----------------------------------------------------------------------- !&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& !----------------------------------------------------------------------- ! #ifdef WITH_NUOPC subroutine InitializeP0(gcomp, importState, exportState, clock, rc) type(ESMF_GridComp) :: gcomp type(ESMF_State) :: importState, exportState type(ESMF_Clock) :: clock integer, intent(out) :: rc ! local variables character(len=NUOPC_PhaseMapStringLength) :: initPhases(4) rc = ESMF_SUCCESS initPhases(1) = "IPDv02p1=1" initPhases(2) = "IPDv02p3=2" initPhases(3) = "IPDv02p4=3" initPhases(4) = "IPDv02p5=5" call ESMF_AttributeSet(gcomp, & name="InitializePhaseMap", valueList=initPhases, & convention="NUOPC", purpose="General", rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & line=__LINE__, & file=__FILE__)) & return ! bail out end subroutine !----------------------------------------------------------------------- subroutine InitializeP1(gcomp, importState, exportState, clock, rc) type(ESMF_GridComp) :: gcomp type(ESMF_State) :: importState, exportState type(ESMF_Clock) :: clock integer, intent(out) :: rc rc = ESMF_SUCCESS ! advertise Fields ! importable field: sea_surface_temperature call NUOPC_StateAdvertiseField(importState, & StandardName="sea_surface_temperature", rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & line=__LINE__, & file=__FILE__)) & return ! bail out ! exportable fields: call NUOPC_StateAdvertiseFields(exportState, StandardNames=(/ & "mean_zonal_moment_flx ", & "mean_merid_moment_flx ", & "mean_sensi_heat_flx ", & "mean_laten_heat_flx ", & "mean_down_lw_flx ", & "mean_down_sw_flx ", & "mean_prec_rate ", & "inst_zonal_moment_flx ", & "inst_merid_moment_flx ", & "inst_sensi_heat_flx ", & "inst_laten_heat_flx ", & "inst_down_lw_flx ", & "inst_down_sw_flx ", & "inst_temp_height2m ", & "inst_spec_humid_height2m ", & "inst_u_wind_height10m ", & "inst_v_wind_height10m ", & "inst_temp_height_surface ", & "inst_pres_height_surface ", & "inst_surface_height ", & "mean_net_lw_flx ", & "mean_net_sw_flx ", & "inst_net_lw_flx ", & "inst_net_sw_flx ", & "mean_down_sw_ir_dir_flx ", & "mean_down_sw_ir_dif_flx ", & "mean_down_sw_vis_dir_flx ", & "mean_down_sw_vis_dif_flx ", & "inst_down_sw_ir_dir_flx ", & "inst_down_sw_ir_dif_flx ", & "inst_down_sw_vis_dir_flx ", & "inst_down_sw_vis_dif_flx ", & "mean_net_sw_ir_dir_flx ", & "mean_net_sw_ir_dif_flx ", & "mean_net_sw_vis_dir_flx ", & "mean_net_sw_vis_dif_flx ", & "inst_net_sw_ir_dir_flx ", & "inst_net_sw_ir_dif_flx ", & "inst_net_sw_vis_dir_flx ", & "inst_net_sw_vis_dif_flx ", & "inst_ir_dir_albedo ", & "inst_ir_dif_albedo ", & "inst_vis_dir_albedo ", & "inst_vis_dif_albedo " & /), rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & line=__LINE__, & file=__FILE__)) & return ! bail out end subroutine !----------------------------------------------------------------------- subroutine InitializeP2(gcomp, importState, exportState, clock, rc) type(ESMF_GridComp) :: gcomp type(ESMF_State) :: importState, exportState type(ESMF_Clock) :: clock integer, intent(out) :: rc type(ESMF_Grid) :: gridIn, gridOut character(160) :: itemNameList(1) type(ESMF_array) :: array rc = ESMF_SUCCESS ! call into the actual NEMS/ATM initialize routine call ATM_INITIALIZE(gcomp, importState, exportState, clock, rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & line=__LINE__, & file=__FILE__)) & return ! bail out ! use the regular Gaussian Grid that was setup during the NEMS/ATM init gridIn = gauss2d ! for imported Fields gridOut = gauss2d ! for exported Fields #if 1 if (atm_int_state%CORE == "gsm") then ! dump the GSM Grid coordinate arrays for reference call ESMF_GridGetCoord(gridIn, coordDim=1, array=array, rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & line=__LINE__, & file=__FILE__)) & return ! bail out call ESMF_ArrayWrite(array, file="array_gsm_grid_coord1.nc", rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & line=__LINE__, & file=__FILE__)) & call ESMF_Finalize(endflag=ESMF_END_ABORT) call ESMF_GridGetCoord(gridIn, coordDim=2, array=array, rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & line=__LINE__, & file=__FILE__)) & return ! bail out call ESMF_ArrayWrite(array, file="array_gsm_grid_coord2.nc", rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & line=__LINE__, & file=__FILE__)) & call ESMF_Finalize(endflag=ESMF_END_ABORT) endif #endif ! conditionally realize or remove Fields from States ... ! importable field: sea_surface_temperature if (NUOPC_StateIsFieldConnected(importState, fieldName="sst")) then ! realize a connected Field inst_sea_surf_temp = ESMF_FieldCreate(name="sst", grid=gridIn, & typekind=ESMF_TYPEKIND_R8, rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & line=__LINE__, & file=__FILE__)) & return ! bail out call NUOPC_StateRealizeField(importState, field=inst_sea_surf_temp, rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & line=__LINE__, & file=__FILE__)) & return ! bail out else ! remove a not connected Field from State call ESMF_StateRemove(importState, (/"sst"/), rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & line=__LINE__, & file=__FILE__)) & return ! bail out endif ! exportable field: mean_zonal_moment_flx call realizeConnectedInternCplField(exportState, & field=mean_zonal_moment_flx, standardName="mean_zonal_moment_flx", & grid=gridOut, rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & line=__LINE__, & file=__FILE__)) & return ! bail out ! exportable field: mean_merid_moment_flx call realizeConnectedInternCplField(exportState, & field=mean_merid_moment_flx, standardName="mean_merid_moment_flx", & grid=gridOut, rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & line=__LINE__, & file=__FILE__)) & return ! bail out ! exportable field: mean_sensi_heat_flx call realizeConnectedInternCplField(exportState, & field=mean_sensi_heat_flx, standardName="mean_sensi_heat_flx", & grid=gridOut, rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & line=__LINE__, & file=__FILE__)) & return ! bail out ! exportable field: mean_laten_heat_flx call realizeConnectedInternCplField(exportState, & field=mean_laten_heat_flx, standardName="mean_laten_heat_flx", & grid=gridOut, rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & line=__LINE__, & file=__FILE__)) & return ! bail out ! exportable field: mean_down_lw_flx call realizeConnectedInternCplField(exportState, & field=mean_down_lw_flx, standardName="mean_down_lw_flx", & grid=gridOut, rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & line=__LINE__, & file=__FILE__)) & return ! bail out ! exportable field: mean_down_sw_flx call realizeConnectedInternCplField(exportState, & field=mean_down_sw_flx, standardName="mean_down_sw_flx", & grid=gridOut, rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & line=__LINE__, & file=__FILE__)) & return ! bail out ! exportable field: mean_prec_rate call realizeConnectedInternCplField(exportState, & field=mean_prec_rate, standardName="mean_prec_rate", & grid=gridOut, rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & line=__LINE__, & file=__FILE__)) & return ! bail out ! exportable field: inst_zonal_moment_flx call realizeConnectedInternCplField(exportState, & field=inst_zonal_moment_flx, standardName="inst_zonal_moment_flx", & grid=gridOut, rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & line=__LINE__, & file=__FILE__)) & return ! bail out ! exportable field: inst_merid_moment_flx call realizeConnectedInternCplField(exportState, & field=inst_merid_moment_flx, standardName="inst_merid_moment_flx", & grid=gridOut, rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & line=__LINE__, & file=__FILE__)) & return ! bail out ! exportable field: inst_sensi_heat_flx call realizeConnectedInternCplField(exportState, & field=inst_sensi_heat_flx, standardName="inst_sensi_heat_flx", & grid=gridOut, rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & line=__LINE__, & file=__FILE__)) & return ! bail out ! exportable field: inst_laten_heat_flx call realizeConnectedInternCplField(exportState, & field=inst_laten_heat_flx, standardName="inst_laten_heat_flx", & grid=gridOut, rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & line=__LINE__, & file=__FILE__)) & return ! bail out ! exportable field: inst_down_lw_flx call realizeConnectedInternCplField(exportState, & field=inst_down_lw_flx, standardName="inst_down_lw_flx", & grid=gridOut, rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & line=__LINE__, & file=__FILE__)) & return ! bail out ! exportable field: inst_down_sw_flx call realizeConnectedInternCplField(exportState, & field=inst_down_sw_flx, standardName="inst_down_sw_flx", & grid=gridOut, rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & line=__LINE__, & file=__FILE__)) & return ! bail out ! exportable field: inst_temp_height2m call realizeConnectedInternCplField(exportState, & field=inst_temp_height2m, standardName="inst_temp_height2m", & grid=gridOut, rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & line=__LINE__, & file=__FILE__)) & return ! bail out ! exportable field: inst_spec_humid_height2m call realizeConnectedInternCplField(exportState, & field=inst_spec_humid_height2m, standardName="inst_spec_humid_height2m", & grid=gridOut, rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & line=__LINE__, & file=__FILE__)) & return ! bail out ! exportable field: inst_u_wind_height10m call realizeConnectedInternCplField(exportState, & field=inst_u_wind_height10m, standardName="inst_u_wind_height10m", & grid=gridOut, rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & line=__LINE__, & file=__FILE__)) & return ! bail out ! exportable field: inst_v_wind_height10m call realizeConnectedInternCplField(exportState, & field=inst_v_wind_height10m, standardName="inst_v_wind_height10m", & grid=gridOut, rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & line=__LINE__, & file=__FILE__)) & return ! bail out ! exportable field: inst_temp_height_surface call realizeConnectedInternCplField(exportState, & field=inst_temp_height_surface, standardName="inst_temp_height_surface", & grid=gridOut, rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & line=__LINE__, & file=__FILE__)) & return ! bail out ! exportable field: inst_pres_height_surface call realizeConnectedInternCplField(exportState, & field=inst_pres_height_surface, standardName="inst_pres_height_surface", & grid=gridOut, rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & line=__LINE__, & file=__FILE__)) & return ! bail out ! exportable field: inst_surface_height call realizeConnectedInternCplField(exportState, & field=inst_surface_height, standardName="inst_surface_height", & grid=gridOut, rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & line=__LINE__, & file=__FILE__)) & return ! bail out ! exportable field: mean_net_lw_flx call realizeConnectedInternCplField(exportState, & field=mean_net_lw_flx, standardName="mean_net_lw_flx", & grid=gridOut, rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & line=__LINE__, & file=__FILE__)) & return ! bail out ! exportable field: mean_net_sw_flx call realizeConnectedInternCplField(exportState, & field=mean_net_sw_flx, standardName="mean_net_sw_flx", & grid=gridOut, rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & line=__LINE__, & file=__FILE__)) & return ! bail out ! exportable field: inst_net_lw_flx call realizeConnectedInternCplField(exportState, & field=inst_net_lw_flx, standardName="inst_net_lw_flx", & grid=gridOut, rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & line=__LINE__, & file=__FILE__)) & return ! bail out ! exportable field: inst_net_sw_flx call realizeConnectedInternCplField(exportState, & field=inst_net_sw_flx, standardName="inst_net_sw_flx", & grid=gridOut, rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & line=__LINE__, & file=__FILE__)) & return ! bail out ! exportable field: mean_down_sw_ir_dir_flx call realizeConnectedInternCplField(exportState, & field=mean_down_sw_ir_dir_flx, standardName="mean_down_sw_ir_dir_flx", & grid=gridOut, rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & line=__LINE__, & file=__FILE__)) & return ! bail out ! exportable field: mean_down_sw_ir_dif_flx call realizeConnectedInternCplField(exportState, & field=mean_down_sw_ir_dif_flx, standardName="mean_down_sw_ir_dif_flx", & grid=gridOut, rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & line=__LINE__, & file=__FILE__)) & return ! bail out ! exportable field: mean_down_sw_vis_dir_flx call realizeConnectedInternCplField(exportState, & field=mean_down_sw_vis_dir_flx, standardName="mean_down_sw_vis_dir_flx", & grid=gridOut, rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & line=__LINE__, & file=__FILE__)) & return ! bail out ! exportable field: mean_down_sw_vis_dif_flx call realizeConnectedInternCplField(exportState, & field=mean_down_sw_vis_dif_flx, standardName="mean_down_sw_vis_dif_flx", & grid=gridOut, rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & line=__LINE__, & file=__FILE__)) & return ! bail out ! exportable field: inst_down_sw_ir_dir_flx call realizeConnectedInternCplField(exportState, & field=inst_down_sw_ir_dir_flx, standardName="inst_down_sw_ir_dir_flx", & grid=gridOut, rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & line=__LINE__, & file=__FILE__)) & return ! bail out ! exportable field: inst_down_sw_ir_dif_flx call realizeConnectedInternCplField(exportState, & field=inst_down_sw_ir_dif_flx, standardName="inst_down_sw_ir_dif_flx", & grid=gridOut, rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & line=__LINE__, & file=__FILE__)) & return ! bail out ! exportable field: inst_down_sw_vis_dir_flx call realizeConnectedInternCplField(exportState, & field=inst_down_sw_vis_dir_flx, standardName="inst_down_sw_vis_dir_flx", & grid=gridOut, rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & line=__LINE__, & file=__FILE__)) & return ! bail out ! exportable field: inst_down_sw_vis_dif_flx call realizeConnectedInternCplField(exportState, & field=inst_down_sw_vis_dif_flx, standardName="inst_down_sw_vis_dif_flx", & grid=gridOut, rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & line=__LINE__, & file=__FILE__)) & return ! bail out ! exportable field: mean_net_sw_ir_dir_flx call realizeConnectedInternCplField(exportState, & field=mean_net_sw_ir_dir_flx, standardName="mean_net_sw_ir_dir_flx", & grid=gridOut, rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & line=__LINE__, & file=__FILE__)) & return ! bail out ! exportable field: mean_net_sw_ir_dif_flx call realizeConnectedInternCplField(exportState, & field=mean_net_sw_ir_dif_flx, standardName="mean_net_sw_ir_dif_flx", & grid=gridOut, rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & line=__LINE__, & file=__FILE__)) & return ! bail out ! exportable field: mean_net_sw_vis_dir_flx call realizeConnectedInternCplField(exportState, & field=mean_net_sw_vis_dir_flx, standardName="mean_net_sw_vis_dir_flx", & grid=gridOut, rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & line=__LINE__, & file=__FILE__)) & return ! bail out ! exportable field: mean_net_sw_vis_dif_flx call realizeConnectedInternCplField(exportState, & field=mean_net_sw_vis_dif_flx, standardName="mean_net_sw_vis_dif_flx", & grid=gridOut, rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & line=__LINE__, & file=__FILE__)) & return ! bail out ! exportable field: inst_net_sw_ir_dir_flx call realizeConnectedInternCplField(exportState, & field=inst_net_sw_ir_dir_flx, standardName="inst_net_sw_ir_dir_flx", & grid=gridOut, rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & line=__LINE__, & file=__FILE__)) & return ! bail out ! exportable field: inst_net_sw_ir_dif_flx call realizeConnectedInternCplField(exportState, & field=inst_net_sw_ir_dif_flx, standardName="inst_net_sw_ir_dif_flx", & grid=gridOut, rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & line=__LINE__, & file=__FILE__)) & return ! bail out ! exportable field: inst_net_sw_vis_dir_flx call realizeConnectedInternCplField(exportState, & field=inst_net_sw_vis_dir_flx, standardName="inst_net_sw_vis_dir_flx", & grid=gridOut, rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & line=__LINE__, & file=__FILE__)) & return ! bail out ! exportable field: inst_net_sw_vis_dif_flx call realizeConnectedInternCplField(exportState, & field=inst_net_sw_vis_dif_flx, standardName="inst_net_sw_vis_dif_flx", & grid=gridOut, rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & line=__LINE__, & file=__FILE__)) & return ! bail out ! exportable field: inst_ir_dir_albedo call realizeConnectedInternCplField(exportState, & field=inst_ir_dir_albedo, standardName="inst_ir_dir_albedo", & grid=gridOut, rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & line=__LINE__, & file=__FILE__)) & return ! bail out ! exportable field: inst_ir_dif_albedo call realizeConnectedInternCplField(exportState, & field=inst_ir_dif_albedo, standardName="inst_ir_dif_albedo", & grid=gridOut, rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & line=__LINE__, & file=__FILE__)) & return ! bail out ! exportable field: inst_vis_dir_albedo call realizeConnectedInternCplField(exportState, & field=inst_vis_dir_albedo, standardName="inst_vis_dir_albedo", & grid=gridOut, rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & line=__LINE__, & file=__FILE__)) & return ! bail out ! exportable field: inst_vis_dif_albedo call realizeConnectedInternCplField(exportState, & field=inst_vis_dif_albedo, standardName="inst_vis_dif_albedo", & grid=gridOut, rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & line=__LINE__, & file=__FILE__)) & return ! bail out contains !- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - subroutine realizeConnectedInternCplField(state, field, standardName, grid, rc) type(ESMF_State) :: state type(ESMF_Field) :: field character(len=*) :: standardName type(ESMF_Grid) :: grid integer, intent(out), optional :: rc ! local variables character(len=80) :: fieldName if (present(rc)) rc = ESMF_SUCCESS ! determine shortName from field dictionary, to be used as fieldName call NUOPC_FieldDictionaryGetEntry(standardName, & defaultShortName=fieldName, rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & line=__LINE__, & file=__FILE__)) & return ! bail out if (NUOPC_StateIsFieldConnected(state, fieldName=fieldName)) then ! realize the connected Field pass back up for internal cpl fields field = ESMF_FieldCreate(grid, ESMF_TYPEKIND_R8, name=fieldName, rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & line=__LINE__, & file=__FILE__)) & return ! bail out call NUOPC_StateRealizeField(state, field=field, rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & line=__LINE__, & file=__FILE__)) & return ! bail out else ! remove a not connected Field from State call ESMF_StateRemove(state, (/fieldName/), rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & line=__LINE__, & file=__FILE__)) & return ! bail out endif end subroutine end subroutine !----------------------------------------------------------------------- !&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& !----------------------------------------------------------------------- ! #endif SUBROUTINE ATM_INITIALIZE(ATM_GRID_COMP & ,IMP_STATE & ,EXP_STATE & ,CLOCK_EARTH & ,RC_INIT) ! !----------------------------------------------------------------------- !*** The Initialize step of the ATM component. !----------------------------------------------------------------------- ! !------------------------ !*** Argument Variables !------------------------ ! TYPE(ESMF_GridComp) :: ATM_GRID_COMP !<-- The ATM component TYPE(ESMF_State) :: IMP_STATE !<-- The ATM import state TYPE(ESMF_State) :: EXP_STATE !<-- The ATM export state TYPE(ESMF_Clock) :: CLOCK_EARTH !<-- The Clock of the EARTH component INTEGER ,INTENT(OUT) :: RC_INIT !<-- Error return code ! !--------------------- !*** Local Variables !--------------------- ! INTEGER :: RC ! TYPE(ESMF_Config) :: CF #ifdef WITH_NUOPC real(ESMF_KIND_R8) :: medAtmCouplingIntervalSec type(ESMF_Clock) :: atmClock type(ESMF_TimeInterval) :: atmStep type(ESMF_Field) :: field character(160) :: itemNameList(10) #endif ! !----------------------------------------------------------------------- !*********************************************************************** !----------------------------------------------------------------------- ! RC_INIT = ESMF_SUCCESS ! !----------------------------------------------------------------------- #ifdef WITH_NUOPC call NUOPC_ClockPrintCurrTime(CLOCK_EARTH, & string="entering ATM_INITIALIZE with CLOCK_EARTH current: ", & unit=nuopcMsg) call ESMF_LogWrite(nuopcMsg, ESMF_LOGMSG_INFO) call NUOPC_ClockPrintStartTime(CLOCK_EARTH, & string="entering ATM_INITIALIZE with CLOCK_EARTH start: ", & unit=nuopcMsg) call ESMF_LogWrite(nuopcMsg, ESMF_LOGMSG_INFO) call NUOPC_ClockPrintStopTime(CLOCK_EARTH, & string="entering ATM_INITIALIZE with CLOCK_EARTH stop: ", & unit=nuopcMsg) call ESMF_LogWrite(nuopcMsg, ESMF_LOGMSG_INFO) #endif ! !----------------------------------------------------------------------- !*** Allocate the ATM component's internal state, point at it, !*** and attach it to the ATM component. !----------------------------------------------------------------------- ! ALLOCATE(ATM_INT_STATE,stat=RC) wrap%ATM_INT_STATE=>ATM_INT_STATE ! ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ MESSAGE_CHECK="Set the ATM Internal State" ! CALL ESMF_LogWrite(MESSAGE_CHECK,ESMF_LOGMSG_INFO,rc=RC) ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ! CALL ESMF_GridCompSetInternalState(ATM_GRID_COMP & ,WRAP & ,RC) ! ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ CALL ERR_MSG(RC,MESSAGE_CHECK,RC_INIT) ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ! !----------------------------------------------------------------------- !*** Create the configure object for the ATM configure file which !*** specifies the dynamic core. !----------------------------------------------------------------------- ! CF=ESMF_ConfigCreate(rc=RC) ! ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ MESSAGE_CHECK="Load the ATM configure file" ! CALL ESMF_LogWrite(MESSAGE_CHECK,ESMF_LOGMSG_INFO,rc=RC) ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ! #ifdef WITH_NUOPC CALL ESMF_ConfigLoadFile(config=CF ,filename='nems.configure' ,rc=RC) #else CALL ESMF_ConfigLoadFile(config=CF ,filename='atmos.configure' ,rc=RC) #endif ! ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ CALL ERR_MSG(RC,MESSAGE_CHECK,RC_INIT) ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ! !----------------------------------------------------------------------- !*** Attach the configure object to the ATM component. !----------------------------------------------------------------------- ! ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ MESSAGE_CHECK="Attach the configure file to the ATM component" ! CALL ESMF_LogWrite(MESSAGE_CHECK,ESMF_LOGMSG_INFO,rc=RC) ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ! CALL ESMF_GridCompSet(gridcomp=ATM_GRID_COMP & !<-- The ATM component ,config =CF & !<-- The associated configure object ,rc =RC) ! ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ CALL ERR_MSG(RC,MESSAGE_CHECK,RC_INIT) ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ! ! !----------------------------------------------------------------------- !*** For the moment, use a direct copy of the EARTH Clock within !*** the ATM component. !----------------------------------------------------------------------- ! #ifdef WITH_NUOPC ! Set ATM component clock as copy of EARTH clock. call NUOPC_GridCompSetClock(ATM_GRID_COMP, CLOCK_EARTH, rc=RC_INIT) ESMF_ERR_RETURN(RC_INIT,RC_INIT) ! Read in the ATM coupling interval call ESMF_ConfigGetAttribute(CF, medAtmCouplingIntervalSec, & label="med_atm_coupling_interval_sec:", default=-1.0_ESMF_KIND_R8, & rc=RC_INIT) ESMF_ERR_RETURN(RC_INIT,RC_INIT) if (medAtmCouplingIntervalSec>0._ESMF_KIND_R8) then ! The coupling time step was provided call ESMF_TimeIntervalSet(atmStep, s_r8=medAtmCouplingIntervalSec, & rc=RC_INIT) ESMF_ERR_RETURN(RC_INIT,RC_INIT) call ESMF_GridCompGet(ATM_GRID_COMP, clock=atmClock, rc=RC_INIT) ESMF_ERR_RETURN(RC_INIT,RC_INIT) call ESMF_ClockSet(atmClock, timestep=atmStep, rc=RC_INIT) ESMF_ERR_RETURN(RC_INIT,RC_INIT) endif !TODO: not sure the following is really needed for NUOPC mode atm_int_state%CLOCK_ATM = ESMF_ClockCreate(CLOCK_EARTH, rc=RC_INIT) ESMF_ERR_RETURN(RC_INIT,RC_INIT) #else atm_int_state%CLOCK_ATM=CLOCK_EARTH #endif !----------------------------------------------------------------------- !*** Extract the dynamic core name from the configure file. !----------------------------------------------------------------------- ! ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ MESSAGE_CHECK="Extract dynamic core from the ATM configure file" ! CALL ESMF_LogWrite(MESSAGE_CHECK,ESMF_LOGMSG_INFO,rc=RC) ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ! CALL ESMF_ConfigGetAttribute(config=CF & !<-- The ATM configure object ,value =atm_int_state%CORE & !<-- The dynamic core name #ifdef WITH_NUOPC ,label ='atm_model:' & !<-- The label in the configure file #else ,label ='core:' & !<-- The label in the configure file #endif ,rc =RC) ! ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ CALL ERR_MSG(RC,MESSAGE_CHECK,RC_INIT) ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ! !----------------------------------------------------------------------- !*** Create the ATM subcomponent and its associated import/export !*** states for the core name that was extracted. !----------------------------------------------------------------------- ! ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ MESSAGE_CHECK="Create the CORE component" ! CALL ESMF_LogWrite(MESSAGE_CHECK,ESMF_LOGMSG_INFO,rc=RC) ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ! atm_int_state%CORE_GRID_COMP=ESMF_GridCompCreate(name=TRIM(atm_int_state%CORE)//' component' & ,rc =RC) ! ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ CALL ERR_MSG(RC,MESSAGE_CHECK,RC_INIT) ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ! !----------------------------------------------------------------------- !*** Attach the configure object to the CORE component. !----------------------------------------------------------------------- ! ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ! MESSAGE_CHECK="Attach the configure file to the CORE component" ! CALL ESMF_LogWrite(MESSAGE_CHECK,ESMF_LOGMSG_INFO,rc=RC) ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ! ! CALL ESMF_GridCompSet(gridcomp=atm_int_state%CORE_GRID_COMP & !<-- The ATM component ! ,config =CF & !<-- The associated configure object ! ,rc =RC) ! ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ! CALL ERR_MSG(RC,MESSAGE_CHECK,RC_INIT) ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ! !----------------------------------------------------------------------- !*** Register the subcomponent's Init, Run, and Finalize subroutines. !----------------------------------------------------------------------- ! ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ MESSAGE_CHECK="Register the CORE component's Init, Run, and Finalize steps" ! CALL ESMF_LogWrite(MESSAGE_CHECK,ESMF_LOGMSG_INFO,rc=RC) ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ! SELECT CASE(atm_int_state%CORE) ! CASE('nmm') CALL ESMF_GridCompSetServices (atm_int_state%CORE_GRID_COMP & ,NMM_REGISTER & ,rc=RC) ! CASE('gfs') CALL ESMF_GridCompSetServices (atm_int_state%CORE_GRID_COMP & ,GFS_REGISTER & ,rc=RC) ! CASE('gsm') CALL ESMF_GridCompSetServices (atm_int_state%CORE_GRID_COMP & ,GFS_REGISTER & ,rc=RC) ! CASE('fim') CALL ESMF_GridCompSetServices (atm_int_state%CORE_GRID_COMP & ,FIM_REGISTER & ,rc=RC) CASE('gen') CALL ESMF_GridCompSetServices (atm_int_state%CORE_GRID_COMP & ,GEN_REGISTER & ,rc=RC) CASE DEFAULT write(0,*)' ATM_INITIALIZE requires unknown core: ',TRIM(atm_int_state%CORE) ! END SELECT ! ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ CALL ERR_MSG(RC,MESSAGE_CHECK,RC_INIT) ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ! !----------------------------------------------------------------------- !*** Create the Core component's import/export states. !----------------------------------------------------------------------- ! ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ MESSAGE_CHECK="Create the CORE import state" ! CALL ESMF_LogWrite(MESSAGE_CHECK,ESMF_LOGMSG_INFO,rc=RC) ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ! atm_int_state%CORE_IMP_STATE=ESMF_StateCreate(STATENAME = "CORE Import" & ,stateintent = ESMF_STATEINTENT_IMPORT & ,rc = RC) ! ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ CALL ERR_MSG(RC,MESSAGE_CHECK,RC_INIT) ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ! ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ MESSAGE_CHECK="Create the CORE export state" ! CALL ESMF_LogWrite(MESSAGE_CHECK,ESMF_LOGMSG_INFO,rc=RC) ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ! atm_int_state%CORE_EXP_STATE=ESMF_StateCreate(STATENAME = "CORE Export" & ,stateintent = ESMF_STATEINTENT_EXPORT & ,rc = RC) ! ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ CALL ERR_MSG(RC,MESSAGE_CHECK,RC_INIT) ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ! !----------------------------------------------------------------------- !*** Nest the import/export states of the CORE component into the !*** analgous states of the ATM component. !----------------------------------------------------------------------- ! ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ MESSAGE_CHECK= "Add the CORE states into the ATMOS states" ! CALL ESMF_LogWrite(MESSAGE_CHECK, ESMF_LOGMSG_INFO, rc = RC) ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ! #ifndef WITH_NUOPC ! - Cannot bring these items out through the ATM Import and Export States ! - under NUOPC, because NUOPC requires a minumum of Field metadata for ! - anything that is going in/out of a component (e.g. to timestamp). CALL ESMF_StateAdd(IMP_STATE,LISTWRAPPER(atm_int_state%CORE_IMP_STATE),rc = RC) CALL ESMF_StateAdd(EXP_STATE,LISTWRAPPER(atm_int_state%CORE_EXP_STATE),rc = RC) #endif ! ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ CALL ERR_MSG(RC,MESSAGE_CHECK,RC_INIT) ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ! !----------------------------------------------------------------------- !*** Initialize the CORE component. !----------------------------------------------------------------------- ! ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ MESSAGE_CHECK="Initialize the CORE component" ! CALL ESMF_LogWrite(MESSAGE_CHECK,ESMF_LOGMSG_INFO,rc=RC) ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ! CALL ESMF_GridCompInitialize(gridcomp =atm_int_state%CORE_GRID_COMP & ,importState=atm_int_state%CORE_IMP_STATE & ,exportState=atm_int_state%CORE_EXP_STATE & ,clock =atm_int_state%CLOCK_ATM & ,rc =RC) ! ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ CALL ERR_MSG(RC,MESSAGE_CHECK,RC_INIT) ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ! !----------------------------------------------------------------------- ! IF(RC_INIT==ESMF_SUCCESS)THEN ! WRITE(0,*)' ATM_INITIALIZE succeeded' ELSE WRITE(0,*)' ATM_INITIALIZE failed RC_INIT=',RC_INIT ENDIF ! !----------------------------------------------------------------------- ! #ifdef WITH_NUOPC call NUOPC_ClockPrintCurrTime(CLOCK_EARTH, & string="leaving ATM_INITIALIZE with CLOCK_EARTH current: ", & unit=nuopcMsg) call ESMF_LogWrite(nuopcMsg, ESMF_LOGMSG_INFO) call NUOPC_ClockPrintStartTime(CLOCK_EARTH, & string="leaving ATM_INITIALIZE with CLOCK_EARTH start: ", & unit=nuopcMsg) call ESMF_LogWrite(nuopcMsg, ESMF_LOGMSG_INFO) call NUOPC_ClockPrintStopTime(CLOCK_EARTH, & string="leaving ATM_INITIALIZE with CLOCK_EARTH stop: ", & unit=nuopcMsg) call ESMF_LogWrite(nuopcMsg, ESMF_LOGMSG_INFO) call NUOPC_ClockPrintCurrTime(atm_int_state%CLOCK_ATM, & string="leaving ATM_INITIALIZE with CLOCK_ATM current: ", & unit=nuopcMsg) call ESMF_LogWrite(nuopcMsg, ESMF_LOGMSG_INFO) call NUOPC_ClockPrintStartTime(atm_int_state%CLOCK_ATM, & string="leaving ATM_INITIALIZE with CLOCK_ATM start: ", & unit=nuopcMsg) call ESMF_LogWrite(nuopcMsg, ESMF_LOGMSG_INFO) call NUOPC_ClockPrintStopTime(atm_int_state%CLOCK_ATM, & string="leaving ATM_INITIALIZE with CLOCK_ATM stop: ", & unit=nuopcMsg) call ESMF_LogWrite(nuopcMsg, ESMF_LOGMSG_INFO) #endif ! !----------------------------------------------------------------------- ! END SUBROUTINE ATM_INITIALIZE ! !----------------------------------------------------------------------- !####################################################################### !----------------------------------------------------------------------- ! #ifdef WITH_NUOPC subroutine ATM_DATAINIT(gcomp, rc) type(ESMF_GridComp) :: gcomp integer, intent(out) :: rc ! local variables type(ESMF_State) :: exportState rc = ESMF_SUCCESS ! the ATM initializes export Fields that the MED initialize depends on ! query the Component for its exportState call ESMF_GridCompGet(gcomp, exportState=exportState, rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & line=__LINE__, & file=__FILE__)) & return ! bail out ! -> set Updated Field Attribute to "true", indicating to the IPDv02p5 ! generic code to set the timestamp for this Field call setFieldsUpdated(exportState, standardNameList=(/ & "mean_zonal_moment_flx ", & "mean_merid_moment_flx ", & "mean_sensi_heat_flx ", & "mean_laten_heat_flx ", & "mean_down_lw_flx ", & "mean_down_sw_flx ", & "mean_prec_rate ", & "inst_zonal_moment_flx ", & "inst_merid_moment_flx ", & "inst_sensi_heat_flx ", & "inst_laten_heat_flx ", & "inst_down_lw_flx ", & "inst_down_sw_flx ", & "inst_temp_height2m ", & "inst_spec_humid_height2m ", & "inst_u_wind_height10m ", & "inst_v_wind_height10m ", & "inst_temp_height_surface ", & "inst_pres_height_surface ", & "inst_surface_height ", & "mean_net_lw_flx ", & "mean_net_sw_flx ", & "inst_net_lw_flx ", & "inst_net_sw_flx ", & "mean_down_sw_ir_dir_flx ", & "mean_down_sw_ir_dif_flx ", & "mean_down_sw_vis_dir_flx ", & "mean_down_sw_vis_dif_flx ", & "inst_down_sw_ir_dir_flx ", & "inst_down_sw_ir_dif_flx ", & "inst_down_sw_vis_dir_flx ", & "inst_down_sw_vis_dif_flx ", & "mean_net_sw_ir_dir_flx ", & "mean_net_sw_ir_dif_flx ", & "mean_net_sw_vis_dir_flx ", & "mean_net_sw_vis_dif_flx ", & "inst_net_sw_ir_dir_flx ", & "inst_net_sw_ir_dif_flx ", & "inst_net_sw_vis_dir_flx ", & "inst_net_sw_vis_dif_flx ", & "inst_ir_dir_albedo ", & "inst_ir_dif_albedo ", & "inst_vis_dir_albedo ", & "inst_vis_dif_albedo " & /), rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & line=__LINE__, & file=__FILE__)) & return ! bail out ! -> set InitializeDataComplete Component Attribute to "true", indicating ! to the driver that this Component has fully initialized its data call ESMF_AttributeSet(gcomp, & name="InitializeDataComplete", value="true", & convention="NUOPC", purpose="General", rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & line=__LINE__, & file=__FILE__)) & return ! bail out contains !- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - subroutine setFieldsUpdated(state, standardNameList, rc) type(ESMF_State) :: state character(len=*) :: standardNameList(:) integer, intent(out), optional :: rc integer :: i character(len=80) :: fieldName type(ESMF_Field) :: field type(ESMF_StateItem_Flag) :: itemType if (present(rc)) rc = ESMF_SUCCESS do i=1, size(standardNameList) call NUOPC_FieldDictionaryGetEntry(standardNameList(i), & defaultShortName=fieldName, rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & line=__LINE__, & file=__FILE__)) & return ! bail out call ESMF_StateGet(state, itemName=fieldName, itemType=itemType, rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & line=__LINE__, & file=__FILE__)) & return ! bail out if (itemType /= ESMF_STATEITEM_NOTFOUND) then ! item exists -> set "Updated" call ESMF_StateGet(state, itemName=fieldName, field=field, rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & line=__LINE__, & file=__FILE__)) & return ! bail out call ESMF_AttributeSet(field, name="Updated", value="true", & convention="NUOPC", purpose="General", rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & line=__LINE__, & file=__FILE__)) & return ! bail out endif enddo end subroutine end subroutine #endif ! !----------------------------------------------------------------------- !####################################################################### !----------------------------------------------------------------------- ! #ifndef WITH_NUOPC SUBROUTINE ATM_RUN(ATM_GRID_COMP & ,IMP_STATE & ,EXP_STATE & ,CLOCK_EARTH & ,RC_RUN) ! !----------------------------------------------------------------------- !*** The Run step of the ATM component. !----------------------------------------------------------------------- ! !------------------------ !*** Argument Variables !------------------------ ! TYPE(ESMF_GridComp) :: ATM_GRID_COMP !<-- The ATM component TYPE(ESMF_State) :: IMP_STATE !<-- The ATM import state TYPE(ESMF_State) :: EXP_STATE !<-- The ATM export state TYPE(ESMF_Clock) :: CLOCK_EARTH !<-- The Clock of the EARTH component INTEGER ,INTENT(OUT) :: RC_RUN !<-- Error return code ! !--------------------- !*** Local Variables !--------------------- ! INTEGER :: RC ! TYPE(ESMF_Time) :: CURRTIME & ,STARTTIME ! TYPE(ESMF_TimeInterval) :: RUNDURATION ! !----------------------------------------------------------------------- !*********************************************************************** !----------------------------------------------------------------------- ! !----------------------------------------------------------------------- !*** For the moment, use a direct copy of the EARTH Clock within !*** the ATM component. !----------------------------------------------------------------------- ! atm_int_state%CLOCK_ATM=CLOCK_EARTH ! !----------------------------------------------------------------------- !*** Execute the Run step of the selected dynamic core. !----------------------------------------------------------------------- ! ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ MESSAGE_CHECK="Execute the Run step of the CORE component" ! CALL ESMF_LogWrite(MESSAGE_CHECK,ESMF_LOGMSG_INFO,rc=RC) ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ! CALL ESMF_GridCompRun(gridcomp =atm_int_state%CORE_GRID_COMP & ,importState=atm_int_state%CORE_IMP_STATE & ,exportState=atm_int_state%CORE_EXP_STATE & ,clock =atm_int_state%CLOCK_ATM & ,rc =RC) ! ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ CALL ERR_MSG(RC,MESSAGE_CHECK,RC_RUN) ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ! ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ! !----------------------------------------------------------------------- !*** Update the ATMOS clock. !----------------------------------------------------------------------- ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ MESSAGE_CHECK = "Update the current time of the ATMOS clock" ! CALL ESMF_LogWrite(MESSAGE_CHECK, ESMF_LOGMSG_INFO, rc = RC) ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ! CALL ESMF_ClockGet(clock =atm_int_state%CLOCK_ATM & ,startTime =STARTTIME & ,runDuration=RUNDURATION & ,rc =RC) ! CURRTIME=STARTTIME+RUNDURATION ! CALL ESMF_ClockSet(clock =atm_int_state%CLOCK_ATM & ,currTime=CURRTIME & ,rc =RC) ! ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ CALL ERR_MSG(RC,MESSAGE_CHECK,RC_RUN) ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ! !----------------------------------------------------------------------- ! IF(RC_RUN==ESMF_SUCCESS)THEN ! WRITE(0,*)' ATM_RUN succeeded' ELSE WRITE(0,*)' ATM_RUN failed RC_RUN=',RC_RUN ENDIF ! !----------------------------------------------------------------------- ! END SUBROUTINE ATM_RUN ! !----------------------------------------------------------------------- !####################################################################### !----------------------------------------------------------------------- ! #else SUBROUTINE ATM_ADVANCE(ATM_GRID_COMP, rc) ! !----------------------------------------------------------------------- !*** Advance the ATM component. !----------------------------------------------------------------------- ! !------------------------ !*** Argument Variables !------------------------ ! type(ESMF_GridComp) :: ATM_GRID_COMP integer, intent(out) :: rc ! !--------------------- !*** Local Variables !--------------------- ! type(ESMF_Clock) :: clock type(ESMF_Time) :: stopTime type(ESMF_State) :: importState, exportState type(ESMF_Field) :: field type(ESMF_StateItem_Flag) :: itemType !TODO: move the slice counter into an internal state to be instance safe integer, save :: slice=1 ! !----------------------------------------------------------------------- !*********************************************************************** !----------------------------------------------------------------------- ! rc = ESMF_SUCCESS ! !----------------------------------------------------------------------- !*** Use the internal Clock set by NUOPC layer for ATM but update stopTime !----------------------------------------------------------------------- ! Component internal Clock gets updated per NUOPC rules call ESMF_GridCompGet(ATM_GRID_COMP, clock=clock, rc=rc) ESMF_ERR_RETURN(rc,rc) ! The stopTime will be updated to be the next ATM-OCN coupling time call ESMF_ClockGet(clock, stopTime=stopTime, rc=rc) ESMF_ERR_RETURN(rc,rc) ! Set the ATM-OCN coupling time to be stopTime in Clock that ATM core uses call ESMF_ClockSet(atm_int_state%CLOCK_ATM, stopTime=stopTime, rc=rc) ESMF_ERR_RETURN(rc,rc) call NUOPC_ClockPrintCurrTime(atm_int_state%CLOCK_ATM, & string="entering ATM_ADVANCE with CLOCK_ATM current: ", & unit=nuopcMsg) call ESMF_LogWrite(nuopcMsg, ESMF_LOGMSG_INFO) call NUOPC_ClockPrintStartTime(atm_int_state%CLOCK_ATM, & string="entering ATM_ADVANCE with CLOCK_ATM start: ", & unit=nuopcMsg) call ESMF_LogWrite(nuopcMsg, ESMF_LOGMSG_INFO) call NUOPC_ClockPrintStopTime(atm_int_state%CLOCK_ATM, & string="entering ATM_ADVANCE with CLOCK_ATM stop: ", & unit=nuopcMsg) call ESMF_LogWrite(nuopcMsg, ESMF_LOGMSG_INFO) !----------------------------------------------------------------------- !*** Execute the Run step of the selected dynamic core. !----------------------------------------------------------------------- CALL ESMF_GridCompRun(gridcomp =atm_int_state%CORE_GRID_COMP & ,importState=atm_int_state%CORE_IMP_STATE & ,exportState=atm_int_state%CORE_EXP_STATE & ,clock =atm_int_state%CLOCK_ATM & ,rc =rc) ESMF_ERR_RETURN(rc,rc) !----------------------------------------------------------------------- ! query the Component for its importState and exportState call ESMF_GridCompGet(ATM_GRID_COMP, exportState=exportState, & importState=importState, rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & line=__LINE__, & file=__FILE__)) & return ! bail out #if 1 ! for testing write all of the Fields in the importState to file call NUOPC_StateWrite(importState, filePrefix="field_atm_import_", & timeslice=slice, relaxedFlag=.true., rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & line=__LINE__, & file=__FILE__)) & return ! bail out ! for testing write all of the Fields in the exportState to file call NUOPC_StateWrite(exportState, filePrefix="field_atm_export_", & timeslice=slice, relaxedFlag=.true., rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & line=__LINE__, & file=__FILE__)) & return ! bail out ! advance the time slice counter slice = slice + 1 #endif call NUOPC_ClockPrintCurrTime(atm_int_state%CLOCK_ATM, & string="leaving ATM_ADVANCE with CLOCK_ATM current: ", & unit=nuopcMsg) call ESMF_LogWrite(nuopcMsg, ESMF_LOGMSG_INFO) call NUOPC_ClockPrintStartTime(atm_int_state%CLOCK_ATM, & string="leaving ATM_ADVANCE with CLOCK_ATM start: ", & unit=nuopcMsg) call ESMF_LogWrite(nuopcMsg, ESMF_LOGMSG_INFO) call NUOPC_ClockPrintStopTime(atm_int_state%CLOCK_ATM, & string="leaving ATM_ADVANCE with CLOCK_ATM stop: ", & unit=nuopcMsg) call ESMF_LogWrite(nuopcMsg, ESMF_LOGMSG_INFO) !----------------------------------------------------------------------- END SUBROUTINE ATM_ADVANCE ! !----------------------------------------------------------------------- !####################################################################### !----------------------------------------------------------------------- ! #endif SUBROUTINE ATM_FINALIZE(ATM_GRID_COMP & ,IMP_STATE & ,EXP_STATE & ,CLOCK_EARTH & ,RC_FINALIZE) ! !----------------------------------------------------------------------- !*** Finalize the ATM component. !----------------------------------------------------------------------- ! !------------------------ !*** Argument Variables !------------------------ ! TYPE(ESMF_GridComp) :: ATM_GRID_COMP !<-- The ATM component TYPE(ESMF_State) :: IMP_STATE !<-- The ATM import state TYPE(ESMF_State) :: EXP_STATE !<-- The ATM import state TYPE(ESMF_Clock) :: CLOCK_EARTH !<-- The Clock of the EARTH component INTEGER ,INTENT(OUT) :: RC_FINALIZE !<-- Error return code ! !--------------------- !*** Local Variables !--------------------- ! INTEGER :: RC ! !----------------------------------------------------------------------- !*********************************************************************** !----------------------------------------------------------------------- ! ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ MESSAGE_CHECK="Execute the Finalize step of the CORE component" ! CALL ESMF_LogWrite(MESSAGE_CHECK,ESMF_LOGMSG_INFO,rc=RC) ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ! CALL ESMF_GridCompFinalize(gridcomp =atm_int_state%CORE_GRID_COMP & ,importState=atm_int_state%CORE_IMP_STATE & ,exportState=atm_int_state%CORE_EXP_STATE & ,clock =atm_int_state%CLOCK_ATM & ,rc =RC) ! ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ CALL ERR_MSG(RC,MESSAGE_CHECK,RC_FINALIZE) ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ! !----------------------------------------------------------------------- ! #ifdef WITH_NUOPC !----------------------------------------------------------------------- ! call ESMF_ClockDestroy(atm_int_state%CLOCK_ATM, rc=RC_FINALIZE) if (ESMF_LogFoundError(rcToCheck=RC_FINALIZE, msg=ESMF_LOGERR_PASSTHRU, & line=__LINE__, & file=__FILE__)) & return ! bail out #endif IF(RC_FINALIZE==ESMF_SUCCESS)THEN ! WRITE(0,*)' ATM_FINALIZE succeeded' ELSE WRITE(0,*)' ATM_FINALIZE failed RC_FINALIZE=',RC_FINALIZE ENDIF ! !----------------------------------------------------------------------- ! END SUBROUTINE ATM_FINALIZE ! !----------------------------------------------------------------------- ! END MODULE module_ATM_GRID_COMP ! !-----------------------------------------------------------------------