diff --git a/src/MAIN_NEMS.F90 b/src/MAIN_NEMS.F90 index ac47df36..fca08461 100644 --- a/src/MAIN_NEMS.F90 +++ b/src/MAIN_NEMS.F90 @@ -1,10 +1,10 @@ #include "./ESMFVersionDefine.h" -#if ESMF_VERSION_MAJOR >= 8 +#ifdef ESMF_VERSION_MAJOR >= 8 ! Do things for ESMF 8 and later #else #ifndef ESMF_VERSION_MAJOR -#error ESMF_VERSION_MAJOR is unset or empty; I do not know what version of ESMF you are using. +!error ESMF_VERSION_MAJOR is unset or empty; I do not know what version of ESMF you are using. #else ! Do things for ESMF versions before 8 #endif @@ -134,16 +134,16 @@ PROGRAM MAIN_NEMS !----------------------------------------------------------------------- ! IF(PRINT_ESMF) THEN - CALL ESMF_Initialize(VM =VM & !<-- The ESMF Virtual Machine - ,defaultCalKind =ESMF_CALKIND_GREGORIAN & !<-- Set up the default calendar. - ,logkindflag =ESMF_LOGKIND_MULTI & !<-- Define multiple log error output files; - ,rc =RC) + CALL ESMF_Initialize(VM = VM & !<-- The ESMF Virtual Machine + ,defaultCalKind = ESMF_CALKIND_GREGORIAN & !<-- Set up the default calendar. + ,logkindflag = ESMF_LOGKIND_MULTI & !<-- Define multiple log error output files; + ,rc = RC) ESMF_ERR_ABORT(RC) ELSE - CALL ESMF_Initialize(VM =VM & !<-- The ESMF Virtual Machine - ,defaultCalKind =ESMF_CALKIND_GREGORIAN & !<-- Set up the default calendar. - ,logkindflag =ESMF_LOGKIND_NONE & !<-- Define no log error output files; - ,rc =RC) + CALL ESMF_Initialize(VM = VM & !<-- The ESMF Virtual Machine + ,defaultCalKind = ESMF_CALKIND_GREGORIAN & !<-- Set up the default calendar. + ,logkindflag = ESMF_LOGKIND_NONE & !<-- Define no log error output files; + ,rc = RC) ESMF_ERR_ABORT(RC) ENDIF ! @@ -163,9 +163,9 @@ PROGRAM MAIN_NEMS ! CALL ESMF_LogWrite(MESSAGE_CHECK,ESMF_LOGMSG_INFO,rc=RC) ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ! - CALL ESMF_VMGet(vm =VM & !<-- The ESMF Virtual Machine - ,localpet=MYPE & !<-- The local MPI task ID - ,rc =RC) + CALL ESMF_VMGet(vm = VM & !<-- The ESMF Virtual Machine + ,localpet = MYPE & !<-- The local MPI task ID + ,rc = RC) ESMF_ERR_ABORT(RC) ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ! @@ -222,9 +222,9 @@ PROGRAM MAIN_NEMS ! CF_MAIN=ESMF_ConfigCreate(rc=RC) ! - CALL ESMF_ConfigLoadFile(config =CF_MAIN & !<-- The Configure object - ,filename='model_configure' & !<-- The name of the configure file - ,rc =RC) + CALL ESMF_ConfigLoadFile(config = CF_MAIN & !<-- The Configure object + ,filename = 'model_configure' & !<-- The name of the configure file + ,rc = RC) ESMF_ERR_ABORT(RC) ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ! @@ -239,9 +239,9 @@ PROGRAM MAIN_NEMS ! CALL ESMF_LogWrite(MESSAGE_CHECK,ESMF_LOGMSG_INFO,rc=RC) ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ! - NEMS_GRID_COMP=ESMF_GridCompCreate(name ='NEMS Grid Comp' & !<-- NEMS component name - ,configFile ='model_configure' & !<-- Link the user-created configure file. - ,rc =RC) + NEMS_GRID_COMP=ESMF_GridCompCreate(name = 'NEMS Grid Comp' & !<-- NEMS component name + ,configFile = 'model_configure' & !<-- Link the user-created configure file. + ,rc = RC) ESMF_ERR_ABORT(RC) ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ! @@ -270,20 +270,20 @@ PROGRAM MAIN_NEMS !*** value is used here. !----------------------------------------------------------------------- ! - TIMESTEP_SEC_WHOLE =1 !<-- Dummy timestep values - TIMESTEP_SEC_NUMERATOR =0 ! - TIMESTEP_SEC_DENOMINATOR=1 !<-- + TIMESTEP_SEC_WHOLE = 1 !<-- Dummy timestep values + TIMESTEP_SEC_NUMERATOR = 0 ! + TIMESTEP_SEC_DENOMINATOR = 1 !<-- ! ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ MESSAGE_CHECK="Set up Time Step Interval in Main Clock" ! CALL ESMF_LogWrite(MESSAGE_CHECK,ESMF_LOGMSG_INFO,rc=RC) ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ! - CALL ESMF_TimeIntervalSet(timeinterval=TIMESTEP & !<-- Main Clock's timestep - ,s =TIMESTEP_SEC_WHOLE & !<-- Whole part of timestep - ,sn =TIMESTEP_SEC_NUMERATOR & !<-- Numerator of fractional part - ,sd =TIMESTEP_SEC_DENOMINATOR & !<-- Denominator of fractional part - ,rc =RC) + CALL ESMF_TimeIntervalSet(timeinterval = TIMESTEP & !<-- Main Clock's timestep + ,s = TIMESTEP_SEC_WHOLE & !<-- Whole part of timestep + ,sn = TIMESTEP_SEC_NUMERATOR & !<-- Numerator of fractional part + ,sd = TIMESTEP_SEC_DENOMINATOR & !<-- Denominator of fractional part + ,rc = RC) ESMF_ERR_ABORT(RC) ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ! @@ -292,90 +292,90 @@ PROGRAM MAIN_NEMS !----------------------------------------------------------------------- ! ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ - MESSAGE_CHECK="MAIN: Extract Starting Year from Config File" + MESSAGE_CHECK = "MAIN: Extract Starting Year from Config File" ! CALL ESMF_LogWrite(MESSAGE_CHECK,ESMF_LOGMSG_INFO,rc=RC) ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ! - CALL ESMF_ConfigGetAttribute(config=CF_MAIN & - ,value =YY & - ,label ='start_year:' & - ,rc =RC) + CALL ESMF_ConfigGetAttribute(config = CF_MAIN & + ,value = YY & + ,label = 'start_year:' & + ,rc = RC) ESMF_ERR_ABORT(RC) ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ! ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ - MESSAGE_CHECK="MAIN: Extract Starting Month from Config File" + MESSAGE_CHECK = "MAIN: Extract Starting Month from Config File" ! CALL ESMF_LogWrite(MESSAGE_CHECK,ESMF_LOGMSG_INFO,rc=RC) ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ! - CALL ESMF_ConfigGetAttribute(config=CF_MAIN & - ,value =MM & - ,label ='start_month:' & - ,rc =RC) + CALL ESMF_ConfigGetAttribute(config = CF_MAIN & + ,value = MM & + ,label = 'start_month:' & + ,rc = RC) ESMF_ERR_ABORT(RC) ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ! ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ - MESSAGE_CHECK="MAIN: Extract Starting Day from Config File" + MESSAGE_CHECK = "MAIN: Extract Starting Day from Config File" ! CALL ESMF_LogWrite(MESSAGE_CHECK,ESMF_LOGMSG_INFO,rc=RC) ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ! - CALL ESMF_ConfigGetAttribute(config=CF_MAIN & - ,value =DD & - ,label ='start_day:' & - ,rc =RC) + CALL ESMF_ConfigGetAttribute(config = CF_MAIN & + ,value = DD & + ,label = 'start_day:' & + ,rc = RC) ESMF_ERR_ABORT(RC) ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ! ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ - MESSAGE_CHECK="MAIN: Extract Starting Hour from Config File" + MESSAGE_CHECK = "MAIN: Extract Starting Hour from Config File" ! CALL ESMF_LogWrite(MESSAGE_CHECK,ESMF_LOGMSG_INFO,rc=RC) ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ! - CALL ESMF_ConfigGetAttribute(config=CF_MAIN & - ,value =HH & - ,label ='start_hour:' & - ,rc =RC) + CALL ESMF_ConfigGetAttribute(config = CF_MAIN & + ,value = HH & + ,label = 'start_hour:' & + ,rc = RC) ESMF_ERR_ABORT(RC) ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ! ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ - MESSAGE_CHECK="MAIN: Extract Starting Minute from Config File" + MESSAGE_CHECK = "MAIN: Extract Starting Minute from Config File" ! CALL ESMF_LogWrite(MESSAGE_CHECK,ESMF_LOGMSG_INFO,rc=RC) ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ! - CALL ESMF_ConfigGetAttribute(config=CF_MAIN & - ,value =MNS & - ,label ='start_minute:' & - ,rc =RC) + CALL ESMF_ConfigGetAttribute(config = CF_MAIN & + ,value = MNS & + ,label = 'start_minute:' & + ,rc = RC) ESMF_ERR_ABORT(RC) ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ! ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ - MESSAGE_CHECK="MAIN: Extract Starting Second from Config File" + MESSAGE_CHECK = "MAIN: Extract Starting Second from Config File" ! CALL ESMF_LogWrite(MESSAGE_CHECK,ESMF_LOGMSG_INFO,rc=RC) ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ! - CALL ESMF_ConfigGetAttribute(config=CF_MAIN & - ,value =SEC & - ,label ='start_second:' & - ,rc =RC) + CALL ESMF_ConfigGetAttribute(config = CF_MAIN & + ,value = SEC & + ,label = 'start_second:' & + ,rc = RC) ESMF_ERR_ABORT(RC) ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ! ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ - MESSAGE_CHECK="MAIN: Set the Forecast Start Time" + MESSAGE_CHECK = "MAIN: Set the Forecast Start Time" ! CALL ESMF_LogWrite(MESSAGE_CHECK,ESMF_LOGMSG_INFO,rc=RC) ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ! - CALL ESMF_TimeSet(time=STARTTIME & !<-- The start time of the forecast (ESMF) - ,yy =YY & !<-- Year from config file - ,mm =MM & !<-- Month from config file - ,dd =DD & !<-- Day from config file - ,h =HH & !<-- Hour from config file - ,m =MNS & !<-- Minute from config file - ,s =SEC & !<-- Second from config file - ,rc =RC) + CALL ESMF_TimeSet(time = STARTTIME & !<-- The start time of the forecast (ESMF) + ,yy = YY & !<-- Year from config file + ,mm = MM & !<-- Month from config file + ,dd = DD & !<-- Day from config file + ,h = HH & !<-- Hour from config file + ,m = MNS & !<-- Minute from config file + ,s = SEC & !<-- Second from config file + ,rc = RC) ESMF_ERR_ABORT(RC) ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ! @@ -388,10 +388,10 @@ PROGRAM MAIN_NEMS ! CALL ESMF_LogWrite(MESSAGE_CHECK,ESMF_LOGMSG_INFO,rc=RC) ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ! - CALL ESMF_ConfigGetAttribute(config=CF_MAIN & - ,value =NHOURS_FCST & - ,label ='nhours_fcst:' & - ,rc =RC) + CALL ESMF_ConfigGetAttribute(config = CF_MAIN & + ,value = NHOURS_FCST & + ,label = 'nhours_fcst:' & + ,rc = RC) ESMF_ERR_ABORT(RC) ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ! @@ -404,9 +404,9 @@ PROGRAM MAIN_NEMS ! CALL ESMF_LogWrite(MESSAGE_CHECK,ESMF_LOGMSG_INFO,rc=RC) ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ! - CALL ESMF_TimeIntervalSet(timeinterval=RUNDURATION & !<-- The forecast length (s) (ESMF) - ,s =NSECONDS_FCST & - ,rc =RC) + CALL ESMF_TimeIntervalSet(timeinterval = RUNDURATION & !<-- The forecast length (s) (ESMF) + ,s = NSECONDS_FCST & + ,rc = RC) ESMF_ERR_ABORT(RC) ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ! @@ -425,11 +425,11 @@ PROGRAM MAIN_NEMS TIMESTEP = RUNDURATION - CLOCK_MAIN=ESMF_ClockCreate(name ='CLOCK_MAIN' & !<-- The top-level ESMF Clock - ,timeStep =TIMESTEP & !<-- Timestep needed by the Clock (ESMF) - ,startTime =STARTTIME & !<-- The integration start time (ESMF) - ,runDuration=RUNDURATION & !<-- The integration duration (ESMF) - ,rc =RC) + CLOCK_MAIN=ESMF_ClockCreate(name = 'CLOCK_MAIN' & !<-- The top-level ESMF Clock + ,timeStep = TIMESTEP & !<-- Timestep needed by the Clock (ESMF) + ,startTime = STARTTIME & !<-- The integration start time (ESMF) + ,runDuration = RUNDURATION & !<-- The integration duration (ESMF) + ,rc = RC) ESMF_ERR_ABORT(RC) ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ! @@ -439,18 +439,16 @@ PROGRAM MAIN_NEMS !----------------------------------------------------------------------- ! ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ - MESSAGE_CHECK="Create the NEMS Import/Export States" + MESSAGE_CHECK = "Create the NEMS Import/Export States" ! CALL ESMF_LogWrite(MESSAGE_CHECK,ESMF_LOGMSG_INFO,rc=RC) ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ! - NEMS_IMP_STATE=ESMF_StateCreate(name='NEMS Import State' & - ,rc =RC) + NEMS_IMP_STATE = ESMF_StateCreate(name='NEMS Import State', rc=RC) ESMF_ERR_ABORT(RC) ! - NEMS_EXP_STATE=ESMF_StateCreate(name='NEMS Export State' & - ,rc =RC) + NEMS_EXP_STATE=ESMF_StateCreate(name='NEMS Export State', rc=RC) ESMF_ERR_ABORT(RC) -! +! ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ! !----------------------------------------------------------------------- @@ -465,13 +463,13 @@ PROGRAM MAIN_NEMS ! CALL ESMF_LogWrite(MESSAGE_CHECK,ESMF_LOGMSG_INFO,rc=RC) ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ! - CALL ESMF_GridCompInitialize(gridcomp =NEMS_GRID_COMP & !<-- The NEMS component - ,importState=NEMS_IMP_STATE & !<-- The NEMS import state - ,exportState=NEMS_EXP_STATE & !<-- The NEMS export state - ,clock =CLOCK_MAIN & !<-- The ESMF clock - ,phase =1 & - ,userRc =RC_USER & - ,rc =RC) + CALL ESMF_GridCompInitialize(gridcomp = NEMS_GRID_COMP & !<-- The NEMS component + ,importState = NEMS_IMP_STATE & !<-- The NEMS import state + ,exportState = NEMS_EXP_STATE & !<-- The NEMS export state + ,clock = CLOCK_MAIN & !<-- The ESMF clock + ,phase = 1 & + ,userRc = RC_USER & + ,rc = RC) ESMF_ERR_ABORT(RC) ESMF_ERR_ABORT(RC_USER) ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ @@ -481,17 +479,17 @@ PROGRAM MAIN_NEMS !----------------------------------------------------------------------- ! ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ - MESSAGE_CHECK="Execute the NEMS Component Run Step" + MESSAGE_CHECK = "Execute the NEMS Component Run Step" ! CALL ESMF_LogWrite(MESSAGE_CHECK,ESMF_LOGMSG_INFO,rc=RC) ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ! - CALL ESMF_GridCompRun(gridcomp =NEMS_GRID_COMP & !<-- The NEMS component - ,importState=NEMS_IMP_STATE & !<-- The NEMS import state - ,exportState=NEMS_EXP_STATE & !<-- The NEMS export state - ,clock =CLOCK_MAIN & !<-- The ESMF clock - ,phase =1 & - ,userRc =RC_USER & - ,rc =RC) + CALL ESMF_GridCompRun(gridcomp = NEMS_GRID_COMP & !<-- The NEMS component + ,importState = NEMS_IMP_STATE & !<-- The NEMS import state + ,exportState = NEMS_EXP_STATE & !<-- The NEMS export state + ,clock = CLOCK_MAIN & !<-- The ESMF clock + ,phase = 1 & + ,userRc = RC_USER & + ,rc = RC) ESMF_ERR_ABORT(RC) ESMF_ERR_ABORT(RC_USER) ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ @@ -502,15 +500,15 @@ PROGRAM MAIN_NEMS !----------------------------------------------------------------------- ! ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ - MESSAGE_CHECK="Extract the RUN_CONTINUE flag from Config File" + MESSAGE_CHECK = "Extract the RUN_CONTINUE flag from Config File" ! CALL ESMF_LogWrite(MESSAGE_CHECK,ESMF_LOGMSG_INFO,rc=RC) ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ! - CALL ESMF_ConfigGetAttribute(config = CF_MAIN & - ,value = RUN_CONTINUE & - ,label = 'RUN_CONTINUE:' & - ,default= .false. & - ,rc = RC) + CALL ESMF_ConfigGetAttribute(config = CF_MAIN & + ,value = RUN_CONTINUE & + ,label = 'RUN_CONTINUE:' & + ,default = .false. & + ,rc = RC) ESMF_ERR_ABORT(RC) ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ! @@ -522,7 +520,7 @@ PROGRAM MAIN_NEMS IF(RUN_CONTINUE) THEN ! ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ - MESSAGE_CHECK="Extract the Ensemble Clock Parameters from Config File" + MESSAGE_CHECK = "Extract the Ensemble Clock Parameters from Config File" ! CALL ESMF_LogWrite(MESSAGE_CHECK,ESMF_LOGMSG_INFO,rc=RC) ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ! @@ -531,7 +529,7 @@ PROGRAM MAIN_NEMS ,label = 'HH_START:' & ,rc = RC) ESMF_ERR_ABORT(RC) -! + CALL ESMF_ConfigGetAttribute(config = CF_MAIN & ,value = hh_final & ,label = 'HH_FINAL:' & @@ -542,7 +540,7 @@ PROGRAM MAIN_NEMS NHOURS_FCST = HH_FINAL - HH_START ! ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ - MESSAGE_CHECK="MAIN: Re-set the clock after the ensemble run cycles." + MESSAGE_CHECK = "MAIN: Re-set the clock after the ensemble run cycles." ! CALL ESMF_LogWrite(MESSAGE_CHECK,ESMF_LOGMSG_INFO,rc=RC) ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ! @@ -572,17 +570,17 @@ PROGRAM MAIN_NEMS !----------------------------------------------------------------------- ! ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ - MESSAGE_CHECK="Execute the NEMS Component Finalize Step" + MESSAGE_CHECK = "Execute the NEMS Component Finalize Step" ! CALL ESMF_LogWrite(MESSAGE_CHECK,ESMF_LOGMSG_INFO,rc=RC) ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ! - CALL ESMF_GridCompFinalize(gridcomp =NEMS_GRID_COMP & !<-- The NEMS component - ,importState=NEMS_IMP_STATE & !<-- The NEMS component import state - ,exportState=NEMS_EXP_STATE & !<-- The NEMS component export state - ,clock =CLOCK_MAIN & !<-- The Main ESMF clock - ,phase =1 & - ,userRc =RC_USER & - ,rc =RC) + CALL ESMF_GridCompFinalize(gridcomp = NEMS_GRID_COMP & !<-- The NEMS component + ,importState = NEMS_IMP_STATE & !<-- The NEMS component import state + ,exportState = NEMS_EXP_STATE & !<-- The NEMS component export state + ,clock = CLOCK_MAIN & !<-- The Main ESMF clock + ,phase = 1 & + ,userRc = RC_USER & + ,rc = RC) ESMF_ERR_ABORT(RC) ESMF_ERR_ABORT(RC_USER) ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ @@ -592,12 +590,11 @@ PROGRAM MAIN_NEMS !----------------------------------------------------------------------- ! ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ - MESSAGE_CHECK="Destroy the Main Clock" -! CALL ESMF_LogWrite(MESSAGE_CHECK,ESMF_LOGMSG_INFO,rc=RC) + MESSAGE_CHECK = "Destroy the Main Clock" +! CALL ESMF_LogWrite(MESSAGE_CHECK,ESMF_LOGMSG_INFO, rc=RC) ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ! - CALL ESMF_ClockDestroy(clock=CLOCK_MAIN & - ,rc =RC) + CALL ESMF_ClockDestroy(clock=CLOCK_MAIN, rc=RC) ESMF_ERR_ABORT(RC) ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ! @@ -606,12 +603,11 @@ PROGRAM MAIN_NEMS !----------------------------------------------------------------------- ! ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ - MESSAGE_CHECK="Destroy the Main Configure Object" + MESSAGE_CHECK = "Destroy the Main Configure Object" ! CALL ESMF_LogWrite(MESSAGE_CHECK,ESMF_LOGMSG_INFO,rc=RC) ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ! - CALL ESMF_ConfigDestroy(config=CF_MAIN & - ,rc =RC) + CALL ESMF_ConfigDestroy(config=CF_MAIN, rc=RC) ESMF_ERR_ABORT(RC) ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ! @@ -620,12 +616,10 @@ PROGRAM MAIN_NEMS ! CALL ESMF_LogWrite(MESSAGE_CHECK, ESMF_LOGMSG_INFO, rc = RC) ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ - CALL ESMF_StateDestroy(state=NEMS_IMP_STATE & - ,rc =RC) + CALL ESMF_StateDestroy(state=NEMS_IMP_STATE, rc=RC) ESMF_ERR_ABORT(RC) ! - CALL ESMF_StateDestroy(state=NEMS_EXP_STATE & - ,rc =RC) + CALL ESMF_StateDestroy(state=NEMS_EXP_STATE, rc=RC) ESMF_ERR_ABORT(RC) ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ! @@ -634,16 +628,15 @@ PROGRAM MAIN_NEMS ! CALL ESMF_LogWrite(MESSAGE_CHECK, ESMF_LOGMSG_INFO, rc = RC) ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ! - CALL ESMF_GridCompDestroy(gridcomp=NEMS_GRID_COMP & - ,rc =RC) + CALL ESMF_GridCompDestroy(gridcomp=NEMS_GRID_COMP, rc=RC) ESMF_ERR_ABORT(RC) ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ! Resource usage reporting. We only do this if the rusage%start was ! successful. - if(rusage%is_valid()) then + if (rusage%is_valid()) then call rusage%stop(rc) - if(rc==0) call rusage%report(rc) + if (rc == 0) call rusage%report(rc) endif !----------------------------------------------------------------------- @@ -654,7 +647,7 @@ PROGRAM MAIN_NEMS ! !----------------------------------------------------------------------- ! - if(mype==0)call w3tage('nems ') + if (mype == 0) call w3tage('nems ') ! !----------------------------------------------------------------------- ! diff --git a/src/incmake/component_CCPP.mk b/src/incmake/component_CCPP.mk index f5313b7f..861ceaec 100644 --- a/src/incmake/component_CCPP.mk +++ b/src/incmake/component_CCPP.mk @@ -25,7 +25,7 @@ endif # Process make options for CCPP build ifneq (,$(findstring SUITES=,$(FV3_MAKEOPT))) - # Extract name of suite definition files using sed: + # Extract names of suite definition files using sed: # - remove everything leading up to the names of the suite definition files # - remove everything following the names of the suite definition files SUITES = $(shell echo $(FV3_MAKEOPT) | sed 's/.* SUITES=//' | sed 's/ .*//') diff --git a/src/incmake/component_CICE.mk b/src/incmake/component_CICE.mk index 3e44d4a4..6274a524 100644 --- a/src/incmake/component_CICE.mk +++ b/src/incmake/component_CICE.mk @@ -10,28 +10,30 @@ CICE_CAPDIR?=$(ROOTDIR)/CICE_CAP # NEMS_GRID was found in CICE and defaults to a low-res GSM grid # This is obsolete and perhaps should be removed. -NEMS_GRID?=T126_mx5 +#NEMS_GRID?=T126_mx5 +NEMS_GRID?=mx025 # Make sure the expected directories exist and are non-empty: $(call require_dir,$(CICE_SRCDIR),CICE source directory) $(call require_dir,$(ROOTDIR)/CICE_CAP,CICE cap directory) ifneq (,$(findstring CMEPS,$(COMPONENTS))) -CPPCMEPS = -DCMEPS + CPPCMEPS = -DCMEPS else -CPPCMEPS = + CPPCMEPS = endif -CICE_ALL_OPTS=\ - COMP_SRCDIR=$(CICE_SRCDIR) \ - COMP_BINDIR=$(CICE_BINDIR) \ - SITE="NEMS.$(MACHINE_ID)" \ +CICE_ALL_OPTS= \ + COMP_SRCDIR=$(CICE_SRCDIR) \ + COMP_BINDIR=$(CICE_BINDIR) \ + MACHINE_ID="NEMS.$(MACHINE_ID)" \ SYSTEM_USERDIR="$(CICE_SRCDIR)" \ - SRCDIR="$(CICE_SRCDIR)" \ - EXEDIR="$(CICE_SRCDIR)" \ - CPPCMEPS="$(CPPCMEPS)" \ + SRCDIR="$(CICE_SRCDIR)" \ + EXEDIR="$(CICE_SRCDIR)" \ + CPPCMEPS="$(CPPCMEPS)" \ NEMS_GRID="$(NEMS_GRID)" + ######################################################################## # Rules for building this component: diff --git a/src/incmake/component_CICE6.mk b/src/incmake/component_CICE6.mk index 7e1b1d36..fc862ec9 100644 --- a/src/incmake/component_CICE6.mk +++ b/src/incmake/component_CICE6.mk @@ -20,15 +20,15 @@ $(call require_dir,$(CICE_SRCDIR),CICE source directory) CPPCICE = #endif -CICE_ALL_OPTS=\ - COMP_SRCDIR=$(CICE_SRCDIR) \ - COMP_BINDIR=$(CICE_BINDIR) \ - SITE="$(MACHINE_ID)" \ +CICE6_ALL_OPTS= \ + COMP_SRCDIR=$(CICE_SRCDIR) \ + COMP_BINDIR=$(CICE_BINDIR) \ + MACHINE_ID="$(MACHINE_ID)" \ SYSTEM_USERDIR="$(CICE_UFSDIR)" \ - BINDIR="$(CICE_BINDIR)" \ - SRCDIR="$(CICE_SRCDIR)" \ - EXEDIR="$(CICE_UFSDIR)" \ - CPPCICE="$(CPPCICE)" \ + BINDIR="$(CICE_BINDIR)" \ + SRCDIR="$(CICE_SRCDIR)" \ + EXEDIR="$(CICE_UFSDIR)" \ + CPPCICE="$(CPPCICE)" \ NEMS_GRID="$(NEMS_GRID)" ######################################################################## @@ -37,7 +37,7 @@ CICE_ALL_OPTS=\ $(cice6_mk): configure $(MODULE_LOGIC) ; \ set -eu ; \ - export $(CICE_ALL_OPTS) $(CICE_MAKEOPT) ; \ + export $(CICE6_ALL_OPTS) $(CICE6_MAKEOPT) ; \ cd $(CICE_UFSDIR) ; \ ./comp_ice.backend.libcice test -f $(cice6_mk) @@ -49,10 +49,9 @@ build_CICE6: $(cice6_mk) # Rules for cleaning the SRCDIR and BINDIR: clean_CICE6_SRC: configure - cp -n $(MODULE_DIR)/$(CHOSEN_MODULE) $(CONFDIR)/modules.nems ; \ $(MODULE_LOGIC) ; \ set -eu ; \ - export $(CICE_ALL_OPTS) $(CICE_MAKEOPT) ; \ + export $(CICE6_ALL_OPTS) $(CICE6_MAKEOPT) ; \ cd $(CICE_UFSDIR) ; \ ./comp_ice.backend.clean diff --git a/src/incmake/component_FV3.mk b/src/incmake/component_FV3.mk index 12f97f60..4e63476c 100644 --- a/src/incmake/component_FV3.mk +++ b/src/incmake/component_FV3.mk @@ -2,6 +2,8 @@ fv3_mk=$(FV3_BINDIR)/fv3.mk all_component_mk_files+=$(fv3_mk) +NCP="/bin/cp" + # Location of source code and installation FV3_SRCDIR?=$(ROOTDIR)/FV3 FV3_BINDIR?=$(ROOTDIR)/FV3/FV3_INSTALL @@ -33,9 +35,9 @@ FV3_FULL_OPTS=\ build_FV3: $(fv3_mk) $(fv3_mk): $(fms_mk) configure - cp -fp $(NEMSDIR)/src/conf/configure.nems \ + $(NCP) -fp $(NEMSDIR)/src/conf/configure.nems \ "$(FV3_SRCDIR)"/conf/configure.fv3 - cp -fp $(NEMSDIR)/src/conf/modules.nems \ + $(NCP) -fp $(NEMSDIR)/src/conf/modules.nems \ "$(FV3_SRCDIR)"/conf/modules.fv3 $(info Compiling $(FV3_MAKEOPT) into $(FV3_BINDIR) on $(MACHINE_ID)) +$(MODULE_LOGIC) ; cd $(FV3_SRCDIR) ; \ diff --git a/src/incmake/component_MOM6.mk b/src/incmake/component_MOM6.mk index cf733335..8e3dfc79 100644 --- a/src/incmake/component_MOM6.mk +++ b/src/incmake/component_MOM6.mk @@ -3,8 +3,9 @@ mom6_mk = $(MOM6_BINDIR)/mom6.mk all_component_mk_files+=$(mom6_mk) # Location of source code and installation -MOM6_SRCDIR?=$(ROOTDIR)/MOM6-interface -MOM6_BINDIR?=$(ROOTDIR)/MOM6-interface/MOM6_INSTALL +MOM6_SRCDIR?=$(ROOTDIR)/MOM6 +MOM6_BINDIR?=$(ROOTDIR)/MOM6/MOM6_INSTALL +#MOM6_BINDIR?=$(ROOTDIR)/MOM6_INSTALL # Make sure the expected directories exist and are non-empty: $(call require_dir,$(MOM6_SRCDIR),MOM6 source directory) @@ -13,9 +14,9 @@ $(call require_dir,$(MOM6_SRCDIR),MOM6 source directory) build_MOM6: $(mom6_mk) ifneq (,$(findstring CMEPS,$(COMPONENTS))) -CPPCMEPS = -DCMEPS + CPPCMEPS = -DCMEPS else -CPPCMEPS = + CPPCMEPS = endif MOM6_ALL_OPTS=\ diff --git a/src/incmake/configure_rules.mk b/src/incmake/configure_rules.mk index a394f138..336ce905 100644 --- a/src/incmake/configure_rules.mk +++ b/src/incmake/configure_rules.mk @@ -1,4 +1,4 @@ - +NCP="/bin/cp" $(CONFDIR)/test-results.mk: +$(MAKE) -f $(NEMSDIR)/src/incmake/tests.mk \ MODULE_LOGIC="$(MODULE_LOGIC)" \ @@ -10,18 +10,18 @@ $(CONFDIR)/test-results.mk: # Copy the configure.nems, externals.nems, and ESMFVersionDefine.h $(CONFDIR)/configure.nems: $(CONFIGURE_NEMS_FILE) - cp $(CONFIGURE_NEMS_FILE) $@ + $(NCP) $(CONFIGURE_NEMS_FILE) $@ ifneq ($(EXTERNALS_NEMS_FILE),) $(CONFDIR)/externals.nems: $(EXTERNALS_NEMS_FILE) - cp $(EXTERNALS_NEMS_FILE) $@ + $(NCP) $(EXTERNALS_NEMS_FILE) $@ else $(CONFDIR)/externals.nems: cat /dev/null > $@ endif $(NEMSDIR)/src/ESMFVersionDefine.h: - cp $(ESMF_VERSION_DEFINE) $@ + $(NCP) $(ESMF_VERSION_DEFINE) $@ ######################################################################## @@ -31,7 +31,7 @@ $(NEMSDIR)/src/ESMFVersionDefine.h: ifneq ($(CHOSEN_MODULE),) $(CONFDIR)/modules.nems: $(MODULE_DIR)/$(CHOSEN_MODULE) - cp $(MODULE_DIR)/$(CHOSEN_MODULE) $@ + $(NCP) $(MODULE_DIR)/$(CHOSEN_MODULE) $@ else $(CONFDIR)/modules.nems: cat /dev/null > $@ diff --git a/src/module_EARTH_GRID_COMP.F90 b/src/module_EARTH_GRID_COMP.F90 index d1d1e614..fa3b0213 100644 --- a/src/module_EARTH_GRID_COMP.F90 +++ b/src/module_EARTH_GRID_COMP.F90 @@ -42,57 +42,57 @@ MODULE module_EARTH_GRID_COMP USE ESMF use NUOPC - use NUOPC_Driver, & - Driver_routine_SS => SetServices, & + use NUOPC_Driver, & + Driver_routine_SS => SetServices, & Driver_label_SetModelServices => label_SetModelServices, & - Driver_label_SetRunSequence => label_SetRunSequence, & - Driver_label_SetRunClock => label_SetRunClock, & + Driver_label_SetRunSequence => label_SetRunSequence, & + Driver_label_SetRunClock => label_SetRunClock, & Driver_label_Finalize => label_Finalize - use NUOPC_Connector, only: conSS => SetServices - ! - Handle build time ATM options: + use NUOPC_Connector, only: conSS => SetServices + ! - Handle build time ATM options: #ifdef FRONT_SATM - use FRONT_SATM, only: SATM_SS => SetServices + use FRONT_SATM, only: SATM_SS => SetServices #endif #ifdef FRONT_XATM - use FRONT_XATM, only: XATM_SS => SetServices + use FRONT_XATM, only: XATM_SS => SetServices #endif #ifdef FRONT_DATAWAM - use FRONT_DATAWAM, only: DATAWAM_SS=> SetServices + use FRONT_DATAWAM, only: DATAWAM_SS => SetServices #endif #ifdef FRONT_GSM - use FRONT_GSM, only: GSM_SS => SetServices + use FRONT_GSM, only: GSM_SS => SetServices #endif #ifdef FRONT_NMMB - use FRONT_NMMB, only: NMMB_SS => SetServices + use FRONT_NMMB, only: NMMB_SS => SetServices #endif #ifdef FRONT_FV3 - use FRONT_FV3, only: FV3_SS => SetServices + use FRONT_FV3, only: FV3_SS => SetServices #endif #ifdef FRONT_DATM - use FRONT_DATM, only: DATM_SS => SetServices + use FRONT_DATM, only: DATM_SS => SetServices #endif ! - Handle build time OCN options: #ifdef FRONT_SOCN - use FRONT_SOCN, only: SOCN_SS => SetServices + use FRONT_SOCN, only: SOCN_SS => SetServices #endif #ifdef FRONT_XOCN - use FRONT_XOCN, only: XOCN_SS => SetServices + use FRONT_XOCN, only: XOCN_SS => SetServices #endif #ifdef FRONT_HYCOM - use FRONT_HYCOM, only: HYCOM_SS => SetServices + use FRONT_HYCOM, only: HYCOM_SS => SetServices #endif #ifdef FRONT_MOM5 - use FRONT_MOM5, only: MOM5_SS => SetServices + use FRONT_MOM5, only: MOM5_SS => SetServices #endif #ifdef FRONT_MOM6 - use FRONT_MOM6, only: MOM6_SS => SetServices + use FRONT_MOM6, only: MOM6_SS => SetServices #endif #ifdef FRONT_POM - use FRONT_POM, only: POM_SS => SetServices + use FRONT_POM, only: POM_SS => SetServices #endif ! - Handle build time ICE options: #ifdef FRONT_SICE - use FRONT_SICE, only: SICE_SS => SetServices + use FRONT_SICE, only: SICE_SS => SetServices #endif #ifdef FRONT_XICE use FRONT_XICE, only: XICE_SS => SetServices @@ -154,7 +154,7 @@ MODULE module_EARTH_GRID_COMP #endif ! - Mediator #ifdef CMEPS - use MED, only : MED_SS => SetServices + use MED, only : MED_SS => SetServices #else use module_MEDIATOR, only: MED_SS => SetServices #endif @@ -193,9 +193,9 @@ logical function verbose_diagnostics(set) !! the given value. logical, optional :: set if(present(set)) then - flag_verbose_diagnostics=set + flag_verbose_diagnostics = set endif - verbose_diagnostics=flag_verbose_diagnostics + verbose_diagnostics = flag_verbose_diagnostics end function verbose_diagnostics !----------------------------------------------------------------------- @@ -218,9 +218,332 @@ SUBROUTINE EARTH_REGISTER(EARTH_GRID_COMP,RC_REG) !*** Local Variables !--------------------- ! - INTEGER :: RC - type(ESMF_Config) :: config - + INTEGER :: RC, nf + type(ESMF_Config) :: config +! + integer, parameter :: NumFields=268 +! integer, parameter :: NumFields=259 +! integer, parameter :: NumFields=256 +! integer, parameter :: NumFields=253 +! integer, parameter :: NumFields=252 +! integer, parameter :: NumFields=251 +! integer, parameter :: NumFields=250 + + character(60), parameter :: Field_Name_unit(2,NumFields) = (/ & + "air_density_height_lowest ", "kg m-3 ", & + "mean_zonal_moment_flx ", "N m-2 ", & + "mean_zonal_moment_flx_atm ", "N m-2 ", & + "mean_merid_moment_flx ", "N m-2 ", & + "mean_merid_moment_flx_atm ", "N m-2 ", & + "mean_sensi_heat_flx ", "W m-2 ", & + "mean_sensi_heat_flx_atm ", "W m-2 ", & + "mean_sensi_heat_flx_atm_into_ice ", "W m-2 ", & + "mean_sensi_heat_flx_atm_into_ocn ", "W m-2 ", & + "mean_laten_heat_flx ", "W m-2 ", & + "mean_laten_heat_flx_atm ", "W m-2 ", & + "mean_laten_heat_flx_atm_into_ice ", "W m-2 ", & + "mean_laten_heat_flx_atm_into_ocn ", "W m-2 ", & + "mean_down_lw_flx ", "W m-2 ", & + "mean_down_sw_flx ", "W m-2 ", & + "mean_fprec_rate ", "kg s m-2 ", & + "mean_prec_rate ", "kg s m-2 ", & + "mean_evap_rate ", "kg s m-2 ", & + "mean_evap_rate_atm_into_ice ", "kg s m-2 ", & + "mean_evap_rate_atm_into_ocn ", "kg s m-2 ", & + "inst_zonal_moment_flx ", "N m-2 ", & + "inst_merid_moment_flx ", "N m-2 ", & + "inst_sensi_heat_flx ", "W m-2 ", & + "inst_laten_heat_flx ", "W m-2 ", & + "inst_down_lw_flx ", "W m-2 ", & + "inst_down_sw_flx ", "W m-2 ", & + "inst_temp_height2m ", "K ", & + "inst_spec_humid_height2m ", "kg kg-1 ", & + "inst_u_wind_height10m ", "m s-1 ", & + "inst_v_wind_height10m ", "m s-1 ", & + "inst_zonal_wind_height10m ", "m s-1 ", & + "inst_merid_wind_height10m ", "m s-1 ", & + "inst_temp_height_surface ", "K ", & + "inst_pres_height_surface ", "Pa ", & + "inst_surface_height ", "m ", & + "mean_down_sw_vis_dir_flx ", "W m-2 ", & + "mean_down_sw_vis_dif_flx ", "W m-2 ", & + "mean_down_sw_ir_dir_flx ", "W m-2 ", & + "mean_down_sw_ir_dif_flx ", "W m-2 ", & + "inst_down_sw_vis_dir_flx ", "W m-2 ", & + "inst_down_sw_vis_dif_flx ", "W m-2 ", & + "inst_down_sw_ir_dir_flx ", "W m-2 ", & + "inst_down_sw_ir_dif_flx ", "W m-2 ", & + "mean_net_sw_vis_dir_flx ", "W m-2 ", & + "mean_net_sw_vis_dif_flx ", "W m-2 ", & + "mean_net_sw_ir_dir_flx ", "W m-2 ", & + "mean_net_sw_ir_dif_flx ", "W m-2 ", & + "inst_net_sw_vis_dir_flx ", "W m-2 ", & + "inst_net_sw_vis_dif_flx ", "W m-2 ", & + "inst_net_sw_ir_dir_flx ", "W m-2 ", & + "inst_net_sw_ir_dif_flx ", "W m-2 ", & + "mean_salt_rate ", "kg psu m-2 s ", & + "mean_runoff_rate ", "kg m-2 s ", & + "mean_calving_rate ", "kg m-2 s ", & + "mean_runoff_heat_flx ", "W m-2 ", & + "mean_calving_heat_flx ", "W m-2 ", & + "ice_fraction ", "1 ", & + "mean_sw_pen_to_ocn ", "W m-2 ", & + "mean_up_lw_flx ", "W m-2 ", & + "mass_of_overlying_sea_ice ", "kg ", & + "s_surf ", "psu ", & + "freezing_melting_potential ", "W m-2 ", & + +! following two added for export from MOM6 +! ---------------------------------------- + "accum_heat_frazil ", "W m-2 ", & + "inst_melt_potential ", "W m-2 ", & + "u_surf ", "m s-1 ", & + "v_surf ", "m s-1 ", & + "sea_lev ", "m ", & + "wind_stress_zonal ", "N m-2 ", & + "wind_stress_merid ", "N m-2 ", & + "ocn_current_zonal ", "m s-1 ", & + "ocn_current_merid ", "m s-1 ", & + "ocn_current_idir ", "m s-1 ", & + "ocn_current_jdir ", "m s-1 ", & + "sea_surface_slope_zonal ", "m m-1 ", & + "sea_surface_slope_merid ", "m m-1 ", & + "stress_on_air_ice_zonal ", "N m-2 ", & + "stress_on_air_ice_merid ", "N m-2 ", & + "stress_on_air_ocn_zonal ", "N m-2 ", & + "stress_on_air_ocn_merid ", "N m-2 ", & + "stress_on_ocn_ice_zonal ", "N m-2 ", & + "stress_on_ocn_ice_merid ", "N m-2 ", & + "stress_on_ocn_ice_idir ", "N m-2 ", & + "stress_on_ocn_ice_jdir ", "N m-2 ", & + "mixed_layer_depth ", "m ", & + "mean_net_lw_flx ", "W m-2 ", & + "mean_net_lw_flx_atm ", "W m-2 ", & + "mean_net_sw_flx ", "W m-2 ", & + "mean_up_lw_flx_ice ", "W m-2 ", & + "mean_up_lw_flx_ocn ", "W m-2 ", & + "inst_net_lw_flx ", "W m-2 ", & + "inst_net_sw_flx ", "W m-2 ", & + "mean_sw_pen_to_ocn_vis_dir_flx ", "W m-2 ", & + "mean_sw_pen_to_ocn_vis_dif_flx ", "W m-2 ", & + "mean_sw_pen_to_ocn_ir_dir_flx ", "W m-2 ", & + "mean_sw_pen_to_ocn_ir_dif_flx ", "W m-2 ", & + "inst_ir_dir_albedo ", "1 ", & + "inst_ir_dif_albedo ", "1 ", & + "inst_vis_dir_albedo ", "1 ", & + "inst_vis_dif_albedo ", "1 ", & + "inst_ocn_ir_dir_albedo ", "1 ", & + "inst_ocn_ir_dif_albedo ", "1 ", & + "inst_ocn_vis_dir_albedo ", "1 ", & + "inst_ocn_vis_dif_albedo ", "1 ", & + "inst_ice_ir_dir_albedo ", "1 ", & + "inst_ice_ir_dif_albedo ", "1 ", & + "inst_ice_vis_dir_albedo ", "1 ", & + "inst_ice_vis_dif_albedo ", "1 ", & + "inst_land_sea_mask ", "1 ", & + "inst_temp_height_lowest ", "K ", & + "inst_spec_humid_height_lowest ", "kg kg-1 ", & + "humidity_2m ", "kg kg-1 ", & + "inst_zonal_wind_height_lowest ", "m s-1 ", & + "inst_merid_wind_height_lowest ", "m s-1 ", & + "inst_pres_height_lowest ", "Pa ", & + "inst_height_lowest ", "m ", & + "ocean_mask ", "1 ", & + "ice_mask ", "1 ", & + "land_mask ", "1 ", & + +! special HYCOM exports +! --------------------- + "surface_downward_eastward_stress ", "Pa ", & + "surface_downward_northward_stress ", "Pa ", & + "wind_speed_height10m ", "m s-1 ", & + "wind_speed_squared_10m ", "m2 s-2 ", & + "friction_speed ", "m s-1 ", & + "mean_lat_flx ", "W m-2 ", & + "mean_sens_flx ", "W m-2 ", & + "water_flux_into_sea_water ", "kg m-2 s-1 ", & + "frozen_water_flux_into_sea_water ", "kg m-2 s-1 ", & + "surface_temperature ", "K ", & + "air_surface_temperature ", "K ", & + "sea_surface_temperature ", "K ", & + "sea_ice_surface_temperature ", "K ", & + "temperature_2m ", "K ", & + "upward_sea_ice_basal_available_heat_flux ", "W m-2 ", & + +! special HYCOM imports +! --------------------- + "sea_ice_area_fraction ", "1 ", & + "downward_x_stress_at_sea_ice_base ", "Pa ", & + "downward_y_stress_at_sea_ice_base ", "Pa ", & + "downward_sea_ice_basal_solar_heat_flux ", "W m-2 ", & + "upward_sea_ice_basal_heat_flux ", "W m-2 ", & + "downward_sea_ice_basal_salt_flux ", "kg m-2 s-1 ", & + "downward_sea_ice_basal_water_flux ", "kg m-2 s-1 ", & +! "sea_ice_surface_temperature ", "K ", & +! "sea_ice_temperature ", "K ", & + "sea_ice_thickness ", "m ", & + "sea_ice_x_velocity ", "m s-1 ", & + "sea_ice_y_velocity ", "m s-1 ", & + "net_heat_flx_to_ocn ", "W m-2 ", & + "mean_fresh_water_to_ocean_rate ", "kg m-2 s-1 ", & + "mean_ice_volume ", "m ", & + "mean_snow_volume ", "m ", & + +! Mass flux of liquid runoff +! -------------------------- + "Foxx_rofl ", "kg m-2 s-1 ", & +! Mass flux of frozen runoff +! -------------------------- + "Foxx_rofi ", "kg m-2 s-1 ", & +! Synonyms for HYCOM fields +! ------------------------- + "So_bldepth ", "m ", & +! + ! DCR - Fields added for Regional Application + ! ATM-OCN-ICE-LND-HYD + ! List of exisitng fields + ! ice_mask, inst_down_lw_flx, inst_down_sw_flx, inst_height_lowest, + ! inst_merid_wind_height_lowest, inst_pres_height_lowest, + ! inst_pres_height_surface, inst_spec_humid_height_lowest, + ! inst_temp_height_lowest, inst_temp_height_surface, + ! inst_zonal_wind_height_lowest, mean_down_lw_flx, mean_down_sw_flx, + ! mean_fprec_rate, mean_laten_heat_flx, mean_net_lw_flx, mean_net_sw_flx, + ! mean_prec_rate, mean_sensi_heat_flx + + "aerodynamic_roughness_length ", "m ", & + "canopy_moisture_storage ", "kg m-2 ", & + "carbon_dioxide ", "ppmv ", & + "cosine_zenith_angle ", "degree ", & + "exchange_coefficient_heat ", "W m-2 K-1 ", & + "exchange_coefficient_heat_height2m ", "W m-2 K-1 ", & + "exchange_coefficient_moisture_height2m ", "kg m-2 s-1 Pa-1 ", & + "inst_wind_speed_height_lowest ", "m s-1 ", & + "mean_cprec_rate ", "kg m-2 s-1 ", & + "mean_grnd_sensi_heat_flx ", " ", & + "mean_laten_heat_flx_kinematic ", "Kg m-2 s-1 ", & + "mean_surface_albedo ", "1 ", & + "mean_surface_skin_temp ", "K ", & + "mixing_ratio_surface ", "kg kg-1 ", & + "root_moisture ", "kg m-2 ", & + "saturated_mixing_ratio ", "kg kg-1 ", & + "surface_snow_area_fraction ", "1 ", & + "surface_snow_thickness ", "m ", & + "surface_snow_melt_flux ", "kg m-2 ", & + "liquid_water_content_of_surface_snow ", "m ", & + "soil_depth ", "m ", & + "soil_hydraulic_conductivity_at_saturation ", "m s-1 ", & + "moisture_content_of_soil_layer ", "kg m-2 ", & + "moisture_content_of_soil_layer_1 ", "kg m-2 ", & + "moisture_content_of_soil_layer_2 ", "kg m-2 ", & + "moisture_content_of_soil_layer_3 ", "kg m-2 ", & + "moisture_content_of_soil_layer_4 ", "kg m-2 ", & + "soil_porosity ", "1 ", & + "temperature_of_soil_layer ", "K ", & + "temperature_of_soil_layer_1 ", "K ", & + "temperature_of_soil_layer_2 ", "K ", & + "temperature_of_soil_layer_3 ", "K ", & + "temperature_of_soil_layer_4 ", "K ", & + "soil_temperature_bottom ", "K ", & + "soil_type ", "1 ", & + "soil_moisture_content ", "kg m-2 ", & + "subsurface_basin_mask ", "1 ", & + "subsurface_runoff_flux ", "kg m-2 s-1 ", & + "surface_microwave_emissivity ", "1 ", & + "surface_runoff_flux ", "kg m-2 s-1 ", & + "vegetation_type ", "1 ", & + "volume_fraction_of_frozen_water_in_soil ", "m3 m-3 ", & + "liquid_water_content_of_soil_layer ", "kg m-2 ", & + "liquid_water_content_of_soil_layer_1 ", "kg m-2 ", & + "liquid_water_content_of_soil_layer_2 ", "kg m-2 ", & + "liquid_water_content_of_soil_layer_3 ", "kg m-2 ", & + "liquid_water_content_of_soil_layer_4 ", "kg m-2 ", & + "volume_fraction_of_total_water_in_soil ", "m3 m-3 ", & + "volume_fraction_of_total_water_in_soil_at_critical_point ", "m3 m-3 ", & + "volume_fraction_of_total_water_in_soil_at_field_capacity ", "m3 m-3 ", & + "volume_fraction_of_total_water_in_soil_at_wilting_point ", "m3 m-3 ", & + "water_surface_height_above_reference_datum ", "m ", & + "mean_sensi_heat_flx_atm_into_lnd ", "W m-2 ", & + "mean_laten_heat_flx_atm_into_lnd ", "W m-2 ", & + +! Fields from and to WW3 +! ---------------------- + "eastward_wind_at_10m_height ", "m s-1 ", & + "northward_wind_at_10m_height ", "m s-1 ", & + "sea_ice_concentration ", "1 ", & + "eastward_stokes_drift_current ", "m s-1 ", & + "northward_stokes_drift_current ", "m s-1 ", & + "eastward_wave_bottom_current ", "m s-1 ", & + "northward_wave_bottom_current ", "m s-1 ", & + "wave_bottom_current_radian_frequency ", "rad s-1 ", & + "eastward_wave_radiation_stress_gradient ", "Pa ", & + "northward_wave_radiation_stress_gradient ", "Pa ", & + "eastward_wave_radiation_stress ", "N m-1 ", & + "eastward_northward_wave_radiation_stress ", "N m-1 ", & + "northward_wave_radiation_stress ", "N m-1 ", & + "wave_induced_charnock_parameter ", "1 ", & + "wave_z0_roughness_length ", "m ", & + "wave_bottom_current_period ", "s ", & +!For MOM6 and WW3 variables to match: + "eastward_partitioned_stokes_drift_1 ", "m s-1 ", & + "northward_partitioned_stokes_drift_1 ", "m s-1 ", & + "eastward_partitioned_stokes_drift_2 ", "m s-1 ", & + "northward_partitioned_stokes_drift_2 ", "m s-1 ", & + "eastward_partitioned_stokes_drift_3 ", "m s-1 ", & + "northward_partitioned_stokes_drift_3 ", "m s-1 ", & + +! Fields from WAM to IPE +! ---------------------- + "northward_wind_neutral ", "m s-1 ", & + "eastward_wind_neutral ", "m s-1 ", & + "upward_wind_neutral ", "m s-1 ", & + "temp_neutral ", "K ", & + "inst_temp_height_surface ", "K ", & + "inst_pres_height_surface ", "Pa ", & + "inst_surface_height ", "m ", & + "O_Density ", "m-3 ", & + "O2_Density ", "m-3 ", & + "N2_Density ", "m-3 ", & + "height ", "km ", & + +! Chemistry fields +! ---------------- + "inst_pres_interface ", "Pa ", & + "inst_pres_levels ", "Pa ", & + "inst_geop_interface ", "m2 s-2 ", & + "inst_geop_levels ", "m2 s-2 ", & + "inst_temp_levels ", "K ", & + "inst_zonal_wind_levels ", "m s-1 ", & + "inst_merid_wind_levels ", "m s-1 ", & + "inst_omega_levels ", "s s-1s ", & + "inst_tracer_mass_frac ", "kg kg-1s ", & + "inst_tracer_up_surface_flx ", "kg m-2 s-1 ", & + "inst_tracer_down_surface_flx ", "kg m-2 s-1 ", & + "inst_tracer_clmn_mass_dens ", "g m-2 ", & + "inst_tracer_up_surface_flx ", "kg m-2 s-1 ", & + "inst_tracer_down_surface_flx ", "kg m-2 s-1 ", & + "inst_tracer_clmn_mass_dens ", "g m-2 ", & + "inst_tracer_anth_biom_flx ", "ug m-2 s-1 ", & + "inst_pbl_height ", "m ", & + "surface_cell_area ", "m2 ", & + "inst_convective_rainfall_amount ", "kg m-2 ", & + "inst_exchange_coefficient_heat_levels ", "W m-2 K-1 ", & + "inst_spec_humid_conv_tendency_levels ", "kg kg-1 s-1 ", & + "inst_friction_velocity ", "s-1 ", & + "inst_rainfall_amount ", "kg m-2 ", & + "inst_soil_moisture_content ", "kg m-2 ", & + "inst_up_sensi_heat_flx ", "W m-2 ", & + "inst_lwe_snow_thickness ", "m ", & + "inst_vegetation_area_frac ", "1 ", & + "inst_surface_roughness ", "1 ", & + +! Dummy fields +! ------------ + "dummyfield ", "1 ", & + "dummyfield1 ", "1 ", & + "dummyfield2 ", "1 " & + + /) + ! !----------------------------------------------------------------------- !*********************************************************************** @@ -234,3129 +557,115 @@ SUBROUTINE EARTH_REGISTER(EARTH_GRID_COMP,RC_REG) ! ! Derive from NUOPC_Driver call NUOPC_CompDerive(EARTH_GRID_COMP, Driver_routine_SS, rc=RC) - ESMF_ERR_RETURN(RC,RC_REG) + ESMF_ERR_RETURN(RC, RC_REG) ! specializations: - call NUOPC_CompSpecialize(EARTH_GRID_COMP, & - specLabel=Driver_label_SetModelServices, specRoutine=SetModelServices, & - rc=RC) - ESMF_ERR_RETURN(RC,RC_REG) + call NUOPC_CompSpecialize(EARTH_GRID_COMP, & + specLabel = Driver_label_SetModelServices,& + specRoutine=SetModelServices, rc=RC) + ESMF_ERR_RETURN(RC, RC_REG) - call NUOPC_CompSpecialize(EARTH_GRID_COMP, & - specLabel=Driver_label_SetRunSequence, specRoutine=SetRunSequence, & - rc=RC) - ESMF_ERR_RETURN(RC,RC_REG) + call NUOPC_CompSpecialize(EARTH_GRID_COMP, & + specLabel=Driver_label_SetRunSequence, & + specRoutine=SetRunSequence, rc=RC) + ESMF_ERR_RETURN(RC, RC_REG) ! The NEMS Earth component is currently the top-level driver and ! does not need to coordinate Clocks with its parent. + call ESMF_MethodRemove(EARTH_GRID_COMP, Driver_label_SetRunClock, rc=RC_REG) - ESMF_ERR_RETURN(RC,RC_REG) - call NUOPC_CompSpecialize(EARTH_GRID_COMP, & - specLabel=Driver_label_SetRunClock, specRoutine=NUOPC_NoOp, rc=RC_REG) - ESMF_ERR_RETURN(RC,RC_REG) - - call NUOPC_CompSpecialize(EARTH_GRID_COMP, & - specLabel=Driver_label_Finalize, specRoutine=Finalize, & - rc=RC) - ESMF_ERR_RETURN(RC,RC_REG) + ESMF_ERR_RETURN(RC, RC_REG) + + call NUOPC_CompSpecialize(EARTH_GRID_COMP, & + specLabel=Driver_label_SetRunClock, & + specRoutine=NUOPC_NoOp, rc=RC_REG) + ESMF_ERR_RETURN(RC, RC_REG) + call NUOPC_CompSpecialize(EARTH_GRID_COMP, & + specLabel=Driver_label_Finalize, & + specRoutine=Finalize, rc=RC) + ESMF_ERR_RETURN(RC, RC_REG) + ! register an internal initialization method call NUOPC_CompSetInternalEntryPoint(EARTH_GRID_COMP, ESMF_METHOD_INITIALIZE, & - phaseLabelList=(/"IPDv04p2"/), userRoutine=ModifyCplLists, rc=rc) - ESMF_ERR_RETURN(RC,RC_REG) + phaseLabelList=(/"IPDv04p2"/), & + userRoutine=ModifyCplLists, rc=rc) + ESMF_ERR_RETURN(RC, RC_REG) ! create, open, and set the config config = ESMF_ConfigCreate(rc=RC) - ESMF_ERR_RETURN(RC,RC_REG) + ESMF_ERR_RETURN(RC, RC_REG) call ESMF_ConfigLoadFile(config, "nems.configure", rc=RC) - ESMF_ERR_RETURN(RC,RC_REG) + ESMF_ERR_RETURN(RC, RC_REG) call ESMF_GridCompSet(EARTH_GRID_COMP, config=config, rc=RC) - ESMF_ERR_RETURN(RC,RC_REG) + ESMF_ERR_RETURN(RC, RC_REG) ! Added the following Field Dictionary block to the EARTH component level ! in order to prevent different dictionary definitions in the lower ! components. Doing this here isn't without problems because it ! potentially makes the components (ATM & OCN) depend on this environment, ! which lowers their transferability to other coupled systems. However, - ! extending the Field Dictionary is a temporary solution anyway (see the - ! TODO: below), so this isn't going to stay for ever this way. - - ! Extend the NUOPC Field Dictionary to hold required entries. - !TODO: In the long run this section will not be needed when we have - !TODO: absorbed the needed standard names into the default dictionary. - ! -> 20 fields identified as exports by the GSM component -#ifdef CMEPS - call NUOPC_FieldDictionarySetup("fd_nems.yaml", rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out -#else - if (.not.NUOPC_FieldDictionaryHasEntry( & - "air_density_height_lowest")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="air_density_height_lowest", & - canonicalUnits="kg m-3", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not.NUOPC_FieldDictionaryHasEntry( & - "mean_zonal_moment_flx")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="mean_zonal_moment_flx", & - canonicalUnits="N m-2", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not.NUOPC_FieldDictionaryHasEntry( & - "mean_zonal_moment_flx_atm")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="mean_zonal_moment_flx_atm", & - canonicalUnits="N m-2", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not.NUOPC_FieldDictionaryHasEntry( & - "mean_merid_moment_flx")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="mean_merid_moment_flx", & - canonicalUnits="N m-2", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not.NUOPC_FieldDictionaryHasEntry( & - "mean_merid_moment_flx_atm")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="mean_merid_moment_flx_atm", & - canonicalUnits="N m-2", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not.NUOPC_FieldDictionaryHasEntry( & - "mean_sensi_heat_flx")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="mean_sensi_heat_flx", & - canonicalUnits="W m-2", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not.NUOPC_FieldDictionaryHasEntry( & - "mean_sensi_heat_flx_atm")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="mean_sensi_heat_flx_atm", & - canonicalUnits="W m-2", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not.NUOPC_FieldDictionaryHasEntry( & - "mean_sensi_heat_flx_atm_into_ice")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="mean_sensi_heat_flx_atm_into_ice", & - canonicalUnits="W m-2", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not.NUOPC_FieldDictionaryHasEntry( & - "mean_sensi_heat_flx_atm_into_ocn")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="mean_sensi_heat_flx_atm_into_ocn", & - canonicalUnits="W m-2", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not.NUOPC_FieldDictionaryHasEntry( & - "mean_laten_heat_flx")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="mean_laten_heat_flx", & - canonicalUnits="W m-2", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not.NUOPC_FieldDictionaryHasEntry( & - "mean_laten_heat_flx_atm")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="mean_laten_heat_flx_atm", & - canonicalUnits="W m-2", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not.NUOPC_FieldDictionaryHasEntry( & - "mean_laten_heat_flx_atm_into_ice")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="mean_laten_heat_flx_atm_into_ice", & - canonicalUnits="W m-2", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not.NUOPC_FieldDictionaryHasEntry( & - "mean_laten_heat_flx_atm_into_ocn")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="mean_laten_heat_flx_atm_into_ocn", & - canonicalUnits="W m-2", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not.NUOPC_FieldDictionaryHasEntry( & - "mean_down_lw_flx")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="mean_down_lw_flx", & - canonicalUnits="W m-2", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not.NUOPC_FieldDictionaryHasEntry( & - "mean_down_sw_flx")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="mean_down_sw_flx", & - canonicalUnits="W m-2", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not.NUOPC_FieldDictionaryHasEntry( & - "mean_fprec_rate")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="mean_fprec_rate", & - canonicalUnits="kg s m-2", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not.NUOPC_FieldDictionaryHasEntry( & - "mean_prec_rate")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="mean_prec_rate", & - canonicalUnits="kg s m-2", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not.NUOPC_FieldDictionaryHasEntry( & - "mean_evap_rate")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="mean_evap_rate", & - canonicalUnits="kg s m-2", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not.NUOPC_FieldDictionaryHasEntry( & - "mean_evap_rate_atm_into_ice")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="mean_evap_rate_atm_into_ice", & - canonicalUnits="kg s m-2", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not.NUOPC_FieldDictionaryHasEntry( & - "mean_evap_rate_atm_into_ocn")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="mean_evap_rate_atm_into_ocn", & - canonicalUnits="kg s m-2", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not.NUOPC_FieldDictionaryHasEntry( & - "inst_zonal_moment_flx")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="inst_zonal_moment_flx", & - canonicalUnits="N m-2", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not.NUOPC_FieldDictionaryHasEntry( & - "inst_merid_moment_flx")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="inst_merid_moment_flx", & - canonicalUnits="N m-2", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not.NUOPC_FieldDictionaryHasEntry( & - "inst_sensi_heat_flx")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="inst_sensi_heat_flx", & - canonicalUnits="W m-2", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not.NUOPC_FieldDictionaryHasEntry( & - "inst_laten_heat_flx")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="inst_laten_heat_flx", & - canonicalUnits="W m-2", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not.NUOPC_FieldDictionaryHasEntry( & - "inst_down_lw_flx")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="inst_down_lw_flx", & - canonicalUnits="W m-2", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not.NUOPC_FieldDictionaryHasEntry( & - "inst_down_sw_flx")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="inst_down_sw_flx", & - canonicalUnits="W m-2", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not.NUOPC_FieldDictionaryHasEntry( & - "inst_temp_height2m")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="inst_temp_height2m", & - canonicalUnits="K", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not.NUOPC_FieldDictionaryHasEntry( & - "inst_spec_humid_height2m")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="inst_spec_humid_height2m", & - canonicalUnits="kg kg-1", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not.NUOPC_FieldDictionaryHasEntry( & - "inst_u_wind_height10m")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="inst_u_wind_height10m", & - canonicalUnits="m s-1", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not.NUOPC_FieldDictionaryHasEntry( & - "inst_v_wind_height10m")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="inst_v_wind_height10m", & - canonicalUnits="m s-1", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not.NUOPC_FieldDictionaryHasEntry( & - "inst_zonal_wind_height10m")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="inst_zonal_wind_height10m", & - canonicalUnits="m s-1", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not.NUOPC_FieldDictionaryHasEntry( & - "inst_merid_wind_height10m")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="inst_merid_wind_height10m", & - canonicalUnits="m s-1", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - - !For MOM6 and WW3 variables to match: - if (.not.NUOPC_FieldDictionaryHasEntry( & - "eastward_partitioned_stokes_drift_1")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="eastward_partitioned_stokes_drift_1", & - canonicalUnits="m s-1", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - - if (.not.NUOPC_FieldDictionaryHasEntry( & - "northward_partitioned_stokes_drift_1")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="northward_partitioned_stokes_drift_1", & - canonicalUnits="m s-1", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - - if (.not.NUOPC_FieldDictionaryHasEntry( & - "eastward_partitioned_stokes_drift_2")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="eastward_partitioned_stokes_drift_2", & - canonicalUnits="m s-1", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - - if (.not.NUOPC_FieldDictionaryHasEntry( & - "northward_partitioned_stokes_drift_2")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="northward_partitioned_stokes_drift_2", & - canonicalUnits="m s-1", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - - - - if (.not.NUOPC_FieldDictionaryHasEntry( & - "eastward_partitioned_stokes_drift_3")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="eastward_partitioned_stokes_drift_3", & - canonicalUnits="m s-1", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - - if (.not.NUOPC_FieldDictionaryHasEntry( & - "northward_partitioned_stokes_drift_3")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="northward_partitioned_stokes_drift_3", & - canonicalUnits="m s-1", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - ! end of MOM6 and WW3 variables to match - - if (.not.NUOPC_FieldDictionaryHasEntry( & - "inst_temp_height_surface")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="inst_temp_height_surface", & - canonicalUnits="K", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not.NUOPC_FieldDictionaryHasEntry( & - "inst_pres_height_surface")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="inst_pres_height_surface", & - canonicalUnits="Pa", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not.NUOPC_FieldDictionaryHasEntry( & - "inst_surface_height")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="inst_surface_height", & - canonicalUnits="m", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - ! -> Additional fields identified as needed by MOM5 and others... - if (.not. NUOPC_FieldDictionaryHasEntry( & - "mean_down_sw_vis_dir_flx")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="mean_down_sw_vis_dir_flx", & - canonicalUnits="W m-2", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not. NUOPC_FieldDictionaryHasEntry( & - "mean_down_sw_vis_dif_flx")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="mean_down_sw_vis_dif_flx", & - canonicalUnits="W m-2", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not. NUOPC_FieldDictionaryHasEntry( & - "mean_down_sw_ir_dir_flx")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="mean_down_sw_ir_dir_flx", & - canonicalUnits="W m-2", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not. NUOPC_FieldDictionaryHasEntry( & - "mean_down_sw_ir_dif_flx")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="mean_down_sw_ir_dif_flx", & - canonicalUnits="W m-2", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not. NUOPC_FieldDictionaryHasEntry( & - "inst_down_sw_vis_dir_flx")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="inst_down_sw_vis_dir_flx", & - canonicalUnits="W m-2", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not. NUOPC_FieldDictionaryHasEntry( & - "inst_down_sw_vis_dif_flx")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="inst_down_sw_vis_dif_flx", & - canonicalUnits="W m-2", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not. NUOPC_FieldDictionaryHasEntry( & - "inst_down_sw_ir_dir_flx")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="inst_down_sw_ir_dir_flx", & - canonicalUnits="W m-2", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not. NUOPC_FieldDictionaryHasEntry( & - "inst_down_sw_ir_dif_flx")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="inst_down_sw_ir_dif_flx", & - canonicalUnits="W m-2", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not. NUOPC_FieldDictionaryHasEntry( & - "mean_net_sw_vis_dir_flx")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="mean_net_sw_vis_dir_flx", & - canonicalUnits="W m-2", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not. NUOPC_FieldDictionaryHasEntry( & - "mean_net_sw_vis_dif_flx")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="mean_net_sw_vis_dif_flx", & - canonicalUnits="W m-2", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not. NUOPC_FieldDictionaryHasEntry( & - "mean_net_sw_ir_dir_flx")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="mean_net_sw_ir_dir_flx", & - canonicalUnits="W m-2", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not. NUOPC_FieldDictionaryHasEntry( & - "mean_net_sw_ir_dif_flx")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="mean_net_sw_ir_dif_flx", & - canonicalUnits="W m-2", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not. NUOPC_FieldDictionaryHasEntry( & - "inst_net_sw_vis_dir_flx")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="inst_net_sw_vis_dir_flx", & - canonicalUnits="W m-2", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not. NUOPC_FieldDictionaryHasEntry( & - "inst_net_sw_vis_dif_flx")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="inst_net_sw_vis_dif_flx", & - canonicalUnits="W m-2", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not. NUOPC_FieldDictionaryHasEntry( & - "inst_net_sw_ir_dir_flx")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="inst_net_sw_ir_dir_flx", & - canonicalUnits="W m-2", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not. NUOPC_FieldDictionaryHasEntry( & - "inst_net_sw_ir_dif_flx")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="inst_net_sw_ir_dif_flx", & - canonicalUnits="W m-2", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not. NUOPC_FieldDictionaryHasEntry( & - "mean_salt_rate")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="mean_salt_rate", & - canonicalUnits="kg psu m-2 s", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not. NUOPC_FieldDictionaryHasEntry( & - "mean_runoff_rate")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="mean_runoff_rate", & - canonicalUnits="kg m-2 s", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not. NUOPC_FieldDictionaryHasEntry( & - "mean_calving_rate")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="mean_calving_rate", & - canonicalUnits="kg m-2 s", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not. NUOPC_FieldDictionaryHasEntry( & - "mean_runoff_heat_flx")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="mean_runoff_heat_flx", & - canonicalUnits="W m-2", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not. NUOPC_FieldDictionaryHasEntry( & - "mean_calving_heat_flx")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="mean_calving_heat_flx", & - canonicalUnits="W m-2", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not. NUOPC_FieldDictionaryHasEntry( & - "ice_fraction")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="ice_fraction", & - canonicalUnits="1", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not. NUOPC_FieldDictionaryHasEntry( & - "mean_sw_pen_to_ocn")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="mean_sw_pen_to_ocn", & - canonicalUnits="W m-2", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not. NUOPC_FieldDictionaryHasEntry( & - "mean_up_lw_flx")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="mean_up_lw_flx", & - canonicalUnits="W m-2", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not. NUOPC_FieldDictionaryHasEntry( & - "mass_of_overlying_sea_ice")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="mass_of_overlying_sea_ice", & - canonicalUnits="kg", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not. NUOPC_FieldDictionaryHasEntry( & - "s_surf")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="s_surf", & - canonicalUnits="psu", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not. NUOPC_FieldDictionaryHasEntry( & - "freezing_melting_potential")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="freezing_melting_potential", & - canonicalUnits="W m-2", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - ! following two added for export from MOM6 - if (.not. NUOPC_FieldDictionaryHasEntry( & - "accum_heat_frazil")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="accum_heat_frazil", & - canonicalUnits="W m-2", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not. NUOPC_FieldDictionaryHasEntry( & - "inst_melt_potential")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="inst_melt_potential", & - canonicalUnits="W m-2", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not. NUOPC_FieldDictionaryHasEntry( & - "u_surf")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="u_surf", & - canonicalUnits="m s-1", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not. NUOPC_FieldDictionaryHasEntry( & - "v_surf")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="v_surf", & - canonicalUnits="m s-1", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not. NUOPC_FieldDictionaryHasEntry( & - "sea_lev")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="sea_lev", & - canonicalUnits="m", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not. NUOPC_FieldDictionaryHasEntry( & - "wind_stress_zonal")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="wind_stress_zonal", & - canonicalUnits="N m-2", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not. NUOPC_FieldDictionaryHasEntry( & - "wind_stress_merid")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="wind_stress_merid", & - canonicalUnits="N m-2", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not. NUOPC_FieldDictionaryHasEntry( & - "ocn_current_zonal")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="ocn_current_zonal", & - canonicalUnits="m s-1", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not. NUOPC_FieldDictionaryHasEntry( & - "ocn_current_merid")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="ocn_current_merid", & - canonicalUnits="m s-1", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not. NUOPC_FieldDictionaryHasEntry( & - "ocn_current_idir")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="ocn_current_idir", & - canonicalUnits="m s-1", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not. NUOPC_FieldDictionaryHasEntry( & - "ocn_current_jdir")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="ocn_current_jdir", & - canonicalUnits="m s-1", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not. NUOPC_FieldDictionaryHasEntry( & - "sea_surface_slope_zonal")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="sea_surface_slope_zonal", & - canonicalUnits="m m-1", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not. NUOPC_FieldDictionaryHasEntry( & - "sea_surface_slope_merid")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="sea_surface_slope_merid", & - canonicalUnits="m m-1", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not. NUOPC_FieldDictionaryHasEntry( & - "sea_surface_slope_zonal")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="sea_surface_slope_zonal", & - canonicalUnits="m m-1", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not. NUOPC_FieldDictionaryHasEntry( & - "sea_surface_slope_merid")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="sea_surface_slope_merid", & - canonicalUnits="m m-1", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not. NUOPC_FieldDictionaryHasEntry( & - "stress_on_air_ice_zonal")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="stress_on_air_ice_zonal", & - canonicalUnits="N m-2", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not. NUOPC_FieldDictionaryHasEntry( & - "stress_on_air_ice_merid")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="stress_on_air_ice_merid", & - canonicalUnits="N m-2", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not. NUOPC_FieldDictionaryHasEntry( & - "stress_on_air_ocn_zonal")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="stress_on_air_ocn_zonal", & - canonicalUnits="N m-2", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not. NUOPC_FieldDictionaryHasEntry( & - "stress_on_air_ocn_merid")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="stress_on_air_ocn_merid", & - canonicalUnits="N m-2", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not. NUOPC_FieldDictionaryHasEntry( & - "stress_on_ocn_ice_zonal")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="stress_on_ocn_ice_zonal", & - canonicalUnits="N m-2", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not. NUOPC_FieldDictionaryHasEntry( & - "stress_on_ocn_ice_merid")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="stress_on_ocn_ice_merid", & - canonicalUnits="N m-2", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not. NUOPC_FieldDictionaryHasEntry( & - "stress_on_ocn_ice_idir")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="stress_on_ocn_ice_idir", & - canonicalUnits="N m-2", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not. NUOPC_FieldDictionaryHasEntry( & - "stress_on_ocn_ice_jdir")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="stress_on_ocn_ice_jdir", & - canonicalUnits="N m-2", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not. NUOPC_FieldDictionaryHasEntry( & - "mixed_layer_depth")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="mixed_layer_depth", & - canonicalUnits="m", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not. NUOPC_FieldDictionaryHasEntry( & - "mean_net_lw_flx")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="mean_net_lw_flx", & - canonicalUnits="W m-2", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not. NUOPC_FieldDictionaryHasEntry( & - "mean_net_lw_flx_atm")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="mean_net_lw_flx_atm", & - canonicalUnits="W m-2", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not. NUOPC_FieldDictionaryHasEntry( & - "mean_net_sw_flx")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="mean_net_sw_flx", & - canonicalUnits="W m-2", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not. NUOPC_FieldDictionaryHasEntry( & - "mean_up_lw_flx_ice")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="mean_up_lw_flx_ice", & - canonicalUnits="W m-2", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not. NUOPC_FieldDictionaryHasEntry( & - "mean_up_lw_flx_ocn")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="mean_up_lw_flx_ocn", & - canonicalUnits="W m-2", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not. NUOPC_FieldDictionaryHasEntry( & - "inst_net_lw_flx")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="inst_net_lw_flx", & - canonicalUnits="W m-2", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not. NUOPC_FieldDictionaryHasEntry( & - "inst_net_sw_flx")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="inst_net_sw_flx", & - canonicalUnits="W m-2", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not. NUOPC_FieldDictionaryHasEntry( & - "mean_sw_pen_to_ocn_vis_dir_flx")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="mean_sw_pen_to_ocn_vis_dir_flx", & - canonicalUnits="W m-2", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not. NUOPC_FieldDictionaryHasEntry( & - "mean_sw_pen_to_ocn_vis_dif_flx")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="mean_sw_pen_to_ocn_vis_dif_flx", & - canonicalUnits="W m-2", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not. NUOPC_FieldDictionaryHasEntry( & - "mean_sw_pen_to_ocn_ir_dir_flx")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="mean_sw_pen_to_ocn_ir_dir_flx", & - canonicalUnits="W m-2", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not. NUOPC_FieldDictionaryHasEntry( & - "mean_sw_pen_to_ocn_ir_dif_flx")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="mean_sw_pen_to_ocn_ir_dif_flx", & - canonicalUnits="W m-2", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not. NUOPC_FieldDictionaryHasEntry( & - "inst_ir_dir_albedo")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="inst_ir_dir_albedo", & - canonicalUnits="1", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not. NUOPC_FieldDictionaryHasEntry( & - "inst_ir_dif_albedo")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="inst_ir_dif_albedo", & - canonicalUnits="1", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not. NUOPC_FieldDictionaryHasEntry( & - "inst_vis_dir_albedo")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="inst_vis_dir_albedo", & - canonicalUnits="1", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not. NUOPC_FieldDictionaryHasEntry( & - "inst_vis_dif_albedo")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="inst_vis_dif_albedo", & - canonicalUnits="1", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not. NUOPC_FieldDictionaryHasEntry( & - "inst_ocn_ir_dir_albedo")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="inst_ocn_ir_dir_albedo", & - canonicalUnits="1", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not. NUOPC_FieldDictionaryHasEntry( & - "inst_ocn_ir_dif_albedo")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="inst_ocn_ir_dif_albedo", & - canonicalUnits="1", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not. NUOPC_FieldDictionaryHasEntry( & - "inst_ocn_vis_dir_albedo")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="inst_ocn_vis_dir_albedo", & - canonicalUnits="1", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not. NUOPC_FieldDictionaryHasEntry( & - "inst_ocn_vis_dif_albedo")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="inst_ocn_vis_dif_albedo", & - canonicalUnits="1", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not. NUOPC_FieldDictionaryHasEntry( & - "inst_ice_ir_dir_albedo")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="inst_ice_ir_dir_albedo", & - canonicalUnits="1", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not. NUOPC_FieldDictionaryHasEntry( & - "inst_ice_ir_dif_albedo")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="inst_ice_ir_dif_albedo", & - canonicalUnits="1", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not. NUOPC_FieldDictionaryHasEntry( & - "inst_ice_vis_dir_albedo")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="inst_ice_vis_dir_albedo", & - canonicalUnits="1", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not. NUOPC_FieldDictionaryHasEntry( & - "inst_ice_vis_dif_albedo")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="inst_ice_vis_dif_albedo", & - canonicalUnits="1", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not. NUOPC_FieldDictionaryHasEntry( & - "inst_land_sea_mask")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="inst_land_sea_mask", & - canonicalUnits="1", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not. NUOPC_FieldDictionaryHasEntry( & - "inst_temp_height_lowest")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="inst_temp_height_lowest", & - canonicalUnits="K", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not. NUOPC_FieldDictionaryHasEntry( & - "inst_spec_humid_height_lowest")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="inst_spec_humid_height_lowest", & - canonicalUnits="kg kg-1", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not. NUOPC_FieldDictionaryHasEntry( & - "humidity_2m")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="humidity_2m", & - canonicalUnits="kg kg-1", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not. NUOPC_FieldDictionaryHasEntry( & - "inst_zonal_wind_height_lowest")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="inst_zonal_wind_height_lowest", & - canonicalUnits="m s-1", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not. NUOPC_FieldDictionaryHasEntry( & - "inst_merid_wind_height_lowest")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="inst_merid_wind_height_lowest", & - canonicalUnits="m s-1", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not. NUOPC_FieldDictionaryHasEntry( & - "inst_pres_height_lowest")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="inst_pres_height_lowest", & - canonicalUnits="Pa", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not. NUOPC_FieldDictionaryHasEntry( & - "inst_height_lowest")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="inst_height_lowest", & - canonicalUnits="m", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not. NUOPC_FieldDictionaryHasEntry( & - "ocean_mask")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="ocean_mask", & - canonicalUnits="1", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not. NUOPC_FieldDictionaryHasEntry( & - "ice_mask")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="ice_mask", & - canonicalUnits="1", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not. NUOPC_FieldDictionaryHasEntry( & - "land_mask")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="land_mask", & - canonicalUnits="1", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - ! special HYCOM exports - if (.not. NUOPC_FieldDictionaryHasEntry( & - "surface_downward_eastward_stress")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="surface_downward_eastward_stress", & - canonicalUnits="Pa", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not. NUOPC_FieldDictionaryHasEntry( & - "surface_downward_northward_stress")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="surface_downward_northward_stress", & - canonicalUnits="Pa", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not. NUOPC_FieldDictionaryHasEntry( & - "wind_speed_height10m")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="wind_speed_height10m", & - canonicalUnits="m s-1", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not. NUOPC_FieldDictionaryHasEntry( & - "wind_speed_squared_10m")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="wind_speed_squared_10m", & - canonicalUnits="m2 s-2", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not. NUOPC_FieldDictionaryHasEntry( & - "friction_speed")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="friction_speed", & - canonicalUnits="m s-1", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not. NUOPC_FieldDictionaryHasEntry( & - "mean_lat_flx")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="mean_lat_flx", & - canonicalUnits="W m-2", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not. NUOPC_FieldDictionaryHasEntry( & - "mean_sens_flx")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="mean_sens_flx", & - canonicalUnits="W m-2", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not. NUOPC_FieldDictionaryHasEntry( & - "water_flux_into_sea_water")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="water_flux_into_sea_water", & - canonicalUnits="kg m-2 s-1", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not. NUOPC_FieldDictionaryHasEntry( & - "frozen_water_flux_into_sea_water")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="frozen_water_flux_into_sea_water", & - canonicalUnits="kg m-2 s-1", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not. NUOPC_FieldDictionaryHasEntry( & - "surface_temperature")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="surface_temperature", & - canonicalUnits="K", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not. NUOPC_FieldDictionaryHasEntry( & - "air_surface_temperature")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="air_surface_temperature", & - canonicalUnits="K", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not. NUOPC_FieldDictionaryHasEntry( & - "temperature_2m")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="temperature_2m", & - canonicalUnits="K", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not. NUOPC_FieldDictionaryHasEntry( & - "upward_sea_ice_basal_available_heat_flux")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="upward_sea_ice_basal_available_heat_flux", & - canonicalUnits="W m-2", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - ! special HYCOM imports - if (.not. NUOPC_FieldDictionaryHasEntry( & - "sea_ice_area_fraction")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="sea_ice_area_fraction", & - canonicalUnits="1", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not. NUOPC_FieldDictionaryHasEntry( & - "downward_x_stress_at_sea_ice_base")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="downward_x_stress_at_sea_ice_base", & - canonicalUnits="Pa", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not. NUOPC_FieldDictionaryHasEntry( & - "downward_y_stress_at_sea_ice_base")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="downward_y_stress_at_sea_ice_base", & - canonicalUnits="Pa", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not. NUOPC_FieldDictionaryHasEntry( & - "downward_sea_ice_basal_solar_heat_flux")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="downward_sea_ice_basal_solar_heat_flux", & - canonicalUnits="W m-2", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not. NUOPC_FieldDictionaryHasEntry( & - "upward_sea_ice_basal_heat_flux")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="upward_sea_ice_basal_heat_flux", & - canonicalUnits="W m-2", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not. NUOPC_FieldDictionaryHasEntry( & - "downward_sea_ice_basal_salt_flux")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="downward_sea_ice_basal_salt_flux", & - canonicalUnits="kg m-2 s-1", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not. NUOPC_FieldDictionaryHasEntry( & - "downward_sea_ice_basal_water_flux")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="downward_sea_ice_basal_water_flux", & - canonicalUnits="kg m-2 s-1", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not. NUOPC_FieldDictionaryHasEntry( & - "sea_ice_surface_temperature")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="sea_ice_surface_temperature", & - canonicalUnits="K", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not. NUOPC_FieldDictionaryHasEntry( & - "sea_ice_temperature")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="sea_ice_temperature", & - canonicalUnits="K", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not. NUOPC_FieldDictionaryHasEntry( & - "sea_ice_thickness")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="sea_ice_thickness", & - canonicalUnits="m", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not. NUOPC_FieldDictionaryHasEntry( & - "sea_ice_x_velocity")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="sea_ice_x_velocity", & - canonicalUnits="m s-1", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not. NUOPC_FieldDictionaryHasEntry( & - "sea_ice_y_velocity")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="sea_ice_y_velocity", & - canonicalUnits="m s-1", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - - if (.not. NUOPC_FieldDictionaryHasEntry( & - "net_heat_flx_to_ocn")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="net_heat_flx_to_ocn", & - canonicalUnits="W m-2", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not. NUOPC_FieldDictionaryHasEntry( & - "mean_fresh_water_to_ocean_rate")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="mean_fresh_water_to_ocean_rate", & - canonicalUnits="kg m-2 s-1", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not. NUOPC_FieldDictionaryHasEntry( & - "mean_ice_volume")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="mean_ice_volume", & - canonicalUnits="m", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not. NUOPC_FieldDictionaryHasEntry( & - "mean_snow_volume")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="mean_snow_volume", & - canonicalUnits="m", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - - !Mass flux of liquid runoff - if (.not. NUOPC_FieldDictionaryHasEntry( & - "Foxx_rofl")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="Foxx_rofl", & - canonicalUnits="kg m-2 s-1", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - !Mass flux of frozen runoff - if (.not. NUOPC_FieldDictionaryHasEntry( & - "Foxx_rofi")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="Foxx_rofi", & - canonicalUnits="kg m-2 s-1", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - !Ocean surface boundary layer depth - if (.not. NUOPC_FieldDictionaryHasEntry( & - "So_bldepth")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="So_bldepth", & - canonicalUnits="m", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - - ! Synonyms for HYCOM fields - call NUOPC_FieldDictionarySetSyno( & - standardNames = (/"surface_downward_eastward_stress",& - "mean_zonal_moment_flx "/), rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - call NUOPC_FieldDictionarySetSyno( & - standardNames = (/"surface_downward_northward_stress",& - "mean_merid_moment_flx "/), rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - call NUOPC_FieldDictionarySetSyno( & - standardNames = (/"mean_lat_flx ",& - "mean_laten_heat_flx"/), rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - call NUOPC_FieldDictionarySetSyno( & - standardNames = (/"mean_sens_flx ",& - "mean_sensi_heat_flx"/), rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - - ! DCR - Fields added for Regional Application - ! ATM-OCN-ICE-LND-HYD - ! List of exisitng fields - ! ice_mask, inst_down_lw_flx, inst_down_sw_flx, inst_height_lowest, - ! inst_merid_wind_height_lowest, inst_pres_height_lowest, - ! inst_pres_height_surface, inst_spec_humid_height_lowest, - ! inst_temp_height_lowest, inst_temp_height_surface, - ! inst_zonal_wind_height_lowest, mean_down_lw_flx, mean_down_sw_flx, - ! mean_fprec_rate, mean_laten_heat_flx, mean_net_lw_flx, mean_net_sw_flx, - ! mean_prec_rate, mean_sensi_heat_flx - - if (.not.NUOPC_FieldDictionaryHasEntry( & - "aerodynamic_roughness_length")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="aerodynamic_roughness_length", & - canonicalUnits="m", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not.NUOPC_FieldDictionaryHasEntry( & - "canopy_moisture_storage")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="canopy_moisture_storage", & - canonicalUnits="kg m-2", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not.NUOPC_FieldDictionaryHasEntry( & - "carbon_dioxide")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="carbon_dioxide", & - canonicalUnits="ppmv", & ! Units must be clarified - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not.NUOPC_FieldDictionaryHasEntry( & - "cosine_zenith_angle")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="cosine_zenith_angle", & - canonicalUnits="degree", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not.NUOPC_FieldDictionaryHasEntry( & - "exchange_coefficient_heat")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="exchange_coefficient_heat", & - canonicalUnits="W m-2 K-1", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not.NUOPC_FieldDictionaryHasEntry( & - "exchange_coefficient_heat_height2m")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="exchange_coefficient_heat_height2m", & - canonicalUnits="W m-2 K-1", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not.NUOPC_FieldDictionaryHasEntry( & - "exchange_coefficient_moisture_height2m")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="exchange_coefficient_moisture_height2m", & - canonicalUnits="kg m-2 s-1 Pa-1", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not.NUOPC_FieldDictionaryHasEntry( & - "inst_wind_speed_height_lowest")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="inst_wind_speed_height_lowest", & - canonicalUnits="m s-1", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not.NUOPC_FieldDictionaryHasEntry( & - "mean_cprec_rate")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="mean_cprec_rate", & - canonicalUnits="kg m-2 s-1", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not.NUOPC_FieldDictionaryHasEntry( & - "mean_grnd_sensi_heat_flx")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="mean_grnd_sensi_heat_flx", & - canonicalUnits="W m-2", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not.NUOPC_FieldDictionaryHasEntry( & - "mean_laten_heat_flx_kinematic")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="mean_laten_heat_flx_kinematic", & - canonicalUnits="Kg m-2 s-1", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not.NUOPC_FieldDictionaryHasEntry( & - "mean_surface_albedo")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="mean_surface_albedo", & - canonicalUnits="1", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not.NUOPC_FieldDictionaryHasEntry( & - "mean_surface_skin_temp")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="mean_surface_skin_temp", & - canonicalUnits="K", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not.NUOPC_FieldDictionaryHasEntry( & - "mixing_ratio_surface")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="mixing_ratio_surface", & - canonicalUnits="kg kg-1", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not.NUOPC_FieldDictionaryHasEntry( & - "root_moisture")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="root_moisture", & - canonicalUnits="kg m-2", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not.NUOPC_FieldDictionaryHasEntry( & - "saturated_mixing_ratio")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="saturated_mixing_ratio", & - canonicalUnits="kg kg-1", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not.NUOPC_FieldDictionaryHasEntry( & - "surface_snow_area_fraction")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="surface_snow_area_fraction", & - canonicalUnits="1", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not.NUOPC_FieldDictionaryHasEntry( & - "surface_snow_thickness")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="surface_snow_thickness", & - canonicalUnits="m", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not.NUOPC_FieldDictionaryHasEntry( & - "surface_snow_melt_flux")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="surface_snow_melt_flux", & - canonicalUnits="kg m-2 s-1", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not.NUOPC_FieldDictionaryHasEntry( & - "liquid_water_content_of_surface_snow")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="liquid_water_content_of_surface_snow", & - canonicalUnits="kg m-2", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not.NUOPC_FieldDictionaryHasEntry( & - "soil_depth")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="soil_depth", & - canonicalUnits="m", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not.NUOPC_FieldDictionaryHasEntry( & - "soil_hydraulic_conductivity_at_saturation")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="soil_hydraulic_conductivity_at_saturation", & - canonicalUnits="m s-1", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not.NUOPC_FieldDictionaryHasEntry( & - "moisture_content_of_soil_layer")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="moisture_content_of_soil_layer", & - canonicalUnits="kg m-2", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not.NUOPC_FieldDictionaryHasEntry( & - "moisture_content_of_soil_layer_1")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="moisture_content_of_soil_layer_1", & - canonicalUnits="kg m-2", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not.NUOPC_FieldDictionaryHasEntry( & - "moisture_content_of_soil_layer_2")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="moisture_content_of_soil_layer_2", & - canonicalUnits="kg m-2", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not.NUOPC_FieldDictionaryHasEntry( & - "moisture_content_of_soil_layer_3")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="moisture_content_of_soil_layer_3", & - canonicalUnits="kg m-2", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not.NUOPC_FieldDictionaryHasEntry( & - "moisture_content_of_soil_layer_4")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="moisture_content_of_soil_layer_4", & - canonicalUnits="kg m-2", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not.NUOPC_FieldDictionaryHasEntry( & - "soil_porosity")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="soil_porosity", & - canonicalUnits="1", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not.NUOPC_FieldDictionaryHasEntry( & - "temperature_of_soil_layer")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="temperature_of_soil_layer", & - canonicalUnits="K", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not.NUOPC_FieldDictionaryHasEntry( & - "temperature_of_soil_layer_1")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="temperature_of_soil_layer_1", & - canonicalUnits="K", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not.NUOPC_FieldDictionaryHasEntry( & - "temperature_of_soil_layer_2")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="temperature_of_soil_layer_2", & - canonicalUnits="K", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not.NUOPC_FieldDictionaryHasEntry( & - "temperature_of_soil_layer_3")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="temperature_of_soil_layer_3", & - canonicalUnits="K", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not.NUOPC_FieldDictionaryHasEntry( & - "temperature_of_soil_layer_4")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="temperature_of_soil_layer_4", & - canonicalUnits="K", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not.NUOPC_FieldDictionaryHasEntry( & - "soil_temperature_bottom")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="soil_temperature_bottom", & - canonicalUnits="K", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not.NUOPC_FieldDictionaryHasEntry( & - "soil_type")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="soil_type", & - canonicalUnits="1", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not.NUOPC_FieldDictionaryHasEntry( & - "soil_moisture_content")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="soil_moisture_content", & - canonicalUnits="kg m-2", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not.NUOPC_FieldDictionaryHasEntry( & - "subsurface_basin_mask")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="subsurface_basin_mask", & - canonicalUnits="1", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not.NUOPC_FieldDictionaryHasEntry( & - "subsurface_runoff_flux")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="subsurface_runoff_flux", & - canonicalUnits="kg m-2 s-1", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not.NUOPC_FieldDictionaryHasEntry( & - "surface_microwave_emissivity")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="surface_microwave_emissivity", & - canonicalUnits="1", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not.NUOPC_FieldDictionaryHasEntry( & - "surface_runoff_flux")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="surface_runoff_flux", & - canonicalUnits="kg m-2 s-1", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not.NUOPC_FieldDictionaryHasEntry( & - "vegetation_type")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="vegetation_type", & - canonicalUnits="1", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not.NUOPC_FieldDictionaryHasEntry( & - "volume_fraction_of_frozen_water_in_soil")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="volume_fraction_of_frozen_water_in_soil", & - canonicalUnits="m3 m-3", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not.NUOPC_FieldDictionaryHasEntry( & - "liquid_water_content_of_soil_layer")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="liquid_water_content_of_soil_layer", & - canonicalUnits="kg m-2", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not.NUOPC_FieldDictionaryHasEntry( & - "liquid_water_content_of_soil_layer_1")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="liquid_water_content_of_soil_layer_1", & - canonicalUnits="kg m-2", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not.NUOPC_FieldDictionaryHasEntry( & - "liquid_water_content_of_soil_layer_2")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="liquid_water_content_of_soil_layer_2", & - canonicalUnits="kg m-2", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not.NUOPC_FieldDictionaryHasEntry( & - "liquid_water_content_of_soil_layer_3")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="liquid_water_content_of_soil_layer_3", & - canonicalUnits="kg m-2", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not.NUOPC_FieldDictionaryHasEntry( & - "liquid_water_content_of_soil_layer_4")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="liquid_water_content_of_soil_layer_4", & - canonicalUnits="kg m-2", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not.NUOPC_FieldDictionaryHasEntry( & - "volume_fraction_of_total_water_in_soil")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="volume_fraction_of_total_water_in_soil", & - canonicalUnits="m3 m-3", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not.NUOPC_FieldDictionaryHasEntry( & - "volume_fraction_of_total_water_in_soil_at_critical_point")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="volume_fraction_of_total_water_in_soil_at_critical_point", & - canonicalUnits="m3 m-3", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not.NUOPC_FieldDictionaryHasEntry( & - "volume_fraction_of_total_water_in_soil_at_field_capacity")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="volume_fraction_of_total_water_in_soil_at_field_capacity", & - canonicalUnits="m3 m-3", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not.NUOPC_FieldDictionaryHasEntry( & - "volume_fraction_of_total_water_in_soil_at_wilting_point")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="volume_fraction_of_total_water_in_soil_at_wilting_point", & - canonicalUnits="m3 m-3", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not.NUOPC_FieldDictionaryHasEntry( & - "water_surface_height_above_reference_datum")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="water_surface_height_above_reference_datum", & - canonicalUnits="m", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - - if (.not.NUOPC_FieldDictionaryHasEntry( & - "mean_sensi_heat_flx_atm_into_lnd")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="mean_sensi_heat_flx_atm_into_lnd", & - canonicalUnits="W m-2", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - - if (.not.NUOPC_FieldDictionaryHasEntry( & - "mean_laten_heat_flx_atm_into_lnd")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="mean_laten_heat_flx_atm_into_lnd", & - canonicalUnits="W m-2", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - - ! Fields from and to WW3 - - if (.not.NUOPC_FieldDictionaryHasEntry( & - "eastward_wind_at_10m_height")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="eastward_wind_at_10m_height", & - canonicalUnits="m s-1", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - call NUOPC_FieldDictionarySetSyno( & - standardNames = (/"eastward_wind_at_10m_height",& - "inst_zonal_wind_height10m "/), rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - - if (.not.NUOPC_FieldDictionaryHasEntry( & - "northward_wind_at_10m_height")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="northward_wind_at_10m_height", & - canonicalUnits="m s-1", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - call NUOPC_FieldDictionarySetSyno( & - standardNames = (/"northward_wind_at_10m_height",& - "inst_merid_wind_height10m "/), rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - - if (.not. NUOPC_FieldDictionaryHasEntry( & - "sea_ice_concentration")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="sea_ice_concentration", & - canonicalUnits="1", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - call NUOPC_FieldDictionarySetSyno( & - standardNames = (/"ice_fraction ",& - "sea_ice_concentration"/), rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - - !For MOM6 and WW3 variables to match: - call NUOPC_FieldDictionarySetSyno( & - standardNames = (/"surface_eastward_sea_water_velocity",& - "ocn_current_zonal "/), rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - call NUOPC_FieldDictionarySetSyno( & - standardNames = (/"surface_northward_sea_water_velocity",& - "ocn_current_merid "/), rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - - if (.not.NUOPC_FieldDictionaryHasEntry( & - "eastward_stokes_drift_current")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="eastward_stokes_drift_current", & - canonicalUnits="m s-1", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - - if (.not.NUOPC_FieldDictionaryHasEntry( & - "northward_stokes_drift_current")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="northward_stokes_drift_current", & - canonicalUnits="m s-1", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - - if (.not.NUOPC_FieldDictionaryHasEntry( & - "eastward_wave_bottom_current")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="eastward_wave_bottom_current", & - canonicalUnits="m s-1", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - - if (.not.NUOPC_FieldDictionaryHasEntry( & - "northward_wave_bottom_current")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="northward_wave_bottom_current", & - canonicalUnits="m s-1", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - - if (.not.NUOPC_FieldDictionaryHasEntry( & - "wave_bottom_current_radian_frequency")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="wave_bottom_current_radian_frequency", & - canonicalUnits="rad s-1", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - - if (.not.NUOPC_FieldDictionaryHasEntry( & - "eastward_wave_radiation_stress_gradient")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="eastward_wave_radiation_stress_gradient", & - canonicalUnits="Pa", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - - if (.not.NUOPC_FieldDictionaryHasEntry( & - "northward_wave_radiation_stress_gradient")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="northward_wave_radiation_stress_gradient", & - canonicalUnits="Pa", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - - if (.not.NUOPC_FieldDictionaryHasEntry( & - "eastward_wave_radiation_stress")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="eastward_wave_radiation_stress", & - canonicalUnits="N m-1", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - - if (.not.NUOPC_FieldDictionaryHasEntry( & - "eastward_northward_wave_radiation_stress")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="eastward_northward_wave_radiation_stress", & - canonicalUnits="N m-1", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - - if (.not.NUOPC_FieldDictionaryHasEntry( & - "northward_wave_radiation_stress")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="northward_wave_radiation_stress", & - canonicalUnits="N m-1", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - - if (.not.NUOPC_FieldDictionaryHasEntry( & - "wave_induced_charnock_parameter")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="wave_induced_charnock_parameter", & - canonicalUnits="1", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - - if (.not.NUOPC_FieldDictionaryHasEntry( & - "wave_z0_roughness_length")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="wave_z0_roughness_length", & - canonicalUnits="m", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - - if (.not.NUOPC_FieldDictionaryHasEntry( & - "wave_bottom_current_period")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="wave_bottom_current_period", & - canonicalUnits="s", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - - - ! Fields from WAM to IPE - - if (.not.NUOPC_FieldDictionaryHasEntry( & - "northward_wind_neutral")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="northward_wind_neutral", & - canonicalUnits="m s-1", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - - if (.not.NUOPC_FieldDictionaryHasEntry( & - "eastward_wind_neutral")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="eastward_wind_neutral", & - canonicalUnits="m s-1", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - - if (.not.NUOPC_FieldDictionaryHasEntry( & - "upward_wind_neutral")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="upward_wind_neutral", & - canonicalUnits="m s-1", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - - if (.not.NUOPC_FieldDictionaryHasEntry( & - "temp_neutral")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="temp_neutral", & - canonicalUnits="K", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - - if (.not.NUOPC_FieldDictionaryHasEntry( & - "O_Density")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="O_Density", & - canonicalUnits="m-3", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - - if (.not.NUOPC_FieldDictionaryHasEntry( & - "O2_Density")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="O2_Density", & - canonicalUnits="m-3", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - - if (.not.NUOPC_FieldDictionaryHasEntry( & - "N2_Density")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="N2_Density", & - canonicalUnits="m-3", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - - if (.not.NUOPC_FieldDictionaryHasEntry( & - "height")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="height", & - canonicalUnits="km", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - - ! Chemistry fields - - if (.not.NUOPC_FieldDictionaryHasEntry( & - "inst_pres_interface")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="inst_pres_interface", & - canonicalUnits="Pa", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - - if (.not.NUOPC_FieldDictionaryHasEntry( & - "inst_pres_levels")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="inst_pres_levels", & - canonicalUnits="Pa", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - - if (.not.NUOPC_FieldDictionaryHasEntry( & - "inst_geop_interface")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="inst_geop_interface", & - canonicalUnits="m2 s-2", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - - if (.not.NUOPC_FieldDictionaryHasEntry( & - "inst_geop_levels")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="inst_geop_levels", & - canonicalUnits="m2 s-2", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - - if (.not.NUOPC_FieldDictionaryHasEntry( & - "inst_temp_levels")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="inst_temp_levels", & - canonicalUnits="K", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - - if (.not.NUOPC_FieldDictionaryHasEntry( & - "inst_zonal_wind_levels")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="inst_zonal_wind_levels", & - canonicalUnits="m s-1", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - - if (.not.NUOPC_FieldDictionaryHasEntry( & - "inst_merid_wind_levels")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="inst_merid_wind_levels", & - canonicalUnits="m s-1", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - - if (.not.NUOPC_FieldDictionaryHasEntry( & - "inst_omega_levels")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="inst_omega_levels", & - canonicalUnits="Pa s-1", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - - if (.not.NUOPC_FieldDictionaryHasEntry( & - "inst_tracer_mass_frac")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="inst_tracer_mass_frac", & - canonicalUnits="kg kg-1", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - - if (.not.NUOPC_FieldDictionaryHasEntry( & - "inst_tracer_up_surface_flx")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="inst_tracer_up_surface_flx", & - canonicalUnits="kg m-2 s-1", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - - if (.not.NUOPC_FieldDictionaryHasEntry( & - "inst_tracer_down_surface_flx")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="inst_tracer_down_surface_flx", & - canonicalUnits="kg m-2 s-1", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - - if (.not.NUOPC_FieldDictionaryHasEntry( & - "inst_tracer_clmn_mass_dens")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="inst_tracer_clmn_mass_dens", & - canonicalUnits="g m-2", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - - if (.not.NUOPC_FieldDictionaryHasEntry( & - "inst_tracer_anth_biom_flx")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="inst_tracer_anth_biom_flx", & - canonicalUnits="ug m-2 s-1", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - - if (.not.NUOPC_FieldDictionaryHasEntry( & - "inst_pbl_height")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="inst_pbl_height", & - canonicalUnits="m", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - - if (.not.NUOPC_FieldDictionaryHasEntry( & - "surface_cell_area")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="surface_cell_area", & - canonicalUnits="m2", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - - if (.not.NUOPC_FieldDictionaryHasEntry( & - "inst_convective_rainfall_amount")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="inst_convective_rainfall_amount", & - canonicalUnits="kg m-2", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - - if (.not.NUOPC_FieldDictionaryHasEntry( & - "inst_exchange_coefficient_heat_levels")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="inst_exchange_coefficient_heat_levels", & - canonicalUnits="W m-2 K-1", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - - if (.not.NUOPC_FieldDictionaryHasEntry( & - "inst_spec_humid_conv_tendency_levels")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="inst_spec_humid_conv_tendency_levels", & - canonicalUnits="kg kg-1 s-1", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - - if (.not.NUOPC_FieldDictionaryHasEntry( & - "inst_friction_velocity")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="inst_friction_velocity", & - canonicalUnits="m s-1", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - - if (.not.NUOPC_FieldDictionaryHasEntry( & - "inst_rainfall_amount")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="inst_rainfall_amount", & - canonicalUnits="kg m-2", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - - if (.not.NUOPC_FieldDictionaryHasEntry( & - "inst_soil_moisture_content")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="inst_soil_moisture_content", & - canonicalUnits="kg m-2", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - - if (.not.NUOPC_FieldDictionaryHasEntry( & - "inst_up_sensi_heat_flx")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="inst_up_sensi_heat_flx", & - canonicalUnits="W m-2", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - - if (.not.NUOPC_FieldDictionaryHasEntry( & - "inst_lwe_snow_thickness")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="inst_lwe_snow_thickness", & - canonicalUnits="m", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - - if (.not.NUOPC_FieldDictionaryHasEntry( & - "inst_vegetation_area_frac")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="inst_vegetation_area_frac", & - canonicalUnits="1", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - - if (.not.NUOPC_FieldDictionaryHasEntry( & - "inst_surface_roughness")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="inst_surface_roughness", & - canonicalUnits="1", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - - ! Dummy fields - - if (.not. NUOPC_FieldDictionaryHasEntry( & - "dummyfield")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="dummyfield", & - canonicalUnits="1", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not. NUOPC_FieldDictionaryHasEntry( & - "dummyfield1")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="dummyfield1", & - canonicalUnits="1", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - if (.not. NUOPC_FieldDictionaryHasEntry( & - "dummyfield2")) then - call NUOPC_FieldDictionaryAddEntry( & - standardName="dummyfield2", & - canonicalUnits="1", & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif + ! extending the Field Dictionary is a temporary solution anyway (see the + ! TODO: below), so this isn't going to stay for ever this way. + + ! Extend the NUOPC Field Dictionary to hold required entries. + !TODO: In the long run this section will not be needed when we have + !TODO: absorbed the needed standard names into the default dictionary. + ! -> 20 fields identified as exports by the GSM component + +#ifdef CMEPS + call NUOPC_FieldDictionarySetup("fd_nems.yaml", rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return +#else + do nf=1,NumFields + if (.not.NUOPC_FieldDictionaryHasEntry(trim(Field_Name_unit(1,nf)))) then + call NUOPC_FieldDictionaryAddEntry(standardName=trim(Field_Name_unit(1,nf)), & + canonicalUnits=trim(Field_Name_unit(2,nf)), rc=rc) + + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + endif + enddo + +! Synonyms for HYCOM fields +! ------------------------- + call NUOPC_FieldDictionarySetSyno(standardNames = (/"surface_downward_eastward_stress",& + "mean_zonal_moment_flx "/), rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call NUOPC_FieldDictionarySetSyno(standardNames = (/"surface_downward_northward_stress",& + "mean_merid_moment_flx "/), rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call NUOPC_FieldDictionarySetSyno(standardNames = (/"mean_lat_flx ",& + "mean_laten_heat_flx"/), rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call NUOPC_FieldDictionarySetSyno(standardNames = (/"mean_sens_flx ",& + "mean_sensi_heat_flx"/), rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + + +! Fields from and to WW3 +! ---------------------- + + call NUOPC_FieldDictionarySetSyno(standardNames = (/"eastward_wind_at_10m_height",& + "inst_zonal_wind_height10m "/), rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + + call NUOPC_FieldDictionarySetSyno(standardNames = (/"northward_wind_at_10m_height",& + "inst_merid_wind_height10m "/), rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + + call NUOPC_FieldDictionarySetSyno(standardNames = (/"ice_fraction",& + "sea_ice_concentration"/), rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + +! For MOM6 and WW3 variables to match: + call NUOPC_FieldDictionarySetSyno(standardNames = (/"surface_eastward_sea_water_velocity",& + "ocn_current_zonal "/), rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call NUOPC_FieldDictionarySetSyno(standardNames = (/"surface_northward_sea_water_velocity",& + "ocn_current_merid "/), rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + #endif !----------------------------------------------------------------------- @@ -3397,119 +706,119 @@ subroutine SetModelServices(driver, rc) #endif rc = ESMF_SUCCESS - ! query the Component for info +! query the Component for info +! ---------------------------- call ESMF_GridCompGet(driver, name=name, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=trim(name)//":"//__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=trim(name)//":"//__FILE__)) return - ! allocate memory for the internal state and store in Component +! allocate memory for the internal state and store in Component +! ------------------------------------------------------------- allocate(is%EARTH_INT_STATE, stat=stat) - if (ESMF_LogFoundAllocError(statusToCheck=stat, & + if (ESMF_LogFoundAllocError(statusToCheck=stat, & msg="Allocation of internal state memory failed.", & - line=__LINE__, file=trim(name)//":"//__FILE__, rcToReturn=rc)) & - return ! bail out + line=__LINE__, file=trim(name)//":"//__FILE__, rcToReturn=rc)) return + call ESMF_GridCompSetInternalState(driver, is, rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=trim(name)//":"//__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=trim(name)//":"//__FILE__)) return - ! get petCount and config +! get petCount and config +! ----------------------- call ESMF_GridCompGet(driver, petCount=petCount, config=config, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=trim(name)//":"//__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=trim(name)//":"//__FILE__)) return - ! read and ingest free format driver attributes +! read and ingest free format driver attributes +! --------------------------------------------- attrFF = NUOPC_FreeFormatCreate(config, label="EARTH_attributes::", & - relaxedflag=.true., rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=trim(name)//":"//__FILE__)) return ! bail out + relaxedflag=.true., rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=trim(name)//":"//__FILE__)) return + call NUOPC_CompAttributeIngest(driver, attrFF, addFlag=.true., rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=trim(name)//":"//__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=trim(name)//":"//__FILE__)) return + call NUOPC_FreeFormatDestroy(attrFF, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=trim(name)//":"//__FILE__)) return ! bail out - - ! dump the current field dictionary into the Log file + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=trim(name)//":"//__FILE__)) return + +! dump the current field dictionary into the Log file +! --------------------------------------------------- call ESMF_AttributeGet(driver, name="DumpFieldDictionary", & - value=value, defaultValue="false", & - convention="NUOPC", purpose="Instance", rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=trim(name)//":"//__FILE__)) return ! bail out - if (trim(value)=="true") then - call ESMF_LogWrite( & - "===>===>===>===> Begin Dumping Field Dictionary <===<===<===<===",& - ESMF_LOGMSG_INFO, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=trim(name)//":"//__FILE__)) return ! bail out + value=value, defaultValue="false", & + convention="NUOPC", purpose="Instance", rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=trim(name)//":"//__FILE__)) return + + if (trim(value) == "true") then + call ESMF_LogWrite("===>===>===>===> Begin Dumping Field Dictionary <===<===<===<===",& + ESMF_LOGMSG_INFO, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=trim(name)//":"//__FILE__)) return + call NUOPC_FieldDictionaryEgest(fdFF, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=trim(name)//":"//__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=trim(name)//":"//__FILE__)) return + call NUOPC_FreeFormatLog(fdFF, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=trim(name)//":"//__FILE__)) return ! bail out - call ESMF_LogWrite( & - "===>===>===>===> Done Dumping Field Dictionary <===<===<===<===", & - ESMF_LOGMSG_INFO, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=trim(name)//":"//__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=trim(name)//":"//__FILE__)) return + call ESMF_LogWrite("===>===>===>===> Done Dumping Field Dictionary <===<===<===<===", & + ESMF_LOGMSG_INFO, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=trim(name)//":"//__FILE__)) return endif - - ! determine the generic component labels - componentCount = ESMF_ConfigGetLen(config, & - label="EARTH_component_list:", rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=trim(name)//":"//__FILE__)) return ! bail out + +! determine the generic component labels +! -------------------------------------- + componentCount = ESMF_ConfigGetLen(config, label="EARTH_component_list:", rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=trim(name)//":"//__FILE__)) return + allocate(compLabels(componentCount), stat=stat) if (ESMF_LogFoundAllocError(statusToCheck=stat, & - msg="Allocation of compLabels failed.", & - line=__LINE__, file=trim(name)//":"//__FILE__, rcToReturn=rc)) & - return ! bail out + msg="Allocation of compLabels failed.", & + line=__LINE__, file=trim(name)//":"//__FILE__, rcToReturn=rc)) return + call ESMF_ConfigGetAttribute(config, valueList=compLabels, & - label="EARTH_component_list:", count=componentCount, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=trim(name)//":"//__FILE__)) return ! bail out + label="EARTH_component_list:", count=componentCount, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=trim(name)//":"//__FILE__)) return #ifdef CMEPS inst_suffix = "" - ! obtain driver attributes (for CMEPS) - call ReadAttributes(driver, config, "DRIVER_attributes::", formatprint=.true., rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=trim(name)//":"//__FILE__)) return ! bail out + if (componentCount > 1) then + ! obtain driver attributes (for CMEPS) + call ReadAttributes(driver, config, "DRIVER_attributes::", formatprint=.true., rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=trim(name)//":"//__FILE__)) return - call ReadAttributes(driver, config, "ALLCOMP_attributes::", formatprint=.true., rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=trim(name)//":"//__FILE__)) return ! bail out + call ReadAttributes(driver, config, "ALLCOMP_attributes::", formatprint=.true., rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=trim(name)//":"//__FILE__)) return + endif #endif - ! determine information for each component and add to the driver + +! determine information for each component and add to the driver +! -------------------------------------------------------------- do i=1, componentCount - ! construct component prefix - prefix=trim(compLabels(i)) - ! read in petList bounds +! construct component prefix +! -------------------------- + prefix = trim(compLabels(i)) +! read in petList bounds +! ---------------------- call ESMF_ConfigGetAttribute(config, petListBounds, & - label=trim(prefix)//"_petlist_bounds:", default=-1, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=trim(name)//":"//__FILE__)) return ! bail out - ! handle the default situation - if (petListBounds(1)==-1 .or. petListBounds(2)==-1) then + label=trim(prefix)//"_petlist_bounds:", default=-1, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=trim(name)//":"//__FILE__)) return +! handle the default situation +! ---------------------------- + if (petListBounds(1) == -1 .or. petListBounds(2) == -1) then petListBounds(1) = 0 petListBounds(2) = petCount - 1 endif - ! read in model instance name +! read in model instance name +! --------------------------- call ESMF_ConfigGetAttribute(config, model, & - label=trim(prefix)//"_model:", default="none", rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=trim(name)//":"//__FILE__)) return ! bail out - ! check that there was a model instance specified - if (trim(model) == "none") then - ! Error condition: no model was specified + label=trim(prefix)//"_model:", default="none", rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=trim(name)//":"//__FILE__)) return +! check that there was a model instance specified +! ----------------------------------------------- + if (trim(model) == "none") then ! Error condition: no model was specified write (msg, *) "No model was specified for component: ",trim(prefix) - call ESMF_LogSetError(ESMF_RC_NOT_VALID, msg=msg, line=__LINE__, & - file=__FILE__, rcToReturn=rc) - return ! bail out + call ESMF_LogSetError(ESMF_RC_NOT_VALID, msg=msg, line=__LINE__, file=__FILE__, rcToReturn=rc) + return endif - ! set petList for this component +! set petList for this component +! ------------------------------ allocate(petList(petListBounds(2)-petListBounds(1)+1)) do j=petListBounds(1), petListBounds(2) petList(j-petListBounds(1)+1) = j ! PETs are 0 based @@ -3518,418 +827,355 @@ subroutine SetModelServices(driver, rc) if (trim(model) == "satm") then #ifdef FRONT_SATM call NUOPC_DriverAddComp(driver, trim(prefix), SATM_SS, & - petList=petList, comp=comp, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=trim(name)//":"//__FILE__)) return ! bail out + petList=petList, comp=comp, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=trim(name)//":"//__FILE__)) return #else write (msg, *) "Model '", trim(model), "' was requested, "// & - "but is not available in the executable!" - call ESMF_LogSetError(ESMF_RC_NOT_VALID, msg=msg, line=__LINE__, & - file=__FILE__, rcToReturn=rc) - return ! bail out + "but is not available in the executable!" + call ESMF_LogSetError(ESMF_RC_NOT_VALID, msg=msg, line=__LINE__, file=__FILE__, rcToReturn=rc) + return #endif elseif (trim(model) == "xatm") then #ifdef FRONT_XATM call NUOPC_DriverAddComp(driver, trim(prefix), XATM_SS, & - petList=petList, comp=comp, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=trim(name)//":"//__FILE__)) return ! bail out + petList=petList, comp=comp, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=trim(name)//":"//__FILE__)) return #else write (msg, *) "Model '", trim(model), "' was requested, "// & - "but is not available in the executable!" - call ESMF_LogSetError(ESMF_RC_NOT_VALID, msg=msg, line=__LINE__, & - file=__FILE__, rcToReturn=rc) - return ! bail out + "but is not available in the executable!" + call ESMF_LogSetError(ESMF_RC_NOT_VALID, msg=msg, line=__LINE__, file=__FILE__, rcToReturn=rc) + return #endif elseif (trim(model) == "datawam") then #ifdef FRONT_DATAWAM call NUOPC_DriverAddComp(driver, trim(prefix), DATAWAM_SS, & - petList=petList, comp=comp, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=trim(name)//":"//__FILE__)) return ! bail out + petList=petList, comp=comp, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=trim(name)//":"//__FILE__)) return #else write (msg, *) "Model '", trim(model), "' was requested, "// & - "but is not available in the executable!" - call ESMF_LogSetError(ESMF_RC_NOT_VALID, msg=msg, line=__LINE__, & - file=__FILE__, rcToReturn=rc) - return ! bail out + "but is not available in the executable!" + call ESMF_LogSetError(ESMF_RC_NOT_VALID, msg=msg, line=__LINE__, file=__FILE__, rcToReturn=rc) + return #endif elseif (trim(model) == "gsm") then #ifdef FRONT_GSM call NUOPC_DriverAddComp(driver, trim(prefix), GSM_SS, & - petList=petList, comp=comp, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=trim(name)//":"//__FILE__)) return ! bail out + petList=petList, comp=comp, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=trim(name)//":"//__FILE__)) return #else write (msg, *) "Model '", trim(model), "' was requested, "// & - "but is not available in the executable!" - call ESMF_LogSetError(ESMF_RC_NOT_VALID, msg=msg, line=__LINE__, & - file=__FILE__, rcToReturn=rc) - return ! bail out + "but is not available in the executable!" + call ESMF_LogSetError(ESMF_RC_NOT_VALID, msg=msg, line=__LINE__, file=__FILE__, rcToReturn=rc) + return #endif elseif (trim(model) == "nmmb") then #ifdef FRONT_NMMB call NUOPC_DriverAddComp(driver, trim(prefix), NMMB_SS, & - petList=petList, comp=comp, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=trim(name)//":"//__FILE__)) return ! bail out + petList=petList, comp=comp, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=trim(name)//":"//__FILE__)) return #else write (msg, *) "Model '", trim(model), "' was requested, "// & - "but is not available in the executable!" - call ESMF_LogSetError(ESMF_RC_NOT_VALID, msg=msg, line=__LINE__, & - file=__FILE__, rcToReturn=rc) - return ! bail out + "but is not available in the executable!" + call ESMF_LogSetError(ESMF_RC_NOT_VALID, msg=msg, line=__LINE__, file=__FILE__, rcToReturn=rc) + return #endif elseif (trim(model) == "fv3") then #ifdef FRONT_FV3 call NUOPC_DriverAddComp(driver, trim(prefix), FV3_SS, & - petList=petList, comp=comp, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=trim(name)//":"//__FILE__)) return ! bail out + petList=petList, comp=comp, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=trim(name)//":"//__FILE__)) return #else write (msg, *) "Model '", trim(model), "' was requested, "// & - "but is not available in the executable!" - call ESMF_LogSetError(ESMF_RC_NOT_VALID, msg=msg, line=__LINE__, & - file=__FILE__, rcToReturn=rc) - return ! bail out + "but is not available in the executable!" + call ESMF_LogSetError(ESMF_RC_NOT_VALID, msg=msg, line=__LINE__, file=__FILE__, rcToReturn=rc) + return #endif elseif (trim(model) == "datm") then #ifdef FRONT_DATM call NUOPC_DriverAddComp(driver, trim(prefix), DATM_SS, & - petList=petList, comp=comp, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=trim(name)//":"//__FILE__)) return ! bail out + petList=petList, comp=comp, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=trim(name)//":"//__FILE__)) return #else write (msg, *) "Model '", trim(model), "' was requested, "// & - "but is not available in the executable!" - call ESMF_LogSetError(ESMF_RC_NOT_VALID, msg=msg, line=__LINE__, & - file=__FILE__, rcToReturn=rc) - return ! bail out + "but is not available in the executable!" + call ESMF_LogSetError(ESMF_RC_NOT_VALID, msg=msg, line=__LINE__, file=__FILE__, rcToReturn=rc) + return #endif elseif (trim(model) == "socn") then #ifdef FRONT_SOCN call NUOPC_DriverAddComp(driver, trim(prefix), SOCN_SS, & - petList=petList, comp=comp, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=trim(name)//":"//__FILE__)) return ! bail out + petList=petList, comp=comp, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=trim(name)//":"//__FILE__)) return #else write (msg, *) "Model '", trim(model), "' was requested, "// & - "but is not available in the executable!" - call ESMF_LogSetError(ESMF_RC_NOT_VALID, msg=msg, line=__LINE__, & - file=__FILE__, rcToReturn=rc) - return ! bail out + "but is not available in the executable!" + call ESMF_LogSetError(ESMF_RC_NOT_VALID, msg=msg, line=__LINE__, file=__FILE__, rcToReturn=rc) + return #endif elseif (trim(model) == "xocn") then #ifdef FRONT_XOCN call NUOPC_DriverAddComp(driver, trim(prefix), XOCN_SS, & - petList=petList, comp=comp, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=trim(name)//":"//__FILE__)) return ! bail out + petList=petList, comp=comp, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=trim(name)//":"//__FILE__)) return #else write (msg, *) "Model '", trim(model), "' was requested, "// & - "but is not available in the executable!" - call ESMF_LogSetError(ESMF_RC_NOT_VALID, msg=msg, line=__LINE__, & - file=__FILE__, rcToReturn=rc) - return ! bail out + "but is not available in the executable!" + call ESMF_LogSetError(ESMF_RC_NOT_VALID, msg=msg, line=__LINE__, file=__FILE__, rcToReturn=rc) + return #endif elseif (trim(model) == "hycom") then #ifdef FRONT_HYCOM call NUOPC_DriverAddComp(driver, trim(prefix), HYCOM_SS, & - petList=petList, comp=comp, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=trim(name)//":"//__FILE__)) return ! bail out + petList=petList, comp=comp, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=trim(name)//":"//__FILE__)) return #else write (msg, *) "Model '", trim(model), "' was requested, "// & - "but is not available in the executable!" - call ESMF_LogSetError(ESMF_RC_NOT_VALID, msg=msg, line=__LINE__, & - file=__FILE__, rcToReturn=rc) - return ! bail out + "but is not available in the executable!" + call ESMF_LogSetError(ESMF_RC_NOT_VALID, msg=msg, line=__LINE__, file=__FILE__, rcToReturn=rc) + return #endif elseif (trim(model) == "mom5") then #ifdef FRONT_MOM5 call NUOPC_DriverAddComp(driver, trim(prefix), MOM5_SS, & - petList=petList, comp=comp, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=trim(name)//":"//__FILE__)) return ! bail out + petList=petList, comp=comp, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=trim(name)//":"//__FILE__)) return #else write (msg, *) "Model '", trim(model), "' was requested, "// & - "but is not available in the executable!" - call ESMF_LogSetError(ESMF_RC_NOT_VALID, msg=msg, line=__LINE__, & - file=__FILE__, rcToReturn=rc) - return ! bail out + "but is not available in the executable!" + call ESMF_LogSetError(ESMF_RC_NOT_VALID, msg=msg, line=__LINE__, file=__FILE__, rcToReturn=rc) + return #endif elseif (trim(model) == "mom6") then #ifdef FRONT_MOM6 call NUOPC_DriverAddComp(driver, trim(prefix), MOM6_SS, & - petList=petList, comp=comp, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=trim(name)//":"//__FILE__)) return ! bail out + petList=petList, comp=comp, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=trim(name)//":"//__FILE__)) return #else write (msg, *) "Model '", trim(model), "' was requested, "// & - "but is not available in the executable!" - call ESMF_LogSetError(ESMF_RC_NOT_VALID, msg=msg, line=__LINE__, & - file=__FILE__, rcToReturn=rc) - return ! bail out + "but is not available in the executable!" + call ESMF_LogSetError(ESMF_RC_NOT_VALID, msg=msg, line=__LINE__, file=__FILE__, rcToReturn=rc) + return #endif elseif (trim(model) == "pom") then #ifdef FRONT_POM call NUOPC_DriverAddComp(driver, trim(prefix), POM_SS, & - petList=petList, comp=comp, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=trim(name)//":"//__FILE__)) return ! bail out + petList=petList, comp=comp, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=trim(name)//":"//__FILE__)) return #else write (msg, *) "Model '", trim(model), "' was requested, "// & - "but is not available in the executable!" - call ESMF_LogSetError(ESMF_RC_NOT_VALID, msg=msg, line=__LINE__, & - file=__FILE__, rcToReturn=rc) - return ! bail out + "but is not available in the executable!" + call ESMF_LogSetError(ESMF_RC_NOT_VALID, msg=msg, line=__LINE__, file=__FILE__, rcToReturn=rc) + return #endif elseif (trim(model) == "sice") then #ifdef FRONT_SICE call NUOPC_DriverAddComp(driver, trim(prefix), SICE_SS, & - petList=petList, comp=comp, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=trim(name)//":"//__FILE__)) return ! bail out + petList=petList, comp=comp, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=trim(name)//":"//__FILE__)) return #else write (msg, *) "Model '", trim(model), "' was requested, "// & - "but is not available in the executable!" - call ESMF_LogSetError(ESMF_RC_NOT_VALID, msg=msg, line=__LINE__, & - file=__FILE__, rcToReturn=rc) - return ! bail out + "but is not available in the executable!" + call ESMF_LogSetError(ESMF_RC_NOT_VALID, msg=msg, line=__LINE__, file=__FILE__, rcToReturn=rc) + return #endif elseif (trim(model) == "xice") then #ifdef FRONT_XICE call NUOPC_DriverAddComp(driver, trim(prefix), XICE_SS, & - petList=petList, comp=comp, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=trim(name)//":"//__FILE__)) return ! bail out + petList=petList, comp=comp, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=trim(name)//":"//__FILE__)) return #else write (msg, *) "Model '", trim(model), "' was requested, "// & - "but is not available in the executable!" - call ESMF_LogSetError(ESMF_RC_NOT_VALID, msg=msg, line=__LINE__, & - file=__FILE__, rcToReturn=rc) - return ! bail out + "but is not available in the executable!" + call ESMF_LogSetError(ESMF_RC_NOT_VALID, msg=msg, line=__LINE__, file=__FILE__, rcToReturn=rc) + return #endif elseif (trim(model) == "cice") then #ifdef FRONT_CICE call NUOPC_DriverAddComp(driver, trim(prefix), CICE_SS, & - petList=petList, comp=comp, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=trim(name)//":"//__FILE__)) return ! bail out + petList=petList, comp=comp, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=trim(name)//":"//__FILE__)) return #else write (msg, *) "Model '", trim(model), "' was requested, "// & - "but is not available in the executable!" - call ESMF_LogSetError(ESMF_RC_NOT_VALID, msg=msg, line=__LINE__, & - file=__FILE__, rcToReturn=rc) - return ! bail out + "but is not available in the executable!" + call ESMF_LogSetError(ESMF_RC_NOT_VALID, msg=msg, line=__LINE__, file=__FILE__, rcToReturn=rc) + return #endif elseif (trim(model) == "cice6") then #ifdef FRONT_CICE6 call NUOPC_DriverAddComp(driver, trim(prefix), CICE6_SS, & - petList=petList, comp=comp, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=trim(name)//":"//__FILE__)) return ! bail out + petList=petList, comp=comp, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=trim(name)//":"//__FILE__)) return #else write (msg, *) "Model '", trim(model), "' was requested, "// & - "but is not available in the executable!" - call ESMF_LogSetError(ESMF_RC_NOT_VALID, msg=msg, line=__LINE__, & - file=__FILE__, rcToReturn=rc) - return ! bail out + "but is not available in the executable!" + call ESMF_LogSetError(ESMF_RC_NOT_VALID, msg=msg, line=__LINE__, file=__FILE__, rcToReturn=rc) + return #endif elseif (trim(model) == "swav") then #ifdef FRONT_SWAV call NUOPC_DriverAddComp(driver, trim(prefix), SWAV_SS, & - petList=petList, comp=comp, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=trim(name)//":"//__FILE__)) return ! bail out + petList=petList, comp=comp, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=trim(name)//":"//__FILE__)) return #else write (msg, *) "Model '", trim(model), "' was requested, "// & - "but is not available in the executable!" - call ESMF_LogSetError(ESMF_RC_NOT_VALID, msg=msg, line=__LINE__, & - file=__FILE__, rcToReturn=rc) - return ! bail out + "but is not available in the executable!" + call ESMF_LogSetError(ESMF_RC_NOT_VALID, msg=msg, line=__LINE__, file=__FILE__, rcToReturn=rc) + return #endif elseif (trim(model) == "xwav") then #ifdef FRONT_XWAV call NUOPC_DriverAddComp(driver, trim(prefix), XWAV_SS, & - petList=petList, comp=comp, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=trim(name)//":"//__FILE__)) return ! bail out + petList=petList, comp=comp, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=trim(name)//":"//__FILE__)) return #else write (msg, *) "Model '", trim(model), "' was requested, "// & - "but is not available in the executable!" - call ESMF_LogSetError(ESMF_RC_NOT_VALID, msg=msg, line=__LINE__, & - file=__FILE__, rcToReturn=rc) - return ! bail out + "but is not available in the executable!" + call ESMF_LogSetError(ESMF_RC_NOT_VALID, msg=msg, line=__LINE__, file=__FILE__, rcToReturn=rc) + return #endif elseif (trim(model) == "ww3") then #ifdef FRONT_WW3 call NUOPC_DriverAddComp(driver, trim(prefix), WW3_SS, & - petList=petList, comp=comp, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=trim(name)//":"//__FILE__)) return ! bail out + petList=petList, comp=comp, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=trim(name)//":"//__FILE__)) return #else write (msg, *) "Model '", trim(model), "' was requested, "// & - "but is not available in the executable!" - call ESMF_LogSetError(ESMF_RC_NOT_VALID, msg=msg, line=__LINE__, & - file=__FILE__, rcToReturn=rc) - return ! bail out + "but is not available in the executable!" + call ESMF_LogSetError(ESMF_RC_NOT_VALID, msg=msg, line=__LINE__, file=__FILE__, rcToReturn=rc) + return #endif elseif (trim(model) == "slnd") then #ifdef FRONT_SLND call NUOPC_DriverAddComp(driver, trim(prefix), SLND_SS, & - petList=petList, comp=comp, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=trim(name)//":"//__FILE__)) return ! bail out + petList=petList, comp=comp, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=trim(name)//":"//__FILE__)) return #else write (msg, *) "Model '", trim(model), "' was requested, "// & - "but is not available in the executable!" - call ESMF_LogSetError(ESMF_RC_NOT_VALID, msg=msg, line=__LINE__, & - file=__FILE__, rcToReturn=rc) - return ! bail out + "but is not available in the executable!" + call ESMF_LogSetError(ESMF_RC_NOT_VALID, msg=msg, line=__LINE__, file=__FILE__, rcToReturn=rc) + return #endif elseif (trim(model) == "xlnd") then #ifdef FRONT_XLND call NUOPC_DriverAddComp(driver, trim(prefix), XLND_SS, & - petList=petList, comp=comp, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=trim(name)//":"//__FILE__)) return ! bail out + petList=petList, comp=comp, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=trim(name)//":"//__FILE__)) return #else write (msg, *) "Model '", trim(model), "' was requested, "// & - "but is not available in the executable!" - call ESMF_LogSetError(ESMF_RC_NOT_VALID, msg=msg, line=__LINE__, & - file=__FILE__, rcToReturn=rc) - return ! bail out + "but is not available in the executable!" + call ESMF_LogSetError(ESMF_RC_NOT_VALID, msg=msg, line=__LINE__, file=__FILE__, rcToReturn=rc) + return #endif elseif (trim(model) == "noah") then #ifdef FRONT_NOAH call NUOPC_DriverAddComp(driver, trim(prefix), NOAH_SS, & - petList=petList, comp=comp, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=trim(name)//":"//__FILE__)) return ! bail out + petList=petList, comp=comp, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=trim(name)//":"//__FILE__)) return #else write (msg, *) "Model '", trim(model), "' was requested, "// & - "but is not available in the executable!" - call ESMF_LogSetError(ESMF_RC_NOT_VALID, msg=msg, line=__LINE__, & - file=__FILE__, rcToReturn=rc) - return ! bail out + "but is not available in the executable!" + call ESMF_LogSetError(ESMF_RC_NOT_VALID, msg=msg, line=__LINE__, file=__FILE__, rcToReturn=rc) + return #endif elseif (trim(model) == "lis") then #ifdef FRONT_LIS call NUOPC_DriverAddComp(driver, trim(prefix), LIS_SS, & - petList=petList, comp=comp, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=trim(name)//":"//__FILE__)) return ! bail out + petList=petList, comp=comp, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=trim(name)//":"//__FILE__)) return #else write (msg, *) "Model '", trim(model), "' was requested, "// & - "but is not available in the executable!" - call ESMF_LogSetError(ESMF_RC_NOT_VALID, msg=msg, line=__LINE__, & - file=__FILE__, rcToReturn=rc) - return ! bail out + "but is not available in the executable!" + call ESMF_LogSetError(ESMF_RC_NOT_VALID, msg=msg, line=__LINE__, file=__FILE__, rcToReturn=rc) + return #endif elseif (trim(model) == "sipm") then #ifdef FRONT_SIPM call NUOPC_DriverAddComp(driver, trim(prefix), SIPM_SS, & - petList=petList, comp=comp, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=trim(name)//":"//__FILE__)) return ! bail out + petList=petList, comp=comp, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=trim(name)//":"//__FILE__)) return #else write (msg, *) "Model '", trim(model), "' was requested, "// & - "but is not available in the executable!" - call ESMF_LogSetError(ESMF_RC_NOT_VALID, msg=msg, line=__LINE__, & - file=__FILE__, rcToReturn=rc) - return ! bail out + "but is not available in the executable!" + call ESMF_LogSetError(ESMF_RC_NOT_VALID, msg=msg, line=__LINE__, file=__FILE__, rcToReturn=rc) + return #endif elseif (trim(model) == "xipm") then #ifdef FRONT_XIPM call NUOPC_DriverAddComp(driver, trim(prefix), XIPM_SS, & - petList=petList, comp=comp, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=trim(name)//":"//__FILE__)) return ! bail out + petList=petList, comp=comp, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=trim(name)//":"//__FILE__)) return #else write (msg, *) "Model '", trim(model), "' was requested, "// & - "but is not available in the executable!" - call ESMF_LogSetError(ESMF_RC_NOT_VALID, msg=msg, line=__LINE__, & - file=__FILE__, rcToReturn=rc) - return ! bail out + "but is not available in the executable!" + call ESMF_LogSetError(ESMF_RC_NOT_VALID, msg=msg, line=__LINE__, file=__FILE__, rcToReturn=rc) + return #endif elseif (trim(model) == "ipe") then #ifdef FRONT_IPE call NUOPC_DriverAddComp(driver, trim(prefix), IPE_SS, & - petList=petList, comp=comp, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=trim(name)//":"//__FILE__)) return ! bail out + petList=petList, comp=comp, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=trim(name)//":"//__FILE__)) return #else write (msg, *) "Model '", trim(model), "' was requested, "// & - "but is not available in the executable!" - call ESMF_LogSetError(ESMF_RC_NOT_VALID, msg=msg, line=__LINE__, & - file=__FILE__, rcToReturn=rc) - return ! bail out + "but is not available in the executable!" + call ESMF_LogSetError(ESMF_RC_NOT_VALID, msg=msg, line=__LINE__, file=__FILE__, rcToReturn=rc) + return #endif elseif (trim(model) == "dataipe") then #ifdef FRONT_DATAIPE call NUOPC_DriverAddComp(driver, trim(prefix), DATAIPE_SS, & - petList=petList, comp=comp, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=trim(name)//":"//__FILE__)) return ! bail out + petList=petList, comp=comp, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=trim(name)//":"//__FILE__)) return #else write (msg, *) "Model '", trim(model), "' was requested, "// & - "but is not available in the executable!" - call ESMF_LogSetError(ESMF_RC_NOT_VALID, msg=msg, line=__LINE__, & - file=__FILE__, rcToReturn=rc) - return ! bail out + "but is not available in the executable!" + call ESMF_LogSetError(ESMF_RC_NOT_VALID, msg=msg, line=__LINE__, file=__FILE__, rcToReturn=rc) + return #endif elseif (trim(model) == "shyd") then #ifdef FRONT_SHYD call NUOPC_DriverAddComp(driver, trim(prefix), SHYD_SS, & - petList=petList, comp=comp, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=trim(name)//":"//__FILE__)) return ! bail out + petList=petList, comp=comp, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=trim(name)//":"//__FILE__)) return #else write (msg, *) "Model '", trim(model), "' was requested, "// & - "but is not available in the executable!" + "but is not available in the executable!" call ESMF_LogSetError(ESMF_RC_NOT_VALID, msg=msg, line=__LINE__, & - file=__FILE__, rcToReturn=rc) - return ! bail out + file=__FILE__, rcToReturn=rc) + return #endif elseif (trim(model) == "xhyd") then #ifdef FRONT_XHYD call NUOPC_DriverAddComp(driver, trim(prefix), XHYD_SS, & - petList=petList, comp=comp, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=trim(name)//":"//__FILE__)) return ! bail out + petList=petList, comp=comp, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=trim(name)//":"//__FILE__)) return #else write (msg, *) "Model '", trim(model), "' was requested, "// & "but is not available in the executable!" - call ESMF_LogSetError(ESMF_RC_NOT_VALID, msg=msg, line=__LINE__, & - file=__FILE__, rcToReturn=rc) - return ! bail out + call ESMF_LogSetError(ESMF_RC_NOT_VALID, msg=msg, line=__LINE__, file=__FILE__, rcToReturn=rc) + return #endif elseif (trim(model) == "wrfhydro") then #ifdef FRONT_WRFHYDRO call NUOPC_DriverAddComp(driver, trim(prefix), WRFHYDRO_SS, & - petList=petList, comp=comp, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=trim(name)//":"//__FILE__)) return ! bail out + petList=petList, comp=comp, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=trim(name)//":"//__FILE__)) return #else write (msg, *) "Model '", trim(model), "' was requested, "// & - "but is not available in the executable!" - call ESMF_LogSetError(ESMF_RC_NOT_VALID, msg=msg, line=__LINE__, & - file=__FILE__, rcToReturn=rc) - return ! bail out + "but is not available in the executable!" + call ESMF_LogSetError(ESMF_RC_NOT_VALID, msg=msg, line=__LINE__, file=__FILE__, rcToReturn=rc) + return #endif elseif (trim(model) == "gsdchem") then #ifdef FRONT_GSDCHEM call NUOPC_DriverAddComp(driver, trim(prefix), GSDCHEM_SS, & - petList=petList, comp=comp, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=trim(name)//":"//__FILE__)) return ! bail out + petList=petList, comp=comp, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=trim(name)//":"//__FILE__)) return #else write (msg, *) "Model '", trim(model), "' was requested, "// & "but is not available in the executable!" - call ESMF_LogSetError(ESMF_RC_NOT_VALID, msg=msg, line=__LINE__, & - file=__FILE__, rcToReturn=rc) - return ! bail out + call ESMF_LogSetError(ESMF_RC_NOT_VALID, msg=msg, line=__LINE__, file=__FILE__, rcToReturn=rc) + return #endif ! - Two mediator choices currently built into NEMS from internal elseif (trim(model) == "nems") then @@ -3937,707 +1183,626 @@ subroutine SetModelServices(driver, rc) med_id = i+1 #endif call NUOPC_DriverAddComp(driver, trim(prefix), MED_SS, & - petList=petList, comp=comp, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=trim(name)//":"//__FILE__)) return ! bail out + petList=petList, comp=comp, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=trim(name)//":"//__FILE__)) return elseif (trim(model) == "spaceweather") then call NUOPC_DriverAddComp(driver, trim(prefix), MEDSW_SS, & - petList=petList, comp=comp, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=trim(name)//":"//__FILE__)) return ! bail out + petList=petList, comp=comp, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=trim(name)//":"//__FILE__)) return else ! Error condition: unknown model requested write (msg, *) "The requested model '", trim(model), & - "' is an invalid choice!" - call ESMF_LogSetError(ESMF_RC_NOT_VALID, msg=msg, line=__LINE__, & - file=__FILE__, rcToReturn=rc) - return ! bail out + "' is an invalid choice!" + call ESMF_LogSetError(ESMF_RC_NOT_VALID, msg=msg, line=__LINE__, file=__FILE__, rcToReturn=rc) + return endif - - ! read and ingest free format component attributes + +! read and ingest free format component attributes +! ------------------------------------------------ attrFF = NUOPC_FreeFormatCreate(config, & - label=trim(prefix)//"_attributes::", relaxedflag=.true., rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=trim(name)//":"//__FILE__)) return ! bail out + label=trim(prefix)//"_attributes::", & + relaxedflag=.true., rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=trim(name)//":"//__FILE__)) return + call NUOPC_CompAttributeIngest(comp, attrFF, addFlag=.true., rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=trim(name)//":"//__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=trim(name)//":"//__FILE__)) return + call NUOPC_FreeFormatDestroy(attrFF, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=trim(name)//":"//__FILE__)) return ! bail out - - ! clean-up - deallocate(petList) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=trim(name)//":"//__FILE__)) return +! clean-up +! -------- + deallocate(petList) #ifdef CMEPS - ! Perform restarts if appropriate - call InitRestart(driver, rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=trim(name)//":"//__FILE__)) return ! bail out + if (componentCount > 1) then + ! Perform restarts if appropriate + call InitRestart(driver, rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=trim(name)//":"//__FILE__)) return + + call AddAttributes(comp, driver, config, i+1, trim(prefix), inst_suffix, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=trim(name)//":"//__FILE__)) return + endif +#endif - call AddAttributes(comp, driver, config, i+1, trim(prefix), inst_suffix, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=trim(name)//":"//__FILE__)) return ! bail out -#endif enddo -#if ESMF_VERSION_MAJOR < 8 +#if ESMF_VERSION_MAJOR < 8 !TODOgjt: REMOVE THIS BLOCK ONCE SHOWN TO WORK WITHOUT - ! SetServices for Connectors +! SetServices for Connectors +! -------------------------- call SetFromConfig(driver, mode="setServicesConnectors", rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=trim(name)//":"//__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=trim(name)//":"//__FILE__)) return #endif - - ! clean-up +! clean-up +! -------- deallocate(compLabels) - + end subroutine - !----------------------------------------------------------------------------- - - subroutine SetRunSequence(driver, rc) - type(ESMF_GridComp) :: driver - integer, intent(out) :: rc + !----------------------------------------------------------------------------- + + subroutine SetRunSequence(driver, rc) + type(ESMF_GridComp) :: driver + integer, intent(out) :: rc - ! local variables - character(ESMF_MAXSTR) :: name +! local variables + character(ESMF_MAXSTR) :: name #if ESMF_VERSION_MAJOR >= 8 - type(ESMF_Config) :: config - type(NUOPC_FreeFormat) :: runSeqFF -#endif + type(ESMF_Config) :: config + type(NUOPC_FreeFormat) :: runSeqFF +#endif - rc = ESMF_SUCCESS + rc = ESMF_SUCCESS - ! query the Component for info - call ESMF_GridCompGet(driver, name=name, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=trim(name)//":"//__FILE__)) return ! bail out +! query the Component for info +! ---------------------------- + call ESMF_GridCompGet(driver, name=name, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=trim(name)//":"//__FILE__)) return #if ESMF_VERSION_MAJOR >= 8 - ! read free format run sequence from config - call ESMF_GridCompGet(driver, config=config, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=trim(name)//":"//__FILE__)) return ! bail out - runSeqFF = NUOPC_FreeFormatCreate(config, label="runSeq::", rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=trim(name)//":"//__FILE__)) return ! bail out - - ! ingest FreeFormat run sequence - call NUOPC_DriverIngestRunSequence(driver, runSeqFF, & - autoAddConnectors=.true., rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=trim(name)//":"//__FILE__)) return ! bail out +! read free format run sequence from config +! ----------------------------------------- + call ESMF_GridCompGet(driver, config=config, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & + line=__LINE__, file=trim(name)//":"//__FILE__)) return + + runSeqFF = NUOPC_FreeFormatCreate(config, label="runSeq::", rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=trim(name)//":"//__FILE__)) return + +! ingest FreeFormat run sequence +! ------------------------------ + call NUOPC_DriverIngestRunSequence(driver, runSeqFF, & + autoAddConnectors=.true., rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=trim(name)//":"//__FILE__)) return #else - ! access runSeq in the config - call SetFromConfig(driver, mode="setRunSequence", rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=trim(name)//":"//__FILE__)) return ! bail out +! access runSeq in the config +! --------------------------- + call SetFromConfig(driver, mode="setRunSequence", rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=trim(name)//":"//__FILE__)) return #endif - - ! Diagnostic output - if(verbose_diagnostics()) then - call NUOPC_DriverPrint(driver, orderflag=.true., rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=trim(name)//":"//__FILE__)) return ! bail out - endif - - end subroutine - - !----------------------------------------------------------------------------- + +! Diagnostic output +! ----------------- + if(verbose_diagnostics()) then + call NUOPC_DriverPrint(driver, orderflag=.true., rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=trim(name)//":"//__FILE__)) return + endif + + end subroutine + + !----------------------------------------------------------------------------- #if ESMF_VERSION_MAJOR < 8 !TODOgjt: REMOVE THIS BLOCK ONCE SHOWN TO WORK WITHOUT - subroutine SetFromConfig(driver, mode, rc) - type(ESMF_GridComp) :: driver - character(len=*) :: mode - integer, intent(out) :: rc - - ! local variables - character(ESMF_MAXSTR) :: name - type(ESMF_Config) :: config - integer :: lineCount, columnCount, i, slotCount - integer, allocatable :: count(:) - character(len=32), allocatable :: line(:) - character(len=32) :: tempString - logical :: phaseFlag - integer :: level, slot, slotHWM - real(ESMF_KIND_R8) :: seconds - integer, allocatable :: slotStack(:) - type(ESMF_TimeInterval) :: timeStep - type(ESMF_Clock) :: internalClock, subClock - character(len=60), allocatable :: connectorInstance(:) - integer :: connectorCount, j - type(ESMF_CplComp) :: conn - - character(len=ESMF_MAXSTR) :: msgString - character(len=10) :: value - - !can set to 'max' to recover intro/extro CurrGarbInfo for - !all connectors - character(len=10) :: defaultVerbosity = "0" - !character(len=10) :: defaultVerbosity = "max" - - rc = ESMF_SUCCESS - - ! query the Component for info - call ESMF_GridCompGet(driver, name=name, config=config, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=trim(name)//":"//__FILE__)) return ! bail out - - ! reset config to beginning of runSeq:: block - call ESMF_ConfigFindLabel(config, label="runSeq::", rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=trim(name)//":"//__FILE__)) return ! bail out - call ESMF_ConfigGetDim(config, lineCount, columnCount, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=trim(name)//":"//__FILE__)) return ! bail out - - allocate(count(lineCount)) - - if (trim(mode)=="setServicesConnectors") then - allocate(connectorInstance(lineCount)) ! max number of connectors - connectorCount = 0 ! reset - write(msgString,'(a,i6)')'max number of connectors ',lineCount - call ESMF_LogWrite(msgString, ESMF_LOGMSG_INFO, rc=rc) - endif - - ! reset config to beginning of runSeq:: block - call ESMF_ConfigFindLabel(config, label="runSeq::", rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=trim(name)//":"//__FILE__)) return ! bail out - - ! determine number of entries on each line - do i=1, lineCount - call ESMF_ConfigNextLine(config) - count(i) = ESMF_ConfigGetLen(config) ! entries on line i - enddo - - ! reset config to beginning of runSeq:: block - call ESMF_ConfigFindLabel(config, label="runSeq::", rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=trim(name)//":"//__FILE__)) return ! bail out - - ! read each line and determine slotCount - slotCount = 0 - do i=1, lineCount - call ESMF_ConfigNextLine(config) - allocate(line(count(i))) - call ESMF_ConfigGetAttribute(config, line, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=trim(name)//":"//__FILE__)) return ! bail out - - ! process the configuration line - if (size(line) == 1) then - if (index(trim(line(1)),"@") == 1) then - slotCount = slotCount + 1 - endif - elseif ((size(line) == 3) .or. (size(line) == 4)) then + subroutine SetFromConfig(driver, mode, rc) + type(ESMF_GridComp) :: driver + character(len=*) :: mode + integer, intent(out) :: rc + +! local variables +! --------------- + character(ESMF_MAXSTR) :: name + type(ESMF_Config) :: config + integer :: lineCount, columnCount, i, slotCount + integer, allocatable :: count(:) + character(len=32), allocatable :: line(:) + character(len=32) :: tempString + logical :: phaseFlag + integer :: level, slot, slotHWM + real(ESMF_KIND_R8) :: seconds + integer, allocatable :: slotStack(:) + type(ESMF_TimeInterval) :: timeStep + type(ESMF_Clock) :: internalClock, subClock + character(len=60), allocatable :: connectorInstance(:) + integer :: connectorCount, j + type(ESMF_CplComp) :: conn + + character(len=ESMF_MAXSTR) :: msgString + character(len=10) :: value + +! can set to 'max' to recover intro/extro CurrGarbInfo for all connectors +! ----------------------------------------------------------------------- + character(len=10) :: defaultVerbosity = "0" + !character(len=10) :: defaultVerbosity = "max" + + rc = ESMF_SUCCESS + +! query the Component for info +! ---------------------------- + call ESMF_GridCompGet(driver, name=name, config=config, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=trim(name)//":"//__FILE__)) return + +! reset config to beginning of runSeq:: block +! ------------------------------------------- + call ESMF_ConfigFindLabel(config, label="runSeq::", rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=trim(name)//":"//__FILE__)) return + + call ESMF_ConfigGetDim(config, lineCount, columnCount, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=trim(name)//":"//__FILE__)) return + + allocate(count(lineCount)) + if (trim(mode)=="setServicesConnectors") then - ! a connector if the second element is "->" - if (trim(line(2)) /= "->") then - call ESMF_LogSetError(rcToCheck=ESMF_RC_ARG_BAD, & - msg="Configuration line incorrectly formatted.", & - line=__LINE__, & - file=__FILE__) - return ! bail out - else - ! found a connector entry, see if it is the first instance - do j=1, connectorCount - if (trim(connectorInstance(j)) == & - trim(line(1))//trim(line(2))//trim(line(3))) exit - enddo - if (j>connectorCount) then - ! this is a new Connector instance - connectorCount = j - connectorInstance(j) = trim(line(1))//trim(line(2))//trim(line(3)) - write(msgString,'(a,i4,a,i4,4a)')'Connector j = ',j,& - ' line number ', i,& - ' ',trim(connectorInstance(j)),& - ' Verbosity = ',trim(defaultVerbosity) - call ESMF_LogWrite(msgString, ESMF_LOGMSG_INFO, rc=rc) - ! SetServices for new Connector instance - call NUOPC_DriverAddComp(driver, & - srcCompLabel=trim(line(1)), dstCompLabel=trim(line(3)), & - compSetServicesRoutine=conSS, comp=conn, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=trim(name)//":"//__FILE__)) return ! bail - call NUOPC_CompAttributeSet(conn, name="Verbosity", value=defaultVerbosity, & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=trim(name)//":"//__FILE__)) return ! bail - if (size(line) == 4) then - ! there are additional connection options specified - ! -> set as Attribute for now on the connector object - call ESMF_AttributeSet(conn, name="ConnectionOptions", & - value=trim(line(4)), rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=trim(name)//":"//__FILE__)) return ! bail - endif - endif - endif + allocate(connectorInstance(lineCount)) ! max number of connectors + connectorCount = 0 ! reset + write(msgString,'(a,i6)')'max number of connectors ',lineCount + call ESMF_LogWrite(msgString, ESMF_LOGMSG_INFO, rc=rc) endif - endif - ! clean-up - deallocate(line) - enddo - slotCount = (slotCount+1) / 2 - slotCount = max(slotCount, 1) ! at least one slot - - if (trim(mode)=="setRunSequence") then - - allocate(slotStack(slotCount)) - - ! Replace the default RunSequence with a customized one - call NUOPC_DriverNewRunSequence(driver, slotCount=slotCount, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - - ! Get driver intenalClock - call ESMF_GridCompGet(driver, clock=internalClock, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - - ! reset config to beginning of runSeq:: block - call ESMF_ConfigFindLabel(config, label="runSeq::", rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=trim(name)//":"//__FILE__)) return ! bail out - - level = 0 - slot = 0 - slotHWM = 0 - do i=1, lineCount - call ESMF_ConfigNextLine(config) - allocate(line(count(i))) - call ESMF_ConfigGetAttribute(config, line, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=trim(name)//":"//__FILE__)) return ! bail out - - ! process the configuration line - if ((size(line) < 1) .or. (size(line) > 4)) then - call ESMF_LogSetError(rcToCheck=ESMF_RC_ARG_BAD, & - msg="Configuration line incorrectly formatted.", & - line=__LINE__, & - file=__FILE__) - return ! bail out - elseif (size(line) == 1) then - ! either a model or a time step indicator - if (index(trim(line(1)),"@") == 1) then - ! time step indicator - tempString=trim(line(1)) - if (len(trim(tempString)) > 1) then - ! entering new time loop level - level = level + 1 - slotStack(level)=slot - slot = slotHWM + 1 - slotHWM = slotHWM + 1 - read(tempString(2:len(tempString)), *) seconds - !print *, "found time step indicator: ", seconds - call ESMF_TimeIntervalSet(timeStep, s_r8=seconds, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - if (slot==1) then - ! Set the timeStep of the internalClock - call ESMF_ClockSet(internalClock, timeStep=timeStep, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out + +! reset config to beginning of runSeq:: block +! ------------------------------------------- + call ESMF_ConfigFindLabel(config, label="runSeq::", rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=trim(name)//":"//__FILE__)) return + +! determine number of entries on each line +! ---------------------------------------- + do i=1, lineCount + call ESMF_ConfigNextLine(config) + count(i) = ESMF_ConfigGetLen(config) ! entries on line i + enddo + +! reset config to beginning of runSeq:: block +! ------------------------------------------- + call ESMF_ConfigFindLabel(config, label="runSeq::", rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=trim(name)//":"//__FILE__)) return + +! read each line and determine slotCount +! -------------------------------------- + slotCount = 0 + do i=1, lineCount + call ESMF_ConfigNextLine(config) + allocate(line(count(i))) + call ESMF_ConfigGetAttribute(config, line, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=trim(name)//":"//__FILE__)) return + +! process the configuration line +! ------------------------------ + if (size(line) == 1) then + if (index(trim(line(1)),"@") == 1) then + slotCount = slotCount + 1 + endif + elseif ((size(line) == 3) .or. (size(line) == 4)) then + if (trim(mode) == "setServicesConnectors") then + ! a connector if the second element is "->" + if (trim(line(2)) /= "->") then + call ESMF_LogSetError(rcToCheck=ESMF_RC_ARG_BAD, & + msg="Configuration line incorrectly formatted.", & + line=__LINE__, file=__FILE__) + return else - ! Insert the link to a new slot, and set the timeStep - call NUOPC_DriverAddRunElement(driver, slot=slotStack(level), & - linkSlot=slot, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=trim(name)//":"//__FILE__)) return ! bail out - subClock = ESMF_ClockCreate(internalClock, rc=rc) ! make a copy first - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=trim(name)//":"//__FILE__)) return ! bail out - call ESMF_ClockSet(subClock, timeStep=timeStep, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=trim(name)//":"//__FILE__)) return ! bail out - call NUOPC_DriverSetRunSequence(driver, slot=slot, & - clock=subClock, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=trim(name)//":"//__FILE__)) return ! bail out +! found a connector entry, see if it is the first instance +! - ------------------------------------- + do j=1, connectorCount + if (trim(connectorInstance(j)) == & + trim(line(1))//trim(line(2))//trim(line(3))) exit + enddo + if (j > connectorCount) then +! this is a new Connector instance +! - ------------------------------------- + connectorCount = j + connectorInstance(j) = trim(line(1))//trim(line(2))//trim(line(3)) + write(msgString,'(a,i4,a,i4,4a)')'Connector j = ',j, & + ' line number ', i, & + ' ',trim(connectorInstance(j)),& + ' Verbosity = ',trim(defaultVerbosity) + call ESMF_LogWrite(msgString, ESMF_LOGMSG_INFO, rc=rc) +! SetServices for new Connector instance +! -------------------------------------- + call NUOPC_DriverAddComp(driver, & + srcCompLabel=trim(line(1)), dstCompLabel=trim(line(3)), & + compSetServicesRoutine=conSS, comp=conn, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=trim(name)//":"//__FILE__)) return + + call NUOPC_CompAttributeSet(conn, name="Verbosity", value=defaultVerbosity, & + rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=trim(name)//":"//__FILE__)) return + + if (size(line) == 4) then +! there are additional connection options specified +! -> set as Attribute for now on the connector object +! -------------------------------------- + call ESMF_AttributeSet(conn, name="ConnectionOptions", & + value=trim(line(4)), rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=trim(name)//":"//__FILE__)) return + endif + endif endif - else - ! exiting time loop level - slot = slotStack(level) - level = level - 1 endif - else - ! model - slot = max(slot, 1) ! model outside of a time loop - call NUOPC_DriverAddRunElement(driver, slot=slot, & - compLabel=trim(line(1)), rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out endif - elseif (size(line) == 2) then - ! a model with a specific phase label - call NUOPC_DriverAddRunElement(driver, slot=slot, & - compLabel=trim(line(1)), phaseLabel=trim(line(2)), rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - elseif ((size(line) == 3) .or. (size(line) == 4)) then - ! a connector if the second element is "->", with options if 4th part - if (trim(line(2)) /= "->") then - call ESMF_LogSetError(rcToCheck=ESMF_RC_ARG_BAD, & - msg="Configuration line incorrectly formatted.", & - line=__LINE__, & - file=__FILE__) - return ! bail out - endif - call NUOPC_DriverAddRunElement(driver, slot=slot, & - srcCompLabel=trim(line(1)), dstCompLabel=trim(line(3)), rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - endif - - ! clean-up - deallocate(line) - enddo - ! clean-up - deallocate(slotStack) - endif +! clean-up + deallocate(line) + enddo + slotCount = (slotCount+1) / 2 + slotCount = max(slotCount, 1) ! at least one slot + + if (trim(mode) == "setRunSequence") then + + allocate(slotStack(slotCount)) + +! Replace the default RunSequence with a customized one + call NUOPC_DriverNewRunSequence(driver, slotCount=slotCount, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + +! Get driver intenalClock + call ESMF_GridCompGet(driver, clock=internalClock, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + +! reset config to beginning of runSeq:: block + call ESMF_ConfigFindLabel(config, label="runSeq::", rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=trim(name)//":"//__FILE__)) return + + level = 0 + slot = 0 + slotHWM = 0 + do i=1, lineCount + call ESMF_ConfigNextLine(config) + allocate(line(count(i))) + call ESMF_ConfigGetAttribute(config, line, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=trim(name)//":"//__FILE__)) return + +! process the configuration line + if ((size(line) < 1) .or. (size(line) > 4)) then + call ESMF_LogSetError(rcToCheck=ESMF_RC_ARG_BAD, & + msg="Configuration line incorrectly formatted.", line=__LINE__, file=__FILE__) + return + elseif (size(line) == 1) then +! either a model or a time step indicator + if (index(trim(line(1)),"@") == 1) then +! time step indicator + tempString = trim(line(1)) + if (len(trim(tempString)) > 1) then +! entering new time loop level + level = level + 1 + slotStack(level) = slot + slot = slotHWM + 1 + slotHWM = slotHWM + 1 + read(tempString(2:len(tempString)), *) seconds +! print *, "found time step indicator: ", seconds + + call ESMF_TimeIntervalSet(timeStep, s_r8=seconds, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + + if (slot == 1) then ! Set the timeStep of the internalClock + call ESMF_ClockSet(internalClock, timeStep=timeStep, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + + else ! Insert the link to a new slot, and set the timeStep + call NUOPC_DriverAddRunElement(driver, slot=slotStack(level), & + linkSlot=slot, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=trim(name)//":"//__FILE__)) return + + subClock = ESMF_ClockCreate(internalClock, rc=rc) ! make a copy first + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=trim(name)//":"//__FILE__)) return + + call ESMF_ClockSet(subClock, timeStep=timeStep, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=trim(name)//":"//__FILE__)) return + + call NUOPC_DriverSetRunSequence(driver, slot=slot, & + clock = subClock, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=trim(name)//":"//__FILE__)) return + endif + else ! exiting time loop level + slot = slotStack(level) + level = level - 1 + endif + else ! model + slot = max(slot, 1) ! model outside of a time loop + call NUOPC_DriverAddRunElement(driver, slot=slot, & + compLabel=trim(line(1)), rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + endif + elseif (size(line) == 2) then ! a model with a specific phase label + call NUOPC_DriverAddRunElement(driver, slot=slot, & + compLabel=trim(line(1)), & + phaseLabel=trim(line(2)), rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + + elseif ((size(line) == 3) .or. (size(line) == 4)) then +! a connector if the second element is "->", with options if 4th part +! ------------------------------------------------------------------- + if (trim(line(2)) /= "->") then + call ESMF_LogSetError(rcToCheck=ESMF_RC_ARG_BAD, & + msg="Configuration line incorrectly formatted.", line=__LINE__, file=__FILE__) + return + endif + call NUOPC_DriverAddRunElement(driver, slot=slot, & + srcCompLabel=trim(line(1)), & + dstCompLabel=trim(line(3)), rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + endif + + deallocate(line) ! clean-up + enddo + deallocate(slotStack) ! clean-up + endif - ! clean-up - deallocate(count) - if (trim(mode)=="setServicesConnectors") then - deallocate(connectorInstance) - endif + deallocate(count) ! clean-up + if (trim(mode)=="setServicesConnectors") then + deallocate(connectorInstance) + endif - end subroutine + end subroutine #endif - !----------------------------------------------------------------------------- - subroutine Finalize(driver, rc) - type(ESMF_GridComp) :: driver - integer, intent(out) :: rc - - ! local variables - integer :: localrc, stat - type(WRAP_EARTH_INTERNAL_STATE) :: is - logical :: existflag - character(ESMF_MAXSTR) :: name + !----------------------------------------------------------------------------- + + subroutine Finalize(driver, rc) + type(ESMF_GridComp) :: driver + integer, intent(out) :: rc - rc = ESMF_SUCCESS +! local variables + integer :: localrc, stat + type(WRAP_EARTH_INTERNAL_STATE) :: is + logical :: existflag + character(ESMF_MAXSTR) :: name - ! query the Component for info - call ESMF_GridCompGet(driver, name=name, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=trim(name)//":"//__FILE__)) return ! bail out - - ! query Component for this internal State - nullify(is%EARTH_INT_STATE) - call ESMF_GridCompGetInternalState(driver, is, rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=trim(name)//":"//__FILE__)) return ! bail out - - ! deallocate internal state memory - deallocate(is%EARTH_INT_STATE, stat=stat) - if (ESMF_LogFoundDeallocError(statusToCheck=stat, & - msg="Deallocation of internal state memory failed.", & - line=__LINE__, file=trim(name)//":"//__FILE__, rcToReturn=rc)) & - return ! bail out - - end subroutine - - !----------------------------------------------------------------------------- - - recursive subroutine ModifyCplLists(driver, importState, exportState, clock, & - rc) - type(ESMF_GridComp) :: driver - type(ESMF_State) :: importState, exportState - type(ESMF_Clock) :: clock - integer, intent(out) :: rc - - character(len=160) :: name, msg - type(ESMF_CplComp), pointer :: connectorList(:) - integer :: i, j, cplListSize - character(len=160), allocatable :: cplList(:) - character(len=160) :: value - type(WRAP_EARTH_INTERNAL_STATE) :: is - - rc = ESMF_SUCCESS - - ! query Component for this internal State - nullify(is%EARTH_INT_STATE) - call ESMF_GridCompGetInternalState(driver, is, rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - - call ESMF_LogWrite("Driver is in ModifyCplLists()", ESMF_LOGMSG_INFO, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - - nullify(connectorList) - call NUOPC_DriverGetComp(driver, compList=connectorList, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - - write (msg,*) "Found ", size(connectorList), " Connectors."// & - " Modifying CplList Attribute...." - call ESMF_LogWrite(trim(msg), ESMF_LOGMSG_INFO, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - - do i=1, size(connectorList) - ! query Connector i for its name - call ESMF_CplCompGet(connectorList(i), name=name, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - ! access CplList for Connector i - call NUOPC_CompAttributeGet(connectorList(i), name="CplList", & - itemCount=cplListSize, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - if (cplListSize>0) then - allocate(cplList(cplListSize)) - call NUOPC_CompAttributeGet(connectorList(i), name="CplList", & - valueList=cplList, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - ! go through all of the entries in the cplList and add options - do j=1, cplListSize - cplList(j) = trim(cplList(j))//":DumpWeights=true" - cplList(j) = trim(cplList(j))//":SrcTermProcessing=1:TermOrder=SrcSeq" - ! add connection options read in from configuration file - call ESMF_AttributeGet(connectorList(i), name="ConnectionOptions", & - value=value, defaultValue="", rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - cplList(j) = trim(cplList(j))//trim(value) + rc = ESMF_SUCCESS + +! query the Component for info + call ESMF_GridCompGet(driver, name=name, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=trim(name)//":"//__FILE__)) return + +! query Component for this internal State + nullify(is%EARTH_INT_STATE) + call ESMF_GridCompGetInternalState(driver, is, rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=trim(name)//":"//__FILE__)) return + +! deallocate internal state memory + deallocate(is%EARTH_INT_STATE, stat=stat) + if (ESMF_LogFoundDeallocError(statusToCheck=stat, & + msg="Deallocation of internal state memory failed.", & + line=__LINE__, file=trim(name)//":"//__FILE__, rcToReturn=rc)) return + + end subroutine + + !----------------------------------------------------------------------------- + + recursive subroutine ModifyCplLists(driver, importState, exportState, clock, rc) + type(ESMF_GridComp) :: driver + type(ESMF_State) :: importState, exportState + type(ESMF_Clock) :: clock + integer, intent(out) :: rc + + character(len=160) :: name, msg + type(ESMF_CplComp), pointer :: connectorList(:) + integer :: i, j, cplListSize + character(len=160), allocatable :: cplList(:) + character(len=160) :: value + type(WRAP_EARTH_INTERNAL_STATE) :: is + + rc = ESMF_SUCCESS + +! query Component for this internal State + + nullify(is%EARTH_INT_STATE) + call ESMF_GridCompGetInternalState(driver, is, rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + + call ESMF_LogWrite("Driver is in ModifyCplLists()", ESMF_LOGMSG_INFO, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + + nullify(connectorList) + call NUOPC_DriverGetComp(driver, compList=connectorList, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + + write (msg,*) "Found ", size(connectorList), " Connectors."// & + " Modifying CplList Attribute...." + call ESMF_LogWrite(trim(msg), ESMF_LOGMSG_INFO, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + + do i=1, size(connectorList) +! query Connector i for its name + call ESMF_CplCompGet(connectorList(i), name=name, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return +! access CplList for Connector i + call NUOPC_CompAttributeGet(connectorList(i), name="CplList", & + itemCount=cplListSize, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + if (cplListSize>0) then + allocate(cplList(cplListSize)) + call NUOPC_CompAttributeGet(connectorList(i), name="CplList", & + valueList=cplList, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return +! go through all of the entries in the cplList and add options + do j=1, cplListSize + cplList(j) = trim(cplList(j))//":DumpWeights=true" + cplList(j) = trim(cplList(j))//":SrcTermProcessing=1:TermOrder=SrcSeq" +! add connection options read in from configuration file + call ESMF_AttributeGet(connectorList(i), name="ConnectionOptions", & + value=value, defaultValue="", rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + cplList(j) = trim(cplList(j))//trim(value) + enddo +! store the modified cplList in CplList attribute of connector i + call NUOPC_CompAttributeSet(connectorList(i), name="CplList", valueList=cplList, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + deallocate(cplList) + endif enddo - ! store the modified cplList in CplList attribute of connector i - call NUOPC_CompAttributeSet(connectorList(i), & - name="CplList", valueList=cplList, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - deallocate(cplList) - endif - enddo - - deallocate(connectorList) - - end subroutine - !----------------------------------------------------------------------------- + deallocate(connectorList) + end subroutine +! +!----------------------------------------------------------------------- +! #ifdef CMEPS - subroutine ReadAttributes(gcomp, config, label, relaxedflag, formatprint, rc) + subroutine ReadAttributes(gcomp, config, label, relaxedflag, formatprint, rc) - use ESMF , only : ESMF_GridComp, ESMF_Config, ESMF_LogWrite, ESMF_LOGMSG_INFO, ESMF_SUCCESS - use NUOPC , only : NUOPC_FreeFormatCreate, NUOPC_CompAttributeIngest - use NUOPC , only : NUOPC_FreeFormatDestroy, NUOPC_FreeFormat + use ESMF , only : ESMF_GridComp, ESMF_Config, ESMF_LogWrite, ESMF_LOGMSG_INFO, ESMF_SUCCESS + use NUOPC , only : NUOPC_FreeFormatCreate, NUOPC_CompAttributeIngest + use NUOPC , only : NUOPC_FreeFormatDestroy, NUOPC_FreeFormat - ! input/output arguments - type(ESMF_GridComp) , intent(inout) :: gcomp - type(ESMF_Config) , intent(in) :: config - character(len=*) , intent(in) :: label - logical , intent(in), optional :: relaxedflag - logical , intent(in), optional :: formatprint - integer , intent(inout) :: rc + ! input/output arguments + type(ESMF_GridComp) , intent(inout) :: gcomp + type(ESMF_Config) , intent(in) :: config + character(len=*) , intent(in) :: label + logical , intent(in), optional :: relaxedflag + logical , intent(in), optional :: formatprint + integer , intent(inout) :: rc - ! local variables - type(NUOPC_FreeFormat) :: attrFF - character(len=*), parameter :: subname = "(module_EARTH_GRID_COMP.F90:ReadAttributes)" + ! local variables + type(NUOPC_FreeFormat) :: attrFF + character(len=*), parameter :: subname = "(module_EARTH_GRID_COMP.F90:ReadAttributes)" !------------------------------------------- - rc = ESMF_SUCCESS - - if (present(relaxedflag)) then - attrFF = NUOPC_FreeFormatCreate(config, label=trim(label), relaxedflag=.true., rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - else - attrFF = NUOPC_FreeFormatCreate(config, label=trim(label), rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - end if - - call NUOPC_CompAttributeIngest(gcomp, attrFF, addFlag=.true., rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - - call NUOPC_FreeFormatDestroy(attrFF, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - - end subroutine ReadAttributes - - subroutine InitRestart(driver, rc) + rc = ESMF_SUCCESS + + if (present(relaxedflag)) then + attrFF = NUOPC_FreeFormatCreate(config, label=trim(label), relaxedflag=.true., rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + else + attrFF = NUOPC_FreeFormatCreate(config, label=trim(label), rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + end if + + call NUOPC_CompAttributeIngest(gcomp, attrFF, addFlag=.true., rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + + call NUOPC_FreeFormatDestroy(attrFF, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + + end subroutine ReadAttributes + + subroutine InitRestart(driver, rc) !----------------------------------------------------- ! Determine if will restart and read pointer file if appropriate !----------------------------------------------------- - use ESMF , only : ESMF_GridComp, ESMF_VM, ESMF_GridCompGet, ESMF_VMGet, ESMF_SUCCESS - use ESMF , only : ESMF_LogSetError, ESMF_LogWrite, ESMF_LOGMSG_INFO, ESMF_RC_NOT_VALID - use NUOPC , only : NUOPC_CompAttributeGet, NUOPC_CompAttributeSet, NUOPC_CompAttributeAdd + use ESMF , only : ESMF_GridComp, ESMF_VM, ESMF_GridCompGet, ESMF_VMGet, ESMF_SUCCESS + use ESMF , only : ESMF_LogSetError, ESMF_LogWrite, ESMF_LOGMSG_INFO, ESMF_RC_NOT_VALID + use NUOPC , only : NUOPC_CompAttributeGet, NUOPC_CompAttributeSet, NUOPC_CompAttributeAdd ! input/output variables - type(ESMF_GridComp) , intent(inout) :: driver - integer , intent(out) :: rc + type(ESMF_GridComp) , intent(inout) :: driver + integer , intent(out) :: rc ! local variables - logical :: read_restart ! read the restart file, based on start_type - character(len=ESMF_MAXSTR) :: cvalue ! temporary - character(len=ESMF_MAXSTR) :: rest_case_name ! Short case identification - character(len=*) , parameter :: subname = "(module_EARTH_GRID_COMP.F90:InitRestart)" + logical :: read_restart ! read the restart file, based on start_type + character(len=ESMF_MAXSTR) :: cvalue ! temporary + character(len=ESMF_MAXSTR) :: rest_case_name ! Short case identification + character(len=*) , parameter :: subname = "(module_EARTH_GRID_COMP.F90:InitRestart)" !------------------------------------------- - rc = ESMF_SUCCESS - call ESMF_LogWrite(trim(subname)//": called", ESMF_LOGMSG_INFO, rc=rc) + rc = ESMF_SUCCESS + call ESMF_LogWrite(trim(subname)//": called", ESMF_LOGMSG_INFO, rc=rc) !----------------------------------------------------- ! Carry out restart if appropriate !----------------------------------------------------- - read_restart = IsRestart(driver, rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out + read_restart = IsRestart(driver, rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return ! Add rest_case_name and read_restart to driver attributes - call NUOPC_CompAttributeAdd(driver, attrList=(/'rest_case_name','read_restart '/), rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - - rest_case_name = ' ' - call NUOPC_CompAttributeSet(driver, name='rest_case_name', value=rest_case_name, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - - write(cvalue,*) read_restart - call NUOPC_CompAttributeSet(driver, name='read_restart', value=trim(cvalue), rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - - end subroutine InitRestart - - function IsRestart(gcomp, rc) - - use ESMF , only : ESMF_GridComp, ESMF_SUCCESS - use ESMF , only : ESMF_LogSetError, ESMF_LogWrite, ESMF_LOGMSG_INFO, ESMF_RC_NOT_VALID - use NUOPC , only : NUOPC_CompAttributeGet + call NUOPC_CompAttributeAdd(driver, attrList=(/'rest_case_name','read_restart '/), rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + + rest_case_name = ' ' + call NUOPC_CompAttributeSet(driver, name='rest_case_name', value=rest_case_name, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + + write(cvalue,*) read_restart + call NUOPC_CompAttributeSet(driver, name='read_restart', value=trim(cvalue), rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + + end subroutine InitRestart + + function IsRestart(gcomp, rc) + + use ESMF , only : ESMF_GridComp, ESMF_SUCCESS + use ESMF , only : ESMF_LogSetError, ESMF_LogWrite, ESMF_LOGMSG_INFO, ESMF_RC_NOT_VALID + use NUOPC , only : NUOPC_CompAttributeGet ! input/output variables - logical :: IsRestart - type(ESMF_GridComp) , intent(inout) :: gcomp - integer , intent(out) :: rc + logical :: IsRestart + type(ESMF_GridComp) , intent(inout) :: gcomp + integer , intent(out) :: rc ! locals - character(len=ESMF_MAXSTR) :: start_type ! Type of startup - character(len=ESMF_MAXSTR) :: msgstr - character(len=*) , parameter :: start_type_start = "startup" - character(len=*) , parameter :: start_type_cont = "continue" - character(len=*) , parameter :: start_type_brnch = "branch" - character(len=*) , parameter :: subname = "(module_EARTH_GRID_COMP.F90:IsRestart)" + character(len=ESMF_MAXSTR) :: start_type ! Type of startup + character(len=ESMF_MAXSTR) :: msgstr + character(len=*) , parameter :: start_type_start = "startup" + character(len=*) , parameter :: start_type_cont = "continue" + character(len=*) , parameter :: start_type_brnch = "branch" + character(len=*) , parameter :: subname = "(module_EARTH_GRID_COMP.F90:IsRestart)" !--------------------------------------- - rc = ESMF_SUCCESS + rc = ESMF_SUCCESS ! First Determine if restart is read - call NUOPC_CompAttributeGet(gcomp, name='start_type', value=start_type, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - - if ((trim(start_type) /= start_type_start) .and. & - (trim(start_type) /= start_type_cont ) .and. & - (trim(start_type) /= start_type_brnch)) then - write (msgstr, *) subname//': start_type invalid = '//trim(start_type) - call ESMF_LogSetError(ESMF_RC_NOT_VALID, msg=msgstr, line=__LINE__, file=__FILE__, rcToReturn=rc) - return - end if + call NUOPC_CompAttributeGet(gcomp, name='start_type', value=start_type, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + + if ((trim(start_type) /= start_type_start) .and. & + (trim(start_type) /= start_type_cont ) .and. & + (trim(start_type) /= start_type_brnch)) then + write (msgstr, *) subname//': start_type invalid = '//trim(start_type) + call ESMF_LogSetError(ESMF_RC_NOT_VALID, msg=msgstr, line=__LINE__, file=__FILE__, rcToReturn=rc) + return + end if !TODO: this is hard-wired to CIME start/continue types in terms of gcomp - IsRestart = .false. - if (trim(start_type) == trim(start_type_cont) .or. trim(start_type) == trim(start_type_brnch)) then - IsRestart = .true. - end if + IsRestart = .false. + if (trim(start_type) == trim(start_type_cont) .or. trim(start_type) == trim(start_type_brnch)) then + IsRestart = .true. + end if - end function IsRestart + end function IsRestart - subroutine AddAttributes(gcomp, driver, config, compid, compname, inst_suffix, rc) + subroutine AddAttributes(gcomp, driver, config, compid, compname, inst_suffix, rc) ! Add specific set of attributes to components from driver attributes - use ESMF , only : ESMF_GridComp, ESMF_Config, ESMF_LogWrite, ESMF_LOGMSG_INFO, ESMF_SUCCESS - use ESMF , only : ESMF_LogFoundAllocError, ESMF_ConfigGetLen, ESMF_ConfigGetAttribute - use NUOPC , only : NUOPC_CompAttributeAdd, NUOPC_CompAttributeGet, NUOPC_CompAttributeSet + use ESMF , only : ESMF_GridComp, ESMF_Config, ESMF_LogWrite, ESMF_LOGMSG_INFO, ESMF_SUCCESS + use ESMF , only : ESMF_LogFoundAllocError, ESMF_ConfigGetLen, ESMF_ConfigGetAttribute + use NUOPC , only : NUOPC_CompAttributeAdd, NUOPC_CompAttributeGet, NUOPC_CompAttributeSet ! input/output parameters - type(ESMF_GridComp) , intent(inout) :: gcomp - type(ESMF_GridComp) , intent(in) :: driver - type(ESMF_Config) , intent(inout) :: config - integer , intent(in) :: compid - character(len=*) , intent(in) :: compname - character(len=*) , intent(in) :: inst_suffix - integer , intent(inout) :: rc + type(ESMF_GridComp) , intent(inout) :: gcomp + type(ESMF_GridComp) , intent(in) :: driver + type(ESMF_Config) , intent(inout) :: config + integer , intent(in) :: compid + character(len=*) , intent(in) :: compname + character(len=*) , intent(in) :: inst_suffix + integer , intent(inout) :: rc ! local variables - integer :: n - integer :: stat - integer :: inst_index - logical :: is_present - character(len=ESMF_MAXSTR) :: cvalue - character(len=32), allocatable :: compLabels(:) - character(len=32), allocatable :: attrList(:) - integer :: componentCount - character(len=*), parameter :: subname = "(module_EARTH_GRID_COMP.F90:AddAttributes)" - logical :: lvalue = .false. + integer :: n + integer :: stat + integer :: inst_index + logical :: is_present + character(len=ESMF_MAXSTR) :: cvalue + character(len=32), allocatable :: compLabels(:) + character(len=32), allocatable :: attrList(:) + integer :: componentCount + character(len=*), parameter :: subname = "(module_EARTH_GRID_COMP.F90:AddAttributes)" + logical :: lvalue = .false. !------------------------------------------- - rc = ESMF_Success - call ESMF_LogWrite(trim(subname)//": called", ESMF_LOGMSG_INFO) + rc = ESMF_Success + call ESMF_LogWrite(trim(subname)//": called", ESMF_LOGMSG_INFO) !------ ! Add compid to gcomp attributes @@ -4645,112 +1810,78 @@ subroutine AddAttributes(gcomp, driver, config, compid, compname, inst_suffix, r !write(cvalue,*) compid !call NUOPC_CompAttributeAdd(gcomp, attrList=(/'MCTID'/), rc=rc) !if (chkerr(rc,__LINE__,u_FILE_u)) return - !call NUOPC_CompAttributeSet(gcomp, name='MCTID', value=trim(cvalue), rc=rc) + !call NUOPC_CompAttributeSet(gcomp, name='MCTID',value=trim(cvalue), rc=rc) !if (chkerr(rc,__LINE__,u_FILE_u)) return !------ ! Add all the other attributes in AttrList (which have already been added to driver attributes) !------ !allocate(attrList(5)) - !attrList = (/"read_restart", "orb_eccen ", "orb_obliqr ", "orb_lambm0 ", "orb_mvelpp "/) + !attrList = (/"read_restart", "orb_eccen ", "orb_obliqr ","orb_lambm0 ", "orb_mvelpp "/) ! TODO: orb_obliqr and orb_lambm0 not exist - allocate(attrList(1)) - attrList = (/"read_restart"/) - - call NUOPC_CompAttributeAdd(gcomp, attrList=attrList, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - - do n = 1,size(attrList) - if (trim(attrList(n)) == "read_restart") then - call NUOPC_CompAttributeGet(driver, name="mediator_read_restart", value=cvalue, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - - read(cvalue,*) lvalue - - if (.not. lvalue) then - call NUOPC_CompAttributeGet(driver, name=trim(attrList(n)), value=cvalue, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - end if - - call NUOPC_CompAttributeSet(gcomp, name=trim(attrList(n)), value=trim(cvalue), rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - else - print*, trim(attrList(n)) - call NUOPC_CompAttributeGet(driver, name=trim(attrList(n)), value=cvalue, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - call NUOPC_CompAttributeSet(gcomp, name=trim(attrList(n)), value=trim(cvalue), rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - end if - enddo - deallocate(attrList) + + allocate(attrList(1)) + attrList = (/"read_restart"/) + + call NUOPC_CompAttributeAdd(gcomp, attrList=attrList, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + + do n = 1,size(attrList) + if (trim(attrList(n)) == "read_restart") then + call NUOPC_CompAttributeGet(driver, name="mediator_read_restart", value=cvalue, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + + read(cvalue,*) lvalue + + if (.not. lvalue) then + call NUOPC_CompAttributeGet(driver, name=trim(attrList(n)), value=cvalue, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + end if + + call NUOPC_CompAttributeSet(gcomp, name=trim(attrList(n)), value=trim(cvalue), rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + else + print*, trim(attrList(n)) + call NUOPC_CompAttributeGet(driver, name=trim(attrList(n)), value=cvalue, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + + call NUOPC_CompAttributeSet(gcomp, name=trim(attrList(n)), value=trim(cvalue), rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + end if + enddo + deallocate(attrList) !------ ! Add component specific attributes !------ - call ReadAttributes(gcomp, config, trim(compname)//"_attributes::", rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - - call ReadAttributes(gcomp, config, "ALLCOMP_attributes::", rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out + call ReadAttributes(gcomp, config, trim(compname)//"_attributes::", rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + + call ReadAttributes(gcomp, config, "ALLCOMP_attributes::", rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return !------ ! Add multi-instance specific attributes !------ - call NUOPC_CompAttributeAdd(gcomp, attrList=(/'inst_index'/), rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out + call NUOPC_CompAttributeAdd(gcomp, attrList=(/'inst_index'/), rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return ! add inst_index attribute (inst_index is not required for cime internal components) ! for now hard-wire inst_index to 1 - inst_index = 1 - write(cvalue,*) inst_index - call NUOPC_CompAttributeSet(gcomp, name='inst_index', value=trim(cvalue), rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out + inst_index = 1 + write(cvalue,*) inst_index + call NUOPC_CompAttributeSet(gcomp, name='inst_index', value=trim(cvalue), rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return ! add inst_suffix attribute - if (len_trim(inst_suffix) > 0) then - call NUOPC_CompAttributeAdd(gcomp, attrList=(/'inst_suffix'/), rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - call NUOPC_CompAttributeSet(gcomp, name='inst_suffix', value=inst_suffix, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - end if - - end subroutine AddAttributes + if (len_trim(inst_suffix) > 0) then + call NUOPC_CompAttributeAdd(gcomp, attrList=(/'inst_suffix'/), rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call NUOPC_CompAttributeSet(gcomp, name='inst_suffix', value=inst_suffix, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + end if + + end subroutine AddAttributes #endif ! !----------------------------------------------------------------------- diff --git a/src/module_MEDIATOR.F90 b/src/module_MEDIATOR.F90 index 8eef0203..fdfc55fa 100644 --- a/src/module_MEDIATOR.F90 +++ b/src/module_MEDIATOR.F90 @@ -40,142 +40,176 @@ module module_MEDIATOR ! bilinear or path interpolation method is used in the future for regridding ! ice variables to other model components, changes in subroutine ! "MedPhase_prep_atm" is required. -B Li. + ! * 2018-11-05 Cleaned up mediator for supported ocean fraction in the atmosphere + ! and consistent masks between land and ocean. Turned off atm/ocn + ! flux calculation in mediator and nearest neighbor fills. - TC !----------------------------------------------------------------------------- use ESMF use NUOPC - use NUOPC_Mediator, & - mediator_routine_SS => SetServices, & - mediator_routine_Run => routine_Run, & - mediator_label_DataInitialize => label_DataInitialize, & - mediator_label_Advance => label_Advance, & - mediator_label_CheckImport => label_CheckImport, & - mediator_label_TimestampExport => label_TimestampExport, & - mediator_label_SetRunClock => label_SetRunClock + use NUOPC_Mediator, & + mediator_routine_SS => SetServices, & + mediator_routine_Run => routine_Run, & + mediator_label_DataInitialize => label_DataInitialize, & + mediator_label_Advance => label_Advance, & + mediator_label_CheckImport => label_CheckImport, & + mediator_label_TimestampExport => label_TimestampExport, & + mediator_label_SetRunClock => label_SetRunClock use module_MEDIATOR_methods - + implicit none - + private - + ! private internal state to keep instance data type InternalStateStruct - integer :: fastcntr ! slice counter for writing to NetCDF file - integer :: slowcntr ! slice counter for writing to NetCDF file - integer :: accumcntAtm ! accumulator counter - integer :: accumcntOcn ! accumulator counter - integer :: accumcntIce ! accumulator counter - integer :: accumcntLnd ! accumulator counter - integer :: accumcntHyd ! accumulator counter + integer :: fastcntr ! slice counter for writing to NetCDF file + integer :: slowcntr ! slice counter for writing to NetCDF file + integer :: accumcntAtm ! accumulator counter + integer :: accumcntOcn ! accumulator counter + integer :: accumcntIce ! accumulator counter + integer :: accumcntLnd ! accumulator counter + integer :: accumcntHyd ! accumulator counter integer :: accumcntAtmOcn ! accumulator counter - type(ESMF_FieldBundle):: FBaccumAtm ! accumulator of atm export data - type(ESMF_FieldBundle):: FBaccumOcn ! accumulator of ocn export data - type(ESMF_FieldBundle):: FBaccumIce ! accumulator of ice export data - type(ESMF_FieldBundle):: FBaccumLnd ! accumulator of lnd export data - type(ESMF_FieldBundle):: FBaccumHyd ! accumulator of lnd export data + type(ESMF_FieldBundle):: FBaccumAtm ! accumulator of atm export data + type(ESMF_FieldBundle):: FBaccumOcn ! accumulator of ocn export data + type(ESMF_FieldBundle):: FBaccumIce ! accumulator of ice export data + type(ESMF_FieldBundle):: FBaccumLnd ! accumulator of lnd export data + type(ESMF_FieldBundle):: FBaccumHyd ! accumulator of lnd export data type(ESMF_FieldBundle):: FBaccumAtmOcn ! accumulator of atm export data - type(ESMF_FieldBundle):: FBAtm_a ! Atm export data on atm grid - type(ESMF_FieldBundle):: FBAtm_o ! Atm export data mapped to ocn grid -!BL2017 - type(ESMF_FieldBundle):: FBAtm2_o ! Atm export data mapped to ocn grid - type(ESMF_FieldBundle):: FBAtm2_i ! Atm export data mapped to ice grid + type(ESMF_FieldBundle):: FBAtm_a ! Atm export data on atm grid + type(ESMF_FieldBundle):: FBAtm_o ! Atm export data mapped to ocn grid !BL2017 - type(ESMF_FieldBundle):: FBAtm_i ! Atm export data mapped to ice grid - type(ESMF_FieldBundle):: FBAtm_l ! Atm export data mapped to lnd grid - type(ESMF_FieldBundle):: FBAtm_h ! Atm export data mapped to hyd grid - type(ESMF_FieldBundle):: FBOcn_a ! Ocn export data mapped to atm grid - type(ESMF_FieldBundle):: FBOcn_o ! Ocn export data on ocn grid - type(ESMF_FieldBundle):: FBOcn_i ! Ocn export data mapped to ice grid - type(ESMF_FieldBundle):: FBIce_a ! Ice export data mapped to atm grid - type(ESMF_FieldBundle):: FBIce_o ! Ice export data mapped to ocn grid - type(ESMF_FieldBundle):: FBIce_i ! Ice export data on ice grid - type(ESMF_FieldBundle):: FBIce_if ! Ice export data on ice grid multiplied by ice fraction - type(ESMF_FieldBundle):: FBLnd_a ! Lnd export data mapped to atm grid - type(ESMF_FieldBundle):: FBLnd_l ! Lnd export on lnd grid - type(ESMF_FieldBundle):: FBLnd_h ! Lnd export data mapped to hyd grid - type(ESMF_FieldBundle):: FBHyd_l ! Hyd export data mapped to lnd grid - type(ESMF_FieldBundle):: FBHyd_a ! Hyd export data mapped to atm grid - type(ESMF_FieldBundle):: FBHyd_h ! Hyd export on hyd grid - type(ESMF_FieldBundle):: FBAtmOcn_o ! Atm/Ocn flux fields on ocn grid - !type(ESMF_FieldBundle):: FBAtmOcn_a ! Atm/Ocn flux fields on atm grid -!BL2017b - type(ESMF_FieldBundle):: FBOcn2_a ! Ocn export data mapped to atm grid - type(ESMF_FieldBundle):: FBIce2_a ! Ice export data mapped to atm grid - !type(ESMF_FieldBundle):: FBAtmOcn2_a ! Atm/Ocn flux fields on atm grid -!BL2017b - type(ESMF_FieldBundle):: FBforAtm ! data storage for atm import - type(ESMF_FieldBundle):: FBforOcn ! data storage for ocn import - type(ESMF_FieldBundle):: FBforIce ! data storage for ice import - type(ESMF_FieldBundle):: FBforLnd ! data storage for lnd import - type(ESMF_FieldBundle):: FBforHyd ! data storage for hyd import - type(ESMF_RouteHandle):: RH_a2o_bilnr ! atm to ocn bilinear - type(ESMF_RouteHandle):: RH_o2a_bilnr ! ocn to atm - type(ESMF_RouteHandle):: RH_a2i_bilnr ! atm to ice - type(ESMF_RouteHandle):: RH_i2a_bilnr ! ice to atm - type(ESMF_RouteHandle):: RH_a2l_bilnr ! atm to lnd - type(ESMF_RouteHandle):: RH_l2a_bilnr ! lnd to atm - type(ESMF_RouteHandle):: RH_a2h_bilnr ! atm to hyd - type(ESMF_RouteHandle):: RH_h2a_bilnr ! hyd to atm - type(ESMF_RouteHandle):: RH_o2i_bilnr ! ocn to ice - type(ESMF_RouteHandle):: RH_i2o_bilnr ! ice to ocn - type(ESMF_RouteHandle):: RH_l2h_bilnr ! lnd to hyd - type(ESMF_RouteHandle):: RH_h2l_bilnr ! hyd to lnd - type(ESMF_RouteHandle):: RH_a2o_consf ! atm to ocn conservative fracarea - type(ESMF_RouteHandle):: RH_o2a_consf ! ocn to atm - type(ESMF_RouteHandle):: RH_a2i_consf ! atm to ice - type(ESMF_RouteHandle):: RH_i2a_consf ! ice to atm - type(ESMF_RouteHandle):: RH_a2l_consf ! atm to lnd - type(ESMF_RouteHandle):: RH_l2a_consf ! lnd to atm - type(ESMF_RouteHandle):: RH_a2h_consf ! atm to hyd - type(ESMF_RouteHandle):: RH_h2a_consf ! hyd to atm - type(ESMF_RouteHandle):: RH_o2i_consf ! ocn to ice - type(ESMF_RouteHandle):: RH_i2o_consf ! ice to ocn - type(ESMF_RouteHandle):: RH_l2h_consf ! lnd to hyd - type(ESMF_RouteHandle):: RH_h2l_consf ! hyd to lnd - type(ESMF_RouteHandle):: RH_a2o_consd ! atm to ocn conservative dstarea - type(ESMF_RouteHandle):: RH_o2a_consd ! ocn to atm - type(ESMF_RouteHandle):: RH_a2i_consd ! atm to ice - type(ESMF_RouteHandle):: RH_i2a_consd ! ice to atm - type(ESMF_RouteHandle):: RH_a2l_consd ! atm to lnd - type(ESMF_RouteHandle):: RH_l2a_consd ! lnd to atm - type(ESMF_RouteHandle):: RH_a2h_consd ! atm to hyd - type(ESMF_RouteHandle):: RH_h2a_consd ! hyd to atm - type(ESMF_RouteHandle):: RH_o2i_consd ! ocn to ice - type(ESMF_RouteHandle):: RH_i2o_consd ! ice to ocn - type(ESMF_RouteHandle):: RH_l2h_consd ! lnd to hyd - type(ESMF_RouteHandle):: RH_h2l_consd ! hyd to lnd -!BL2017 - type(ESMF_RouteHandle):: RH_a2o_nearest ! atm to ocn nearest neighbor stod - type(ESMF_RouteHandle):: RH_a2i_nearest ! atm to ice nearest neighbor stod + type(ESMF_FieldBundle):: FBAtm2_o ! Atm export data mapped to ocn grid + type(ESMF_FieldBundle):: FBAtm2_i ! Atm export data mapped to ice grid !BL2017 + type(ESMF_FieldBundle):: FBAtm_i ! Atm export data mapped to ice grid + type(ESMF_FieldBundle):: FBAtm_l ! Atm export data mapped to lnd grid + type(ESMF_FieldBundle):: FBAtm_h ! Atm export data mapped to hyd grid + type(ESMF_FieldBundle):: FBOcn_a ! Ocn export data mapped to atm grid + type(ESMF_FieldBundle):: FBOcn_o ! Ocn export data on ocn grid + type(ESMF_FieldBundle):: FBOcn_i ! Ocn export data mapped to ice grid + type(ESMF_FieldBundle):: FBIce_a ! Ice export data mapped to atm grid + type(ESMF_FieldBundle):: FBIce_o ! Ice export data mapped to ocn grid + type(ESMF_FieldBundle):: FBIce_i ! Ice export data on ice grid + type(ESMF_FieldBundle):: FBIce_if ! Ice export data on ice grid multiplied by ice fraction + type(ESMF_FieldBundle):: FBLnd_a ! Lnd export data mapped to atm grid + type(ESMF_FieldBundle):: FBLnd_l ! Lnd export on lnd grid + type(ESMF_FieldBundle):: FBLnd_h ! Lnd export data mapped to hyd grid + type(ESMF_FieldBundle):: FBHyd_l ! Hyd export data mapped to lnd grid + type(ESMF_FieldBundle):: FBHyd_a ! Hyd export data mapped to atm grid + type(ESMF_FieldBundle):: FBHyd_h ! Hyd export on hyd grid + type(ESMF_FieldBundle):: FBAtmOcn_o ! Atm/Ocn flux fields on ocn grid + type(ESMF_FieldBundle):: FBAtmOcn_a ! Atm/Ocn flux fields on atm grid !BL2017b - type(ESMF_RouteHandle):: RH_i2a_nearest ! ice to atm nearest neighbor stod - type(ESMF_RouteHandle):: RH_o2a_nearest ! ocn to atm nearest neighbor stod + type(ESMF_FieldBundle):: FBOcn2_a ! Ocn export data mapped to atm grid + type(ESMF_FieldBundle):: FBIce2_a ! Ice export data mapped to atm grid + type(ESMF_FieldBundle):: FBAtmOcn2_a ! Atm/Ocn flux fields on atm grid !BL2017b - type(ESMF_RouteHandle):: RH_a2o_patch ! atm to ocn patch - type(ESMF_RouteHandle):: RH_o2a_patch ! ocn to atm - type(ESMF_RouteHandle):: RH_a2i_patch ! atm to ice - type(ESMF_RouteHandle):: RH_i2a_patch ! ice to atm - type(ESMF_RouteHandle):: RH_a2l_patch ! atm to lnd - type(ESMF_RouteHandle):: RH_l2a_patch ! lnd to atm - type(ESMF_RouteHandle):: RH_a2h_patch ! atm to hyd - type(ESMF_RouteHandle):: RH_h2a_patch ! hyd to atm - type(ESMF_RouteHandle):: RH_o2i_patch ! ocn to ice - type(ESMF_RouteHandle):: RH_i2o_patch ! ice to ocn - type(ESMF_RouteHandle):: RH_l2h_patch ! lnd to hyd - type(ESMF_RouteHandle):: RH_h2l_patch ! hyd to lnd - type(ESMF_RouteHandle):: RH_a2o_fcopy ! atm to ocn fcopy - type(ESMF_RouteHandle):: RH_o2a_fcopy ! ocn to atm - type(ESMF_RouteHandle):: RH_a2i_fcopy ! atm to ice - type(ESMF_RouteHandle):: RH_i2a_fcopy ! ice to atm - type(ESMF_RouteHandle):: RH_a2l_fcopy ! atm to lnd - type(ESMF_RouteHandle):: RH_l2a_fcopy ! lnd to atm - type(ESMF_RouteHandle):: RH_a2h_fcopy ! atm to hyd - type(ESMF_RouteHandle):: RH_h2a_fcopy ! hyd to atm - type(ESMF_RouteHandle):: RH_o2i_fcopy ! ocn to ice - type(ESMF_RouteHandle):: RH_i2o_fcopy ! ice to ocn - type(ESMF_RouteHandle):: RH_l2h_fcopy ! lnd to hyd - type(ESMF_RouteHandle):: RH_h2l_fcopy ! hyd to lnd + type(ESMF_FieldBundle):: FBforAtm ! data storage for atm import + type(ESMF_FieldBundle):: FBforOcn ! data storage for ocn import + type(ESMF_FieldBundle):: FBforIce ! data storage for ice import + type(ESMF_FieldBundle):: FBforLnd ! data storage for lnd import + type(ESMF_FieldBundle):: FBforHyd ! data storage for hyd import + + type(ESMF_RouteHandle):: RH_a2o_bilnr ! atm to ocn bilinear + type(ESMF_RouteHandle):: RH_o2a_bilnr ! ocn to atm + type(ESMF_RouteHandle):: RH_a2i_bilnr ! atm to ice + type(ESMF_RouteHandle):: RH_i2a_bilnr ! ice to atm + type(ESMF_RouteHandle):: RH_a2l_bilnr ! atm to lnd + type(ESMF_RouteHandle):: RH_l2a_bilnr ! lnd to atm + type(ESMF_RouteHandle):: RH_a2h_bilnr ! atm to hyd + type(ESMF_RouteHandle):: RH_h2a_bilnr ! hyd to atm + type(ESMF_RouteHandle):: RH_o2i_bilnr ! ocn to ice + type(ESMF_RouteHandle):: RH_i2o_bilnr ! ice to ocn + type(ESMF_RouteHandle):: RH_l2h_bilnr ! lnd to hyd + type(ESMF_RouteHandle):: RH_h2l_bilnr ! hyd to lnd + + type(ESMF_RouteHandle):: RH_a2o_consf ! atm to ocn conservative fracarea + type(ESMF_RouteHandle):: RH_o2a_consf ! ocn to atm + type(ESMF_RouteHandle):: RH_a2i_consf ! atm to ice + type(ESMF_RouteHandle):: RH_i2a_consf ! ice to atm + type(ESMF_RouteHandle):: RH_a2l_consf ! atm to lnd + type(ESMF_RouteHandle):: RH_l2a_consf ! lnd to atm + type(ESMF_RouteHandle):: RH_a2h_consf ! atm to hyd + type(ESMF_RouteHandle):: RH_h2a_consf ! hyd to atm + type(ESMF_RouteHandle):: RH_o2i_consf ! ocn to ice + type(ESMF_RouteHandle):: RH_i2o_consf ! ice to ocn + type(ESMF_RouteHandle):: RH_l2h_consf ! lnd to hyd + type(ESMF_RouteHandle):: RH_h2l_consf ! hyd to lnd + type(ESMF_RouteHandle):: RH_a2o_consd ! atm to ocn conservative dstarea + type(ESMF_RouteHandle):: RH_o2a_consd ! ocn to atm + type(ESMF_RouteHandle):: RH_a2i_consd ! atm to ice + type(ESMF_RouteHandle):: RH_i2a_consd ! ice to atm + type(ESMF_RouteHandle):: RH_a2l_consd ! atm to lnd + type(ESMF_RouteHandle):: RH_l2a_consd ! lnd to atm + type(ESMF_RouteHandle):: RH_a2h_consd ! atm to hyd + type(ESMF_RouteHandle):: RH_h2a_consd ! hyd to atm + type(ESMF_RouteHandle):: RH_o2i_consd ! ocn to ice + type(ESMF_RouteHandle):: RH_i2o_consd ! ice to ocn + type(ESMF_RouteHandle):: RH_l2h_consd ! lnd to hyd + type(ESMF_RouteHandle):: RH_h2l_consd ! hyd to lnd + + type(ESMF_RouteHandle):: RH_a2o_con2f ! atm to ocn conservative 2nd order fracarea + type(ESMF_RouteHandle):: RH_o2a_con2f ! ocn to atm + type(ESMF_RouteHandle):: RH_a2i_con2f ! atm to ice + type(ESMF_RouteHandle):: RH_i2a_con2f ! ice to atm + type(ESMF_RouteHandle):: RH_a2l_con2f ! atm to lnd + type(ESMF_RouteHandle):: RH_l2a_con2f ! lnd to atm + type(ESMF_RouteHandle):: RH_a2h_con2f ! atm to hyd + type(ESMF_RouteHandle):: RH_h2a_con2f ! hyd to atm + type(ESMF_RouteHandle):: RH_o2i_con2f ! ocn to ice + type(ESMF_RouteHandle):: RH_i2o_con2f ! ice to ocn + type(ESMF_RouteHandle):: RH_l2h_con2f ! lnd to hyd + type(ESMF_RouteHandle):: RH_h2l_con2f ! hyd to lnd + + type(ESMF_RouteHandle):: RH_a2o_con2d ! atm to ocn conservative 2nd order dstarea + type(ESMF_RouteHandle):: RH_o2a_con2d ! ocn to atm + type(ESMF_RouteHandle):: RH_a2i_con2d ! atm to ice + type(ESMF_RouteHandle):: RH_i2a_con2d ! ice to atm + type(ESMF_RouteHandle):: RH_a2l_con2d ! atm to lnd + type(ESMF_RouteHandle):: RH_l2a_con2d ! lnd to atm + type(ESMF_RouteHandle):: RH_a2h_con2d ! atm to hyd + type(ESMF_RouteHandle):: RH_h2a_con2d ! hyd to atm + type(ESMF_RouteHandle):: RH_o2i_con2d ! ocn to ice + type(ESMF_RouteHandle):: RH_i2o_con2d ! ice to ocn + type(ESMF_RouteHandle):: RH_l2h_con2d ! lnd to hyd + type(ESMF_RouteHandle):: RH_h2l_con2d ! hyd to lnd + + type(ESMF_RouteHandle):: RH_a2o_nrnbr ! atm to ocn nearest neighbor stod + type(ESMF_RouteHandle):: RH_a2i_nrnbr ! atm to ice nearest neighbor stod + type(ESMF_RouteHandle):: RH_i2a_nrnbr ! ice to atm nearest neighbor stod + type(ESMF_RouteHandle):: RH_o2a_nrnbr ! ocn to atm nearest neighbor stod + + type(ESMF_RouteHandle):: RH_a2o_patch ! atm to ocn patch + type(ESMF_RouteHandle):: RH_o2a_patch ! ocn to atm + type(ESMF_RouteHandle):: RH_a2i_patch ! atm to ice + type(ESMF_RouteHandle):: RH_i2a_patch ! ice to atm + type(ESMF_RouteHandle):: RH_a2l_patch ! atm to lnd + type(ESMF_RouteHandle):: RH_l2a_patch ! lnd to atm + type(ESMF_RouteHandle):: RH_a2h_patch ! atm to hyd + type(ESMF_RouteHandle):: RH_h2a_patch ! hyd to atm + type(ESMF_RouteHandle):: RH_o2i_patch ! ocn to ice + type(ESMF_RouteHandle):: RH_i2o_patch ! ice to ocn + type(ESMF_RouteHandle):: RH_l2h_patch ! lnd to hyd + type(ESMF_RouteHandle):: RH_h2l_patch ! hyd to lnd + type(ESMF_RouteHandle):: RH_a2o_fcopy ! atm to ocn fcopy + type(ESMF_RouteHandle):: RH_o2a_fcopy ! ocn to atm + type(ESMF_RouteHandle):: RH_a2i_fcopy ! atm to ice + type(ESMF_RouteHandle):: RH_i2a_fcopy ! ice to atm + type(ESMF_RouteHandle):: RH_a2l_fcopy ! atm to lnd + type(ESMF_RouteHandle):: RH_l2a_fcopy ! lnd to atm + type(ESMF_RouteHandle):: RH_a2h_fcopy ! atm to hyd + type(ESMF_RouteHandle):: RH_h2a_fcopy ! hyd to atm + type(ESMF_RouteHandle):: RH_o2i_fcopy ! ocn to ice + type(ESMF_RouteHandle):: RH_i2o_fcopy ! ice to ocn + type(ESMF_RouteHandle):: RH_l2h_fcopy ! lnd to hyd + type(ESMF_RouteHandle):: RH_h2l_fcopy ! hyd to lnd + logical :: atm_active + logical :: lnd_active + logical :: ocn_active + logical :: ice_active + logical :: hyd_active logical :: a2o_active logical :: o2a_active logical :: a2i_active @@ -188,20 +222,20 @@ module module_MEDIATOR logical :: i2o_active logical :: l2h_active logical :: h2l_active -! logical :: o2l_active ! (o2l connection not implemented) -! logical :: l2o_active ! (l2o connection not implemented) -! logical :: o2h_active ! (o2h connection not implemented) -! logical :: h2o_active ! (h2o connection not implemented) -! logical :: i2l_active ! (i2l connection not implemented) -! logical :: l2i_active ! (l2i connection not implemented) -! logical :: i2h_active ! (i2h connection not implemented) -! logical :: h2i_active ! (h2i connection not implemented) +! logical :: o2l_active ! (o2l connection not implemented) +! logical :: l2o_active ! (l2o connection not implemented) +! logical :: o2h_active ! (o2h connection not implemented) +! logical :: h2o_active ! (h2o connection not implemented) +! logical :: i2l_active ! (i2l connection not implemented) +! logical :: l2i_active ! (l2i connection not implemented) +! logical :: i2h_active ! (i2h connection not implemented) +! logical :: h2i_active ! (h2i connection not implemented) ! tcx Xgrid -! type(ESMF_RouteHandle):: RHa2x ! atm to xgrid RH -! type(ESMF_RouteHandle):: RHo2x ! ocn to xgrid RH -! type(ESMF_RouteHandle):: RHx2a ! xgrid to atm RH -! type(ESMF_RouteHandle):: RHx2o ! xgrid to ocn RH +! type(ESMF_RouteHandle):: RHa2x ! atm to xgrid RH +! type(ESMF_RouteHandle):: RHo2x ! ocn to xgrid RH +! type(ESMF_RouteHandle):: RHx2a ! xgrid to atm RH +! type(ESMF_RouteHandle):: RHx2o ! xgrid to ocn RH end type type InternalState @@ -209,62 +243,67 @@ module module_MEDIATOR end type interface fieldBundle_accum ; module procedure & - fieldBundle_accumFB2FB, & - fieldBundle_accumFB2ST, & - fieldBundle_accumST2FB + fieldBundle_accumFB2FB, & + fieldBundle_accumFB2ST, & + fieldBundle_accumST2FB end interface interface fieldBundle_copy ; module procedure & - fieldBundle_copyFB2FB, & - fieldBundle_copyFB2ST, & - fieldBundle_copyST2FB + fieldBundle_copyFB2FB, & + fieldBundle_copyFB2ST, & + fieldBundle_copyST2FB end interface interface NUOPCplus_UpdateTimestamp; module procedure & - NUOPCplus_UpdateTimestampS, & - NUOPCplus_UpdateTimestampF + NUOPCplus_UpdateTimestampS, & + NUOPCplus_UpdateTimestampF end interface ! local variables type(ESMF_Grid) :: gridAtm, gridOcn, gridIce, gridLnd, gridHyd, gridMed - integer, parameter :: nx_med=400, ny_med=200 + integer, parameter :: nx_med=400, ny_med=nx_med/2 integer :: dbug_flag = 5 integer :: restart_interval = 0 logical :: statewrite_flag = .true. ! diagnostics output, default + logical :: overwrite_flag = .true. ! logical :: rhprint_flag = .false. ! diagnostics output, default logical :: profile_memory = .true. ! diagnostics output, default logical :: coldstart = .false. ! coldstart flag + logical :: maptest = .false. ! maptest flag logical :: atmocn_flux_from_atm = .true. ! where is atm/ocn flux computed - logical :: generate_landmask = .true. ! landmask flag + logical :: generate_landmask = .false. ! landmask flag integer :: dbrc - character(len=256) :: msgString + character(len=256) :: msgString, restart_dir logical :: isPresent type(ESMF_Time) :: time_invalidTimeStamp type(ESMF_Clock) :: clock_invalidTimeStamp real(ESMF_KIND_R8), parameter :: const_lhvap = 2.501e6_ESMF_KIND_R8 ! latent heat of evaporation ~ J/kg integer :: srcTermProcessing_Value = 0 - logical :: read_rest_FBaccumAtm = .false. - logical :: read_rest_FBaccumOcn = .false. - logical :: read_rest_FBaccumIce = .false. - logical :: read_rest_FBaccumLnd = .false. - logical :: read_rest_FBaccumHyd = .false. - logical :: read_rest_FBaccumAtmOcn = .false. - logical :: read_rest_FBAtm_a = .false. - logical :: read_rest_FBIce_i = .false. - logical :: read_rest_FBOcn_o = .false. - logical :: read_rest_FBLnd_l = .false. - logical :: read_rest_FBHyd_h = .false. - logical :: read_rest_FBAtmOcn_o = .false. -! real(ESMF_KIND_R8), parameter :: spval_init = -9.99999e6_ESMF_KIND_R8 ! spval for initialization -! real(ESMF_KIND_R8), parameter :: spval = -1.0e36_ESMF_KIND_R8 ! spval - real(ESMF_KIND_R8), parameter :: spval_init = 0.0_ESMF_KIND_R8 ! spval for initialization - real(ESMF_KIND_R8), parameter :: spval = 0.0_ESMF_KIND_R8 ! spval - real(ESMF_KIND_R8), parameter :: czero = 0.0_ESMF_KIND_R8 ! spval -!BL2017b -! real(ESMF_KIND_R8), parameter :: c9999 = 9999.0_ESMF_KIND_R8 ! spval -! real(ESMF_KIND_R8), parameter :: c9999 = 0.0_ESMF_KIND_R8 ! spval -!BL2017b - integer , parameter :: ispval_mask = -987987 ! spval for RH mask values + +! logical :: read_rest_FBaccumAtm = .false. +! logical :: read_rest_FBaccumOcn = .false. +! logical :: read_rest_FBaccumIce = .false. +! logical :: read_rest_FBaccumLnd = .false. +! logical :: read_rest_FBaccumHyd = .false. +! logical :: read_rest_FBaccumAtmOcn = .false. +! logical :: read_rest_FBAtm_a = .false. +! logical :: read_rest_FBIce_i = .false. +! logical :: read_rest_FBOcn_o = .false. +! logical :: read_rest_FBLnd_l = .false. +! logical :: read_rest_FBHyd_h = .false. +! logical :: read_rest_FBAtmOcn_o = .false. + +! real(ESMF_KIND_R8), parameter :: spval_init = -9.99999e6_ESMF_KIND_R8 ! spval for initialization +! real(ESMF_KIND_R8), parameter :: spval = -1.0e36_ESMF_KIND_R8 ! spval + real(ESMF_KIND_R8), parameter :: spval_init = 0.0_ESMF_KIND_R8 ! spval for initialization + real(ESMF_KIND_R8), parameter :: spval = 0.0_ESMF_KIND_R8 + real(ESMF_KIND_R8), parameter :: czero = 0.0_ESMF_KIND_R8 + real(ESMF_KIND_R8), parameter :: cone = 1.0_ESMF_KIND_R8 + real(ESMF_KIND_R8), parameter :: chalf = 0.5_ESMF_KIND_R8 + real(ESMF_KIND_R8), parameter :: conem6 = 1.0e-6_ESMF_KIND_R8 + real(ESMF_KIND_R8), parameter :: epsln = 1.0e-12_ESMF_KIND_R8 + real(ESMF_KIND_R8), parameter :: albocn = 0.06_ESMF_KIND_R8 + integer , parameter :: ispval_mask = -987987 ! spval for RH mask values type fld_list_type integer :: num = -1 @@ -283,27 +322,22 @@ module module_MEDIATOR type(ESMF_State) :: NState_IceExp ! Ice Export nested state type(ESMF_State) :: NState_LndExp ! Lnd Export nested state type(ESMF_State) :: NState_HydExp ! Hyd Export nested state - type (fld_list_type) :: fldsToAtm - type (fld_list_type) :: fldsFrAtm - type (fld_list_type) :: fldsToOcn - type (fld_list_type) :: fldsFrOcn - type (fld_list_type) :: fldsToIce - type (fld_list_type) :: fldsFrIce - type (fld_list_type) :: fldsToLnd - type (fld_list_type) :: fldsFrLnd - type (fld_list_type) :: fldsToHyd - type (fld_list_type) :: fldsFrHyd + type (fld_list_type) :: fldsToAtm, fldsFrAtm + type (fld_list_type) :: fldsToOcn, fldsFrOcn + type (fld_list_type) :: fldsToIce, fldsFrIce + type (fld_list_type) :: fldsToLnd, fldsFrLnd + type (fld_list_type) :: fldsToHyd, fldsFrHyd type (fld_list_type) :: fldsAtmOcn real(ESMF_KIND_R8), allocatable :: land_mask(:,:) type(ESMF_PoleMethod_Flag), parameter :: polemethod=ESMF_POLEMETHOD_ALLAVG public SetServices - + !----------------------------------------------------------------------------- contains !----------------------------------------------------------------------------- - + subroutine SetServices(gcomp, rc) type(ESMF_GridComp) :: gcomp integer, intent(out) :: rc @@ -315,593 +349,616 @@ subroutine SetServices(gcomp, rc) call ESMF_LogWrite(trim(subname)//": called", ESMF_LOGMSG_INFO, rc=dbrc) endif rc = ESMF_SUCCESS - + ! the NUOPC mediator component will register the generic methods call NUOPC_CompDerive(gcomp, mediator_routine_SS, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return ! Provide InitializeP0 to switch from default IPDv00 to IPDv03 call ESMF_GridCompSetEntryPoint(gcomp, ESMF_METHOD_INITIALIZE, & - InitializeP0, phase=0, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + InitializeP0, phase=0, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return ! IPDv03p1: advertise Fields call NUOPC_CompSetEntryPoint(gcomp, ESMF_METHOD_INITIALIZE, & - phaseLabelList=(/"IPDv03p1"/), userRoutine=InitializeIPDv03p1, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out - + phaseLabelList=(/"IPDv03p1"/), userRoutine=InitializeIPDv03p1, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + ! IPDv03p3: realize connected Fields with transfer action "provide" call NUOPC_CompSetEntryPoint(gcomp, ESMF_METHOD_INITIALIZE, & - phaseLabelList=(/"IPDv03p3"/), userRoutine=InitializeIPDv03p3, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + phaseLabelList=(/"IPDv03p3"/), userRoutine=InitializeIPDv03p3, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return ! IPDv03p4: optionally modify the decomp/distr of transferred Grid/Mesh call NUOPC_CompSetEntryPoint(gcomp, ESMF_METHOD_INITIALIZE, & - phaseLabelList=(/"IPDv03p4"/), userRoutine=InitializeIPDv03p4, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + phaseLabelList=(/"IPDv03p4"/), userRoutine=InitializeIPDv03p4, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return ! IPDv03p5: realize all Fields with transfer action "accept" call NUOPC_CompSetEntryPoint(gcomp, ESMF_METHOD_INITIALIZE, & - phaseLabelList=(/"IPDv03p5"/), userRoutine=InitializeIPDv03p5, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + phaseLabelList=(/"IPDv03p5"/), userRoutine=InitializeIPDv03p5, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return ! attach specializing method(s) call NUOPC_CompSpecialize(gcomp, specLabel=mediator_label_DataInitialize, & - specRoutine=DataInitialize, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + specRoutine=DataInitialize, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return ! overwrite Finalize call ESMF_GridCompSetEntryPoint(gcomp, ESMF_METHOD_FINALIZE, & - userRoutine=Finalize, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + userRoutine=Finalize, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return ! set entry point for Run( phase = slow ) and specialize - call NUOPC_CompSetEntryPoint(gcomp, ESMF_METHOD_RUN, & - phaseLabelList=(/"MedPhase_slow"/), & - userRoutine=mediator_routine_Run, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + ! ------------- + call NUOPC_CompSetEntryPoint(gcomp, ESMF_METHOD_RUN, & + phaseLabelList=(/"MedPhase_slow"/), & + userRoutine=mediator_routine_Run, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call NUOPC_CompSpecialize(gcomp, specLabel=mediator_label_Advance, & - specPhaseLabel="MedPhase_slow", specRoutine=MedPhase_slow, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + specPhaseLabel="MedPhase_slow", specRoutine=MedPhase_slow, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return ! set entry point for Run( phase = fast_before ) and specialize + ! -------------------- call NUOPC_CompSetEntryPoint(gcomp, ESMF_METHOD_RUN, & - phaseLabelList=(/"MedPhase_fast_before"/), & - userRoutine=mediator_routine_Run, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + phaseLabelList=(/"MedPhase_fast_before"/), & + userRoutine = mediator_routine_Run, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call NUOPC_CompSpecialize(gcomp, specLabel=mediator_label_Advance, & - specPhaseLabel="MedPhase_fast_before", & - specRoutine=MedPhase_fast_before, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out - + specPhaseLabel="MedPhase_fast_before", & + specRoutine=MedPhase_fast_before, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + ! set entry point for Run( phase = fast_after ) and specialize - call NUOPC_CompSetEntryPoint(gcomp, ESMF_METHOD_RUN, & - phaseLabelList=(/"MedPhase_fast_after"/), & - userRoutine=mediator_routine_Run, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + ! ------------------- + call NUOPC_CompSetEntryPoint(gcomp, ESMF_METHOD_RUN, & + phaseLabelList=(/"MedPhase_fast_after"/), & + userRoutine=mediator_routine_Run, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call NUOPC_CompSpecialize(gcomp, specLabel=mediator_label_Advance, & - specPhaseLabel="MedPhase_fast_after", & - specRoutine=MedPhase_fast_after, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + specPhaseLabel="MedPhase_fast_after", & + specRoutine=MedPhase_fast_after, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return ! set entry point for Run( phase = accum_fast ) and specialize - call NUOPC_CompSetEntryPoint(gcomp, ESMF_METHOD_RUN, & - phaseLabelList=(/"MedPhase_accum_fast"/), & - userRoutine=mediator_routine_Run, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + ! ------------------- + call NUOPC_CompSetEntryPoint(gcomp, ESMF_METHOD_RUN, & + phaseLabelList=(/"MedPhase_accum_fast"/), & + userRoutine = mediator_routine_Run, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call NUOPC_CompSpecialize(gcomp, specLabel=mediator_label_Advance, & - specPhaseLabel="MedPhase_accum_fast", specRoutine=MedPhase_accum_fast, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + specPhaseLabel="MedPhase_accum_fast", specRoutine=MedPhase_accum_fast, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return ! set entry point for Run( phase = atm_ocn_flux ) and specialize - call NUOPC_CompSetEntryPoint(gcomp, ESMF_METHOD_RUN, & - phaseLabelList=(/"MedPhase_atm_ocn_flux"/), & - userRoutine=mediator_routine_Run, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + ! --------------------- + call NUOPC_CompSetEntryPoint(gcomp, ESMF_METHOD_RUN, & + phaseLabelList=(/"MedPhase_atm_ocn_flux"/), & + userRoutine=mediator_routine_Run, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call NUOPC_CompSpecialize(gcomp, specLabel=mediator_label_Advance, & - specPhaseLabel="MedPhase_atm_ocn_flux", specRoutine=MedPhase_atm_ocn_flux, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + specPhaseLabel="MedPhase_atm_ocn_flux", specRoutine=MedPhase_atm_ocn_flux, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return ! set entry point for Run( phase = prep_ocn ) and specialize - call NUOPC_CompSetEntryPoint(gcomp, ESMF_METHOD_RUN, & - phaseLabelList=(/"MedPhase_prep_ocn"/), & - userRoutine=mediator_routine_Run, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + ! ----------------- + call NUOPC_CompSetEntryPoint(gcomp, ESMF_METHOD_RUN, & + phaseLabelList=(/"MedPhase_prep_ocn"/), & + userRoutine=mediator_routine_Run, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call NUOPC_CompSpecialize(gcomp, specLabel=mediator_label_Advance, & - specPhaseLabel="MedPhase_prep_ocn", specRoutine=MedPhase_prep_ocn, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + specPhaseLabel="MedPhase_prep_ocn", specRoutine=MedPhase_prep_ocn, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return ! set entry point for Run( phase = prep_ice ) and specialize - call NUOPC_CompSetEntryPoint(gcomp, ESMF_METHOD_RUN, & - phaseLabelList=(/"MedPhase_prep_ice"/), & - userRoutine=mediator_routine_Run, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + ! ----------------- + call NUOPC_CompSetEntryPoint(gcomp, ESMF_METHOD_RUN, & + phaseLabelList=(/"MedPhase_prep_ice"/), & + userRoutine=mediator_routine_Run, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call NUOPC_CompSpecialize(gcomp, specLabel=mediator_label_Advance, & - specPhaseLabel="MedPhase_prep_ice", specRoutine=MedPhase_prep_ice, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + specPhaseLabel="MedPhase_prep_ice", specRoutine=MedPhase_prep_ice, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return ! set entry point for Run( phase = prep_atm ) and specialize - call NUOPC_CompSetEntryPoint(gcomp, ESMF_METHOD_RUN, & - phaseLabelList=(/"MedPhase_prep_atm"/), & - userRoutine=mediator_routine_Run, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + ! ----------------- + call NUOPC_CompSetEntryPoint(gcomp, ESMF_METHOD_RUN, & + phaseLabelList=(/"MedPhase_prep_atm"/), & + userRoutine=mediator_routine_Run, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call NUOPC_CompSpecialize(gcomp, specLabel=mediator_label_Advance, & - specPhaseLabel="MedPhase_prep_atm", specRoutine=MedPhase_prep_atm, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + specPhaseLabel="MedPhase_prep_atm", specRoutine=MedPhase_prep_atm, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call NUOPC_CompSpecialize(gcomp, specLabel=mediator_label_TimestampExport, & - specPhaseLabel="MedPhase_prep_atm", & - specRoutine=TimestampExport_prep_atm, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + specPhaseLabel="MedPhase_prep_atm", & + specRoutine=TimestampExport_prep_atm, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return ! set entry point for Run( phase = prep_lnd ) and specialize - call NUOPC_CompSetEntryPoint(gcomp, ESMF_METHOD_RUN, & - phaseLabelList=(/"MedPhase_prep_lnd"/), & - userRoutine=mediator_routine_Run, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + ! ----------------- + call NUOPC_CompSetEntryPoint(gcomp, ESMF_METHOD_RUN, & + phaseLabelList=(/"MedPhase_prep_lnd"/), & + userRoutine=mediator_routine_Run, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call NUOPC_CompSpecialize(gcomp, specLabel=mediator_label_Advance, & - specPhaseLabel="MedPhase_prep_lnd", specRoutine=MedPhase_prep_lnd, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + specPhaseLabel="MedPhase_prep_lnd", specRoutine=MedPhase_prep_lnd, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return ! set entry point for Run( phase = prep_hyd ) and specialize - call NUOPC_CompSetEntryPoint(gcomp, ESMF_METHOD_RUN, & - phaseLabelList=(/"MedPhase_prep_hyd"/), & - userRoutine=mediator_routine_Run, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + ! ----------------- + call NUOPC_CompSetEntryPoint(gcomp, ESMF_METHOD_RUN, & + phaseLabelList=(/"MedPhase_prep_hyd"/), & + userRoutine=mediator_routine_Run, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call NUOPC_CompSpecialize(gcomp, specLabel=mediator_label_Advance, & - specPhaseLabel="MedPhase_prep_hyd", specRoutine=MedPhase_prep_hyd, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + specPhaseLabel="MedPhase_prep_hyd", specRoutine=MedPhase_prep_hyd, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return ! set entry point for Run( phase = write_restart ) and specialize - call NUOPC_CompSetEntryPoint(gcomp, ESMF_METHOD_RUN, & - phaseLabelList=(/"MedPhase_write_restart"/), & - userRoutine=mediator_routine_Run, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + ! ---------------------- + call NUOPC_CompSetEntryPoint(gcomp, ESMF_METHOD_RUN, & + phaseLabelList=(/"MedPhase_write_restart"/), & + userRoutine=mediator_routine_Run, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call NUOPC_CompSpecialize(gcomp, specLabel=mediator_label_Advance, & - specPhaseLabel="MedPhase_write_restart", specRoutine=MedPhase_write_restart, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + specPhaseLabel="MedPhase_write_restart", specRoutine=MedPhase_write_restart, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return ! attach specializing method(s) ! -> NUOPC specializes by default --->>> first need to remove the default call ESMF_MethodRemove(gcomp, mediator_label_CheckImport, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call NUOPC_CompSpecialize(gcomp, specLabel=mediator_label_CheckImport, & - specRoutine=NUOPC_NoOp, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + specRoutine=NUOPC_NoOp, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return ! attach specializing method(s) ! -> NUOPC specializes by default --->>> first need to remove the default call ESMF_MethodRemove(gcomp, mediator_label_SetRunClock, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call NUOPC_CompSpecialize(gcomp, specLabel=mediator_label_SetRunClock, & - specRoutine=SetRunClock, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out - - ! AtmOcn Coupling Fields - call fld_list_add(fldsAtmOcn,"mean_up_lw_flx_ocn" , "cannot provide","conservefrac") - call fld_list_add(fldsAtmOcn,"mean_sensi_heat_flx_atm_into_ocn", "cannot provide","conservefrac") - call fld_list_add(fldsAtmOcn,"mean_laten_heat_flx_atm_into_ocn", "cannot provide","conservefrac") - call fld_list_add(fldsAtmOcn,"mean_evap_rate_atm_into_ocn" , "cannot provide","conservefrac") - call fld_list_add(fldsAtmOcn,"stress_on_air_ocn_zonal" , "cannot provide","conservefrac") - call fld_list_add(fldsAtmOcn,"stress_on_air_ocn_merid" , "cannot provide","conservefrac") -! call fld_list_add(fldsAtmOcn,"temperature_2m" , "cannot provide","bilinear") -! call fld_list_add(fldsAtmOcn,"humidity_2m" , "cannot provide","bilinear") -! call fld_list_add(fldsAtmOcn,"wind_speed_squared_10m" , "cannot provide","bilinear") - call fld_list_add(fldsAtmOcn,"temperature_2m" , "cannot provide","conservefrac") - call fld_list_add(fldsAtmOcn,"humidity_2m" , "cannot provide","conservefrac") - call fld_list_add(fldsAtmOcn,"wind_speed_squared_10m" , "cannot provide","conservefrac") - - ! Fields to ATM - call fld_list_add(fldsToAtm,"land_mask" , "cannot provide") - call fld_list_add(fldsToAtm,"surface_temperature" , "will provide") - call fld_list_add(fldsToAtm,"sea_surface_temperature" , "will provide") - call fld_list_add(fldsToAtm,"inst_ice_ir_dir_albedo" , "will provide") - call fld_list_add(fldsToAtm,"inst_ice_ir_dif_albedo" , "will provide") - call fld_list_add(fldsToAtm,"inst_ice_vis_dir_albedo" , "will provide") - call fld_list_add(fldsToAtm,"inst_ice_vis_dif_albedo" , "will provide") - call fld_list_add(fldsToAtm,"ice_fraction" , "will provide") - call fld_list_add(fldsToAtm,"stress_on_air_ice_zonal" , "will provide") - call fld_list_add(fldsToAtm,"stress_on_air_ice_merid" , "will provide") - call fld_list_add(fldsToAtm,"mean_up_lw_flx_ice" , "will provide") - call fld_list_add(fldsToAtm,"mean_sensi_heat_flx_atm_into_ice", "will provide") - call fld_list_add(fldsToAtm,"mean_laten_heat_flx_atm_into_ice", "will provide") - call fld_list_add(fldsToAtm,"mean_sensi_heat_flx_atm_into_lnd", "will provide") - call fld_list_add(fldsToAtm,"mean_laten_heat_flx_atm_into_lnd", "will provide") - call fld_list_add(fldsToAtm,"mean_evap_rate_atm_into_ice" , "will provide") - call fld_list_add(fldsToAtm,"mean_zonal_moment_flx" , "will provide") - call fld_list_add(fldsToAtm,"mean_merid_moment_flx" , "will provide") - call fld_list_add(fldsToAtm,"mean_sensi_heat_flx" , "will provide") - call fld_list_add(fldsToAtm,"mean_laten_heat_flx" , "will provide") - call fld_list_add(fldsToAtm,"mean_up_lw_flx" , "will provide") - call fld_list_add(fldsToAtm,"mean_evap_rate" , "will provide") - call fld_list_add(fldsToAtm,"liquid_water_content_of_soil_layer_1", "will provide") - call fld_list_add(fldsToAtm,"liquid_water_content_of_soil_layer_2", "will provide") - call fld_list_add(fldsToAtm,"liquid_water_content_of_soil_layer_3", "will provide") - call fld_list_add(fldsToAtm,"liquid_water_content_of_soil_layer_4", "will provide") - call fld_list_add(fldsToAtm,"mean_ice_volume" , "will provide") - call fld_list_add(fldsToAtm,"mean_snow_volume" , "will provide") - call fld_list_add(fldsToAtm,"sea_ice_surface_temperature" , "will provide") -! call fld_list_add(fldsFrHyd,"volume_fraction_of_total_water_in_soil", "will provide") -! call fld_list_add(fldsFrHyd,"surface_snow_thickness" , "will provide") -! call fld_list_add(fldsFrHyd,"liquid_water_content_of_surface_snow" , "will provide") + specRoutine=SetRunClock, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + +! +! AtmOcn Coupling Fields +! ---------------------- + call fld_list_add(fldsAtmOcn, "mean_up_lw_flx_ocn" , "cannot provide", "conservefrac") + call fld_list_add(fldsAtmOcn, "mean_sensi_heat_flx_atm_into_ocn", "cannot provide", "conservefrac") + call fld_list_add(fldsAtmOcn, "mean_laten_heat_flx_atm_into_ocn", "cannot provide", "conservefrac") + call fld_list_add(fldsAtmOcn, "mean_evap_rate_atm_into_ocn" , "cannot provide", "conservefrac") + call fld_list_add(fldsAtmOcn, "stress_on_air_ocn_zonal" , "cannot provide", "conservefrac") + call fld_list_add(fldsAtmOcn, "stress_on_air_ocn_merid" , "cannot provide", "conservefrac") +! call fld_list_add(fldsAtmOcn, "temperature_2m" , "cannot provide", "bilinear") +! call fld_list_add(fldsAtmOcn, "humidity_2m" , "cannot provide", "bilinear") +! call fld_list_add(fldsAtmOcn, "wind_speed_squared_10m" , "cannot provide", "bilinear") + call fld_list_add(fldsAtmOcn, "temperature_2m" , "cannot provide", "conservefrac") + call fld_list_add(fldsAtmOcn, "humidity_2m" , "cannot provide", "conservefrac") + call fld_list_add(fldsAtmOcn, "wind_speed_squared_10m" , "cannot provide", "conservefrac") + +! Fields to ATM +! ------------- + call fld_list_add(fldsToAtm, "land_mask" , "cannot provide") + call fld_list_add(fldsToAtm, "surface_temperature" , "will provide") + call fld_list_add(fldsToAtm, "sea_surface_temperature" , "will provide") + call fld_list_add(fldsToAtm, "sea_ice_surface_temperature" , "will provide") + call fld_list_add(fldsToAtm, "inst_ice_ir_dir_albedo" , "will provide") + call fld_list_add(fldsToAtm, "inst_ice_ir_dif_albedo" , "will provide") + call fld_list_add(fldsToAtm, "inst_ice_vis_dir_albedo" , "will provide") + call fld_list_add(fldsToAtm, "inst_ice_vis_dif_albedo" , "will provide") + call fld_list_add(fldsToAtm, "ice_fraction" , "will provide") + call fld_list_add(fldsToAtm, "stress_on_air_ice_zonal" , "will provide") + call fld_list_add(fldsToAtm, "stress_on_air_ice_merid" , "will provide") + call fld_list_add(fldsToAtm, "mean_up_lw_flx_ice" , "will provide") + call fld_list_add(fldsToAtm, "mean_sensi_heat_flx_atm_into_ice" , "will provide") + call fld_list_add(fldsToAtm, "mean_laten_heat_flx_atm_into_ice" , "will provide") + call fld_list_add(fldsToAtm, "mean_sensi_heat_flx_atm_into_lnd" , "will provide") + call fld_list_add(fldsToAtm, "mean_laten_heat_flx_atm_into_lnd" , "will provide") + call fld_list_add(fldsToAtm, "mean_evap_rate_atm_into_ice" , "will provide") + call fld_list_add(fldsToAtm, "mean_zonal_moment_flx" , "will provide") + call fld_list_add(fldsToAtm, "mean_merid_moment_flx" , "will provide") + call fld_list_add(fldsToAtm, "mean_sensi_heat_flx" , "will provide") + call fld_list_add(fldsToAtm, "mean_laten_heat_flx" , "will provide") + call fld_list_add(fldsToAtm, "mean_up_lw_flx" , "will provide") + call fld_list_add(fldsToAtm, "mean_evap_rate" , "will provide") + call fld_list_add(fldsToAtm, "liquid_water_content_of_soil_layer_1", "will provide") + call fld_list_add(fldsToAtm, "liquid_water_content_of_soil_layer_2", "will provide") + call fld_list_add(fldsToAtm, "liquid_water_content_of_soil_layer_3", "will provide") + call fld_list_add(fldsToAtm, "liquid_water_content_of_soil_layer_4", "will provide") + call fld_list_add(fldsToAtm, "mean_ice_volume" , "will provide") + call fld_list_add(fldsToAtm, "mean_snow_volume" , "will provide") +! call fld_list_add(fldsFrHyd, "volume_fraction_of_total_water_in_soil", "will provide") +! call fld_list_add(fldsFrHyd, "surface_snow_thickness" , "will provide") +! call fld_list_add(fldsFrHyd, "liquid_water_content_of_surface_snow" , "will provide") ! Fields from ATM - call fld_list_add(fldsFrAtm,"mean_zonal_moment_flx_atm" , "cannot provide","conservefrac") - call fld_list_add(fldsFrAtm,"mean_merid_moment_flx_atm" , "will provide","conservefrac") - call fld_list_add(fldsFrAtm,"mean_sensi_heat_flx" , "will provide","conservefrac") - call fld_list_add(fldsFrAtm,"mean_laten_heat_flx" , "will provide","conservefrac") - call fld_list_add(fldsFrAtm,"mean_down_lw_flx" , "will provide","conservefrac") -! call fld_list_add(fldsFrAtm,"mean_up_lw_flx" , "will provide","conservefrac") - call fld_list_add(fldsFrAtm,"mean_down_sw_flx" , "will provide","conservefrac") - call fld_list_add(fldsFrAtm,"mean_prec_rate" , "will provide","conservefrac") - call fld_list_add(fldsFrAtm,"mean_fprec_rate" , "will provide","conservefrac") - call fld_list_add(fldsFrAtm,"inst_zonal_moment_flx" , "will provide","conservefrac") - call fld_list_add(fldsFrAtm,"inst_merid_moment_flx" , "will provide","conservefrac") - call fld_list_add(fldsFrAtm,"inst_sensi_heat_flx" , "will provide","conservefrac") - call fld_list_add(fldsFrAtm,"inst_laten_heat_flx" , "will provide","conservefrac") - call fld_list_add(fldsFrAtm,"inst_down_lw_flx" , "will provide","conservefrac") -! call fld_list_add(fldsFrAtm,"inst_up_lw_flx" , "will provide","conservefrac") - call fld_list_add(fldsFrAtm,"inst_down_sw_flx" , "will provide","conservefrac") - call fld_list_add(fldsFrAtm,"inst_temp_height2m" , "will provide","bilinear") - call fld_list_add(fldsFrAtm,"inst_spec_humid_height2m", "will provide","bilinear") + call fld_list_add(fldsFrAtm, "mean_zonal_moment_flx_atm", "cannot provide", "conservefrac") + call fld_list_add(fldsFrAtm, "mean_merid_moment_flx_atm", "will provide", "conservefrac") + call fld_list_add(fldsFrAtm, "mean_sensi_heat_flx" , "will provide", "conservefrac") + call fld_list_add(fldsFrAtm, "mean_laten_heat_flx" , "will provide", "conservefrac") + call fld_list_add(fldsFrAtm, "mean_down_lw_flx" , "will provide", "conservefrac") +! call fld_list_add(fldsFrAtm, "mean_up_lw_flx" , "will provide", "conservefrac") + call fld_list_add(fldsFrAtm, "mean_down_sw_flx" , "will provide", "conservefrac") + call fld_list_add(fldsFrAtm, "mean_prec_rate" , "will provide", "conservefrac") + call fld_list_add(fldsFrAtm, "mean_fprec_rate" , "will provide", "conservefrac") + call fld_list_add(fldsFrAtm, "inst_zonal_moment_flx" , "will provide", "conservefrac") + call fld_list_add(fldsFrAtm, "inst_merid_moment_flx" , "will provide", "conservefrac") + call fld_list_add(fldsFrAtm, "inst_sensi_heat_flx" , "will provide", "conservefrac") + call fld_list_add(fldsFrAtm, "inst_laten_heat_flx" , "will provide", "conservefrac") + call fld_list_add(fldsFrAtm, "inst_down_lw_flx" , "will provide", "conservefrac") +! call fld_list_add(fldsFrAtm, "inst_up_lw_flx" , "will provide", "conservefrac") + call fld_list_add(fldsFrAtm, "inst_down_sw_flx" , "will provide", "conservefrac") + call fld_list_add(fldsFrAtm, "inst_temp_height2m" , "will provide", "conservefrac") ! bilinear + call fld_list_add(fldsFrAtm, "inst_spec_humid_height2m" , "will provide", "conservefrac") ! bilinear +! call fld_list_add(fldsFrAtm, "inst_temp_height2m" , "will provide", "bilinear") +! call fld_list_add(fldsFrAtm, "inst_spec_humid_height2m" , "will provide", "bilinear") #ifdef PATCH_BFB_FIXED - call fld_list_add(fldsFrAtm,"inst_u_wind_height10m" , "will provide","patch") - call fld_list_add(fldsFrAtm,"inst_v_wind_height10m" , "will provide","patch") - call fld_list_add(fldsFrAtm,"inst_zonal_wind_height10m" , "will provide","patch") - call fld_list_add(fldsFrAtm,"inst_merid_wind_height10m" , "will provide","patch") + call fld_list_add(fldsFrAtm, "inst_u_wind_height10m" , "will provide", "patch") + call fld_list_add(fldsFrAtm, "inst_v_wind_height10m" , "will provide", "patch") + call fld_list_add(fldsFrAtm, "inst_zonal_wind_height10m" , "will provide", "patch") + call fld_list_add(fldsFrAtm, "inst_merid_wind_height10m" , "will provide", "patch") #else - call fld_list_add(fldsFrAtm,"inst_u_wind_height10m" , "will provide","bilinear") - call fld_list_add(fldsFrAtm,"inst_v_wind_height10m" , "will provide","bilinear") - call fld_list_add(fldsFrAtm,"inst_zonal_wind_height10m" , "will provide","bilinear") - call fld_list_add(fldsFrAtm,"inst_merid_wind_height10m" , "will provide","bilinear") + call fld_list_add(fldsFrAtm, "inst_u_wind_height10m" , "will provide", "conservefrac") ! bilinear + call fld_list_add(fldsFrAtm, "inst_v_wind_height10m" , "will provide", "conservefrac") ! bilinear + call fld_list_add(fldsFrAtm, "inst_zonal_wind_height10m" , "will provide", "conservefrac") ! bilinear + call fld_list_add(fldsFrAtm, "inst_merid_wind_height10m" , "will provide", "conservefrac") ! bilinear +! call fld_list_add(fldsFrAtm, "inst_u_wind_height10m" , "will provide", "bilinear") +! call fld_list_add(fldsFrAtm, "inst_v_wind_height10m" , "will provide", "bilinear") +! call fld_list_add(fldsFrAtm, "inst_zonal_wind_height10m" , "will provide", "bilinear") +! call fld_list_add(fldsFrAtm, "inst_merid_wind_height10m" , "will provide", "bilinear") #endif - call fld_list_add(fldsFrAtm,"inst_temp_height_surface", "will provide","bilinear") - call fld_list_add(fldsFrAtm,"inst_pres_height_surface", "will provide","bilinear") - call fld_list_add(fldsFrAtm,"inst_surface_height" , "will provide","bilinear") + call fld_list_add(fldsFrAtm, "inst_temp_height_surface" , "will provide", "conservefrac") ! bilinear + call fld_list_add(fldsFrAtm, "inst_pres_height_surface" , "will provide", "conservefrac") ! bilinear + call fld_list_add(fldsFrAtm, "inst_surface_height" , "will provide", "conservefrac") ! bilinear +! call fld_list_add(fldsFrAtm, "inst_temp_height_surface" , "will provide", "bilinear") +! call fld_list_add(fldsFrAtm, "inst_pres_height_surface" , "will provide", "bilinear") +! call fld_list_add(fldsFrAtm, "inst_surface_height" , "will provide", "bilinear") ! new imports from GSM added 04/23/14: - call fld_list_add(fldsFrAtm,"mean_net_lw_flx" , "will provide","conservefrac") - call fld_list_add(fldsFrAtm,"mean_net_sw_flx" , "will provide","conservefrac") - call fld_list_add(fldsFrAtm,"inst_net_lw_flx" , "will provide","conservefrac") - call fld_list_add(fldsFrAtm,"inst_net_sw_flx" , "will provide","conservefrac") - call fld_list_add(fldsFrAtm,"mean_down_sw_ir_dir_flx" , "will provide","conservefrac") - call fld_list_add(fldsFrAtm,"mean_down_sw_ir_dif_flx" , "will provide","conservefrac") - call fld_list_add(fldsFrAtm,"mean_down_sw_vis_dir_flx", "will provide","conservefrac") - call fld_list_add(fldsFrAtm,"mean_down_sw_vis_dif_flx", "will provide","conservefrac") - call fld_list_add(fldsFrAtm,"inst_down_sw_ir_dir_flx" , "will provide","conservefrac") - call fld_list_add(fldsFrAtm,"inst_down_sw_ir_dif_flx" , "will provide","conservefrac") - call fld_list_add(fldsFrAtm,"inst_down_sw_vis_dir_flx", "will provide","conservefrac") - call fld_list_add(fldsFrAtm,"inst_down_sw_vis_dif_flx", "will provide","conservefrac") - call fld_list_add(fldsFrAtm,"mean_net_sw_ir_dir_flx" , "will provide","conservefrac") - call fld_list_add(fldsFrAtm,"mean_net_sw_ir_dif_flx" , "will provide","conservefrac") - call fld_list_add(fldsFrAtm,"mean_net_sw_vis_dir_flx" , "will provide","conservefrac") - call fld_list_add(fldsFrAtm,"mean_net_sw_vis_dif_flx" , "will provide","conservefrac") - call fld_list_add(fldsFrAtm,"inst_net_sw_ir_dir_flx" , "will provide","conservefrac") - call fld_list_add(fldsFrAtm,"inst_net_sw_ir_dif_flx" , "will provide","conservefrac") - call fld_list_add(fldsFrAtm,"inst_net_sw_vis_dir_flx" , "will provide","conservefrac") - call fld_list_add(fldsFrAtm,"inst_net_sw_vis_dif_flx" , "will provide","conservefrac") - call fld_list_add(fldsFrAtm,"inst_ir_dir_albedo" , "will provide","conservefrac") - call fld_list_add(fldsFrAtm,"inst_ir_dif_albedo" , "will provide","conservefrac") - call fld_list_add(fldsFrAtm,"inst_vis_dir_albedo" , "will provide","conservefrac") - call fld_list_add(fldsFrAtm,"inst_vis_dif_albedo" , "will provide","conservefrac") - call fld_list_add(fldsFrAtm,"inst_ocn_ir_dir_albedo" , "will provide","conservefrac") - call fld_list_add(fldsFrAtm,"inst_ocn_ir_dif_albedo" , "will provide","conservefrac") - call fld_list_add(fldsFrAtm,"inst_ocn_vis_dir_albedo" , "will provide","conservefrac") - call fld_list_add(fldsFrAtm,"inst_ocn_vis_dif_albedo" , "will provide","conservefrac") + call fld_list_add(fldsFrAtm, "mean_net_lw_flx" , "will provide", "conservefrac") + call fld_list_add(fldsFrAtm, "mean_net_sw_flx" , "will provide", "conservefrac") + call fld_list_add(fldsFrAtm, "inst_net_lw_flx" , "will provide", "conservefrac") + call fld_list_add(fldsFrAtm, "inst_net_sw_flx" , "will provide", "conservefrac") + call fld_list_add(fldsFrAtm, "mean_down_sw_ir_dir_flx" , "will provide", "conservefrac") + call fld_list_add(fldsFrAtm, "mean_down_sw_ir_dif_flx" , "will provide", "conservefrac") + call fld_list_add(fldsFrAtm, "mean_down_sw_vis_dir_flx", "will provide", "conservefrac") + call fld_list_add(fldsFrAtm, "mean_down_sw_vis_dif_flx", "will provide", "conservefrac") + call fld_list_add(fldsFrAtm, "inst_down_sw_ir_dir_flx" , "will provide", "conservefrac") + call fld_list_add(fldsFrAtm, "inst_down_sw_ir_dif_flx" , "will provide", "conservefrac") + call fld_list_add(fldsFrAtm, "inst_down_sw_vis_dir_flx", "will provide", "conservefrac") + call fld_list_add(fldsFrAtm, "inst_down_sw_vis_dif_flx", "will provide", "conservefrac") + call fld_list_add(fldsFrAtm, "mean_net_sw_ir_dir_flx" , "will provide", "conservefrac") + call fld_list_add(fldsFrAtm, "mean_net_sw_ir_dif_flx" , "will provide", "conservefrac") + call fld_list_add(fldsFrAtm, "mean_net_sw_vis_dir_flx" , "will provide", "conservefrac") + call fld_list_add(fldsFrAtm, "mean_net_sw_vis_dif_flx" , "will provide", "conservefrac") + call fld_list_add(fldsFrAtm, "inst_net_sw_ir_dir_flx" , "will provide", "conservefrac") + call fld_list_add(fldsFrAtm, "inst_net_sw_ir_dif_flx" , "will provide", "conservefrac") + call fld_list_add(fldsFrAtm, "inst_net_sw_vis_dir_flx" , "will provide", "conservefrac") + call fld_list_add(fldsFrAtm, "inst_net_sw_vis_dif_flx" , "will provide", "conservefrac") + call fld_list_add(fldsFrAtm, "inst_ir_dir_albedo" , "will provide", "conservefrac") + call fld_list_add(fldsFrAtm, "inst_ir_dif_albedo" , "will provide", "conservefrac") + call fld_list_add(fldsFrAtm, "inst_vis_dir_albedo" , "will provide", "conservefrac") + call fld_list_add(fldsFrAtm, "inst_vis_dif_albedo" , "will provide", "conservefrac") + call fld_list_add(fldsFrAtm, "inst_ocn_ir_dir_albedo" , "will provide", "conservefrac") + call fld_list_add(fldsFrAtm, "inst_ocn_ir_dif_albedo" , "will provide", "conservefrac") + call fld_list_add(fldsFrAtm, "inst_ocn_vis_dir_albedo" , "will provide", "conservefrac") + call fld_list_add(fldsFrAtm, "inst_ocn_vis_dif_albedo" , "will provide", "conservefrac") ! new imports from GSM added 06/09/15: - call fld_list_add(fldsFrAtm,"inst_temp_height_lowest" , "will provide","bilinear") - call fld_list_add(fldsFrAtm,"inst_spec_humid_height_lowest" , "will provide","bilinear") - call fld_list_add(fldsFrAtm,"inst_zonal_wind_height_lowest" , "will provide","bilinear") - call fld_list_add(fldsFrAtm,"inst_merid_wind_height_lowest" , "will provide","bilinear") - call fld_list_add(fldsFrAtm,"inst_pres_height_lowest" , "will provide","bilinear") - call fld_list_add(fldsFrAtm,"inst_height_lowest" , "will provide","bilinear") - - ! Fields to OCN - call fld_list_add(fldsToOcn,"mean_zonal_moment_flx" , "cannot provide") - call fld_list_add(fldsToOcn,"mean_merid_moment_flx" , "will provide") - call fld_list_add(fldsToOcn,"mean_sensi_heat_flx" , "will provide") - call fld_list_add(fldsToOcn,"mean_laten_heat_flx" , "will provide") - call fld_list_add(fldsToOcn,"mean_down_lw_flx" , "will provide") - call fld_list_add(fldsToOcn,"mean_down_sw_vis_dir_flx", "will provide") - call fld_list_add(fldsToOcn,"mean_down_sw_vis_dif_flx", "will provide") - call fld_list_add(fldsToOcn,"mean_down_sw_ir_dir_flx" , "will provide") - call fld_list_add(fldsToOcn,"mean_down_sw_ir_dif_flx" , "will provide") - call fld_list_add(fldsToOcn,"mean_net_sw_vis_dir_flx" , "will provide") - call fld_list_add(fldsToOcn,"mean_net_sw_vis_dif_flx" , "will provide") - call fld_list_add(fldsToOcn,"mean_net_sw_ir_dir_flx" , "will provide") - call fld_list_add(fldsToOcn,"mean_net_sw_ir_dif_flx" , "will provide") -! call fld_list_add(fldsToOcn,"mean_salt_flx" , "will provide") - call fld_list_add(fldsToOcn,"mean_prec_rate" , "will provide") - call fld_list_add(fldsToOcn,"mean_fprec_rate" , "will provide") - call fld_list_add(fldsToOcn,"mean_evap_rate" , "will provide") -! call fld_list_add(fldsToOcn,"mean_runoff_rate" , "will provide") -! call fld_list_add(fldsToOcn,"mean_calving_rate" , "will provide") -! call fld_list_add(fldsToOcn,"mean_runoff_flx" , "will provide") -! call fld_list_add(fldsToOcn,"mean_calving_flx" , "will provide") - call fld_list_add(fldsToOcn,"inst_pres_height_surface", "will provide") -! call fld_list_add(fldsToOcn,"mass_of_overlying_sea_ice, "will provide") - call fld_list_add(fldsToOcn,"stress_on_ocn_ice_zonal" , "will provide") - call fld_list_add(fldsToOcn,"stress_on_ocn_ice_merid" , "will provide") -! call fld_list_add(fldsToOcn,"stress_on_ocn_ice_idir" , "will provide") -! call fld_list_add(fldsToOcn,"stress_on_ocn_ice_jdir" , "will provide") - call fld_list_add(fldsToOcn,"mean_sw_pen_to_ocn" , "will provide") - call fld_list_add(fldsToOcn,"mean_down_sw_flx" , "will provide") - call fld_list_add(fldsToOcn,"mean_net_sw_flx" , "will provide") - call fld_list_add(fldsToOcn,"mean_net_lw_flx" , "will provide") -! call fld_list_add(fldsToOcn,"mean_up_lw_flx" , "will provide") - call fld_list_add(fldsToOcn,"inst_temp_height2m" , "will provide") - call fld_list_add(fldsToOcn,"inst_spec_humid_height2m", "will provide") - call fld_list_add(fldsToOcn,"net_heat_flx_to_ocn" , "will provide") - call fld_list_add(fldsToOcn,"mean_fresh_water_to_ocean_rate", "will provide") - call fld_list_add(fldsToOcn,"mean_salt_rate" , "will provide") - call fld_list_add(fldsToOcn,"ice_fraction" , "will provide") - + call fld_list_add(fldsFrAtm, "inst_temp_height_lowest" , "will provide", "conservefrac") ! bilinear + call fld_list_add(fldsFrAtm, "inst_spec_humid_height_lowest" , "will provide", "conservefrac") ! bilinear + call fld_list_add(fldsFrAtm, "inst_zonal_wind_height_lowest" , "will provide", "conservefrac") ! bilinear + call fld_list_add(fldsFrAtm, "inst_merid_wind_height_lowest" , "will provide", "conservefrac") ! bilinear + call fld_list_add(fldsFrAtm, "inst_pres_height_lowest" , "will provide", "conservefrac") ! bilinear + call fld_list_add(fldsFrAtm, "inst_height_lowest" , "will provide", "conservefrac") ! bilinear +! call fld_list_add(fldsFrAtm, "inst_temp_height_lowest" , "will provide", "bilinear") +! call fld_list_add(fldsFrAtm, "inst_spec_humid_height_lowest" , "will provide", "bilinear") +! call fld_list_add(fldsFrAtm, "inst_zonal_wind_height_lowest" , "will provide", "bilinear") +! call fld_list_add(fldsFrAtm, "inst_merid_wind_height_lowest" , "will provide", "bilinear") +! call fld_list_add(fldsFrAtm, "inst_pres_height_lowest" , "will provide", "bilinear") +! call fld_list_add(fldsFrAtm, "inst_height_lowest" , "will provide", "bilinear") + +! Fields to OCN +! ------------- + call fld_list_add(fldsToOcn, "mean_zonal_moment_flx" , "cannot provide") + call fld_list_add(fldsToOcn, "mean_merid_moment_flx" , "will provide") + call fld_list_add(fldsToOcn, "mean_sensi_heat_flx" , "will provide") + call fld_list_add(fldsToOcn, "mean_laten_heat_flx" , "will provide") + call fld_list_add(fldsToOcn, "mean_down_lw_flx" , "will provide") + call fld_list_add(fldsToOcn, "mean_down_sw_vis_dir_flx", "will provide") + call fld_list_add(fldsToOcn, "mean_down_sw_vis_dif_flx", "will provide") + call fld_list_add(fldsToOcn, "mean_down_sw_ir_dir_flx" , "will provide") + call fld_list_add(fldsToOcn, "mean_down_sw_ir_dif_flx" , "will provide") + call fld_list_add(fldsToOcn, "mean_net_sw_vis_dir_flx" , "will provide") + call fld_list_add(fldsToOcn, "mean_net_sw_vis_dif_flx" , "will provide") + call fld_list_add(fldsToOcn, "mean_net_sw_ir_dir_flx" , "will provide") + call fld_list_add(fldsToOcn, "mean_net_sw_ir_dif_flx" , "will provide") +! call fld_list_add(fldsToOcn, "mean_salt_flx" , "will provide") + call fld_list_add(fldsToOcn, "mean_prec_rate" , "will provide") + call fld_list_add(fldsToOcn, "mean_fprec_rate" , "will provide") + call fld_list_add(fldsToOcn, "mean_evap_rate" , "will provide") +! call fld_list_add(fldsToOcn, "mean_runoff_rate" , "will provide") +! call fld_list_add(fldsToOcn, "mean_calving_rate" , "will provide") +! call fld_list_add(fldsToOcn, "mean_runoff_flx" , "will provide") +! call fld_list_add(fldsToOcn, "mean_calving_flx" , "will provide") + call fld_list_add(fldsToOcn, "inst_pres_height_surface", "will provide") +! call fld_list_add(fldsToOcn, "mass_of_overlying_sea_ice, "will provide") + call fld_list_add(fldsToOcn, "stress_on_ocn_ice_zonal" , "will provide") + call fld_list_add(fldsToOcn, "stress_on_ocn_ice_merid" , "will provide") +! call fld_list_add(fldsToOcn, "stress_on_ocn_ice_idir" , "will provide") +! call fld_list_add(fldsToOcn, "stress_on_ocn_ice_jdir" , "will provide") + call fld_list_add(fldsToOcn, "mean_sw_pen_to_ocn" , "will provide") + call fld_list_add(fldsToOcn, "mean_down_sw_flx" , "will provide") + call fld_list_add(fldsToOcn, "mean_net_sw_flx" , "will provide") + call fld_list_add(fldsToOcn, "mean_net_lw_flx" , "will provide") +! call fld_list_add(fldsToOcn, "mean_up_lw_flx" , "will provide") + call fld_list_add(fldsToOcn, "inst_temp_height2m" , "will provide") + call fld_list_add(fldsToOcn, "inst_spec_humid_height2m", "will provide") + call fld_list_add(fldsToOcn, "net_heat_flx_to_ocn" , "will provide") + call fld_list_add(fldsToOcn, "mean_fresh_water_to_ocean_rate", "will provide") + call fld_list_add(fldsToOcn, "mean_salt_rate" , "will provide") + call fld_list_add(fldsToOcn, "ice_fraction" , "will provide") + ! Fields from OCN - call fld_list_add(fldsFrOcn,"ocean_mask" , "cannot provide","conservedst") - call fld_list_add(fldsFrOcn,"sea_surface_temperature" , "will provide","copy") - call fld_list_add(fldsFrOcn,"s_surf" , "will provide","copy") + call fld_list_add(fldsFrOcn, "ocean_mask" , "cannot provide", "conservedst") + call fld_list_add(fldsFrOcn, "sea_surface_temperature" , "will provide", "copy") + call fld_list_add(fldsFrOcn, "s_surf" , "will provide", "copy") #ifdef PATCH_BFB_FIXED - call fld_list_add(fldsFrOcn,"ocn_current_zonal" , "will provide","patch") - call fld_list_add(fldsFrOcn,"ocn_current_merid" , "will provide","patch") + call fld_list_add(fldsFrOcn, "ocn_current_zonal" , "will provide", "patch") + call fld_list_add(fldsFrOcn, "ocn_current_merid" , "will provide", "patch") #else - call fld_list_add(fldsFrOcn,"ocn_current_zonal" , "will provide","copy") - call fld_list_add(fldsFrOcn,"ocn_current_merid" , "will provide","copy") + call fld_list_add(fldsFrOcn, "ocn_current_zonal" , "will provide", "copy") + call fld_list_add(fldsFrOcn, "ocn_current_merid" , "will provide", "copy") #endif -! call fld_list_add(fldsFrOcn,"ocn_current_idir" , "will provide","copy") -! call fld_list_add(fldsFrOcn,"ocn_current_jdir" , "will provide","copy") - call fld_list_add(fldsFrOcn,"sea_lev" , "will provide","copy") - call fld_list_add(fldsFrOcn,"freezing_melting_potential", "will provide","copy") - call fld_list_add(fldsFrOcn,"upward_sea_ice_basal_available_heat_flux" & - , "will provide","conservefrac") - call fld_list_add(fldsFrOcn,"mixed_layer_depth" , "will provide","copy") - call fld_list_add(fldsFrOcn,"sea_surface_slope_zonal" , "will provide","copy") - call fld_list_add(fldsFrOcn,"sea_surface_slope_merid" , "will provide","copy") - call fld_list_add(fldsFrOcn,"accum_heat_frazil" , "will provide","copy") - call fld_list_add(fldsFrOcn,"inst_melt_potential " , "will provide","copy") - - ! Fields to ICE - call fld_list_add(fldsToIce,"dummyfield" , "cannot provide") - call fld_list_add(fldsToIce,"inst_temp_height2m" , "cannot provide") - call fld_list_add(fldsToIce,"inst_spec_humid_height2m" , "will provide") - call fld_list_add(fldsToIce,"inst_zonal_wind_height10m", "will provide") - call fld_list_add(fldsToIce,"inst_merid_wind_height10m", "will provide") - call fld_list_add(fldsToIce,"inst_temp_height_surface" , "will provide") - call fld_list_add(fldsToIce,"inst_surface_height" , "will provide") - call fld_list_add(fldsToIce,"inst_pres_height_surface" , "will provide") - call fld_list_add(fldsToIce,"mean_down_lw_flx" , "will provide") - call fld_list_add(fldsToIce,"mean_down_sw_vis_dir_flx" , "will provide") - call fld_list_add(fldsToIce,"mean_down_sw_vis_dif_flx" , "will provide") - call fld_list_add(fldsToIce,"mean_down_sw_ir_dir_flx" , "will provide") - call fld_list_add(fldsToIce,"mean_down_sw_ir_dif_flx" , "will provide") - call fld_list_add(fldsToIce,"mean_prec_rate" , "will provide") - call fld_list_add(fldsToIce,"mean_fprec_rate" , "will provide") - call fld_list_add(fldsToIce,"sea_surface_temperature" , "will provide") - call fld_list_add(fldsToIce,"s_surf" , "will provide") - call fld_list_add(fldsToIce,"sea_lev" , "will provide") - call fld_list_add(fldsToIce,"sea_surface_slope_zonal" , "will provide") - call fld_list_add(fldsToIce,"sea_surface_slope_merid" , "will provide") - call fld_list_add(fldsToIce,"ocn_current_zonal" , "will provide") - call fld_list_add(fldsToIce,"ocn_current_merid" , "will provide") -! call fld_list_add(fldsToIce,"ocn_current_idir" , "will provide") -! call fld_list_add(fldsToIce,"ocn_current_jdir" , "will provide") - call fld_list_add(fldsToIce,"freezing_melting_potential", "will provide") - call fld_list_add(fldsToIce,"mixed_layer_depth" , "will provide") - ! new exports from GSM added 06/09/15: - call fld_list_add(fldsToIce,"inst_temp_height_lowest" , "will provide") - call fld_list_add(fldsToIce,"inst_spec_humid_height_lowest" , "will provide") - call fld_list_add(fldsToIce,"inst_zonal_wind_height_lowest" , "will provide") - call fld_list_add(fldsToIce,"inst_merid_wind_height_lowest" , "will provide") - call fld_list_add(fldsToIce,"inst_pres_height_lowest" , "will provide") - call fld_list_add(fldsToIce,"inst_height_lowest" , "will provide") - call fld_list_add(fldsToIce,"mean_zonal_moment_flx" , "will provide") - call fld_list_add(fldsToIce,"mean_merid_moment_flx" , "will provide") - call fld_list_add(fldsToIce,"air_density_height_lowest" , "will provide") - - ! Fields from ICE -! call fld_list_add(fldsFrIce,"dummyfield" , "cannot provide","bilinear") - call fld_list_add(fldsFrIce,"ice_mask" , "cannot provide","conservedst") - call fld_list_add(fldsFrIce,"sea_ice_surface_temperature" , "will provide","conservefrac") - call fld_list_add(fldsFrIce,"inst_ice_ir_dir_albedo" , "will provide","conservefrac") - call fld_list_add(fldsFrIce,"inst_ice_ir_dif_albedo" , "will provide","conservefrac") - call fld_list_add(fldsFrIce,"inst_ice_vis_dir_albedo" , "will provide","conservefrac") - call fld_list_add(fldsFrIce,"inst_ice_vis_dif_albedo" , "will provide","conservefrac") - call fld_list_add(fldsFrIce,"ice_fraction" , "will provide","conservedst") - call fld_list_add(fldsFrIce,"stress_on_air_ice_zonal" , "will provide","conservefrac") - call fld_list_add(fldsFrIce,"stress_on_air_ice_merid" , "will provide","conservefrac") - call fld_list_add(fldsFrIce,"stress_on_ocn_ice_zonal" , "will provide","conservefrac") - call fld_list_add(fldsFrIce,"stress_on_ocn_ice_merid" , "will provide","conservefrac") -! call fld_list_add(fldsFrIce,"stress_on_ocn_ice_idir" , "will provide","copy") -! call fld_list_add(fldsFrIce,"stress_on_ocn_ice_jdir" , "will provide","copy") - call fld_list_add(fldsFrIce,"mean_sw_pen_to_ocn" , "will provide","conservefrac") - call fld_list_add(fldsFrIce,"mean_sw_pen_to_ocn_vis_dir_flx" , "will provide","conservefrac") - call fld_list_add(fldsFrIce,"mean_sw_pen_to_ocn_vis_dif_flx" , "will provide","conservefrac") - call fld_list_add(fldsFrIce,"mean_sw_pen_to_ocn_ir_dir_flx" , "will provide","conservefrac") - call fld_list_add(fldsFrIce,"mean_sw_pen_to_ocn_ir_dif_flx" , "will provide","conservefrac") - call fld_list_add(fldsFrIce,"mean_up_lw_flx_ice" , "will provide","conservefrac") - call fld_list_add(fldsFrIce,"mean_sensi_heat_flx_atm_into_ice", "will provide","conservefrac") - call fld_list_add(fldsFrIce,"mean_laten_heat_flx_atm_into_ice", "will provide","conservefrac") - call fld_list_add(fldsFrIce,"mean_evap_rate_atm_into_ice" , "will provide","conservefrac") - call fld_list_add(fldsFrIce,"net_heat_flx_to_ocn" , "will provide","conservefrac") - call fld_list_add(fldsFrIce,"mean_fresh_water_to_ocean_rate" , "will provide","conservefrac") - call fld_list_add(fldsFrIce,"mean_salt_rate" , "will provide","conservefrac") - call fld_list_add(fldsFrIce,"mean_ice_volume" , "will provide","conservefrac") - call fld_list_add(fldsFrIce,"mean_snow_volume" , "will provide","conservefrac") - - ! Required met forcing fields to LND - call fld_list_add(fldsToLnd,"inst_down_lw_flx" , "cannot provide") - call fld_list_add(fldsToLnd,"inst_down_sw_flx" , "cannot provide") - call fld_list_add(fldsToLnd,"inst_merid_wind_height_lowest" , "cannot provide") - call fld_list_add(fldsToLnd,"inst_pres_height_surface" , "cannot provide") - call fld_list_add(fldsToLnd,"inst_spec_humid_height_lowest" , "cannot provide") - call fld_list_add(fldsToLnd,"inst_temp_height_lowest" , "cannot provide") - call fld_list_add(fldsToLnd,"inst_zonal_wind_height_lowest" , "cannot provide") - call fld_list_add(fldsToLnd,"mean_prec_rate" , "cannot provide") - ! Feedback from HYD - call fld_list_add(fldsToLnd,"liquid_water_content_of_soil_layer_1" , "cannot provide") - call fld_list_add(fldsToLnd,"liquid_water_content_of_soil_layer_2" , "cannot provide") - call fld_list_add(fldsToLnd,"liquid_water_content_of_soil_layer_3" , "cannot provide") - call fld_list_add(fldsToLnd,"liquid_water_content_of_soil_layer_4" , "cannot provide") -! call fld_list_add(fldsToLnd,"volume_fraction_of_total_water_in_soil", "cannot provide") ! Missing -! call fld_list_add(fldsToLnd,"surface_snow_thickness" , "cannot provide") ! Missing -! call fld_list_add(fldsToLnd,"liquid_water_content_of_surface_snow" , "cannot provide") ! Missing - ! Other fields to LND -! call fld_list_add(fldsToLnd,"aerodynamic_roughness_length" , "cannot provide") -! call fld_list_add(fldsToLnd,"canopy_moisture_storage" , "cannot provide") ! Missing -! call fld_list_add(fldsToLnd,"carbon_dioxide" , "cannot provide") ! Future -! call fld_list_add(fldsToLnd,"cosine_zenith_angle" , "cannot provide") -! call fld_list_add(fldsToLnd,"exchange_coefficient_heat" , "cannot provide") -! call fld_list_add(fldsToLnd,"exchange_coefficient_heat_height2m" , "cannot provide") -! call fld_list_add(fldsToLnd,"exchange_coefficient_moisture_height2m", "cannot provide") -! call fld_list_add(fldsToLnd,"ice_mask" , "cannot provide") -! call fld_list_add(fldsToLnd,"inst_height_lowest" , "cannot provide") -! call fld_list_add(fldsToLnd,"inst_pres_height_lowest" , "cannot provide") -! call fld_list_add(fldsToLnd,"inst_temp_height_surface" , "cannot provide") ! Missing -! call fld_list_add(fldsToLnd,"inst_wind_speed_height_lowest" , "cannot provide") -! call fld_list_add(fldsToLnd,"mean_cprec_rate" , "cannot provide") -! call fld_list_add(fldsToLnd,"mean_down_lw_flx" , "cannot provide") ! Missing -! call fld_list_add(fldsToLnd,"mean_down_sw_flx" , "cannot provide") ! Missing -! call fld_list_add(fldsToLnd,"mean_fprec_rate" , "cannot provide") -! call fld_list_add(fldsToLnd,"mean_surface_albedo" , "cannot provide") -! call fld_list_add(fldsToLnd,"saturated_mixing_ratio" , "cannot provide") -! call fld_list_add(fldsToLnd,"moisture_content_of_soil_layer_1" , "cannot provide") ! Missing -! call fld_list_add(fldsToLnd,"moisture_content_of_soil_layer_2" , "cannot provide") ! Missing -! call fld_list_add(fldsToLnd,"moisture_content_of_soil_layer_3" , "cannot provide") ! Missing -! call fld_list_add(fldsToLnd,"moisture_content_of_soil_layer_4" , "cannot provide") ! Missing -! call fld_list_add(fldsToLnd,"temperature_of_soil_layer_1" , "cannot provide") ! Missing -! call fld_list_add(fldsToLnd,"temperature_of_soil_layer_2" , "cannot provide") ! Missing -! call fld_list_add(fldsToLnd,"temperature_of_soil_layer_3" , "cannot provide") ! Missing -! call fld_list_add(fldsToLnd,"temperature_of_soil_layer_4" , "cannot provide") ! Missing -! call fld_list_add(fldsToLnd,"soil_temperature_bottom" , "cannot provide") -! call fld_list_add(fldsToLnd,"surface_microwave_emissivity" , "cannot provide") - - ! Forcing fields to hydrology - call fld_list_add(fldsFrLnd,"temperature_of_soil_layer_1" , "cannot provide","conservefrac") - call fld_list_add(fldsFrLnd,"temperature_of_soil_layer_2" , "cannot provide","conservefrac") - call fld_list_add(fldsFrLnd,"temperature_of_soil_layer_3" , "cannot provide","conservefrac") - call fld_list_add(fldsFrLnd,"temperature_of_soil_layer_4" , "cannot provide","conservefrac") -! call fld_list_add(fldsFrLnd,"moisture_content_of_soil_layer_1" , "cannot provide","conservefrac") -! call fld_list_add(fldsFrLnd,"moisture_content_of_soil_layer_2" , "cannot provide","conservefrac") -! call fld_list_add(fldsFrLnd,"moisture_content_of_soil_layer_3" , "cannot provide","conservefrac") -! call fld_list_add(fldsFrLnd,"moisture_content_of_soil_layer_4" , "cannot provide","conservefrac") -! call fld_list_add(fldsFrLnd,"liquid_water_content_of_soil_layer_1" , "cannot provide","conservefrac") -! call fld_list_add(fldsFrLnd,"liquid_water_content_of_soil_layer_2" , "cannot provide","conservefrac") -! call fld_list_add(fldsFrLnd,"liquid_water_content_of_soil_layer_3" , "cannot provide","conservefrac") -! call fld_list_add(fldsFrLnd,"liquid_water_content_of_soil_layer_4" , "cannot provide","conservefrac") -! call fld_list_add(fldsFrLnd,"surface_runoff_flux" , "cannot provide","conservefrac") -! call fld_list_add(fldsFrLnd,"subsurface_runoff_flux" , "cannot provide","conservefrac") - ! Feedback to atmosphere - call fld_list_add(fldsFrLnd,"mean_sensi_heat_flx_atm_into_lnd", "cannot provide","conservefrac") - call fld_list_add(fldsFrLnd,"mean_laten_heat_flx_atm_into_lnd", "cannot provide","conservefrac") - ! Other fields from LND -! call fld_list_add(fldsFrLnd,"aerodynamic_roughness_length" , "cannot provide","conservefrac") -! call fld_list_add(fldsFrLnd,"canopy_moisture_storage" , "cannot provide","conservefrac") -! call fld_list_add(fldsFrLnd,"exchange_coefficient_heat_height2m" , "cannot provide","conservefrac") -! call fld_list_add(fldsFrLnd,"exchange_coefficient_moisture_height2m", "cannot provide","conservefrac") -! call fld_list_add(fldsFrLnd,"ice_mask" , "cannot provide","conservefrac") -! call fld_list_add(fldsFrLnd,"inst_temp_height_lowest" , "cannot provide","conservefrac") ! Missing -! call fld_list_add(fldsFrLnd,"inst_temp_height_surface" , "cannot provide","conservefrac") ! Missing -! call fld_list_add(fldsFrLnd,"mean_grnd_sensi_heat_flx" , "cannot provide","conservefrac") -! call fld_list_add(fldsFrLnd,"mean_laten_heat_flx_kinematic" , "cannot provide","conservefrac") -! call fld_list_add(fldsFrLnd,"mean_net_lw_flx" , "cannot provide","conservefrac") ! Missing -! call fld_list_add(fldsFrLnd,"mean_net_sw_flx" , "cannot provide","conservefrac") ! Missing -! call fld_list_add(fldsFrLnd,"mean_surface_albedo" , "cannot provide","conservefrac") -! call fld_list_add(fldsFrLnd,"mean_surface_skin_temp" , "cannot provide","conservefrac") -! call fld_list_add(fldsFrLnd,"mixing_ratio_surface" , "cannot provide","conservefrac") -! call fld_list_add(fldsFrLnd,"root_moisture" , "cannot provide","conservefrac") -! call fld_list_add(fldsFrLnd,"surface_snow_area_fraction" , "cannot provide","conservefrac") -! call fld_list_add(fldsFrLnd,"surface_snow_melt_flux" , "cannot provide","conservefrac") -! call fld_list_add(fldsFrLnd,"liquid_water_content_of_surface_snow" , "cannot provide","conservefrac") -! call fld_list_add(fldsFrLnd,"surface_snow_thickness" , "cannot provide","conservefrac") ! Missing -! call fld_list_add(fldsFrLnd,"soil_hydraulic_conductivity_at_saturation", "cannot provide","conservefrac") ! Missing -! call fld_list_add(fldsFrLnd,"soil_porosity" , "cannot provide","conservefrac") -! call fld_list_add(fldsFrLnd,"soil_temperature_bottom" , "cannot provide","conservefrac") ! Missing -! call fld_list_add(fldsFrLnd,"soil_type" , "cannot provide","conservefrac") ! Missing -! call fld_list_add(fldsFrLnd,"soil_moisture_content" , "cannot provide","conservefrac") -! call fld_list_add(fldsFrLnd,"subsurface_basin_mask" , "cannot provide","conservefrac") ! Missing -! call fld_list_add(fldsFrLnd,"surface_microwave_emissivity" , "cannot provide","conservefrac") -! call fld_list_add(fldsFrLnd,"vegetation_type" , "cannot provide","conservefrac") -! call fld_list_add(fldsFrLnd,"volume_fraction_of_frozen_water_in_soil", "cannot provide","conservefrac") ! Missing -! call fld_list_add(fldsFrLnd,"volume_fraction_of_total_water_in_soil", "cannot provide","conservefrac") -! call fld_list_add(fldsFrLnd,"volume_fraction_of_total_water_in_soil_at_critical_point", "cannot provide","conservefrac") ! Missing -! call fld_list_add(fldsFrLnd,"volume_fraction_of_total_water_in_soil_at_field_capacity", "cannot provide","conservefrac") ! Missing -! call fld_list_add(fldsFrLnd,"volume_fraction_of_total_water_in_soil_at_wilting_point" , "cannot provide","conservefrac") ! Missing - - ! Required LND forcing fields to HYD - call fld_list_add(fldsToHyd,"temperature_of_soil_layer_1" , "cannot provide") - call fld_list_add(fldsToHyd,"temperature_of_soil_layer_2" , "cannot provide") - call fld_list_add(fldsToHyd,"temperature_of_soil_layer_3" , "cannot provide") - call fld_list_add(fldsToHyd,"temperature_of_soil_layer_4" , "cannot provide") -! call fld_list_add(fldsToHyd,"moisture_content_of_soil_layer_1" , "cannot provide") -! call fld_list_add(fldsToHyd,"moisture_content_of_soil_layer_2" , "cannot provide") -! call fld_list_add(fldsToHyd,"moisture_content_of_soil_layer_3" , "cannot provide") -! call fld_list_add(fldsToHyd,"moisture_content_of_soil_layer_4" , "cannot provide") -! call fld_list_add(fldsToHyd,"liquid_water_content_of_soil_layer_1", "cannot provide") -! call fld_list_add(fldsToHyd,"liquid_water_content_of_soil_layer_2", "cannot provide") -! call fld_list_add(fldsToHyd,"liquid_water_content_of_soil_layer_3", "cannot provide") -! call fld_list_add(fldsToHyd,"liquid_water_content_of_soil_layer_4", "cannot provide") -! call fld_list_add(fldsToHyd,"surface_runoff_flux" , "cannot provide") -! call fld_list_add(fldsToHyd,"subsurface_runoff_flux" , "cannot provide") +! call fld_list_add(fldsFrOcn, "ocn_current_idir" , "will provide", "copy") +! call fld_list_add(fldsFrOcn, "ocn_current_jdir" , "will provide", "copy") + call fld_list_add(fldsFrOcn, "sea_lev" , "will provide", "copy") + call fld_list_add(fldsFrOcn, "freezing_melting_potential", "will provide", "copy") + call fld_list_add(fldsFrOcn, "upward_sea_ice_basal_available_heat_flux" & + , "will provide", "conservefrac") + call fld_list_add(fldsFrOcn, "mixed_layer_depth" , "will provide", "copy") + call fld_list_add(fldsFrOcn, "sea_surface_slope_zonal" , "will provide", "copy") + call fld_list_add(fldsFrOcn, "sea_surface_slope_merid" , "will provide", "copy") + call fld_list_add(fldsFrOcn, "accum_heat_frazil" , "will provide", "copy") + call fld_list_add(fldsFrOcn, "inst_melt_potential " , "will provide", "copy") + +! Fields to ICE +! ------------- + call fld_list_add(fldsToIce, "dummyfield" , "cannot provide") + call fld_list_add(fldsToIce, "inst_temp_height2m" , "cannot provide") + call fld_list_add(fldsToIce, "inst_spec_humid_height2m" , "will provide") + call fld_list_add(fldsToIce, "inst_zonal_wind_height10m" , "will provide") + call fld_list_add(fldsToIce, "inst_merid_wind_height10m" , "will provide") + call fld_list_add(fldsToIce, "inst_temp_height_surface" , "will provide") + call fld_list_add(fldsToIce, "inst_surface_height" , "will provide") + call fld_list_add(fldsToIce, "inst_pres_height_surface" , "will provide") + call fld_list_add(fldsToIce, "mean_down_lw_flx" , "will provide") + call fld_list_add(fldsToIce, "mean_down_sw_vis_dir_flx" , "will provide") + call fld_list_add(fldsToIce, "mean_down_sw_vis_dif_flx" , "will provide") + call fld_list_add(fldsToIce, "mean_down_sw_ir_dir_flx" , "will provide") + call fld_list_add(fldsToIce, "mean_down_sw_ir_dif_flx" , "will provide") + call fld_list_add(fldsToIce, "mean_prec_rate" , "will provide") + call fld_list_add(fldsToIce, "mean_fprec_rate" , "will provide") + call fld_list_add(fldsToIce, "sea_surface_temperature" , "will provide") + call fld_list_add(fldsToIce, "s_surf" , "will provide") + call fld_list_add(fldsToIce, "sea_lev" , "will provide") + call fld_list_add(fldsToIce, "sea_surface_slope_zonal" , "will provide") + call fld_list_add(fldsToIce, "sea_surface_slope_merid" , "will provide") + call fld_list_add(fldsToIce, "ocn_current_zonal" , "will provide") + call fld_list_add(fldsToIce, "ocn_current_merid" , "will provide") +! call fld_list_add(fldsToIce, "ocn_current_idir" , "will provide") +! call fld_list_add(fldsToIce, "ocn_current_jdir" , "will provide") + call fld_list_add(fldsToIce, "freezing_melting_potential" , "will provide") + call fld_list_add(fldsToIce, "mixed_layer_depth" , "will provide") + ! new exports from GSM added 06/09/15: + call fld_list_add(fldsToIce, "inst_temp_height_lowest" , "will provide") + call fld_list_add(fldsToIce, "inst_spec_humid_height_lowest" , "will provide") + call fld_list_add(fldsToIce, "inst_zonal_wind_height_lowest" , "will provide") + call fld_list_add(fldsToIce, "inst_merid_wind_height_lowest" , "will provide") + call fld_list_add(fldsToIce, "inst_pres_height_lowest" , "will provide") + call fld_list_add(fldsToIce, "inst_height_lowest" , "will provide") + call fld_list_add(fldsToIce, "mean_zonal_moment_flx" , "will provide") + call fld_list_add(fldsToIce, "mean_merid_moment_flx" , "will provide") + call fld_list_add(fldsToIce, "air_density_height_lowest" , "will provide") + +! Fields from ICE +! --------------- +! call fld_list_add(fldsFrIce, "dummyfield" , "cannot provide","bilinear") + call fld_list_add(fldsFrIce, "ice_mask" , "cannot provide", "conservedst") + call fld_list_add(fldsFrIce, "sea_ice_surface_temperature" , "will provide", "conservefrac") + call fld_list_add(fldsFrIce, "inst_ice_ir_dir_albedo" , "will provide", "conservefrac") + call fld_list_add(fldsFrIce, "inst_ice_ir_dif_albedo" , "will provide", "conservefrac") + call fld_list_add(fldsFrIce, "inst_ice_vis_dir_albedo" , "will provide", "conservefrac") + call fld_list_add(fldsFrIce, "inst_ice_vis_dif_albedo" , "will provide", "conservefrac") + call fld_list_add(fldsFrIce, "ice_fraction" , "will provide", "conservedst") + call fld_list_add(fldsFrIce, "stress_on_air_ice_zonal" , "will provide", "conservefrac") + call fld_list_add(fldsFrIce, "stress_on_air_ice_merid" , "will provide", "conservefrac") + call fld_list_add(fldsFrIce, "stress_on_ocn_ice_zonal" , "will provide", "conservefrac") + call fld_list_add(fldsFrIce, "stress_on_ocn_ice_merid" , "will provide", "conservefrac") +! call fld_list_add(fldsFrIce, "stress_on_ocn_ice_idir" , "will provide", "copy") +! call fld_list_add(fldsFrIce, "stress_on_ocn_ice_jdir" , "will provide", "copy") + call fld_list_add(fldsFrIce, "mean_sw_pen_to_ocn" , "will provide", "conservefrac") + call fld_list_add(fldsFrIce, "mean_sw_pen_to_ocn_vis_dir_flx" , "will provide", "conservefrac") + call fld_list_add(fldsFrIce, "mean_sw_pen_to_ocn_vis_dif_flx" , "will provide", "conservefrac") + call fld_list_add(fldsFrIce, "mean_sw_pen_to_ocn_ir_dir_flx" , "will provide", "conservefrac") + call fld_list_add(fldsFrIce, "mean_sw_pen_to_ocn_ir_dif_flx" , "will provide", "conservefrac") + call fld_list_add(fldsFrIce, "mean_up_lw_flx_ice" , "will provide", "conservefrac") + call fld_list_add(fldsFrIce, "mean_sensi_heat_flx_atm_into_ice", "will provide", "conservefrac") + call fld_list_add(fldsFrIce, "mean_laten_heat_flx_atm_into_ice", "will provide", "conservefrac") + call fld_list_add(fldsFrIce, "mean_evap_rate_atm_into_ice" , "will provide", "conservefrac") + call fld_list_add(fldsFrIce, "net_heat_flx_to_ocn" , "will provide", "conservefrac") + call fld_list_add(fldsFrIce, "mean_fresh_water_to_ocean_rate" , "will provide", "conservefrac") + call fld_list_add(fldsFrIce, "mean_salt_rate" , "will provide", "conservefrac") + call fld_list_add(fldsFrIce, "mean_ice_volume" , "will provide", "conservefrac") + call fld_list_add(fldsFrIce, "mean_snow_volume" , "will provide", "conservefrac") + +! Required met forcing fields to LND +! ---------------------------------- + call fld_list_add(fldsToLnd, "inst_down_lw_flx" , "cannot provide") + call fld_list_add(fldsToLnd, "inst_down_sw_flx" , "cannot provide") + call fld_list_add(fldsToLnd, "inst_merid_wind_height_lowest" , "cannot provide") + call fld_list_add(fldsToLnd, "inst_pres_height_surface" , "cannot provide") + call fld_list_add(fldsToLnd, "inst_spec_humid_height_lowest" , "cannot provide") + call fld_list_add(fldsToLnd, "inst_temp_height_lowest" , "cannot provide") + call fld_list_add(fldsToLnd, "inst_zonal_wind_height_lowest" , "cannot provide") + call fld_list_add(fldsToLnd, "mean_prec_rate" , "cannot provide") + +! Feedback from HYD +! ----------------- + call fld_list_add(fldsToLnd, "liquid_water_content_of_soil_layer_1" , "cannot provide") + call fld_list_add(fldsToLnd, "liquid_water_content_of_soil_layer_2" , "cannot provide") + call fld_list_add(fldsToLnd, "liquid_water_content_of_soil_layer_3" , "cannot provide") + call fld_list_add(fldsToLnd, "liquid_water_content_of_soil_layer_4" , "cannot provide") +! call fld_list_add(fldsToLnd, "volume_fraction_of_total_water_in_soil", "cannot provide") ! Missing +! call fld_list_add(fldsToLnd, "surface_snow_thickness" , "cannot provide") ! Missing +! call fld_list_add(fldsToLnd, "liquid_water_content_of_surface_snow" , "cannot provide") ! Missing + +! Other fields to LND +! ------------------- +! call fld_list_add(fldsToLnd, "aerodynamic_roughness_length" , "cannot provide") +! call fld_list_add(fldsToLnd, "canopy_moisture_storage" , "cannot provide") ! Missing +! call fld_list_add(fldsToLnd, "carbon_dioxide" , "cannot provide") ! Future +! call fld_list_add(fldsToLnd, "cosine_zenith_angle" , "cannot provide") +! call fld_list_add(fldsToLnd, "exchange_coefficient_heat" , "cannot provide") +! call fld_list_add(fldsToLnd, "exchange_coefficient_heat_height2m" , "cannot provide") +! call fld_list_add(fldsToLnd, "exchange_coefficient_moisture_height2m", "cannot provide") +! call fld_list_add(fldsToLnd, "ice_mask" , "cannot provide") +! call fld_list_add(fldsToLnd, "inst_height_lowest" , "cannot provide") +! call fld_list_add(fldsToLnd, "inst_pres_height_lowest" , "cannot provide") +! call fld_list_add(fldsToLnd, "inst_temp_height_surface" , "cannot provide") ! Missing +! call fld_list_add(fldsToLnd, "inst_wind_speed_height_lowest" , "cannot provide") +! call fld_list_add(fldsToLnd, "mean_cprec_rate" , "cannot provide") +! call fld_list_add(fldsToLnd, "mean_down_lw_flx" , "cannot provide") ! Missing +! call fld_list_add(fldsToLnd, "mean_down_sw_flx" , "cannot provide") ! Missing +! call fld_list_add(fldsToLnd, "mean_fprec_rate" , "cannot provide") +! call fld_list_add(fldsToLnd, "mean_surface_albedo" , "cannot provide") +! call fld_list_add(fldsToLnd, "saturated_mixing_ratio" , "cannot provide") +! call fld_list_add(fldsToLnd, "moisture_content_of_soil_layer_1" , "cannot provide") ! Missing +! call fld_list_add(fldsToLnd, "moisture_content_of_soil_layer_2" , "cannot provide") ! Missing +! call fld_list_add(fldsToLnd, "moisture_content_of_soil_layer_3" , "cannot provide") ! Missing +! call fld_list_add(fldsToLnd, "moisture_content_of_soil_layer_4" , "cannot provide") ! Missing +! call fld_list_add(fldsToLnd, "temperature_of_soil_layer_1" , "cannot provide") ! Missing +! call fld_list_add(fldsToLnd, "temperature_of_soil_layer_2" , "cannot provide") ! Missing +! call fld_list_add(fldsToLnd, "temperature_of_soil_layer_3" , "cannot provide") ! Missing +! call fld_list_add(fldsToLnd, "temperature_of_soil_layer_4" , "cannot provide") ! Missing +! call fld_list_add(fldsToLnd, "soil_temperature_bottom" , "cannot provide") +! call fld_list_add(fldsToLnd, "surface_microwave_emissivity" , "cannot provide") + +! Forcing fields to hydrology +! --------------------------- + call fld_list_add(fldsFrLnd, "temperature_of_soil_layer_1" , "cannot provide", "conservefrac") + call fld_list_add(fldsFrLnd, "temperature_of_soil_layer_2" , "cannot provide", "conservefrac") + call fld_list_add(fldsFrLnd, "temperature_of_soil_layer_3" , "cannot provide", "conservefrac") + call fld_list_add(fldsFrLnd, "temperature_of_soil_layer_4" , "cannot provide", "conservefrac") +! call fld_list_add(fldsFrLnd, "moisture_content_of_soil_layer_1" , "cannot provide", "conservefrac") +! call fld_list_add(fldsFrLnd, "moisture_content_of_soil_layer_2" , "cannot provide", "conservefrac") +! call fld_list_add(fldsFrLnd, "moisture_content_of_soil_layer_3" , "cannot provide", "conservefrac") +! call fld_list_add(fldsFrLnd, "moisture_content_of_soil_layer_4" , "cannot provide", "conservefrac") +! call fld_list_add(fldsFrLnd, "liquid_water_content_of_soil_layer_1" , "cannot provide", "conservefrac") +! call fld_list_add(fldsFrLnd, "liquid_water_content_of_soil_layer_2" , "cannot provide", "conservefrac") +! call fld_list_add(fldsFrLnd, "liquid_water_content_of_soil_layer_3" , "cannot provide", "conservefrac") +! call fld_list_add(fldsFrLnd, "liquid_water_content_of_soil_layer_4" , "cannot provide", "conservefrac") +! call fld_list_add(fldsFrLnd, "surface_runoff_flux" , "cannot provide", "conservefrac") +! call fld_list_add(fldsFrLnd, "subsurface_runoff_flux" , "cannot provide", "conservefrac") + +! Feedback to atmosphere +! --------------------- + call fld_list_add(fldsFrLnd, "mean_sensi_heat_flx_atm_into_lnd", "cannot provide", "conservefrac") + call fld_list_add(fldsFrLnd, "mean_laten_heat_flx_atm_into_lnd", "cannot provide", "conservefrac") + +! Other fields from LND +! --------------------- +! call fld_list_add(fldsFrLnd, "aerodynamic_roughness_length" , "cannot provide", "conservefrac") +! call fld_list_add(fldsFrLnd, "canopy_moisture_storage" , "cannot provide", "conservefrac") +! call fld_list_add(fldsFrLnd, "exchange_coefficient_heat_height2m" , "cannot provide", "conservefrac") +! call fld_list_add(fldsFrLnd, "exchange_coefficient_moisture_height2m", "cannot provide", "conservefrac") +! call fld_list_add(fldsFrLnd, "ice_mask" , "cannot provide", "conservefrac") +! call fld_list_add(fldsFrLnd, "inst_temp_height_lowest" , "cannot provide", "conservefrac") ! Missing +! call fld_list_add(fldsFrLnd, "inst_temp_height_surface" , "cannot provide", "conservefrac") ! Missing +! call fld_list_add(fldsFrLnd, "mean_grnd_sensi_heat_flx" , "cannot provide", "conservefrac") +! call fld_list_add(fldsFrLnd, "mean_laten_heat_flx_kinematic" , "cannot provide", "conservefrac") +! call fld_list_add(fldsFrLnd, "mean_net_lw_flx" , "cannot provide", "conservefrac") ! Missing +! call fld_list_add(fldsFrLnd, "mean_net_sw_flx" , "cannot provide", "conservefrac") ! Missing +! call fld_list_add(fldsFrLnd, "mean_surface_albedo" , "cannot provide", "conservefrac") +! call fld_list_add(fldsFrLnd, "mean_surface_skin_temp" , "cannot provide", "conservefrac") +! call fld_list_add(fldsFrLnd, "mixing_ratio_surface" , "cannot provide", "conservefrac") +! call fld_list_add(fldsFrLnd, "root_moisture" , "cannot provide", "conservefrac") +! call fld_list_add(fldsFrLnd, "surface_snow_area_fraction" , "cannot provide", "conservefrac") +! call fld_list_add(fldsFrLnd, "surface_snow_melt_flux" , "cannot provide", "conservefrac") +! call fld_list_add(fldsFrLnd, "liquid_water_content_of_surface_snow" , "cannot provide", "conservefrac") +! call fld_list_add(fldsFrLnd, "surface_snow_thickness" , "cannot provide", "conservefrac") ! Missing +! call fld_list_add(fldsFrLnd, "soil_hydraulic_conductivity_at_saturation", "cannot provide", "conservefrac") ! Missing +! call fld_list_add(fldsFrLnd, "soil_porosity" , "cannot provide", "conservefrac") +! call fld_list_add(fldsFrLnd, "soil_temperature_bottom" , "cannot provide", "conservefrac") ! Missing +! call fld_list_add(fldsFrLnd, "soil_type" , "cannot provide", "conservefrac") ! Missing +! call fld_list_add(fldsFrLnd, "soil_moisture_content" , "cannot provide", "conservefrac") +! call fld_list_add(fldsFrLnd, "subsurface_basin_mask" , "cannot provide", "conservefrac") ! Missing +! call fld_list_add(fldsFrLnd, "surface_microwave_emissivity" , "cannot provide", "conservefrac") +! call fld_list_add(fldsFrLnd, "vegetation_type" , "cannot provide", "conservefrac") + +! call fld_list_add(fldsFrLnd, "volume_fraction_of_frozen_water_in_soil", "cannot provide", "conservefrac") ! Missing +! call fld_list_add(fldsFrLnd, "volume_fraction_of_total_water_in_soil", "cannot provide", "conservefrac") +! call fld_list_add(fldsFrLnd, "volume_fraction_of_total_water_in_soil_at_critical_point", "cannot provide", "conservefrac") ! Missing +! call fld_list_add(fldsFrLnd, "volume_fraction_of_total_water_in_soil_at_field_capacity", "cannot provide", "conservefrac") ! Missing +! call fld_list_add(fldsFrLnd, "volume_fraction_of_total_water_in_soil_at_wilting_point" , "cannot provide", "conservefrac") ! Missing + +! Required LND forcing fields to HYD +! ---------------------------------- + call fld_list_add(fldsToHyd, "temperature_of_soil_layer_1" , "cannot provide") + call fld_list_add(fldsToHyd, "temperature_of_soil_layer_2" , "cannot provide") + call fld_list_add(fldsToHyd, "temperature_of_soil_layer_3" , "cannot provide") + call fld_list_add(fldsToHyd, "temperature_of_soil_layer_4" , "cannot provide") +! call fld_list_add(fldsToHyd, "moisture_content_of_soil_layer_1" , "cannot provide") +! call fld_list_add(fldsToHyd, "moisture_content_of_soil_layer_2" , "cannot provide") +! call fld_list_add(fldsToHyd, "moisture_content_of_soil_layer_3" , "cannot provide") +! call fld_list_add(fldsToHyd, "moisture_content_of_soil_layer_4" , "cannot provide") +! call fld_list_add(fldsToHyd, "liquid_water_content_of_soil_layer_1", "cannot provide") +! call fld_list_add(fldsToHyd, "liquid_water_content_of_soil_layer_2", "cannot provide") +! call fld_list_add(fldsToHyd, "liquid_water_content_of_soil_layer_3", "cannot provide") +! call fld_list_add(fldsToHyd, "liquid_water_content_of_soil_layer_4", "cannot provide") +! call fld_list_add(fldsToHyd, "surface_runoff_flux" , "cannot provide") +! call fld_list_add(fldsToHyd, "subsurface_runoff_flux" , "cannot provide") ! Met forcing fields to HYD - call fld_list_add(fldsToHyd,"inst_down_lw_flx" , "cannot provide") - call fld_list_add(fldsToHyd,"inst_down_sw_flx" , "cannot provide") -! call fld_list_add(fldsToHyd,"inst_merid_wind_height_lowest" , "cannot provide") -! call fld_list_add(fldsToHyd,"inst_pres_height_surface" , "cannot provide") -! call fld_list_add(fldsToHyd,"inst_spec_humid_height_lowest" , "cannot provide") -! call fld_list_add(fldsToHyd,"inst_temp_height_lowest" , "cannot provide") -! call fld_list_add(fldsToHyd,"inst_zonal_wind_height_lowest" , "cannot provide") -! call fld_list_add(fldsToHyd,"mean_prec_rate" , "cannot provide") + call fld_list_add(fldsToHyd, "inst_down_lw_flx" , "cannot provide") + call fld_list_add(fldsToHyd, "inst_down_sw_flx" , "cannot provide") +! call fld_list_add(fldsToHyd, "inst_merid_wind_height_lowest" , "cannot provide") +! call fld_list_add(fldsToHyd, "inst_pres_height_surface" , "cannot provide") +! call fld_list_add(fldsToHyd, "inst_spec_humid_height_lowest" , "cannot provide") +! call fld_list_add(fldsToHyd, "inst_temp_height_lowest" , "cannot provide") +! call fld_list_add(fldsToHyd, "inst_zonal_wind_height_lowest" , "cannot provide") +! call fld_list_add(fldsToHyd, "mean_prec_rate" , "cannot provide") ! Fields from HYD to LND and ATM - call fld_list_add(fldsFrHyd,"liquid_water_content_of_soil_layer_1" , "cannot provide","conservefrac") - call fld_list_add(fldsFrHyd,"liquid_water_content_of_soil_layer_2" , "cannot provide","conservefrac") - call fld_list_add(fldsFrHyd,"liquid_water_content_of_soil_layer_3" , "cannot provide","conservefrac") - call fld_list_add(fldsFrHyd,"liquid_water_content_of_soil_layer_4" , "cannot provide","conservefrac") -! call fld_list_add(fldsFrHyd,"volume_fraction_of_total_water_in_soil" , "cannot provide","conservefrac") -! call fld_list_add(fldsFrHyd,"surface_snow_thickness" , "cannot provide","conservefrac") -! call fld_list_add(fldsFrHyd,"liquid_water_content_of_surface_snow" , "cannot provide","conservefrac") + call fld_list_add(fldsFrHyd, "liquid_water_content_of_soil_layer_1" , "cannot provide", "conservefrac") + call fld_list_add(fldsFrHyd, "liquid_water_content_of_soil_layer_2" , "cannot provide", "conservefrac") + call fld_list_add(fldsFrHyd, "liquid_water_content_of_soil_layer_3" , "cannot provide", "conservefrac") + call fld_list_add(fldsFrHyd, "liquid_water_content_of_soil_layer_4" , "cannot provide", "conservefrac") +! call fld_list_add(fldsFrHyd, "volume_fraction_of_total_water_in_soil" , "cannot provide", "conservefrac") +! call fld_list_add(fldsFrHyd, "surface_snow_thickness" , "cannot provide", "conservefrac") +! call fld_list_add(fldsFrHyd, "liquid_water_content_of_surface_snow" , "cannot provide", "conservefrac") ! Other fields from HYD -! call fld_list_add(fldsFrHyd,"water_surface_height_above_reference_datum" , "cannot provide","conservefrac") +! call fld_list_add(fldsFrHyd, "water_surface_height_above_reference_datum" , "cannot provide", "conservefrac") if (dbug_flag > 5) then call ESMF_LogWrite(trim(subname)//": done", ESMF_LOGMSG_INFO, rc=dbrc) endif end subroutine SetServices - + !----------------------------------------------------------------------------- subroutine InitializeP0(gcomp, importState, exportState, clock, rc) @@ -912,104 +969,123 @@ subroutine InitializeP0(gcomp, importState, exportState, clock, rc) ! local variables character(len=NUOPC_PhaseMapStringLength) :: initPhases(6) - character(len=*),parameter :: subname='(module_MEDIATOR:InitializeP0)' + character(len=*),parameter :: subname='(module_MEDIATOR:InitializeP0)' character(len=10) :: value + character(len=256) :: cvalue call ESMF_AttributeGet(gcomp, name="Verbosity", value=value, defaultValue="max", & - convention="NUOPC", purpose="Instance", rc=rc) - call ESMF_LogWrite(trim(subname)//": Verbosity="//trim(value), ESMF_LOGMSG_INFO, rc=dbrc) - - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out - dbug_flag = ESMF_UtilString2Int(value, & - specialStringList=(/character(4)::"off","low","high","max"/), & - specialValueList=(/0,1,100,255/), rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + convention="NUOPC", purpose="Instance", rc=rc) + call ESMF_LogWrite(trim(subname)//": Verbosity="//trim(value), ESMF_LOGMSG_INFO, rc=dbrc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + + dbug_flag = ESMF_UtilString2Int(value, & + specialStringList=(/character(4)::"off","low","high","max"/), & + specialValueList=(/0,1,100,255/), rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + write(msgString,'(A,i6)') trim(subname)//' dbug_flag = ',dbug_flag call ESMF_LogWrite(trim(msgString), ESMF_LOGMSG_INFO, rc=dbrc) if (dbug_flag > 5) then - call ESMF_LogWrite(trim(subname)//": called", ESMF_LOGMSG_INFO, rc=dbrc) + call ESMF_LogWrite(trim(subname)//": called", ESMF_LOGMSG_INFO, rc=dbrc) endif rc = ESMF_SUCCESS ! Switch to IPDv03 by filtering all other phaseMap entries call NUOPC_CompFilterPhaseMap(gcomp, ESMF_METHOD_INITIALIZE, & - acceptStringList=(/"IPDv03p"/), rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + acceptStringList=(/"IPDv03p"/), rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return call ESMF_AttributeGet(gcomp, name="restart_interval", value=value, defaultValue="unset", & - convention="NUOPC", purpose="Instance", rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + convention="NUOPC", purpose="Instance", rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + restart_interval = ESMF_UtilString2Int(value, & - specialStringList=(/"unset"/), specialValueList=(/0/), rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + specialStringList=(/"unset"/), specialValueList=(/0/), rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return write(msgString,'(A,i6)') trim(subname)//' restart_interval = ',restart_interval call ESMF_LogWrite(trim(msgString), ESMF_LOGMSG_INFO, rc=dbrc) + if (restart_interval > 0) then + restart_dir = ' ' + call ESMF_AttributeGet(gcomp, name="restart_dir", value=cvalue, defaultValue=" ", & + convention="NUOPC", purpose="Instance", rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + restart_dir = trim(cvalue) + endif + call ESMF_AttributeGet(gcomp, name="coldstart", value=value, defaultValue="false", & - convention="NUOPC", purpose="Instance", rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out - coldstart=(trim(value)=="true") + convention="NUOPC", purpose="Instance", rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + + coldstart = (trim(value)=="true") write(msgString,'(A,l6)') trim(subname)//' coldstart = ',coldstart call ESMF_LogWrite(trim(msgString), ESMF_LOGMSG_INFO, rc=dbrc) - call ESMF_AttributeGet(gcomp, name="generate_landmask", value=value, defaultValue="true", & - convention="NUOPC", purpose="Instance", rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out - generate_landmask=(trim(value)=="true") + call ESMF_AttributeGet(gcomp, name="maptest", value=value, defaultValue="false", & + convention="NUOPC", purpose="Instance", rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + maptest = (trim(value)=="true") + write(msgString,'(A,l6)') trim(subname)//' maptest = ',maptest + call ESMF_LogWrite(trim(msgString), ESMF_LOGMSG_INFO, rc=dbrc) + + call ESMF_AttributeGet(gcomp, name="generate_landmask", value=value, defaultValue="false", & + convention="NUOPC", purpose="Instance", rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + + generate_landmask = (trim(value)=="true") write(msgString,'(A,l6)') trim(subname)//' generate_landmask = ',generate_landmask call ESMF_LogWrite(trim(msgString), ESMF_LOGMSG_INFO, rc=dbrc) - call ESMF_AttributeGet(gcomp, name="DumpFields", value=value, defaultValue="true", & - convention="NUOPC", purpose="Instance", rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out - statewrite_flag=(trim(value)=="true") + call ESMF_AttributeGet(gcomp, name="DumpFields_MED", value=value, defaultValue="true", & + convention="NUOPC", purpose="Instance", rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + + statewrite_flag = (trim(value)=="true") write(msgString,'(A,l6)') trim(subname)//' statewrite_flag = ',statewrite_flag call ESMF_LogWrite(trim(msgString), ESMF_LOGMSG_INFO, rc=dbrc) + + call ESMF_AttributeGet(gcomp, name="OverwriteSlice_MED", value=value, defaultValue="true", & + convention="NUOPC", purpose="Instance", rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + overwrite_flag = (trim(value) /= "false") + write(msgString,'(A,l6)')'MEDIATOR: Overwrite_Flag = ',overwrite_flag + call ESMF_LogWrite(trim(msgString), ESMF_LOGMSG_INFO, rc=rc) call ESMF_AttributeGet(gcomp, name="DumpRHs", value=value, defaultValue="false", & - convention="NUOPC", purpose="Instance", rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out - rhprint_flag=(trim(value)=="true") + convention="NUOPC", purpose="Instance", rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + + rhprint_flag = (trim(value)=="true") write(msgString,'(A,l6)') trim(subname)//' rhprint_flag = ',rhprint_flag call ESMF_LogWrite(trim(msgString), ESMF_LOGMSG_INFO, rc=dbrc) call ESMF_AttributeGet(gcomp, name="ProfileMemory", value=value, defaultValue="true", & - convention="NUOPC", purpose="Instance", rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out - profile_memory=(trim(value)/="false") + convention="NUOPC", purpose="Instance", rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + + profile_memory = (trim(value)/="false") write(msgString,'(A,l6)') trim(subname)//' profile_memory = ',profile_memory call ESMF_LogWrite(trim(msgString), ESMF_LOGMSG_INFO, rc=dbrc) - call ESMF_AttributeGet(gcomp, name="AoMedFlux", value=value, defaultValue="true", & - convention="NUOPC", purpose="Instance", rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out - atmocn_flux_from_atm=(trim(value)/="false") + call ESMF_AttributeGet(gcomp, name="AoMedFlux", value=value, & + defaultValue="true", convention="NUOPC", purpose="Instance", rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + atmocn_flux_from_atm = (trim(value)/="false") write(msgString,'(A,l6)') trim(subname)//' atmocn_flux_from_atm = ',atmocn_flux_from_atm call ESMF_LogWrite(trim(msgString), ESMF_LOGMSG_INFO, rc=dbrc) + ! Set clock_invalidTimeStamp call ESMF_TimeSet(time_invalidTimeStamp, yy=99999999, mm=1, dd=1, h=0, m=0, s=0, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + clock_invalidTimeStamp = ESMF_ClockCreate(clock, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call ESMF_ClockSet(clock_invalidTimeStamp, currTime=time_invalidTimeStamp, & - stopTime=time_invalidTimeStamp, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + stopTime=time_invalidTimeStamp, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return if (dbug_flag > 5) then call ESMF_LogWrite(trim(subname)//": done", ESMF_LOGMSG_INFO, rc=dbrc) @@ -1028,12 +1104,12 @@ subroutine InitializeIPDv03p1(gcomp, importState, exportState, clock, rc) ! local variables integer :: n character(len=*),parameter :: subname='(module_MEDIATOR:InitializeIPDv03p1)' - + if (dbug_flag > 5) then call ESMF_LogWrite(trim(subname)//": called", ESMF_LOGMSG_INFO, rc=dbrc) endif rc = ESMF_SUCCESS - + ! importable fields: ! add a namespace @@ -1042,6 +1118,7 @@ subroutine InitializeIPDv03p1(gcomp, importState, exportState, clock, rc) call NUOPC_AddNamespace(importState, namespace="ICE", nestedStateName="NestedState-IceImp", nestedState=NState_IceImp, rc=rc) call NUOPC_AddNamespace(importState, namespace="LND", nestedStateName="NestedState-LndImp", nestedState=NState_LndImp, rc=rc) call NUOPC_AddNamespace(importState, namespace="HYD", nestedStateName="NestedState-HydImp", nestedState=NState_HydImp, rc=rc) +! call NUOPC_AddNamespace(exportState, namespace="ATM", nestedStateName="NestedState-AtmExp", nestedState=NState_AtmExp, rc=rc) call NUOPC_AddNamespace(exportState, namespace="OCN", nestedStateName="NestedState-OcnExp", nestedState=NState_OcnExp, rc=rc) call NUOPC_AddNamespace(exportState, namespace="ICE", nestedStateName="NestedState-IceExp", nestedState=NState_IceExp, rc=rc) @@ -1051,71 +1128,66 @@ subroutine InitializeIPDv03p1(gcomp, importState, exportState, clock, rc) do n = 1,fldsFrAtm%num if (dbug_flag > 1) then call ESMF_LogWrite(trim(subname)//": FrAtm Advertise "// & - trim(fldsFrAtm%stdname(n))//":"// & - trim(fldsFrAtm%shortname(n)), ESMF_LOGMSG_INFO, rc=dbrc) + trim(fldsFrAtm%stdname(n))//":"// & + trim(fldsFrAtm%shortname(n)), ESMF_LOGMSG_INFO, rc=dbrc) endif - call NUOPC_Advertise(NState_AtmImp, & - StandardName = trim(fldsFrAtm%stdname(n)), & - name=fldsFrAtm%shortname(n), & - TransferOfferGeomObject=fldsFrAtm%transferOffer(n), rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + call NUOPC_Advertise(NState_AtmImp, & + StandardName = trim(fldsFrAtm%stdname(n)), & + name = fldsFrAtm%shortname(n), & + TransferOfferGeomObject=fldsFrAtm%transferOffer(n), rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return enddo do n = 1,fldsFrOcn%num if (dbug_flag > 1) then call ESMF_LogWrite(trim(subname)//": FrOcn Advertise "// & - trim(fldsFrOcn%stdname(n))//":"// & - trim(fldsFrOcn%shortname(n)), ESMF_LOGMSG_INFO, rc=dbrc) + trim(fldsFrOcn%stdname(n))//":"// & + trim(fldsFrOcn%shortname(n)), ESMF_LOGMSG_INFO, rc=dbrc) endif - call NUOPC_Advertise(NState_OcnImp, & - StandardName = fldsFrOcn%stdname(n), & - name = fldsFrOcn%shortname(n), & - TransferOfferGeomObject=fldsFrOcn%transferOffer(n), rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + call NUOPC_Advertise(NState_OcnImp, & + StandardName = fldsFrOcn%stdname(n), & + name = fldsFrOcn%shortname(n), & + TransferOfferGeomObject=fldsFrOcn%transferOffer(n), rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return enddo do n = 1,fldsFrIce%num if (dbug_flag > 1) then call ESMF_LogWrite(trim(subname)//": FrIce Advertise "// & - trim(fldsFrIce%stdname(n))//":"// & - trim(fldsFrIce%shortname(n)), ESMF_LOGMSG_INFO, rc=dbrc) + trim(fldsFrIce%stdname(n))//":"// & + trim(fldsFrIce%shortname(n)), ESMF_LOGMSG_INFO, rc=dbrc) endif - call NUOPC_Advertise(NState_IceImp, & - StandardName = fldsFrIce%stdname(n), & - name = fldsFrIce%shortname(n), & - TransferOfferGeomObject=fldsFrIce%transferOffer(n), rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + call NUOPC_Advertise(NState_IceImp, & + StandardName = fldsFrIce%stdname(n), & + name = fldsFrIce%shortname(n), & + TransferOfferGeomObject=fldsFrIce%transferOffer(n), rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return enddo do n = 1,fldsFrLnd%num if (dbug_flag > 1) then call ESMF_LogWrite(trim(subname)//": FrLnd Advertise "// & - trim(fldsFrLnd%stdname(n))//":"// & - trim(fldsFrLnd%shortname(n)), ESMF_LOGMSG_INFO, rc=dbrc) + trim(fldsFrLnd%stdname(n))//":"// & + trim(fldsFrLnd%shortname(n)), ESMF_LOGMSG_INFO, rc=dbrc) endif - call NUOPC_Advertise(NState_LndImp, & - StandardName = fldsFrLnd%stdname(n), & - name = fldsFrLnd%shortname(n), & - TransferOfferGeomObject=fldsFrLnd%transferOffer(n), rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + call NUOPC_Advertise(NState_LndImp, & + StandardName = fldsFrLnd%stdname(n), & + name = fldsFrLnd%shortname(n), & + TransferOfferGeomObject=fldsFrLnd%transferOffer(n), rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return enddo do n = 1,fldsFrHyd%num if (dbug_flag > 1) then call ESMF_LogWrite(trim(subname)//": FrHyd Advertise "// & - trim(fldsFrHyd%stdname(n))//":"// & - trim(fldsFrHyd%shortname(n)), ESMF_LOGMSG_INFO, rc=dbrc) + trim(fldsFrHyd%stdname(n))//":"// & + trim(fldsFrHyd%shortname(n)), ESMF_LOGMSG_INFO, rc=dbrc) endif - call NUOPC_Advertise(NState_HydImp, & - StandardName = fldsFrHyd%stdname(n), & - name = fldsFrHyd%shortname(n), & + call NUOPC_Advertise(NState_HydImp, & + StandardName = fldsFrHyd%stdname(n), & + name = fldsFrHyd%shortname(n), & TransferOfferGeomObject=fldsFrHyd%transferOffer(n), rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return enddo ! exportable fields: @@ -1123,71 +1195,66 @@ subroutine InitializeIPDv03p1(gcomp, importState, exportState, clock, rc) do n = 1,fldsToAtm%num if (dbug_flag > 1) then call ESMF_LogWrite(trim(subname)//": ToAtm Advertise "// & - trim(fldsToAtm%stdname(n))//":"// & - trim(fldsToAtm%shortname(n)), ESMF_LOGMSG_INFO, rc=dbrc) + trim(fldsToAtm%stdname(n))//":"// & + trim(fldsToAtm%shortname(n)), ESMF_LOGMSG_INFO, rc=dbrc) endif - call NUOPC_Advertise(NState_AtmExp, & - StandardName = fldsToAtm%stdname(n), & - name = fldsToAtm%shortname(n), & - TransferOfferGeomObject=fldsToAtm%transferOffer(n), rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + call NUOPC_Advertise(NState_AtmExp, & + StandardName = fldsToAtm%stdname(n), & + name = fldsToAtm%shortname(n), & + TransferOfferGeomObject=fldsToAtm%transferOffer(n), rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return enddo do n = 1,fldsToOcn%num if (dbug_flag > 1) then call ESMF_LogWrite(trim(subname)//": ToOcn Advertise "// & - trim(fldsToOcn%stdname(n))//":"// & - trim(fldsToOcn%shortname(n)), ESMF_LOGMSG_INFO, rc=dbrc) + trim(fldsToOcn%stdname(n))//":"// & + trim(fldsToOcn%shortname(n)), ESMF_LOGMSG_INFO, rc=dbrc) endif - call NUOPC_Advertise(NState_OcnExp, & - StandardName = fldsToOcn%stdname(n), & - name = fldsToOcn%shortname(n), & - TransferOfferGeomObject=fldsToOcn%transferOffer(n), rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + call NUOPC_Advertise(NState_OcnExp, & + StandardName = fldsToOcn%stdname(n), & + name = fldsToOcn%shortname(n), & + TransferOfferGeomObject=fldsToOcn%transferOffer(n), rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return enddo do n = 1,fldsToIce%num if (dbug_flag > 1) then call ESMF_LogWrite(trim(subname)//": ToIce Advertise "// & - trim(fldsToIce%stdname(n))//":"// & - trim(fldsToIce%shortname(n)), ESMF_LOGMSG_INFO, rc=dbrc) + trim(fldsToIce%stdname(n))//":"// & + trim(fldsToIce%shortname(n)), ESMF_LOGMSG_INFO, rc=dbrc) endif - call NUOPC_Advertise(NState_IceExp, & - StandardName = fldsToIce%stdname(n), & - name = fldsToIce%shortname(n), & - TransferOfferGeomObject=fldsToIce%transferOffer(n), rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + call NUOPC_Advertise(NState_IceExp, & + StandardName = fldsToIce%stdname(n), & + name = fldsToIce%shortname(n), & + TransferOfferGeomObject=fldsToIce%transferOffer(n), rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return enddo do n = 1,fldsToLnd%num if (dbug_flag > 1) then call ESMF_LogWrite(trim(subname)//": ToLnd Advertise "// & - trim(fldsToLnd%stdname(n))//":"// & - trim(fldsToLnd%shortname(n)), ESMF_LOGMSG_INFO, rc=dbrc) + trim(fldsToLnd%stdname(n))//":"// & + trim(fldsToLnd%shortname(n)), ESMF_LOGMSG_INFO, rc=dbrc) endif - call NUOPC_Advertise(NState_LndExp, & - StandardName = fldsToLnd%stdname(n), & - name = fldsToLnd%shortname(n), & - TransferOfferGeomObject=fldsToLnd%transferOffer(n), rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + call NUOPC_Advertise(NState_LndExp, & + StandardName = fldsToLnd%stdname(n), & + name = fldsToLnd%shortname(n), & + TransferOfferGeomObject=fldsToLnd%transferOffer(n), rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return enddo do n = 1,fldsToHyd%num if (dbug_flag > 1) then call ESMF_LogWrite(trim(subname)//": ToHyd Advertise "// & - trim(fldsToHyd%stdname(n))//":"// & - trim(fldsToHyd%shortname(n)), ESMF_LOGMSG_INFO, rc=dbrc) + trim(fldsToHyd%stdname(n))//":"// & + trim(fldsToHyd%shortname(n)), ESMF_LOGMSG_INFO, rc=dbrc) endif - call NUOPC_Advertise(NState_HydExp, & - StandardName = fldsToHyd%stdname(n), & - name = fldsToHyd%shortname(n), & - TransferOfferGeomObject=fldsToHyd%transferOffer(n), rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + call NUOPC_Advertise(NState_HydExp, & + StandardName = fldsToHyd%stdname(n), & + name = fldsToHyd%shortname(n), & + TransferOfferGeomObject=fldsToHyd%transferOffer(n), rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return enddo if (dbug_flag > 5) then @@ -1195,7 +1262,7 @@ subroutine InitializeIPDv03p1(gcomp, importState, exportState, clock, rc) endif end subroutine InitializeIPDv03p1 - + !----------------------------------------------------------------------------- subroutine InitializeIPDv03p3(gcomp, importState, exportState, clock, rc) @@ -1203,7 +1270,7 @@ subroutine InitializeIPDv03p3(gcomp, importState, exportState, clock, rc) type(ESMF_State) :: importState, exportState type(ESMF_Clock) :: clock integer, intent(out) :: rc - + ! local variables integer :: i, j real(kind=ESMF_KIND_R8),pointer :: lonPtr(:,:), latPtr(:,:) @@ -1213,48 +1280,43 @@ subroutine InitializeIPDv03p3(gcomp, importState, exportState, clock, rc) type(ESMF_TimeInterval) :: timeStep character(ESMF_MAXSTR) :: transferAction ! tcx XGrid -! type(ESMF_Field) :: fieldX, fieldA, fieldO -! type(ESMF_XGrid) :: xgrid - character(len=*),parameter :: subname='(module_MEDIATOR:InitializeIPDv03p3)' - +! type(ESMF_Field) :: fieldX, fieldA, fieldO +! type(ESMF_XGrid) :: xgrid + character(len=*),parameter :: subname='(module_MEDIATOR:InitializeIPDv03p3)' + if (dbug_flag > 5) then call ESMF_LogWrite(trim(subname)//": called", ESMF_LOGMSG_INFO, rc=dbrc) endif rc = ESMF_SUCCESS - + ! Allocate memory for the internal state and set it in the Component. allocate(is_local%wrap, stat=stat) - if (ESMF_LogFoundAllocError(statusToCheck=stat, & - msg="Allocation of the internal state memory failed.", & - line=__LINE__, & - file=__FILE__)) & - return ! bail out + if (ESMF_LogFoundAllocError(statusToCheck=stat, & + msg="Allocation of the internal state memory failed.", & + line=__LINE__, file=__FILE__)) return + call ESMF_GridCompSetInternalState(gcomp, is_local, rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out - + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + ! Initialize the internal state members is_local%wrap%fastcntr = 1 is_local%wrap%slowcntr = 1 - gridMed = ESMF_GridCreate1PeriDimUfrm(maxIndex=(/nx_med,ny_med/), & - minCornerCoord=(/0._ESMF_KIND_R8, -85._ESMF_KIND_R8/), & - maxCornerCoord=(/360._ESMF_KIND_R8, 85._ESMF_KIND_R8/), & - staggerLocList=(/ESMF_STAGGERLOC_CENTER/), rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + gridMed = ESMF_GridCreate1PeriDimUfrm(maxIndex=(/nx_med,ny_med/), & + minCornerCoord = (/0._ESMF_KIND_R8, -85._ESMF_KIND_R8/), & + maxCornerCoord = (/360._ESMF_KIND_R8, 85._ESMF_KIND_R8/), & + staggerLocList = (/ESMF_STAGGERLOC_CENTER/), rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return ! gridLnd = NUOPC_GridCreateSimpleSph(0._ESMF_KIND_R8, -85._ESMF_KIND_R8, & -! 360._ESMF_KIND_R8, 85._ESMF_KIND_R8, nx_med, ny_med, & -! scheme=ESMF_REGRID_SCHEME_FULL3D, rc=rc) -! if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & -! line=__LINE__, file=__FILE__)) return ! bail out +! 360._ESMF_KIND_R8, 85._ESMF_KIND_R8, nx_med, ny_med, & +! scheme=ESMF_REGRID_SCHEME_FULL3D, rc=rc) +! if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return ! gridHyd = NUOPC_GridCreateSimpleSph(0._ESMF_KIND_R8, -85._ESMF_KIND_R8, & -! 360._ESMF_KIND_R8, 85._ESMF_KIND_R8, nx_med, ny_med, & -! scheme=ESMF_REGRID_SCHEME_FULL3D, rc=rc) -! if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & -! line=__LINE__, file=__FILE__)) return ! bail out +! 360._ESMF_KIND_R8, 85._ESMF_KIND_R8, nx_med, ny_med, & +! scheme=ESMF_REGRID_SCHEME_FULL3D, rc=rc) +! if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return !--- Generate RouteHandles ! tcx Xgrid @@ -1262,8 +1324,7 @@ subroutine InitializeIPDv03p3(gcomp, importState, exportState, clock, rc) ! add error checking code ! xgrid = ESMF_XGridCreate(sideAGrid=(/gridatm/), sideBGrid=(/gridocn/), rc=rc) -! if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & -! line=__LINE__, file=__FILE__)) return ! bail out +! if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return ! fieldX = ESMF_FieldCreate(xgrid , typekind=ESMF_TYPEKIND_R8, rc=rc) ! fieldA = ESMF_FieldCreate(gridAtm, typekind=ESMF_TYPEKIND_R8, rc=rc) ! fieldO = ESMF_FieldCreate(gridAtm, typekind=ESMF_TYPEKIND_R8, rc=rc) @@ -1280,99 +1341,87 @@ subroutine InitializeIPDv03p3(gcomp, importState, exportState, clock, rc) !gjt: import fields from ATM are now marked as "cannot provide" thus accept Grid !gjt: -> eventually comment out the following lines... - call realizeConnectedFields(NState_AtmImp, & - fieldNameList=fldsFrAtm%shortname(1:fldsFrAtm%num), & - string='AtmImp',rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + call realizeConnectedFields(NState_AtmImp, & + fieldNameList=fldsFrAtm%shortname(1:fldsFrAtm%num), & + string='AtmImp',rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return !--- Exportable fields to atm: - call realizeConnectedFields(NState_AtmExp, & - fieldNameList=fldsToAtm%shortname(1:fldsToAtm%num), & - string='AtmExp',rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + call realizeConnectedFields(NState_AtmExp, & + fieldNameList=fldsToAtm%shortname(1:fldsToAtm%num), & + string='AtmExp',rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return !--- Importable fields from ocn: - call realizeConnectedFields(NState_OcnImp, & - fieldNameList=fldsFrOcn%shortname(1:fldsFrOcn%num), & - string='OcnImp',rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + call realizeConnectedFields(NState_OcnImp, & + fieldNameList=fldsFrOcn%shortname(1:fldsFrOcn%num), & + string='OcnImp',rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return !--- Exportable fields to ocn: - call realizeConnectedFields(NState_OcnExp, & - fieldNameList=fldsToOcn%shortname(1:fldsToOcn%num), & - string='OcnExp',rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + call realizeConnectedFields(NState_OcnExp, & + fieldNameList=fldsToOcn%shortname(1:fldsToOcn%num), & + string='OcnExp',rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return !--- Importable fields from ice: - call realizeConnectedFields(NState_IceImp, & - fieldNameList=fldsFrIce%shortname(1:fldsFrIce%num), & - string='IceImp',rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + call realizeConnectedFields(NState_IceImp, & + fieldNameList=fldsFrIce%shortname(1:fldsFrIce%num), & + string='IceImp',rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return !--- Exportable fields to ice: - call realizeConnectedFields(NState_IceExp, & - fieldNameList=fldsToIce%shortname(1:fldsToIce%num), & - string='IceExp',rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + call realizeConnectedFields(NState_IceExp, & + fieldNameList=fldsToIce%shortname(1:fldsToIce%num), & + string='IceExp',rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return !--- Importable fields from lnd: - call realizeConnectedFields(NState_LndImp, & - fieldNameList=fldsFrLnd%shortname(1:fldsFrLnd%num), & - string='LndImp',rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + call realizeConnectedFields(NState_LndImp, & + fieldNameList=fldsFrLnd%shortname(1:fldsFrLnd%num), & + string='LndImp',rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return !--- Exportable fields to lnd: - call realizeConnectedFields(NState_LndExp, & - fieldNameList=fldsToLnd%shortname(1:fldsToLnd%num), & - string='LndExp',rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + call realizeConnectedFields(NState_LndExp, & + fieldNameList=fldsToLnd%shortname(1:fldsToLnd%num), & + string='LndExp',rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return !--- Importable fields from hyd: - call realizeConnectedFields(NState_HydImp, & - fieldNameList=fldsFrHyd%shortname(1:fldsFrHyd%num), & - string='HydImp',rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + call realizeConnectedFields(NState_HydImp, & + fieldNameList=fldsFrHyd%shortname(1:fldsFrHyd%num), & + string='HydImp',rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return !--- Exportable fields to hyd: - call realizeConnectedFields(NState_HydExp, & - fieldNameList=fldsToHyd%shortname(1:fldsToHyd%num), & - string='HydExp',rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + call realizeConnectedFields(NState_HydExp, & + fieldNameList=fldsToHyd%shortname(1:fldsToHyd%num), & + string='HydExp',rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return ! Clean Up ! call ESMF_GridDestroy(gridAtm, rc=rc) -! if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & -! line=__LINE__, file=__FILE__)) return ! bail out +! if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return ! call ESMF_GridDestroy(gridOcn, rc=rc) -! if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & -! line=__LINE__, file=__FILE__)) return ! bail out - +! if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + if (dbug_flag > 5) then call ESMF_LogWrite(trim(subname)//": done", ESMF_LOGMSG_INFO, rc=dbrc) endif contains !- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + subroutine realizeConnectedFields(state, fieldNameList, grid, string, rc) type(ESMF_State) :: state character(len=*) :: fieldNameList(:) @@ -1388,17 +1437,16 @@ subroutine realizeConnectedFields(state, fieldNameList, grid, string, rc) call ESMF_LogWrite(trim(subname)//": called", ESMF_LOGMSG_INFO, rc=dbrc) endif rc = ESMF_SUCCESS - + do n=1, size(fieldNameList) if (NUOPC_IsConnected(state, fieldName=fieldNameList(n))) then call ESMF_StateGet(state, field=field, itemName=fieldNameList(n), rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call NUOPC_GetAttribute(field, name="TransferActionGeomObject", & - value=transferAction, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + value=transferAction, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return if (trim(transferAction) == "accept") then call ESMF_LogWrite(trim(subname)//trim(string)//" field+grid connected "//trim(fieldNameList(n)), ESMF_LOGMSG_INFO, rc=dbrc) @@ -1413,17 +1461,15 @@ subroutine realizeConnectedFields(state, fieldNameList, grid, string, rc) return endif field = ESMF_FieldCreate(grid, ESMF_TYPEKIND_R8, name=fieldNameList(n),rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return call NUOPC_Realize(state, field=field, rc=rc) call ESMF_LogWrite(trim(subname)//trim(string)//" field connected "//trim(fieldNameList(n)), ESMF_LOGMSG_INFO, rc=dbrc) #else call NUOPC_SetAttribute(field, name="TransferActionGeomObject", & - value="accept-internal", rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out - + value="accept-internal", rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + #endif endif ! transferAction @@ -1432,8 +1478,7 @@ subroutine realizeConnectedFields(state, fieldNameList, grid, string, rc) ! remove a not connected Field from State call ESMF_StateRemove(state, (/fieldNameList(n)/), rc=rc) call ESMF_LogWrite(trim(subname)//trim(string)//" field NOT connected "//trim(fieldNameList(n)), ESMF_LOGMSG_INFO, rc=dbrc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return endif enddo if (dbug_flag > 5) then @@ -1443,7 +1488,7 @@ subroutine realizeConnectedFields(state, fieldNameList, grid, string, rc) end subroutine realizeConnectedFields end subroutine InitializeIPDv03p3 - + !----------------------------------------------------------------------------- !----------------------------------------------------------------------------- @@ -1453,67 +1498,44 @@ subroutine InitializeIPDv03p4(gcomp, importState, exportState, clock, rc) type(ESMF_State) :: importState, exportState type(ESMF_Clock) :: clock integer, intent(out) :: rc - - ! local variables -! type(ESMF_Field) :: field -! type(ESMF_Grid) :: grid -! integer :: localDeCount - -! type(ESMF_DistGrid) :: distgrid -! integer :: dimCount, tileCount, petCount -! integer :: deCountPTile, extraDEs -! integer, allocatable :: minIndexPTile(:,:), maxIndexPTile(:,:) -! integer, allocatable :: regDecompPTile(:,:) -! integer :: i, j, n, n1 -! character(ESMF_MAXSTR) :: transferAction - + character(len=*),parameter :: subname='(module_MEDIATOR:InitializeIPDv03p4)' if (dbug_flag > 5) then call ESMF_LogWrite(trim(subname)//": called", ESMF_LOGMSG_INFO, rc=dbrc) endif - + rc = ESMF_SUCCESS call realizeConnectedGrid(NState_atmImp, 'AtmImp', rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return call realizeConnectedGrid(NState_atmExp, 'AtmExp', rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return call realizeConnectedGrid(NState_ocnImp, 'OcnImp', rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return call realizeConnectedGrid(NState_ocnExp, 'OcnExp', rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return call realizeConnectedGrid(NState_iceImp, 'IceImp', rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return call realizeConnectedGrid(NState_iceExp, 'IceExp', rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return call realizeConnectedGrid(NState_lndImp, 'LndImp', rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return call realizeConnectedGrid(NState_lndExp, 'LndExp', rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return call realizeConnectedGrid(NState_hydImp, 'HydImp', rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return call realizeConnectedGrid(NState_hydExp, 'HydExp', rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return if (dbug_flag > 5) then call ESMF_LogWrite(trim(subname)//": done", ESMF_LOGMSG_INFO, rc=dbrc) @@ -1526,7 +1548,7 @@ subroutine realizeConnectedGrid(State,string,rc) type(ESMF_State) , intent(inout) :: State character(len=*) , intent(in) :: string integer , intent(out) :: rc - + ! local variables type(ESMF_Field) :: field type(ESMF_Grid) :: grid @@ -1541,8 +1563,8 @@ subroutine realizeConnectedGrid(State,string,rc) integer :: i, j, n, n1, fieldCount, nxg character(ESMF_MAXSTR),allocatable :: fieldNameList(:) character(ESMF_MAXSTR) :: transferAction - character(len=*),parameter :: subname='(module_MEDIATOR:realizeConnectedGrid)' - + character(len=*), parameter :: subname='(module_MEDIATOR:realizeConnectedGrid)' + !NOTE: All of the Fields that set their TransferOfferGeomObject Attribute !NOTE: to "cannot provide" should now have the accepted Grid available. !NOTE: Go and pull out this Grid for one of a representative Field and @@ -1558,80 +1580,69 @@ subroutine realizeConnectedGrid(State,string,rc) rc = ESMF_Success call ESMF_GridCompGet(gcomp, petCount=petCount, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return call ESMF_StateGet(State, itemCount=fieldCount, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return allocate(fieldNameList(fieldCount)) call ESMF_StateGet(State, itemNameList=fieldNameList, & - itemorderflag=ESMF_ITEMORDER_ADDORDER, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + itemorderflag=ESMF_ITEMORDER_ADDORDER, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return do n=1, fieldCount !tcx do n=1, 1 call ESMF_StateGet(State, field=field, itemName=fieldNameList(n), rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return call NUOPC_GetAttribute(field, name="TransferActionGeomObject", & - value=transferAction, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + value=transferAction, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return if (trim(transferAction) == "accept") then if (dbug_flag > 1) then call ESMF_LogWrite(trim(subname)//trim(string)//": accept grid for "//trim(fieldNameList(n)), ESMF_LOGMSG_INFO, rc=dbrc) endif - + ! this is still an empty field, but holds a Grid with DistGrid call ESMF_FieldGet(field, grid=grid, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return ! diagnostic print call Grid_Print(grid,trim(fieldNameList(n))//'_orig',rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return ! access the DistGrid inside the Grid call ESMF_GridGet(grid, distgrid=distgrid, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out - + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + ! Create a custom DistGrid, based on the minIndex, maxIndex of the ! accepted DistGrid, but with a default regDecomp for the current VM ! that leads to 1DE/PET. - + ! get dimCount and tileCount call ESMF_DistGridGet(distgrid, dimCount=dimCount, tileCount=tileCount, & - connectionCount=connectionCount, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + connectionCount=connectionCount, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return ! allocate minIndexPTile and maxIndexPTile accord. to dimCount and tileCount allocate(minIndexPTile(dimCount, tileCount), & maxIndexPTile(dimCount, tileCount)) allocate(connectionList(connectionCount)) - + ! get minIndex and maxIndex arrays, and connectionList call ESMF_DistGridGet(distgrid, minIndexPTile=minIndexPTile, & - maxIndexPTile=maxIndexPTile, connectionList=connectionList, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out - + maxIndexPTile=maxIndexPTile, connectionList=connectionList, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + #if ESMF_VERSION_MAJOR >= 8 if (petCount/tileCount * tileCount == petCount) then ! petCount is a multiple of tileCount: ! determine a "most square" factorization of the available petCount ! for each tile in dimCount dims allocate(regDecomp(dimCount)) - call ESMF_DistGridRegDecompSetCubic(regDecomp, & - deCount=petCount/tileCount, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + call ESMF_DistGridRegDecompSetCubic(regDecomp, deCount=petCount/tileCount, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + allocate(regDecompPTile(dimCount,tileCount)) do i=1, tileCount regDecompPTile(:,i) = regDecomp(:) @@ -1639,11 +1650,10 @@ subroutine realizeConnectedGrid(State,string,rc) ! create the new DistGrid with the same minIndexPTile and ! maxIndexPTile, but with most square regDecompPTile for the ! local petCount - distgrid = ESMF_DistGridCreate(minIndexPTile=minIndexPTile, & - maxIndexPTile=maxIndexPTile, connectionList=connectionList, & - regDecompPTile=regDecompPTile, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + distgrid = ESMF_DistGridCreate(minIndexPTile=minIndexPTile, & + maxIndexPTile=maxIndexPTile, connectionList=connectionList, & + regDecompPTile=regDecompPTile, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return deallocate(regDecomp, regDecompPTile) else #endif @@ -1651,60 +1661,51 @@ subroutine realizeConnectedGrid(State,string,rc) ! create the new DistGrid with the same minIndexPTile and ! maxIndexPTile, but with default multi-tile regDecomp: 1DE/PET distgrid = ESMF_DistGridCreate(minIndexPTile=minIndexPTile, & - maxIndexPTile=maxIndexPTile, connectionList=connectionList, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + maxIndexPTile=maxIndexPTile, connectionList=connectionList, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return #if ESMF_VERSION_MAJOR >= 8 endif #endif if (dbug_flag > 1) then call ESMF_LogWrite(trim(subname)//trim(string)//': distgrid with connlist', ESMF_LOGMSG_INFO, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return endif - + ! local clean-up deallocate(minIndexPTile, maxIndexPTile, connectionList) ! Create a new Grid on the new DistGrid and swap it in the Field - grid = ESMF_GridCreate(distgrid, & - gridEdgeLWidth=(/0,0/), gridEdgeUWidth=(/0,1/), rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + grid = ESMF_GridCreate(distgrid, & + gridEdgeLWidth=(/0,0/), gridEdgeUWidth=(/0,1/), rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return ! check to ensure 1DE/PET condition is satisfied call ESMF_GridGet(grid, localDeCount=localDeCount, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return if (localDeCount /= 1) then call ESMF_LogSetError(ESMF_RC_INTNRL_BAD, & msg=SUBNAME//": Violation of 1 DE/PET condition in the Mediator",& line=__LINE__, file=__FILE__, rcToReturn=rc) - return ! bail out + return endif - ! Swap all the Grids in the State - -!tcx do n1=1, fieldCount - do n1=n,n + +!tcx do n1=1, fieldCount +! do n1=n,n + n1 = n ! access a field in the importState and set the Grid - call ESMF_StateGet(State, field=field, & - itemName=fieldNameList(n1), rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out - call ESMF_FieldEmptySet(field, grid=grid, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + call ESMF_StateGet(State, field=field, itemName=fieldNameList(n1), rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call ESMF_FieldEmptySet(field, grid=grid, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return if (dbug_flag > 1) then call ESMF_LogWrite(trim(subname)//trim(string)//": attach grid for "//trim(fieldNameList(n1)), ESMF_LOGMSG_INFO, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return endif call Grid_print(grid,trim(fieldNameList(n))//'_new',rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out - enddo + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return +! enddo else @@ -1723,7 +1724,7 @@ subroutine realizeConnectedGrid(State,string,rc) end subroutine realizeConnectedGrid end subroutine InitializeIPDv03p4 - + !----------------------------------------------------------------------------- subroutine InitializeIPDv03p5(gcomp, importState, exportState, clock, rc) @@ -1733,140 +1734,147 @@ subroutine InitializeIPDv03p5(gcomp, importState, exportState, clock, rc) integer, intent(out) :: rc ! local variables - type(ESMF_Field) :: field, field1, field2 - type(ESMF_Field) :: fieldArea - type(ESMF_Grid) :: grid - type(InternalState) :: is_local - integer :: fieldCount - real(ESMF_KIND_R8), pointer :: factorList(:) - character(ESMF_MAXSTR) :: name + type(ESMF_Field) :: field, field1, field2 + type(ESMF_Field) :: fieldArea + type(ESMF_Grid) :: grid + type(ESMF_VM) :: vm + type(InternalState) :: is_local + integer :: fieldCount + real(ESMF_KIND_R8), pointer :: factorList(:) + character(ESMF_MAXSTR) :: name character(ESMF_MAXSTR) ,pointer :: fieldNameList(:) - integer :: i,j - type(ESMF_Field) :: fieldAtm, fieldOcn - type(ESMF_Array) :: arrayOcn, arrayIce - type(ESMF_RouteHandle) :: RH_mapmask ! unmasked conservative remapping - type(ESMF_Grid) :: gridAtmCoord, gridOcnCoord - integer(ESMF_KIND_I4), pointer :: dataPtr_arrayOcn(:,:), dataPtr_arrayIce(:,:) - integer(ESMF_KIND_I4), pointer :: dataPtr_arrayAtm(:,:) - real(ESMF_KIND_R8), pointer :: dataPtr_fieldOcn(:,:), dataPtr_fieldAtm(:,:) - logical :: isPresentOcn, isPresentIce - character(len=*),parameter :: subname='(module_MEDIATOR:InitializeIPDv03p5)' + integer :: i,j + type(ESMF_Field) :: fieldAtmMask, fieldOcnMask + type(ESMF_Array) :: arrayOcn, arrayIce + type(ESMF_RouteHandle) :: RH_mapmask ! unmasked conservative remapping + type(ESMF_Grid) :: gridAtmCoord, gridOcnCoord + integer(ESMF_KIND_I4), pointer :: dataPtr_arrayOcn(:,:), dataPtr_arrayIce(:,:) + integer(ESMF_KIND_I4), pointer :: dataPtr_arrayAtm(:,:) + real(ESMF_KIND_R8), pointer :: dataPtr_fieldOcn(:,:), dataPtr_fieldAtm(:,:) + logical :: isPresentOcn, isPresentIce + character(len=*),parameter :: subname='(module_MEDIATOR:InitializeIPDv03p5)' + integer :: localPet + type(ESMF_GridComp) :: IOComp if (dbug_flag > 5) then call ESMF_LogWrite(trim(subname)//": called", ESMF_LOGMSG_INFO, rc=dbrc) endif - + rc = ESMF_SUCCESS + ! Get the internal state from Component. + ! ------------------------------------- + nullify(is_local%wrap) + call ESMF_GridCompGetInternalState(gcomp, is_local, rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + + call ESMF_GridCompGet(gcomp, vm=vm, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__,file=__FILE__)) return + + call ESMF_VMGet(vm, localPet=localPet, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__,file=__FILE__)) return !---------------------------------------------------------- !--- Finish initializing the State Fields !---------------------------------------------------------- call completeFieldInitialization(NState_atmImp, rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call state_reset(NState_atmImp, value=spval_init, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return call completeFieldInitialization(NState_atmExp, rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call state_reset(NState_atmExp, value=spval_init, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return call completeFieldInitialization(NState_ocnImp, rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out - call state_reset(NState_ocnImp, value=spval_init, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + + call state_reset(NState_ocnImp, value=spval_init, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return call completeFieldInitialization(NState_ocnExp, rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call state_reset(NState_ocnExp, value=spval_init, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return call completeFieldInitialization(NState_iceImp, rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call state_reset(NState_iceImp, value=spval_init, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return call completeFieldInitialization(NState_iceExp, rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call state_reset(NState_iceExp, value=spval_init, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return call completeFieldInitialization(NState_lndImp, rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call state_reset(NState_lndImp, value=spval_init, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return call completeFieldInitialization(NState_lndExp, rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call state_reset(NState_lndExp, value=spval_init, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return call completeFieldInitialization(NState_hydImp, rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call state_reset(NState_hydImp, value=spval_init, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return call completeFieldInitialization(NState_hydExp, rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call state_reset(NState_hydExp, value=spval_init, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return !---------------------------------------------------------- !--- Set the model grids using first field in each model's import state !---------------------------------------------------------- + is_local%wrap%atm_active = .false. + is_local%wrap%lnd_active = .false. + is_local%wrap%ocn_active = .false. + is_local%wrap%ice_active = .false. + is_local%wrap%hyd_active = .false. + !tcraig old version -! call ESMF_StateGet(NState_atmImp, field=field, itemName=fldsFrAtm%shortname(1), rc=rc) -! if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & -! line=__LINE__, file=__FILE__)) return ! bail out +! call ESMF_StateGet(NState_atmImp, field=field, itemName=fldsFrAtm%shortname(1), rc=rc) +! if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return -! call ESMF_FieldGet(field, grid=gridAtm, rc=rc) -! if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & -! line=__LINE__, file=__FILE__)) return ! bail out +! call ESMF_FieldGet(field, grid=gridAtm, rc=rc) +! if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return -! call ESMF_StateGet(NState_ocnImp, field=field, itemName=fldsFrOcn%shortname(1), rc=rc) -! if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & -! line=__LINE__, file=__FILE__)) return ! bail out +! call ESMF_StateGet(NState_ocnImp, field=field, itemName=fldsFrOcn%shortname(1), rc=rc) +! if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return -! call ESMF_FieldGet(field, grid=gridOcn, rc=rc) -! if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & -! line=__LINE__, file=__FILE__)) return ! bail out +! call ESMF_FieldGet(field, grid=gridOcn, rc=rc) +! if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return call ESMF_StateGet(NState_atmImp, itemCount=fieldCount, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + if (fieldCount > 0) then + is_local%wrap%atm_active = .true. allocate(fieldNameList(fieldCount)) call ESMF_StateGet(NState_atmImp, itemNameList=fieldNameList, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call ESMF_StateGet(NState_atmImp, field=field, itemName=fieldNameList(1), rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call ESMF_FieldGet(field, grid=gridAtm, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + deallocate(fieldNameList) !jwtest @@ -1880,38 +1888,40 @@ subroutine InitializeIPDv03p5(gcomp, importState, exportState, clock, rc) endif call ESMF_StateGet(NState_ocnImp, itemCount=fieldCount, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + if (fieldCount > 0) then + is_local%wrap%ocn_active = .true. allocate(fieldNameList(fieldCount)) call ESMF_StateGet(NState_ocnImp, itemNameList=fieldNameList, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call ESMF_StateGet(NState_ocnImp, field=field, itemName=fieldNameList(1), rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call ESMF_FieldGet(field, grid=gridOcn, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + deallocate(fieldNameList) else gridOcn = gridMed endif call ESMF_StateGet(NState_iceImp, itemCount=fieldCount, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + if (fieldCount > 0) then + is_local%wrap%ice_active = .true. allocate(fieldNameList(fieldCount)) call ESMF_StateGet(NState_iceImp, itemNameList=fieldNameList, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call ESMF_StateGet(NState_iceImp, field=field, itemName=fieldNameList(1), rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call ESMF_FieldGet(field, grid=gridIce, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + deallocate(fieldNameList) else gridIce = gridMed @@ -1920,48 +1930,47 @@ subroutine InitializeIPDv03p5(gcomp, importState, exportState, clock, rc) ! Land will pick up the grid from the first field exported to Land call ESMF_StateGet(NState_lndExp, itemCount=fieldCount, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + if (fieldCount > 0) then + is_local%wrap%lnd_active = .true. allocate(fieldNameList(fieldCount)) call ESMF_StateGet(NState_lndExp, itemNameList=fieldNameList, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call ESMF_StateGet(NState_lndExp, field=field, itemName=fieldNameList(1), rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call ESMF_FieldGet(field, grid=gridLnd, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return call ESMF_GridGetCoord(gridLnd, staggerloc=ESMF_STAGGERLOC_CENTER, & - isPresent=isPresent,rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + isPresent=isPresent,rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + if (.NOT. isPresent) then call NEMS_GridCopyCoord(gridcomp=gcomp, gridSrc=gridAtm, gridDst=gridLnd, & - staggerloc=(/ESMF_STAGGERLOC_CENTER/), invert=(/2/), rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + staggerloc=(/ESMF_STAGGERLOC_CENTER/), invert=(/2/), rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call ESMF_LogWrite(trim(subname)// & ": Copied gridATM center coordinates to gridLnd", ESMF_LOGMSG_INFO, rc=dbrc) endif call ESMF_GridGetCoord(gridLnd, staggerloc=ESMF_STAGGERLOC_CORNER, & - isPresent=isPresent,rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + isPresent=isPresent,rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + if (.NOT. isPresent) then call NEMS_GridCopyCoord(gridcomp=gcomp, gridSrc=gridAtm, gridDst=gridLnd, & - staggerloc=(/ESMF_STAGGERLOC_CENTER, ESMF_STAGGERLOC_CORNER/), invert=(/2/), rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + staggerloc=(/ESMF_STAGGERLOC_CENTER, ESMF_STAGGERLOC_CORNER/), invert=(/2/), rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return call ESMF_LogWrite(trim(subname)// & ": Copied gridATM center and corner coordinates to gridLnd", ESMF_LOGMSG_INFO, rc=dbrc) + call NEMS_GridCopyItem(gridcomp=gcomp, gridSrc=gridAtm, gridDst=gridLnd, & - item=(/ESMF_GRIDITEM_AREA/), rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + item=(/ESMF_GRIDITEM_AREA/), rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return call ESMF_LogWrite(trim(subname)// & ": Copied gridATM areas to gridLnd", ESMF_LOGMSG_INFO, rc=dbrc) endif @@ -1973,19 +1982,18 @@ subroutine InitializeIPDv03p5(gcomp, importState, exportState, clock, rc) ! Hydro will pick up the grid from the first field exported to Hydro call ESMF_StateGet(NState_hydExp, itemCount=fieldCount, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return if (fieldCount > 0) then + is_local%wrap%hyd_active = .true. allocate(fieldNameList(fieldCount)) call ESMF_StateGet(NState_hydExp, itemNameList=fieldNameList, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call ESMF_StateGet(NState_hydExp, field=field, itemName=fieldNameList(1), rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call ESMF_FieldGet(field, grid=gridHyd, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return deallocate(fieldNameList) else gridHyd = gridMed @@ -1993,10 +2001,13 @@ subroutine InitializeIPDv03p5(gcomp, importState, exportState, clock, rc) !BL2017 !--- land mask + isPresentOcn = .false. + isPresentIce = .false. if (generate_landmask) then call ESMF_GridGetItem(gridOcn, itemflag=ESMF_GRIDITEM_MASK, staggerLoc=ESMF_STAGGERLOC_CENTER, isPresent=isPresentOcn, rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call ESMF_GridGetItem(gridIce, itemflag=ESMF_GRIDITEM_MASK, staggerLoc=ESMF_STAGGERLOC_CENTER, isPresent=isPresentIce, rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return @@ -2008,10 +2019,13 @@ subroutine InitializeIPDv03p5(gcomp, importState, exportState, clock, rc) call ESMF_GridGetItem(gridOcn, staggerLoc=ESMF_STAGGERLOC_CENTER, itemflag=ESMF_GRIDITEM_MASK, array=arrayOcn, rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call ESMF_GridGetItem(gridOcn, staggerLoc=ESMF_STAGGERLOC_CENTER, itemflag=ESMF_GRIDITEM_MASK, farrayPtr=dataPtr_arrayOcn, rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call ESMF_ArraySet(arrayOcn, name="ocean_mask", rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + write (msgString,*) trim(subname)//"ocn_mask raw = ",minval(dataPtr_arrayOcn),maxval(dataPtr_arrayOcn) call ESMF_LogWrite(msgString, ESMF_LOGMSG_INFO, rc=rc) call ESMF_ArrayWrite(arrayOcn, 'field_med_ocn_a_ocean_mask.nc', rc=rc) @@ -2021,12 +2035,16 @@ subroutine InitializeIPDv03p5(gcomp, importState, exportState, clock, rc) call ESMF_GridGetItem(gridIce, staggerLoc=ESMF_STAGGERLOC_CENTER, itemflag=ESMF_GRIDITEM_MASK, array=arrayIce, rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call ESMF_GridGetItem(gridIce, staggerLoc=ESMF_STAGGERLOC_CENTER, itemflag=ESMF_GRIDITEM_MASK, farrayPtr=dataPtr_arrayIce, rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call ESMF_ArraySet(arrayIce, name="ice_mask", rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + write (msgString,*) trim(subname)//"ice_mask raw = ",minval(dataPtr_arrayIce),maxval(dataPtr_arrayIce) call ESMF_LogWrite(msgString, ESMF_LOGMSG_INFO, rc=rc) + call ESMF_ArrayWrite(arrayIce, 'field_med_ocn_a_ice_mask.nc', rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return @@ -2035,9 +2053,11 @@ subroutine InitializeIPDv03p5(gcomp, importState, exportState, clock, rc) call Grid_CreateCoords(gridOcnCoord, gridOcn, rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return - fieldOcn = ESMF_FieldCreate(gridOcnCoord, ESMF_TYPEKIND_R8, name='ocnice_mask', rc=rc) + + fieldOcnMask = ESMF_FieldCreate(gridOcnCoord, ESMF_TYPEKIND_R8, name='ocnice_mask', rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return - call ESMF_FieldGet(fieldOcn, farrayPtr=dataPtr_fieldOcn, rc=rc) + + call ESMF_FieldGet(fieldOcnMask, farrayPtr=dataPtr_fieldOcn, rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return ! generate atm grid with just coords, no mask or area @@ -2045,41 +2065,44 @@ subroutine InitializeIPDv03p5(gcomp, importState, exportState, clock, rc) call Grid_CreateCoords(gridAtmCoord, gridAtm, rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return - fieldAtm = ESMF_FieldCreate(gridAtmCoord, ESMF_TYPEKIND_R8, name='land_mask', rc=rc) + + fieldAtmMask = ESMF_FieldCreate(gridAtmCoord, ESMF_TYPEKIND_R8, name='land_mask', rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return - call ESMF_FieldGet(fieldAtm, farrayPtr=dataPtr_FieldAtm, rc=rc) + + call ESMF_FieldGet(fieldAtmMask, farrayPtr=dataPtr_FieldAtm, rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return ! Here, the ocean/ice mask is the intersection of ocean and ice masks, which are integer fields of 0 or 1 ! Convert to real and make sure values are only 0 or 1. +!$omp parallel do default(shared) private(i,j) do j = lbound(dataPtr_fieldOcn,2),ubound(dataPtr_fieldOcn,2) - do i = lbound(dataPtr_fieldOcn,1),ubound(dataPtr_fieldOcn,1) - dataPtr_fieldOcn(i,j) = min(dataPtr_arrayIce(i,j),dataPtr_arrayOcn(i,j)) - if (dataPtr_fieldOcn(i,j) < 0.50_ESMF_KIND_R8) then - dataPtr_fieldOcn(i,j) = 0.0_ESMF_KIND_R8 - else - dataPtr_fieldOcn(i,j) = 1.0_ESMF_KIND_R8 - endif - enddo + do i = lbound(dataPtr_fieldOcn,1),ubound(dataPtr_fieldOcn,1) + dataPtr_fieldOcn(i,j) = min(dataPtr_arrayIce(i,j), dataPtr_arrayOcn(i,j)) + if (dataPtr_fieldOcn(i,j) < chalf) then + dataPtr_fieldOcn(i,j) = czero + else + dataPtr_fieldOcn(i,j) = cone + endif + enddo enddo ! generate a new RH from Atm and Ocn coords, no masks, no areas. Should not use o2a_consd mapping ! because it has masks and area corrections. - call ESMF_FieldRegridStore(fieldOcn, fieldAtm, routehandle=RH_mapmask, & - regridmethod=ESMF_REGRIDMETHOD_CONSERVE, & - srcTermProcessing=srcTermProcessing_Value, & - ignoreDegenerate=.true., & - unmappedaction=ESMF_UNMAPPEDACTION_IGNORE, rc=rc) + call ESMF_FieldRegridStore(fieldOcnMask, fieldAtmMask, routehandle=RH_mapmask,& + regridmethod=ESMF_REGRIDMETHOD_CONSERVE, & + srcTermProcessing=srcTermProcessing_Value, & + ignoreDegenerate=.true., & + unmappedaction=ESMF_UNMAPPEDACTION_IGNORE, rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return ! regrid ocean mask from ocn to atm grid using unmasked conservative mapping if (ESMF_RouteHandleIsCreated(RH_mapmask, rc=rc)) then - dataPtr_fieldAtm = 0.0_ESMF_KIND_R8 - call ESMF_FieldRegrid(fieldOcn, fieldAtm, routehandle=RH_mapmask, & - termorderflag=ESMF_TERMORDER_SRCSEQ, zeroregion=ESMF_REGION_TOTAL, rc=rc) + dataPtr_fieldAtm = czero + call ESMF_FieldRegrid(fieldOcnMask, fieldAtmMask, routehandle=RH_mapmask, & + termorderflag=ESMF_TERMORDER_SRCSEQ, zeroregion=ESMF_REGION_TOTAL, rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return call ESMF_FieldRegridRelease(RH_mapmask, rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return @@ -2091,58 +2114,61 @@ subroutine InitializeIPDv03p5(gcomp, importState, exportState, clock, rc) ! convert from ocean mask to land mask ! check min/max ! also fill "land_mask" array and save it for later - allocate(land_mask(lbound(dataPtr_fieldAtm,1):ubound(dataPtr_fieldAtm,1),lbound(dataPtr_fieldAtm,2):ubound(dataPtr_fieldAtm,2))) +!$omp parallel do default(shared) private(i,j) do j = lbound(dataPtr_fieldAtm,2),ubound(dataPtr_fieldAtm,2) - do i = lbound(dataPtr_fieldAtm,1),ubound(dataPtr_fieldAtm,1) - dataPtr_fieldAtm(i,j) = 1.0_ESMF_KIND_R8 - dataPtr_fieldAtm(i,j) - if (dataPtr_fieldAtm(i,j) > 1.0_ESMF_KIND_R8) dataPtr_fieldAtm(i,j) = 1.0_ESMF_KIND_R8 - if (dataPtr_fieldAtm(i,j) < 1.0e-6_ESMF_KIND_R8) dataPtr_fieldAtm(i,j) = 0.0_ESMF_KIND_R8 - land_mask(i,j) = dataPtr_fieldAtm(i,j) - enddo + do i = lbound(dataPtr_fieldAtm,1),ubound(dataPtr_fieldAtm,1) + dataPtr_fieldAtm(i,j) = cone - dataPtr_fieldAtm(i,j) +! dataPtr_fieldAtm(i,j) = dataPtr_arrayAtm(i,j) + if (dataPtr_fieldAtm(i,j) > cone) dataPtr_fieldAtm(i,j) = cone + if (dataPtr_fieldAtm(i,j) < conem6) dataPtr_fieldAtm(i,j) = czero + land_mask(i,j) = dataPtr_fieldAtm(i,j) + enddo enddo ! write out masks - call ESMF_FieldWrite(fieldOcn,'field_med_ocn_a_ocnice_mask.nc',overwrite=.true.,rc=rc) + call ESMF_FieldWrite(fieldOcnMask,'field_med_ocn_a_ocnice_mask.nc',overwrite=overwrite_flag,rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU,line=__LINE__, file=__FILE__)) return write (msgString,*) trim(subname)//"ocean_mask = ",minval(dataPtr_fieldOcn),maxval(dataPtr_fieldOcn) call ESMF_LogWrite(msgString, ESMF_LOGMSG_INFO, rc=rc) -#ifndef FRONT_FV3 - call ESMF_FieldWrite(fieldAtm,'field_med_atm_a_land_mask.nc',overwrite=.true.,rc=rc) +!#ifndef FRONT_FV3 +! call ESMF_FieldWrite(fieldAtmMask,'field_med_atm_a_land_mask.nc',overwrite=overwrite_flag,rc=rc) +! if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU,line=__LINE__, file=__FILE__)) return +! write (msgString,*) trim(subname)//"land_mask = ",minval(dataPtr_fieldAtm),maxval(dataPtr_fieldAtm) +! call ESMF_LogWrite(msgString, ESMF_LOGMSG_INFO, rc=rc) +!#endif + +!************* +!------------- +! -- Create ESMFIO + IOComp = ESMFIO_Create(gridAtmCoord, rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU,line=__LINE__, file=__FILE__)) return - write (msgString,*) trim(subname)//"land_mask = ",minval(dataPtr_fieldAtm),maxval(dataPtr_fieldAtm) - call ESMF_LogWrite(msgString, ESMF_LOGMSG_INFO, rc=rc) -#endif - ! clean up - call ESMF_GridDestroy(gridAtmCoord,rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU,line=__LINE__, file=__FILE__)) return - call ESMF_FieldDestroy(fieldAtm,rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU,line=__LINE__, file=__FILE__)) return - call ESMF_GridDestroy(gridOcnCoord,rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU,line=__LINE__, file=__FILE__)) return - call ESMF_FieldDestroy(fieldOcn,rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU,line=__LINE__, file=__FILE__)) return +! -- Write landmask files + call ESMFIO_Write(IOComp, 'field_med_atm_a_land_mask.nc', (/fieldAtmMask/), filePath='./', rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + +!************ +!------------- else ! isPresentOcn .and. isPresentIce call ESMF_LogWrite(trim(subname)//": ABORT more support needed for Ocn or Ice mask", ESMF_LOGMSG_INFO, rc=rc) call ESMF_Finalize(endflag=ESMF_END_ABORT) endif - - endif ! isPresentOcn .or. isPresentIce + endif ! isPresentOcn .or. isPresentIce !BL2017b -! call ESMF_GridGetItem(gridAtm, staggerLoc=ESMF_STAGGERLOC_CENTER, itemflag=ESMF_GRIDITEM_MASK, farrayPtr=dataPtr_arrayAtm, rc=rc) -! do j = lbound(dataPtr_arrayAtm,2),ubound(dataPtr_arrayAtm,2) +! call ESMF_GridGetItem(gridAtm, staggerLoc=ESMF_STAGGERLOC_CENTER, itemflag=ESMF_GRIDITEM_MASK, farrayPtr=dataPtr_arrayAtm, rc=rc) +! do j = lbound(dataPtr_arrayAtm,2),ubound(dataPtr_arrayAtm,2) ! do i = lbound(dataPtr_arrayAtm,1),ubound(dataPtr_arrayAtm,1) -! dataPtr_arrayAtm(i,j) = 0 ! over ocean -!! if (land_mask(i,j) >= 0.01_ESMF_KIND_R8) dataPtr_arrayAtm(i,j) =1_ESMF_KIND_I4 -! if (land_mask(i,j) >= 1.0e-6_ESMF_KIND_R8) dataPtr_arrayAtm(i,j) =1_ESMF_KIND_I4 -! enddo +! dataPtr_arrayAtm(i,j) = 0 ! over ocean +!! if (land_mask(i,j) >= 0.01_ESMF_KIND_R8) dataPtr_arrayAtm(i,j) = 1_ESMF_KIND_I4 +! if (land_mask(i,j) >= 1.0e-6_ESMF_KIND_R8) dataPtr_arrayAtm(i,j) = 1_ESMF_KIND_I4 ! enddo +! enddo !BL2017 endif ! generate_landmask @@ -2154,60 +2180,72 @@ subroutine InitializeIPDv03p5(gcomp, importState, exportState, clock, rc) !--- Diagnose Grid Info !---------------------------------------------------------- - call Grid_Print(gridAtm,'gridAtm',rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (is_local%wrap%atm_active) then + call Grid_Print(gridAtm,'gridAtm',rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + endif - call Grid_Print(gridOcn,'gridOcn',rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (is_local%wrap%ocn_active) then + call Grid_Print(gridOcn,'gridOcn',rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + endif - call Grid_Print(gridIce,'gridIce',rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (is_local%wrap%ice_active) then + call Grid_Print(gridIce,'gridIce',rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + endif - call Grid_Print(gridLnd,'gridLnd',rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (is_local%wrap%lnd_active) then + call Grid_Print(gridLnd,'gridLnd',rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + endif - call Grid_Print(gridHyd,'gridHyd',rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (is_local%wrap%hyd_active) then + call Grid_Print(gridHyd,'gridHyd',rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + endif - call Grid_Print(gridMed,'gridMed',rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out +! if (is_local%wrap%med_active) then +! call Grid_Print(gridMed,'gridMed',rc=rc) +! if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return +! endif #if 1 !---------------------------------------------------------- ! dump the Grid coordinate arrays for reference !---------------------------------------------------------- -#ifndef FRONT_FV3 - call Grid_Write(gridAtm, 'array_med_atm', rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out -#endif +!#ifndef FRONT_FV3 +! if (is_local%wrap%atm_active) then +! call Grid_Write(gridAtm, 'array_med_atm', rc=rc) +! if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return +! endif +!#endif - call Grid_Write(gridOcn, 'array_med_ocn', rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (is_local%wrap%ocn_active) then + call Grid_Write(gridOcn, 'array_med_ocn', rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + endif - call Grid_Write(gridIce, 'array_med_ice', rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (is_local%wrap%ice_active) then + call Grid_Write(gridIce, 'array_med_ice', rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + endif - call Grid_Write(gridLnd, 'array_med_lnd', rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (is_local%wrap%lnd_active) then + call Grid_Write(gridLnd, 'array_med_lnd', rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + endif - call Grid_Write(gridHyd, 'array_med_hyd', rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (is_local%wrap%hyd_active) then + call Grid_Write(gridHyd, 'array_med_hyd', rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + endif - call Grid_Write(gridMed, 'array_med_med', rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out +! if (is_local%wrap%med_active) then +! call Grid_Write(gridMed, 'array_med_med', rc=rc) +! if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return +! endif #endif @@ -2215,219 +2253,145 @@ subroutine InitializeIPDv03p5(gcomp, importState, exportState, clock, rc) ! NOW allocate other Mediator datatypes !---------------------------------------------------------- - ! Get the internal state from Component. - nullify(is_local%wrap) - call ESMF_GridCompGetInternalState(gcomp, is_local, rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out - !---------------------------------------------------------- ! Initialize FB for each model import states on each grid !---------------------------------------------------------- !--- atm - call fieldBundle_init(is_local%wrap%FBAtm_a, grid=gridAtm, & - state=NState_AtmImp, name='FBAtm_a', rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out - - call fieldBundle_init(is_local%wrap%FBAtm_o, grid=gridOcn, & - state=NState_AtmImp, name='FBAtm_o', rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out - - call fieldBundle_init(is_local%wrap%FBAtm2_o, grid=gridOcn, & - state=NState_AtmImp, name='FBAtm2_o', rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out - - call fieldBundle_init(is_local%wrap%FBAtm_i, grid=gridIce, & - state=NState_AtmImp, name='FBAtm_i', rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out - - call fieldBundle_init(is_local%wrap%FBAtm2_i, grid=gridIce, & - state=NState_AtmImp, name='FBAtm2_i', rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out - - call fieldBundle_init(is_local%wrap%FBAtm_l, grid=gridLnd, & - state=NState_AtmImp, name='FBAtm_l', rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out - - call fieldBundle_init(is_local%wrap%FBAtm_h, grid=gridHyd, & - state=NState_AtmImp, name='FBAtm_h', rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + call fieldBundle_init(is_local%wrap%FBAtm_a, grid=gridAtm, state=NState_AtmImp, name='FBAtm_a', rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + + call fieldBundle_init(is_local%wrap%FBAtm_o, grid=gridOcn, state=NState_AtmImp, name='FBAtm_o', rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + + call fieldBundle_init(is_local%wrap%FBAtm2_o, grid=gridOcn, state=NState_AtmImp, name='FBAtm2_o', rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + + call fieldBundle_init(is_local%wrap%FBAtm_i, grid=gridIce, state=NState_AtmImp, name='FBAtm_i', rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + + call fieldBundle_init(is_local%wrap%FBAtm2_i, grid=gridIce, state=NState_AtmImp, name='FBAtm2_i', rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + + call fieldBundle_init(is_local%wrap%FBAtm_l, grid=gridLnd, state=NState_AtmImp, name='FBAtm_l', rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + + call fieldBundle_init(is_local%wrap%FBAtm_h, grid=gridHyd, state=NState_AtmImp, name='FBAtm_h', rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return !--- ocn - call fieldBundle_init(is_local%wrap%FBOcn_a, grid=gridAtm, & - state=NState_OcnImp, name='FBOcn_a', rc=rc) + call fieldBundle_init(is_local%wrap%FBOcn_a, grid=gridAtm, state=NState_OcnImp, name='FBOcn_a', rc=rc) !BL2017b - call fieldBundle_init(is_local%wrap%FBOcn2_a, grid=gridAtm, & - state=NState_OcnImp, name='FBOcn2_a', rc=rc) + call fieldBundle_init(is_local%wrap%FBOcn2_a, grid=gridAtm, state=NState_OcnImp, name='FBOcn2_a', rc=rc) !BL2017b - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return - call fieldBundle_init(is_local%wrap%FBOcn_o, grid=gridOcn, & - state=NState_OcnImp, name='FBOcn_o', rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + call fieldBundle_init(is_local%wrap%FBOcn_o, grid=gridOcn, state=NState_OcnImp, name='FBOcn_o', rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return - call fieldBundle_init(is_local%wrap%FBOcn_i, grid=gridIce, & - state=NState_OcnImp, name='FBOcn_i', rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + call fieldBundle_init(is_local%wrap%FBOcn_i, grid=gridIce, state=NState_OcnImp, name='FBOcn_i', rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return !--- ice - call fieldBundle_init(is_local%wrap%FBIce_a, grid=gridAtm, & - state=NState_IceImp, name='FBIce_a', rc=rc) + call fieldBundle_init(is_local%wrap%FBIce_a, grid=gridAtm, state=NState_IceImp, name='FBIce_a', rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return !BL2017b - call fieldBundle_init(is_local%wrap%FBIce2_a, grid=gridAtm, & - state=NState_IceImp, name='FBIce2_a', rc=rc) + call fieldBundle_init(is_local%wrap%FBIce2_a, grid=gridAtm, state=NState_IceImp, name='FBIce2_a', rc=rc) !BL2017b - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return - call fieldBundle_init(is_local%wrap%FBIce_o, grid=gridOcn, & - state=NState_IceImp, name='FBIce_o', rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + call fieldBundle_init(is_local%wrap%FBIce_o, grid=gridOcn, state=NState_IceImp, name='FBIce_o', rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return - call fieldBundle_init(is_local%wrap%FBIce_i, grid=gridIce, & - state=NState_IceImp, name='FBIce_i', rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + call fieldBundle_init(is_local%wrap%FBIce_i, grid=gridIce, state=NState_IceImp, name='FBIce_i', rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return - call fieldBundle_init(is_local%wrap%FBIce_if, grid=gridIce, & - state=NState_IceImp, name='FBIce_if', rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + call fieldBundle_init(is_local%wrap%FBIce_if, grid=gridIce, state=NState_IceImp, name='FBIce_if', rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return !--- lnd - call fieldBundle_init(is_local%wrap%FBLnd_a, grid=gridAtm, & - state=NState_LndImp, name='FBLnd_a', rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + call fieldBundle_init(is_local%wrap%FBLnd_a, grid=gridAtm, state=NState_LndImp, name='FBLnd_a', rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return - call fieldBundle_init(is_local%wrap%FBLnd_l, grid=gridLnd, & - state=NState_LndImp, name='FBLnd_l', rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + call fieldBundle_init(is_local%wrap%FBLnd_l, grid=gridLnd, state=NState_LndImp, name='FBLnd_l', rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return - call fieldBundle_init(is_local%wrap%FBLnd_h, grid=gridHyd, & - state=NState_LndImp, name='FBLnd_h', rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + call fieldBundle_init(is_local%wrap%FBLnd_h, grid=gridHyd, state=NState_LndImp, name='FBLnd_h', rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return !--- hyd - call fieldBundle_init(is_local%wrap%FBHyd_l, grid=gridLnd, & - state=NState_HydImp, name='FBHyd_l', rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + call fieldBundle_init(is_local%wrap%FBHyd_l, grid=gridLnd, state=NState_HydImp, name='FBHyd_l', rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return - call fieldBundle_init(is_local%wrap%FBHyd_a, grid=gridAtm, & - state=NState_HydImp, name='FBHyd_a', rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + call fieldBundle_init(is_local%wrap%FBHyd_a, grid=gridAtm, state=NState_HydImp, name='FBHyd_a', rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return - call fieldBundle_init(is_local%wrap%FBHyd_h, grid=gridHyd, & - state=NState_HydImp, name='FBHyd_h', rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + call fieldBundle_init(is_local%wrap%FBHyd_h, grid=gridHyd, state=NState_HydImp, name='FBHyd_h', rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return !---------------------------------------------------------- ! Initialize Accumulators !---------------------------------------------------------- - call fieldBundle_init(is_local%wrap%FBaccumAtm, grid=gridAtm, & - state=NState_AtmImp, name='FBaccumAtm', rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + call fieldBundle_init(is_local%wrap%FBaccumAtm, grid=gridAtm, state=NState_AtmImp, name='FBaccumAtm', rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return - call fieldBundle_init(is_local%wrap%FBaccumOcn, grid=gridOcn, & - state=NState_OcnImp, name='FBaccumOcn', rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + call fieldBundle_init(is_local%wrap%FBaccumOcn, grid=gridOcn, state=NState_OcnImp, name='FBaccumOcn', rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return - call fieldBundle_init(is_local%wrap%FBaccumIce, grid=gridIce, & - state=NState_IceImp, name='FBaccumIce', rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + call fieldBundle_init(is_local%wrap%FBaccumIce, grid=gridIce, state=NState_IceImp, name='FBaccumIce', rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return - call fieldBundle_init(is_local%wrap%FBaccumLnd, grid=gridLnd, & - state=NState_LndImp, name='FBaccumLnd', rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + call fieldBundle_init(is_local%wrap%FBaccumLnd, grid=gridLnd, state=NState_LndImp, name='FBaccumLnd', rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return - call fieldBundle_init(is_local%wrap%FBaccumHyd, grid=gridHyd, & - state=NState_HydImp, name='FBaccumHyd', rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + call fieldBundle_init(is_local%wrap%FBaccumHyd, grid=gridHyd, state=NState_HydImp, name='FBaccumHyd', rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return !---------------------------------------------------------- ! Initialize AtmOcn FBs !---------------------------------------------------------- - call fieldBundle_init(is_local%wrap%FBAtmOcn_o, grid=gridOcn, & - fieldnamelist=fldsAtmOcn%shortname(1:fldsAtmOcn%num), name='FBAtmOcn_o', rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + call fieldBundle_init(is_local%wrap%FBAtmOcn_o, grid=gridOcn, fieldnamelist=fldsAtmOcn%shortname(1:fldsAtmOcn%num), name='FBAtmOcn_o', rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return - !call fieldBundle_init(is_local%wrap%FBAtmOcn_a, grid=gridAtm, & - ! fieldnamelist=fldsAtmOcn%shortname(1:fldsAtmOcn%num), name='FBAtmOcn_a', rc=rc) + call fieldBundle_init(is_local%wrap%FBAtmOcn_a, grid=gridAtm, fieldnamelist=fldsAtmOcn%shortname(1:fldsAtmOcn%num), name='FBAtmOcn_a', rc=rc) !BL2017b - !call fieldBundle_init(is_local%wrap%FBAtmOcn2_a, grid=gridAtm, & - ! fieldnamelist=fldsAtmOcn%shortname(1:fldsAtmOcn%num), name='FBAtmOcn2_a', rc=rc) + call fieldBundle_init(is_local%wrap%FBAtmOcn2_a, grid=gridAtm, fieldnamelist=fldsAtmOcn%shortname(1:fldsAtmOcn%num), name='FBAtmOcn2_a', rc=rc) !BL2017b - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return - call fieldBundle_init(is_local%wrap%FBaccumAtmOcn, grid=gridOcn, & - fieldnamelist=fldsAtmOcn%shortname(1:fldsAtmOcn%num), name='FBaccumAtmOcn', rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + call fieldBundle_init(is_local%wrap%FBaccumAtmOcn, grid=gridOcn, fieldnamelist=fldsAtmOcn%shortname(1:fldsAtmOcn%num), name='FBaccumAtmOcn', rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return !---------------------------------------------------------- ! Initialize FB for export to models !---------------------------------------------------------- - call fieldBundle_init(is_local%wrap%FBforAtm, & - state=NState_AtmExp, name='FBforAtm', rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + call fieldBundle_init(is_local%wrap%FBforAtm, state=NState_AtmExp, name='FBforAtm', rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return - call fieldBundle_init(is_local%wrap%FBforOcn, & - state=NState_OcnExp, name='FBforOcn', rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + call fieldBundle_init(is_local%wrap%FBforOcn, state=NState_OcnExp, name='FBforOcn', rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return - call fieldBundle_init(is_local%wrap%FBforIce, & - state=NState_IceExp, name='FBforIce', rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + call fieldBundle_init(is_local%wrap%FBforIce, state=NState_IceExp, name='FBforIce', rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return - call fieldBundle_init(is_local%wrap%FBforLnd, & - state=NState_LndExp, name='FBforLnd', rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + call fieldBundle_init(is_local%wrap%FBforLnd, state=NState_LndExp, name='FBforLnd', rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return - call fieldBundle_init(is_local%wrap%FBforHyd, & - state=NState_HydExp, name='FBforHyd', rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + call fieldBundle_init(is_local%wrap%FBforHyd, state=NState_HydExp, name='FBforHyd', rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return !---------------------------------------------------------- !--- Check for active regrid directions !---------------------------------------------------------- - + ! initialize is_local%wrap%a2o_active = .false. is_local%wrap%a2i_active = .false. @@ -2443,112 +2407,106 @@ subroutine InitializeIPDv03p5(gcomp, importState, exportState, clock, rc) is_local%wrap%h2a_active = .false. ! a2o, a2i, a2l, a2h - call ESMF_FieldBundleGet(is_local%wrap%FBAtm_a, fieldCount=fieldCount, rc=rc) ! Atmosphere Export Field Count - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + call ESMF_FieldBundleGet(is_local%wrap%FBAtm_a, fieldCount=fieldCount, rc=rc) ! Atmosphere Export Field Count + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return if (fieldCount > 0) then call ESMF_FieldBundleGet(is_local%wrap%FBforOcn, fieldCount=fieldCount, rc=rc) ! Ocean Import Field Count - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return if (fieldCount > 0) then is_local%wrap%a2o_active = .true. endif call ESMF_FieldBundleGet(is_local%wrap%FBforIce, fieldCount=fieldCount, rc=rc) ! Ice Import Field Count - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return if (fieldCount > 0) then is_local%wrap%a2i_active = .true. endif call ESMF_FieldBundleGet(is_local%wrap%FBforLnd, fieldCount=fieldCount, rc=rc) ! Land Import Field Count - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return if (fieldCount > 0) then is_local%wrap%a2l_active = .true. endif call ESMF_FieldBundleGet(is_local%wrap%FBforHyd, fieldCount=fieldCount, rc=rc) ! Hydro Import Field Count - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return if (fieldCount > 0) then is_local%wrap%a2h_active = .true. endif endif - + ! o2a, o2i - call ESMF_FieldBundleGet(is_local%wrap%FBOcn_o, fieldCount=fieldCount, rc=rc) ! Ocean Export Field Count - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + call ESMF_FieldBundleGet(is_local%wrap%FBOcn_o, fieldCount=fieldCount, rc=rc) ! Ocean Export Field Count + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return if (fieldCount > 0) then call ESMF_FieldBundleGet(is_local%wrap%FBforAtm, fieldCount=fieldCount, rc=rc) ! Atmosphere Import Field Count - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return if (fieldCount > 0) then is_local%wrap%o2a_active = .true. endif call ESMF_FieldBundleGet(is_local%wrap%FBforIce, fieldCount=fieldCount, rc=rc) ! Ice Import Field Count - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return if (fieldCount > 0) then is_local%wrap%o2i_active = .true. endif endif - + ! i2a, i2o - call ESMF_FieldBundleGet(is_local%wrap%FBIce_i, fieldCount=fieldCount, rc=rc) ! Ice Export Field Count - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + call ESMF_FieldBundleGet(is_local%wrap%FBIce_i, fieldCount=fieldCount, rc=rc) ! Ice Export Field Count + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return if (fieldCount > 0) then call ESMF_FieldBundleGet(is_local%wrap%FBforAtm, fieldCount=fieldCount, rc=rc) ! Atmosphere Import Field Count - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return if (fieldCount > 0) then is_local%wrap%i2a_active = .true. endif call ESMF_FieldBundleGet(is_local%wrap%FBforOcn, fieldCount=fieldCount, rc=rc) ! Ocean Import Field Count - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return if (fieldCount > 0) then is_local%wrap%i2o_active = .true. endif endif - + ! l2a, l2h - call ESMF_FieldBundleGet(is_local%wrap%FBLnd_l, fieldCount=fieldCount, rc=rc) ! Land Export Field Count - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + call ESMF_FieldBundleGet(is_local%wrap%FBLnd_l, fieldCount=fieldCount, rc=rc) ! Land Export Field Count + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return if (fieldCount > 0) then call ESMF_FieldBundleGet(is_local%wrap%FBforAtm, fieldCount=fieldCount, rc=rc) ! Atmosphere Import Field Count - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return if (fieldCount > 0) then is_local%wrap%l2a_active = .true. endif call ESMF_FieldBundleGet(is_local%wrap%FBforHyd, fieldCount=fieldCount, rc=rc) ! Hyd Import Field Count - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return if (fieldCount > 0) then is_local%wrap%l2h_active = .true. endif endif ! h2l, h2a - call ESMF_FieldBundleGet(is_local%wrap%FBHyd_h, fieldCount=fieldCount, rc=rc) ! Hydro Export Field Count - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + call ESMF_FieldBundleGet(is_local%wrap%FBHyd_h, fieldCount=fieldCount, rc=rc) ! Hydro Export Field Count + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return if (fieldCount > 0) then call ESMF_FieldBundleGet(is_local%wrap%FBforLnd, fieldCount=fieldCount, rc=rc) ! Land Import Field Count - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return if (fieldCount > 0) then is_local%wrap%h2l_active = .true. endif call ESMF_FieldBundleGet(is_local%wrap%FBforAtm, fieldCount=fieldCount, rc=rc) ! Atmosphere Import Field Count - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return if (fieldCount > 0) then is_local%wrap%h2a_active = .true. endif endif + write(msgString,*) is_local%wrap%atm_active + call ESMF_LogWrite(trim(subname)//": atm active: " // trim(msgString), ESMF_LOGMSG_INFO, rc=dbrc) + write(msgString,*) is_local%wrap%lnd_active + call ESMF_LogWrite(trim(subname)//": lnd active: " // trim(msgString), ESMF_LOGMSG_INFO, rc=dbrc) + write(msgString,*) is_local%wrap%ocn_active + call ESMF_LogWrite(trim(subname)//": ocn active: " // trim(msgString), ESMF_LOGMSG_INFO, rc=dbrc) + write(msgString,*) is_local%wrap%ice_active + call ESMF_LogWrite(trim(subname)//": ice active: " // trim(msgString), ESMF_LOGMSG_INFO, rc=dbrc) + write(msgString,*) is_local%wrap%hyd_active + call ESMF_LogWrite(trim(subname)//": hyd active: " // trim(msgString), ESMF_LOGMSG_INFO, rc=dbrc) + write(msgString,*) is_local%wrap%a2o_active call ESMF_LogWrite(trim(subname)//": a2o active: " // trim(msgString), ESMF_LOGMSG_INFO, rc=dbrc) write(msgString,*) is_local%wrap%a2i_active @@ -2579,7 +2537,7 @@ subroutine InitializeIPDv03p5(gcomp, importState, exportState, clock, rc) call ESMF_LogWrite(trim(subname)//": h2a active: " // trim(msgString), ESMF_LOGMSG_INFO, rc=dbrc) !---------------------------------------------------------- - !--- Initialize route handles + !--- Initialize Route Handles (RHs) !---------------------------------------------------------- if (dbug_flag > 1) then @@ -2589,160 +2547,208 @@ subroutine InitializeIPDv03p5(gcomp, importState, exportState, clock, rc) if (is_local%wrap%a2o_active) then call Compute_RHs(FBsrc=is_local%wrap%FBAtm_a, FBdst=is_local%wrap%FBAtm_o, & - bilnrmap=is_local%wrap%RH_a2o_bilnr, & - consfmap=is_local%wrap%RH_a2o_consf, & - consdmap=is_local%wrap%RH_a2o_consd, & - patchmap=is_local%wrap%RH_a2o_patch, & - fcopymap=is_local%wrap%RH_a2o_fcopy, & - nearestmap=is_local%wrap%RH_a2o_nearest, & - srcMaskValue=1, & - dstMaskValue=0, & - fldlist1=FldsFrAtm, string='a2o_weights', rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + consfmap=is_local%wrap%RH_a2o_consf, & + consdmap=is_local%wrap%RH_a2o_consd, & + con2fmap=is_local%wrap%RH_a2o_con2f, & + con2dmap=is_local%wrap%RH_a2o_con2d, & + patchmap=is_local%wrap%RH_a2o_patch, & + nrnbrmap=is_local%wrap%RH_a2o_nrnbr, & + srcMaskValue=1, & + dstMaskValue=0, & + fldlist1=FldsFrAtm, string='a2o_weights1', rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + + call Compute_RHs(FBsrc=is_local%wrap%FBAtm_a, FBdst=is_local%wrap%FBAtm_o, & + bilnrmap=is_local%wrap%RH_a2o_bilnr, & + fcopymap=is_local%wrap%RH_a2o_fcopy, & +! srcMaskValue=1, & + dstMaskValue=0, & + fldlist1=FldsFrAtm, string='a2o_weights2', rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return endif if (is_local%wrap%a2i_active) then call Compute_RHs(FBsrc=is_local%wrap%FBAtm_a, FBdst=is_local%wrap%FBAtm_i, & - bilnrmap=is_local%wrap%RH_a2i_bilnr, & - consfmap=is_local%wrap%RH_a2i_consf, & - consdmap=is_local%wrap%RH_a2i_consd, & - patchmap=is_local%wrap%RH_a2i_patch, & - fcopymap=is_local%wrap%RH_a2i_fcopy, & - nearestmap=is_local%wrap%RH_a2i_nearest, & - srcMaskValue=1, & - dstMaskValue=0, & - fldlist1=FldsFrAtm, string='a2i_weights', rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + consfmap=is_local%wrap%RH_a2i_consf, & + consdmap=is_local%wrap%RH_a2i_consd, & + con2fmap=is_local%wrap%RH_a2i_con2f, & + con2dmap=is_local%wrap%RH_a2i_con2d, & + patchmap=is_local%wrap%RH_a2i_patch, & + nrnbrmap=is_local%wrap%RH_a2i_nrnbr, & + srcMaskValue=1, & + dstMaskValue=0, & + fldlist1=FldsFrAtm, string='a2i_weights1', rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + + call Compute_RHs(FBsrc=is_local%wrap%FBAtm_a, FBdst=is_local%wrap%FBAtm_i, & + bilnrmap=is_local%wrap%RH_a2i_bilnr, & + fcopymap=is_local%wrap%RH_a2i_fcopy, & +! srcMaskValue=1, & + dstMaskValue=0, & + fldlist1=FldsFrAtm, string='a2i_weights2', rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + endif if (is_local%wrap%a2l_active) then call Compute_RHs(FBsrc=is_local%wrap%FBAtm_a, FBdst=is_local%wrap%FBAtm_l, & - bilnrmap=is_local%wrap%RH_a2l_bilnr, & - consfmap=is_local%wrap%RH_a2l_consf, & - consdmap=is_local%wrap%RH_a2l_consd, & - patchmap=is_local%wrap%RH_a2l_patch, & - fcopymap=is_local%wrap%RH_a2l_fcopy, & - fldlist1=FldsFrAtm, string='a2l_weights', rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + bilnrmap=is_local%wrap%RH_a2l_bilnr, & + consfmap=is_local%wrap%RH_a2l_consf, & + consdmap=is_local%wrap%RH_a2l_consd, & + con2fmap=is_local%wrap%RH_a2l_con2f, & + con2dmap=is_local%wrap%RH_a2l_con2d, & + patchmap=is_local%wrap%RH_a2l_patch, & + fcopymap=is_local%wrap%RH_a2l_fcopy, & + fldlist1=FldsFrAtm, string='a2l_weights', rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return endif if (is_local%wrap%a2h_active) then call Compute_RHs(FBsrc=is_local%wrap%FBAtm_a, FBdst=is_local%wrap%FBAtm_h, & - bilnrmap=is_local%wrap%RH_a2h_bilnr, & - consfmap=is_local%wrap%RH_a2h_consf, & - consdmap=is_local%wrap%RH_a2h_consd, & - patchmap=is_local%wrap%RH_a2h_patch, & - fcopymap=is_local%wrap%RH_a2h_fcopy, & - fldlist1=FldsFrAtm, string='a2h_weights', rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + bilnrmap=is_local%wrap%RH_a2h_bilnr, & + consfmap=is_local%wrap%RH_a2h_consf, & + consdmap=is_local%wrap%RH_a2h_consd, & + con2fmap=is_local%wrap%RH_a2h_con2f, & + con2dmap=is_local%wrap%RH_a2h_con2d, & + patchmap=is_local%wrap%RH_a2h_patch, & + fcopymap=is_local%wrap%RH_a2h_fcopy, & + fldlist1=FldsFrAtm, string='a2h_weights', rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return endif if (is_local%wrap%o2a_active) then call Compute_RHs(FBsrc=is_local%wrap%FBOcn_o, FBdst=is_local%wrap%FBOcn_a, & - bilnrmap=is_local%wrap%RH_o2a_bilnr, & - consfmap=is_local%wrap%RH_o2a_consf, & - consdmap=is_local%wrap%RH_o2a_consd, & - patchmap=is_local%wrap%RH_o2a_patch, & - fcopymap=is_local%wrap%RH_o2a_fcopy, & - nearestmap=is_local%wrap%RH_o2a_nearest, & - srcMaskValue=0, & - dstMaskValue=1, & - fldlist1=FldsFrOcn, fldlist2=FldsAtmOcn, string='o2a_weights', rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + bilnrmap=is_local%wrap%RH_o2a_bilnr, & + consfmap=is_local%wrap%RH_o2a_consf, & + consdmap=is_local%wrap%RH_o2a_consd, & + con2fmap=is_local%wrap%RH_o2a_con2f, & + con2dmap=is_local%wrap%RH_o2a_con2d, & + patchmap=is_local%wrap%RH_o2a_patch, & + fcopymap=is_local%wrap%RH_o2a_fcopy, & + nrnbrmap=is_local%wrap%RH_o2a_nrnbr, & + srcMaskValue=0, & + dstMaskValue=1, & + fldlist1=FldsFrOcn, fldlist2=FldsAtmOcn, string='o2a_weights', rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return endif if (is_local%wrap%o2i_active) then call Compute_RHs(FBsrc=is_local%wrap%FBOcn_o, FBdst=is_local%wrap%FBOcn_i, & - bilnrmap=is_local%wrap%RH_o2i_bilnr, & - consfmap=is_local%wrap%RH_o2i_consf, & - consdmap=is_local%wrap%RH_o2i_consd, & - patchmap=is_local%wrap%RH_o2i_patch, & - fcopymap=is_local%wrap%RH_o2i_fcopy, & - srcMaskValue=0, dstMaskValue=0, & - fldlist1=FldsFrOcn, string='o2i_weights', rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + bilnrmap=is_local%wrap%RH_o2i_bilnr, & + consfmap=is_local%wrap%RH_o2i_consf, & + consdmap=is_local%wrap%RH_o2i_consd, & + con2fmap=is_local%wrap%RH_o2i_con2f, & + con2dmap=is_local%wrap%RH_o2i_con2d, & + patchmap=is_local%wrap%RH_o2i_patch, & + fcopymap=is_local%wrap%RH_o2i_fcopy, & + srcMaskValue=0, dstMaskValue=0, & + fldlist1=FldsFrOcn, string='o2i_weights', rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return endif if (is_local%wrap%i2a_active) then call Compute_RHs(FBsrc=is_local%wrap%FBIce_i, FBdst=is_local%wrap%FBIce_a, & - bilnrmap=is_local%wrap%RH_i2a_bilnr, & - consfmap=is_local%wrap%RH_i2a_consf, & - consdmap=is_local%wrap%RH_i2a_consd, & - patchmap=is_local%wrap%RH_i2a_patch, & - fcopymap=is_local%wrap%RH_i2a_fcopy, & - nearestmap=is_local%wrap%RH_i2a_nearest, & - srcMaskValue=0, & - dstMaskValue=1, & - fldlist1=FldsFrIce, string='i2a_weights', rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + bilnrmap=is_local%wrap%RH_i2a_bilnr, & + consfmap=is_local%wrap%RH_i2a_consf, & + consdmap=is_local%wrap%RH_i2a_consd, & + con2fmap=is_local%wrap%RH_i2a_con2f, & + con2dmap=is_local%wrap%RH_i2a_con2d, & + patchmap=is_local%wrap%RH_i2a_patch, & + fcopymap=is_local%wrap%RH_i2a_fcopy, & + nrnbrmap=is_local%wrap%RH_i2a_nrnbr, & + srcMaskValue=0, & + dstMaskValue=1, & + fldlist1=FldsFrIce, string='i2a_weights', rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return endif if (is_local%wrap%i2o_active) then call Compute_RHs(FBsrc=is_local%wrap%FBIce_i, FBdst=is_local%wrap%FBIce_o, & - bilnrmap=is_local%wrap%RH_i2o_bilnr, & - consfmap=is_local%wrap%RH_i2o_consf, & - consdmap=is_local%wrap%RH_i2o_consd, & - patchmap=is_local%wrap%RH_i2o_patch, & - fcopymap=is_local%wrap%RH_i2o_fcopy, & - srcMaskValue=0, dstMaskValue=0, & - fldlist1=FldsFrIce, string='i2o_weights', rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + bilnrmap=is_local%wrap%RH_i2o_bilnr, & + consfmap=is_local%wrap%RH_i2o_consf, & + consdmap=is_local%wrap%RH_i2o_consd, & + con2fmap=is_local%wrap%RH_i2o_con2f, & + con2dmap=is_local%wrap%RH_i2o_con2d, & + patchmap=is_local%wrap%RH_i2o_patch, & + fcopymap=is_local%wrap%RH_i2o_fcopy, & + srcMaskValue=0, dstMaskValue=0, & + fldlist1=FldsFrIce, string='i2o_weights', rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return endif if (is_local%wrap%l2a_active) then call Compute_RHs(FBsrc=is_local%wrap%FBLnd_l, FBdst=is_local%wrap%FBLnd_a, & - bilnrmap=is_local%wrap%RH_l2a_bilnr, & - consfmap=is_local%wrap%RH_l2a_consf, & - consdmap=is_local%wrap%RH_l2a_consd, & - patchmap=is_local%wrap%RH_l2a_patch, & - fcopymap=is_local%wrap%RH_l2a_fcopy, & - fldlist1=FldsFrLnd, string='l2a_weights', rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + bilnrmap=is_local%wrap%RH_l2a_bilnr, & + consfmap=is_local%wrap%RH_l2a_consf, & + consdmap=is_local%wrap%RH_l2a_consd, & + con2fmap=is_local%wrap%RH_l2a_con2f, & + con2dmap=is_local%wrap%RH_l2a_con2d, & + patchmap=is_local%wrap%RH_l2a_patch, & + fcopymap=is_local%wrap%RH_l2a_fcopy, & + fldlist1=FldsFrLnd, string='l2a_weights', rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return endif if (is_local%wrap%l2h_active) then call Compute_RHs(FBsrc=is_local%wrap%FBLnd_l, FBdst=is_local%wrap%FBLnd_h, & - bilnrmap=is_local%wrap%RH_l2h_bilnr, & - consfmap=is_local%wrap%RH_l2h_consf, & - consdmap=is_local%wrap%RH_l2h_consd, & - patchmap=is_local%wrap%RH_l2h_patch, & - fcopymap=is_local%wrap%RH_l2h_fcopy, & - fldlist1=FldsFrLnd, string='l2h_weights', rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + bilnrmap=is_local%wrap%RH_l2h_bilnr, & + consfmap=is_local%wrap%RH_l2h_consf, & + consdmap=is_local%wrap%RH_l2h_consd, & + con2fmap=is_local%wrap%RH_l2h_con2f, & + con2dmap=is_local%wrap%RH_l2h_con2d, & + patchmap=is_local%wrap%RH_l2h_patch, & + fcopymap=is_local%wrap%RH_l2h_fcopy, & + fldlist1=FldsFrLnd, string='l2h_weights', rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return endif if (is_local%wrap%h2a_active) then call Compute_RHs(FBsrc=is_local%wrap%FBHyd_h, FBdst=is_local%wrap%FBHyd_a, & - bilnrmap=is_local%wrap%RH_h2a_bilnr, & - consfmap=is_local%wrap%RH_h2a_consf, & - consdmap=is_local%wrap%RH_h2a_consd, & - patchmap=is_local%wrap%RH_h2a_patch, & - fcopymap=is_local%wrap%RH_h2a_fcopy, & - fldlist1=FldsFrHyd, string='h2a_weights', rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + bilnrmap=is_local%wrap%RH_h2a_bilnr, & + consfmap=is_local%wrap%RH_h2a_consf, & + consdmap=is_local%wrap%RH_h2a_consd, & + con2fmap=is_local%wrap%RH_h2a_con2f, & + con2dmap=is_local%wrap%RH_h2a_con2d, & + patchmap=is_local%wrap%RH_h2a_patch, & + fcopymap=is_local%wrap%RH_h2a_fcopy, & + fldlist1=FldsFrHyd, string='h2a_weights', rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return endif if (is_local%wrap%h2l_active) then call Compute_RHs(FBsrc=is_local%wrap%FBHyd_h, FBdst=is_local%wrap%FBHyd_l, & - bilnrmap=is_local%wrap%RH_h2l_bilnr, & - consfmap=is_local%wrap%RH_h2l_consf, & - consdmap=is_local%wrap%RH_h2l_consd, & - patchmap=is_local%wrap%RH_h2l_patch, & - fcopymap=is_local%wrap%RH_h2l_fcopy, & - fldlist1=FldsFrHyd, string='h2l_weights', rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + bilnrmap=is_local%wrap%RH_h2l_bilnr, & + consfmap=is_local%wrap%RH_h2l_consf, & + consdmap=is_local%wrap%RH_h2l_consd, & + con2fmap=is_local%wrap%RH_h2l_con2f, & + con2dmap=is_local%wrap%RH_h2l_con2d, & + patchmap=is_local%wrap%RH_h2l_patch, & + fcopymap=is_local%wrap%RH_h2l_fcopy, & + fldlist1=FldsFrHyd, string='h2l_weights', rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + endif + + if (maptest .and. isPresentOcn) then + call maptest_chk(gridOcn,fieldOcnMask,gridAtm,fieldAtmMask,is_local%wrap%RH_o2a_consf,'o2a',rc) + call maptest_chk(gridAtm,fieldAtmMask,gridOcn,fieldOcnMask,is_local%wrap%RH_a2o_consf,'a2o',rc) + endif + + ! clean up + + if (isPresentOcn) then + call ESMF_FieldDestroy(fieldOcnMask,rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU,line=__LINE__, file=__FILE__)) return + call ESMF_GridDestroy(gridOcnCoord,rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU,line=__LINE__, file=__FILE__)) return + endif + + if (generate_landmask) then + call ESMF_FieldDestroy(fieldAtmMask,rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU,line=__LINE__, file=__FILE__)) return + +! -- Finalize ESMFIO (commented out because calling the following maked the model to segfault) +! call ESMFIO_Destroy(IOComp, rc=rc) +! if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return endif if (dbug_flag > 5) then @@ -2751,85 +2757,437 @@ subroutine InitializeIPDv03p5(gcomp, importState, exportState, clock, rc) contains !- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - subroutine completeFieldInitialization(State,rc) - - type(ESMF_State) , intent(inout) :: State - integer , intent(out) :: rc - - integer :: n, fieldCount - character(ESMF_MAXSTR),allocatable :: fieldNameList(:) - type(ESMF_FieldStatus_Flag) :: fieldStatus - - character(len=*),parameter :: subname='(module_MEDIATOR:completeFieldInitialization)' -#ifndef NUOPC_DOES_SMART_GRID_TRANSFER - type(ESMF_Grid) :: grid + subroutine maptest_chk(gridsrc,fracsrc,griddst,fracdst,RH,istr,rc) + + type(ESMF_Grid) :: gridsrc ! grid src + type(ESMF_Field) :: fracsrc ! field with src frac + type(ESMF_Grid) :: gridDst ! grid dst + type(ESMF_Field) :: fracdst ! field with dst frac + type(ESMF_RouteHandle) :: RH + character(len=*),intent(in) :: istr + integer,intent(inout) :: rc + + type(ESMF_FieldBundle):: FBtestSrc ! FB Src for testing interpolation + type(ESMF_FieldBundle):: FBtestDst ! FB Dst for testing interpolation + type(ESMF_Field) :: fieldDstArea, fieldSrcArea ! Fields containing ESMF computed areas + type(ESMF_Field) :: fieldDstFrac, fieldSrcFrac ! Fields containing fracs + type(ESMF_ArraySpec) :: arrayspec +#if (1 == 0) + type(ESMF_Field) :: fldsrc, flddst + type(ESMF_Grid) :: tmpGrid + type(ESMF_Array) :: tmpArray #endif + real(ESMF_KIND_R8), pointer :: dataptr(:,:),dataptr2(:,:) + real(ESMF_KIND_R8), pointer :: dataptr_Area(:,:) + real(ESMF_KIND_R8), pointer :: dataptr_Frac(:,:) + real(ESMF_KIND_R8), pointer :: dataptr_lon(:,:) + real(ESMF_KIND_R8), pointer :: dataptr_lat(:,:) + real(ESMF_KIND_R8) :: pi,rad2deg,deg2rad + integer :: n,nf,i1,i2 + integer :: localDECount, lDE + integer :: clbnd(2),cubnd(2) + character(len=*),parameter :: subname='(module_MEDIATOR:maptest_chk)' + + pi = atan(1.0_ESMF_KIND_R8) * 4.0_ESMF_KIND_R8 + rad2deg = 180._ESMF_KIND_R8/pi + deg2rad = pi/180._ESMF_KIND_R8 + + ! create field bundles + nf = 3 + allocate(fieldNameList(nf)) + FBtestsrc = ESMF_FieldBundleCreate(name='FBtestsrc',rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + FBtestdst = ESMF_FieldBundleCreate(name='FBtestdst',rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return - if (dbug_flag > 5) then - call ESMF_LogWrite(trim(subname)//": called", ESMF_LOGMSG_INFO, rc=dbrc) - endif + ! initialize/compute ESMF areas + call ESMF_ArraySpecSet(arrayspec, 2, ESMF_TYPEKIND_R8, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + FieldSrcArea = ESMF_FieldCreate(gridsrc, arrayspec, staggerloc=ESMF_STAGGERLOC_CENTER, name="area", rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + FieldDstArea = ESMF_FieldCreate(gridDst, arrayspec, staggerloc=ESMF_STAGGERLOC_CENTER, name="area", rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call ESMF_FieldRegridGetArea(FieldSrcArea, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call ESMF_FieldRegridGetArea(FieldDstArea, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return - rc = ESMF_Success + ! src frac + FieldSrcFrac = ESMF_FieldCreate(gridsrc, arrayspec, staggerloc=ESMF_STAGGERLOC_CENTER, name="frac", rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return - call ESMF_StateGet(State, itemCount=fieldCount, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out - allocate(fieldNameList(fieldCount)) - call ESMF_StateGet(State, itemNameList=fieldNameList, & - itemorderflag=ESMF_ITEMORDER_ADDORDER, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + call ESMF_GridGet(gridsrc, localDECount=localDECount, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return - do n=1, fieldCount + do lDE = 0,localDECount-1 + call ESMF_FieldGet(fracsrc, localDE=lDE, farrayPtr=dataptr,rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call ESMF_FieldGet(FieldSrcFrac, localDE=lDE, farrayPtr=dataptr2,rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + dataptr2(:,:) = dataptr(:,:) + enddo + ! dst frac + FieldDstFrac = ESMF_FieldCreate(gridDst, arrayspec, staggerloc=ESMF_STAGGERLOC_CENTER, name="frac", rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return - call ESMF_StateGet(State, field=field, itemName=fieldNameList(n), rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + call ESMF_GridGet(gridDst, localDECount=localDECount, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + + do lDE = 0,localDECount-1 + call ESMF_FieldGet(fracdst, localDE=lDE, farrayPtr=dataptr,rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call ESMF_FieldGet(FieldDstFrac, localDE=lDE, farrayPtr=dataptr2,rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + dataptr2(:,:) = dataptr(:,:) + enddo + + ! create test fields + do n = 1,nf + write(fieldnameList(n),'(a,i3.3)') 'fld',n + + ! dst field + field = ESMF_FieldCreate(gridDst, ESMF_TYPEKIND_R8, name=trim(fieldnameList(n)), rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call ESMF_FieldBundleAdd(FBtestdst, (/field/), rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + + ! src field + field = ESMF_FieldCreate(gridsrc, ESMF_TYPEKIND_R8, name=trim(fieldnameList(n)), rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call ESMF_FieldBundleAdd(FBtestSrc, (/field/), rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + + call ESMF_GridGet(gridsrc, localDECount=localDECount, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + + do lDE = 0,localDECount-1 + call ESMF_GridGetCoord(gridsrc, localDE=lDE, staggerLoc=ESMF_STAGGERLOC_CENTER, coordDim=1, & + farrayPtr=dataptr_lon, computationalLBound=clbnd, computationalUBound=cubnd, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call ESMF_GridGetCoord(gridsrc, localDE=lDE, staggerLoc=ESMF_STAGGERLOC_CENTER, coordDim=2, & + farrayPtr=dataptr_lat, computationalLBound=clbnd, computationalUBound=cubnd, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call ESMF_FieldGet(field, localDE=lDE, farrayPtr=dataptr, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call ESMF_FieldGet(fieldSrcFrac, localDE=lDE, farrayPtr=dataPtr_frac, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + + dataptr = 0.0_ESMF_KIND_R8 + + do i1=clbnd(1),cubnd(1) + do i2=clbnd(2),cubnd(2) + if (n == 1) dataptr(i1,i2) = 5.0_ESMF_KIND_R8 + if (n == 2) then + if (dataPtr_frac(i1,i2) > 1.0e-12_ESMF_KIND_R8) then + dataptr(i1,i2) = 5.0_ESMF_KIND_R8 + else + dataPtr(i1,i2) = 1.0e36_ESMF_KIND_R8 + endif + endif + if (n == 3) dataptr(i1,i2) = 2.0 + cos(0.5*dataptr_lon(i1,i2)*deg2rad)**2.0 * cos(dataptr_lat(i1,i2)*deg2rad) + enddo + enddo + + enddo + enddo + + ! regrid + do n = 1,nf + call FieldBundle_FieldRegrid(FBtestsrc, fieldnameList(n), & + FBtestdst, fieldnameList(n), & + RH, rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + enddo + +#if (1 == 0) + ! vtk output of grid information + call FieldBundle_getFieldN(FBtestsrc,1,fldsrc,rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call FieldBundle_getFieldN(FBtestdst,1,flddst,rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + + call ESMF_FieldGet(fldsrc, grid=tmpGrid, array=tmpArray, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + + call ESMF_GridWriteVTK(tmpGrid, staggerloc=ESMF_STAGGERLOC_CENTER, & + filename='srcGrid', array1=tmpArray, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + + call ESMF_GridWriteVTK(tmpGrid, staggerloc=ESMF_STAGGERLOC_CORNER, & + filename='srcGridCnr', rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + + call ESMF_FieldGet(flddst, grid=tmpGrid, array=tmpArray, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + + call ESMF_GridWriteVTK(tmpGrid, staggerloc=ESMF_STAGGERLOC_CENTER, & + filename='dstGrid', array1=tmpArray, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + + call ESMF_GridWriteVTK(tmpGrid, staggerloc=ESMF_STAGGERLOC_CORNER, & + filename='dstGridCnr', rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return +#endif + + !--- Src output --- + call maptest_diagnose(gcomp,gridsrc,FBtestsrc,fieldSrcArea,fieldSrcFrac,trim(istr)//'_src',rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + + !--- Src output --- + call maptest_diagnose(gcomp,gridDst,FBtestdst,fieldDstArea,fieldDstFrac,trim(istr)//'_dst',rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + + deallocate(fieldNameList) + call ESMF_FieldDestroy(fieldDstArea,rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU,line=__LINE__, file=__FILE__)) return + call ESMF_FieldDestroy(fieldSrcArea,rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU,line=__LINE__, file=__FILE__)) return + call ESMF_FieldDestroy(fieldDstFrac,rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU,line=__LINE__, file=__FILE__)) return + call ESMF_FieldDestroy(fieldSrcFrac,rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU,line=__LINE__, file=__FILE__)) return + call ESMF_FieldBundleDestroy(fbtestdst,rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU,line=__LINE__, file=__FILE__)) return + call ESMF_FieldBundleDestroy(fbtestsrc,rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU,line=__LINE__, file=__FILE__)) return + + end subroutine maptest_chk + + !-------------------- + + subroutine maptest_diagnose(gcomp,grid,FB,fieldA,fieldF,istr,rc) + + type(ESMF_GridComp) :: gcomp + type(ESMF_Grid) :: grid + type(ESMF_FieldBundle) :: FB + type(ESMF_Field) :: fieldA ! area + type(ESMF_Field) :: fieldF ! frac + character(len=*),intent(in) :: istr + integer, intent(inout) :: rc + + type(ESMF_GridComp) :: IOComp + type(ESMF_Field) :: field + type(ESMF_VM) :: vm + real(ESMF_KIND_R8), pointer :: dataptr(:,:),dataptr2(:,:) + real(ESMF_KIND_R8), pointer :: dataptr_Area(:,:) + real(ESMF_KIND_R8), pointer :: dataptr_Frac(:,:) + integer :: n,nf,i1,i2 + integer :: localDECount, lDE + integer :: clbnd(2),cubnd(2) + character(ESMF_MAXSTR),pointer :: fieldNamelist(:) + real(ESMF_KIND_R8) :: datamin(1),datamax(1),datasum(1),datasumx(1) + real(ESMF_KIND_R8) :: dataming(1),datamaxg(1),datasumg(1),datasumxg(1) + real(ESMF_KIND_R8) :: areamin(1),areamax(1),areasum(1),areasumx(1) + real(ESMF_KIND_R8) :: areaming(1),areamaxg(1),areasumg(1),areasumxg(1) + real(ESMF_KIND_R8) :: fracmin(1),fracmax(1),fracsum(1),fracsumx(1) + real(ESMF_KIND_R8) :: fracming(1),fracmaxg(1),fracsumg(1),fracsumxg(1) + + character(len=*),parameter :: subname='(module_MEDIATOR:maptest_diagnose)' + + call ESMF_GridCompGet(gcomp, vm=vm, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + + IOComp = ESMFIO_Create(grid, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU,line=__LINE__, file=__FILE__)) return + call ESMFIO_Write(IOComp, 'maptest_'//trim(istr)//'_frac.nc', (/fieldF/), filePath='./', rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call ESMFIO_Write(IOComp, 'maptest_'//trim(istr)//'_area.nc', (/fieldA/), filePath='./', rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + + call ESMF_FieldBundleGet(FB, fieldCount=nf, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + allocate(fieldNameList(nf)) + call ESMF_FieldBundleGet(FB, fieldNameList=fieldNameList, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + + do n = 1,nf + + call ESMF_GridGet(grid, localDECount=localDECount, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call FieldBundle_getFieldN(FB,n,field,rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call ESMFIO_Write(IOComp, 'maptest_'//trim(istr)//'_'//trim(fieldnameList(n))//'.nc', (/field/), filePath='./', rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + + datamin = 1.0e99 ! data + datamax = -1.0e99 + datasum = 0.0_ESMF_KIND_R8 + datasumx = 0.0_ESMF_KIND_R8 + areamin = 1.0e99 ! area + areamax = -1.0e99 + areasum = 0.0_ESMF_KIND_R8 + areasumx = 0.0_ESMF_KIND_R8 + fracmin = 1.0e99 ! frac + fracmax = -1.0e99 + fracsum = 0.0_ESMF_KIND_R8 + fracsumx = 0.0_ESMF_KIND_R8 + + do lDE = 0,localDECount-1 + + call ESMF_GridGetCoord(grid, localDE=lDE, staggerLoc=ESMF_STAGGERLOC_CENTER, coordDim=1, & + farrayPtr=dataptr, computationalLBound=clbnd, computationalUBound=cubnd, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call ESMF_GridGetCoord(grid, localDE=lDE, staggerLoc=ESMF_STAGGERLOC_CENTER, coordDim=2, & + farrayPtr=dataptr, computationalLBound=clbnd, computationalUBound=cubnd, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call ESMF_FieldGet(fieldF, localDE=lDE, farrayPtr=dataPtr_frac, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call ESMF_FieldGet(FieldA, localDE=lDE, farrayPtr=dataPtr_area, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call ESMF_FieldGet(field, localDE=lDE, farrayPtr=dataptr,rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + +! local info +! write(msgString,'(2a,i4,2g25.17)') 'maptest loc frac:',trim(fieldnameList(n)),lDE,minval(dataPtr_frac),maxval(dataPtr_frac) +! call ESMF_LogWrite(trim(msgString), ESMF_LOGMSG_INFO, rc=dbrc) +! write(msgString,'(2a,i4,2g25.17)') 'maptest loc area:',trim(fieldnameList(n)),lDE,minval(dataPtr_area),maxval(dataPtr_area) +! call ESMF_LogWrite(trim(msgString), ESMF_LOGMSG_INFO, rc=dbrc) +! write(msgString,'(2a,i4,2g25.17)') 'maptest loc fld :',trim(fieldnameList(n)),lDE,minval(dataPtr),maxval(dataPtr) +! call ESMF_LogWrite(trim(msgString), ESMF_LOGMSG_INFO, rc=dbrc) + + do i1=clbnd(1),cubnd(1) + do i2=clbnd(2),cubnd(2) +! if (dataPtr_frac(i1,i2) > 1.0e-12_ESMF_KIND_R8) then + datamin = min(datamin,dataptr(i1,i2)) + datamax = max(datamax,dataptr(i1,i2)) + datasum = datasum + dataptr(i1,i2)*dataPtr_area(i1,i2)*dataPtr_frac(i1,i2) + + areamin = min(areamin,dataptr_area(i1,i2)) + areamax = max(areamax,dataptr_area(i1,i2)) + areasum = areasum + dataPtr_area(i1,i2)*dataPtr_frac(i1,i2) + + fracmin = min(fracmin,dataptr_frac(i1,i2)) + fracmax = max(fracmax,dataptr_frac(i1,i2)) + fracsum = fracsum + dataPtr_frac(i1,i2) +! endif + datasumx = datasumx + dataptr(i1,i2)*dataPtr_area(i1,i2) + areasumx = areasumx + dataPtr_area(i1,i2) + fracsumx = fracsumx + 1 + enddo + enddo + + enddo + + call ESMF_VMAllReduce(vm, datamin, dataming, 1, ESMF_REDUCE_MIN, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call ESMF_VMAllReduce(vm, datamax, datamaxg, 1, ESMF_REDUCE_MAX, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call ESMF_VMAllReduce(vm, datasum, datasumg, 1, ESMF_REDUCE_SUM, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call ESMF_VMAllReduce(vm, datasumx, datasumxg, 1, ESMF_REDUCE_SUM, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + + call ESMF_VMAllReduce(vm, areamin, areaming, 1, ESMF_REDUCE_MIN, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call ESMF_VMAllReduce(vm, areamax, areamaxg, 1, ESMF_REDUCE_MAX, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call ESMF_VMAllReduce(vm, areasum, areasumg, 1, ESMF_REDUCE_SUM, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call ESMF_VMAllReduce(vm, areasumx, areasumxg, 1, ESMF_REDUCE_SUM, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + + call ESMF_VMAllReduce(vm, fracmin, fracming, 1, ESMF_REDUCE_MIN, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call ESMF_VMAllReduce(vm, fracmax, fracmaxg, 1, ESMF_REDUCE_MAX, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call ESMF_VMAllReduce(vm, fracsum, fracsumg, 1, ESMF_REDUCE_SUM, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call ESMF_VMAllReduce(vm, fracsumx, fracsumxg, 1, ESMF_REDUCE_SUM, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + + if (n == 1) then + write(msgString,'(a)') 'maptest output '//trim(istr)//': n name sum min max (unmasked_sum)' + call ESMF_LogWrite(trim(msgString), ESMF_LOGMSG_INFO, rc=dbrc) + write(msgString,'(a,i4,1x,a,4g25.17)') 'maptest '//trim(istr)//':',0,'frac',fracsumg,fracming,fracmaxg,fracsumxg + call ESMF_LogWrite(trim(msgString), ESMF_LOGMSG_INFO, rc=dbrc) + write(msgString,'(a,i4,1x,a,4g25.17)') 'maptest '//trim(istr)//':',0,'area',areasumg,areaming,areamaxg,areasumxg + call ESMF_LogWrite(trim(msgString), ESMF_LOGMSG_INFO, rc=dbrc) + endif + write(msgString,'(a,i4,1x,a,4g25.17)') 'maptest '//trim(istr)//':',n,trim(fieldnameList(n)),datasumg,dataming,datamaxg,datasumxg + call ESMF_LogWrite(trim(msgString), ESMF_LOGMSG_INFO, rc=dbrc) + + enddo + + deallocate(fieldNameList) + call ESMFIO_Destroy(IOComp, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + + end subroutine maptest_diagnose + + !---------------------------- + + subroutine completeFieldInitialization(State,rc) + + type(ESMF_State) , intent(inout) :: State + integer , intent(out) :: rc + + integer :: n, fieldCount + character(ESMF_MAXSTR),allocatable :: fieldNameList(:) + type(ESMF_FieldStatus_Flag) :: fieldStatus + + character(len=*),parameter :: subname='(module_MEDIATOR:completeFieldInitialization)' +#ifndef NUOPC_DOES_SMART_GRID_TRANSFER + type(ESMF_Grid) :: grid +#endif + + if (dbug_flag > 5) then + call ESMF_LogWrite(trim(subname)//": called", ESMF_LOGMSG_INFO, rc=dbrc) + endif + + rc = ESMF_Success + + call ESMF_StateGet(State, itemCount=fieldCount, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + + allocate(fieldNameList(fieldCount)) + call ESMF_StateGet(State, itemNameList=fieldNameList, & + itemorderflag=ESMF_ITEMORDER_ADDORDER, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + + do n=1, fieldCount + + call ESMF_StateGet(State, field=field, itemName=fieldNameList(n), rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return call ESMF_FieldGet(field, status=fieldStatus, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return - if (fieldStatus==ESMF_FIELDSTATUS_GRIDSET) then + if (fieldStatus == ESMF_FIELDSTATUS_GRIDSET) then if (dbug_flag > 1) then - call ESMF_LogWrite(subname//" is accepting grid for field "//trim(fieldNameList(n)), & - ESMF_LOGMSG_INFO, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + call ESMF_LogWrite(subname//" is accepting grid for field "//trim(fieldNameList(n)), ESMF_LOGMSG_INFO, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return endif + ! the transferred Grid is already set, allocate field data memory ! DCR - The WRFHYDRO soil fields have an ungridded 3rd dimension. ! The ESMF_FieldEmptyComplete is not allocating memory for this 3rd dimension + call ESMF_FieldEmptyComplete(field, typekind=ESMF_TYPEKIND_R8, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return #ifndef NUOPC_DOES_SMART_GRID_TRANSFER ! access the transferred Grid to use for other fields call ESMF_FieldGet(field, grid=grid, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return else if (dbug_flag > 1) then call ESMF_LogWrite(subname//" is accepting INTERNAL grid for field "//trim(fieldNameList(n)), & ESMF_LOGMSG_INFO, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return endif ! now use the Grid object in other fields call ESMF_FieldEmptySet(field, grid=grid, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call ESMF_FieldEmptyComplete(field, typekind=ESMF_TYPEKIND_R8, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return #endif endif ! accept call FldGrid_Print(field,fieldNameList(n),rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return enddo + deallocate(fieldNameList) if (dbug_flag > 5) then call ESMF_LogWrite(trim(subname)//": done", ESMF_LOGMSG_INFO, rc=dbrc) @@ -2838,13 +3196,13 @@ subroutine completeFieldInitialization(State,rc) end subroutine completeFieldInitialization end subroutine InitializeIPDv03p5 - + !----------------------------------------------------------------------------- subroutine DataInitialize(gcomp, rc) type(ESMF_GridComp) :: gcomp integer, intent(out) :: rc - + ! local variables type(ESMF_Clock) :: clock type(ESMF_State) :: importState, exportState @@ -2866,55 +3224,48 @@ subroutine DataInitialize(gcomp, rc) ! query the Component for its clock, importState and exportState call ESMF_GridCompGet(gcomp, clock=clock, importState=importState, & - exportState=exportState, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out - + exportState=exportState, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + ! Get the internal state from Component. nullify(is_local%wrap) call ESMF_GridCompGetInternalState(gcomp, is_local, rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return ! get the current time out of the clock call ESMF_ClockGet(clock, currTime=time, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out - + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + ! initialze cumulative flag allDone = .true. ! reset if an item is found that is not done - + ! check that all imported fields from ATM show correct timestamp do n = 1,fldsFrAtm%num call ESMF_StateGet(NState_AtmImp, itemName=fldsFrAtm%shortname(n), & - itemType=itemType, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + itemType=itemType, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + if (itemType /= ESMF_STATEITEM_NOTFOUND) then - connected = NUOPC_IsConnected(NState_AtmImp, & - fieldName=fldsFrAtm%shortname(n), rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + connected = NUOPC_IsConnected(NState_AtmImp, fieldName=fldsFrAtm%shortname(n), rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + if (connected) then - call ESMF_StateGet(NState_AtmImp, itemName=fldsFrAtm%shortname(n), & - field=field, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + call ESMF_StateGet(NState_AtmImp, itemName=fldsFrAtm%shortname(n), field=field, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + atCorrectTime = NUOPC_IsAtTime(field, time, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out - if (.not.atCorrectTime) then + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + + if (.not. atCorrectTime) then call ESMF_LogWrite("MED - Initialize-Data-Dependency NOT YET SATISFIED!!!", & - ESMF_LOGMSG_INFO, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + ESMF_LOGMSG_INFO, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return allDone = .false. exit ! break out of the loop when first not satisfied found else call ESMF_LogWrite("MED - Initialize-Data-Dependency SATISFIED!!!", & - ESMF_LOGMSG_INFO, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + ESMF_LOGMSG_INFO, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return endif endif endif @@ -2926,62 +3277,51 @@ subroutine DataInitialize(gcomp, rc) if (allDone) then ! -> set InitializeDataComplete Component Attribute to "true", indicating ! to the driver that this Component has fully initialized its data - call NUOPC_CompAttributeSet(gcomp, & - name="InitializeDataComplete", value="true", rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + + call NUOPC_CompAttributeSet(gcomp, name="InitializeDataComplete", value="true", rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return ! gjt: The above code ensures that the MED has initial conditions from ATM. - + ! TODO - For the real case this should probably use the fields from the ! importState and do something with it as a sensible starting point ! for the accumulation field so that the OCN receives a meaningful ! fields during its first time step. However, here for testing ! I simply initialize to zero. - + call state_reset(NState_atmImp, value=spval_init, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return call state_reset(NState_ocnImp, value=spval_init, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return call state_reset(NState_iceImp, value=spval_init, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return call state_reset(NState_lndImp, value=spval_init, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return call state_reset(NState_hydImp, value=spval_init, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return call fieldBundle_reset(is_local%wrap%FBaccumAtm, value=czero, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return is_local%wrap%accumcntAtm = 0 call fieldBundle_reset(is_local%wrap%FBaccumOcn, value=czero, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return is_local%wrap%accumcntOcn = 0 call fieldBundle_reset(is_local%wrap%FBaccumIce, value=czero, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return is_local%wrap%accumcntIce = 0 call fieldBundle_reset(is_local%wrap%FBaccumLnd, value=czero, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return is_local%wrap%accumcntLnd = 0 call fieldBundle_reset(is_local%wrap%FBaccumHyd, value=czero, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return is_local%wrap%accumcntHyd = 0 !--------------------------------------- @@ -2989,24 +3329,22 @@ subroutine DataInitialize(gcomp, rc) !--------------------------------------- !---tcraig, turn if on to force no mediator restarts for testing - !if (.not.coldstart) then + !if (.not. coldstart) then call Mediator_restart(gcomp,'read','mediator',rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return !endif + write(0,*)' after Mediator_restart read' ! default initialize s_surf to work around limitations of current initialization sequence - call ESMF_StateGet(NState_IceExp, itemName='s_surf', & - itemType=itemType, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + call ESMF_StateGet(NState_IceExp, itemName='s_surf', itemType=itemType, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + if (itemType /= ESMF_STATEITEM_NOTFOUND) then if (NUOPC_IsConnected(NState_IceExp,'s_surf',rc=rc)) then - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call State_SetFldPtr(NState_IceExp, 's_surf', 34.0_ESMF_KIND_R8, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return endif endif @@ -3038,10 +3376,9 @@ subroutine SetRunClock(gcomp, rc) endif ! query the Mediator for clocks - call NUOPC_MediatorGet(gcomp, mediatorClock=mediatorClock, & - driverClock=driverClock, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + call NUOPC_MediatorGet(gcomp, mediatorClock=mediatorClock, & + driverClock=driverClock, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return if (dbug_flag > 1) then call ClockTimePrint(driverClock ,trim(subname)//'driver clock1',rc) @@ -3050,11 +3387,10 @@ subroutine SetRunClock(gcomp, rc) ! set the mediatorClock to have the current start time as the driverClock call ESMF_ClockGet(driverClock, currTime=currTime, timeStep=timeStep, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call ESMF_ClockSet(mediatorClock, currTime=currTime, timeStep=timeStep, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return if (dbug_flag > 1) then call ClockTimePrint(driverClock ,trim(subname)//'driver clock2',rc) @@ -3063,8 +3399,7 @@ subroutine SetRunClock(gcomp, rc) ! check and set the component clock against the driver clock call NUOPC_CompCheckSetClock(gcomp, driverClock, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return if (dbug_flag > 5) then call ESMF_LogWrite(trim(subname)//": done", ESMF_LOGMSG_INFO, rc=dbrc) @@ -3082,15 +3417,7 @@ subroutine MedPhase_fast_before(gcomp, rc) ! prepares the ATM and ICE import Fields. ! local variables - type(ESMF_Clock) :: clock - type(ESMF_Time) :: time - character(len=64) :: timestr - type(ESMF_State) :: importState, exportState - type(ESMF_Field) :: field - type(InternalState) :: is_local - real(ESMF_KIND_R8), pointer :: dataPtr1(:,:),dataPtr2(:,:),dataPtr3(:,:) - integer :: i,j,n - character(len=*),parameter :: subname='(module_MEDIATOR:MedPhase_fast_before)' + character(len=*),parameter :: subname='(module_MEDIATOR:MedPhase_fast_before)' if(profile_memory) call ESMF_VMLogMemInfo("Entering "//trim(subname)) if (dbug_flag > 5) then @@ -3099,17 +3426,13 @@ subroutine MedPhase_fast_before(gcomp, rc) rc = ESMF_SUCCESS call MedPhase_prep_atm(gcomp,rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return call MedPhase_prep_ice(gcomp,rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return call MedPhase_prep_lnd(gcomp,rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return call MedPhase_prep_hyd(gcomp,rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return if (dbug_flag > 5) then call ESMF_LogWrite(trim(subname)//": done", ESMF_LOGMSG_INFO, rc=dbrc) @@ -3123,53 +3446,70 @@ end subroutine MedPhase_fast_before subroutine MedPhase_prep_atm(gcomp, rc) type(ESMF_GridComp) :: gcomp integer, intent(out) :: rc - + ! This Mediator phase runs before ATM and ICE are being called and ! prepares the ATM and ICE import Fields. - + ! local variables type(ESMF_Clock) :: clock - type(ESMF_Time) :: time + type(ESMF_Time) :: time, startTime + type(ESMF_TimeInterval) :: elapsedTime character(len=64) :: timestr type(ESMF_State) :: importState, exportState type(ESMF_Field) :: field + type(ESMF_VM) :: vm type(InternalState) :: is_local real(ESMF_KIND_R8), pointer :: dataPtr1(:,:),dataPtr2(:,:),dataPtr3(:,:),dataPtr4(:,:) real(ESMF_KIND_R8), pointer :: dataPtr5(:,:) real(ESMF_KIND_R8), pointer :: ifrac_i(:,:) ! ice fraction on ice grid real(ESMF_KIND_R8), pointer :: ifrac_af(:,:), ifrac_afr(:,:) ! ice fraction on atm grid consf map real(ESMF_KIND_R8), pointer :: ifrac_ad(:,:), ifrac_adr(:,:) ! ice fraction on atm grid consd map + real(ESMF_KIND_R8), pointer :: ifrac_ag(:,:), ifrac_agr(:,:) ! ice fraction on atm grid con2f map + real(ESMF_KIND_R8), pointer :: ifrac_ae(:,:), ifrac_aer(:,:) ! ice fraction on atm grid con2d map real(ESMF_KIND_R8), pointer :: ifrac_ab(:,:), ifrac_abr(:,:) ! ice fraction on atm grid bilnr map real(ESMF_KIND_R8), pointer :: ifrac_ap(:,:), ifrac_apr(:,:) ! ice fraction on atm grid patch map - real(ESMF_KIND_R8), pointer :: icewgt(:,:) - integer :: i,j,n + real(ESMF_KIND_R8), pointer :: ocnwgt(:,:), icewgt(:,:), customwgt(:,:) + integer :: i,j,n,il,iu,jl,ju integer :: regridwriteAtmExp_timeslice = 0 - character(len=128) :: fname - character(len=*),parameter :: subname='(module_MEDIATOR:MedPhase_prep_atm)' + character(len=128) :: fname + character(len=*),parameter :: subname='(module_MEDIATOR:MedPhase_prep_atm)' !BL2017b character(ESMF_MAXSTR) ,pointer :: fieldNameList(:) - integer :: fieldCount + integer :: fieldCount, kdt + integer*8 :: sec8 + integer, parameter :: deltim=450 + integer :: localPet !BL2017b - + if(profile_memory) call ESMF_VMLogMemInfo("Entering "//trim(subname)) if (dbug_flag > 5) then call ESMF_LogWrite(trim(subname)//": called", ESMF_LOGMSG_INFO, rc=dbrc) endif rc = ESMF_SUCCESS + call ESMF_GridCompGet(gcomp, vm=vm, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__,file=__FILE__)) return + + call ESMF_VMGet(vm, localPet=localPet, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__,file=__FILE__)) return + ! query the Component for its clock, importState and exportState call ESMF_GridCompGet(gcomp, clock=clock, importState=importState, & - exportState=exportState, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out - + exportState=exportState, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + ! Get the internal state from Component. nullify(is_local%wrap) call ESMF_GridCompGetInternalState(gcomp, is_local, rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + +! call ESMF_ClockGet(clock,currtime=time,rc=rc) + call ESMF_ClockGet(clock,currtime=time, startTime=startTime,rc=rc) + elapsedTime = time - startTime + call ESMF_TimeIntervalGet(elapsedTime,s_i8=sec8,rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + kdt = sec8 / deltim + 1 - call ESMF_ClockGet(clock,currtime=time,rc=rc) call ESMF_TimeGet(time,timestring=timestr) if (dbug_flag > 1) then call ESMF_LogWrite(trim(subname)//": time = "//trim(timestr), ESMF_LOGMSG_INFO, rc=dbrc) @@ -3177,13 +3517,11 @@ subroutine MedPhase_prep_atm(gcomp, rc) if (dbug_flag > 1) then call ESMF_ClockPrint(clock, options="currTime", & - preString="-------->"//trim(subname)//" mediating for: ", & - unit=msgString, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + preString="-------->"//trim(subname)//" mediating for: ", & + unit=msgString, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return call ESMF_LogWrite(msgString, ESMF_LOGMSG_INFO, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return endif !--------------------------------------- @@ -3196,11 +3534,13 @@ subroutine MedPhase_prep_atm(gcomp, rc) call fieldBundle_reset(is_local%wrap%FBIce_i, value=czero, rc=rc) call fieldBundle_reset(is_local%wrap%FBLnd_l, value=czero, rc=rc) call fieldBundle_reset(is_local%wrap%FBHyd_h, value=czero, rc=rc) + call FieldBundle_diagnose(is_local%wrap%FBAtm_a, trim(subname)//' FBAtm_a zero', rc=rc) call FieldBundle_diagnose(is_local%wrap%FBOcn_o, trim(subname)//' FBOcn_o zero', rc=rc) call FieldBundle_diagnose(is_local%wrap%FBIce_i, trim(subname)//' FBIce_i zero', rc=rc) call FieldBundle_diagnose(is_local%wrap%FBLnd_l, trim(subname)//' FBLnd_l zero', rc=rc) call FieldBundle_diagnose(is_local%wrap%FBHyd_h, trim(subname)//' FBhyd_h zero', rc=rc) + call State_diagnose(NState_AtmImp, trim(subname)//' AtmImp ', rc=rc) call State_diagnose(NState_OcnImp, trim(subname)//' OcnImp ', rc=rc) call State_diagnose(NState_IceImp, trim(subname)//' IceImp ', rc=rc) @@ -3224,111 +3564,150 @@ subroutine MedPhase_prep_atm(gcomp, rc) ! Regrid Full Field Bundles conservatively - call fieldBundle_reset(is_local%wrap%FBOcn_a, value=czero, rc=rc) - call fieldBundle_reset(is_local%wrap%FBIce_a, value=czero, rc=rc) - call fieldBundle_reset(is_local%wrap%FBIce_if, value=czero, rc=rc) - call fieldBundle_reset(is_local%wrap%FBLnd_a, value=czero, rc=rc) - call fieldBundle_reset(is_local%wrap%FBHyd_a, value=czero, rc=rc) - !call fieldBundle_reset(is_local%wrap%FBAtmOcn_a, value=czero, rc=rc) + call fieldBundle_reset(is_local%wrap%FBOcn_a, value=czero, rc=rc) + call fieldBundle_reset(is_local%wrap%FBIce_a, value=czero, rc=rc) + call fieldBundle_reset(is_local%wrap%FBIce_if, value=czero, rc=rc) + call fieldBundle_reset(is_local%wrap%FBLnd_a, value=czero, rc=rc) + call fieldBundle_reset(is_local%wrap%FBHyd_a, value=czero, rc=rc) + +! do we need to call the following four lines? + call fieldBundle_reset(is_local%wrap%FBAtmOcn_a, value=czero, rc=rc) !BL2017b - call fieldBundle_reset(is_local%wrap%FBOcn2_a, value=czero, rc=rc) - call fieldBundle_reset(is_local%wrap%FBIce2_a, value=czero, rc=rc) - !call fieldBundle_reset(is_local%wrap%FBAtmOcn2_a, value=czero, rc=rc) + call fieldBundle_reset(is_local%wrap%FBOcn2_a, value=czero, rc=rc) + call fieldBundle_reset(is_local%wrap%FBIce2_a, value=czero, rc=rc) + call fieldBundle_reset(is_local%wrap%FBAtmOcn2_a, value=czero, rc=rc) !BL2017b if (is_local%wrap%o2a_active) then + +! if (localpet == 176) write(0,*)' in medphase_prep_atm in o2a_active at kdt=', kdt + call Fieldbundle_Regrid(fldsFrOcn, is_local%wrap%FBOcn_o, is_local%wrap%FBOcn_a, & - consfmap=is_local%wrap%RH_o2a_consf, & - consdmap=is_local%wrap%RH_o2a_consd, & - bilnrmap=is_local%wrap%RH_o2a_bilnr, & - patchmap=is_local%wrap%RH_o2a_patch, & - string='o2a', rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + consfmap=is_local%wrap%RH_o2a_consf, & + consdmap=is_local%wrap%RH_o2a_consd, & + con2fmap=is_local%wrap%RH_o2a_con2f, & + con2dmap=is_local%wrap%RH_o2a_con2d, & + bilnrmap=is_local%wrap%RH_o2a_bilnr, & + patchmap=is_local%wrap%RH_o2a_patch, & + string='o2a', rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return !BL2017b ! use the nearest neighbor method call Fieldbundle_Regrid2(fldsFrOcn, is_local%wrap%FBOcn_o, is_local%wrap%FBOcn2_a, & - nearestmap=is_local%wrap%RH_o2a_nearest, & - string='o2a_nearest', rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + nrnbrmap=is_local%wrap%RH_o2a_nrnbr, & + string='o2a_nrnbr', rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return call ESMF_FieldBundleGet(is_local%wrap%FBOcn_a, fieldCount=fieldCount, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + allocate(fieldNameList(fieldCount)) call ESMF_FieldBundleGet(is_local%wrap%FBOcn_a, fieldNameList=fieldNameList, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return do n = 1, fieldCount - call FieldBundle_GetFldPtr(is_local%wrap%FBOcn_a, fieldNameList(n),dataPtr1,rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out - - call FieldBundle_GetFldPtr(is_local%wrap%FBOcn2_a, fieldNameList(n), dataPtr2, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out - - do j=lbound(dataPtr1,2),ubound(dataPtr1,2) - do i=lbound(dataPtr1,1),ubound(dataPtr1,1) - if(dataPtr1(i,j).eq.0._ESMF_KIND_R8.and.abs(dataPtr2(i,j)).gt.0._ESMF_KIND_R8) then - dataPtr1(i,j)=dataPtr2(i,j) - endif - enddo - enddo + call FieldBundle_GetFldPtr(is_local%wrap%FBOcn_a, fieldNameList(n), dataPtr1,rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + + call FieldBundle_GetFldPtr(is_local%wrap%FBOcn2_a, fieldNameList(n), dataPtr2, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + + jl = lbound(dataPtr1,2) ; ju = ubound(dataPtr1,2) + il = lbound(dataPtr1,1) ; iu = ubound(dataPtr1,1) + + +!--------------------------------------------------------------------------------------- +! if (trim(fldsFrOcn%shortname(n)) == 'sea_surface_temperature' .and. & +! if (localpet == 171) then +! if (trim(fieldNameList(n)) == 'sea_surface_temperature' .and. kdt >= 21 .and. kdt < 30) then + +! write(0,*)' field=',fieldNameList(n),' kdt=',kdt,' localpet=',localpet, & +! ' iliu=',il,iu,' jlju=',jl,ju +! write(0,*)' dataptr1=',dataptr1(24,57), ' dataptr2=',dataptr2(24,57) +! write(0,*)' sample dataptr1=',dataptr1((il+iu)/2,(jl+ju)/2), & +! ' dataptr2=',dataptr2((il+iu)/2,(jl+ju)/2) +! write(1200+localpet,*)' kdt=',kdt +! do j=jl,ju +! write(1200+localpet,*)' dataPtr1=',dataPtr1(il:iu,j),' j=',j, & +! ' name=',trim(fieldNameList(n)) +! write(1200+localpet,*)' dataPtr2=',dataPtr2(il:iu,j),' j=',j +! enddo +! if (localpet == 176) then +! write(0,*)' dataPtr1=',dataPtr1(169,249), ' +! name=',trim(fldsFrIce%shortname(n)),' kdt=',kdt,' il=',il +! write(0,*)' dataPtr2=',dataPtr2(169,249),' n=',n,' jlju=',jl,ju, & +! ' iliu=',il,iu +! endif +! endif +!--------------------------------------------------------------------------------------- + +!$omp parallel do default(shared) private(i,j) + do j=jl, ju + do i=il, iu + if (abs(dataPtr1(i,j)) <= epsln .and. abs(dataPtr2(i,j)) > epsln) then + dataPtr1(i,j) = dataPtr2(i,j) + endif + enddo + enddo + enddo deallocate(fieldNameList) !BL2017b -! -! call Fieldbundle_Regrid(fldsAtmOcn, is_local%wrap%FBAtmOcn_o, is_local%wrap%FBAtmOcn_a, & -! consfmap=is_local%wrap%RH_o2a_consf, & -! consdmap=is_local%wrap%RH_o2a_consd, & -! bilnrmap=is_local%wrap%RH_o2a_bilnr, & -! patchmap=is_local%wrap%RH_o2a_patch, & -! string='o2aatmocn', rc=rc) -! if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & -! line=__LINE__, file=__FILE__)) return ! bail out -! -!!BL2017b -!! use the nearest neighbor method -! call Fieldbundle_Regrid2(fldsAtmOcn, is_local%wrap%FBAtmOcn_o, is_local%wrap%FBAtmOcn2_a, & -! nearestmap=is_local%wrap%RH_o2a_nearest, & -! string='atmocn_o2a_nearest', rc=rc) -! if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & -! line=__LINE__, file=__FILE__)) return ! bail out -! -! call ESMF_FieldBundleGet(is_local%wrap%FBAtmOcn_a, fieldCount=fieldCount, rc=rc) -! if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & -! line=__LINE__, file=__FILE__)) return ! bail out -! allocate(fieldNameList(fieldCount)) -! call ESMF_FieldBundleGet(is_local%wrap%FBAtmOcn_a, fieldNameList=fieldNameList, rc=rc) -! if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & -! line=__LINE__, file=__FILE__)) return ! bail out -! -! do n = 1, fieldCount -! call FieldBundle_GetFldPtr(is_local%wrap%FBAtmOcn_a, fieldNameList(n),dataPtr1,rc=rc) -! if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & -! line=__LINE__, file=__FILE__)) return ! bail out -! -! call FieldBundle_GetFldPtr(is_local%wrap%FBAtmOcn2_a, fieldNameList(n), dataPtr2, rc=rc) -! if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & -! line=__LINE__, file=__FILE__)) return ! bail out -! -! do j=lbound(dataPtr1,2),ubound(dataPtr1,2) -! do i=lbound(dataPtr1,1),ubound(dataPtr1,1) -! if(dataPtr1(i,j).eq.0._ESMF_KIND_R8.and.abs(dataPtr2(i,j)).gt.0._ESMF_KIND_R8) then -! dataPtr1(i,j)=dataPtr2(i,j) -! endif -! enddo -! enddo -! enddo -! deallocate(fieldNameList) +!tcxao +#if (2 == 3) + + call Fieldbundle_Regrid(fldsAtmOcn, is_local%wrap%FBAtmOcn_o, is_local%wrap%FBAtmOcn_a, & + consfmap=is_local%wrap%RH_o2a_consf, & + consdmap=is_local%wrap%RH_o2a_consd, & + con2fmap=is_local%wrap%RH_o2a_con2f, & + con2dmap=is_local%wrap%RH_o2a_con2d, & + bilnrmap=is_local%wrap%RH_o2a_bilnr, & + patchmap=is_local%wrap%RH_o2a_patch, & + string='o2aatmocn', rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + !BL2017b - endif +! use the nearest neighbor method + call Fieldbundle_Regrid2(fldsAtmOcn, is_local%wrap%FBAtmOcn_o, is_local%wrap%FBAtmOcn2_a, & + nrnbrmap=is_local%wrap%RH_o2a_nrnbr, & + string='atmocn_o2a_nrnbr', rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + + call ESMF_FieldBundleGet(is_local%wrap%FBAtmOcn_a, fieldCount=fieldCount, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + + allocate(fieldNameList(fieldCount)) + call ESMF_FieldBundleGet(is_local%wrap%FBAtmOcn_a, fieldNameList=fieldNameList, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + + do n = 1, fieldCount + call FieldBundle_GetFldPtr(is_local%wrap%FBAtmOcn_a, fieldNameList(n),dataPtr1,rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + + call FieldBundle_GetFldPtr(is_local%wrap%FBAtmOcn2_a, fieldNameList(n), dataPtr2, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + +!$omp parallel do default(shared) private(i,j) + do j=lbound(dataPtr1,2),ubound(dataPtr1,2) + do i=lbound(dataPtr1,1),ubound(dataPtr1,1) + if (abs(dataPtr1(i,j)) <= epsln .and. abs(dataPtr2(i,j)) > epsln) then + dataPtr1(i,j) = dataPtr2(i,j) + endif + enddo + enddo + enddo + + deallocate(fieldNameList) + +#endif + +!BL2017b + endif ! if (is_local%wrap%o2a_active) if (is_local%wrap%i2a_active) then + +! if (localpet == 276) write(0,*)' in medphase_prep_atm in i2a_active' if (FieldBundle_FldChk(is_local%wrap%FBIce_i, 'ice_fraction', rc=rc) .and. & FieldBundle_FldChk(is_local%wrap%FBIce_a, 'ice_fraction', rc=rc)) then !--- tcraig, need to weight the ice2atm regrid by the ice fraction @@ -3338,25 +3717,25 @@ subroutine MedPhase_prep_atm(gcomp, rc) !--- copy out the ifrac on ice grid call FieldBundle_GetFldPtr(is_local%wrap%FBIce_i, 'ice_fraction', dataPtr1, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + allocate(ifrac_i (lbound(dataPtr1,1):ubound(dataPtr1,1),lbound(dataPtr1,2):ubound(dataPtr1,2))) - do j=lbound(dataptr1,2),ubound(dataptr1,2) + +!$omp parallel do default(shared) private(i,j) + do j=lbound(dataptr1,2),ubound(dataptr1,2) do i=lbound(dataptr1,1),ubound(dataptr1,1) - ifrac_i(i,j) = dataPtr1(i,j) - enddo + ifrac_i(i,j) = max(czero, min(cone, dataPtr1(i,j))) enddo + enddo !BL2017b !--- need to add the nearest neighbor regridding method here - B Li - call FieldBundle_FieldRegrid(is_local%wrap%FBIce_i,'ice_fraction', & - is_local%wrap%FBIce2_a,'ice_fraction', & - is_local%wrap%RH_i2a_nearest, rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + call FieldBundle_FieldRegrid(is_local%wrap%FBIce_i, 'ice_fraction', & + is_local%wrap%FBIce2_a,'ice_fraction', & + is_local%wrap%RH_i2a_nrnbr, rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return - call FieldBundle_GetFldPtr(is_local%wrap%FBIce2_a,'ice_fraction', dataPtr5, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + call FieldBundle_GetFldPtr(is_local%wrap%FBIce2_a,'ice_fraction', dataPtr5, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return !BL2017b !--- conservative frac @@ -3364,36 +3743,38 @@ subroutine MedPhase_prep_atm(gcomp, rc) call FieldBundle_FieldRegrid(is_local%wrap%FBIce_i,'ice_fraction', & is_local%wrap%FBIce_a,'ice_fraction', & is_local%wrap%RH_i2a_consf, rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return !--- copy out the ifrac on atm grid call FieldBundle_GetFldPtr(is_local%wrap%FBIce_a, 'ice_fraction', dataPtr2, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return - do j=lbound(dataPtr2,2),ubound(dataPtr2,2) - do i=lbound(dataPtr2,1),ubound(dataPtr2,1) - if(dataPtr2(i,j).eq.0._ESMF_KIND_R8.and.abs(dataPtr5(i,j)).gt.0._ESMF_KIND_R8) then - dataPtr2(i,j) = dataPtr5(i,j) - endif - enddo + jl = lbound(dataPtr2,2) ; ju = ubound(dataPtr2,2) + il = lbound(dataPtr2,1) ; iu = ubound(dataPtr2,1) +!$omp parallel do default(shared) private(i,j) + do j=jl,ju + do i=il,iu + dataPtr2(i,j) = max(czero, min(cone, dataPtr2(i,j))) + if (dataPtr2(i,j) <= epsln .and. dataPtr5(i,j) > epsln) then + dataPtr2(i,j) = max(czero, min(cone, dataPtr5(i,j))) + endif + enddo enddo !BL2017b - allocate(ifrac_afr(lbound(dataptr2,1):ubound(dataptr2,1),lbound(dataptr2,2):ubound(dataptr2,2))) - allocate(ifrac_af (lbound(dataptr2,1):ubound(dataptr2,1),lbound(dataptr2,2):ubound(dataptr2,2))) + allocate(ifrac_afr(il:iu, jl:ju), ifrac_af(il:iu, jl:ju)) - do j=lbound(dataptr2,2),ubound(dataptr2,2) - do i=lbound(dataptr2,1),ubound(dataptr2,1) +!$omp parallel do default(shared) private(i,j) + do j=jl,ju + do i=il,iu !--- compute ice fraction on atm grid and reciprocal - ifrac_af(i,j) = dataPtr2(i,j) - if (dataPtr2(i,j) == 0._ESMF_KIND_R8) then - ifrac_afr(i,j) = 1.0_ESMF_KIND_R8 - else - ifrac_afr(i,j) = 1.0_ESMF_KIND_R8/dataPtr2(i,j) - endif - enddo + ifrac_af(i,j) = dataPtr2(i,j) + if (dataPtr2(i,j) <= epsln) then + ifrac_afr(i,j) = cone + else + ifrac_afr(i,j) = cone / dataPtr2(i,j) + endif + enddo enddo endif @@ -3402,39 +3783,99 @@ subroutine MedPhase_prep_atm(gcomp, rc) call FieldBundle_FieldRegrid(is_local%wrap%FBIce_i,'ice_fraction', & is_local%wrap%FBIce_a,'ice_fraction', & is_local%wrap%RH_i2a_consd, rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return !BL2017b !--- copy out the ifrac on atm grid call FieldBundle_GetFldPtr(is_local%wrap%FBIce_a, 'ice_fraction', dataPtr2, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + + jl = lbound(dataPtr2,2) ; ju = ubound(dataPtr2,2) + il = lbound(dataPtr2,1) ; iu = ubound(dataPtr2,1) - allocate(ifrac_adr(lbound(dataptr2,1):ubound(dataptr2,1),lbound(dataptr2,2):ubound(dataptr2,2))) - allocate(ifrac_ad (lbound(dataptr2,1):ubound(dataptr2,1),lbound(dataptr2,2):ubound(dataptr2,2))) + allocate(ifrac_adr(il:iu, jl:ju), ifrac_ad(il:iu, jl:ju)) !BL2017b - do j=lbound(dataptr2,2),ubound(dataptr2,2) - do i=lbound(dataptr2,1),ubound(dataptr2,1) - if(dataPtr2(i,j).eq.0._ESMF_KIND_R8.and.abs(dataPtr5(i,j)).gt.0._ESMF_KIND_R8) then - dataPtr2(i,j) = dataPtr5(i,j) - endif - enddo +!$omp parallel do default(shared) private(i,j) + do j=jl,ju + do i=il,iu + dataPtr2(i,j) = max(czero, min(cone, dataPtr2(i,j))) + if (dataPtr2(i,j) <= epsln .and. dataPtr5(i,j) > epsln) then + dataPtr2(i,j) = max(czero, min(cone, dataPtr5(i,j))) + endif + enddo enddo !BL2017b +!$omp parallel do default(shared) private(i,j) + do j=jl,ju + do i=il,iu + !--- compute ice fraction on atm grid and reciprocal + ifrac_ad(i,j) = dataPtr2(i,j) + if (dataPtr2(i,j) <= epsln) then + ifrac_adr(i,j) = cone + else + ifrac_adr(i,j) = cone / dataPtr2(i,j) + endif + enddo + enddo + endif + + !--- conservative 2nd order frac + if (ESMF_RouteHandleIsCreated(is_local%wrap%RH_i2a_con2f, rc=rc)) then + call FieldBundle_FieldRegrid(is_local%wrap%FBIce_i,'ice_fraction', & + is_local%wrap%FBIce_a,'ice_fraction', & + is_local%wrap%RH_i2a_con2f, rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + + !--- copy out the ifrac on atm grid + call FieldBundle_GetFldPtr(is_local%wrap%FBIce_a, 'ice_fraction', dataPtr2, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + + allocate(ifrac_agr(lbound(dataptr2,1):ubound(dataptr2,1),lbound(dataptr2,2):ubound(dataptr2,2))) + allocate(ifrac_ag (lbound(dataptr2,1):ubound(dataptr2,1),lbound(dataptr2,2):ubound(dataptr2,2))) + +!$omp parallel do default(shared) private(i,j) do j=lbound(dataptr2,2),ubound(dataptr2,2) - do i=lbound(dataptr2,1),ubound(dataptr2,1) + do i=lbound(dataptr2,1),ubound(dataptr2,1) !--- compute ice fraction on atm grid and reciprocal - ifrac_ad(i,j) = dataPtr2(i,j) - if (dataPtr2(i,j) == 0._ESMF_KIND_R8) then - ifrac_adr(i,j) = 1.0_ESMF_KIND_R8 - else - ifrac_adr(i,j) = 1.0_ESMF_KIND_R8/dataPtr2(i,j) - endif + ifrac_ag(i,j) = dataPtr2(i,j) + if (dataPtr2(i,j) <= epsln) then + ifrac_agr(i,j) = cone + else + ifrac_agr(i,j) = cone / dataPtr2(i,j) + endif + enddo enddo + endif + + !--- conservative dst + if (ESMF_RouteHandleIsCreated(is_local%wrap%RH_i2a_con2d, rc=rc)) then + call FieldBundle_FieldRegrid(is_local%wrap%FBIce_i,'ice_fraction', & + is_local%wrap%FBIce_a,'ice_fraction', & + is_local%wrap%RH_i2a_con2d, rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + + !--- copy out the ifrac on atm grid + call FieldBundle_GetFldPtr(is_local%wrap%FBIce_a, 'ice_fraction', dataPtr2, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + + allocate(ifrac_aer(lbound(dataptr2,1):ubound(dataptr2,1),lbound(dataptr2,2):ubound(dataptr2,2))) + allocate(ifrac_ae (lbound(dataptr2,1):ubound(dataptr2,1),lbound(dataptr2,2):ubound(dataptr2,2))) + +!$omp parallel do default(shared) private(i,j) + do j=lbound(dataptr2,2),ubound(dataptr2,2) + do i=lbound(dataptr2,1),ubound(dataptr2,1) + !--- compute ice fraction on atm grid and reciprocal + ifrac_ae(i,j) = dataPtr2(i,j) + if (dataPtr2(i,j) <= epsln) then + ifrac_aer(i,j) = cone + else + ifrac_aer(i,j) = cone / dataPtr2(i,j) + endif + enddo enddo endif + !BL2017b !--- the bilinear and patch interpolation methods are currently not used !--- for any export variables from ice model - B Li @@ -3444,33 +3885,28 @@ subroutine MedPhase_prep_atm(gcomp, rc) call FieldBundle_FieldRegrid(is_local%wrap%FBIce_i,'ice_fraction', & is_local%wrap%FBIce_a,'ice_fraction', & is_local%wrap%RH_i2a_bilnr, rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return !--- copy out the ifrac on ice grid and ifrac on atm grid call FieldBundle_GetFldPtr(is_local%wrap%FBIce_a, 'ice_fraction', dataPtr2, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return - allocate(ifrac_abr(lbound(dataptr2,1):ubound(dataptr2,1),lbound(dataptr2,2):ubound(dataptr2,2))) - allocate(ifrac_ab (lbound(dataptr2,1):ubound(dataptr2,1),lbound(dataptr2,2):ubound(dataptr2,2))) + jl = lbound(dataPtr2,2) ; ju = ubound(dataPtr2,2) + il = lbound(dataPtr2,1) ; iu = ubound(dataPtr2,1) - do j=lbound(dataptr1,2),ubound(dataptr1,2) - do i=lbound(dataptr1,1),ubound(dataptr1,1) - ifrac_i(i,j) = dataPtr1(i,j) - enddo - enddo - - do j=lbound(dataptr2,2),ubound(dataptr2,2) - do i=lbound(dataptr2,1),ubound(dataptr2,1) + allocate(ifrac_abr(il:iu, jl:ju), ifrac_ab(il:iu, jl:ju)) +!$omp parallel do default(shared) private(i,j) + do j=jl,ju + do i=il,iu !--- compute ice fraction on atm grid and reciprocal - ifrac_ab(i,j) = dataPtr2(i,j) - if (dataPtr2(i,j) == 0._ESMF_KIND_R8) then - ifrac_abr(i,j) = 1.0_ESMF_KIND_R8 - else - ifrac_abr(i,j) = 1.0_ESMF_KIND_R8/dataPtr2(i,j) - endif - enddo + dataPtr2(i,j) = max(czero, min(cone, dataPtr2(i,j))) + ifrac_ab(i,j) = dataPtr2(i,j) + if (dataPtr2(i,j) <= epsln) then + ifrac_abr(i,j) = cone + else + ifrac_abr(i,j) = cone / dataPtr2(i,j) + endif + enddo enddo endif @@ -3479,33 +3915,29 @@ subroutine MedPhase_prep_atm(gcomp, rc) call FieldBundle_FieldRegrid(is_local%wrap%FBIce_i,'ice_fraction', & is_local%wrap%FBIce_a,'ice_fraction', & is_local%wrap%RH_i2a_patch, rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return !--- copy out the ifrac on ice grid and ifrac on atm grid call FieldBundle_GetFldPtr(is_local%wrap%FBIce_a, 'ice_fraction', dataPtr2, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return - allocate(ifrac_apr(lbound(dataptr2,1):ubound(dataptr2,1),lbound(dataptr2,2):ubound(dataptr2,2))) - allocate(ifrac_ap (lbound(dataptr2,1):ubound(dataptr2,1),lbound(dataptr2,2):ubound(dataptr2,2))) + jl = lbound(dataPtr2,2) ; ju = ubound(dataPtr2,2) + il = lbound(dataPtr2,1) ; iu = ubound(dataPtr2,1) - do j=lbound(dataptr1,2),ubound(dataptr1,2) - do i=lbound(dataptr1,1),ubound(dataptr1,1) - ifrac_i(i,j) = dataPtr1(i,j) - enddo - enddo + allocate(ifrac_apr(il:iu, jl:ju), ifrac_ap(il:iu, jl:ju)) - do j=lbound(dataptr2,2),ubound(dataptr2,2) - do i=lbound(dataptr2,1),ubound(dataptr2,1) +!$omp parallel do default(shared) private(i,j) + do j=jl,ju + do i=il,iu !--- compute ice fraction on atm grid and reciprocal - ifrac_ap(i,j) = dataPtr2(i,j) - if (dataPtr2(i,j) == 0._ESMF_KIND_R8) then - ifrac_apr(i,j) = 1.0_ESMF_KIND_R8 - else - ifrac_apr(i,j) = 1.0_ESMF_KIND_R8/dataPtr2(i,j) - endif - enddo + dataPtr2(i,j) = max(czero, min(cone, dataPtr2(i,j))) + ifrac_ap(i,j) = dataPtr2(i,j) + if (dataPtr2(i,j) <= epsln) then + ifrac_apr(i,j) = cone + else + ifrac_apr(i,j) = cone / dataPtr2(i,j) + endif + enddo enddo endif @@ -3516,30 +3948,33 @@ subroutine MedPhase_prep_atm(gcomp, rc) FieldBundle_FldChk(is_local%wrap%FBIce_if,fldsFrIce%shortname(n), rc=rc)) then call FieldBundle_GetFldPtr(is_local%wrap%FBIce_i , fldsFrIce%shortname(n), dataPtr4, rc=rc) call FieldBundle_GetFldPtr(is_local%wrap%FBIce_if, fldsFrIce%shortname(n), dataPtr3, rc=rc) +!$omp parallel do default(shared) private(i,j) do j=lbound(dataptr3,2),ubound(dataptr3,2) - do i=lbound(dataptr3,1),ubound(dataptr3,1) - dataPtr3(i,j) = dataPtr4(i,j) * ifrac_i(i,j) - enddo + do i=lbound(dataptr3,1),ubound(dataptr3,1) + dataPtr3(i,j) = dataPtr4(i,j) * ifrac_i(i,j) + enddo enddo endif enddo + deallocate(ifrac_i) + !--- regrid FBIce_if, fields with fraction multiplied call Fieldbundle_Regrid(fldsFrIce, is_local%wrap%FBIce_if, is_local%wrap%FBIce_a, & - consfmap=is_local%wrap%RH_i2a_consf, & - consdmap=is_local%wrap%RH_i2a_consd, & - bilnrmap=is_local%wrap%RH_i2a_bilnr, & - patchmap=is_local%wrap%RH_i2a_patch, & - string='i2a', rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + consfmap=is_local%wrap%RH_i2a_consf, & + consdmap=is_local%wrap%RH_i2a_consd, & + con2fmap=is_local%wrap%RH_i2a_con2f, & + con2dmap=is_local%wrap%RH_i2a_con2d, & + bilnrmap=is_local%wrap%RH_i2a_bilnr, & + patchmap=is_local%wrap%RH_i2a_patch, & + string='i2a', rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return !BL2017b call Fieldbundle_Regrid2(fldsFrIce, is_local%wrap%FBIce_if, is_local%wrap%FBIce2_a, & - nearestmap=is_local%wrap%RH_i2a_nearest, & - string='i2a_nearest', rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + nrnbrmap=is_local%wrap%RH_i2a_nrnbr, & + string='i2a_nrnbr', rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return !BL2017b !--- divide FBIce_a by ifrac_a, interpolated ice fraction @@ -3547,136 +3982,170 @@ subroutine MedPhase_prep_atm(gcomp, rc) do n = 1,fldsFrIce%num if (FieldBundle_FldChk(is_local%wrap%FBIce_a, fldsFrIce%shortname(n), rc=rc)) then - call FieldBundle_GetFldPtr(is_local%wrap%FBIce_a, fldsFrIce%shortname(n), dataPtr3, rc=rc) + call FieldBundle_GetFldPtr(is_local%wrap%FBIce_a, fldsFrIce%shortname(n), dataPtr3, rc=rc) !BL2017b call FieldBundle_GetFldPtr(is_local%wrap%FBIce2_a, fldsFrIce%shortname(n), dataPtr4, rc=rc) - do j=lbound(dataptr3,2),ubound(dataptr3,2) - do i=lbound(dataptr3,1),ubound(dataptr3,1) - if(dataPtr3(i,j).eq.0._ESMF_KIND_R8.and.abs(dataPtr4(i,j)).gt.0._ESMF_KIND_R8) then - dataPtr3(i,j) = dataPtr4(i,j) - endif - enddo + + jl = lbound(dataPtr3,2) ; ju = ubound(dataPtr3,2) + il = lbound(dataPtr3,1) ; iu = ubound(dataPtr3,1) +!$omp parallel do default(shared) private(i,j) + do j=jl,ju + do i=il,iu + if (abs(dataPtr3(i,j)) <= epsln .and. abs(dataPtr4(i,j)) > epsln) then + dataPtr3(i,j) = dataPtr4(i,j) + endif + enddo enddo !BL2017b if (fldsFrIce%mapping(n) == "conservefrac") then - do j=lbound(dataptr3,2),ubound(dataptr3,2) - do i=lbound(dataptr3,1),ubound(dataptr3,1) - dataPtr3(i,j) = dataPtr3(i,j) * ifrac_afr(i,j) - enddo +!$omp parallel do default(shared) private(i,j) + do j=jl,ju + do i=il,iu + dataPtr3(i,j) = dataPtr3(i,j) * ifrac_afr(i,j) + enddo enddo elseif (fldsFrIce%mapping(n) == "conservedst") then - do j=lbound(dataptr3,2),ubound(dataptr3,2) - do i=lbound(dataptr3,1),ubound(dataptr3,1) - dataPtr3(i,j) = dataPtr3(i,j) * ifrac_adr(i,j) +!$omp parallel do default(shared) private(i,j) + do j=jl,ju + do i=il,iu + dataPtr3(i,j) = dataPtr3(i,j) * ifrac_adr(i,j) + enddo enddo + elseif (fldsFrIce%mapping(n) == "conserve2frac") then +!$omp parallel do default(shared) private(i,j) + do j=jl,ju + do i=il,iu + dataPtr3(i,j) = dataPtr3(i,j) * ifrac_agr(i,j) + enddo enddo - elseif (fldsFrIce%mapping(n) == 'bilinear') then - do j=lbound(dataptr3,2),ubound(dataptr3,2) - do i=lbound(dataptr3,1),ubound(dataptr3,1) - dataPtr3(i,j) = dataPtr3(i,j) * ifrac_abr(i,j) + elseif (fldsFrIce%mapping(n) == "conserve2dst") then +!$omp parallel do default(shared) private(i,j) + do j=jl,ju + do i=il,iu + dataPtr3(i,j) = dataPtr3(i,j) * ifrac_aer(i,j) + enddo enddo + elseif (fldsFrIce%mapping(n) == 'bilinear') then +!$omp parallel do default(shared) private(i,j) + do j=jl,ju + do i=il,iu + dataPtr3(i,j) = dataPtr3(i,j) * ifrac_abr(i,j) + enddo enddo elseif (fldsFrIce%mapping(n) == 'patch') then - do j=lbound(dataptr3,2),ubound(dataptr3,2) - do i=lbound(dataptr3,1),ubound(dataptr3,1) - dataPtr3(i,j) = dataPtr3(i,j) * ifrac_apr(i,j) - enddo +!$omp parallel do default(shared) private(i,j) + do j=jl,ju + do i=il,iu + dataPtr3(i,j) = dataPtr3(i,j) * ifrac_apr(i,j) + enddo enddo else call ESMF_LogWrite(trim(subname)//": mapping name error "//trim(fldsFrIce%mapping(n)), ESMF_LOGMSG_INFO, rc=rc) - rc=ESMF_FAILURE + rc = ESMF_FAILURE return endif endif + +! if (trim(fldsFrIce%shortname(n)) == 'sea_ice_surface_temperature' .and. kdt >= 24 .and. localpet == 276) then +! write(0,*)' dataPtr3=',dataPtr3(il+29,59),' name=',trim(fldsFrIce%shortname(n)),' kdt=',kdt,' il=',il +! do j=jl,ju +! write(1200+localpet,*)' dataPtr3=',dataPtr3(il:iu,j),' j=',j,' name=',trim(fldsFrIce%shortname(n)),' kdt=',kdt +! enddo +! write(0,*)' dataPtr3=',dataPtr3(222,315),' n=',n,' jlju=',jl,ju, & +! ' iliu=',il,iu,' mapping=',fldsFrIce%mapping(n) +! endif enddo + !--- make sure ifrac_a in the mapped bundle is correct call FieldBundle_GetFldPtr(is_local%wrap%FBIce_a, 'ice_fraction', dataPtr3, rc=rc) +!$omp parallel do default(shared) private(i,j) do j=lbound(dataptr3,2),ubound(dataptr3,2) - do i=lbound(dataptr3,1),ubound(dataptr3,1) - dataPtr3(i,j) = ifrac_af(i,j) - enddo + do i=lbound(dataptr3,1),ubound(dataptr3,1) + dataPtr3(i,j) = max(czero, min(cone, ifrac_ad(i,j))) + enddo enddo - deallocate(ifrac_i) - if (ESMF_RouteHandleIsCreated(is_local%wrap%RH_i2a_consf, rc=rc)) & - deallocate(ifrac_af, ifrac_afr) - if (ESMF_RouteHandleIsCreated(is_local%wrap%RH_i2a_consd, rc=rc)) & - deallocate(ifrac_ad, ifrac_adr) - if (ESMF_RouteHandleIsCreated(is_local%wrap%RH_i2a_bilnr, rc=rc)) & - deallocate(ifrac_ab, ifrac_abr) - if (ESMF_RouteHandleIsCreated(is_local%wrap%RH_i2a_patch, rc=rc)) & - deallocate(ifrac_ap, ifrac_apr) + if (ESMF_RouteHandleIsCreated(is_local%wrap%RH_i2a_consf, rc=rc)) deallocate(ifrac_af, ifrac_afr) + if (ESMF_RouteHandleIsCreated(is_local%wrap%RH_i2a_consd, rc=rc)) deallocate(ifrac_ad, ifrac_adr) + if (ESMF_RouteHandleIsCreated(is_local%wrap%RH_i2a_con2f, rc=rc)) deallocate(ifrac_ag, ifrac_agr) + if (ESMF_RouteHandleIsCreated(is_local%wrap%RH_i2a_con2d, rc=rc)) deallocate(ifrac_ae, ifrac_aer) + if (ESMF_RouteHandleIsCreated(is_local%wrap%RH_i2a_bilnr, rc=rc)) deallocate(ifrac_ab, ifrac_abr) + if (ESMF_RouteHandleIsCreated(is_local%wrap%RH_i2a_patch, rc=rc)) deallocate(ifrac_ap, ifrac_apr) else call Fieldbundle_Regrid(fldsFrIce, is_local%wrap%FBIce_i, is_local%wrap%FBIce_a, & - consfmap=is_local%wrap%RH_i2a_consf, & - consdmap=is_local%wrap%RH_i2a_consd, & - bilnrmap=is_local%wrap%RH_i2a_bilnr, & - patchmap=is_local%wrap%RH_i2a_patch, & - string='i2a', rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + consfmap=is_local%wrap%RH_i2a_consf, & + consdmap=is_local%wrap%RH_i2a_consd, & + con2fmap=is_local%wrap%RH_i2a_con2f, & + con2dmap=is_local%wrap%RH_i2a_con2d, & + bilnrmap=is_local%wrap%RH_i2a_bilnr, & + patchmap=is_local%wrap%RH_i2a_patch, & + string='i2a', rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return call Fieldbundle_Regrid2(fldsFrIce, is_local%wrap%FBIce_i, is_local%wrap%FBIce2_a, & - nearestmap=is_local%wrap%RH_i2a_nearest, & - string='i2a_nearest', rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + nrnbrmap=is_local%wrap%RH_i2a_nrnbr, & + string='i2a_nrnbr', rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return do n = 1,fldsFrIce%num - call FieldBundle_GetFldPtr(is_local%wrap%FBIce_a, fldsFrIce%shortname(n), dataPtr3, rc=rc) + call FieldBundle_GetFldPtr(is_local%wrap%FBIce_a, fldsFrIce%shortname(n), dataPtr3, rc=rc) call FieldBundle_GetFldPtr(is_local%wrap%FBIce2_a, fldsFrIce%shortname(n), dataPtr4, rc=rc) +!$omp parallel do default(shared) private(i,j) do j=lbound(dataPtr3,2),ubound(dataPtr3,2) - do i=lbound(dataPtr3,1),ubound(dataPtr3,1) - if(dataPtr3(i,j).eq.0._ESMF_KIND_R8.and.abs(dataPtr4(i,j)).gt.0._ESMF_KIND_R8) then - dataPtr3(i,j) = dataPtr4(i,j) - endif - enddo + do i=lbound(dataPtr3,1),ubound(dataPtr3,1) + if (abs(dataPtr3(i,j)) <= epsln .and. abs(dataPtr4(i,j)) > epsln) then + dataPtr3(i,j) = dataPtr4(i,j) + endif + enddo enddo enddo + endif - endif + endif ! if (is_local%wrap%i2a_active) !BL2017b -! call ESMF_FieldBundleWrite(is_local%wrap%FBIce2_a, 'fields_med_ice2.nc', & +! call ESMF_FieldBundleWrite(is_local%wrap%FBIce2_a, 'fields_med_ice2.nc', & ! singleFile=.true., overwrite=.true., timeslice=is_local%wrap%fastcntr, & ! iofmt=ESMF_IOFMT_NETCDF, rc=rc) !BL2017b if (is_local%wrap%l2a_active) then call Fieldbundle_Regrid(fldsFrLnd, is_local%wrap%FBLnd_l, is_local%wrap%FBLnd_a, & - consfmap=is_local%wrap%RH_l2a_consf, & - consdmap=is_local%wrap%RH_l2a_consd, & - bilnrmap=is_local%wrap%RH_l2a_bilnr, & - patchmap=is_local%wrap%RH_l2a_patch, & - string='l2a', rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + consfmap=is_local%wrap%RH_l2a_consf, & + consdmap=is_local%wrap%RH_l2a_consd, & + con2fmap=is_local%wrap%RH_l2a_con2f, & + con2dmap=is_local%wrap%RH_l2a_con2d, & + bilnrmap=is_local%wrap%RH_l2a_bilnr, & + patchmap=is_local%wrap%RH_l2a_patch, & + string='l2a', rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return endif if (is_local%wrap%h2a_active) then call Fieldbundle_Regrid(fldsFrHyd, is_local%wrap%FBHyd_h, is_local%wrap%FBHyd_a, & - consfmap=is_local%wrap%RH_h2a_consf, & - consdmap=is_local%wrap%RH_h2a_consd, & - bilnrmap=is_local%wrap%RH_h2a_bilnr, & - patchmap=is_local%wrap%RH_h2a_patch, & - string='h2a', rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + consfmap=is_local%wrap%RH_h2a_consf, & + consdmap=is_local%wrap%RH_h2a_consd, & + con2fmap=is_local%wrap%RH_h2a_con2f, & + con2dmap=is_local%wrap%RH_h2a_con2d, & + bilnrmap=is_local%wrap%RH_h2a_bilnr, & + patchmap=is_local%wrap%RH_h2a_patch, & + string='h2a', rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return endif if (dbug_flag > 1) then - call FieldBundle_diagnose(is_local%wrap%FBOcn_a, trim(subname)//' FBOcn_a ', rc=rc) - call FieldBundle_diagnose(is_local%wrap%FBIce_a, trim(subname)//' FBIce_a ', rc=rc) - call FieldBundle_diagnose(is_local%wrap%FBLnd_a, trim(subname)//' FBLnd_a ', rc=rc) - call FieldBundle_diagnose(is_local%wrap%FBHyd_a, trim(subname)//' FBHyd_a ', rc=rc) - !call FieldBundle_diagnose(is_local%wrap%FBAtmOcn_a, trim(subname)//' FBAtmOcn_a ', rc=rc) + call FieldBundle_diagnose(is_local%wrap%FBOcn_a, trim(subname)//' FBOcn_a ', rc=rc) + call FieldBundle_diagnose(is_local%wrap%FBIce_a, trim(subname)//' FBIce_a ', rc=rc) + call FieldBundle_diagnose(is_local%wrap%FBLnd_a, trim(subname)//' FBLnd_a ', rc=rc) + call FieldBundle_diagnose(is_local%wrap%FBHyd_a, trim(subname)//' FBHyd_a ', rc=rc) +! call FieldBundle_diagnose(is_local%wrap%FBAtmOcn_a, trim(subname)//' FBAtmOcn_a ', rc=rc) endif - call fieldBundle_copy(is_local%wrap%FBforAtm, is_local%wrap%FBOcn_a, rc=rc) - call fieldBundle_copy(is_local%wrap%FBforAtm, is_local%wrap%FBIce_a, rc=rc) - call fieldBundle_copy(is_local%wrap%FBforAtm, is_local%wrap%FBLnd_a, rc=rc) - call fieldBundle_copy(is_local%wrap%FBforAtm, is_local%wrap%FBHyd_a, rc=rc) - !call fieldBundle_copy(is_local%wrap%FBforAtm, is_local%wrap%FBAtmOcn_a, rc=rc) + call fieldBundle_copy(is_local%wrap%FBforAtm, is_local%wrap%FBOcn_a, rc=rc) + call fieldBundle_copy(is_local%wrap%FBforAtm, is_local%wrap%FBIce_a, rc=rc) + call fieldBundle_copy(is_local%wrap%FBforAtm, is_local%wrap%FBLnd_a, rc=rc) + call fieldBundle_copy(is_local%wrap%FBforAtm, is_local%wrap%FBHyd_a, rc=rc) +! call fieldBundle_copy(is_local%wrap%FBforAtm, is_local%wrap%FBAtmOcn_a, rc=rc) if (dbug_flag > 1) then call FieldBundle_diagnose(is_local%wrap%FBforAtm, trim(subname)//' FBforAtm ', rc=rc) @@ -3686,56 +4155,93 @@ subroutine MedPhase_prep_atm(gcomp, rc) ! write the fields imported from ocn to file #ifndef FRONT_FV3 call ESMF_FieldBundleWrite(is_local%wrap%FBOcn_a, 'fields_med_ocn_a.nc', & - singleFile=.true., overwrite=.true., timeslice=is_local%wrap%fastcntr, & - iofmt=ESMF_IOFMT_NETCDF, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + singleFile=.true., overwrite=overwrite_flag, & + timeslice=is_local%wrap%fastcntr, & + iofmt=ESMF_IOFMT_NETCDF, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return call ESMF_FieldBundleWrite(is_local%wrap%FBIce_a, 'fields_med_ice_a.nc', & - singleFile=.true., overwrite=.true., timeslice=is_local%wrap%fastcntr, & - iofmt=ESMF_IOFMT_NETCDF, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + singleFile=.true., overwrite=overwrite_flag, & + timeslice=is_local%wrap%fastcntr, & + iofmt=ESMF_IOFMT_NETCDF, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return #endif endif !--- check for ice fraction out of range - call FieldBundle_GetFldPtr(is_local%wrap%FBIce_a, 'ice_fraction', icewgt, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out +! call FieldBundle_GetFldPtr(is_local%wrap%FBIce_a, 'ice_fraction', icewgt, rc=rc) +! if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + +! ! FLAG icewgt > 1.0 +! write(msgString,'(A,3g17.10)')trim(subname)//trim(' FLAG icewgt>1.0'), & +! minval(icewgt),maxval(icewgt-cone),sum(icewgt) +! if(maxval(icewgt) > cone)call ESMF_LogWrite(trim(msgString), ESMF_LOGMSG_INFO, rc=rc) + + !--------------------------------------- + !--- custom calculations to atm + !--------------------------------------- + + !--- fill land mask every coupling from initial computation + +! if (generate_landmask) then +! call FieldBundle_GetFldPtr(is_local%wrap%FBforAtm, 'land_mask', dataPtr3, rc=rc) +! if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + +!!$omp parallel do default(shared) private(i,j) +! do j=lbound(dataPtr3,2),ubound(dataPtr3,2) +! do i=lbound(dataPtr3,1),ubound(dataPtr3,1) +! dataPtr3(i,j) = land_mask(i,j) +!! dataPtr3(i,j) = cone +! enddo +! enddo +! if (allocated(land_mask)) deallocate(land_mask) +!BL2017b +! else +! call ESMF_LogWrite(trim(subname)//": ERROR generate_landmask must be true ", ESMF_LOGMSG_ERROR, line=__LINE__, file=__FILE__, rc=dbrc) +! rc = ESMF_FAILURE +! return +! endif + + !--- merges + +! ice temperature field was already copied via fieldBundle_copy as they have the same name - Moorthi + +!! call fieldBundle_FieldMerge(is_local%wrap%FBforAtm ,'sea_ice_surface_temperature' , 1, & +!! is_local%wrap%FBIce_a ,'sea_ice_temperature' , rc=rc) +!! if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + +! call fieldBundle_FieldMerge(is_local%wrap%FBforAtm ,'mean_sensi_heat_flx' , 1, & +! is_local%wrap%FBIce_a ,'mean_sensi_heat_flx_atm_into_ice', rc=rc) +! if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + +! call fieldBundle_FieldMerge(is_local%wrap%FBforAtm ,'mean_laten_heat_flx' , 1, & +! is_local%wrap%FBIce_a ,'mean_laten_heat_flx_atm_into_ice', rc=rc) +! if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + +! call fieldBundle_FieldMerge(is_local%wrap%FBforAtm ,'mean_up_lw_flx' , 1, & +! is_local%wrap%FBIce_a ,'mean_up_lw_flx_ice', rc=rc) +! if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + +! call fieldBundle_FieldMerge(is_local%wrap%FBforAtm ,'mean_evap_rate' , 1, & +! is_local%wrap%FBIce_a ,'mean_evap_rate_atm_into_ice', rc=rc) +! if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return - ! FLAG icewgt > 1.0 - write(msgString,'(A,3g17.10)')trim(subname)//trim(' FLAG icewgt>1.0'), & - minval(icewgt),maxval(icewgt-1.0_ESMF_KIND_R8),sum(icewgt) - if(maxval(icewgt) .gt. 1.0_ESMF_KIND_R8)call ESMF_LogWrite(trim(msgString), ESMF_LOGMSG_INFO, rc=rc) +! call fieldBundle_FieldMerge(is_local%wrap%FBforAtm ,'mean_zonal_moment_flx' , 1, & +! is_local%wrap%FBIce_a ,'stress_on_air_ice_zonal', rc=rc) +! if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return - !--- fill land mask every coupling from initial computation +! call fieldBundle_FieldMerge(is_local%wrap%FBforAtm ,'mean_merid_moment_flx' , 1, & +! is_local%wrap%FBIce_a ,'stress_on_air_ice_merid', rc=rc) +! if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return - if (generate_landmask) then - call FieldBundle_GetFldPtr(is_local%wrap%FBforAtm, 'land_mask', dataPtr3, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out - do j=lbound(dataPtr3,2),ubound(dataPtr3,2) - do i=lbound(dataPtr3,1),ubound(dataPtr3,1) -! dataPtr3(i,j) = land_mask(i,j) - dataPtr3(i,j) = 1.0_ESMF_KIND_R8 - enddo - enddo -!BL2017b - else - call ESMF_LogWrite(trim(subname)//": ERROR generate_landmask must be true ", ESMF_LOGMSG_ERROR, line=__LINE__, file=__FILE__, rc=dbrc) - rc = ESMF_FAILURE - return - endif !--------------------------------------- !--- set export State to special value for testing !--------------------------------------- call state_reset(NState_AtmExp, value=spval, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return if (dbug_flag > 1) then call State_diagnose(NState_AtmExp, trim(subname)//' AtmExp_99 ', rc=rc) @@ -3746,31 +4252,40 @@ subroutine MedPhase_prep_atm(gcomp, rc) !--------------------------------------- call fieldBundle_copy(NState_AtmExp, is_local%wrap%FBforAtm, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return if (statewrite_flag) then ! write the fields exported to atm to file - write(msgString,'(A,i10)')trim(subname)//trim(': write field_med_to_atm '), is_local%wrap%fastcntr - call ESMF_LogWrite(trim(msgString), ESMF_LOGMSG_INFO, rc=rc) + + write(msgString,'(A,i10)')trim(subname)//trim(': write field_med_to_atm '), is_local%wrap%fastcntr + call ESMF_LogWrite(trim(msgString), ESMF_LOGMSG_INFO, rc=rc) #ifdef FV3_CPLD write(fname,'(a,i6.6)') 'field_med_to_atm_',is_local%wrap%fastcntr - call FieldBundle_RWFields_tiles('write',trim(fname),is_local%wrap%FBforAtm,rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + call FieldBundle_RWFields_tiles('write', trim(fname), is_local%wrap%FBforAtm, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return #else ! TODO: check method for DATM - call NUOPC_Write(NState_AtmExp, & - fldsToAtm%shortname(1:fldsToAtm%num), & - "field_med_to_atm_", timeslice=is_local%wrap%fastcntr, & - relaxedFlag=.true., rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out -! write(fname,'(a,i6.6)') 'field_med_to_atm_',is_local%wrap%fastcntr -! call FieldBundle_RWFields('write',trim(fname),is_local%wrap%FBforAtm,rc=rc) -! if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & -! line=__LINE__, file=__FILE__)) return ! bail out + call NUOPC_Write(NState_AtmExp, fldsToAtm%shortname(1:fldsToAtm%num), & + "field_med_to_atm_", timeslice=is_local%wrap%fastcntr, & + relaxedFlag=.true., rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + +! write(fname,'(a,i6.6)') 'field_med_to_atm_',is_local%wrap%fastcntr +! call FieldBundle_RWFields('write', trim(fname), is_local%wrap%FBforAtm, rc=rc) +! if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return #endif + +!#ifdef FRONT_FV3 +! regridwriteAtmExp_timeslice = regridwriteAtmExp_timeslice + 1 +! call ESMFPP_RegridWriteFB(is_local%wrap%FBforAtm, "med_to_atm_export_", regridwriteAtmExp_timeslice, rc=rc) +! if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return +!#else +! call NUOPC_Write(NState_AtmExp, & +! fldsToAtm%shortname(1:fldsToAtm%num), & +! "field_med_to_atm_", timeslice=is_local%wrap%fastcntr, & +! relaxedFlag=.true., rc=rc) +! if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return +!#endif endif if (dbug_flag > 1) then @@ -3802,44 +4317,28 @@ subroutine ESMFPP_RegridWriteFB(FieldBundle, fileName, timeslice, rc) rc = ESMF_SUCCESS - outGrid = ESMF_GridCreate1PeriDimUfrm( & - maxIndex=(/180,360/), & - minCornerCoord=(/0.0_ESMF_KIND_R8,-90.0_ESMF_KIND_R8/), & - maxCornerCoord=(/360.0_ESMF_KIND_R8,90.0_ESMF_KIND_R8/), & - staggerLocList=(/ESMF_STAGGERLOC_CORNER, ESMF_STAGGERLOC_CENTER/), & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out + outGrid = ESMF_GridCreate1PeriDimUfrm(maxIndex = (/360,180/), & + minCornerCoord = (/0.0_ESMF_KIND_R8,-90.0_ESMF_KIND_R8/), & + maxCornerCoord = (/360.0_ESMF_KIND_R8,90.0_ESMF_KIND_R8/), & + staggerLocList = (/ESMF_STAGGERLOC_CORNER, ESMF_STAGGERLOC_CENTER/), rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return call ESMF_FieldBundleGet(fieldBundle, fieldCount=icount, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return allocate(itemNameList(icount)) call ESMF_FieldBundleGet(fieldBundle, fieldNameList=itemNameList, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return do i = 1, icount call ESMF_LogWrite("RegridWrite Field Name Initiated: "//trim(itemNameList(i)), ESMF_LOGMSG_INFO) call ESMF_FieldBundleGet(fieldBundle, fieldName=itemNameList(i), field=field, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call ESMFPP_RegridWrite(field, outGrid, ESMF_REGRIDMETHOD_BILINEAR, & - fileName//trim(itemNameList(i))//'.nc', timeslice, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out + fileName//trim(itemNameList(i))//'.nc', timeslice, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return call ESMF_LogWrite("RegridWrite Field Name done: "//trim(itemNameList(i)), ESMF_LOGMSG_INFO) enddo @@ -3863,35 +4362,22 @@ subroutine ESMFPP_RegridWrite(inField, outGrid, regridMethod, fileName, timeslic type(ESMF_Field) :: outField outField = ESMF_FieldCreate(outGrid, typekind=ESMF_TYPEKIND_R8, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return ! For other options for the regrid operation, please refer to: ! http://www.earthsystemmodeling.org/esmf_releases/last_built/ESMF_refdoc/node5.html#SECTION050366000000000000000 call ESMF_FieldRegridStore(inField, outField, regridMethod=regridMethod, & - unmappedaction=ESMF_UNMAPPEDACTION_IGNORE, & - srcTermProcessing=srcTermProcessing_Value, & - Routehandle=rh, & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - - call ESMF_FieldRegrid(inField, outField, Routehandle=rh, & - termorderflag=ESMF_TERMORDER_SRCSEQ, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - - call ESMF_FieldWrite(outField, fileName, overwrite=.true., timeslice=timeslice, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out + unmappedaction=ESMF_UNMAPPEDACTION_IGNORE, & + srcTermProcessing=srcTermProcessing_Value, & + Routehandle=rh, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + + call ESMF_FieldRegrid(inField, outField, Routehandle=rh, & + termorderflag=ESMF_TERMORDER_SRCSEQ, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + + call ESMF_FieldWrite(outField, fileName, overwrite=overwrite_flag, timeslice=timeslice, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return rc = ESMF_SUCCESS @@ -3899,11 +4385,11 @@ end subroutine ESMFPP_RegridWrite end subroutine MedPhase_prep_atm !----------------------------------------------------------------------------- - + subroutine TimestampExport_prep_atm(gcomp, rc) type(ESMF_GridComp) :: gcomp integer, intent(out) :: rc - + ! This attaches an invalid timestamp on fields sometimes. ! Otherwise, it just sets the timestamp to the current clock. @@ -3924,26 +4410,21 @@ subroutine TimestampExport_prep_atm(gcomp, rc) ! query the Component for info call NUOPC_MediatorGet(gcomp, driverClock=driverClock, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return call ESMF_GridCompGet(gcomp, clock=clock, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return ! set the Clock to have the current time as the driverClock call ESMF_ClockGet(driverClock, currTime=currTime, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return call ESMF_ClockSet(Clock, currTime=currTime, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return ! Get the internal state from Component. nullify(is_local%wrap) call ESMF_GridCompGetInternalState(gcomp, is_local, rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return !--------------------------- ! validate all data by default @@ -3954,8 +4435,7 @@ subroutine TimestampExport_prep_atm(gcomp, rc) #else call NUOPC_UpdateTimestamp(NState_AtmExp, clock, rc=rc) #endif - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return !--------------------------- ! COLDSTART: @@ -3970,29 +4450,24 @@ subroutine TimestampExport_prep_atm(gcomp, rc) #else call NUOPC_UpdateTimestamp(NState_AtmExp, clock_invalidTimeStamp, rc=rc) #endif - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return else call ESMF_StateGet(NState_AtmExp, itemCount=fieldCount, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return allocate(fieldNameList(fieldCount)) call ESMF_StateGet(NState_AtmExp, itemNameList=fieldNameList, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return nullify(fieldList) call NUOPC_GetStateMemberLists(NState_AtmExp, fieldList=fieldList, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return do n = 1, fieldCount if (trim(fieldNameList(n))=="sea_surface_temperature") then #if ESMF_VERSION_MAJOR >= 8 - call NUOPC_SetTimestamp(fieldList(n), time_invalidTimeStamp, rc=rc) + call NUOPC_SetTimestamp(fieldList(n), time_invalidTimeStamp, rc=rc) #else - call NUOPCplus_UpdateTimestamp(fieldList(n), time_invalidTimeStamp, rc=rc) + call NUOPCplus_UpdateTimestamp(fieldList(n), time_invalidTimeStamp, rc=rc) #endif - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return endif enddo if (associated(fieldList)) deallocate(fieldList) @@ -4011,10 +4486,10 @@ end subroutine TimestampExport_prep_atm subroutine MedPhase_prep_ice(gcomp, rc) type(ESMF_GridComp) :: gcomp integer, intent(out) :: rc - + ! This Mediator phase runs before ATM and ICE are being called and ! prepares the ATM and ICE import Fields. - + ! local variables type(ESMF_Clock) :: clock type(ESMF_Time) :: time @@ -4022,7 +4497,7 @@ subroutine MedPhase_prep_ice(gcomp, rc) type(ESMF_State) :: importState, exportState type(ESMF_Field) :: field type(InternalState) :: is_local - real(ESMF_KIND_R8), pointer :: dataPtr1(:,:),dataPtr2(:,:),dataPtr3(:,:) + real(ESMF_KIND_R8), pointer :: dataPtr1(:,:), dataPtr2(:,:), dataPtr3(:,:) real(ESMF_KIND_R8), pointer :: temperature(:,:), humidity(:,:), pressure(:,:) real(ESMF_KIND_R8), pointer :: air_density(:,:) character(ESMF_MAXSTR) ,pointer :: fieldNameList(:) @@ -4032,11 +4507,11 @@ subroutine MedPhase_prep_ice(gcomp, rc) !BL2018 ! real(ESMF_KIND_R8), pointer :: temp293(:,:) ! type(ESMF_Grid) :: outGrid -! type(ESMF_Field) :: outField -! type(ESMF_Field) :: inField -! type(ESMF_Routehandle) :: rh180 +! type(ESMF_Field) :: outField +! type(ESMF_Field) :: inField +! type(ESMF_Routehandle) :: rh180 !BL2018 - + if(profile_memory) call ESMF_VMLogMemInfo("Entering "//trim(subname)) if (dbug_flag > 5) then call ESMF_LogWrite(trim(subname)//": called", ESMF_LOGMSG_INFO, rc=dbrc) @@ -4045,35 +4520,29 @@ subroutine MedPhase_prep_ice(gcomp, rc) ! query the Component for its clock, importState and exportState call ESMF_GridCompGet(gcomp, clock=clock, importState=importState, & - exportState=exportState, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out - + exportState=exportState, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + ! Get the internal state from Component. nullify(is_local%wrap) call ESMF_GridCompGetInternalState(gcomp, is_local, rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return call ESMF_ClockGet(clock,currtime=time,rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return call ESMF_TimeGet(time,timestring=timestr) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return if (dbug_flag > 1) then call ESMF_LogWrite(trim(subname)//": time = "//trim(timestr), ESMF_LOGMSG_INFO, rc=dbrc) endif if (dbug_flag > 1) then call ESMF_ClockPrint(clock, options="currTime", & - preString="-------->"//trim(subname)//" mediating for: ", & - unit=msgString, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + preString="-------->"//trim(subname)//" mediating for: ", & + unit=msgString, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return call ESMF_LogWrite(msgString, ESMF_LOGMSG_INFO, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return endif !--------------------------------------- @@ -4115,28 +4584,26 @@ subroutine MedPhase_prep_ice(gcomp, rc) !BL2018 ! call FieldBundle_GetFldPtr(is_local%wrap%FBAtm_a, 'inst_temp_height_lowest', temp293, rc=rc) ! do j = lbound(temp293,2),ubound(temp293,2) -! do i = lbound(temp293,1),ubound(temp293,1) -! temp293(i,j) = 293.0_ESMF_KIND_R8 -! enddo +! do i = lbound(temp293,1),ubound(temp293,1) +! temp293(i,j) = 293.0_ESMF_KIND_R8 +! enddo ! enddo ! Regrid to lat-lon 180*360 -! call ESMF_FieldBundleGet(is_local%wrap%FBAtm_a,& -! fieldName='inst_temp_height_lowest', & -! field=inField,rc=rc) +! call ESMF_FieldBundleGet(is_local%wrap%FBAtm_a, & +! fieldName='inst_temp_height_lowest', & +! field=inField,rc=rc) -! outGrid = ESMF_GridCreate1PeriDimUfrm( & -! maxIndex=(/180,360/), & -! minCornerCoord=(/0.0_ESMF_KIND_R8,-90.0_ESMF_KIND_R8/), & -! maxCornerCoord=(/360.0_ESMF_KIND_R8,90.0_ESMF_KIND_R8/), & -! staggerLocList=(/ESMF_STAGGERLOC_CORNER, ESMF_STAGGERLOC_CENTER/), & -! rc=rc) +! outGrid = ESMF_GridCreate1PeriDimUfrm(maxIndex=(/180,360/), & +! minCornerCoord=(/0.0_ESMF_KIND_R8,-90.0_ESMF_KIND_R8/), & +! maxCornerCoord=(/360.0_ESMF_KIND_R8,90.0_ESMF_KIND_R8/), & +! staggerLocList=(/ESMF_STAGGERLOC_CORNER, ESMF_STAGGERLOC_CENTER/), & +! rc=rc) ! outField = ESMF_FieldCreate(outGrid, typekind=ESMF_TYPEKIND_R8, rc=rc) ! call ESMF_FieldRegridStore(inField, outField,& -! regridMethod=ESMF_REGRIDMETHOD_BILINEAR,& -! unmappedaction=ESMF_UNMAPPEDACTION_IGNORE, & -! Routehandle=rh180, & -! rc=rc) +! regridMethod=ESMF_REGRIDMETHOD_BILINEAR,& +! unmappedaction=ESMF_UNMAPPEDACTION_IGNORE, & +! Routehandle=rh180, rc=rc) ! call ESMF_FieldRegrid(inField, outField, Routehandle=rh180, rc=rc) ! call ESMF_FieldWrite(outField,'field_fv3_to_latlon.nc',overwrite=.true.,rc=rc) !BL2018 @@ -4151,45 +4618,42 @@ subroutine MedPhase_prep_ice(gcomp, rc) if (is_local%wrap%a2i_active) then call Fieldbundle_Regrid(fldsFrAtm, is_local%wrap%FBAtm_a, is_local%wrap%FBAtm_i, & - consfmap=is_local%wrap%RH_a2i_consf, & - consdmap=is_local%wrap%RH_a2i_consd, & - bilnrmap=is_local%wrap%RH_a2i_bilnr, & - patchmap=is_local%wrap%RH_a2i_patch, & - string='a2i', rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + consfmap=is_local%wrap%RH_a2i_consf, & + consdmap=is_local%wrap%RH_a2i_consd, & + con2fmap=is_local%wrap%RH_a2i_con2f, & + con2dmap=is_local%wrap%RH_a2i_con2d, & + bilnrmap=is_local%wrap%RH_a2i_bilnr, & + patchmap=is_local%wrap%RH_a2i_patch, & + string='a2i', rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return !BL2017 use nearest neighbor method call Fieldbundle_Regrid2(fldsFrAtm, is_local%wrap%FBAtm_a, is_local%wrap%FBAtm2_i, & - nearestmap=is_local%wrap%RH_a2i_nearest, & - string='a2i_nearest', rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + nrnbrmap=is_local%wrap%RH_a2i_nrnbr, & + string='a2i_nrnbr', rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return call ESMF_FieldBundleGet(is_local%wrap%FBAtm_i, fieldCount=fieldCount, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return allocate(fieldNameList(fieldCount)) call ESMF_FieldBundleGet(is_local%wrap%FBAtm_i, fieldNameList=fieldNameList, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return do n = 1, fieldCount - call FieldBundle_GetFldPtr(is_local%wrap%FBAtm_i, fieldNameList(n),dataPtr1,rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out - - call FieldBundle_GetFldPtr(is_local%wrap%FBAtm2_i, fieldNameList(n), dataPtr2, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out - - do j=lbound(dataPtr1,2),ubound(dataPtr1,2) - do i=lbound(dataPtr1,1),ubound(dataPtr1,1) - if(dataPtr1(i,j).eq.0._ESMF_KIND_R8.and.abs(dataPtr2(i,j)).gt.0._ESMF_KIND_R8) then - dataPtr1(i,j)=dataPtr2(i,j) - endif - enddo - enddo + call FieldBundle_GetFldPtr(is_local%wrap%FBAtm_i, fieldNameList(n),dataPtr1,rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + + call FieldBundle_GetFldPtr(is_local%wrap%FBAtm2_i, fieldNameList(n), dataPtr2, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + +!$omp parallel do default(shared) private(i,j) + do j=lbound(dataPtr1,2),ubound(dataPtr1,2) + do i=lbound(dataPtr1,1),ubound(dataPtr1,1) + if (abs(dataPtr1(i,j)) <= epsln .and. abs(dataPtr2(i,j)) > epsln) then + dataPtr1(i,j) = dataPtr2(i,j) + endif + enddo + enddo enddo deallocate(fieldNameList) !BL2017 @@ -4197,14 +4661,15 @@ subroutine MedPhase_prep_ice(gcomp, rc) if (is_local%wrap%o2i_active) then call Fieldbundle_Regrid(fldsFrOcn, is_local%wrap%FBOcn_o, is_local%wrap%FBOcn_i, & - consfmap=is_local%wrap%RH_o2i_consf, & - consdmap=is_local%wrap%RH_o2i_consd, & - bilnrmap=is_local%wrap%RH_o2i_bilnr, & - patchmap=is_local%wrap%RH_o2i_patch, & - fcopymap=is_local%wrap%RH_o2i_fcopy, & - string='o2i', rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + consfmap=is_local%wrap%RH_o2i_consf, & + consdmap=is_local%wrap%RH_o2i_consd, & + con2fmap=is_local%wrap%RH_o2i_con2f, & + con2dmap=is_local%wrap%RH_o2i_con2d, & + bilnrmap=is_local%wrap%RH_o2i_bilnr, & + patchmap=is_local%wrap%RH_o2i_patch, & + fcopymap=is_local%wrap%RH_o2i_fcopy, & + string='o2i', rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return endif if (dbug_flag > 1) then @@ -4226,28 +4691,25 @@ subroutine MedPhase_prep_ice(gcomp, rc) !--- calculate air density for cice call FieldBundle_GetFldPtr(is_local%wrap%FBforIce, 'inst_temp_height_lowest', temperature, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return call FieldBundle_GetFldPtr(is_local%wrap%FBforIce, 'inst_pres_height_lowest', pressure, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return call FieldBundle_GetFldPtr(is_local%wrap%FBforIce, 'inst_spec_humid_height_lowest', humidity, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return call FieldBundle_GetFldPtr(is_local%wrap%FBforIce, 'air_density_height_lowest', air_density, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return +!$omp parallel do default(shared) private(i,j) do j = lbound(temperature,2),ubound(temperature,2) - do i = lbound(temperature,1),ubound(temperature,1) - if (temperature(i,j) /= 0._ESMF_KIND_R8) then - air_density(i,j) = pressure(i,j)/& - (287.058_ESMF_KIND_R8*(1._ESMF_KIND_R8+0.608_ESMF_KIND_R8*humidity(i,j))*temperature(i,j)) - else - air_density(i,j) = 0._ESMF_KIND_R8 - endif - enddo + do i = lbound(temperature,1),ubound(temperature,1) + if (temperature(i,j) > czero) then + air_density(i,j) = pressure(i,j) / & + (287.058_ESMF_KIND_R8*(cone + 0.608_ESMF_KIND_R8*humidity(i,j))*temperature(i,j)) + else + air_density(i,j) = czero + endif + enddo enddo !--------------------------------------- @@ -4255,8 +4717,7 @@ subroutine MedPhase_prep_ice(gcomp, rc) !--------------------------------------- call state_reset(NState_IceExp, value=spval, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return if (dbug_flag > 1) then call State_diagnose(NState_IceExp, trim(subname)//' IceExp_99 ', rc=rc) @@ -4267,8 +4728,7 @@ subroutine MedPhase_prep_ice(gcomp, rc) !--------------------------------------- call fieldBundle_copy(NState_IceExp, is_local%wrap%FBforIce, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return if (dbug_flag > 1) then call state_diagnose(NState_IceExp, trim(subname)//' IceExp_final ', rc=rc) @@ -4277,16 +4737,14 @@ subroutine MedPhase_prep_ice(gcomp, rc) if (statewrite_flag) then write(msgString,'(A,i10)')trim(subname)//trim(': write field_med_to_ice '), is_local%wrap%fastcntr call ESMF_LogWrite(trim(msgString), ESMF_LOGMSG_INFO, rc=rc) - ! write the fields exported to ice to file - call NUOPC_Write(NState_IceExp, & - fldsToIce%shortname(1:fldsToIce%num), & - "field_med_to_ice_", timeslice=is_local%wrap%fastcntr, & - relaxedFlag=.true., rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + call NUOPC_Write(NState_IceExp, & + fldsToIce%shortname(1:fldsToIce%num), & + "field_med_to_ice_", timeslice=is_local%wrap%fastcntr, & + relaxedFlag=.true., rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return endif - + !--------------------------------------- !--- clean up !--------------------------------------- @@ -4303,9 +4761,9 @@ end subroutine MedPhase_prep_ice subroutine MedPhase_prep_lnd(gcomp, rc) type(ESMF_GridComp) :: gcomp integer, intent(out) :: rc - + ! This Mediator phase preps land exports - + ! local variables type(ESMF_Clock) :: clock type(ESMF_Time) :: time @@ -4313,8 +4771,8 @@ subroutine MedPhase_prep_lnd(gcomp, rc) type(ESMF_State) :: importState, exportState type(ESMF_Field) :: field type(InternalState) :: is_local - character(len=*),parameter :: subname='(module_MEDIATOR:MedPhase_prep_lnd)' - + character(len=*),parameter :: subname='(module_MEDIATOR:MedPhase_prep_lnd)' + if(profile_memory) call ESMF_VMLogMemInfo("Entering "//trim(subname)) if (dbug_flag > 5) then call ESMF_LogWrite(trim(subname)//": called", ESMF_LOGMSG_INFO, rc=dbrc) @@ -4323,35 +4781,29 @@ subroutine MedPhase_prep_lnd(gcomp, rc) ! query the Component for its clock, importState and exportState call ESMF_GridCompGet(gcomp, clock=clock, importState=importState, & - exportState=exportState, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out - + exportState=exportState, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + ! Get the internal state from Component. nullify(is_local%wrap) call ESMF_GridCompGetInternalState(gcomp, is_local, rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return call ESMF_ClockGet(clock,currtime=time,rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return call ESMF_TimeGet(time,timestring=timestr) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return if (dbug_flag > 1) then call ESMF_LogWrite(trim(subname)//": time = "//trim(timestr), ESMF_LOGMSG_INFO, rc=dbrc) endif if (dbug_flag > 1) then - call ESMF_ClockPrint(clock, options="currTime", & - preString="-------->"//trim(subname)//" mediating for: ", & - unit=msgString, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + call ESMF_ClockPrint(clock, options="currTime", & + preString="-------->"//trim(subname)//" mediating for: ", & + unit=msgString, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return call ESMF_LogWrite(msgString, ESMF_LOGMSG_INFO, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return endif !--------------------------------------- @@ -4397,24 +4849,26 @@ subroutine MedPhase_prep_lnd(gcomp, rc) if (is_local%wrap%a2l_active) then call Fieldbundle_Regrid(fldsFrAtm, is_local%wrap%FBAtm_a, is_local%wrap%FBAtm_l, & - consfmap=is_local%wrap%RH_a2l_consf, & - consdmap=is_local%wrap%RH_a2l_consd, & - bilnrmap=is_local%wrap%RH_a2l_bilnr, & - patchmap=is_local%wrap%RH_a2l_patch, & - string='a2l', rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + consfmap=is_local%wrap%RH_a2l_consf, & + consdmap=is_local%wrap%RH_a2l_consd, & + con2fmap=is_local%wrap%RH_a2l_con2f, & + con2dmap=is_local%wrap%RH_a2l_con2d, & + bilnrmap=is_local%wrap%RH_a2l_bilnr, & + patchmap=is_local%wrap%RH_a2l_patch, & + string='a2l', rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return endif if (is_local%wrap%h2l_active) then call Fieldbundle_Regrid(fldsFrHyd, is_local%wrap%FBHyd_h, is_local%wrap%FBHyd_l, & - consfmap=is_local%wrap%RH_h2l_consf, & - consdmap=is_local%wrap%RH_h2l_consd, & - bilnrmap=is_local%wrap%RH_h2l_bilnr, & - patchmap=is_local%wrap%RH_h2l_patch, & - string='h2l', rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + consfmap=is_local%wrap%RH_h2l_consf, & + consdmap=is_local%wrap%RH_h2l_consd, & + con2fmap=is_local%wrap%RH_h2l_con2f, & + con2dmap=is_local%wrap%RH_h2l_con2d, & + bilnrmap=is_local%wrap%RH_h2l_bilnr, & + patchmap=is_local%wrap%RH_h2l_patch, & + string='h2l', rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return endif if (dbug_flag > 1) then @@ -4440,8 +4894,7 @@ subroutine MedPhase_prep_lnd(gcomp, rc) !--------------------------------------- call state_reset(NState_LndExp, value=spval, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return if (dbug_flag > 1) then call State_diagnose(NState_LndExp, trim(subname)//' LndExp_99 ', rc=rc) @@ -4452,8 +4905,7 @@ subroutine MedPhase_prep_lnd(gcomp, rc) !--------------------------------------- call fieldBundle_copy(NState_LndExp, is_local%wrap%FBforLnd, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return if (dbug_flag > 1) then call state_diagnose(NState_LndExp, trim(subname)//' LndExp_final ', rc=rc) @@ -4461,14 +4913,13 @@ subroutine MedPhase_prep_lnd(gcomp, rc) if (statewrite_flag) then ! write the fields exported to lnd to file - call NUOPC_Write(NState_LndExp, & - fieldNameList=fldsToLnd%shortname(1:fldsToLnd%num), & - fileNamePrefix="field_med_to_lnd_", timeslice=is_local%wrap%fastcntr, & - relaxedFlag=.true., rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + call NUOPC_Write(NState_LndExp, & + fieldNameList=fldsToLnd%shortname(1:fldsToLnd%num), & + fileNamePrefix="field_med_to_lnd_", timeslice=is_local%wrap%fastcntr, & + relaxedFlag=.true., rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return endif - + !--------------------------------------- !--- clean up !--------------------------------------- @@ -4485,7 +4936,7 @@ end subroutine MedPhase_prep_lnd subroutine MedPhase_prep_hyd(gcomp, rc) type(ESMF_GridComp) :: gcomp integer, intent(out) :: rc - + ! This Mediator phase prepares data for they hyd component ! local variables @@ -4495,7 +4946,7 @@ subroutine MedPhase_prep_hyd(gcomp, rc) type(ESMF_State) :: importState, exportState type(ESMF_Field) :: field type(InternalState) :: is_local - character(len=*),parameter :: subname='(module_MEDIATOR:MedPhase_prep_hyd)' + character(len=*),parameter :: subname='(module_MEDIATOR:MedPhase_prep_hyd)' if(profile_memory) call ESMF_VMLogMemInfo("Entering "//trim(subname)) if (dbug_flag > 5) then @@ -4505,35 +4956,29 @@ subroutine MedPhase_prep_hyd(gcomp, rc) ! query the Component for its clock, importState and exportState call ESMF_GridCompGet(gcomp, clock=clock, importState=importState, & - exportState=exportState, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + exportState=exportState, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return ! Get the internal state from Component. nullify(is_local%wrap) call ESMF_GridCompGetInternalState(gcomp, is_local, rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return call ESMF_ClockGet(clock,currtime=time,rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return call ESMF_TimeGet(time,timestring=timestr) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return if (dbug_flag > 1) then call ESMF_LogWrite(trim(subname)//": time = "//trim(timestr), ESMF_LOGMSG_INFO, rc=dbrc) endif if (dbug_flag > 1) then - call ESMF_ClockPrint(clock, options="currTime", & - preString="-------->"//trim(subname)//" mediating for: ", & - unit=msgString, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + call ESMF_ClockPrint(clock, options="currTime", & + preString="-------->"//trim(subname)//" mediating for: ", & + unit=msgString, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return call ESMF_LogWrite(msgString, ESMF_LOGMSG_INFO, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return endif !--------------------------------------- @@ -4579,24 +5024,26 @@ subroutine MedPhase_prep_hyd(gcomp, rc) if (is_local%wrap%a2h_active) then call Fieldbundle_Regrid(fldsFrAtm, is_local%wrap%FBAtm_a, is_local%wrap%FBAtm_h, & - consfmap=is_local%wrap%RH_a2h_consf, & - consdmap=is_local%wrap%RH_a2h_consd, & - bilnrmap=is_local%wrap%RH_a2h_bilnr, & - patchmap=is_local%wrap%RH_a2h_patch, & - string='a2h', rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + consfmap=is_local%wrap%RH_a2h_consf, & + consdmap=is_local%wrap%RH_a2h_consd, & + con2fmap=is_local%wrap%RH_a2h_con2f, & + con2dmap=is_local%wrap%RH_a2h_con2d, & + bilnrmap=is_local%wrap%RH_a2h_bilnr, & + patchmap=is_local%wrap%RH_a2h_patch, & + string='a2h', rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return endif if (is_local%wrap%l2h_active) then call Fieldbundle_Regrid(fldsFrLnd, is_local%wrap%FBLnd_l, is_local%wrap%FBLnd_h, & - consfmap=is_local%wrap%RH_l2h_consf, & - consdmap=is_local%wrap%RH_l2h_consd, & - bilnrmap=is_local%wrap%RH_l2h_bilnr, & - patchmap=is_local%wrap%RH_l2h_patch, & - string='l2h', rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + consfmap=is_local%wrap%RH_l2h_consf, & + consdmap=is_local%wrap%RH_l2h_consd, & + con2fmap=is_local%wrap%RH_l2h_con2f, & + con2dmap=is_local%wrap%RH_l2h_con2d, & + bilnrmap=is_local%wrap%RH_l2h_bilnr, & + patchmap=is_local%wrap%RH_l2h_patch, & + string='l2h', rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return endif if (dbug_flag > 1) then @@ -4622,8 +5069,7 @@ subroutine MedPhase_prep_hyd(gcomp, rc) !--------------------------------------- call state_reset(NState_HydExp, value=spval, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return if (dbug_flag > 1) then call State_diagnose(NState_HydExp, trim(subname)//' HydExp_99 ', rc=rc) @@ -4634,8 +5080,7 @@ subroutine MedPhase_prep_hyd(gcomp, rc) !--------------------------------------- call fieldBundle_copy(NState_HydExp, is_local%wrap%FBforHyd, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return if (dbug_flag > 1) then call state_diagnose(NState_HydExp, trim(subname)//' HydExp_final ', rc=rc) @@ -4643,14 +5088,13 @@ subroutine MedPhase_prep_hyd(gcomp, rc) if (statewrite_flag) then ! write the fields exported to hyd to file - call NUOPC_Write(NState_HydExp, & - fieldNameList=fldsToHyd%shortname(1:fldsToHyd%num), & - fileNamePrefix="field_med_to_hyd_", timeslice=is_local%wrap%fastcntr, & - relaxedFlag=.true., rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + call NUOPC_Write(NState_HydExp, & + fieldNameList=fldsToHyd%shortname(1:fldsToHyd%num), & + fileNamePrefix="field_med_to_hyd_", timeslice=is_local%wrap%fastcntr, & + relaxedFlag=.true., rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return endif - + !--------------------------------------- !--- clean up !--------------------------------------- @@ -4667,39 +5111,20 @@ end subroutine MedPhase_prep_hyd subroutine MedPhase_fast_after(gcomp, rc) type(ESMF_GridComp) :: gcomp integer, intent(out) :: rc - + ! local variables - type(ESMF_Clock) :: clock - type(ESMF_Time) :: time - character(len=64) :: timestr - type(ESMF_State) :: importState, exportState - type(InternalState) :: is_local - integer :: i,j,n - real(ESMF_KIND_R8), pointer :: zbot(:,:),ubot(:,:),vbot(:,:),thbot(:,:), & - qbot(:,:),rbot(:,:),tbot(:,:), pbot(:,:) - real(ESMF_KIND_R8), pointer :: us (:,:),vs (:,:),ts (:,:),mask(:,:) - real(ESMF_KIND_R8), pointer :: sen (:,:),lat (:,:),lwup(:,:),evap(:,:), & - taux(:,:),tauy(:,:),tref(:,:),qref(:,:),duu10n(:,:) - real(ESMF_KIND_R8) :: zbot1(1),ubot1(1),vbot1(1),thbot1(1), & - qbot1(1),rbot1(1),tbot1(1) - integer :: mask1(1) - real(ESMF_KIND_R8) :: us1 (1),vs1 (1),ts1 (1) - real(ESMF_KIND_R8) :: sen1 (1),lat1 (1),lwup1(1),evap1(1), & - taux1(1),tauy1(1),tref1(1),qref1(1),duu10n1(1) - character(len=*),parameter :: subname='(module_MEDIATOR:MedPhase_fast_after)' - + character(len=*), parameter :: subname='(module_MEDIATOR:MedPhase_fast_after)' + if(profile_memory) call ESMF_VMLogMemInfo("Entering "//trim(subname)) if (dbug_flag > 5) then call ESMF_LogWrite(trim(subname)//": called", ESMF_LOGMSG_INFO, rc=dbrc) endif rc = ESMF_SUCCESS - + call MedPhase_atm_ocn_flux(gcomp,rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return call MedPhase_accum_fast(gcomp,rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return if (dbug_flag > 5) then call ESMF_LogWrite(trim(subname)//": done", ESMF_LOGMSG_INFO, rc=dbrc) @@ -4713,7 +5138,7 @@ end subroutine MedPhase_fast_after subroutine MedPhase_accum_fast(gcomp, rc) type(ESMF_GridComp) :: gcomp integer, intent(out) :: rc - + ! local variables type(ESMF_Clock) :: clock type(ESMF_Time) :: time @@ -4721,45 +5146,39 @@ subroutine MedPhase_accum_fast(gcomp, rc) type(ESMF_State) :: importState, exportState type(InternalState) :: is_local integer :: i,j,n - character(len=128) :: fname - character(len=*),parameter :: subname='(module_MEDIATOR:MedPhase_accum_fast)' - + character(len=128) :: fname + character(len=*),parameter :: subname='(module_MEDIATOR:MedPhase_accum_fast)' + if (dbug_flag > 5) then call ESMF_LogWrite(trim(subname)//": called", ESMF_LOGMSG_INFO, rc=dbrc) endif rc = ESMF_SUCCESS - + ! query the Component for its clock, importState and exportState call ESMF_GridCompGet(gcomp, clock=clock, importState=importState, & - exportState=exportState, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out - + exportState=exportState, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + ! Get the internal state from Component. nullify(is_local%wrap) call ESMF_GridCompGetInternalState(gcomp, is_local, rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return call ESMF_ClockGet(clock,currtime=time,rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return call ESMF_TimeGet(time,timestring=timestr) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return if (dbug_flag > 1) then call ESMF_LogWrite(trim(subname)//": time = "//trim(timestr), ESMF_LOGMSG_INFO, rc=dbrc) endif if (dbug_flag > 1) then - call ESMF_ClockPrint(clock, options="currTime", & - preString="-------->"//trim(subname)//" mediating for: ", & - unit=msgString, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + call ESMF_ClockPrint(clock, options="currTime", & + preString="-------->"//trim(subname)//" mediating for: ", & + unit=msgString, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return call ESMF_LogWrite(msgString, ESMF_LOGMSG_INFO, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return endif if (statewrite_flag) then @@ -4768,47 +5187,43 @@ subroutine MedPhase_accum_fast(gcomp, rc) call ESMF_LogWrite(trim(msgString), ESMF_LOGMSG_INFO, rc=rc) #ifdef FV3_CPLD write(fname,'(a,i6.6)') 'field_med_from_atm_',is_local%wrap%fastcntr - call FieldBundle_RWFields_tiles('write',trim(fname),is_local%wrap%FBAtm_a,rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + call FieldBundle_RWFields_tiles('write', trim(fname), is_local%wrap%FBAtm_a, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return #else ! TODO: check method for DATM - call NUOPC_Write(NState_AtmImp, & - fldsFrAtm%shortname(1:fldsFrAtm%num), & - "field_med_from_atm_", timeslice=is_local%wrap%fastcntr, & - relaxedFlag=.true., rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out -! write(fname,'(a,i6.6)') 'field_med_from_atm_',is_local%wrap%fastcntr -! call FieldBundle_RWFields('write',trim(fname),is_local%wrap%FBAtm_a,rc=rc) -! if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & -! line=__LINE__, file=__FILE__)) return ! bail out + call NUOPC_Write(NState_AtmImp, fldsFrAtm%shortname(1:fldsFrAtm%num), & + "field_med_from_atm_", timeslice=is_local%wrap%fastcntr, & + relaxedFlag=.true., rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + +! write(fname,'(a,i6.6)') 'field_med_from_atm_',is_local%wrap%fastcntr +! call FieldBundle_RWFields('write', trim(fname), is_local%wrap%FBAtm_a, rc=rc) +! if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return #endif + ! write the fields imported from ice to file write(msgString,'(A,i10)')trim(subname)//trim(': write field_med_from_ice '), is_local%wrap%fastcntr call ESMF_LogWrite(trim(msgString), ESMF_LOGMSG_INFO, rc=rc) - call NUOPC_Write(NState_IceImp, & - fldsFrIce%shortname(1:fldsFrIce%num), & - "field_med_from_ice_", timeslice=is_local%wrap%fastcntr, & - relaxedFlag=.true., rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + + call NUOPC_Write(NState_IceImp, & + fldsFrIce%shortname(1:fldsFrIce%num), & + "field_med_from_ice_", timeslice=is_local%wrap%fastcntr, & + relaxedFlag=.true., rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return ! write the fields imported from lnd to file - call NUOPC_Write(NState_LndImp, & - fieldNameList=fldsFrLnd%shortname(1:fldsFrLnd%num), & - fileNamePrefix="field_med_from_lnd_", timeslice=is_local%wrap%fastcntr, & - relaxedFlag=.true., rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + call NUOPC_Write(NState_LndImp, & + fieldNameList=fldsFrLnd%shortname(1:fldsFrLnd%num), & + fileNamePrefix="field_med_from_lnd_", timeslice=is_local%wrap%fastcntr, & + relaxedFlag=.true., rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return ! write the fields imported from hyd to file - call NUOPC_Write(NState_HydImp, & - fieldNameList=fldsFrHyd%shortname(1:fldsFrHyd%num), & - fileNamePrefix="field_med_from_hyd_", timeslice=is_local%wrap%fastcntr, & - relaxedFlag=.true., rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + call NUOPC_Write(NState_HydImp, & + fieldNameList=fldsFrHyd%shortname(1:fldsFrHyd%num), & + fileNamePrefix="field_med_from_hyd_", timeslice=is_local%wrap%fastcntr, & + relaxedFlag=.true., rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return endif !--------------------------------------- @@ -4820,43 +5235,38 @@ subroutine MedPhase_accum_fast(gcomp, rc) call State_diagnose(NState_IceImp, trim(subname)//' IceImp ', rc=rc) call State_diagnose(NState_LndImp, trim(subname)//' LndImp ', rc=rc) call State_diagnose(NState_HydImp, trim(subname)//' HydImp ', rc=rc) - call FieldBundle_diagnose(is_local%wrap%FBaccumAtm, trim(subname)//' FBaccAtm_B4accum ', rc=rc) - call FieldBundle_diagnose(is_local%wrap%FBaccumIce, trim(subname)//' FBaccIce_B4accum ', rc=rc) - call FieldBundle_diagnose(is_local%wrap%FBaccumLnd, trim(subname)//' FBaccLnd_B4accum ', rc=rc) - call FieldBundle_diagnose(is_local%wrap%FBaccumHyd, trim(subname)//' FBaccHyd_B4accum ', rc=rc) + call FieldBundle_diagnose(is_local%wrap%FBaccumAtm, trim(subname)//' FBaccAtm_B4accum ', rc=rc) + call FieldBundle_diagnose(is_local%wrap%FBaccumIce, trim(subname)//' FBaccIce_B4accum ', rc=rc) + call FieldBundle_diagnose(is_local%wrap%FBaccumLnd, trim(subname)//' FBaccLnd_B4accum ', rc=rc) + call FieldBundle_diagnose(is_local%wrap%FBaccumHyd, trim(subname)//' FBaccHyd_B4accum ', rc=rc) call FieldBundle_diagnose(is_local%wrap%FBaccumAtmOcn, trim(subname)//' FBaccAtmOcn_B4accum ', rc=rc) endif call fieldBundle_accum(is_local%wrap%FBaccumAtm, NState_AtmImp, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return is_local%wrap%accumcntAtm = is_local%wrap%accumcntAtm + 1 call fieldBundle_accum(is_local%wrap%FBaccumIce, NState_IceImp, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return is_local%wrap%accumcntIce = is_local%wrap%accumcntIce + 1 call fieldBundle_accum(is_local%wrap%FBaccumLnd, NState_LndImp, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return is_local%wrap%accumcntLnd = is_local%wrap%accumcntLnd + 1 call fieldBundle_accum(is_local%wrap%FBaccumHyd, NState_HydImp, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return is_local%wrap%accumcntHyd = is_local%wrap%accumcntHyd + 1 - call fieldBundle_accum(is_local%wrap%FBaccumAtmOcn, is_local%wrap%FBAtmOcn_o, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + call fieldBundle_accum(is_local%wrap%FBaccumAtmOcn, is_local%wrap%FBAtmOcn_o, rc=rc) ! Do we need this? Moorthi + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return is_local%wrap%accumcntAtmOcn = is_local%wrap%accumcntAtmOcn + 1 if (dbug_flag > 1) then - call FieldBundle_diagnose(is_local%wrap%FBaccumAtm, trim(subname)//' FBaccAtm_AFaccum ', rc=rc) - call FieldBundle_diagnose(is_local%wrap%FBaccumIce, trim(subname)//' FBaccIce_AFaccum ', rc=rc) - call FieldBundle_diagnose(is_local%wrap%FBaccumLnd, trim(subname)//' FBaccLnd_AFaccum ', rc=rc) - call FieldBundle_diagnose(is_local%wrap%FBaccumHyd, trim(subname)//' FBaccHyd_AFaccum ', rc=rc) + call FieldBundle_diagnose(is_local%wrap%FBaccumAtm, trim(subname)//' FBaccAtm_AFaccum ', rc=rc) + call FieldBundle_diagnose(is_local%wrap%FBaccumIce, trim(subname)//' FBaccIce_AFaccum ', rc=rc) + call FieldBundle_diagnose(is_local%wrap%FBaccumLnd, trim(subname)//' FBaccLnd_AFaccum ', rc=rc) + call FieldBundle_diagnose(is_local%wrap%FBaccumHyd, trim(subname)//' FBaccHyd_AFaccum ', rc=rc) call FieldBundle_diagnose(is_local%wrap%FBaccumAtmOcn, trim(subname)//' FBaccAtmOcn_AFaccum ', rc=rc) endif @@ -4881,7 +5291,7 @@ end subroutine MedPhase_accum_fast subroutine MedPhase_atm_ocn_flux(gcomp, rc) type(ESMF_GridComp) :: gcomp integer, intent(out) :: rc - + ! local variables type(ESMF_Clock) :: clock type(ESMF_Time) :: time @@ -4906,45 +5316,39 @@ subroutine MedPhase_atm_ocn_flux(gcomp, rc) real(ESMF_KIND_R8), pointer :: zbot2(:,:),ubot2(:,:),vbot2(:,:) real(ESMF_KIND_R8), pointer :: tbot2(:,:),pbot2(:,:),qbot2(:,:) !BL2017 - character(len=*),parameter :: subname='(module_MEDIATOR:MedPhase_atm_ocn_flux)' - + character(len=*), parameter :: subname='(module_MEDIATOR:MedPhase_atm_ocn_flux)' + if (dbug_flag > 5) then call ESMF_LogWrite(trim(subname)//": called", ESMF_LOGMSG_INFO, rc=dbrc) endif rc = ESMF_SUCCESS - + ! query the Component for its clock, importState and exportState call ESMF_GridCompGet(gcomp, clock=clock, importState=importState, & - exportState=exportState, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out - + exportState=exportState, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call ESMF_ClockGet(clock,currtime=time,rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return call ESMF_TimeGet(time,timestring=timestr) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return if (dbug_flag > 1) then call ESMF_LogWrite(trim(subname)//": time = "//trim(timestr), ESMF_LOGMSG_INFO, rc=dbrc) endif if (dbug_flag > 1) then - call ESMF_ClockPrint(clock, options="currTime", & - preString="-------->"//trim(subname)//" mediating for: ", & - unit=msgString, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + call ESMF_ClockPrint(clock, options="currTime", & + preString="-------->"//trim(subname)//" mediating for: ", & + unit=msgString, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return call ESMF_LogWrite(msgString, ESMF_LOGMSG_INFO, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return endif ! Get the internal state from Component. nullify(is_local%wrap) call ESMF_GridCompGetInternalState(gcomp, is_local, rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return !--------------------------------------- !--- compute atm/ocn fluxes @@ -4952,212 +5356,193 @@ subroutine MedPhase_atm_ocn_flux(gcomp, rc) call fieldBundle_reset(is_local%wrap%FBAtmOcn_o, value=czero, rc=rc) !BL2017 - call fieldBundle_reset(is_local%wrap%FBAtm_o, value=czero, rc=rc) - call fieldBundle_reset(is_local%wrap%FBAtm2_o, value=czero, rc=rc) + call fieldBundle_reset(is_local%wrap%FBAtm_o, value=czero, rc=rc) + call fieldBundle_reset(is_local%wrap%FBAtm2_o, value=czero, rc=rc) !BL2017 - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return !--- atm fields on ocean grid input if (is_local%wrap%a2o_active) then - + if (dbug_flag > 1) then call ESMF_LogWrite(trim(subname)//' calling FBRegrid FBAtm_a to FBAtm_o', ESMF_LOGMSG_INFO, rc=rc) endif call FieldBundle_Regrid(fldsFrAtm, is_local%wrap%FBAtm_a, is_local%wrap%FBAtm_o, & - consfmap=is_local%wrap%RH_a2o_consf, & - consdmap=is_local%wrap%RH_a2o_consd, & - bilnrmap=is_local%wrap%RH_a2o_bilnr, & -! patchmap=is_local%wrap%RH_a2o_patch, & - string='a2oflx', rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + consfmap=is_local%wrap%RH_a2o_consf, & + consdmap=is_local%wrap%RH_a2o_consd, & + con2fmap=is_local%wrap%RH_a2o_con2f, & + con2dmap=is_local%wrap%RH_a2o_con2d, & + bilnrmap=is_local%wrap%RH_a2o_bilnr, & +! patchmap=is_local%wrap%RH_a2o_patch, & + string='a2oflx', rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return !BL2017 use nearest neighbor method call FieldBundle_Regrid2(fldsFrAtm, is_local%wrap%FBAtm_a, is_local%wrap%FBAtm2_o, & - nearestmap=is_local%wrap%RH_a2o_nearest, & - string='a2oflx_nearest', rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + nrnbrmap=is_local%wrap%RH_a2o_nrnbr, & + string='a2oflx_nrnbr', rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return call ESMF_FieldBundleGet(is_local%wrap%FBAtm_o, fieldCount=fieldCount, rc=rc) allocate(fieldNameList(fieldCount)) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return call FieldBundle_GetFldPtr(is_local%wrap%FBAtm_o, 'inst_height_lowest', zbot, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return call FieldBundle_GetFldPtr(is_local%wrap%FBAtm2_o, 'inst_height_lowest', zbot2, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return -! write(msgString,'(A,3g14.7)') trim(subname)//':'//trim(fieldNameList(1)), & -! minval(zbot2),maxval(zbot2),sum(zbot2) -! call ESMF_LogWrite(trim(msgString), ESMF_LOGMSG_INFO, rc=dbrc) +! write(msgString,'(A,3g14.7)') trim(subname)//':'//trim(fieldNameList(1)), & +! minval(zbot2),maxval(zbot2),sum(zbot2) +! call ESMF_LogWrite(trim(msgString), ESMF_LOGMSG_INFO, rc=dbrc) -! write(msgString,'(A,3g14.7)') trim(subname)//':'//trim(fieldNameList(1)), & -! minval(zbot),maxval(zbot),sum(zbot) -! call ESMF_LogWrite(trim(msgString), ESMF_LOGMSG_INFO, rc=dbrc) +! write(msgString,'(A,3g14.7)') trim(subname)//':'//trim(fieldNameList(1)), & +! minval(zbot),maxval(zbot),sum(zbot) +! call ESMF_LogWrite(trim(msgString), ESMF_LOGMSG_INFO, rc=dbrc) - call FieldBundle_GetFldPtr(is_local%wrap%FBAtm_o, 'inst_temp_height_lowest', tbot, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out - call FieldBundle_GetFldPtr(is_local%wrap%FBAtm2_o, 'inst_temp_height_lowest', tbot2, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + call FieldBundle_GetFldPtr(is_local%wrap%FBAtm_o, 'inst_temp_height_lowest', tbot, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call FieldBundle_GetFldPtr(is_local%wrap%FBAtm2_o, 'inst_temp_height_lowest', tbot2, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return - call FieldBundle_GetFldPtr(is_local%wrap%FBAtm_o, 'inst_zonal_wind_height_lowest', ubot, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out - call FieldBundle_GetFldPtr(is_local%wrap%FBAtm2_o, 'inst_zonal_wind_height_lowest',ubot2, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + call FieldBundle_GetFldPtr(is_local%wrap%FBAtm_o, 'inst_zonal_wind_height_lowest', ubot, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return - call FieldBundle_GetFldPtr(is_local%wrap%FBAtm_o, 'inst_merid_wind_height_lowest', vbot, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out - call FieldBundle_GetFldPtr(is_local%wrap%FBAtm2_o, 'inst_merid_wind_height_lowest',vbot2, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + call FieldBundle_GetFldPtr(is_local%wrap%FBAtm2_o, 'inst_zonal_wind_height_lowest',ubot2, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return - call FieldBundle_GetFldPtr(is_local%wrap%FBAtm_o, 'inst_pres_height_lowest', pbot, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out - call FieldBundle_GetFldPtr(is_local%wrap%FBAtm2_o, 'inst_pres_height_lowest', pbot2, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + call FieldBundle_GetFldPtr(is_local%wrap%FBAtm_o, 'inst_merid_wind_height_lowest', vbot, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return - call FieldBundle_GetFldPtr(is_local%wrap%FBAtm_o, 'inst_spec_humid_height_lowest', qbot, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out - call FieldBundle_GetFldPtr(is_local%wrap%FBAtm2_o, 'inst_spec_humid_height_lowest',qbot2, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + call FieldBundle_GetFldPtr(is_local%wrap%FBAtm2_o, 'inst_merid_wind_height_lowest',vbot2, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return - do j=lbound(zbot,2),ubound(zbot,2) - do i=lbound(zbot,1),ubound(zbot,1) - if(tbot(i,j).eq.0._ESMF_KIND_R8.and.abs(tbot2(i,j)).gt.0._ESMF_KIND_R8) then - zbot(i,j)=zbot2(i,j) - tbot(i,j)=tbot2(i,j) - ubot(i,j)=ubot2(i,j) - vbot(i,j)=vbot2(i,j) - qbot(i,j)=qbot2(i,j) - pbot(i,j)=pbot2(i,j) - endif - enddo - enddo - deallocate(fieldNameList) + call FieldBundle_GetFldPtr(is_local%wrap%FBAtm_o, 'inst_pres_height_lowest', pbot, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + + call FieldBundle_GetFldPtr(is_local%wrap%FBAtm2_o, 'inst_pres_height_lowest', pbot2, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + + call FieldBundle_GetFldPtr(is_local%wrap%FBAtm_o, 'inst_spec_humid_height_lowest', qbot, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + + call FieldBundle_GetFldPtr(is_local%wrap%FBAtm2_o, 'inst_spec_humid_height_lowest',qbot2, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + +!$omp parallel do default(shared) private(i,j) + do j=lbound(zbot,2),ubound(zbot,2) + do i=lbound(zbot,1),ubound(zbot,1) + if(tbot(i,j) <= epsln .and. tbot2(i,j) > epsln ) then + zbot(i,j) = zbot2(i,j) + tbot(i,j) = tbot2(i,j) + ubot(i,j) = ubot2(i,j) + vbot(i,j) = vbot2(i,j) + qbot(i,j) = qbot2(i,j) + pbot(i,j) = pbot2(i,j) + endif + enddo + enddo + deallocate(fieldNameList) !BL2017 endif call FieldBundle_GetFldPtr(is_local%wrap%FBAtm_o, 'inst_height_lowest', zbot, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return call FieldBundle_GetFldPtr(is_local%wrap%FBAtm_o, 'inst_zonal_wind_height_lowest', ubot, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return call FieldBundle_GetFldPtr(is_local%wrap%FBAtm_o, 'inst_merid_wind_height_lowest', vbot, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out -! call FieldBundle_GetFldPtr(is_local%wrap%FBAtm_o, 'inst_pot_temp_height_lowest', thbot, rc=rc) -! if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & -! line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return +! call FieldBundle_GetFldPtr(is_local%wrap%FBAtm_o, 'inst_pot_temp_height_lowest', thbot, rc=rc) +! if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return call FieldBundle_GetFldPtr(is_local%wrap%FBAtm_o, 'inst_spec_humid_height_lowest', qbot, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out -! call FieldBundle_GetFldPtr(is_local%wrap%FBAtm_o, 'inst_density_height_lowest', rbot, rc=rc) -! if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & -! line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return +! call FieldBundle_GetFldPtr(is_local%wrap%FBAtm_o, 'inst_density_height_lowest', rbot, rc=rc) +! if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return call FieldBundle_GetFldPtr(is_local%wrap%FBAtm_o, 'inst_temp_height_lowest', tbot, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return call FieldBundle_GetFldPtr(is_local%wrap%FBAtm_o, 'inst_pres_height_lowest', pbot, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return !--- ocean fields input call FieldBundle_GetFldPtr(is_local%wrap%FBOcn_o, 'ocean_mask', mask, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return call FieldBundle_GetFldPtr(is_local%wrap%FBOcn_o, 'ocn_current_zonal', us, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return call FieldBundle_GetFldPtr(is_local%wrap%FBOcn_o, 'ocn_current_merid', vs, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return call FieldBundle_GetFldPtr(is_local%wrap%FBOcn_o, 'sea_surface_temperature', ts, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return !--- atm/ocn fluxes output call FieldBundle_GetFldPtr(is_local%wrap%FBAtmOcn_o, 'mean_up_lw_flx_ocn', lwup, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return call FieldBundle_GetFldPtr(is_local%wrap%FBAtmOcn_o, 'mean_sensi_heat_flx_atm_into_ocn', sen, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return call FieldBundle_GetFldPtr(is_local%wrap%FBAtmOcn_o, 'mean_laten_heat_flx_atm_into_ocn', lat, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return call FieldBundle_GetFldPtr(is_local%wrap%FBAtmOcn_o, 'mean_evap_rate_atm_into_ocn', evap, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return call FieldBundle_GetFldPtr(is_local%wrap%FBAtmOcn_o, 'stress_on_air_ocn_zonal', taux, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return call FieldBundle_GetFldPtr(is_local%wrap%FBAtmOcn_o, 'stress_on_air_ocn_merid', tauy, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return call FieldBundle_GetFldPtr(is_local%wrap%FBAtmOcn_o, 'temperature_2m', tref, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return call FieldBundle_GetFldPtr(is_local%wrap%FBAtmOcn_o, 'humidity_2m', qref, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return call FieldBundle_GetFldPtr(is_local%wrap%FBAtmOcn_o, 'wind_speed_squared_10m', duu10n, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return !--- flux calculation do j=lbound(zbot,2),ubound(zbot,2) - do i=lbound(zbot,1),ubound(zbot,1) - zbot1(1) = zbot(i,j) - ubot1(1) = ubot(i,j) - vbot1(1) = vbot(i,j) - if(pbot(i,j) .gt. 0.0) & - thbot1(1) = tbot(i,j)*((100000._ESMF_KIND_R8/pbot(i,j))**0.286_ESMF_KIND_R8) ! tcx temporary + do i=lbound(zbot,1),ubound(zbot,1) + if (pbot(i,j) > 10000.0) then + zbot1(1) = zbot(i,j) + ubot1(1) = ubot(i,j) + vbot1(1) = vbot(i,j) + thbot1(1) = tbot(i,j)*((100000._ESMF_KIND_R8/pbot(i,j))**0.286_ESMF_KIND_R8) ! tcx temporary !tcx thbot1(1) = thbot(i,j) - qbot1(1) = qbot(i,j) - if(tbot(i,j) .gt. 0.0) & - rbot1(1) = pbot(i,j)/(287.058_ESMF_KIND_R8*(1._ESMF_KIND_R8+0.608_ESMF_KIND_R8*qbot(i,j))*tbot(i,j)) ! tcx temporary + qbot1(1) = qbot(i,j) + rbot1(1) = pbot(i,j)/(287.058_ESMF_KIND_R8*(cone+0.608_ESMF_KIND_R8*qbot(i,j))*tbot(i,j)) ! tcx temporary !tcx rbot1(1) = rbot(i,j) - tbot1(1) = tbot(i,j) - us1(1) = us(i,j) - vs1(1) = vs(i,j) - ts1(1) = ts(i,j) - - mask1(1) = nint(mask(i,j)) - call shr_flux_atmOcn(1 ,zbot1(1) ,ubot1(1) ,vbot1(1) ,thbot1(1) , & - qbot1(1) ,rbot1(1) ,tbot1(1) ,us1(1) ,vs1(1) , & - ts1(1) ,mask1(1) ,sen1(1) ,lat1(1) ,lwup1(1) , & -! evap1(1) ,taux1(1) ,tauy1(1) ,tref1(1) ,qref1(1) ,duu10n1(1)) + tbot1(1) = tbot(i,j) + us1(1) = us(i,j) + vs1(1) = vs(i,j) + ts1(1) = ts(i,j) + + mask1(1) = nint(mask(i,j)) + call shr_flux_atmOcn(1 ,zbot1(1) ,ubot1(1) ,vbot1(1) ,thbot1(1) , & + qbot1(1) ,rbot1(1) ,tbot1(1) ,us1(1) ,vs1(1) , & + ts1(1) ,mask1(1) ,sen1(1) ,lat1(1) ,lwup1(1) , & +! evap1(1) ,taux1(1) ,tauy1(1) ,tref1(1) ,qref1(1) ,duu10n1(1)) !tcx include this for the time being to get over the initialization hump - evap1(1) ,taux1(1) ,tauy1(1) ,tref1(1) ,qref1(1) ,duu10n1(1), & - missval = 0.0_ESMF_KIND_R8 ) - sen(i,j) = sen1(1) - lat(i,j) = lat1(1) - lwup(i,j) = lwup1(1) - evap(i,j) = evap1(1) - taux(i,j) = taux1(1) - tauy(i,j) = tauy1(1) - tref(i,j) = tref1(1) - qref(i,j) = qref1(1) - duu10n(i,j) = duu10n1(1) - enddo + evap1(1) ,taux1(1) ,tauy1(1) ,tref1(1) ,qref1(1) ,duu10n1(1), & + missval = czero ) + sen(i,j) = sen1(1) + lat(i,j) = lat1(1) + lwup(i,j) = lwup1(1) + evap(i,j) = evap1(1) + taux(i,j) = taux1(1) + tauy(i,j) = tauy1(1) + tref(i,j) = tref1(1) + qref(i,j) = qref1(1) + duu10n(i,j) = duu10n1(1) + else + sen(i,j) = czero + lat(i,j) = czero + lwup(i,j) = czero + evap(i,j) = czero + taux(i,j) = czero + tauy(i,j) = czero + tref(i,j) = czero + qref(i,j) = czero + duu10n(i,j) = czero + endif + + enddo enddo !--------------------------------------- @@ -5170,11 +5555,10 @@ subroutine MedPhase_atm_ocn_flux(gcomp, rc) if (statewrite_flag) then ! write the fields imported from ocn to file - call ESMF_FieldBundleWrite(is_local%wrap%FBAtmOcn_o, 'fields_med_atmocn.nc', & - singleFile=.true., overwrite=.true., timeslice=is_local%wrap%fastcntr, & - iofmt=ESMF_IOFMT_NETCDF, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + call ESMF_FieldBundleWrite(is_local%wrap%FBAtmOcn_o, 'fields_med_atmocn.nc', & + singleFile=.true., overwrite=overwrite_flag, timeslice=is_local%wrap%fastcntr, & + iofmt=ESMF_IOFMT_NETCDF, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return endif if (dbug_flag > 5) then @@ -5188,19 +5572,19 @@ end subroutine MedPhase_atm_ocn_flux subroutine MedPhase_slow(gcomp, rc) type(ESMF_GridComp) :: gcomp integer, intent(out) :: rc - + ! local variables - type(ESMF_Clock) :: clock - type(ESMF_Time) :: time - character(len=64) :: timestr - type(ESMF_State) :: importState, exportState - type(ESMF_StateItem_Flag) :: itemType - type(InternalState) :: is_local - integer :: i,j,n - character(ESMF_MAXSTR) :: fieldname1(10),fieldname2(10),fieldname3(10) - real(ESMF_KIND_R8), pointer :: dataPtr1(:,:),dataPtr2(:,:),dataPtr3(:,:) - real(ESMF_KIND_R8), pointer :: atmwgt(:,:),icewgt(:,:),customwgt(:,:) - logical :: checkOK, checkOK1, checkOK2 +! type(ESMF_Clock) :: clock +! type(ESMF_Time) :: time +! character(len=64) :: timestr +! type(ESMF_State) :: importState, exportState +! type(ESMF_StateItem_Flag) :: itemType +! type(InternalState) :: is_local +! integer :: i,j,n +! character(ESMF_MAXSTR) :: fieldname1(10),fieldname2(10),fieldname3(10) +! real(ESMF_KIND_R8), pointer :: dataPtr1(:,:),dataPtr2(:,:),dataPtr3(:,:) +! real(ESMF_KIND_R8), pointer :: atmwgt(:,:),icewgt(:,:),customwgt(:,:) +! logical :: checkOK, checkOK1, checkOK2 character(len=*),parameter :: subname='(module_MEDIATOR:MedPhase_slow)' if(profile_memory) call ESMF_VMLogMemInfo("Entering "//trim(subname)) @@ -5208,10 +5592,9 @@ subroutine MedPhase_slow(gcomp, rc) call ESMF_LogWrite(trim(subname)//": called", ESMF_LOGMSG_INFO, rc=dbrc) endif rc = ESMF_SUCCESS - + call MedPhase_prep_ocn(gcomp,rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return if (dbug_flag > 5) then call ESMF_LogWrite(trim(subname)//": done", ESMF_LOGMSG_INFO, rc=dbrc) @@ -5225,7 +5608,7 @@ end subroutine MedPhase_slow subroutine MedPhase_prep_ocn(gcomp, rc) type(ESMF_GridComp) :: gcomp integer, intent(out) :: rc - + ! local variables type(ESMF_Clock) :: clock type(ESMF_Time) :: time @@ -5233,69 +5616,71 @@ subroutine MedPhase_prep_ocn(gcomp, rc) type(ESMF_State) :: importState, exportState type(ESMF_StateItem_Flag) :: itemType type(InternalState) :: is_local - integer :: i,j,n + type(ESMF_VM) :: vm + integer :: i,j,n, il, iu, jl, ju, localPet character(ESMF_MAXSTR) :: fieldname1(10),fieldname2(10),fieldname3(10) -! real(ESMF_KIND_R8), pointer :: dataPtr1(:,:),dataPtr2(:,:),dataPtr3(:,:) + real(ESMF_KIND_R8), pointer :: dataPtr1(:,:),dataPtr2(:,:),dataPtr3(:,:) real(ESMF_KIND_R8), pointer :: atmwgt(:,:),icewgt(:,:),customwgt(:,:) - real(ESMF_KIND_R8), pointer :: atmwgt1(:,:),icewgt1(:,:),wgtp01(:,:),wgtm01(:,:) real(ESMF_KIND_R8), pointer :: tmp_n1(:,:),tmp_n2(:,:) character(ESMF_MAXSTR) ,pointer :: fieldNameList(:) type(ESMF_Field) :: aofield integer :: fieldCount logical :: checkOK, checkOK1, checkOK2 + logical,save :: first_call = .true. character(len=*),parameter :: subname='(module_MEDIATOR:MedPhase_prep_ocn)' - integer :: ii,jj - if(profile_memory) call ESMF_VMLogMemInfo("Entering "//trim(subname)) if (dbug_flag > 5) then call ESMF_LogWrite(trim(subname)//": called", ESMF_LOGMSG_INFO, rc=dbrc) endif rc = ESMF_SUCCESS - + + call ESMF_GridCompGet(gcomp, vm=vm, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__,file=__FILE__)) return + + call ESMF_VMGet(vm, localPet=localPet, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__,file=__FILE__)) return + ! query the Component for its clock, importState and exportState call ESMF_GridCompGet(gcomp, clock=clock, importState=importState, & - exportState=exportState, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out - + exportState=exportState, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + ! Get the internal state from Component. nullify(is_local%wrap) call ESMF_GridCompGetInternalState(gcomp, is_local, rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return call ESMF_ClockGet(clock,currtime=time,rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call ESMF_TimeGet(time,timestring=timestr) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return if (dbug_flag > 1) then call ESMF_LogWrite(trim(subname)//": time = "//trim(timestr), ESMF_LOGMSG_INFO, rc=dbrc) endif if (dbug_flag > 1) then call ESMF_ClockPrint(clock, options="currTime", & - preString="-------->"//trim(subname)//" mediating for: ", & - unit=msgString, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + preString="-------->"//trim(subname)//" mediating for: ", & + unit=msgString, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call ESMF_LogWrite(msgString, ESMF_LOGMSG_INFO, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return endif if (statewrite_flag) then + write(msgString,'(A,i10)')trim(subname)//trim(': write field_med_from_ocn '), is_local%wrap%slowcntr + call ESMF_LogWrite(trim(msgString), ESMF_LOGMSG_INFO, rc=rc) ! write the fields imported from ocn to file write(msgString,'(A,i10)')trim(subname)//trim(': write field_med_from_ocn '), is_local%wrap%slowcntr call ESMF_LogWrite(trim(msgString), ESMF_LOGMSG_INFO, rc=rc) - call NUOPC_Write(NState_OcnImp, & - fldsFrOcn%shortname(1:fldsFrOcn%num), & - "field_med_from_ocn_", timeslice=is_local%wrap%slowcntr, & - overwrite=.true., relaxedFlag=.true., rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + + call NUOPC_Write(NState_OcnImp, fldsFrOcn%shortname(1:fldsFrOcn%num), & + "field_med_from_ocn_", timeslice=is_local%wrap%slowcntr, & + overwrite=overwrite_flag, relaxedFlag=.true., rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return endif !--------------------------------------- @@ -5303,41 +5688,66 @@ subroutine MedPhase_prep_ocn(gcomp, rc) !--------------------------------------- if (dbug_flag > 1) then - call FieldBundle_diagnose(is_local%wrap%FBaccumAtm, trim(subname)//' FBaccA_B4avg ', rc=rc) - call FieldBundle_diagnose(is_local%wrap%FBaccumIce, trim(subname)//' FBaccI_B4avg ', rc=rc) - call FieldBundle_diagnose(is_local%wrap%FBaccumLnd, trim(subname)//' FBaccL_B4avg ', rc=rc) - call FieldBundle_diagnose(is_local%wrap%FBaccumHyd, trim(subname)//' FBaccH_B4avg ', rc=rc) + call FieldBundle_diagnose(is_local%wrap%FBaccumAtm, trim(subname)//' FBaccA_B4avg ', rc=rc) + call FieldBundle_diagnose(is_local%wrap%FBaccumIce, trim(subname)//' FBaccI_B4avg ', rc=rc) + call FieldBundle_diagnose(is_local%wrap%FBaccumLnd, trim(subname)//' FBaccL_B4avg ', rc=rc) + call FieldBundle_diagnose(is_local%wrap%FBaccumHyd, trim(subname)//' FBaccH_B4avg ', rc=rc) call FieldBundle_diagnose(is_local%wrap%FBaccumAtmOcn, trim(subname)//' FBaccAO_B4avg ', rc=rc) endif - call FieldBundle_average(is_local%wrap%FBaccumAtm, is_local%wrap%accumcntAtm, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + call FieldBundle_average(is_local%wrap%FBaccumAtm, is_local%wrap%accumcntAtm, rc=rc) ! average ATM field bundle + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return - call FieldBundle_average(is_local%wrap%FBaccumIce, is_local%wrap%accumcntIce, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + call FieldBundle_average(is_local%wrap%FBaccumIce, is_local%wrap%accumcntIce, rc=rc) ! average ICE field bundle + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return - call FieldBundle_average(is_local%wrap%FBaccumLnd, is_local%wrap%accumcntLnd, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + call FieldBundle_average(is_local%wrap%FBaccumLnd, is_local%wrap%accumcntLnd, rc=rc) ! average LAND field bundle + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + + call FieldBundle_average(is_local%wrap%FBaccumHyd, is_local%wrap%accumcntHyd, rc=rc) ! average Hydrology field bundle + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return - call FieldBundle_average(is_local%wrap%FBaccumHyd, is_local%wrap%accumcntHyd, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out - call FieldBundle_average(is_local%wrap%FBaccumAtmOcn, is_local%wrap%accumcntAtmOcn, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return if (dbug_flag > 1) then - call FieldBundle_diagnose(is_local%wrap%FBaccumAtm, trim(subname)//' FBaccA_avg ', rc=rc) - call FieldBundle_diagnose(is_local%wrap%FBaccumIce, trim(subname)//' FBaccI_avg ', rc=rc) - call FieldBundle_diagnose(is_local%wrap%FBaccumLnd, trim(subname)//' FBaccL_avg ', rc=rc) - call FieldBundle_diagnose(is_local%wrap%FBaccumHyd, trim(subname)//' FBaccH_avg ', rc=rc) + call FieldBundle_diagnose(is_local%wrap%FBaccumAtm, trim(subname)//' FBaccA_avg ', rc=rc) + call FieldBundle_diagnose(is_local%wrap%FBaccumIce, trim(subname)//' FBaccI_avg ', rc=rc) + call FieldBundle_diagnose(is_local%wrap%FBaccumLnd, trim(subname)//' FBaccL_avg ', rc=rc) + call FieldBundle_diagnose(is_local%wrap%FBaccumHyd, trim(subname)//' FBaccH_avg ', rc=rc) call FieldBundle_diagnose(is_local%wrap%FBaccumAtmOcn, trim(subname)//' FBaccAO_avg ', rc=rc) endif + if (coldstart .and. first_call) then + ! latent and sensible heat from atm may be inconsistent with current ice frac and SST + ! just on first timestep due to coldstart initialization + ! so check for bad values and zero them out as a work-around + + if (FieldBundle_FldChk(is_local%wrap%FBaccumAtm, 'mean_laten_heat_flx', rc=rc)) then + call FieldBundle_GetFldPtr(is_local%wrap%FBaccumAtm, 'mean_laten_heat_flx', dataPtr1, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return +!$omp parallel do private(i,j) + do j=lbound(dataPtr1,2),ubound(dataPtr1,2) + do i=lbound(dataPtr1,1),ubound(dataPtr1,1) + if (abs(dataPtr1(i,j)) > 1.0e6_ESMF_KIND_R8) dataPtr1(i,j) = czero + enddo + enddo + endif + if (FieldBundle_FldChk(is_local%wrap%FBaccumAtm, 'mean_sensi_heat_flx', rc=rc)) then + call FieldBundle_GetFldPtr(is_local%wrap%FBaccumAtm, 'mean_sensi_heat_flx', dataPtr1, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return +!$omp parallel do private(i,j) + do j=lbound(dataPtr1,2),ubound(dataPtr1,2) + do i=lbound(dataPtr1,1),ubound(dataPtr1,1) + if (abs(dataPtr1(i,j)) > 1.0e6_ESMF_KIND_R8) dataPtr1(i,j) = czero + enddo + enddo + endif + if (dbug_flag > 1) then + call FieldBundle_diagnose(is_local%wrap%FBaccumAtm, trim(subname)//' FBaccA_coldfix ', rc=rc) + endif + endif + !--------------------------------------- !--- regrid average atm+ice+lnd+hyd fields to ocean grid !--------------------------------------- @@ -5345,41 +5755,40 @@ subroutine MedPhase_prep_ocn(gcomp, rc) if (is_local%wrap%a2o_active) then call ESMF_LogWrite(trim(subname)//' calling FBRegrid FBaccumAtm to FBAtm_o', ESMF_LOGMSG_INFO, rc=rc) call FieldBundle_Regrid(fldsFrAtm, is_local%wrap%FBaccumAtm, is_local%wrap%FBAtm_o, & - consfmap=is_local%wrap%RH_a2o_consf, & - consdmap=is_local%wrap%RH_a2o_consd, & - bilnrmap=is_local%wrap%RH_a2o_bilnr, & - patchmap=is_local%wrap%RH_a2o_patch, & - string='a2o', rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + consfmap=is_local%wrap%RH_a2o_consf, & + consdmap=is_local%wrap%RH_a2o_consd, & + con2fmap=is_local%wrap%RH_a2o_con2f, & + con2dmap=is_local%wrap%RH_a2o_con2d, & + bilnrmap=is_local%wrap%RH_a2o_bilnr, & + patchmap=is_local%wrap%RH_a2o_patch, & + string='a2o', rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return !BL2017 use nearest neighbor method - call FieldBundle_Regrid2(fldsFrAtm, is_local%wrap%FBaccumAtm, is_local%wrap%FBAtm2_o, & - nearestmap=is_local%wrap%RH_a2o_nearest, & - string='a2o_nearest', rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + call FieldBundle_Regrid2(fldsFrAtm, is_local%wrap%FBaccumAtm, is_local%wrap%FBAtm2_o, & + nrnbrmap=is_local%wrap%RH_a2o_nrnbr, & + string='a2o_nrnbr', rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return call ESMF_FieldBundleGet(is_local%wrap%FBAtm_o, fieldCount=fieldCount, rc=rc) allocate(fieldNameList(fieldCount)) call ESMF_FieldBundleGet(is_local%wrap%FBAtm_o, fieldNameList=fieldNameList, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return do n = 1, fieldCount call FieldBundle_GetFldPtr(is_local%wrap%FBAtm_o, fieldNameList(n), tmp_n1,rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return call FieldBundle_GetFldPtr(is_local%wrap%FBAtm2_o, fieldNameList(n), tmp_n2, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out - do j=lbound(tmp_n1,2),ubound(tmp_n1,2) - do i=lbound(tmp_n1,1),ubound(tmp_n1,1) - if(tmp_n1(i,j).eq.0._ESMF_KIND_R8.and.abs(tmp_n2(i,j)).gt.0._ESMF_KIND_R8) then - tmp_n1(i,j)=tmp_n2(i,j) - endif - enddo - enddo + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + +!$omp parallel do default(shared) private(i,j) + do j=lbound(tmp_n1,2),ubound(tmp_n1,2) + do i=lbound(tmp_n1,1),ubound(tmp_n1,1) + if (abs(tmp_n1(i,j)) <= epsln .and. abs(tmp_n2(i,j)) > epsln) then + tmp_n1(i,j) = tmp_n2(i,j) + endif + enddo + enddo enddo deallocate(fieldNameList) !BL2017 @@ -5388,14 +5797,15 @@ subroutine MedPhase_prep_ocn(gcomp, rc) if (is_local%wrap%i2o_active) then call ESMF_LogWrite(trim(subname)//' calling FBRegrid FBaccumIce to FBIce_o', ESMF_LOGMSG_INFO, rc=rc) call FieldBundle_Regrid(fldsFrIce, is_local%wrap%FBaccumIce, is_local%wrap%FBIce_o, & - consfmap=is_local%wrap%RH_i2o_consf, & - consdmap=is_local%wrap%RH_i2o_consd, & - bilnrmap=is_local%wrap%RH_i2o_bilnr, & - patchmap=is_local%wrap%RH_i2o_patch, & - fcopymap=is_local%wrap%RH_i2o_fcopy, & - string='i2o', rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + consfmap=is_local%wrap%RH_i2o_consf, & + consdmap=is_local%wrap%RH_i2o_consd, & + con2fmap=is_local%wrap%RH_i2o_con2f, & + con2dmap=is_local%wrap%RH_i2o_con2d, & + bilnrmap=is_local%wrap%RH_i2o_bilnr, & + patchmap=is_local%wrap%RH_i2o_patch, & + fcopymap=is_local%wrap%RH_i2o_fcopy, & + string='i2o', rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return endif if (dbug_flag > 1) then @@ -5410,7 +5820,7 @@ subroutine MedPhase_prep_ocn(gcomp, rc) ! call ESMF_FieldBundleRegrid(FBXgrid, is_local%wrap%FBforOcn , is_local%wrap%RHx2o, & ! termorderflag=(/ESMF_TERMORDER_SRCSEQ/), rc=rc) ! tcraig temporarily copy - + call fieldBundle_copy(is_local%wrap%FBforOcn, is_local%wrap%FBAtm_o, rc=rc) call fieldBundle_copy(is_local%wrap%FBforOcn, is_local%wrap%FBIce_o, rc=rc) call fieldBundle_copy(is_local%wrap%FBforOcn, is_local%wrap%FBAccumAtmOcn, rc=rc) @@ -5423,9 +5833,9 @@ subroutine MedPhase_prep_ocn(gcomp, rc) !--- custom calculations to ocn !--------------------------------------- - !if (dbug_flag > 1) then - ! call FieldBundle_diagnose(is_local%wrap%FBforOcn, trim(subname)//' FB4ocn_AFcc ', rc=rc) - !endif +! if (dbug_flag > 1) then +! call FieldBundle_diagnose(is_local%wrap%FBforOcn, trim(subname)//' FB4ocn_AFcc ', rc=rc) +! endif !--------------------------------------- !--- write the Mediator Atm-Ocn fluxes @@ -5445,17 +5855,18 @@ subroutine MedPhase_prep_ocn(gcomp, rc) call ESMF_FieldBundleGet(is_local%wrap%FBAccumAtmOcn, fieldname=fieldNameList(n), field=aofield, rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU,line=__LINE__, file=__FILE__)) return call ESMF_FieldWrite(aofield,'field_aofield_to_ocn_'//trim(fieldnameList(n))//'.nc', & - timeslice=is_local%wrap%slowcntr, overwrite=.true.,rc=rc) + timeslice=is_local%wrap%slowcntr, overwrite=overwrite_flag,rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU,line=__LINE__, file=__FILE__)) return - end do + enddo deallocate(fieldNameList) endif + !--------------------------------------- !--- merges to ocn !--------------------------------------- - if ((is_local%wrap%i2o_active) .and. (is_local%wrap%a2o_active))then + if (is_local%wrap%i2o_active .and. is_local%wrap%a2o_active) then ! atm and ice fraction ! atmwgt and icewgt are the "normal" fractions @@ -5463,267 +5874,254 @@ subroutine MedPhase_prep_ocn(gcomp, rc) ! wgtp01 and wgtm01 are the same just one is +1 and the other is -1 to change sign ! depending on the ice fraction. atmwgt1+icewgt1+wgtp01 = 1.0 always, either ! wgtp01 is 1 (when ice fraction is 0) or wgtp01 is zero (when ice fraction is > 0) - call FieldBundle_GetFldPtr(is_local%wrap%FBIce_o, 'ice_fraction', icewgt, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out - allocate(atmwgt(lbound(icewgt,1):ubound(icewgt,1),lbound(icewgt,2):ubound(icewgt,2))) - allocate(customwgt(lbound(icewgt,1):ubound(icewgt,1),lbound(icewgt,2):ubound(icewgt,2))) - allocate(atmwgt1(lbound(icewgt,1):ubound(icewgt,1),lbound(icewgt,2):ubound(icewgt,2))) - allocate(icewgt1(lbound(icewgt,1):ubound(icewgt,1),lbound(icewgt,2):ubound(icewgt,2))) - allocate(wgtp01(lbound(icewgt,1):ubound(icewgt,1),lbound(icewgt,2):ubound(icewgt,2))) - allocate(wgtm01(lbound(icewgt,1):ubound(icewgt,1),lbound(icewgt,2):ubound(icewgt,2))) - do j=lbound(icewgt,2),ubound(icewgt,2) - do i=lbound(icewgt,1),ubound(icewgt,1) -#ifndef FV3_CPLD -! DATM uses mediator aoflux calc in icy water - atmwgt(i,j) = 1.0_ESMF_KIND_R8 - icewgt(i,j) - atmwgt1(i,j) = atmwgt(i,j) - icewgt1(i,j) = icewgt(i,j) - wgtp01(i,j) = 0.0_ESMF_KIND_R8 - wgtm01(i,j) = 0.0_ESMF_KIND_R8 -! DATM uses atm fluxes in non-icy water - if (atmocn_flux_from_atm .and. icewgt(i,j) <= 0.0_ESMF_KIND_R8) then - atmwgt1(i,j) = 1.0_ESMF_KIND_R8 - icewgt1(i,j) = 0.0_ESMF_KIND_R8 - wgtp01(i,j) = 0.0_ESMF_KIND_R8 - wgtm01(i,j) = 0.0_ESMF_KIND_R8 - endif - ! check wgts do add to 1 as expected - if (abs(atmwgt(i,j) + icewgt(i,j) - 1.0_ESMF_KIND_R8) > 1.0e-12 .or. & - abs(atmwgt1(i,j) + icewgt1(i,j) + wgtp01(i,j) - 1.0_ESMF_KIND_R8) > 1.0e-12 .or. & - abs(atmwgt1(i,j) + icewgt1(i,j) - wgtm01(i,j) - 1.0_ESMF_KIND_R8) > 1.0e-12) then - call ESMF_LogWrite(trim(subname)//": ERROR atm + ice fracs inconsistent", ESMF_LOGMSG_ERROR, line=__LINE__, file=__FILE__, rc=dbrc) - rc = ESMF_FAILURE - return - endif -#else - atmwgt(i,j) = 1.0_ESMF_KIND_R8 - icewgt(i,j) - atmwgt1(i,j) = 0.0_ESMF_KIND_R8 - icewgt1(i,j) = icewgt(i,j) - wgtm01(i,j) = -atmwgt(i,j) - wgtp01(i,j) = atmwgt(i,j) -#endif - enddo - enddo + call FieldBundle_GetFldPtr(is_local%wrap%FBIce_o, 'ice_fraction', icewgt, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return - ii =lbound(icewgt,1)+(ubound(icewgt,1) - lbound(icewgt,1))/2 - jj =lbound(icewgt,2)+(ubound(icewgt,2) - lbound(icewgt,2))/2 - write(msgString,'(A,6f12.5)')trim(subname)//trim(' sample wts for atm-ocn merges'), & - real(icewgt(ii,jj),4), real(atmwgt(ii,jj),4),& - real(icewgt1(ii,jj),4), real( atmwgt1(ii,jj),4),& - real(wgtp01(ii,jj),4), real( wgtm01(ii,jj),4) - call ESMF_LogWrite(trim(msgString), ESMF_LOGMSG_INFO, rc=rc) + jl=lbound(icewgt,2) ; ju=ubound(icewgt,2) + il=lbound(icewgt,1) ; iu=ubound(icewgt,1) + + allocate(atmwgt (il:iu, jl:ju)) + allocate(customwgt(il:iu, jl:ju)) + +!$omp parallel do default(shared) private(i,j) + do j=jl,ju + do i=il,iu + icewgt(i,j) = max(czero, min(icewgt(i,j), cone)) + atmwgt(i,j) = max(czero, cone - icewgt(i,j)) + customwgt(i,j) = abs(atmwgt(i,j) + icewgt(i,j) - cone) + enddo + enddo + do j=jl,ju + do i=il,iu + if (customwgt(i,j) > epsln) then ! check wgts do add to 1 as expected + call ESMF_LogWrite(trim(subname)//": ERROR atm + ice fracs inconsistent", ESMF_LOGMSG_ERROR, line=__LINE__, file=__FILE__, rc=dbrc) + rc = ESMF_FAILURE + return + endif + enddo + enddo + if (atmocn_flux_from_atm) then !------------- ! mean_evap_rate = mean_laten_heat_flux * (1-ice_fraction)/const_lhvap !------------- - customwgt = wgtm01 / const_lhvap - call fieldBundle_FieldMerge(is_local%wrap%FBforOcn , 'mean_evap_rate' , & - is_local%wrap%FBAccumAtmOcn, 'mean_evap_rate_atm_into_ocn', atmwgt1, & - is_local%wrap%FBAtm_o , 'mean_laten_heat_flx' , customwgt, & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + customwgt = - atmwgt / const_lhvap + call fieldBundle_FieldMerge(is_local%wrap%FBforOcn , 'mean_evap_rate' , 1, & + is_local%wrap%FBAtm_o , 'mean_laten_heat_flx' , customwgt, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return - !------------- - ! field_for_ocn = field_from_atm * (1-ice_fraction) - !------------- +! not used by mom, mom uses evap +! hycom uses latent heat flux + customwgt = - atmwgt + call fieldBundle_FieldMerge(is_local%wrap%FBforOcn , 'mean_laten_heat_flx' , 1, & + is_local%wrap%FBAtm_o , 'mean_laten_heat_flx' , customwgt, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + + call fieldBundle_FieldMerge(is_local%wrap%FBforOcn , 'mean_sensi_heat_flx' , 1, & + is_local%wrap%FBAtm_o , 'mean_sensi_heat_flx' , customwgt, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return - call fieldBundle_FieldMerge(is_local%wrap%FBforOcn, 'mean_fprec_rate', & - is_local%wrap%FBAtm_o , 'mean_fprec_rate', atmwgt, & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + call fieldBundle_FieldMerge(is_local%wrap%FBforOcn , 'mean_net_lw_flx' , 1, & + is_local%wrap%FBAtm_o , 'mean_net_lw_flx' , atmwgt, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return - call fieldBundle_FieldMerge(is_local%wrap%FBforOcn, 'mean_prec_rate', & - is_local%wrap%FBAtm_o , 'mean_prec_rate', atmwgt, & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out +! not used by mom, mom uses net, also mean_up_lw_flx not recvd from atm +! call fieldBundle_FieldMerge(is_local%wrap%FBforOcn , 'mean_up_lw_flx' , 1 , & +! is_local%wrap%FBAtm_o , 'mean_up_lw_flx' , atmwgt, rc=rc) +! if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return !------------- - ! field_for_ocn = field_from_ice * ice_fraction + ! field_for_ocn = field_from_atm * (1-ice_fraction) + field_from_ice * (ice_fraction) !------------- - call fieldBundle_FieldMerge(is_local%wrap%FBforOcn, 'net_heat_flx_to_ocn', & - is_local%wrap%FBIce_o , 'net_heat_flx_to_ocn', icewgt, & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + call fieldBundle_FieldMerge(is_local%wrap%FBforOcn , 'mean_zonal_moment_flx' , 2, & + is_local%wrap%FBIce_o , 'stress_on_ocn_ice_zonal' , icewgt, & + is_local%wrap%FBAtm_o , 'mean_zonal_moment_flx_atm', customwgt, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call fieldBundle_FieldMerge(is_local%wrap%FBforOcn , 'mean_merid_moment_flx' , 2, & + is_local%wrap%FBIce_o , 'stress_on_ocn_ice_merid' , icewgt, & + is_local%wrap%FBAtm_o , 'mean_merid_moment_flx_atm', customwgt, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return - call fieldBundle_FieldMerge(is_local%wrap%FBforOcn, 'mean_fresh_water_to_ocean_rate', & - is_local%wrap%FBIce_o , 'mean_fresh_water_to_ocean_rate', icewgt, & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + else -! not used by mom, mom uses net, also mean_down_lw_flx not connected to ocn -! call fieldBundle_FieldMerge(is_local%wrap%FBforOcn, 'mean_down_lw_flx', & -! is_local%wrap%FBAtm_o , 'mean_down_lw_flx', atmwgt, & -! rc=rc) -! if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & -! line=__LINE__, file=__FILE__)) return ! bail out + !------------- + ! mean_evap_rate = mean_laten_heat_flux * (1-ice_fraction)/const_lhvap + !------------- + customwgt = - atmwgt + call fieldBundle_FieldMerge(is_local%wrap%FBforOcn , 'mean_evap_rate' , 1, & + is_local%wrap%FBAccumAtmOcn, 'mean_evap_rate_atm_into_ocn', atmwgt, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return ! not used by mom, mom uses evap ! hycom uses latent heat flux - !call fieldBundle_FieldMerge(is_local%wrap%FBforOcn , 'mean_laten_heat_flx' , & - ! is_local%wrap%FBAccumAtmOcn, 'mean_laten_heat_flx_atm_into_ocn', atmwgt1, & - ! is_local%wrap%FBAtm_o , 'mean_laten_heat_flx' , wgtm01, & - ! rc=rc) - !if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - ! line=__LINE__, file=__FILE__)) return ! bail out - - call fieldBundle_FieldMerge(is_local%wrap%FBforOcn , 'mean_sensi_heat_flx' , & - is_local%wrap%FBAccumAtmOcn, 'mean_sensi_heat_flx_atm_into_ocn', atmwgt1, & - is_local%wrap%FBAtm_o , 'mean_sensi_heat_flx' , wgtm01, & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out - - call fieldBundle_FieldMerge(is_local%wrap%FBforOcn , 'mean_net_lw_flx' , & - is_local%wrap%FBAtm_o , 'mean_down_lw_flx' , atmwgt1, & - is_local%wrap%FBAccumAtmOcn, 'mean_up_lw_flx_ocn', atmwgt1, & - is_local%wrap%FBAtm_o , 'mean_net_lw_flx' , wgtp01, & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + call fieldBundle_FieldMerge(is_local%wrap%FBforOcn , 'mean_laten_heat_flx' , 1, & + is_local%wrap%FBAccumAtmOcn, 'mean_laten_heat_flx_atm_into_ocn', atmwgt, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + + call fieldBundle_FieldMerge(is_local%wrap%FBforOcn , 'mean_sensi_heat_flx' , 1, & + is_local%wrap%FBAccumAtmOcn, 'mean_sensi_heat_flx_atm_into_ocn', atmwgt, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + + call fieldBundle_FieldMerge(is_local%wrap%FBforOcn , 'mean_net_lw_flx' , 2, & + is_local%wrap%FBAtm_o , 'mean_down_lw_flx' , atmwgt, & + is_local%wrap%FBAccumAtmOcn, 'mean_up_lw_flx_ocn', atmwgt, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return ! not used by mom, mom uses net, also mean_up_lw_flx not recvd from atm -! call fieldBundle_FieldMerge(is_local%wrap%FBforOcn , 'mean_up_lw_flx' , & -! is_local%wrap%FBAccumAtmOcn, 'mean_up_lw_flx_ocn', atmwgt1, & -! is_local%wrap%FBAtm_o , 'mean_up_lw_flx' , wgtp01, & -! rc=rc) -! if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & -! line=__LINE__, file=__FILE__)) return ! bail out +! call fieldBundle_FieldMerge(is_local%wrap%FBforOcn , 'mean_up_lw_flx' , 1 , & +! is_local%wrap%FBAccumAtmOcn, 'mean_up_lw_flx_ocn', atmwgt, rc=rc) + ! if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + + !------------- + ! field_for_ocn = field_from_atm * (1-ice_fraction) + field_from_ice * (ice_fraction) + !------------- + + call fieldBundle_FieldMerge(is_local%wrap%FBforOcn , 'mean_zonal_moment_flx' , 2, & + is_local%wrap%FBAccumAtmOcn, 'stress_on_air_ocn_zonal', atmwgt, & + is_local%wrap%FBIce_o , 'stress_on_ocn_ice_zonal', icewgt, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + + call fieldBundle_FieldMerge(is_local%wrap%FBforOcn , 'mean_merid_moment_flx' , 2, & + is_local%wrap%FBAccumAtmOcn, 'stress_on_air_ocn_merid', atmwgt, & + is_local%wrap%FBIce_o , 'stress_on_ocn_ice_merid', icewgt, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + + endif + + !------------- + ! field_for_ocn = field_from_atm * (1-ice_fraction) + !------------- + + call fieldBundle_FieldMerge(is_local%wrap%FBforOcn, 'mean_fprec_rate', 1, & + is_local%wrap%FBAtm_o , 'mean_fprec_rate', atmwgt, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + + call fieldBundle_FieldMerge(is_local%wrap%FBforOcn, 'mean_prec_rate', 1, & + is_local%wrap%FBAtm_o , 'mean_prec_rate', atmwgt, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return !------------- ! field_for_ocn = field_from_ice * ice_fraction !------------- - call fieldBundle_FieldMerge(is_local%wrap%FBforOcn, 'mean_salt_rate', & - is_local%wrap%FBIce_o , 'mean_salt_rate', icewgt, & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + call fieldBundle_FieldMerge(is_local%wrap%FBforOcn, 'net_heat_flx_to_ocn', 1, & + is_local%wrap%FBIce_o , 'net_heat_flx_to_ocn', icewgt, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + + + call fieldBundle_FieldMerge(is_local%wrap%FBforOcn, 'mean_fresh_water_to_ocean_rate', 1, & + is_local%wrap%FBIce_o , 'mean_fresh_water_to_ocean_rate', icewgt, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + + call fieldBundle_FieldMerge(is_local%wrap%FBforOcn, 'mean_salt_rate', 1, & + is_local%wrap%FBIce_o , 'mean_salt_rate', icewgt, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + + +! not used by mom, mom uses net, also mean_down_lw_flx not connected to ocn +! call fieldBundle_FieldMerge(is_local%wrap%FBforOcn, 'mean_down_lw_flx', & +! is_local%wrap%FBAtm_o , 'mean_down_lw_flx', atmwgt, rc=rc) +! if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return !------------- ! field_for_ocn = field_from_atm * (1-ice_fraction) + field_from_ice * (ice_fraction) !------------- - call fieldBundle_FieldMerge(is_local%wrap%FBforOcn , 'mean_zonal_moment_flx' , & - is_local%wrap%FBAccumAtmOcn, 'stress_on_air_ocn_zonal', atmwgt1, & - is_local%wrap%FBIce_o , 'stress_on_ocn_ice_zonal', icewgt1, & - is_local%wrap%FBAtm_o , 'mean_zonal_moment_flx_atm' , wgtm01, & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out - - call fieldBundle_FieldMerge(is_local%wrap%FBforOcn , 'mean_merid_moment_flx' , & - is_local%wrap%FBAccumAtmOcn, 'stress_on_air_ocn_merid', atmwgt1, & - is_local%wrap%FBIce_o , 'stress_on_ocn_ice_merid', icewgt1, & - is_local%wrap%FBAtm_o , 'mean_merid_moment_flx_atm' , wgtm01, & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + call fieldBundle_FieldMerge(is_local%wrap%FBforOcn , 'mean_zonal_moment_flx' , 2, & + is_local%wrap%FBIce_o , 'stress_on_ocn_ice_zonal' , icewgt, & + is_local%wrap%FBAtm_o , 'mean_zonal_moment_flx_atm', customwgt, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + + call fieldBundle_FieldMerge(is_local%wrap%FBforOcn , 'mean_merid_moment_flx' , 2, & + is_local%wrap%FBIce_o , 'stress_on_ocn_ice_merid' , icewgt, & + is_local%wrap%FBAtm_o , 'mean_merid_moment_flx_atm', customwgt, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return !------------- ! netsw_for_ocn = downsw_from_atm * (1-ocn_albedo) * (1-ice_fraction) + pensw_from_ice * (ice_fraction) !------------- - customwgt = atmwgt * (1.0 - 0.06) -! customwgt = (1.0 - 0.06) - call fieldBundle_FieldMerge(is_local%wrap%FBforOcn,'mean_net_sw_flx' , & - is_local%wrap%FBAtm_o ,'mean_down_sw_flx',customwgt, & - is_local%wrap%FBIce_o ,'mean_sw_pen_to_ocn' ,icewgt, & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out - - call fieldBundle_FieldMerge(is_local%wrap%FBforOcn,'mean_net_sw_vis_dir_flx' , & - is_local%wrap%FBAtm_o ,'mean_down_sw_vis_dir_flx',customwgt, & - is_local%wrap%FBIce_o ,'mean_sw_pen_to_ocn_vis_dir_flx' ,icewgt, & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out - - call fieldBundle_FieldMerge(is_local%wrap%FBforOcn,'mean_net_sw_vis_dif_flx' , & - is_local%wrap%FBAtm_o ,'mean_down_sw_vis_dif_flx',customwgt, & - is_local%wrap%FBIce_o ,'mean_sw_pen_to_ocn_vis_dif_flx',icewgt, & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out - - call fieldBundle_FieldMerge(is_local%wrap%FBforOcn,'mean_net_sw_ir_dir_flx' , & - is_local%wrap%FBAtm_o ,'mean_down_sw_ir_dir_flx',customwgt, & - is_local%wrap%FBIce_o ,'mean_sw_pen_to_ocn_ir_dir_flx',icewgt, & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out - - call fieldBundle_FieldMerge(is_local%wrap%FBforOcn,'mean_net_sw_ir_dif_flx' , & - is_local%wrap%FBAtm_o ,'mean_down_sw_ir_dif_flx',customwgt, & - is_local%wrap%FBIce_o ,'mean_sw_pen_to_ocn_ir_dif_flx',icewgt, & - rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + customwgt = atmwgt * (cone - albocn) + call fieldBundle_FieldMerge(is_local%wrap%FBforOcn,'mean_net_sw_flx' , 2, & + is_local%wrap%FBAtm_o ,'mean_down_sw_flx' , customwgt, & + is_local%wrap%FBIce_o ,'mean_sw_pen_to_ocn', icewgt, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + + call fieldBundle_FieldMerge(is_local%wrap%FBforOcn,'mean_net_sw_vis_dir_flx' , 2, & + is_local%wrap%FBAtm_o ,'mean_down_sw_vis_dir_flx' , customwgt, & + is_local%wrap%FBIce_o ,'mean_sw_pen_to_ocn_vis_dir_flx' , icewgt, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + + call fieldBundle_FieldMerge(is_local%wrap%FBforOcn,'mean_net_sw_vis_dif_flx' , 2, & + is_local%wrap%FBAtm_o ,'mean_down_sw_vis_dif_flx' , customwgt, & + is_local%wrap%FBIce_o ,'mean_sw_pen_to_ocn_vis_dif_flx' , icewgt, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + + call fieldBundle_FieldMerge(is_local%wrap%FBforOcn,'mean_net_sw_ir_dir_flx' , 2, & + is_local%wrap%FBAtm_o ,'mean_down_sw_ir_dir_flx' , customwgt, & + is_local%wrap%FBIce_o ,'mean_sw_pen_to_ocn_ir_dir_flx' , icewgt, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + + call fieldBundle_FieldMerge(is_local%wrap%FBforOcn,'mean_net_sw_ir_dif_flx' , 2, & + is_local%wrap%FBAtm_o ,'mean_down_sw_ir_dif_flx' , customwgt, & + is_local%wrap%FBIce_o ,'mean_sw_pen_to_ocn_ir_dif_flx' , icewgt, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + !------------- ! End merges !------------- - deallocate(atmwgt,customwgt,atmwgt1,icewgt1,wgtp01) + deallocate(atmwgt,customwgt) - if (dbug_flag > 1) then - call FieldBundle_diagnose(is_local%wrap%FBforOcn, trim(subname)//' FB4ocn_AFmrg ', rc=rc) - endif - - endif + if (dbug_flag > 1) then + call FieldBundle_diagnose(is_local%wrap%FBforOcn, trim(subname)//' FB4ocn_AFmrg ', rc=rc) + endif + + endif ! if (is_local%wrap%i2o_active) !--------------------------------------- - !--- zero accumulator + !--- zero accumulator if not cold start !--------------------------------------- - is_local%wrap%accumcntAtm = 0 - call fieldBundle_reset(is_local%wrap%FBaccumAtm, value=czero, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (.not. coldstart) then + is_local%wrap%accumcntAtm = 0 + call fieldBundle_reset(is_local%wrap%FBaccumAtm, value=czero, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return - is_local%wrap%accumcntIce = 0 - call fieldBundle_reset(is_local%wrap%FBaccumIce, value=czero, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + is_local%wrap%accumcntIce = 0 + call fieldBundle_reset(is_local%wrap%FBaccumIce, value=czero, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return - is_local%wrap%accumcntLnd = 0 - call fieldBundle_reset(is_local%wrap%FBaccumLnd, value=czero, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + is_local%wrap%accumcntLnd = 0 + call fieldBundle_reset(is_local%wrap%FBaccumLnd, value=czero, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return - is_local%wrap%accumcntHyd = 0 - call fieldBundle_reset(is_local%wrap%FBaccumHyd, value=czero, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + is_local%wrap%accumcntHyd = 0 + call fieldBundle_reset(is_local%wrap%FBaccumHyd, value=czero, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return - is_local%wrap%accumcntAtmOcn = 0 - call fieldBundle_reset(is_local%wrap%FBaccumAtmOcn, value=czero, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + is_local%wrap%accumcntAtmOcn = 0 + call fieldBundle_reset(is_local%wrap%FBaccumAtmOcn, value=czero, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + endif if (dbug_flag > 1) then -!tcx call FieldBundle_diagnose(is_local%wrap%FBaccumAtm, trim(subname)//' FBacc_AFzero ', rc=rc) -!tcx call FieldBundle_diagnose(is_local%wrap%FBaccumIce, trim(subname)//' FBacc_AFzero ', rc=rc) -!dcr call FieldBundle_diagnose(is_local%wrap%FBaccumLnd, trim(subname)//' FBacc_AFzero ', rc=rc) -!dcr call FieldBundle_diagnose(is_local%wrap%FBaccumHyd, trim(subname)//' FBacc_AFzero ', rc=rc) -!tcx call FieldBundle_diagnose(is_local%wrap%FBaccumAtmOcn, trim(subname)//' FBacc_AFzero ', rc=rc) +!tcx call FieldBundle_diagnose(is_local%wrap%FBaccumAtm, trim(subname)//' FBacc_AFzero ', rc=rc) +!tcx call FieldBundle_diagnose(is_local%wrap%FBaccumIce, trim(subname)//' FBacc_AFzero ', rc=rc) +!dcr call FieldBundle_diagnose(is_local%wrap%FBaccumLnd, trim(subname)//' FBacc_AFzero ', rc=rc) +!dcr call FieldBundle_diagnose(is_local%wrap%FBaccumHyd, trim(subname)//' FBacc_AFzero ', rc=rc) +!tcx call FieldBundle_diagnose(is_local%wrap%FBaccumAtmOcn, trim(subname)//' FBacc_AFzero ', rc=rc) endif !--- set export State to special value for testing call state_reset(NState_OcnExp, value=spval, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return if (dbug_flag > 1) then call State_diagnose(NState_OcnExp, trim(subname)//' es_AF99 ', rc=rc) @@ -5734,8 +6132,7 @@ subroutine MedPhase_prep_ocn(gcomp, rc) !--------------------------------------- call fieldBundle_copy(NState_OcnExp, is_local%wrap%FBforOcn, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return if (dbug_flag > 1) then call State_diagnose(NState_OcnExp, trim(subname)//' es_AFcp ', rc=rc) @@ -5745,19 +6142,20 @@ subroutine MedPhase_prep_ocn(gcomp, rc) ! write the fields exported to ocn to file write(msgString,'(A,i10)')trim(subname)//trim(': write field_med_to_ocn '), is_local%wrap%slowcntr call ESMF_LogWrite(trim(msgString), ESMF_LOGMSG_INFO, rc=rc) - - call NUOPC_Write(NState_OcnExp, & - fldsToOcn%shortname(1:fldsToOcn%num), & - "field_med_to_ocn_", timeslice=is_local%wrap%slowcntr, & - relaxedFlag=.true., rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + call NUOPC_Write(NState_OcnExp, & + fldsToOcn%shortname(1:fldsToOcn%num), & + "field_med_to_ocn_", timeslice=is_local%wrap%slowcntr, & + relaxedFlag=.true., rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return endif + !--------------------------------------- is_local%wrap%slowcntr = is_local%wrap%slowcntr + 1 + first_call = .false. + !--------------------------------------- !--- clean up !--------------------------------------- @@ -5778,16 +6176,15 @@ end subroutine MedPhase_prep_ocn subroutine MedPhase_write_restart(gcomp, rc) type(ESMF_GridComp) :: gcomp integer, intent(out) :: rc - + ! local variables type(ESMF_Clock) :: clock - type(ESMF_Time) :: currTime - type(ESMF_Time) :: startTime + type(ESMF_Time) :: currTime, startTime type(ESMF_TimeInterval) :: elapsedTime ! ESMF_TimeInterval integer*8 :: sec8 integer :: yr,mon,day,hr,min,sec - character(len=128) :: fname + character(len=256) :: fname character(len=*),parameter :: subname='(module_MEDIATOR:MedPhase_write_restart)' if (dbug_flag > 5) then @@ -5797,40 +6194,36 @@ subroutine MedPhase_write_restart(gcomp, rc) if (restart_interval > 0) then call ESMF_GridCompGet(gcomp, clock=clock, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return call ESMF_ClockGet(clock,currTime=currTime,startTime=startTime, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return elapsedTime = currTime - startTime call ESMF_TimeIntervalGet(elapsedTime,s_i8=sec8,rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return - if (mod(sec8,restart_interval) == 0) then + if (mod(sec8, restart_interval) == 0 .and. sec8 > 0) then write(msgString,*) trim(subname)//' restart at sec8= ',sec8,restart_interval call ESMF_LogWrite(msgString, ESMF_LOGMSG_INFO, rc=dbrc) call ESMF_TimeGet(currTime,yy=yr,mm=mon,dd=day,h=hr,m=min,s=sec,rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return - write(fname,'(i4.4,2i2.2,a,3i2.2,a)') yr,mon,day,'-',hr,min,sec,'_mediator' + write(fname,'(a,i4.4,2i2.2,a,3i2.2,a)') restart_dir(1:lenstr(restart_dir)), & + yr, mon, day, '-', hr, min, sec, '_mediator' write(msgString,*) trim(subname)//' restart to '//trim(fname) call ESMF_LogWrite(msgString, ESMF_LOGMSG_INFO, rc=dbrc) call Mediator_restart(gcomp,'write',trim(fname),rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return endif endif - !if (dbug_flag > 5) then + if (dbug_flag > 5) then call ESMF_LogWrite(trim(subname)//": done", ESMF_LOGMSG_INFO, rc=dbrc) - !endif + endif end subroutine MedPhase_write_restart @@ -5841,7 +6234,7 @@ subroutine Finalize(gcomp, importState, exportState, clock, rc) type(ESMF_State) :: importState, exportState type(ESMF_Clock) :: clock integer, intent(out) :: rc - + ! local variables type(InternalState) :: is_local integer :: stat @@ -5853,71 +6246,56 @@ subroutine Finalize(gcomp, importState, exportState, clock, rc) rc = ESMF_SUCCESS call Mediator_restart(gcomp,'write','mediator',rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return ! Get the internal state from Component. nullify(is_local%wrap) call ESMF_GridCompGetInternalState(gcomp, is_local, rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out - + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + ! Destroy objects inside of internal state. ! TODO: destroy objects inside objects call fieldBundle_clean(is_local%wrap%FBaccumAtm, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return ! tcraig - generates errors -! call fieldBundle_clean(is_local%wrap%FBaccumOcn, rc=rc) -! if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & -! line=__LINE__, file=__FILE__)) return ! bail out +! call fieldBundle_clean(is_local%wrap%FBaccumOcn, rc=rc) +! if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return call fieldBundle_clean(is_local%wrap%FBaccumIce, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return call fieldBundle_clean(is_local%wrap%FBaccumLnd, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return call fieldBundle_clean(is_local%wrap%FBaccumHyd, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return call fieldBundle_clean(is_local%wrap%FBaccumAtmOcn, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return call fieldBundle_clean(is_local%wrap%FBforAtm, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return call fieldBundle_clean(is_local%wrap%FBforOcn, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return call fieldBundle_clean(is_local%wrap%FBforIce, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return call fieldBundle_clean(is_local%wrap%FBforLnd, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return call fieldBundle_clean(is_local%wrap%FBforHyd, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return ! Deallocate the internal state memory. deallocate(is_local%wrap, stat=stat) - if (ESMF_LogFoundDeallocError(statusToCheck=stat, & - msg="Deallocation of internal state memory failed.", & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - + if (ESMF_LogFoundDeallocError(statusToCheck=stat, & + msg="Deallocation of internal state memory failed.", & + line=__LINE__, file=__FILE__)) return + call ESMF_LogWrite(trim(subname)//" complete", ESMF_LOGMSG_INFO, rc=dbrc) if (dbug_flag > 5) then @@ -5931,16 +6309,16 @@ subroutine Mediator_restart(gcomp,mode,bfname,rc) ! ! read/write mediator restart file ! - type(ESMF_GridComp) :: gcomp + type(ESMF_GridComp) :: gcomp character(len=*), intent(in) :: mode character(len=*), intent(in) :: bfname integer , intent(inout) :: rc - type(InternalState) :: is_local - character(len=1280) :: fname - integer :: funit - logical :: fexists - character(len=*),parameter :: subname='(module_MEDIATOR:Mediator_restart)' + type(InternalState) :: is_local + character(len=1280) :: fname + integer :: funit + logical :: fexists + character(len=*), parameter :: subname='(module_MEDIATOR:Mediator_restart)' if (dbug_flag > 5) then call ESMF_LogWrite(trim(subname)//": called", ESMF_LOGMSG_INFO, rc=dbrc) @@ -5956,107 +6334,107 @@ subroutine Mediator_restart(gcomp,mode,bfname,rc) ! Get the internal state from Component. nullify(is_local%wrap) call ESMF_GridCompGetInternalState(gcomp, is_local, rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return +! + if (mode == 'write') then + call fieldBundle_copy(is_local%wrap%FBAtm_a, NState_AtmImp, rc=rc) + call fieldBundle_copy(is_local%wrap%FBOcn_o, NState_OcnImp, rc=rc) + call fieldBundle_copy(is_local%wrap%FBIce_i, NState_IceImp, rc=rc) + call fieldBundle_copy(is_local%wrap%FBLnd_l, NState_LndImp, rc=rc) + call fieldBundle_copy(is_local%wrap%FBHyd_h, NState_HydImp, rc=rc) + endif +! #ifdef FV3_CPLD fname = trim(bfname)//'_FBaccumAtm_restart.nc' - call FieldBundle_RWFields_tiles(mode,fname,is_local%wrap%FBaccumAtm,read_rest_FBaccumAtm,rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + call FieldBundle_RWFields_tiles(mode, fname, is_local%wrap%FBaccumAtm, rc=rc) +! call FieldBundle_RWFields_tiles(mode,fname,is_local%wrap%FBaccumAtm,read_rest_FBaccumAtm,rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return #else fname = trim(bfname)//'_FBaccumAtm_restart.nc' - call FieldBundle_RWFields(mode,fname,is_local%wrap%FBaccumAtm,read_rest_FBaccumAtm,rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + call FieldBundle_RWFields(mode, fname, is_local%wrap%FBaccumAtm, rc=rc) +! call FieldBundle_RWFields(mode,fname,is_local%wrap%FBaccumAtm,read_rest_FBaccumAtm,rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return #endif fname = trim(bfname)//'_FBaccumOcn_restart.nc' - call FieldBundle_RWFields(mode,fname,is_local%wrap%FBaccumOcn,read_rest_FBaccumOcn,rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + call FieldBundle_RWFields(mode, fname, is_local%wrap%FBaccumOcn, rc=rc) +! call FieldBundle_RWFields(mode,fname,is_local%wrap%FBaccumOcn,read_rest_FBaccumOcn,rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return fname = trim(bfname)//'_FBaccumIce_restart.nc' - call FieldBundle_RWFields(mode,fname,is_local%wrap%FBaccumIce,read_rest_FBaccumIce,rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + call FieldBundle_RWFields(mode, fname, is_local%wrap%FBaccumIce, rc=rc) +! call FieldBundle_RWFields(mode,fname,is_local%wrap%FBaccumIce,read_rest_FBaccumIce,rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return fname = trim(bfname)//'_FBaccumLnd_restart.nc' - call FieldBundle_RWFields(mode,fname,is_local%wrap%FBaccumLnd,read_rest_FBaccumLnd,rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + call FieldBundle_RWFields(mode, fname, is_local%wrap%FBaccumLnd, rc=rc) +! call FieldBundle_RWFields(mode,fname,is_local%wrap%FBaccumLnd,read_rest_FBaccumLnd,rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return fname = trim(bfname)//'_FBaccumHyd_restart.nc' - call FieldBundle_RWFields(mode,fname,is_local%wrap%FBaccumHyd,read_rest_FBaccumHyd,rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + call FieldBundle_RWFields(mode, fname, is_local%wrap%FBaccumHyd, rc) +! call FieldBundle_RWFields(mode,fname,is_local%wrap%FBaccumHyd,read_rest_FBaccumHyd,rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return fname = trim(bfname)//'_FBaccumAtmOcn_restart.nc' - call FieldBundle_RWFields(mode,fname,is_local%wrap%FBaccumAtmOcn,read_rest_FBaccumAtmOcn,rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + call FieldBundle_RWFields(mode, fname, is_local%wrap%FBaccumAtmOcn, rc=rc) +! call FieldBundle_RWFields(mode,fname,is_local%wrap%FBaccumAtmOcn,read_rest_FBaccumAtmOcn,rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return #ifdef FV3_CPLD fname = trim(bfname)//'_FBAtm_a_restart.nc' - call FieldBundle_RWFields_tiles(mode,fname,is_local%wrap%FBAtm_a,read_rest_FBAtm_a,rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + call FieldBundle_RWFields_tiles(mode, fname, is_local%wrap%FBAtm_a, rc=rc) +! call FieldBundle_RWFields_tiles(mode,fname,is_local%wrap%FBAtm_a,read_rest_FBAtm_a,rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return #else fname = trim(bfname)//'_FBAtm_a_restart.nc' - call FieldBundle_RWFields(mode,fname,is_local%wrap%FBAtm_a,read_rest_FBAtm_a,rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + call FieldBundle_RWFields(mode, fname, is_local%wrap%FBAtm_a, rc=rc) +! call FieldBundle_RWFields(mode,fname,is_local%wrap%FBAtm_a,read_rest_FBAtm_a,rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return #endif + + fname = trim(bfname)//'_FBIce_i_restart.nc' + call FieldBundle_RWFields(mode, fname, is_local%wrap%FBIce_i, rc=rc) +! call FieldBundle_RWFields(mode,fname,is_local%wrap%FBIce_i,read_rest_FBIce_i,rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + + fname = trim(bfname)//'_FBOcn_o_restart.nc' + call FieldBundle_RWFields(mode, fname, is_local%wrap%FBOcn_o, rc=rc) +! call FieldBundle_RWFields(mode,fname,is_local%wrap%FBOcn_o,read_rest_FBOCN_o,rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + + fname = trim(bfname)//'_FBLnd_l_restart.nc' + call FieldBundle_RWFields(mode, fname, is_local%wrap%FBLnd_l, rc=rc) +! call FieldBundle_RWFields(mode,fname,is_local%wrap%FBLnd_l,read_rest_FBLnd_l,rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + + fname = trim(bfname)//'_FBHyd_h_restart.nc' + call FieldBundle_RWFields(mode, fname, is_local%wrap%FBHyd_h, rc=rc) +! call FieldBundle_RWFields(mode,fname,is_local%wrap%FBHyd_h,read_rest_FBHyd_h,rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + + fname = trim(bfname)//'_FBAtmOcn_o_restart.nc' + call FieldBundle_RWFields(mode, fname, is_local%wrap%FBAtmOcn_o, rc=rc) +! call FieldBundle_RWFields(mode,fname,is_local%wrap%FBAtmOcn_o,read_rest_FBAtmOcn_o,rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + if (mode == 'read') then call fieldBundle_copy(NState_AtmImp, is_local%wrap%FBAtm_a, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out - endif + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return - fname = trim(bfname)//'_FBIce_i_restart.nc' - call FieldBundle_RWFields(mode,fname,is_local%wrap%FBIce_i,read_rest_FBIce_i,rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out - if (mode == 'read') then call fieldBundle_copy(NState_IceImp, is_local%wrap%FBIce_i, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out - endif + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return - fname = trim(bfname)//'_FBOcn_o_restart.nc' - call FieldBundle_RWFields(mode,fname,is_local%wrap%FBOcn_o,read_rest_FBOCN_o,rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out - if (mode == 'read') then call fieldBundle_copy(NState_OcnImp, is_local%wrap%FBOcn_o, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out - endif + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return - fname = trim(bfname)//'_FBLnd_l_restart.nc' - call FieldBundle_RWFields(mode,fname,is_local%wrap%FBLnd_l,read_rest_FBLnd_l,rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out - if (mode == 'read') then call fieldBundle_copy(NState_LndImp, is_local%wrap%FBLnd_l, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out - endif + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return - fname = trim(bfname)//'_FBHyd_h_restart.nc' - call FieldBundle_RWFields(mode,fname,is_local%wrap%FBHyd_h,read_rest_FBHyd_h,rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out - if (mode == 'read') then call fieldBundle_copy(NState_HydImp, is_local%wrap%FBHyd_h, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return endif - fname = trim(bfname)//'_FBAtmOcn_o_restart.nc' - call FieldBundle_RWFields(mode,fname,is_local%wrap%FBAtmOcn_o,read_rest_FBAtmOcn_o,rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out - funit = 1101 fname = trim(bfname)//'_scalars_restart.txt' if (mode == 'write') then @@ -6076,26 +6454,26 @@ subroutine Mediator_restart(gcomp,mode,bfname,rc) open(funit,file=fname,form='formatted') ! DCR - temporary skip reading Lnd and Hyd until components are added to test case ! restart files - is_local%wrap%accumcntAtm=0 - is_local%wrap%accumcntOcn=0 - is_local%wrap%accumcntIce=0 - is_local%wrap%accumcntAtmOcn=0 - is_local%wrap%accumcntLnd=0 - is_local%wrap%accumcntHyd=0 + is_local%wrap%accumcntAtm = 0 + is_local%wrap%accumcntOcn = 0 + is_local%wrap%accumcntIce = 0 + is_local%wrap%accumcntAtmOcn = 0 + is_local%wrap%accumcntLnd = 0 + is_local%wrap%accumcntHyd = 0 read (funit,*) is_local%wrap%accumcntAtm read (funit,*) is_local%wrap%accumcntOcn read (funit,*) is_local%wrap%accumcntIce read (funit,*) is_local%wrap%accumcntAtmOcn -! read (funit,*) is_local%wrap%accumcntLnd -! read (funit,*) is_local%wrap%accumcntHyd +! read (funit,*) is_local%wrap%accumcntLnd +! read (funit,*) is_local%wrap%accumcntHyd close(funit) - else - read_rest_FBaccumAtm = .false. - read_rest_FBaccumOcn = .false. - read_rest_FBaccumIce = .false. - read_rest_FBaccumLnd = .false. - read_rest_FBaccumHyd = .false. - read_rest_FBaccumAtmOcn = .false. +! else +! read_rest_FBaccumAtm = .false. +! read_rest_FBaccumOcn = .false. +! read_rest_FBaccumIce = .false. +! read_rest_FBaccumLnd = .false. +! read_rest_FBaccumHyd = .false. +! read_rest_FBaccumAtmOcn = .false. endif endif @@ -6107,11 +6485,12 @@ end subroutine Mediator_restart !----------------------------------------------------------------------------- - subroutine FieldBundle_RWFields(mode,fname,FB,flag,rc) + subroutine FieldBundle_RWFields(mode,fname,FB,rc) +! subroutine FieldBundle_RWFields(mode,fname,FB,flag,rc) character(len=*) :: mode character(len=*) :: fname type(ESMF_FieldBundle) :: FB - logical,optional :: flag +! logical,optional :: flag integer,optional :: rc ! local variables @@ -6129,20 +6508,20 @@ subroutine FieldBundle_RWFields(mode,fname,FB,flag,rc) if (mode == 'write') then call ESMF_LogWrite(trim(subname)//": write "//trim(fname), ESMF_LOGMSG_INFO, rc=dbrc) call ESMF_FieldBundleWrite(FB, fname, & - singleFile=.true., status=ESMF_FILESTATUS_REPLACE, iofmt=ESMF_IOFMT_NETCDF, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + singleFile=.true., status=ESMF_FILESTATUS_REPLACE, iofmt=ESMF_IOFMT_NETCDF, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return call fieldBundle_diagnose(FB, 'write '//trim(fname), rc) elseif (mode == 'read') then - inquire(file=fname,exist=fexists) + inquire(file = fname,exist=fexists) - if(.not.fexists .and. .not. coldstart)then - call ESMF_LogWrite(trim(fname)//' does not exist', ESMF_LOGMSG_INFO, rc=dbrc) - call ESMF_Finalize(endflag=ESMF_END_ABORT) + if (.not.fexists .and. .not. coldstart) then + call ESMF_LogWrite(trim(fname)//' does not exist', ESMF_LOGMSG_INFO, rc=dbrc) + call ESMF_Finalize(endflag=ESMF_END_ABORT) endif if (fexists) then call ESMF_LogWrite(trim(subname)//": read "//trim(fname), ESMF_LOGMSG_INFO, rc=dbrc) + !----------------------------------------------------------------------------------------------------- ! tcraig, ESMF_FieldBundleRead fails if a field is not on the field bundle, but we really want to just ! ignore that field and read the rest, so instead read each field one at a time through ESMF_FieldRead @@ -6151,23 +6530,21 @@ subroutine FieldBundle_RWFields(mode,fname,FB,flag,rc) ! if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & ! line=__LINE__, file=__FILE__)) call ESMF_LogWrite(trim(subname)//' WARNING missing fields',rc=dbrc) !----------------------------------------------------------------------------------------------------- + call ESMF_FieldBundleGet(FB, fieldCount=fieldCount, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return do n = 1,fieldCount call fieldBundle_getName(FB, n, name, rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return call fieldBundle_getFieldN(FB, n, field, rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return call ESMF_FieldRead (field, fname, iofmt=ESMF_IOFMT_NETCDF, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) call ESMF_LogWrite(trim(subname)//' WARNING missing field '//trim(name),rc=dbrc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) & + call ESMF_LogWrite(trim(subname)//' WARNING missing field '//trim(name),rc=dbrc) enddo call fieldBundle_diagnose(FB, 'read '//trim(fname), rc) - if (present(flag)) flag = .true. +! if (present(flag)) flag = .true. endif else call ESMF_LogWrite(trim(subname)//": mode WARNING "//trim(fname)//" mode="//trim(mode), ESMF_LOGMSG_INFO, rc=dbrc) @@ -6182,19 +6559,20 @@ end subroutine FieldBundle_RWFields ! This subroutine requires ESMFv8 - for coupled FV3 #ifdef FV3_CPLD - subroutine FieldBundle_RWFields_tiles(mode,fname,FB,flag,rc) - character(len=*) :: mode - character(len=*) :: fname + subroutine FieldBundle_RWFields_tiles(mode,fname,FB,rc) +! subroutine FieldBundle_RWFields_tiles(mode,fname,FB,flag,rc) + character(len=*) :: mode + character(len=*) :: fname type(ESMF_FieldBundle) :: FB - logical,optional :: flag - integer,optional :: rc +! logical,optional :: flag + integer,optional :: rc ! local variables - type(ESMF_Field),allocatable :: flds(:) - type(ESMF_GridComp) :: IOComp - type(ESMF_Grid) :: gridFv3 - character(len=ESMF_MAXSTR) :: name - character(len=ESMF_MAXSTR) :: fname_tile1 + type(ESMF_Field), allocatable :: flds(:) + type(ESMF_GridComp) :: IOComp + type(ESMF_Grid) :: gridFv3 + character(len=ESMF_MAXSTR) :: name + character(len=ESMF_MAXSTR) :: fname_tile1 integer :: fieldcount, n logical :: fexists character(len=*),parameter :: subname='(module_MEDIATOR:FieldBundle_RWFields_tiles)' @@ -6205,84 +6583,75 @@ subroutine FieldBundle_RWFields_tiles(mode,fname,FB,flag,rc) endif call ESMF_FieldBundleGet(FB, fieldCount=fieldCount, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return - !write(msgString,*) trim(subname)//' fieldCount = ',fieldCount - !call ESMF_LogWrite(trim(msgString), ESMF_LOGMSG_INFO, rc=dbrc) + write(msgString,*) trim(subname)//' fieldCount = ',fieldCount + call ESMF_LogWrite(trim(msgString), ESMF_LOGMSG_INFO, rc=dbrc) - allocate(flds(fieldCount)) + allocate(flds(fieldCount)) if (mode == 'write') then - call ESMF_LogWrite(trim(subname)//": write "//trim(fname)// & - "tile1-tile6", ESMF_LOGMSG_INFO, rc=dbrc) - - call fieldBundle_getFieldN(FB, 1, flds(1), rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + call ESMF_LogWrite(trim(subname)//": write "//trim(fname)// & + "tile1-tile6", ESMF_LOGMSG_INFO, rc=dbrc) + call fieldBundle_getFieldN(FB, 1, flds(1), rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return - call ESMF_FieldGet(flds(1), grid=gridFv3, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + call ESMF_FieldGet(flds(1), grid=gridFv3, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return - IOComp = ESMFIO_Create(gridFv3, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out - call ESMF_LogWrite(trim(subname)//": write "//trim(fname), ESMF_LOGMSG_INFO, rc=dbrc) + IOComp = ESMFIO_Create(gridFv3, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call ESMF_LogWrite(trim(subname)//": write "//trim(fname), ESMF_LOGMSG_INFO, rc=dbrc) - do n=2, fieldCount - call fieldBundle_getFieldN(FB, n, flds(n), rc) - enddo + do n=2, fieldCount + call fieldBundle_getFieldN(FB, n, flds(n), rc) + enddo - call ESMFIO_Write(IOComp, fname, flds, filePath='./', rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + call ESMFIO_Write(IOComp, fname, flds, filePath='./', rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return elseif (mode == 'read') then - fname_tile1='mediator_FBAtm_a_restart.tile1.nc' - inquire(file=fname_tile1,exist=fexists) + fname_tile1 = 'mediator_FBAtm_a_restart.tile1.nc' + inquire(file = fname_tile1,exist=fexists) - if(.not.fexists .and. .not. coldstart)then - call ESMF_LogWrite(trim(fname_tile1)//' does not exist', ESMF_LOGMSG_INFO, rc=dbrc) - call ESMF_Finalize(endflag=ESMF_END_ABORT) + if (.not.fexists .and. .not. coldstart) then + call ESMF_LogWrite(trim(fname_tile1)//' does not exist', ESMF_LOGMSG_INFO, rc=dbrc) + call ESMF_Finalize(endflag=ESMF_END_ABORT) endif if (fexists) then - call ESMF_LogWrite(trim(subname)//": read "//trim(fname)// & - "tile1-tile6", ESMF_LOGMSG_INFO, rc=dbrc) + call ESMF_LogWrite(trim(subname)//": read "//trim(fname)// & + "tile1-tile6", ESMF_LOGMSG_INFO, rc=dbrc) - call fieldBundle_getFieldN(FB, 1, flds(1), rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + call fieldBundle_getFieldN(FB, 1, flds(1), rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return - call ESMF_FieldGet(flds(1), grid=gridFv3, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + call ESMF_FieldGet(flds(1), grid=gridFv3, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return - IOComp = ESMFIO_Create(gridFv3, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + IOComp = ESMFIO_Create(gridFv3, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return - do n=2, fieldCount - call fieldBundle_getFieldN(FB, n, flds(n), rc) - enddo + do n=2, fieldCount + call fieldBundle_getFieldN(FB, n, flds(n), rc) + enddo - call ESMFIO_Read(IOComp, fname, flds, filePath='./', rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + call ESMFIO_Read(IOComp, fname, flds, filePath='./', rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return - if (present(flag)) flag = .true. - endif +! if (present(flag)) flag = .true. + endif else - call ESMF_LogWrite(trim(subname)//": mode WARNING "//trim(fname)//" mode="//trim(mode), ESMF_LOGMSG_INFO, rc=dbrc) + call ESMF_LogWrite(trim(subname)//": mode WARNING "//trim(fname)//" mode="//trim(mode), ESMF_LOGMSG_INFO, rc=dbrc) endif + ! -- Finalize ESMFIO + deallocate(flds) call ESMFIO_Destroy(IOComp, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) call ESMF_Finalize() + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) call ESMF_Finalize() if (dbug_flag > 5) then call ESMF_LogWrite(trim(subname)//trim(fname)//": done", ESMF_LOGMSG_INFO, rc=dbrc) @@ -6293,17 +6662,19 @@ end subroutine FieldBundle_RWFields_tiles !----------------------------------------------------------------------------- - subroutine Compute_RHs(FBsrc, FBdst, bilnrmap, consfmap, consdmap, patchmap, fcopymap, & - nearestmap, srcMaskValue, dstMaskValue, & + subroutine Compute_RHs(FBsrc, FBdst, bilnrmap, consfmap, consdmap, con2fmap, con2dmap, & + patchmap, fcopymap, nrnbrmap, srcMaskValue, dstMaskValue, & fldlist1, fldlist2, fldlist3, fldlist4, string, rc) type(ESMF_FieldBundle) :: FBsrc type(ESMF_FieldBundle) :: FBdst type(ESMF_Routehandle),optional :: bilnrmap type(ESMF_Routehandle),optional :: consfmap type(ESMF_Routehandle),optional :: consdmap + type(ESMF_Routehandle),optional :: con2fmap + type(ESMF_Routehandle),optional :: con2dmap type(ESMF_Routehandle),optional :: patchmap type(ESMF_Routehandle),optional :: fcopymap - type(ESMF_Routehandle),optional :: nearestmap + type(ESMF_Routehandle),optional :: nrnbrmap integer ,optional :: srcMaskValue integer ,optional :: dstMaskValue type(fld_list_type) ,optional :: fldlist1 @@ -6317,7 +6688,7 @@ subroutine Compute_RHs(FBsrc, FBdst, bilnrmap, consfmap, consdmap, patchmap, fco integer :: n character(len=128) :: lstring logical :: do_consf, do_consd, do_bilnr, do_patch, do_fcopy - logical :: do_nearest + logical :: do_con2f, do_con2d, do_nrnbr integer :: lsrcMaskValue, ldstMaskValue type(ESMF_Field) :: fldsrc, flddst real(ESMF_KIND_R8), pointer :: factorList(:) @@ -6365,63 +6736,81 @@ subroutine Compute_RHs(FBsrc, FBdst, bilnrmap, consfmap, consdmap, patchmap, fco do_bilnr = .true. do_consf = .true. do_consd = .true. + do_con2f = .true. + do_con2d = .true. do_patch = .true. do_fcopy = .true. - do_nearest = .true. + do_nrnbr = .true. else do_bilnr = .false. do_consf = .false. do_consd = .false. + do_con2f = .false. + do_con2d = .false. do_patch = .false. do_fcopy = .false. - do_nearest = .false. + do_nrnbr = .false. endif if (present(fldlist1)) then do n = 1,fldlist1%num - if (fldlist1%mapping(n) == 'bilinear' ) do_bilnr = .true. - if (fldlist1%mapping(n) == "conservefrac") do_consf = .true. - if (fldlist1%mapping(n) == "conservedst" ) do_consd = .true. - if (fldlist1%mapping(n) == 'patch' ) do_patch = .true. - if (fldlist1%mapping(n) == 'copy' ) do_fcopy = .true. + if (fldlist1%mapping(n) == 'bilinear' ) do_bilnr = .true. + if (fldlist1%mapping(n) == "conservefrac" ) do_consf = .true. + if (fldlist1%mapping(n) == "conservedst" ) do_consd = .true. + if (fldlist1%mapping(n) == "conserve2frac") do_con2f = .true. + if (fldlist1%mapping(n) == "conserve2dst" ) do_con2d = .true. + if (fldlist1%mapping(n) == 'patch' ) do_patch = .true. + if (fldlist1%mapping(n) == 'copy' ) do_fcopy = .true. + if (fldlist1%mapping(n) == 'neareststod' ) do_nrnbr = .true. enddo endif if (present(fldlist2)) then do n = 1,fldlist2%num - if (fldlist2%mapping(n) == 'bilinear' ) do_bilnr = .true. - if (fldlist2%mapping(n) == "conservefrac") do_consf = .true. - if (fldlist2%mapping(n) == "conservedst" ) do_consd = .true. - if (fldlist2%mapping(n) == 'patch' ) do_patch = .true. - if (fldlist2%mapping(n) == 'copy' ) do_fcopy = .true. + if (fldlist2%mapping(n) == 'bilinear' ) do_bilnr = .true. + if (fldlist2%mapping(n) == "conservefrac" ) do_consf = .true. + if (fldlist2%mapping(n) == "conservedst " ) do_consd = .true. + if (fldlist2%mapping(n) == "conserve2frac") do_con2f = .true. + if (fldlist2%mapping(n) == "conserve2dst" ) do_con2d = .true. + if (fldlist2%mapping(n) == 'patch' ) do_patch = .true. + if (fldlist2%mapping(n) == 'copy' ) do_fcopy = .true. + if (fldlist2%mapping(n) == 'neareststod' ) do_nrnbr = .true. enddo endif if (present(fldlist3)) then do n = 1,fldlist3%num - if (fldlist3%mapping(n) == 'bilinear' ) do_bilnr = .true. - if (fldlist3%mapping(n) == "conservefrac") do_consf = .true. - if (fldlist3%mapping(n) == "conservedst" ) do_consd = .true. - if (fldlist3%mapping(n) == 'patch' ) do_patch = .true. - if (fldlist3%mapping(n) == 'copy' ) do_fcopy = .true. + if (fldlist3%mapping(n) == 'bilinear' ) do_bilnr = .true. + if (fldlist3%mapping(n) == "conservefrac" ) do_consf = .true. + if (fldlist3%mapping(n) == "conservedst" ) do_consd = .true. + if (fldlist3%mapping(n) == "conserve2frac") do_con2f = .true. + if (fldlist3%mapping(n) == "conserve2dst" ) do_con2d = .true. + if (fldlist3%mapping(n) == 'patch' ) do_patch = .true. + if (fldlist3%mapping(n) == 'copy' ) do_fcopy = .true. + if (fldlist3%mapping(n) == 'neareststod' ) do_nrnbr = .true. enddo endif if (present(fldlist4)) then do n = 1,fldlist4%num - if (fldlist4%mapping(n) == 'bilinear' ) do_bilnr = .true. - if (fldlist4%mapping(n) == "conservefrac") do_consf = .true. - if (fldlist4%mapping(n) == "conservedst" ) do_consd = .true. - if (fldlist4%mapping(n) == 'patch' ) do_patch = .true. - if (fldlist4%mapping(n) == 'copy' ) do_fcopy = .true. + if (fldlist4%mapping(n) == 'bilinear' ) do_bilnr = .true. + if (fldlist4%mapping(n) == "conservefrac" ) do_consf = .true. + if (fldlist4%mapping(n) == "conservedst" ) do_consd = .true. + if (fldlist4%mapping(n) == "conserve2frac") do_con2f = .true. + if (fldlist4%mapping(n) == "conserve2dst" ) do_con2d = .true. + if (fldlist4%mapping(n) == 'patch' ) do_patch = .true. + if (fldlist4%mapping(n) == 'copy' ) do_fcopy = .true. + if (fldlist4%mapping(n) == 'neareststod' ) do_nrnbr = .true. enddo endif if (.not.present(bilnrmap)) do_bilnr = .false. if (.not.present(consfmap)) do_consf = .false. if (.not.present(consdmap)) do_consd = .false. + if (.not.present(con2fmap)) do_con2f = .false. + if (.not.present(con2dmap)) do_con2d = .false. if (.not.present(patchmap)) do_patch = .false. if (.not.present(fcopymap)) do_fcopy = .false. - if (present(nearestmap)) do_nearest = .true. + if ( present(nrnbrmap)) do_nrnbr = .true. !--------------------------------------------------- !--- get single fields from bundles @@ -6429,27 +6818,24 @@ subroutine Compute_RHs(FBsrc, FBdst, bilnrmap, consfmap, consdmap, patchmap, fco !--------------------------------------------------- call fieldBundle_getFieldN(FBsrc, 1, fldsrc, rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return call fieldBundle_getFieldN(FBdst, 1, flddst, rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return !--------------------------------------------------- !--- bilinear !--------------------------------------------------- if (do_bilnr) then - call ESMF_FieldRegridStore(fldsrc, flddst, routehandle=bilnrmap, & - srcMaskValues=(/lsrcMaskValue/), dstMaskValues=(/ldstMaskValue/), & - regridmethod=ESMF_REGRIDMETHOD_BILINEAR, & - polemethod=polemethod, & - srcTermProcessing=srcTermProcessing_Value, & - factorList=factorList, ignoreDegenerate=.true., & - unmappedaction=ESMF_UNMAPPEDACTION_IGNORE, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + call ESMF_FieldRegridStore(fldsrc, flddst, routehandle=bilnrmap, & + srcMaskValues=(/lsrcMaskValue/), dstMaskValues=(/ldstMaskValue/), & + regridmethod=ESMF_REGRIDMETHOD_BILINEAR, & + polemethod=polemethod, & + srcTermProcessing=srcTermProcessing_Value, & + factorList=factorList, ignoreDegenerate=.true., & + unmappedaction=ESMF_UNMAPPEDACTION_IGNORE, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return #if 0 if (trim(string)=="o2a_weights") then call ESMF_VMGetCurrent(vm) @@ -6459,11 +6845,9 @@ subroutine Compute_RHs(FBsrc, FBdst, bilnrmap, consfmap, consdmap, patchmap, fco #endif if (rhprint_flag) then call NUOPC_Write(factorList, "array_med_"//trim(lstring)//"_bilnr.nc", rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return call ESMF_RouteHandlePrint(bilnrmap, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return endif if (ESMF_RouteHandleIsCreated(bilnrmap, rc=rc)) then call ESMF_LogWrite(trim(subname)//trim(lstring)//": computed RH bilnr", ESMF_LOGMSG_INFO, rc=dbrc) @@ -6471,21 +6855,20 @@ subroutine Compute_RHs(FBsrc, FBdst, bilnrmap, consfmap, consdmap, patchmap, fco call ESMF_LogWrite(trim(subname)//trim(lstring)//": failed RH bilnr", ESMF_LOGMSG_INFO, rc=dbrc) endif endif - + !--------------------------------------------------- !--- conservative frac !--------------------------------------------------- if (do_consf) then - call ESMF_FieldRegridStore(fldsrc, flddst, routehandle=consfmap, & - srcMaskValues=(/lsrcMaskValue/), dstMaskValues=(/ldstMaskValue/), & - regridmethod=ESMF_REGRIDMETHOD_CONSERVE, & - normType=ESMF_NORMTYPE_FRACAREA, & - srcTermProcessing=srcTermProcessing_Value, & - factorList=factorList, ignoreDegenerate=.true., & - unmappedaction=ESMF_UNMAPPEDACTION_IGNORE, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + call ESMF_FieldRegridStore(fldsrc, flddst, routehandle=consfmap, & + srcMaskValues=(/lsrcMaskValue/), dstMaskValues=(/ldstMaskValue/), & + regridmethod=ESMF_REGRIDMETHOD_CONSERVE, & + normType=ESMF_NORMTYPE_FRACAREA, & + srcTermProcessing=srcTermProcessing_Value, & + factorList=factorList, ignoreDegenerate=.true., & + unmappedaction=ESMF_UNMAPPEDACTION_IGNORE, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return #if 0 if (trim(string)=="o2a_weights") then call ESMF_VMGetCurrent(vm) @@ -6495,11 +6878,9 @@ subroutine Compute_RHs(FBsrc, FBdst, bilnrmap, consfmap, consdmap, patchmap, fco #endif if (rhprint_flag) then call NUOPC_Write(factorList, "array_med_"//trim(lstring)//"_consf.nc", rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return call ESMF_RouteHandlePrint(consfmap, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return endif if (ESMF_RouteHandleIsCreated(consfmap, rc=rc)) then call ESMF_LogWrite(trim(subname)//trim(lstring)//": computed RH consf", ESMF_LOGMSG_INFO, rc=dbrc) @@ -6507,28 +6888,25 @@ subroutine Compute_RHs(FBsrc, FBdst, bilnrmap, consfmap, consdmap, patchmap, fco call ESMF_LogWrite(trim(subname)//trim(lstring)//": failed RH consf", ESMF_LOGMSG_INFO, rc=dbrc) endif endif - + !--------------------------------------------------- !--- conservative dst !--------------------------------------------------- if (do_consd) then - call ESMF_FieldRegridStore(fldsrc, flddst, routehandle=consdmap, & - srcMaskValues=(/lsrcMaskValue/), dstMaskValues=(/ldstMaskValue/), & - regridmethod=ESMF_REGRIDMETHOD_CONSERVE, & - normType=ESMF_NORMTYPE_DSTAREA, & - srcTermProcessing=srcTermProcessing_Value, & - factorList=factorList, ignoreDegenerate=.true., & - unmappedaction=ESMF_UNMAPPEDACTION_IGNORE, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + call ESMF_FieldRegridStore(fldsrc, flddst, routehandle=consdmap, & + srcMaskValues=(/lsrcMaskValue/), dstMaskValues=(/ldstMaskValue/), & + regridmethod=ESMF_REGRIDMETHOD_CONSERVE, & + normType=ESMF_NORMTYPE_DSTAREA, & + srcTermProcessing=srcTermProcessing_Value, & + factorList=factorList, ignoreDegenerate=.true., & + unmappedaction=ESMF_UNMAPPEDACTION_IGNORE, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return if (rhprint_flag) then call NUOPC_Write(factorList, "array_med_"//trim(lstring)//"_consd.nc", rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return call ESMF_RouteHandlePrint(consdmap, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return endif if (ESMF_RouteHandleIsCreated(consdmap, rc=rc)) then call ESMF_LogWrite(trim(subname)//trim(lstring)//": computed RH consd", ESMF_LOGMSG_INFO, rc=dbrc) @@ -6537,55 +6915,108 @@ subroutine Compute_RHs(FBsrc, FBdst, bilnrmap, consfmap, consdmap, patchmap, fco endif endif + !--------------------------------------------------- + !--- conservative 2nd order frac + !--------------------------------------------------- + + if (do_con2f) then + call ESMF_FieldRegridStore(fldsrc, flddst, routehandle=con2fmap, & + srcMaskValues=(/lsrcMaskValue/), dstMaskValues=(/ldstMaskValue/), & + regridmethod=ESMF_REGRIDMETHOD_CONSERVE_2ND, & + normType=ESMF_NORMTYPE_FRACAREA, & + srcTermProcessing=srcTermProcessing_Value, & + factorList=factorList, ignoreDegenerate=.true., & + unmappedaction=ESMF_UNMAPPEDACTION_IGNORE, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return +#if 0 +if (trim(string)=="o2a_weights") then + call ESMF_VMGetCurrent(vm) + call ESMF_VMBarrier(vm) + call ESMF_Finalize(endflag=ESMF_END_ABORT) +endif +#endif + if (rhprint_flag) then + call NUOPC_Write(factorList, "array_med_"//trim(lstring)//"_con2f.nc", rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call ESMF_RouteHandlePrint(con2fmap, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + endif + if (ESMF_RouteHandleIsCreated(con2fmap, rc=rc)) then + call ESMF_LogWrite(trim(subname)//trim(lstring)//": computed RH con2f", ESMF_LOGMSG_INFO, rc=dbrc) + else + call ESMF_LogWrite(trim(subname)//trim(lstring)//": failed RH con2f", ESMF_LOGMSG_INFO, rc=dbrc) + endif + endif + + !--------------------------------------------------- + !--- conservative 2nd order dst + !--------------------------------------------------- + + if (do_con2d) then + call ESMF_FieldRegridStore(fldsrc, flddst, routehandle=con2dmap, & + srcMaskValues=(/lsrcMaskValue/), dstMaskValues=(/ldstMaskValue/), & + regridmethod=ESMF_REGRIDMETHOD_CONSERVE_2ND, & + normType=ESMF_NORMTYPE_DSTAREA, & + srcTermProcessing=srcTermProcessing_Value, & + factorList=factorList, ignoreDegenerate=.true., & + unmappedaction=ESMF_UNMAPPEDACTION_IGNORE, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + if (rhprint_flag) then + call NUOPC_Write(factorList, "array_med_"//trim(lstring)//"_con2d.nc", rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call ESMF_RouteHandlePrint(con2dmap, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + endif + if (ESMF_RouteHandleIsCreated(con2dmap, rc=rc)) then + call ESMF_LogWrite(trim(subname)//trim(lstring)//": computed RH con2d", ESMF_LOGMSG_INFO, rc=dbrc) + else + call ESMF_LogWrite(trim(subname)//trim(lstring)//": failed RH con2d", ESMF_LOGMSG_INFO, rc=dbrc) + endif + endif + !--------------------------------------------------- !--- nearest stod !--------------------------------------------------- - if (do_nearest) then - call ESMF_FieldRegridStore(fldsrc, flddst, routehandle=nearestmap, & - srcMaskValues=(/lsrcMaskValue/), dstMaskValues=(/ldstMaskValue/), & - regridmethod=ESMF_REGRIDMETHOD_NEAREST_STOD, & - srcTermProcessing=srcTermProcessing_Value, & - factorList=factorList, ignoreDegenerate=.true., & - unmappedaction=ESMF_UNMAPPEDACTION_IGNORE, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (do_nrnbr) then + call ESMF_FieldRegridStore(fldsrc, flddst, routehandle=nrnbrmap, & + srcMaskValues=(/lsrcMaskValue/), dstMaskValues=(/ldstMaskValue/), & + regridmethod=ESMF_REGRIDMETHOD_NEAREST_STOD, & + srcTermProcessing=srcTermProcessing_Value, & + factorList=factorList, ignoreDegenerate=.true., & + unmappedaction=ESMF_UNMAPPEDACTION_IGNORE, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return if (rhprint_flag) then - call NUOPC_Write(factorList, "array_med_"//trim(lstring)//"_nearest.nc", rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out - call ESMF_RouteHandlePrint(nearestmap, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + call NUOPC_Write(factorList, "array_med_"//trim(lstring)//"_nrnbr.nc", rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call ESMF_RouteHandlePrint(nrnbrmap, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return endif - if (ESMF_RouteHandleIsCreated(nearestmap, rc=rc)) then - call ESMF_LogWrite(trim(subname)//trim(lstring)//": computed RH nearest", ESMF_LOGMSG_INFO, rc=dbrc) + if (ESMF_RouteHandleIsCreated(nrnbrmap, rc=rc)) then + call ESMF_LogWrite(trim(subname)//trim(lstring)//": computed RH nrnbr", ESMF_LOGMSG_INFO, rc=dbrc) else - call ESMF_LogWrite(trim(subname)//trim(lstring)//": failed RH nearest", ESMF_LOGMSG_INFO, rc=dbrc) + call ESMF_LogWrite(trim(subname)//trim(lstring)//": failed RH nrnbr", ESMF_LOGMSG_INFO, rc=dbrc) endif endif - + !--------------------------------------------------- !--- patch !--------------------------------------------------- if (do_patch) then - call ESMF_FieldRegridStore(fldsrc, flddst, routehandle=patchmap, & - srcMaskValues=(/lsrcMaskValue/), dstMaskValues=(/ldstMaskValue/), & - regridmethod=ESMF_REGRIDMETHOD_PATCH, & - polemethod=polemethod, & - srcTermProcessing=srcTermProcessing_Value, & - factorList=factorList, ignoreDegenerate=.true., & - unmappedaction=ESMF_UNMAPPEDACTION_IGNORE, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + call ESMF_FieldRegridStore(fldsrc, flddst, routehandle=patchmap, & + srcMaskValues=(/lsrcMaskValue/), dstMaskValues=(/ldstMaskValue/), & + regridmethod=ESMF_REGRIDMETHOD_PATCH, & + polemethod=polemethod, & + srcTermProcessing=srcTermProcessing_Value, & + factorList=factorList, ignoreDegenerate=.true., & + unmappedaction=ESMF_UNMAPPEDACTION_IGNORE, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return if (rhprint_flag) then call NUOPC_Write(factorList, "array_med_"//trim(lstring)//"_patch.nc", rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return call ESMF_RouteHandlePrint(patchmap, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return endif if (ESMF_RouteHandleIsCreated(patchmap, rc=rc)) then call ESMF_LogWrite(trim(subname)//trim(lstring)//": computed RH patch", ESMF_LOGMSG_INFO, rc=dbrc) @@ -6599,15 +7030,13 @@ subroutine Compute_RHs(FBsrc, FBdst, bilnrmap, consfmap, consdmap, patchmap, fco !--------------------------------------------------- if (do_fcopy) then - call ESMF_FieldRedistStore(fldsrc, flddst, & - routehandle=fcopymap, & - ignoreUnmatchedIndices=.true., rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + call ESMF_FieldRedistStore(fldsrc, flddst, & + routehandle=fcopymap, & + ignoreUnmatchedIndices=.true., rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return if (rhprint_flag) then call ESMF_RouteHandlePrint(fcopymap, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return endif if (ESMF_RouteHandleIsCreated(fcopymap, rc=rc)) then call ESMF_LogWrite(trim(subname)//trim(lstring)//": computed RH fcopy", ESMF_LOGMSG_INFO, rc=dbrc) @@ -6652,14 +7081,12 @@ subroutine Grid_CreateCoords(gridNew,gridOld,rc) call ESMF_LogWrite(trim(subname)//": tcxA", ESMF_LOGMSG_INFO, rc=dbrc) call ESMF_GridGet(gridold, dimCount=dimCount, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return allocate(gridEdgeLWidth(dimCount),gridEdgeUWidth(dimCount)) call ESMF_GridGet(gridold,distgrid=distgrid, coordSys=coordSys, indexflag=indexflag, dimCount=dimCount, & - gridEdgeLWidth=gridEdgeLWidth, gridEdgeUWidth=gridEdgeUWidth, localDECount=localDECount, rc=rc) + gridEdgeLWidth=gridEdgeLWidth, gridEdgeUWidth=gridEdgeUWidth, localDECount=localDECount, rc=rc) ! localDECount=localDECount, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return call ESMF_LogWrite(trim(subname)//": tcxB", ESMF_LOGMSG_INFO, rc=dbrc) @@ -6677,58 +7104,56 @@ subroutine Grid_CreateCoords(gridNew,gridOld,rc) call ESMF_LogWrite(trim(subname)//": tcxC", ESMF_LOGMSG_INFO, rc=dbrc) gridnew = ESMF_GridCreate(distgrid=distgrid, coordSys=coordSys, indexflag=indexflag, & - gridEdgeLWidth=gridEdgeLWidth, gridEdgeUWidth=gridEdgeUWidth, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + gridEdgeLWidth=gridEdgeLWidth, gridEdgeUWidth=gridEdgeUWidth, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return deallocate(gridEdgeLWidth, gridEdgeUWidth) call ESMF_GridAddCoord(gridnew, staggerLoc=ESMF_STAGGERLOC_CENTER, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call ESMF_GridAddCoord(gridnew, staggerLoc=ESMF_STAGGERLOC_CORNER, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return do localDE = 0,localDeCount-1 call ESMF_GridGetCoord(gridold, coordDim=1, localDE=localDE, & - staggerLoc=ESMF_STAGGERLOC_CENTER, farrayPtr=dataPtr1, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + staggerLoc=ESMF_STAGGERLOC_CENTER, farrayPtr=dataPtr1, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call ESMF_GridGetCoord(gridnew, coordDim=1, localDE=localDE, & - staggerLoc=ESMF_STAGGERLOC_CENTER, farrayPtr=dataPtr2, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + staggerLoc=ESMF_STAGGERLOC_CENTER, farrayPtr=dataPtr2, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + dataPtr2 = dataPtr1 call ESMF_GridGetCoord(gridold, coordDim=2, localDE=localDE, & - staggerLoc=ESMF_STAGGERLOC_CENTER, farrayPtr=dataPtr1, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + staggerLoc=ESMF_STAGGERLOC_CENTER, farrayPtr=dataPtr1, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call ESMF_GridGetCoord(gridnew, coordDim=2, localDE=localDE, & - staggerLoc=ESMF_STAGGERLOC_CENTER, farrayPtr=dataPtr2, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + staggerLoc=ESMF_STAGGERLOC_CENTER, farrayPtr=dataPtr2, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + dataPtr2 = dataPtr1 call ESMF_GridGetCoord(gridold, coordDim=1, localDE=localDE, & - staggerLoc=ESMF_STAGGERLOC_CORNER, farrayPtr=dataPtr1, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + staggerLoc=ESMF_STAGGERLOC_CORNER, farrayPtr=dataPtr1, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call ESMF_GridGetCoord(gridnew, coordDim=1, localDE=localDE, & - staggerLoc=ESMF_STAGGERLOC_CORNER, farrayPtr=dataPtr2, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + staggerLoc=ESMF_STAGGERLOC_CORNER, farrayPtr=dataPtr2, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + dataPtr2 = dataPtr1 call ESMF_GridGetCoord(gridold, coordDim=2, localDE=localDE, & - staggerLoc=ESMF_STAGGERLOC_CORNER, farrayPtr=dataPtr1, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + staggerLoc=ESMF_STAGGERLOC_CORNER, farrayPtr=dataPtr1, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call ESMF_GridGetCoord(gridnew, coordDim=2, localDE=localDE, & - staggerLoc=ESMF_STAGGERLOC_CORNER, farrayPtr=dataPtr2, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + staggerLoc=ESMF_STAGGERLOC_CORNER, farrayPtr=dataPtr2, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + dataPtr2 = dataPtr1 enddo @@ -6766,30 +7191,28 @@ subroutine fieldBundle_initFromFB(FBout, FBin, grid, name, rc) call ESMF_LogWrite(trim(subname)//": called", ESMF_LOGMSG_INFO, rc=dbrc) endif rc = ESMF_SUCCESS - + lname = 'undefined' if (present(name)) then lname = trim(name) endif call ESMF_FieldBundleGet(FBin, fieldCount=fieldCount, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + allocate(fieldNameList(fieldCount)) call ESMF_FieldBundleGet(FBin, fieldNameList=fieldNameList, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + if (present(grid)) then call fieldBundle_init(FBout, fieldNameList=fieldNameList, grid=grid, name=trim(lname), rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return else call ESMF_FieldBundleGet(FBin, grid=lgrid, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call fieldBundle_init(FBout, fieldNameList=fieldNameList, grid=lgrid, name=trim(lname), rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return endif deallocate(fieldNameList) @@ -6845,17 +7268,16 @@ subroutine fieldBundle_init(FieldBundle, fieldNameList, grid, State, name, rc) endif FieldBundle = ESMF_FieldBundleCreate(name=trim(lname), rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return if (present(fieldNameList)) then do n = 1, size(fieldNameList) field = ESMF_FieldCreate(grid, ESMF_TYPEKIND_R8, name=fieldNameList(n), rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call ESMF_FieldBundleAdd(FieldBundle, (/field/), rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + if (dbug_flag > 1) then call ESMF_LogWrite(trim(subname)//":"//trim(lname)//":add "//trim(fieldNameList(n)), ESMF_LOGMSG_INFO, rc=dbrc) endif @@ -6864,38 +7286,37 @@ subroutine fieldBundle_init(FieldBundle, fieldNameList, grid, State, name, rc) if (present(State)) then call ESMF_StateGet(State, itemCount=fieldCount, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + allocate(lfieldNameList(fieldCount)) call ESMF_StateGet(State, itemNameList=lfieldNameList, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + do n = 1, fieldCount if (present(grid)) then field = ESMF_FieldCreate(grid, ESMF_TYPEKIND_R8, name=lfieldNameList(n), rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call ESMF_FieldBundleAdd(FieldBundle, (/field/), rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + if (dbug_flag > 1) then call ESMF_LogWrite(trim(subname)//":"//trim(lname)//":add "//trim(lfieldNameList(n)), ESMF_LOGMSG_INFO, rc=dbrc) endif else call ESMF_StateGet(State, itemName=trim(lfieldNameList(n)), field=lfield, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return call ESMF_FieldGet(lfield, grid=lgrid, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return field = ESMF_FieldCreate(lgrid, ESMF_TYPEKIND_R8, name=lfieldNameList(n), rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call ESMF_FieldBundleAdd(FieldBundle, (/field/), rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + if (dbug_flag > 1) then call ESMF_LogWrite(trim(subname)//":"//trim(lname)//":add "//trim(lfieldNameList(n)), ESMF_LOGMSG_INFO, rc=dbrc) endif @@ -6905,8 +7326,7 @@ subroutine fieldBundle_init(FieldBundle, fieldNameList, grid, State, name, rc) endif ! present State call fieldBundle_reset(FieldBundle, value=spval_init, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return if (dbug_flag > 10) then call ESMF_LogWrite(trim(subname)//": done", ESMF_LOGMSG_INFO, rc=dbrc) @@ -6937,8 +7357,7 @@ subroutine fieldBundle_getName(FieldBundle, fieldnum, fieldname, rc) fieldname = ' ' call ESMF_FieldBundleGet(FieldBundle, fieldCount=fieldCount, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return if (fieldnum > fieldCount) then call ESMF_LogWrite(trim(subname)//": ERROR fieldnum > fieldCount ", ESMF_LOGMSG_ERROR, line=__LINE__, file=__FILE__, rc=dbrc) @@ -6948,8 +7367,7 @@ subroutine fieldBundle_getName(FieldBundle, fieldnum, fieldname, rc) allocate(fieldNameList(fieldCount)) call ESMF_FieldBundleGet(FieldBundle, fieldNameList=fieldNameList, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return fieldname = fieldNameList(fieldnum) @@ -6982,12 +7400,10 @@ subroutine fieldBundle_getFieldN(FieldBundle, fieldnum, field, rc) rc = ESMF_SUCCESS call fieldBundle_getName(FieldBundle, fieldnum, name, rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return call ESMF_FieldBundleGet(FieldBundle, fieldName=name, field=field, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return if (dbug_flag > 10) then call ESMF_LogWrite(trim(subname)//": done", ESMF_LOGMSG_INFO, rc=dbrc) @@ -7015,8 +7431,7 @@ subroutine fieldBundle_getFieldName(FieldBundle, fieldname, field, rc) rc = ESMF_SUCCESS call ESMF_FieldBundleGet(FieldBundle, fieldName=fieldname, field=field, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return if (dbug_flag > 10) then call ESMF_LogWrite(trim(subname)//": done", ESMF_LOGMSG_INFO, rc=dbrc) @@ -7046,23 +7461,22 @@ subroutine fieldBundle_clean(FieldBundle, rc) rc = ESMF_SUCCESS call ESMF_FieldBundleGet(FieldBundle, fieldCount=fieldCount, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + allocate(fieldNameList(fieldCount)) call ESMF_FieldBundleGet(FieldBundle, fieldNameList=fieldNameList, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + do n = 1, fieldCount call ESMF_FieldBundleGet(FieldBundle, fieldName=fieldNameList(n), field=field, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call ESMF_FieldDestroy(field, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return enddo call ESMF_FieldBundleDestroy(FieldBundle, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + deallocate(fieldNameList) if (dbug_flag > 10) then @@ -7088,7 +7502,7 @@ subroutine fieldBundle_reset(FieldBundle, value, rc) character(ESMF_MAXSTR) ,pointer :: fieldNameList(:) real(ESMF_KIND_R8) :: lvalue real(ESMF_KIND_R8), pointer :: dataPtr(:,:) - character(len=*),parameter :: subname='(module_MEDIATOR:fieldBundle_reset)' + character(len=*), parameter :: subname='(module_MEDIATOR:fieldBundle_reset)' if (dbug_flag > 10) then call ESMF_LogWrite(trim(subname)//": called", ESMF_LOGMSG_INFO, rc=dbrc) @@ -7101,21 +7515,21 @@ subroutine fieldBundle_reset(FieldBundle, value, rc) endif call ESMF_FieldBundleGet(FieldBundle, fieldCount=fieldCount, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + allocate(fieldNameList(fieldCount)) call ESMF_FieldBundleGet(FieldBundle, fieldNameList=fieldNameList, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + do n = 1, fieldCount call FieldBundle_GetFldPtr(FieldBundle, fieldNameList(n), dataPtr, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return +!$omp parallel do default(shared) private(i,j) do j=lbound(dataPtr,2),ubound(dataPtr,2) - do i=lbound(dataPtr,1),ubound(dataPtr,1) - dataPtr(i,j) = lvalue - enddo + do i=lbound(dataPtr,1),ubound(dataPtr,1) + dataPtr(i,j) = lvalue + enddo enddo enddo @@ -7153,11 +7567,10 @@ subroutine FieldBundle_FieldCopy(FBin,fldin,FBout,fldout,rc) FieldBundle_FldChk(FBout, trim(fldout), rc=rc)) then call FieldBundle_GetFldPtr(FBin, trim(fldin), dataPtrIn, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call FieldBundle_GetFldPtr(FBout, trim(fldout), dataPtrOut, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return if (.not.FldPtr_SameCheck(dataPtrIn, dataPtrOut, subname, rc)) then call ESMF_LogWrite(trim(subname)//": ERROR fname not present with FBin", ESMF_LOGMSG_ERROR, line=__LINE__, file=__FILE__, rc=dbrc) @@ -7183,23 +7596,26 @@ end subroutine FieldBundle_FieldCopy !----------------------------------------------------------------------------- - subroutine Fieldbundle_Regrid(fldlist, FBin, FBout, consfmap, consdmap, bilnrmap, patchmap, & - fcopymap,string, rc) + subroutine Fieldbundle_Regrid(fldlist, FBin, FBout, consfmap, consdmap, con2fmap, con2dmap, & + bilnrmap, patchmap, fcopymap, nrnbrmap, string, rc) type(fld_list_type) :: fldlist type(ESMF_FieldBundle) :: FBin type(ESMF_FieldBundle) :: FBout type(ESMF_Routehandle),optional :: consfmap type(ESMF_Routehandle),optional :: consdmap + type(ESMF_Routehandle),optional :: con2fmap + type(ESMF_Routehandle),optional :: con2dmap type(ESMF_Routehandle),optional :: bilnrmap type(ESMF_Routehandle),optional :: patchmap type(ESMF_Routehandle),optional :: fcopymap + type(ESMF_Routehandle),optional :: nrnbrmap character(len=*) ,optional :: string integer ,optional :: rc ! local variables integer :: n character(len=64) :: lstring - logical :: okconsf, okconsd, okbilnr, okpatch, okfcopy + logical :: okconsf, okconsd, okbilnr, okpatch, okfcopy, okcon2f, okcon2d, oknrnbr character(len=*),parameter :: subname='(module_MEDIATOR:Fieldbundle_Regrid)' rc = ESMF_SUCCESS @@ -7229,6 +7645,16 @@ subroutine Fieldbundle_Regrid(fldlist, FBin, FBout, consfmap, consdmap, bilnrmap if (ESMF_RouteHandleIsCreated(consdmap, rc=rc)) okconsd = .true. endif + okcon2f = .false. + if (present(con2fmap)) then + if (ESMF_RouteHandleIsCreated(con2fmap, rc=rc)) okcon2f = .true. + endif + + okcon2d = .false. + if (present(con2dmap)) then + if (ESMF_RouteHandleIsCreated(con2dmap, rc=rc)) okcon2d = .true. + endif + okbilnr = .false. if (present(bilnrmap)) then if (ESMF_RouteHandleIsCreated(bilnrmap, rc=rc)) okbilnr = .true. @@ -7239,6 +7665,11 @@ subroutine Fieldbundle_Regrid(fldlist, FBin, FBout, consfmap, consdmap, bilnrmap if (ESMF_RouteHandleIsCreated(patchmap, rc=rc)) okpatch = .true. endif + oknrnbr = .false. + if (present(nrnbrmap)) then + if (ESMF_RouteHandleIsCreated(nrnbrmap, rc=rc)) oknrnbr = .true. + endif + okfcopy = .false. if (present(fcopymap)) then if (ESMF_RouteHandleIsCreated(fcopymap, rc=rc)) okfcopy = .true. @@ -7260,11 +7691,10 @@ subroutine Fieldbundle_Regrid(fldlist, FBin, FBout, consfmap, consdmap, bilnrmap rc = ESMF_FAILURE return endif - call FieldBundle_FieldRegrid(FBin,fldlist%shortname(n), & - FBout,fldlist%shortname(n), & + call FieldBundle_FieldRegrid(FBin , fldlist%shortname(n), & + FBout, fldlist%shortname(n), & bilnrmap,rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return elseif (fldlist%mapping(n) == "conservefrac") then if (.not. okconsf) then @@ -7273,11 +7703,10 @@ subroutine Fieldbundle_Regrid(fldlist, FBin, FBout, consfmap, consdmap, bilnrmap rc = ESMF_FAILURE return endif - call FieldBundle_FieldRegrid(FBin ,fldlist%shortname(n), & - FBout,fldlist%shortname(n), & + call FieldBundle_FieldRegrid(FBin , fldlist%shortname(n), & + FBout, fldlist%shortname(n), & consfmap, rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return elseif (fldlist%mapping(n) == "conservedst") then if (.not. okconsd) then @@ -7286,11 +7715,34 @@ subroutine Fieldbundle_Regrid(fldlist, FBin, FBout, consfmap, consdmap, bilnrmap rc = ESMF_FAILURE return endif + call FieldBundle_FieldRegrid(FBin , fldlist%shortname(n), & + FBout, fldlist%shortname(n), & + consdmap, rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + + elseif (fldlist%mapping(n) == "conserve2frac") then + if (.not. okcon2f) then + call ESMF_LogWrite(trim(subname)//trim(lstring)//": ERROR RH not available for "//trim(fldlist%mapping(n))// & + ": fld="//trim(fldlist%shortname(n)), ESMF_LOGMSG_ERROR, line=__LINE__, file=__FILE__, rc=dbrc) + rc = ESMF_FAILURE + return + endif call FieldBundle_FieldRegrid(FBin ,fldlist%shortname(n), & FBout,fldlist%shortname(n), & - consdmap, rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + con2fmap, rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return ! bail out + + elseif (fldlist%mapping(n) == "conserve2dst") then + if (.not. okcon2d) then + call ESMF_LogWrite(trim(subname)//trim(lstring)//": ERROR RH not available for "//trim(fldlist%mapping(n))// & + ": fld="//trim(fldlist%shortname(n)), ESMF_LOGMSG_ERROR, line=__LINE__, file=__FILE__, rc=dbrc) + rc = ESMF_FAILURE + return + endif + call FieldBundle_FieldRegrid(FBin ,fldlist%shortname(n), & + FBout,fldlist%shortname(n), & + con2dmap, rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return elseif (fldlist%mapping(n) == 'patch') then if (.not. okpatch) then @@ -7299,11 +7751,23 @@ subroutine Fieldbundle_Regrid(fldlist, FBin, FBout, consfmap, consdmap, bilnrmap rc = ESMF_FAILURE return endif + call FieldBundle_FieldRegrid(FBin , fldlist%shortname(n), & + FBout, fldlist%shortname(n), & + patchmap,rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + + elseif (fldlist%mapping(n) == 'neareststod') then + if (.not. oknrnbr) then + call ESMF_LogWrite(trim(subname)//trim(lstring)//": ERROR RH not available for "//trim(fldlist%mapping(n))// & + ": fld="//trim(fldlist%shortname(n)), ESMF_LOGMSG_ERROR, line=__LINE__, file=__FILE__, rc=dbrc) + rc = ESMF_FAILURE + return + endif call FieldBundle_FieldRegrid(FBin ,fldlist%shortname(n), & FBout,fldlist%shortname(n), & - patchmap,rc) + nrnbrmap,rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + line=__LINE__, file=__FILE__)) return elseif (fldlist%mapping(n) == 'copy') then !------------------------------------------- @@ -7319,18 +7783,16 @@ subroutine Fieldbundle_Regrid(fldlist, FBin, FBout, consfmap, consdmap, bilnrmap else call ESMF_LogWrite(trim(subname)//trim(lstring)//": NOTE using conservative instead of copy for"// & " fld="//trim(fldlist%shortname(n)), ESMF_LOGMSG_INFO, line=__LINE__, file=__FILE__, rc=dbrc) - call FieldBundle_FieldRegrid(FBin ,fldlist%shortname(n), & - FBout,fldlist%shortname(n), & + call FieldBundle_FieldRegrid(FBin , fldlist%shortname(n), & + FBout, fldlist%shortname(n), & consfmap,rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return endif else - call FieldBundle_FieldRegrid(FBin ,fldlist%shortname(n), & - FBout,fldlist%shortname(n), & + call FieldBundle_FieldRegrid(FBin , fldlist%shortname(n), & + FBout, fldlist%shortname(n), & fcopymap,rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return endif else @@ -7352,23 +7814,22 @@ subroutine Fieldbundle_Regrid(fldlist, FBin, FBout, consfmap, consdmap, bilnrmap endif end subroutine Fieldbundle_Regrid - + !----------------------------------------------------------------------------- !BL2017 - subroutine Fieldbundle_Regrid2(fldlist, FBin, FBout, & - nearestmap,string, rc) + subroutine Fieldbundle_Regrid2(fldlist, FBin, FBout, nrnbrmap,string, rc) type(fld_list_type) :: fldlist type(ESMF_FieldBundle) :: FBin type(ESMF_FieldBundle) :: FBout - type(ESMF_Routehandle),optional :: nearestmap + type(ESMF_Routehandle),optional :: nrnbrmap character(len=*) ,optional :: string integer ,optional :: rc ! local variables - integer :: n + integer :: n character(len=64) :: lstring - logical :: oknearest + logical :: oknearest character(len=*),parameter :: subname='(module_MEDIATOR:Fieldbundle_Regrid2)' rc = ESMF_SUCCESS @@ -7389,8 +7850,8 @@ subroutine Fieldbundle_Regrid2(fldlist, FBin, FBout, & endif oknearest = .false. - if (present(nearestmap)) then - if (ESMF_RouteHandleIsCreated(nearestmap, rc=rc)) oknearest = .true. + if (present(nrnbrmap)) then + if (ESMF_RouteHandleIsCreated(nrnbrmap, rc=rc)) oknearest = .true. endif do n = 1,fldlist%num @@ -7399,14 +7860,13 @@ subroutine Fieldbundle_Regrid2(fldlist, FBin, FBout, & if (dbug_flag > 1) then call ESMF_LogWrite(trim(subname)//trim(lstring)//": map=neareststod"// & - ": fld="//trim(fldlist%shortname(n)), ESMF_LOGMSG_INFO, rc=dbrc) + ": fld="//trim(fldlist%shortname(n)), ESMF_LOGMSG_INFO, rc=dbrc) endif - call FieldBundle_FieldRegrid(FBin ,fldlist%shortname(n), & - FBout,fldlist%shortname(n), & - nearestmap,rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + call FieldBundle_FieldRegrid(FBin , fldlist%shortname(n), & + FBout, fldlist%shortname(n), & + nrnbrmap,rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return endif enddo end subroutine Fieldbundle_Regrid2 @@ -7425,7 +7885,7 @@ subroutine FieldBundle_FieldRegrid(FBin,fldin,FBout,fldout,RH,rc) integer , intent(out) :: rc ! local - type(ESMF_Field) :: field1, field2 + type(ESMF_Field) :: field1, field2 character(len=*),parameter :: subname='(module_MEDIATOR:FieldBundle_FieldRegrid)' rc = ESMF_SUCCESS @@ -7437,16 +7897,14 @@ subroutine FieldBundle_FieldRegrid(FBin,fldin,FBout,fldout,RH,rc) FieldBundle_FldChk(FBout, trim(fldout), rc=rc)) then call FieldBundle_GetFieldName(FBin, trim(fldin), field1, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call FieldBundle_GetFieldName(FBout, trim(fldout), field2, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return call ESMF_FieldRegrid(field1, field2, routehandle=RH, & - termorderflag=ESMF_TERMORDER_SRCSEQ, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + termorderflag=ESMF_TERMORDER_SRCSEQ, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return else if (dbug_flag > 1) then @@ -7463,61 +7921,55 @@ end subroutine FieldBundle_FieldRegrid !----------------------------------------------------------------------------- - subroutine FieldBundle_FieldMerge(FBout, fnameout, & - FBinA, fnameA, wgtA, & - FBinB, fnameB, wgtB, & - FBinC, fnameC, wgtC, & - FBinD, fnameD, wgtD, & - FBinE, fnameE, wgtE, rc) + subroutine FieldBundle_FieldMerge(FBout, fnameout, nmerg, & + FBinA, fnameA, wgtA, & + FBinB, fnameB, wgtB, & + FBinC, fnameC, wgtC, & + FBinD, fnameD, wgtD, & + FBinE, fnameE, wgtE, rc) ! ---------------------------------------------- ! Supports up to a five way merge ! ---------------------------------------------- type(ESMF_FieldBundle), intent(inout) :: FBout character(len=*) , intent(in) :: fnameout - type(ESMF_FieldBundle), intent(in), optional :: FBinA - character(len=*) , intent(in), optional :: fnameA - real(ESMF_KIND_R8) , intent(in), optional, pointer :: wgtA(:,:) - type(ESMF_FieldBundle), intent(in), optional :: FBinB - character(len=*) , intent(in), optional :: fnameB - real(ESMF_KIND_R8) , intent(in), optional, pointer :: wgtB(:,:) - type(ESMF_FieldBundle), intent(in), optional :: FBinC - character(len=*) , intent(in), optional :: fnameC - real(ESMF_KIND_R8) , intent(in), optional, pointer :: wgtC(:,:) - type(ESMF_FieldBundle), intent(in), optional :: FBinD - character(len=*) , intent(in), optional :: fnameD - real(ESMF_KIND_R8) , intent(in), optional, pointer :: wgtD(:,:) - type(ESMF_FieldBundle), intent(in), optional :: FBinE - character(len=*) , intent(in), optional :: fnameE - real(ESMF_KIND_R8) , intent(in), optional, pointer :: wgtE(:,:) + integer , intent(in) :: nmerg ! number of components to merge + type(ESMF_FieldBundle), intent(in), optional :: FBinA, FBinB, FBinC, FBinD, FBinE + character(len=*) , intent(in), optional :: fnameA, fnameB, fnameC, fnameD, fnameE + real(ESMF_KIND_R8) , intent(in), optional, pointer :: wgtA(:,:), wgtB(:,:), & + wgtC(:,:), wgtD(:,:), & + wgtE(:,:) integer , intent(out) :: rc ! local variables - real(ESMF_KIND_R8), pointer :: dataOut(:,:) - real(ESMF_KIND_R8), pointer :: dataPtr(:,:) - real(ESMF_KIND_R8), pointer :: wgt(:,:) - character(len=ESMF_MAXSTR) :: fname - integer :: lb1,ub1,lb2,ub2,i,j,n - logical :: wgtfound, FBinfound - character(len=*),parameter :: subname='(module_MEDIATOR:FieldBundle_FieldMerge)' + real(ESMF_KIND_R8), pointer :: dataOut(:,:), dataPtr(:,:), wgt(:,:) + character(len=ESMF_MAXSTR) :: fname + integer :: lb1,ub1,lb2,ub2,i,j,n + logical :: wgtfound, FBinfound + character(len=*),parameter :: subname='(module_MEDIATOR:FieldBundle_FieldMerge)' if (dbug_flag > 10) then call ESMF_LogWrite(trim(subname)//": called", ESMF_LOGMSG_INFO, rc=dbrc) endif - rc=ESMF_SUCCESS + rc = ESMF_SUCCESS if (.not. FieldBundle_FldChk(FBout, trim(fnameout), rc=rc)) then call ESMF_LogWrite(trim(subname)//": WARNING output field not in FBout, skipping merge of: "//trim(fnameout), ESMF_LOGMSG_WARNING, line=__LINE__, file=__FILE__, rc=dbrc) return endif call FieldBundle_GetFldPtr(FBout, trim(fnameout), dataOut, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + lb1 = lbound(dataOut,1) ub1 = ubound(dataOut,1) lb2 = lbound(dataOut,2) ub2 = ubound(dataOut,2) - dataOut = czero +!$omp parallel do default(shared) private(i,j) + do j=lb2,ub2 + do i=lb1,ub1 + dataOut(i,j) = czero + enddo + enddo ! check each field has a fieldname passed in if ((present(FBinA) .and. .not.present(fnameA)) .or. & @@ -7568,16 +8020,15 @@ subroutine FieldBundle_FieldMerge(FBout, fnameout, & endif ! n=1,5 represents adding A to E inputs if they exist - do n = 1,5 + do n = 1,min(nmerg,5) FBinfound = .false. - wgtfound = .false. + wgtfound = .false. if (n == 1 .and. present(FBinA)) then fname = fnameA FBinfound = .true. call FieldBundle_GetFldPtr(FBinA, trim(fname), dataPtr, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return if (present(wgtA)) then wgtfound = .true. wgt => wgtA @@ -7587,8 +8038,7 @@ subroutine FieldBundle_FieldMerge(FBout, fnameout, & fname = fnameB FBinfound = .true. call FieldBundle_GetFldPtr(FBinB, trim(fname), dataPtr, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return if (present(wgtB)) then wgtfound = .true. wgt => wgtB @@ -7598,8 +8048,7 @@ subroutine FieldBundle_FieldMerge(FBout, fnameout, & fname = fnameC FBinfound = .true. call FieldBundle_GetFldPtr(FBinC, trim(fname), dataPtr, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return if (present(wgtC)) then wgtfound = .true. wgt => wgtC @@ -7609,8 +8058,7 @@ subroutine FieldBundle_FieldMerge(FBout, fnameout, & fname = fnameD FBinfound = .true. call FieldBundle_GetFldPtr(FBinD, trim(fname), dataPtr, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return if (present(wgtD)) then wgtfound = .true. wgt => wgtD @@ -7620,8 +8068,7 @@ subroutine FieldBundle_FieldMerge(FBout, fnameout, & fname = fnameE FBinfound = .true. call FieldBundle_GetFldPtr(FBinE, trim(fname), dataPtr, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return if (present(wgtE)) then wgtfound = .true. wgt => wgtE @@ -7642,16 +8089,20 @@ subroutine FieldBundle_FieldMerge(FBout, fnameout, & rc = ESMF_FAILURE return endif +!$omp parallel do default(shared) private(i,j) do j = lb2,ub2 - do i = lb1,ub1 - dataOut(i,j) = dataOut(i,j) + dataPtr(i,j) * wgt(i,j) - enddo + do i = lb1,ub1 + if (abs(wgt(i,j)) > epsln) then + dataOut(i,j) = dataOut(i,j) + dataPtr(i,j) * wgt(i,j) + endif + enddo enddo else +!$omp parallel do default(shared) private(i,j) do j = lb2,ub2 - do i = lb1,ub1 - dataOut(i,j) = dataOut(i,j) + dataPtr(i,j) - enddo + do i = lb1,ub1 + dataOut(i,j) = dataOut(i,j) + dataPtr(i,j) + enddo enddo endif ! wgtfound @@ -7681,7 +8132,7 @@ subroutine state_reset(State, value, rc) character(ESMF_MAXSTR) ,pointer :: fieldNameList(:) real(ESMF_KIND_R8) :: lvalue real(ESMF_KIND_R8), pointer :: dataPtr(:,:) - character(len=*),parameter :: subname='(module_MEDIATOR:state_reset)' + character(len=*), parameter :: subname='(module_MEDIATOR:state_reset)' if (dbug_flag > 10) then call ESMF_LogWrite(trim(subname)//": called", ESMF_LOGMSG_INFO, rc=dbrc) @@ -7694,21 +8145,21 @@ subroutine state_reset(State, value, rc) endif call ESMF_StateGet(State, itemCount=fieldCount, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + allocate(fieldNameList(fieldCount)) call ESMF_StateGet(State, itemNameList=fieldNameList, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + do n = 1, fieldCount call State_GetFldPtr(State, fieldNameList(n), dataPtr, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return +!$omp parallel do default(shared) private(i,j) do j=lbound(dataPtr,2),ubound(dataPtr,2) - do i=lbound(dataPtr,1),ubound(dataPtr,1) - dataPtr(i,j) = lvalue - enddo + do i=lbound(dataPtr,1),ubound(dataPtr,1) + dataPtr(i,j) = lvalue + enddo enddo enddo @@ -7735,6 +8186,7 @@ subroutine fieldBundle_average(FieldBundle, count, rc) integer :: fieldCount character(ESMF_MAXSTR) ,pointer :: fieldNameList(:) real(ESMF_KIND_R8), pointer :: dataPtr(:,:) + real(ESMF_KIND_R8) :: counti character(len=*),parameter :: subname='(module_MEDIATOR:fieldBundle_average)' if (dbug_flag > 10) then @@ -7745,29 +8197,29 @@ subroutine fieldBundle_average(FieldBundle, count, rc) if (count == 0) then call ESMF_LogWrite(trim(subname)//": WARNING count is 0", ESMF_LOGMSG_INFO, rc=dbrc) -! call ESMF_LogWrite(trim(subname)//": WARNING count is 0 set avg to spval", ESMF_LOGMSG_INFO, rc=dbrc) -! call fieldBundle_reset(FieldBundle, value=spval, rc=rc) -! if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & -! line=__LINE__, file=__FILE__)) return ! bail out +! call ESMF_LogWrite(trim(subname)//": WARNING count is 0 set avg to spval", ESMF_LOGMSG_INFO, rc=dbrc) +! call fieldBundle_reset(FieldBundle, value=spval, rc=rc) +! if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return else call ESMF_FieldBundleGet(FieldBundle, fieldCount=fieldCount, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + allocate(fieldNameList(fieldCount)) call ESMF_FieldBundleGet(FieldBundle, fieldNameList=fieldNameList, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + do n = 1, fieldCount call FieldBundle_GetFldPtr(FieldBundle, fieldNameList(n), dataPtr, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + counti = cone / real(count, ESMF_KIND_R8) +!$omp parallel do default(shared) private(i,j) do j=lbound(dataPtr,2),ubound(dataPtr,2) - do i=lbound(dataPtr,1),ubound(dataPtr,1) - dataPtr(i,j) = dataPtr(i,j) / real(count, ESMF_KIND_R8) - enddo + do i=lbound(dataPtr,1),ubound(dataPtr,1) + dataPtr(i,j) = dataPtr(i,j) * counti + enddo enddo enddo deallocate(fieldNameList) @@ -7796,7 +8248,7 @@ subroutine fieldBundle_diagnose(FieldBundle, string, rc) character(ESMF_MAXSTR) ,pointer :: fieldNameList(:) character(len=64) :: lstring real(ESMF_KIND_R8), pointer :: dataPtr(:,:) - character(len=*),parameter :: subname='(module_MEDIATOR:fieldBundle_diagnose)' + character(len=*), parameter :: subname='(module_MEDIATOR:fieldBundle_diagnose)' if (dbug_flag > 10) then call ESMF_LogWrite(trim(subname)//": called", ESMF_LOGMSG_INFO, rc=dbrc) @@ -7809,18 +8261,18 @@ subroutine fieldBundle_diagnose(FieldBundle, string, rc) endif call ESMF_FieldBundleGet(FieldBundle, fieldCount=fieldCount, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + allocate(fieldNameList(fieldCount)) call ESMF_FieldBundleGet(FieldBundle, fieldNameList=fieldNameList, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + do n = 1, fieldCount call FieldBundle_GetFldPtr(FieldBundle, fieldNameList(n), dataPtr, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + write(msgString,'(A,3g14.7)') trim(subname)//' '//trim(lstring)//':'//trim(fieldNameList(n)), & - minval(dataPtr),maxval(dataPtr),sum(dataPtr) + minval(dataPtr),maxval(dataPtr),sum(dataPtr) call ESMF_LogWrite(trim(msgString), ESMF_LOGMSG_INFO, rc=dbrc) enddo deallocate(fieldNameList) @@ -7860,10 +8312,10 @@ subroutine array_diagnose(array, string, rc) endif call ESMF_ArrayGet(Array, farrayPtr=dataPtr, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + write(msgString,'(A,3g14.7)') trim(subname)//' '//trim(lstring), & - minval(dataPtr),maxval(dataPtr),sum(dataPtr) + minval(dataPtr),maxval(dataPtr),sum(dataPtr) call ESMF_LogWrite(trim(msgString), ESMF_LOGMSG_INFO, rc=dbrc) if (dbug_flag > 10) then @@ -7901,18 +8353,18 @@ subroutine state_diagnose(State, string, rc) endif call ESMF_StateGet(State, itemCount=fieldCount, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + allocate(fieldNameList(fieldCount)) call ESMF_StateGet(State, itemNameList=fieldNameList, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + do n = 1, fieldCount call State_GetFldPtr(State, fieldNameList(n), dataPtr, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + write(msgString,'(A,3g14.7)') trim(subname)//' '//trim(lstring)//':'//trim(fieldNameList(n)), & - minval(dataPtr),maxval(dataPtr),sum(dataPtr) + minval(dataPtr),maxval(dataPtr),sum(dataPtr) call ESMF_LogWrite(trim(msgString), ESMF_LOGMSG_INFO, rc=dbrc) enddo deallocate(fieldNameList) @@ -7941,8 +8393,7 @@ subroutine fieldBundle_copyFB2FB(FBout, FBin, rc) rc = ESMF_SUCCESS call fieldBundle_accum(FBout, FBin, copy=.true., rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return if (dbug_flag > 10) then call ESMF_LogWrite(trim(subname)//": done", ESMF_LOGMSG_INFO, rc=dbrc) @@ -7968,8 +8419,7 @@ subroutine fieldBundle_copyFB2ST(STout, FBin, rc) rc = ESMF_SUCCESS call fieldBundle_accum(STout, FBin, copy=.true., rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return if (dbug_flag > 10) then call ESMF_LogWrite(trim(subname)//": done", ESMF_LOGMSG_INFO, rc=dbrc) @@ -7995,8 +8445,7 @@ subroutine fieldBundle_copyST2FB(FBout, STin, rc) rc = ESMF_SUCCESS call fieldBundle_accum(FBout, STin, copy=.true., rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return if (dbug_flag > 10) then call ESMF_LogWrite(trim(subname)//": done", ESMF_LOGMSG_INFO, rc=dbrc) @@ -8037,24 +8486,22 @@ subroutine fieldBundle_accumFB2FB(FBout, FBin, copy, rc) endif call ESMF_FieldBundleGet(FBout, fieldCount=fieldCount, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + allocate(fieldNameList(fieldCount)) call ESMF_FieldBundleGet(FBout, fieldNameList=fieldNameList, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return do n = 1, fieldCount call ESMF_FieldBundleGet(FBin, fieldName=fieldNameList(n), isPresent=exists, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + if (exists) then call FieldBundle_GetFldPtr(FBin, fieldNameList(n), dataPtri, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call FieldBundle_GetFldPtr(FBout, fieldNameList(n), dataPtro, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return if (.not.FldPtr_SameCheck(dataPtro, dataPtri, subname, rc)) then call ESMF_LogWrite(trim(subname)//": ERROR in dataPtr size ", ESMF_LOGMSG_ERROR, line=__LINE__, file=__FILE__, rc=rc) @@ -8062,16 +8509,18 @@ subroutine fieldBundle_accumFB2FB(FBout, FBin, copy, rc) endif if (lcopy) then +!$omp parallel do default(shared) private(i,j) do j=lbound(dataPtri,2),ubound(dataPtri,2) - do i=lbound(dataPtri,1),ubound(dataPtri,1) - dataPtro(i,j) = dataPtri(i,j) - enddo + do i=lbound(dataPtri,1),ubound(dataPtri,1) + dataPtro(i,j) = dataPtri(i,j) + enddo enddo else +!$omp parallel do default(shared) private(i,j) do j=lbound(dataPtri,2),ubound(dataPtri,2) - do i=lbound(dataPtri,1),ubound(dataPtri,1) - dataPtro(i,j) = dataPtro(i,j) + dataPtri(i,j) - enddo + do i=lbound(dataPtri,1),ubound(dataPtri,1) + dataPtro(i,j) = dataPtro(i,j) + dataPtri(i,j) + enddo enddo endif @@ -8121,16 +8570,14 @@ subroutine fieldBundle_accumST2FB(FBout, STin, copy, rc) call ESMF_FieldBundleGet(FBout, fieldNameList=fieldNameList, rc=rc) do n = 1, fieldCount call ESMF_StateGet(STin, itemName=fieldNameList(n), itemType=itemType, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return if (itemType /= ESMF_STATEITEM_NOTFOUND) then call State_GetFldPtr(STin, fieldNameList(n), dataPtrS, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call FieldBundle_GetFldPtr(FBout, fieldNameList(n), dataPtrB, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return if (.not.FldPtr_SameCheck(dataPtrS, dataPtrB, subname, rc)) then call ESMF_LogWrite(trim(subname)//": ERROR in dataPtr size ", ESMF_LOGMSG_ERROR, line=__LINE__, file=__FILE__, rc=rc) @@ -8138,16 +8585,18 @@ subroutine fieldBundle_accumST2FB(FBout, STin, copy, rc) endif if (lcopy) then +!$omp parallel do default(shared) private(i,j) do j=lbound(dataPtrB,2),ubound(dataPtrB,2) - do i=lbound(dataPtrB,1),ubound(dataPtrB,1) - dataPtrB(i,j) = dataPtrS(i,j) - enddo + do i=lbound(dataPtrB,1),ubound(dataPtrB,1) + dataPtrB(i,j) = dataPtrS(i,j) + enddo enddo else +!$omp parallel do default(shared) private(i,j) do j=lbound(dataPtrB,2),ubound(dataPtrB,2) - do i=lbound(dataPtrB,1),ubound(dataPtrB,1) - dataPtrB(i,j) = dataPtrB(i,j) + dataPtrS(i,j) - enddo + do i=lbound(dataPtrB,1),ubound(dataPtrB,1) + dataPtrB(i,j) = dataPtrB(i,j) + dataPtrS(i,j) + enddo enddo endif @@ -8198,16 +8647,15 @@ subroutine fieldBundle_accumFB2ST(STout, FBin, copy, rc) call ESMF_FieldBundleGet(FBin, fieldNameList=fieldNameList, rc=rc) do n = 1, fieldCount call ESMF_StateGet(STout, itemName=fieldNameList(n), itemType=itemType, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + if (itemType /= ESMF_STATEITEM_NOTFOUND) then call FieldBundle_GetFldPtr(FBin, fieldNameList(n), dataPtrB, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call State_GetFldPtr(STout, fieldNameList(n), dataPtrS, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return if (.not.FldPtr_SameCheck(dataPtrS, dataPtrB, subname, rc)) then call ESMF_LogWrite(trim(subname)//": ERROR in dataPtr size ", ESMF_LOGMSG_ERROR, line=__LINE__, file=__FILE__, rc=rc) @@ -8215,16 +8663,18 @@ subroutine fieldBundle_accumFB2ST(STout, FBin, copy, rc) endif if (lcopy) then +!$omp parallel do default(shared) private(i,j) do j=lbound(dataPtrB,2),ubound(dataPtrB,2) - do i=lbound(dataPtrB,1),ubound(dataPtrB,1) - dataPtrS(i,j) = dataPtrB(i,j) - enddo + do i=lbound(dataPtrB,1),ubound(dataPtrB,1) + dataPtrS(i,j) = dataPtrB(i,j) + enddo enddo else +!$omp parallel do default(shared) private(i,j) do j=lbound(dataPtrB,2),ubound(dataPtrB,2) - do i=lbound(dataPtrB,1),ubound(dataPtrB,1) - dataPtrS(i,j) = dataPtrS(i,j) + dataPtrB(i,j) - enddo + do i=lbound(dataPtrB,1),ubound(dataPtrB,1) + dataPtrS(i,j) = dataPtrS(i,j) + dataPtrB(i,j) + enddo enddo endif @@ -8257,8 +8707,8 @@ logical function FieldBundle_FldChk(FB, fldname, rc) FieldBundle_FldChk = .false. call ESMF_FieldBundleGet(FB, fieldName=trim(fldname), isPresent=isPresent, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + if (isPresent) then FieldBundle_FldChk = .true. endif @@ -8293,11 +8743,10 @@ subroutine FieldBundle_GetFldPtr(FB, fldname, fldptr, rc) endif call ESMF_FieldBundleGet(FB, fieldName=trim(fldname), field=lfield, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call ESMF_FieldGet(lfield, farrayPtr=fldptr, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return if (dbug_flag > 10) then call ESMF_LogWrite(trim(subname)//": done", ESMF_LOGMSG_INFO, rc=dbrc) @@ -8330,11 +8779,10 @@ subroutine FieldBundle_SetFldPtr(FB, fldname, val, rc) endif call ESMF_FieldBundleGet(FB, fieldName=trim(fldname), field=lfield, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call ESMF_FieldGet(lfield, farrayPtr=fldptr, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return fldptr = val @@ -8366,11 +8814,10 @@ subroutine State_GetFldPtr(ST, fldname, fldptr, rc) call ESMF_LogWrite(trim(subname)//": fldname ="//trim(fldname), ESMF_LOGMSG_INFO,rc=dbrc) endif ! call ESMF_StatePrint(ST,rc=dbrc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call ESMF_FieldGet(lfield, farrayPtr=fldptr, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return if (dbug_flag > 10) then call ESMF_LogWrite(trim(subname)//": done", ESMF_LOGMSG_INFO, rc=dbrc) @@ -8401,11 +8848,10 @@ subroutine State_SetFldPtr(ST, fldname, val, rc) call ESMF_LogWrite(trim(subname)//": fldname ="//trim(fldname), ESMF_LOGMSG_INFO,rc=dbrc) endif ! call ESMF_StatePrint(ST,rc=dbrc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call ESMF_FieldGet(lfield, farrayPtr=fldptr, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return fldptr = val @@ -8437,8 +8883,8 @@ logical function FldPtr_SameCheck(fldptr1, fldptr2, cstring, rc) ubound(fldptr2,2) /= ubound(fldptr1,2) .or. & ubound(fldptr2,1) /= ubound(fldptr1,1)) then call ESMF_LogWrite(trim(subname)//": ERROR in data size "//trim(cstring), ESMF_LOGMSG_ERROR, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + write(msgString,*) trim(subname)//': fldptr2 ',lbound(fldptr2),ubound(fldptr2) call ESMF_LogWrite(trim(msgString), ESMF_LOGMSG_INFO, rc=dbrc) write(msgString,*) trim(subname)//': fldptr1 ',lbound(fldptr1),ubound(fldptr1) @@ -8471,26 +8917,21 @@ subroutine FldGrid_Print(field, string, rc) rc = ESMF_SUCCESS call ESMF_FieldGet(field, grid=grid, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return call Grid_Print(grid, string, rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return call ESMF_FieldGet(field,farrayPtr=dataptr,rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return write (msgString,*) trim(subname)//":"//trim(string)//": dataptr bounds dim=1 ",lbound(dataptr,1),ubound(dataptr,1) call ESMF_LogWrite(msgString, ESMF_LOGMSG_INFO, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return write (msgString,*) trim(subname)//":"//trim(string)//": dataptr bounds dim=2 ",lbound(dataptr,2),ubound(dataptr,2) call ESMF_LogWrite(msgString, ESMF_LOGMSG_INFO, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return if (dbug_flag > 10) then call ESMF_LogWrite(trim(subname)//": done", ESMF_LOGMSG_INFO, rc=dbrc) @@ -8520,48 +8961,40 @@ subroutine Grid_Print(grid, string, rc) ! access localDeCount to show this is a real Grid call ESMF_GridGet(grid, localDeCount=localDeCount, distgrid=distgrid, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out - + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + write (msgString,*) trim(subname)//":"//trim(string)//": localDeCount=", localDeCount call ESMF_LogWrite(msgString, ESMF_LOGMSG_INFO, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out - + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + ! get dimCount and tileCount call ESMF_DistGridGet(distgrid, dimCount=dimCount, tileCount=tileCount, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return write (msgString,*) trim(subname)//":"//trim(string)//": dimCount=", dimCount call ESMF_LogWrite(msgString, ESMF_LOGMSG_INFO, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return write (msgString,*) trim(subname)//":"//trim(string)//": tileCount=", tileCount call ESMF_LogWrite(msgString, ESMF_LOGMSG_INFO, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return ! allocate minIndexPTile and maxIndexPTile accord. to dimCount and tileCount allocate(minIndexPTile(dimCount, tileCount), & maxIndexPTile(dimCount, tileCount)) - + ! get minIndex and maxIndex arrays call ESMF_DistGridGet(distgrid, minIndexPTile=minIndexPTile, & - maxIndexPTile=maxIndexPTile, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out - + maxIndexPTile=maxIndexPTile, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + write (msgString,*) trim(subname)//":"//trim(string)//": minIndexPTile=", minIndexPTile call ESMF_LogWrite(msgString, ESMF_LOGMSG_INFO, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return write (msgString,*) trim(subname)//":"//trim(string)//": maxIndexPTile=", maxIndexPTile call ESMF_LogWrite(msgString, ESMF_LOGMSG_INFO, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return deallocate(minIndexPTile, maxIndexPTile) @@ -8597,35 +9030,35 @@ subroutine ClockTimePrint(clock,string,rc) endif call ESMF_ClockGet(clock,currtime=time,rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call ESMF_TimeGet(time,timestring=timestr,rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call ESMF_LogWrite(trim(lstring)//": currtime = "//trim(timestr), ESMF_LOGMSG_INFO, rc=dbrc) call ESMF_ClockGet(clock,starttime=time,rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call ESMF_TimeGet(time,timestring=timestr,rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call ESMF_LogWrite(trim(lstring)//": startime = "//trim(timestr), ESMF_LOGMSG_INFO, rc=dbrc) call ESMF_ClockGet(clock,stoptime=time,rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call ESMF_TimeGet(time,timestring=timestr,rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call ESMF_LogWrite(trim(lstring)//": stoptime = "//trim(timestr), ESMF_LOGMSG_INFO, rc=dbrc) call ESMF_ClockGet(clock,timestep=timestep,rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call ESMF_TimeIntervalGet(timestep,timestring=timestr,rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call ESMF_LogWrite(trim(lstring)//": timestep = "//trim(timestr), ESMF_LOGMSG_INFO, rc=dbrc) if (dbug_flag > 5) then @@ -8640,9 +9073,15 @@ subroutine Grid_Write(grid, string, rc) type(ESMF_Grid) ,intent(in) :: grid character(len=*),intent(in) :: string integer ,intent(out) :: rc - - ! local + + ! local type(ESMF_Array) :: array + type(ESMF_Field) :: field(1), fieldR(1) + type(ESMF_GridComp) :: IOComp + integer, pointer :: iPtr(:,:) + real(ESMF_KIND_R8), pointer :: rPtr(:,:) + logical :: multitile + integer :: tileCount character(len=*),parameter :: subname='(module_MEDIATOR:Grid_Write)' ! -- centers -- @@ -8652,6 +9091,16 @@ subroutine Grid_Write(grid, string, rc) call ESMF_LogWrite(trim(subname)//": called", ESMF_LOGMSG_INFO, rc=dbrc) endif + call ESMF_GridGet(grid, tileCount=tileCount, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + multitile = .false. + if (tileCount > 1) then + multitile = .true. + IOComp = ESMFIO_Create(grid, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + endif + + ! -- centers -- call ESMF_GridGetCoord(grid, staggerLoc=ESMF_STAGGERLOC_CENTER, isPresent=isPresent, rc=rc) @@ -8659,19 +9108,48 @@ subroutine Grid_Write(grid, string, rc) if (isPresent) then call ESMF_GridGetCoord(grid, coordDim=1, staggerLoc=ESMF_STAGGERLOC_CENTER, array=array, rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call ESMF_ArraySet(array, name="lon_center", rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call Array_diagnose(array,trim(string)//"_grid_coord1", rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return - call ESMF_ArrayWrite(array, trim(string)//"_grid_coord1.nc", rc=rc) + + field(1) = ESMF_FieldCreate(grid, array, staggerloc=ESMF_STAGGERLOC_CENTER, name="lon_center", rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + +! call ESMF_ArrayWrite(array, trim(string)//"_grid_coord1.nc", rc=rc) + if (multitile) then + call ESMFIO_Write(IOComp, trim(string)//"_grid_coord1.nc", field, filePath='./', rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + else + call ESMF_FieldWrite(field(1), trim(string)//"_grid_coord1.nc", rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + endif + call ESMF_FieldDestroy(field(1),rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call ESMF_GridGetCoord(grid, coordDim=2, staggerLoc=ESMF_STAGGERLOC_CENTER, array=array, rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call ESMF_ArraySet(array, name="lat_center", rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call Array_diagnose(array,trim(string)//"_grid_coord2", rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return - call ESMF_ArrayWrite(array, trim(string)//"_grid_coord2.nc", rc=rc) + + field(1) = ESMF_FieldCreate(grid, array, staggerloc=ESMF_STAGGERLOC_CENTER, name="lat_center", rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + +! call ESMF_ArrayWrite(array, trim(string)//"_grid_coord2.nc", rc=rc) + if (multitile) then + call ESMFIO_Write(IOComp, trim(string)//"_grid_coord2.nc", field, filePath='./', rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + else + call ESMF_FieldWrite(field(1), trim(string)//"_grid_coord2.nc", rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + endif + call ESMF_FieldDestroy(field(1),rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return endif @@ -8684,18 +9162,45 @@ subroutine Grid_Write(grid, string, rc) if (.not. ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) then call ESMF_ArraySet(array, name="lon_corner", rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call Array_diagnose(array,trim(string)//"_grid_corner1", rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return - call ESMF_ArrayWrite(array, trim(string)//"_grid_corner1.nc", rc=rc) + + field(1) = ESMF_FieldCreate(grid, array, staggerloc=ESMF_STAGGERLOC_CORNER, name="lat_corner", rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + +! call ESMF_ArrayWrite(array, trim(string)//"_grid_corner1.nc", rc=rc) + if (multitile) then + call ESMFIO_Write(IOComp, trim(string)//"_grid_corner1.nc", field, filePath='./', rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + else + call ESMF_FieldWrite(field(1), trim(string)//"_grid_corner1.nc", rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + endif + call ESMF_FieldDestroy(field(1),rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return endif call ESMF_GridGetCoord(grid, coordDim=2, staggerLoc=ESMF_STAGGERLOC_CORNER, array=array, rc=rc) + if (.not. ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) then call ESMF_ArraySet(array, name="lat_corner", rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call Array_diagnose(array,trim(string)//"_grid_corner2", rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return - call ESMF_ArrayWrite(array, trim(string)//"_grid_corner2.nc", rc=rc) + + field(1) = ESMF_FieldCreate(grid, array, staggerloc=ESMF_STAGGERLOC_CORNER, name="lat_corner", rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + +! call ESMF_ArrayWrite(array, trim(string)//"_grid_corner2.nc", rc=rc) + if (multitile) then + call ESMFIO_Write(IOComp, trim(string)//"_grid_corner2.nc", field, filePath='./', rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + else + call ESMF_FieldWrite(field(1), trim(string)//"_grid_corner2.nc", rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + endif + call ESMF_FieldDestroy(field(1),rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return endif endif @@ -8705,14 +9210,38 @@ subroutine Grid_Write(grid, string, rc) call ESMF_GridGetItem(grid, itemflag=ESMF_GRIDITEM_MASK, staggerLoc=ESMF_STAGGERLOC_CENTER, isPresent=isPresent, rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + if (isPresent) then call ESMF_GridGetItem(grid, staggerLoc=ESMF_STAGGERLOC_CENTER, itemflag=ESMF_GRIDITEM_MASK, array=array, rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call ESMF_ArraySet(array, name="mask", rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call Array_diagnose(array,trim(string)//"_grid_mask", rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return - call ESMF_ArrayWrite(array, trim(string)//"_grid_mask.nc", rc=rc) + + field(1) = ESMF_FieldCreate(grid, array, staggerloc=ESMF_STAGGERLOC_CENTER, name="mask", rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + +! call ESMF_ArrayWrite(array, trim(string)//"_grid_mask.nc", rc=rc) + if (multitile) then + fieldR(1) = ESMF_FieldCreate(grid, ESMF_TYPEKIND_R8, name="mask", rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call ESMF_FieldGet(field(1) , farrayPtr=iptr, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call ESMF_FieldGet(fieldR(1), farrayPtr=rptr, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + rptr = iptr + call ESMFIO_Write(IOComp, trim(string)//"_grid_mask.nc", fieldR, filePath='./', rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call ESMF_FieldDestroy(fieldR(1),rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + else + call ESMF_FieldWrite(field(1), trim(string)//"_grid_mask.nc", rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + endif + call ESMF_FieldDestroy(field(1),rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return endif @@ -8720,17 +9249,38 @@ subroutine Grid_Write(grid, string, rc) call ESMF_GridGetItem(grid, itemflag=ESMF_GRIDITEM_AREA, staggerLoc=ESMF_STAGGERLOC_CENTER, isPresent=isPresent, rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + if (isPresent) then call ESMF_GridGetItem(grid, staggerLoc=ESMF_STAGGERLOC_CENTER, itemflag=ESMF_GRIDITEM_AREA, array=array, rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call ESMF_ArraySet(array, name="area", rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call Array_diagnose(array,trim(string)//"_grid_area", rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return - call ESMF_ArrayWrite(array, trim(string)//"_grid_area.nc", rc=rc) + + field(1) = ESMF_FieldCreate(grid, array, staggerloc=ESMF_STAGGERLOC_CENTER, name="area", rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + +! call ESMF_ArrayWrite(array, trim(string)//"_grid_area.nc", rc=rc) + if (multitile) then + call ESMFIO_Write(IOComp, trim(string)//"_grid_area.nc", field, filePath='./', rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + else + call ESMF_FieldWrite(field(1), trim(string)//"_grid_area.nc", rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + endif + call ESMF_FieldDestroy(field(1),rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return endif + if (multitile) then +! call ESMFIO_Destroy(IOComp, rc=rc) +! if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, +! line=__LINE__, file=__FILE__)) return + endif + if (dbug_flag > 10) then call ESMF_LogWrite(trim(subname)//": done", ESMF_LOGMSG_INFO, rc=dbrc) endif @@ -8762,9 +9312,8 @@ subroutine fld_list_add(fldlist, stdname, transferOffer, mapping) ! make sure that stdname is in the NUOPC Field Dictionary call NUOPC_FieldDictionaryGetEntry(stdname, rc=rc) if (ESMF_LogFoundError(rcToCheck=rc, msg=trim(subname)//& - ": invalid stdname: "//trim(stdname), & - line=__LINE__, file=__FILE__)) return ! bail out - + ": invalid stdname: "//trim(stdname), line=__LINE__, file=__FILE__)) return + ! potentially extend the existing lists if (fldlist%num < 0) then @@ -8803,7 +9352,7 @@ subroutine fld_list_add(fldlist, stdname, transferOffer, mapping) fldlist%mapping(1:cnum) = tmpString(1:cnum) deallocate(tmpString) endif - + ! fill in the new entry fldlist%num = fldlist%num + 1 @@ -8811,10 +9360,14 @@ subroutine fld_list_add(fldlist, stdname, transferOffer, mapping) fldlist%shortname (fldlist%num) = trim(stdname) fldlist%transferOffer (fldlist%num) = trim(transferOffer) if (present(mapping)) then - if (trim(mapping) /= "conservefrac" .and. trim(mapping) /= 'bilinear' .and. & - trim(mapping) /= 'conservedst' .and. & - trim(mapping) /= 'nearest' .and. & - trim(mapping) /= 'patch' .and. trim(mapping) /= 'copy') then + if (trim(mapping) /= "conservefrac" .and. & + trim(mapping) /= 'conservedst' .and. & + trim(mapping) /= 'conserve2frac' .and. & + trim(mapping) /= 'conserve2dst' .and. & + trim(mapping) /= 'bilinear' .and. & + trim(mapping) /= 'neareststod' .and. & + trim(mapping) /= 'patch' .and. & + trim(mapping) /= 'copy') then call ESMF_LogWrite(trim(subname)//": ERROR mapping not allowed "//trim(mapping), ESMF_LOGMSG_ERROR, rc=rc) call ESMF_Finalize(endflag=ESMF_END_ABORT) endif @@ -8856,15 +9409,12 @@ function NEMS_DistGridMatch(distGrid1, distGrid2, rc) if(present(rc)) rc = ESMF_SUCCESS NEMS_DistGridMatch = .true. - call ESMF_DistGridGet(distGrid1, & - dimCount=dimCount1, tileCount=tileCount1, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__,file=__FILE__)) return ! bail out + call ESMF_DistGridGet(distGrid1, dimCount=dimCount1, tileCount=tileCount1, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__,file=__FILE__)) return call ESMF_DistGridGet(distGrid2, & dimCount=dimCount2, tileCount=tileCount2, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__,file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__,file=__FILE__)) return if ( dimCount1 /= dimCount2) then NEMS_DistGridMatch = .false. @@ -8889,19 +9439,17 @@ function NEMS_DistGridMatch(distGrid1, distGrid2, rc) allocate(maxIndexPTile1(dimCount1,tileCount1)) allocate(maxIndexPTile2(dimCount2,tileCount2)) - call ESMF_DistGridGet(distGrid1, & - elementCountPTile=elementCountPTile1, & - minIndexPTile=minIndexPTile1, & - maxIndexPTile=maxIndexPTile1, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__,file=__FILE__)) return ! bail out + call ESMF_DistGridGet(distGrid1, & + elementCountPTile=elementCountPTile1, & + minIndexPTile=minIndexPTile1, & + maxIndexPTile=maxIndexPTile1, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__,file=__FILE__)) return - call ESMF_DistGridGet(distGrid2, & - elementCountPTile=elementCountPTile2, & - minIndexPTile=minIndexPTile2, & - maxIndexPTile=maxIndexPTile2, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__,file=__FILE__)) return ! bail out + call ESMF_DistGridGet(distGrid2, & + elementCountPTile=elementCountPTile2, & + minIndexPTile=minIndexPTile2, & + maxIndexPTile=maxIndexPTile2, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__,file=__FILE__)) return if ( ANY((elementCountPTile1 - elementCountPTile2) .NE. 0) ) then NEMS_DistGridMatch = .false. @@ -8967,24 +9515,24 @@ subroutine NEMS_GridCopyCoord(gridcomp, gridSrc, gridDst, staggerloc, tolerance, type(ESMF_Array) :: coordArraySrc, coordArrayDst integer(ESMF_KIND_I4),allocatable :: factorList(:) integer, allocatable :: factorIndexList(:,:) - type(ESMF_RouteHandle) :: routehandle - integer :: dimCountSrc, dimCountDst - integer :: deCountDst - integer, allocatable :: elementCountPDeDst(:) - integer(ESMF_KIND_I8) :: sumElementCountPDeDst - type(ESMF_TypeKind_Flag) :: coordTypeKindSrc, coordTypeKindDst - type(ESMF_CoordSys_Flag) :: coordSysSrc, coordSysDst - logical :: isPresentSrc, isPresentDst - integer :: dimIndex, staggerlocIndex - integer :: localPet - character(len=10) :: numString - CHARACTER(LEN=*), PARAMETER :: SUBNAME='(module_MEDIATOR:NEMS_GridCopyCoord)' + type(ESMF_RouteHandle) :: routehandle + integer :: dimCountSrc, dimCountDst + integer :: deCountDst + integer, allocatable :: elementCountPDeDst(:) + integer(ESMF_KIND_I8) :: sumElementCountPDeDst + type(ESMF_TypeKind_Flag) :: coordTypeKindSrc, coordTypeKindDst + type(ESMF_CoordSys_Flag) :: coordSysSrc, coordSysDst + logical :: isPresentSrc, isPresentDst + integer :: dimIndex, staggerlocIndex + integer :: localPet + character(len=10) :: numString + CHARACTER(LEN=*), PARAMETER :: SUBNAME='(module_MEDIATOR:NEMS_GridCopyCoord)' if (dbug_flag > 10) then call ESMF_LogWrite(SUBNAME//": called", ESMF_LOGMSG_INFO, rc=dbrc) endif - l_tolerance = 0.0 + l_tolerance = czero if (present(tolerance)) l_tolerance = tolerance l_compare = .FALSE. if (present(compare)) l_compare = compare @@ -8996,115 +9544,100 @@ subroutine NEMS_GridCopyCoord(gridcomp, gridSrc, gridDst, staggerloc, tolerance, l_invert = -1 endif - call ESMF_GridGet(gridSrc, distGrid=distGridSrc, & - dimCount=dimCountSrc, coordTypeKind=coordTypeKindSrc, & - coordSys=coordSysSrc, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__,file=__FILE__)) return ! bail out + call ESMF_GridGet(gridSrc, distGrid=distGridSrc, & + dimCount=dimCountSrc, coordTypeKind=coordTypeKindSrc, & + coordSys=coordSysSrc, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__,file=__FILE__)) return - call ESMF_GridGet(gridDst, distGrid=distGridDst, & - dimCount=dimCountDst, coordTypeKind=coordTypeKindDst, & - coordSys=coordSysDst, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__,file=__FILE__)) return ! bail out + call ESMF_GridGet(gridDst, distGrid=distGridDst, & + dimCount=dimCountDst, coordTypeKind=coordTypeKindDst, & + coordSys=coordSysDst, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__,file=__FILE__)) return if (.NOT. NEMS_DistGridMatch(distGrid1=distGridSrc, distGrid2=distGridDst, rc=rc)) then call ESMF_LogSetError(ESMF_RC_ARG_BAD, & - msg=SUBNAME//": Unable to redistribute coordinates. DistGrids do not match.", & - line=__LINE__, file=__FILE__, rcToReturn=rc) - return ! bail out + msg=SUBNAME//": Unable to redistribute coordinates. DistGrids do not match.", & + line=__LINE__, file=__FILE__, rcToReturn=rc) + return endif if ( dimCountSrc /= dimCountDst) then - call ESMF_LogSetError(ESMF_RC_ARG_BAD, & - msg=SUBNAME//": DIMCOUNT MISMATCH", & - line=__LINE__, file=__FILE__, rcToReturn=rc) - return ! bail out + call ESMF_LogSetError(ESMF_RC_ARG_BAD, & + msg=SUBNAME//": DIMCOUNT MISMATCH", & + line=__LINE__, file=__FILE__, rcToReturn=rc) + return endif if ( coordTypeKindSrc /= coordTypeKindDst) then - call ESMF_LogSetError(ESMF_RC_ARG_BAD, & - msg=SUBNAME//": COORDTYPEKIND MISMATCH", & - line=__LINE__, file=__FILE__, rcToReturn=rc) - return ! bail out + call ESMF_LogSetError(ESMF_RC_ARG_BAD, & + msg=SUBNAME//": COORDTYPEKIND MISMATCH", & + line=__LINE__, file=__FILE__, rcToReturn=rc) + return endif if ( coordSysSrc /= coordSysDst) then - call ESMF_LogSetError(ESMF_RC_ARG_BAD, & - msg=SUBNAME//": COORDSYS MISMATCH", & - line=__LINE__, file=__FILE__, rcToReturn=rc) - return ! bail out + call ESMF_LogSetError(ESMF_RC_ARG_BAD, & + msg=SUBNAME//": COORDSYS MISMATCH", & + line=__LINE__, file=__FILE__, rcToReturn=rc) + return endif do dimIndex=1, dimCountDst do staggerlocIndex=1, size(staggerloc) call ESMF_GridGetCoord(gridSrc, staggerloc=staggerloc(staggerlocIndex), & - isPresent=isPresentSrc, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__,file=__FILE__)) return ! bail out + isPresent=isPresentSrc, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__,file=__FILE__)) return if(isPresentSrc) then - call ESMF_GridGetCoord(gridSrc, coordDim=dimIndex, & - staggerloc=staggerloc(staggerlocIndex), & - array=coordArraySrc, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__,file=__FILE__)) return ! bail out - call ESMF_GridGetCoord(gridDst, & - staggerloc=staggerloc(staggerlocIndex), & - isPresent=isPresentDst, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__,file=__FILE__)) return ! bail out + call ESMF_GridGetCoord(gridSrc, coordDim=dimIndex, & + staggerloc=staggerloc(staggerlocIndex), & + array=coordArraySrc, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__,file=__FILE__)) return + call ESMF_GridGetCoord(gridDst, & + staggerloc=staggerloc(staggerlocIndex), & + isPresent=isPresentDst, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__,file=__FILE__)) return if(.NOT.isPresentDst) then - call ESMF_GridAddCoord(gridDst, & - staggerLoc=staggerloc(staggerlocIndex), rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__,file=__FILE__)) return ! bail out + call ESMF_GridAddCoord(gridDst, staggerLoc=staggerloc(staggerlocIndex), rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__,file=__FILE__)) return else if(l_compare .EQV. .TRUE.) then ! TODO: Compare existing coordinates call ESMF_LogSetError(ESMF_RC_NOT_IMPL, & - msg=SUBNAME//": Cannot compare existing coordinates.", & - line=__LINE__, file=__FILE__, rcToReturn=rc) - return ! bail out + msg=SUBNAME//": Cannot compare existing coordinates.", & + line=__LINE__, file=__FILE__, rcToReturn=rc) + return end if endif - call ESMF_GridGetCoord(gridDst, coordDim=dimIndex, & - staggerloc=staggerloc(staggerlocIndex), & - array=coordArrayDst, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__,file=__FILE__)) return ! bail out + call ESMF_GridGetCoord(gridDst, coordDim=dimIndex, & + staggerloc=staggerloc(staggerlocIndex), & + array=coordArrayDst, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__,file=__FILE__)) return call ESMF_ArrayGet(coordArraySrc, distGrid=distGridSrc, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__,file=__FILE__)) return ! bail out - call ESMF_ArrayGet(coordArrayDst, distGrid=distGridDst, & - dimCount=dimCountDst, deCount=deCountDst, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__,file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__,file=__FILE__)) return + call ESMF_ArrayGet(coordArrayDst, distGrid=distGridDst, & + dimCount=dimCountDst, deCount=deCountDst, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__,file=__FILE__)) return if (.NOT. NEMS_DistGridMatch(distGrid1=distGridSrc, distGrid2=distGridDst, rc=rc)) then call ESMF_LogSetError(ESMF_RC_ARG_BAD, & - msg=SUBNAME//": Unable to redistribute coordinates. DistGrids do not match.", & - line=__LINE__, file=__FILE__, rcToReturn=rc) - return ! bail out + msg=SUBNAME//": Unable to redistribute coordinates. DistGrids do not match.", & + line=__LINE__, file=__FILE__, rcToReturn=rc) + return endif if ( ANY( l_invert == dimIndex )) then call ESMF_GridCompGet(gridcomp, vm=vm, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__,file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__,file=__FILE__)) return call ESMF_VMGet(vm, localPet=localPet, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__,file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__,file=__FILE__)) return if (localPet == 0) then call ESMF_DistGridGet(distGridDst, deCount=deCountDst, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__,file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__,file=__FILE__)) return allocate(elementCountPDeDst(deCountDst)) - call ESMF_DistGridGet(distGridDst, & - elementCountPDe=elementCountPDeDst, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__,file=__FILE__)) return ! bail out + call ESMF_DistGridGet(distGridDst, elementCountPDe=elementCountPDeDst, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__,file=__FILE__)) return sumElementCountPDeDst = SUM(elementCountPDeDst) if (dbug_flag >= 2) then @@ -9127,49 +9660,42 @@ subroutine NEMS_GridCopyCoord(gridcomp, gridSrc, gridDst, staggerloc, tolerance, write (numString, "(I10)") factorIndexList(1,sumElementCountPDeDst) write (msgString, "(A)") trim(msgString)//" "//trim(adjustl(numString))//"=>" write (numString, "(I10)") factorIndexList(2,sumElementCountPDEDst) - write (msgString, "(A)") trim(msgString)//trim(adjustl(numString)) + write (msgString, "(A)") trim(msgString)//trim(adjustl(numString)) call ESMF_LogWrite(SUBNAME//": Invert Mapping: "//msgString, ESMF_LOGMSG_INFO, rc=dbrc) endif call ESMF_ArraySMMStore(srcArray=coordArraySrc, dstArray=coordArrayDst, & - routehandle=routehandle, factorList=factorList, & - factorIndexList=factorIndexList, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__,file=__FILE__)) return ! bail out + routehandle=routehandle, factorList=factorList, & + factorIndexList=factorIndexList, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__,file=__FILE__)) return deallocate(elementCountPDeDst) deallocate(factorList) deallocate(factorIndexList) else call ESMF_ArraySMMStore(srcArray=coordArraySrc, dstArray=coordArrayDst, & - routehandle=routehandle, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__,file=__FILE__)) return ! bail out + routehandle=routehandle, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__,file=__FILE__)) return endif call ESMF_ArraySMM(srcArray=coordArraySrc, dstArray=coordArrayDst, & - routehandle=routehandle, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__,file=__FILE__)) return ! bail out + routehandle=routehandle, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__,file=__FILE__)) return call ESMF_ArraySMMRelease(routehandle=routehandle, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__,file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__,file=__FILE__)) return else call ESMF_ArrayRedistStore(coordArraySrc, coordArrayDst, routehandle=routehandle, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__,file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__,file=__FILE__)) return call ESMF_ArrayRedist(coordArraySrc, coordArrayDst, routehandle=routehandle, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__,file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__,file=__FILE__)) return call ESMF_ArrayRedistRelease(routehandle=routehandle, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__,file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__,file=__FILE__)) return endif else - call ESMF_LogSetError(ESMF_RC_ARG_BAD, & - msg=SUBNAME//": SOURCE GRID MISSING STAGGER LOCATION", & - line=__LINE__, file=__FILE__, rcToReturn=rc) - return ! bail out + call ESMF_LogSetError(ESMF_RC_ARG_BAD, & + msg=SUBNAME//": SOURCE GRID MISSING STAGGER LOCATION", & + line=__LINE__, file=__FILE__, rcToReturn=rc) + return endif enddo enddo @@ -9203,21 +9729,21 @@ subroutine NEMS_GridCopyItem(gridcomp, gridSrc, gridDst, item, tolerance, compar type(ESMF_StaggerLoc) :: l_staggerloc type(ESMF_DistGrid) :: distGridSrc, distGridDst type(ESMF_Array) :: itemArraySrc, itemArrayDst - type(ESMF_RouteHandle) :: routehandle - integer :: dimCountSrc, dimCountDst - type(ESMF_TypeKind_Flag) :: coordTypeKindSrc, coordTypeKindDst - type(ESMF_CoordSys_Flag) :: coordSysSrc, coordSysDst - logical :: isPresentSrc, isPresentDst - integer :: itemIndex - integer :: localPet - character(len=10) :: numString - CHARACTER(LEN=*), PARAMETER :: SUBNAME='(module_MEDIATOR:NEMS_GridCopyItem)' + type(ESMF_RouteHandle) :: routehandle + integer :: dimCountSrc, dimCountDst + type(ESMF_TypeKind_Flag) :: coordTypeKindSrc, coordTypeKindDst + type(ESMF_CoordSys_Flag) :: coordSysSrc, coordSysDst + logical :: isPresentSrc, isPresentDst + integer :: itemIndex + integer :: localPet + character(len=10) :: numString + CHARACTER(LEN=*), PARAMETER :: SUBNAME='(module_MEDIATOR:NEMS_GridCopyItem)' if (dbug_flag > 10) then call ESMF_LogWrite(SUBNAME//": called", ESMF_LOGMSG_INFO, rc=dbrc) endif - l_tolerance = 0.0 + l_tolerance = czero if (present(tolerance)) l_tolerance = tolerance l_compare = .FALSE. if (present(compare)) l_compare = compare @@ -9230,113 +9756,101 @@ subroutine NEMS_GridCopyItem(gridcomp, gridSrc, gridDst, item, tolerance, compar endif l_staggerloc = ESMF_STAGGERLOC_CENTER - call ESMF_GridGet(gridSrc, distGrid=distGridSrc, & - dimCount=dimCountSrc, coordTypeKind=coordTypeKindSrc, & - coordSys=coordSysSrc, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__,file=__FILE__)) return ! bail out + call ESMF_GridGet(gridSrc, distGrid=distGridSrc, & + dimCount=dimCountSrc, coordTypeKind=coordTypeKindSrc, & + coordSys=coordSysSrc, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__,file=__FILE__)) return - call ESMF_GridGet(gridDst, distGrid=distGridDst, & - dimCount=dimCountDst, coordTypeKind=coordTypeKindDst, & - coordSys=coordSysDst, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__,file=__FILE__)) return ! bail out + call ESMF_GridGet(gridDst, distGrid=distGridDst, & + dimCount=dimCountDst, coordTypeKind=coordTypeKindDst, & + coordSys=coordSysDst, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__,file=__FILE__)) return if (.NOT. NEMS_DistGridMatch(distGrid1=distGridSrc, distGrid2=distGridDst, rc=rc)) then - call ESMF_LogSetError(ESMF_RC_ARG_BAD, & - msg=SUBNAME//": Unable to redistribute coordinates. DistGrids do not match.", & - line=__LINE__, file=__FILE__, rcToReturn=rc) - return ! bail out + call ESMF_LogSetError(ESMF_RC_ARG_BAD, & + msg=SUBNAME//": Unable to redistribute coordinates. DistGrids do not match.", & + line=__LINE__, file=__FILE__, rcToReturn=rc) + return endif if ( dimCountSrc /= dimCountDst) then call ESMF_LogSetError(ESMF_RC_ARG_BAD, & - msg=SUBNAME//": DIMCOUNT MISMATCH", & - line=__LINE__, file=__FILE__, rcToReturn=rc) - return ! bail out + msg=SUBNAME//": DIMCOUNT MISMATCH", & + line=__LINE__, file=__FILE__, rcToReturn=rc) + return endif if ( coordTypeKindSrc /= coordTypeKindDst) then call ESMF_LogSetError(ESMF_RC_ARG_BAD, & - msg=SUBNAME//": COORDTYPEKIND MISMATCH", & - line=__LINE__, file=__FILE__, rcToReturn=rc) - return ! bail out + msg=SUBNAME//": COORDTYPEKIND MISMATCH", & + line=__LINE__, file=__FILE__, rcToReturn=rc) + return endif if ( coordSysSrc /= coordSysDst) then - call ESMF_LogSetError(ESMF_RC_ARG_BAD, & - msg=SUBNAME//": COORDSYS MISMATCH", & - line=__LINE__, file=__FILE__, rcToReturn=rc) - return ! bail out + call ESMF_LogSetError(ESMF_RC_ARG_BAD, & + msg=SUBNAME//": COORDSYS MISMATCH", & + line=__LINE__, file=__FILE__, rcToReturn=rc) + return endif do itemIndex=1, size(item) call ESMF_GridGetItem(gridSrc, itemflag=item(itemIndex), & - staggerloc=l_staggerloc, isPresent=isPresentSrc, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__,file=__FILE__)) return ! bail out + staggerloc=l_staggerloc, isPresent=isPresentSrc, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__,file=__FILE__)) return if(isPresentSrc) then call ESMF_GridGetItem(gridSrc, itemflag=item(itemIndex), & - staggerloc=l_staggerloc, array=itemArraySrc, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__,file=__FILE__)) return ! bail out + staggerloc=l_staggerloc, array=itemArraySrc, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__,file=__FILE__)) return call ESMF_GridGetItem(gridDst, itemflag=item(itemIndex), & - staggerloc=l_staggerloc, isPresent=isPresentDst, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__,file=__FILE__)) return ! bail out + staggerloc=l_staggerloc, isPresent=isPresentDst, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__,file=__FILE__)) return if(.NOT.isPresentDst) then call ESMF_GridAddItem(gridDst, itemflag=item(itemIndex), & - staggerLoc=l_staggerloc, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__,file=__FILE__)) return ! bail out + staggerLoc=l_staggerloc, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__,file=__FILE__)) return else if(l_compare .EQV. .TRUE.) then ! TODO: Compare existing coordinates - call ESMF_LogSetError(ESMF_RC_NOT_IMPL, & - msg=SUBNAME//": Cannot compare existing coordinates.", & - line=__LINE__, file=__FILE__, rcToReturn=rc) - return ! bail out + call ESMF_LogSetError(ESMF_RC_NOT_IMPL, & + msg=SUBNAME//": Cannot compare existing coordinates.", & + line=__LINE__, file=__FILE__, rcToReturn=rc) + return end if endif call ESMF_GridGetItem(gridDst, itemflag=item(itemIndex), & - staggerloc=l_staggerloc, array=itemArrayDst, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__,file=__FILE__)) return ! bail out + staggerloc=l_staggerloc, array=itemArrayDst, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__,file=__FILE__)) return call ESMF_ArrayGet(itemArraySrc, distGrid=distGridSrc, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__,file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__,file=__FILE__)) return call ESMF_ArrayGet(itemArrayDst, distGrid=distGridDst, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__,file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__,file=__FILE__)) return if (.NOT. NEMS_DistGridMatch(distGrid1=distGridSrc, distGrid2=distGridDst, rc=rc)) then call ESMF_LogSetError(ESMF_RC_ARG_BAD, & - msg=SUBNAME//": Unable to redistribute coordinates. DistGrids do not match.", & - line=__LINE__, file=__FILE__, rcToReturn=rc) - return ! bail out + msg=SUBNAME//": Unable to redistribute coordinates. DistGrids do not match.", & + line=__LINE__, file=__FILE__, rcToReturn=rc) + return endif if ( ANY( l_invert > 0 )) then ! TODO: Invert Item - call ESMF_LogSetError(ESMF_RC_NOT_IMPL, & - msg=SUBNAME//": Cannot invert item.", & - line=__LINE__, file=__FILE__, rcToReturn=rc) - return ! bail out + call ESMF_LogSetError(ESMF_RC_NOT_IMPL, & + msg=SUBNAME//": Cannot invert item.", & + line=__LINE__, file=__FILE__, rcToReturn=rc) + return else call ESMF_ArrayRedistStore(itemArraySrc, itemArrayDst, routehandle=routehandle, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__,file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & line=__LINE__,file=__FILE__)) return call ESMF_ArrayRedist(itemArraySrc, itemArrayDst, routehandle=routehandle, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__,file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & line=__LINE__,file=__FILE__)) return call ESMF_ArrayRedistRelease(routehandle=routehandle, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__,file=__FILE__)) return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__,file=__FILE__)) return endif else - call ESMF_LogSetError(ESMF_RC_ARG_BAD, & - msg=SUBNAME//": SOURCE GRID MISSING ITEM", & - line=__LINE__, file=__FILE__, rcToReturn=rc) - return ! bail out + call ESMF_LogSetError(ESMF_RC_ARG_BAD, & + msg=SUBNAME//": SOURCE GRID MISSING ITEM", & + line=__LINE__, file=__FILE__, rcToReturn=rc) + return endif enddo @@ -9349,7 +9863,6 @@ subroutine NEMS_GridCopyItem(gridcomp, gridSrc, gridDst, item, tolerance, compar end subroutine NEMS_GridCopyItem !----------------------------------------------------------------------------- - subroutine NUOPCplus_UpdateTimestampS(state, time, rc) type(ESMF_State) :: state type(ESMF_Time) :: time @@ -9357,27 +9870,21 @@ subroutine NUOPCplus_UpdateTimestampS(state, time, rc) ! local variables integer :: i - type(ESMF_Field), pointer :: fieldList(:) + type(ESMF_Field), pointer :: fieldList(:) rc = ESMF_SUCCESS nullify(fieldList) call NUOPC_GetStateMemberLists(state, fieldList=fieldList, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return do i=1, size(fieldList) call NUOPCplus_UpdateTimestamp(fieldList(i), time, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return enddo if (associated(fieldList)) deallocate(fieldList) - + end subroutine NUOPCplus_UpdateTimestampS !----------------------------------------------------------------------------- @@ -9391,24 +9898,38 @@ subroutine NUOPCplus_UpdateTimestampF(field, time, rc) integer :: yy, mm, dd, h, m, s, ms, us, ns rc = ESMF_SUCCESS - + call ESMF_TimeGet(time, yy=yy, mm=mm, dd=dd, h=h, m=m, s=s, ms=ms, us=us, & - ns=ns, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out - call ESMF_AttributeSet(field, & - name="TimeStamp", valueList=(/yy,mm,dd,h,m,s,ms,us,ns/), & - convention="NUOPC", purpose="Instance", & - attnestflag=ESMF_ATTNEST_ON, rc=rc) - if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, & - line=__LINE__, & - file=__FILE__)) & - return ! bail out + ns=ns, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return + call ESMF_AttributeSet(field, & + name="TimeStamp", valueList=(/yy,mm,dd,h,m,s,ms,us,ns/), & + convention="NUOPC", purpose="Instance", & + attnestflag=ESMF_ATTNEST_ON, rc=rc) + if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return end subroutine NUOPCplus_UpdateTimestampF - !----------------------------------------------------------------------------- +!======================================================================= + +! Compute length of string by finding first non-blank character from the right. + + integer function lenstr(label) + + character*(*) label + + ! local variables + + integer :: length, n + + length = len(label) + do n=length,1,-1 + if( label(n:n) /= ' ' ) exit + enddo + lenstr = n + + end function lenstr + +!======================================================================= end module diff --git a/src/module_MEDIATOR_methods.F90 b/src/module_MEDIATOR_methods.F90 index 4391e04c..e4d30886 100644 --- a/src/module_MEDIATOR_methods.F90 +++ b/src/module_MEDIATOR_methods.F90 @@ -33,10 +33,10 @@ module module_MEDIATOR_methods real(R8),parameter :: SHR_CONST_LATVAP = 2.501e6_R8 ! latent heat of evaporation ~ J/kg real(R8),parameter :: SHR_CONST_LATSUB = & ! latent heat of sublimation ~ J/kg SHR_CONST_LATICE + SHR_CONST_LATVAP - real(R8),parameter :: SHR_CONST_SPVAL = 1.0e30_R8 ! special missing value + real(R8),parameter :: SHR_CONST_SPVAL = 1.0e30_R8 ! special missing value - integer, parameter :: debug = 0 - integer, parameter :: s_loglev = 0 + integer, parameter :: debug = 0 + integer, parameter :: s_loglev = 0 integer, parameter :: s_logunit = 6 public shr_flux_atmOcn diff --git a/src/module_NEMS_GRID_COMP.F90 b/src/module_NEMS_GRID_COMP.F90 index e0593f1c..4ac6705f 100644 --- a/src/module_NEMS_GRID_COMP.F90 +++ b/src/module_NEMS_GRID_COMP.F90 @@ -35,14 +35,14 @@ MODULE module_NEMS_GRID_COMP ! USE ESMF ! - USE module_NEMS_INTERNAL_STATE,ONLY: NEMS_INTERNAL_STATE & - ,WRAP_NEMS_INTERNAL_STATE + USE module_NEMS_INTERNAL_STATE,ONLY : NEMS_INTERNAL_STATE & + ,WRAP_NEMS_INTERNAL_STATE ! - USE ENS_CplComp_ESMFMod,ONLY: ENS_CplCompSetServices + USE ENS_CplComp_ESMFMod, ONLY : ENS_CplCompSetServices ! USE module_EARTH_GRID_COMP ! - USE module_NEMS_UTILS,ONLY: ERR_MSG,MESSAGE_CHECK + USE module_NEMS_UTILS, ONLY : ERR_MSG,MESSAGE_CHECK ! !----------------------------------------------------------------------- ! @@ -56,15 +56,11 @@ MODULE module_NEMS_GRID_COMP ! !----------------------------------------------------------------------- ! - INTEGER :: MEMBER_ID & - ,TOTAL_MEMBER + INTEGER :: MEMBER_ID, TOTAL_MEMBER ! - INTEGER :: HH_INCREASE & - ,HH_START & - ,HH_FINAL + INTEGER :: HH_INCREASE, HH_START, HH_FINAL ! - INTEGER :: NUMBER_START & - ,NUMBER_FINAL + INTEGER :: NUMBER_START, NUMBER_FINAL ! INTEGER,DIMENSION(:), ALLOCATABLE :: PE_MEMBER !<-- Tasks for each member INTEGER,DIMENSION(:, :),ALLOCATABLE :: PETLIST !<-- Task list for each member @@ -128,7 +124,7 @@ SUBROUTINE NEMS_REGISTER(NEMS_GRID_COMP,RC_REG) !----------------------------------------------------------------------- ! ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ - MESSAGE_CHECK="Set Entry Point for NEMS Initialize" + MESSAGE_CHECK = "Set Entry Point for NEMS Initialize" ! CALL ESMF_LogWrite(MESSAGE_CHECK,ESMF_LOGMSG_INFO,rc=RC) ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ! @@ -143,7 +139,7 @@ SUBROUTINE NEMS_REGISTER(NEMS_GRID_COMP,RC_REG) !----------------------------------------------------------------------- ! ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ - MESSAGE_CHECK="Set Entry Point for NEMS Run" + MESSAGE_CHECK = "Set Entry Point for NEMS Run" ! CALL ESMF_LogWrite(MESSAGE_CHECK,ESMF_LOGMSG_INFO,rc=RC) ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ! @@ -158,7 +154,7 @@ SUBROUTINE NEMS_REGISTER(NEMS_GRID_COMP,RC_REG) !----------------------------------------------------------------------- ! ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ - MESSAGE_CHECK="Set Entry Point for NEMS Finalize" + MESSAGE_CHECK = "Set Entry Point for NEMS Finalize" ! CALL ESMF_LogWrite(MESSAGE_CHECK,ESMF_LOGMSG_INFO,rc=RC) ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ! @@ -176,11 +172,8 @@ END SUBROUTINE NEMS_REGISTER !####################################################################### !----------------------------------------------------------------------- ! - SUBROUTINE NEMS_INITIALIZE(NEMS_GRID_COMP & - ,IMP_STATE & - ,EXP_STATE & - ,CLOCK_MAIN & - ,RC_INIT) + SUBROUTINE NEMS_INITIALIZE(NEMS_GRID_COMP, IMP_STATE, EXP_STATE, & + CLOCK_MAIN , RC_INIT) ! !----------------------------------------------------------------------- ! @@ -190,10 +183,10 @@ SUBROUTINE NEMS_INITIALIZE(NEMS_GRID_COMP & ! TYPE(ESMF_GridComp) :: NEMS_GRID_COMP !<-- The NEMS component ! - TYPE(ESMF_State) :: IMP_STATE & !<-- The NEMS import state - ,EXP_STATE !<-- The NEMS export state + TYPE(ESMF_State) :: IMP_STATE & !<-- The NEMS import state + ,EXP_STATE !<-- The NEMS export state ! - TYPE(ESMF_Clock) :: CLOCK_MAIN !<-- The main Clock + TYPE(ESMF_Clock) :: CLOCK_MAIN !<-- The main Clock ! INTEGER,INTENT(OUT) :: RC_INIT !<-- Error return code ! @@ -211,14 +204,10 @@ SUBROUTINE NEMS_INITIALIZE(NEMS_GRID_COMP & ,IMP_EARTH_NAME & !<-- Import state name of the EARTH components ,EXP_EARTH_NAME !<-- Export state name of the EARTH components ! - INTEGER :: I,IJ,J,RC,RC_USER + INTEGER :: I, IJ, J, RC, RC_USER ! - INTEGER :: MYPE_GLOBAL & - ,NHOURS_FCST & - ,NSECONDS_FCST & - ,PE_MAX & - ,TASKS & - ,fhrot + INTEGER :: MYPE_GLOBAL, NHOURS_FCST, NSECONDS_FCST, PE_MAX, & + TASKS, fhrot ! INTEGER,DIMENSION(:,:),ALLOCATABLE :: PETLIST !<-- Task list for each ensemble member ! @@ -233,7 +222,7 @@ SUBROUTINE NEMS_INITIALIZE(NEMS_GRID_COMP & !*** the NEMS component. !----------------------------------------------------------------------- ! - CLOCK_NEMS=CLOCK_MAIN + CLOCK_NEMS = CLOCK_MAIN ! !----------------------------------------------------------------------- !*** What is the start time on the NEMS clock? @@ -244,9 +233,7 @@ SUBROUTINE NEMS_INITIALIZE(NEMS_GRID_COMP & ! CALL ESMF_LogWrite(MESSAGE_CHECK, ESMF_LOGMSG_INFO, rc = RC) ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ - CALL ESMF_ClockGet(clock = CLOCK_NEMS & - ,startTime = STARTTIME & - ,rc = RC) + CALL ESMF_ClockGet(clock = CLOCK_NEMS, startTime = STARTTIME, rc = RC) ESMF_ERR_RETURN(RC,RC_INIT) ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ @@ -257,7 +244,7 @@ SUBROUTINE NEMS_INITIALIZE(NEMS_GRID_COMP & !----------------------------------------------------------------------- ! ALLOCATE(NEMS_INT_STATE,stat=RC) - wrap%NEMS_INT_STATE=>NEMS_INT_STATE + wrap%NEMS_INT_STATE => NEMS_INT_STATE ! CALL ESMF_GridCompSetInternalState(NEMS_GRID_COMP & !<--The NEMS component ,WRAP & !<-- Pointer to the NEMS internal state @@ -269,9 +256,8 @@ SUBROUTINE NEMS_INITIALIZE(NEMS_GRID_COMP & !*** Obtain the total task count and the local task ID. !----------------------------------------------------------------------- ! - CALL ESMF_VMGetGlobal(vm = VM_GLOBAL & !<-- The ESMF global Virtual Machine - ,rc = RC) - ESMF_ERR_RETURN(RC,RC_INIT) + CALL ESMF_VMGetGlobal(vm = VM_GLOBAL, rc = RC) !<-- The ESMF global Virtual Machine + ESMF_ERR_RETURN(RC, RC_INIT) ! CALL ESMF_VMGet(vm = VM_GLOBAL & !<-- The ESMF global Virtual Machine ,pecount = TASKS & !<-- Total # of MPI tasks @@ -290,7 +276,7 @@ SUBROUTINE NEMS_INITIALIZE(NEMS_GRID_COMP & !----------------------------------------------------------------------- ! ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ - MESSAGE_CHECK="Create/Load the NEMS Configure Object" + MESSAGE_CHECK = "Create/Load the NEMS Configure Object" ! CALL ESMF_LogWrite(MESSAGE_CHECK,ESMF_LOGMSG_INFO,rc=RC) ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ! @@ -305,16 +291,16 @@ SUBROUTINE NEMS_INITIALIZE(NEMS_GRID_COMP & !----------------------------------------------------------------------- ! ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ - MESSAGE_CHECK="Extract the Ensemble Stochastic Coupling Flag from Config File" + MESSAGE_CHECK = "Extract the Ensemble Stochastic Coupling Flag from Config File" ! CALL ESMF_LogWrite(MESSAGE_CHECK,ESMF_LOGMSG_INFO,rc=RC) ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ! - CALL ESMF_ConfigGetAttribute(config = CF_NEMS & !<-- The NEMS configure object - ,value = ENS_SPS & !<-- Value of control flag for + CALL ESMF_ConfigGetAttribute(config = CF_NEMS & !<-- The NEMS configure object + ,value = ENS_SPS & !<-- Value of control flag for ! stochastic perturbation scheme - ,label = 'ENS_SPS:' & !<-- Flag's label in configure file - ,default= .false. & - ,rc = RC) + ,label = 'ENS_SPS:' & !<-- Flag's label in configure file + ,default = .false. & + ,rc = RC) ESMF_ERR_RETURN(RC,RC_INIT) ! !----------------------------------------------------------------------- @@ -329,31 +315,31 @@ SUBROUTINE NEMS_INITIALIZE(NEMS_GRID_COMP & ! CALL ESMF_LogWrite(MESSAGE_CHECK,ESMF_LOGMSG_INFO,rc=RC) ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ! - CALL ESMF_ConfigGetAttribute(config=CF_NEMS & - ,value =NHOURS_FCST & - ,label ='nhours_fcst1:' & - ,rc =RC) + CALL ESMF_ConfigGetAttribute(config = CF_NEMS & + ,value = NHOURS_FCST & + ,label = 'nhours_fcst1:' & + ,rc = RC) ESMF_ERR_RETURN(RC,RC_INIT) ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ! - NSECONDS_FCST=NHOURS_FCST*3600 !<-- The forecast length (sec) (Integer) + NSECONDS_FCST = NHOURS_FCST*3600 !<-- The forecast length (sec) (Integer) ! !----------------------------------------------------------------------- ! ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ - MESSAGE_CHECK="NEMS: Set the Forecast Length" + MESSAGE_CHECK = "NEMS: Set the Forecast Length" ! CALL ESMF_LogWrite(MESSAGE_CHECK,ESMF_LOGMSG_INFO,rc=RC) ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ! - CALL ESMF_TimeIntervalSet(timeinterval=RUNDURATION & !<-- The forecast length (s) (ESMF) - ,s =NSECONDS_FCST & !<-- The forecast length (s) (Integer) - ,rc =RC) + CALL ESMF_TimeIntervalSet(timeinterval = RUNDURATION & !<-- The forecast length (s) (ESMF) + ,s = NSECONDS_FCST & !<-- The forecast length (s) (Integer) + ,rc = RC) ESMF_ERR_RETURN(RC,RC_INIT) ! CALL ESMF_ClockSet(clock = CLOCK_NEMS & !<-- The NEMS Clock ,runDuration = RUNDURATION & !<-- The forecast length (s) (ESMF) ,rc = RC) - ESMF_ERR_RETURN(RC,RC_INIT) + ESMF_ERR_RETURN(RC, RC_INIT) ! END IF ! @@ -362,15 +348,15 @@ SUBROUTINE NEMS_INITIALIZE(NEMS_GRID_COMP & !----------------------------------------------------------------------- ! ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ - MESSAGE_CHECK="Extract the Total Number of the EARTH Members from Config File" + MESSAGE_CHECK = "Extract the Total Number of the EARTH Members from Config File" ! CALL ESMF_LogWrite(MESSAGE_CHECK,ESMF_LOGMSG_INFO,rc=RC) ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ! - CALL ESMF_ConfigGetAttribute(config = CF_NEMS & !<-- The NEMS configure object - ,value = TOTAL_MEMBER & !<-- Total # of ensemble members - ,label = 'total_member:' & !<-- Flag in configure file - ,default= 1 & - ,rc = RC) + CALL ESMF_ConfigGetAttribute(config = CF_NEMS & !<-- The NEMS configure object + ,value = TOTAL_MEMBER & !<-- Total # of ensemble members + ,label = 'total_member:' & !<-- Flag in configure file + ,default = 1 & + ,rc = RC) ESMF_ERR_RETURN(RC,RC_INIT) ! !----------------------------------------------------------------------- @@ -443,10 +429,10 @@ SUBROUTINE NEMS_INITIALIZE(NEMS_GRID_COMP & !*** cycles from the config file. !----------------------------------------------------------------------- ! - IF(ENS_SPS) THEN + IF (ENS_SPS) THEN ! ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ - MESSAGE_CHECK="Extract the Ensemble Clock Parameters from Config File" + MESSAGE_CHECK = "Extract the Ensemble Clock Parameters from Config File" ! CALL ESMF_LogWrite(MESSAGE_CHECK,ESMF_LOGMSG_INFO,rc=RC) ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ! @@ -481,7 +467,7 @@ SUBROUTINE NEMS_INITIALIZE(NEMS_GRID_COMP & !----------------------------------------------------------------------- ! ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ - MESSAGE_CHECK="Create EARTH grid Components" + MESSAGE_CHECK = "Create EARTH grid Components" ! CALL ESMF_LogWrite(MESSAGE_CHECK,ESMF_LOGMSG_INFO,rc=RC) ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ! @@ -491,7 +477,7 @@ SUBROUTINE NEMS_INITIALIZE(NEMS_GRID_COMP & ,petlist = PETLIST(1:PE_MEMBER(I), I) & !<-- Element I's PE list ,config = CF_NEMS & !<-- Associate the NEMS config object with this element ,rc = RC) - ESMF_ERR_RETURN(RC,RC_INIT) + ESMF_ERR_RETURN(RC, RC_INIT) END DO ! !----------------------------------------------------------------------- @@ -500,9 +486,9 @@ SUBROUTINE NEMS_INITIALIZE(NEMS_GRID_COMP & !----------------------------------------------------------------------- ! IF(ENS_SPS) THEN - ENS_CPL_COMP=ESMF_CplCompCreate(name = "ENS Cpl component" & - ,rc = RC) - ESMF_ERR_RETURN(RC,RC_INIT) + ENS_CPL_COMP = ESMF_CplCompCreate(name = "ENS Cpl component" & + ,rc = RC) + ESMF_ERR_RETURN(RC, RC_INIT) END IF ! !----------------------------------------------------------------------- @@ -511,7 +497,7 @@ SUBROUTINE NEMS_INITIALIZE(NEMS_GRID_COMP & !----------------------------------------------------------------------- ! ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ - MESSAGE_CHECK="Register EARTH Init, Run, Finalize" + MESSAGE_CHECK = "Register EARTH Init, Run, Finalize" ! CALL ESMF_LogWrite(MESSAGE_CHECK,ESMF_LOGMSG_INFO,rc=RC) ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ! @@ -519,7 +505,7 @@ SUBROUTINE NEMS_INITIALIZE(NEMS_GRID_COMP & CALL ESMF_GridCompSetServices(EARTH_GRID_COMP(I) & !<-- The EARTH gridded components ,EARTH_REGISTER & !<-- User's name for the Register routine ,rc=RC) - ESMF_ERR_RETURN(RC,RC_INIT) + ESMF_ERR_RETURN(RC, RC_INIT) END DO ! !----------------------------------------------------------------------- @@ -530,14 +516,14 @@ SUBROUTINE NEMS_INITIALIZE(NEMS_GRID_COMP & IF(ENS_SPS) THEN ! ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ - MESSAGE_CHECK="Register Ensemble Coupler Init, Run, Finalize" + MESSAGE_CHECK = "Register Ensemble Coupler Init, Run, Finalize" ! CALL ESMF_LogWrite(MESSAGE_CHECK,ESMF_LOGMSG_INFO,rc=RC) ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ! CALL ESMF_CplCompSetServices(ENS_CPL_COMP & ,ENS_CplCompSetServices & !<-- The user's name for the Register routine ,rc=RC) - ESMF_ERR_RETURN(RC,RC_INIT) + ESMF_ERR_RETURN(RC, RC_INIT) ! END IF ! @@ -546,31 +532,31 @@ SUBROUTINE NEMS_INITIALIZE(NEMS_GRID_COMP & !----------------------------------------------------------------------- ! ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ - MESSAGE_CHECK="Create the EARTH import states" + MESSAGE_CHECK = "Create the EARTH import states" ! CALL ESMF_LogWrite(MESSAGE_CHECK,ESMF_LOGMSG_INFO,rc=RC) ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ! DO I = 1,TOTAL_MEMBER EARTH_IMP_STATE(I) = ESMF_StateCreate( & - name = IMP_EARTH_NAME(I) & - ,stateintent = ESMF_STATEINTENT_IMPORT & - ,rc = RC) - ESMF_ERR_RETURN(RC,RC_INIT) + name = IMP_EARTH_NAME(I) & + ,stateintent = ESMF_STATEINTENT_IMPORT & + ,rc = RC) + ESMF_ERR_RETURN(RC, RC_INIT) END DO ! !----------------------------------------------------------------------- ! ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ - MESSAGE_CHECK="Create the EARTH export states" + MESSAGE_CHECK = "Create the EARTH export states" ! CALL ESMF_LogWrite(MESSAGE_CHECK,ESMF_LOGMSG_INFO,rc=RC) ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ! DO I = 1,TOTAL_MEMBER - EARTH_EXP_STATE(I) = ESMF_StateCreate( & - name = EXP_EARTH_NAME(I) & - ,stateintent = ESMF_STATEINTENT_EXPORT & - ,rc = RC) - ESMF_ERR_RETURN(RC,RC_INIT) + EARTH_EXP_STATE(I) = ESMF_StateCreate( & + name = EXP_EARTH_NAME(I) & + ,stateintent = ESMF_STATEINTENT_EXPORT & + ,rc = RC) + ESMF_ERR_RETURN(RC, RC_INIT) END DO ! !----------------------------------------------------------------------- @@ -580,26 +566,26 @@ SUBROUTINE NEMS_INITIALIZE(NEMS_GRID_COMP & IF(ENS_SPS) THEN ! ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ - MESSAGE_CHECK="Create the Ensemble Coupler import state" + MESSAGE_CHECK = "Create the Ensemble Coupler import state" ! CALL ESMF_LogWrite(MESSAGE_CHECK,ESMF_LOGMSG_INFO,rc=RC) ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ! - ENS_CPL_IMP_STATE=ESMF_StateCreate(name = "ENS_CPL_Import" & - ,stateintent = ESMF_STATEINTENT_IMPORT & - ,rc = RC) - ESMF_ERR_RETURN(RC,RC_INIT) + ENS_CPL_IMP_STATE = ESMF_StateCreate(name = "ENS_CPL_Import" & + ,stateintent = ESMF_STATEINTENT_IMPORT & + ,rc = RC) + ESMF_ERR_RETURN(RC, RC_INIT) ! !----------------------------------------------------------------------- ! ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ - MESSAGE_CHECK="Create the Ensemble Coupler export state" + MESSAGE_CHECK = "Create the Ensemble Coupler export state" ! CALL ESMF_LogWrite(MESSAGE_CHECK,ESMF_LOGMSG_INFO,rc=RC) ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ! - ENS_CPL_EXP_STATE=ESMF_StateCreate(name = "ENS_CPL_Export" & - ,stateintent = ESMF_STATEINTENT_EXPORT & - ,rc = RC) - ESMF_ERR_RETURN(RC,RC_INIT) + ENS_CPL_EXP_STATE = ESMF_StateCreate(name = "ENS_CPL_Export" & + ,stateintent = ESMF_STATEINTENT_EXPORT & + ,rc = RC) + ESMF_ERR_RETURN(RC, RC_INIT) ! !----------------------------------------------------------------------- !*** Nest the EARTH export/import states into the import/export states @@ -607,16 +593,17 @@ SUBROUTINE NEMS_INITIALIZE(NEMS_GRID_COMP & !----------------------------------------------------------------------- ! ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ - MESSAGE_CHECK= "Add the EARTH states into the ENS_CPL states" + MESSAGE_CHECK = "Add the EARTH states into the ENS_CPL states" ! CALL ESMF_LogWrite(MESSAGE_CHECK, ESMF_LOGMSG_INFO, rc = RC) ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ! DO I = 1, TOTAL_MEMBER IF(MEMBER_ID == I) THEN - CALL ESMF_StateAddReplace(ENS_CPL_IMP_STATE,(/EARTH_EXP_STATE(I)/), rc = RC) - ESMF_ERR_RETURN(RC,RC_INIT) - CALL ESMF_StateAddReplace(ENS_CPL_EXP_STATE,(/EARTH_IMP_STATE(I)/), rc = RC) - ESMF_ERR_RETURN(RC,RC_INIT) + CALL ESMF_StateAddReplace(ENS_CPL_IMP_STATE, (/EARTH_EXP_STATE(I)/), rc = RC) + ESMF_ERR_RETURN(RC, RC_INIT) + + CALL ESMF_StateAddReplace(ENS_CPL_EXP_STATE, (/EARTH_IMP_STATE(I)/), rc = RC) + ESMF_ERR_RETURN(RC, RC_INIT) END IF END DO ! @@ -630,15 +617,15 @@ SUBROUTINE NEMS_INITIALIZE(NEMS_GRID_COMP & !*** Restart-From-History. !----------------------------------------------------------------------- - CALL ESMF_ConfigGetAttribute(config = CF_NEMS & - ,value = fhrot & - ,label = 'fhrot:' & - ,default = 0 & - ,rc = RC) - ESMF_ERR_RETURN(RC,RC_INIT) + CALL ESMF_ConfigGetAttribute(config = CF_NEMS & + ,value = fhrot & + ,label = 'fhrot:' & + ,default = 0 & + ,rc = RC) + ESMF_ERR_RETURN(RC, RC_INIT) if (fhrot > 0) then - CALL ESMF_TimeIntervalSet(restartOffset, h=fhrot,rc=RC) - ESMF_ERR_RETURN(RC,RC_INIT) + CALL ESMF_TimeIntervalSet(restartOffset, h=fhrot, rc=RC) + ESMF_ERR_RETURN(RC, RC_INIT) CURRTIME = STARTTIME + restartOffset call ESMF_ClockSet(CLOCK_NEMS, currTime=CURRTIME, rc=RC) ESMF_ERR_RETURN(RC,RC_INIT) @@ -650,7 +637,7 @@ SUBROUTINE NEMS_INITIALIZE(NEMS_GRID_COMP & !----------------------------------------------------------------------- ! ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ - MESSAGE_CHECK="Execute the Initialize step of the EARTH component" + MESSAGE_CHECK = "Execute the Initialize step of the EARTH component" ! CALL ESMF_LogWrite(MESSAGE_CHECK,ESMF_LOGMSG_INFO,rc=RC) ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ! @@ -664,8 +651,8 @@ SUBROUTINE NEMS_INITIALIZE(NEMS_GRID_COMP & ,phase = 1 & ,userRc = RC_USER & ,rc = RC) - ESMF_ERR_RETURN(RC,RC_INIT) - ESMF_ERR_RETURN(RC_USER,RC_INIT) + ESMF_ERR_RETURN(RC, RC_INIT) + ESMF_ERR_RETURN(RC_USER, RC_INIT) END IF ! END DO @@ -677,19 +664,19 @@ SUBROUTINE NEMS_INITIALIZE(NEMS_GRID_COMP & IF(ENS_SPS) THEN ! ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ - MESSAGE_CHECK="Execute the Initialize step of the Ensemble Coupler component" + MESSAGE_CHECK = "Execute the Initialize step of the Ensemble Coupler component" ! CALL ESMF_LogWrite(MESSAGE_CHECK,ESMF_LOGMSG_INFO,rc=RC) ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ! - CALL ESMF_CplCompInitialize(cplcomp =ENS_CPL_COMP & - ,importState=ENS_CPL_IMP_STATE & - ,exportState=ENS_CPL_EXP_STATE & - ,clock =CLOCK_NEMS & - ,phase =1 & - ,userRc =RC_USER & - ,rc =RC) - ESMF_ERR_RETURN(RC,RC_INIT) - ESMF_ERR_RETURN(RC_USER,RC_INIT) + CALL ESMF_CplCompInitialize(cplcomp = ENS_CPL_COMP & + ,importState = ENS_CPL_IMP_STATE & + ,exportState = ENS_CPL_EXP_STATE & + ,clock = CLOCK_NEMS & + ,phase = 1 & + ,userRc = RC_USER & + ,rc = RC) + ESMF_ERR_RETURN(RC, RC_INIT) + ESMF_ERR_RETURN(RC_USER, RC_INIT) ! END IF ! @@ -701,11 +688,8 @@ END SUBROUTINE NEMS_INITIALIZE !&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& !----------------------------------------------------------------------- ! - SUBROUTINE NEMS_RUN(NEMS_GRID_COMP & - ,IMP_STATE & - ,EXP_STATE & - ,CLOCK_MAIN & - ,RC_RUN) + SUBROUTINE NEMS_RUN(NEMS_GRID_COMP, IMP_STATE, EXP_STATE, & + CLOCK_MAIN, RC_RUN) ! !----------------------------------------------------------------------- ! @@ -715,10 +699,10 @@ SUBROUTINE NEMS_RUN(NEMS_GRID_COMP & ! TYPE(ESMF_GridComp) :: NEMS_GRID_COMP !<-- The NEMS component ! - TYPE(ESMF_State) :: IMP_STATE & !<-- The NEMS import state - ,EXP_STATE !<-- The NEMS export state + TYPE(ESMF_State) :: IMP_STATE & !<-- The NEMS import state + ,EXP_STATE !<-- The NEMS export state ! - TYPE(ESMF_Clock) :: CLOCK_MAIN !<-- The main Clock + TYPE(ESMF_Clock) :: CLOCK_MAIN !<-- The main Clock ! INTEGER,INTENT(OUT) :: RC_RUN !<-- Error return code ! @@ -726,9 +710,9 @@ SUBROUTINE NEMS_RUN(NEMS_GRID_COMP & !*** Local Variables !--------------------- ! - INTEGER :: HH,I,J,RC,RC_USER + INTEGER :: HH, I, J, RC, RC_USER ! - TYPE(ESMF_Time) :: CURRTIME + TYPE(ESMF_Time) :: CURRTIME ! TYPE(ESMF_TimeInterval) :: RUNDURATION ! @@ -743,7 +727,7 @@ SUBROUTINE NEMS_RUN(NEMS_GRID_COMP & !*** the NEMS component. !----------------------------------------------------------------------- ! - CLOCK_NEMS=CLOCK_MAIN + CLOCK_NEMS = CLOCK_MAIN ! !----------------------------------------------------------------------- !*** Execute the Run step of each element in the EARTH component @@ -751,7 +735,7 @@ SUBROUTINE NEMS_RUN(NEMS_GRID_COMP & !----------------------------------------------------------------------- ! ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ - MESSAGE_CHECK="Execute the Run step of the EARTH components" + MESSAGE_CHECK = "Execute the Run step of the EARTH components" ! CALL ESMF_LogWrite(MESSAGE_CHECK,ESMF_LOGMSG_INFO,rc=RC) ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ! @@ -765,8 +749,8 @@ SUBROUTINE NEMS_RUN(NEMS_GRID_COMP & ,phase = 1 & ,userRc = RC_USER & ,rc = RC) - ESMF_ERR_RETURN(RC,RC_RUN) - ESMF_ERR_RETURN(RC_USER,RC_RUN) + ESMF_ERR_RETURN(RC, RC_RUN) + ESMF_ERR_RETURN(RC_USER, RC_RUN) END IF ! END DO @@ -782,22 +766,22 @@ SUBROUTINE NEMS_RUN(NEMS_GRID_COMP & DO I = NUMBER_START, NUMBER_FINAL ! ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ - MESSAGE_CHECK="Execute the Run step of the Ensemble Coupler component" + MESSAGE_CHECK = "Execute the Run step of the Ensemble Coupler component" ! CALL ESMF_LogWrite(MESSAGE_CHECK,ESMF_LOGMSG_INFO,rc=RC) ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ! - CALL ESMF_CplCompRun(cplcomp =ENS_CPL_COMP & - ,importState=ENS_CPL_IMP_STATE & - ,exportState=ENS_CPL_EXP_STATE & - ,clock =CLOCK_NEMS & - ,phase =1 & - ,userRc =RC_USER & - ,rc =RC) - ESMF_ERR_RETURN(RC,RC_RUN) - ESMF_ERR_RETURN(RC_USER,RC_RUN) + CALL ESMF_CplCompRun(cplcomp = ENS_CPL_COMP & + ,importState = ENS_CPL_IMP_STATE & + ,exportState = ENS_CPL_EXP_STATE & + ,clock = CLOCK_NEMS & + ,phase = 1 & + ,userRc = RC_USER & + ,rc = RC) + ESMF_ERR_RETURN(RC, RC_RUN) + ESMF_ERR_RETURN(RC_USER, RC_RUN) ! CALL ESMF_VMBarrier(vm = VM_GLOBAL, rc = RC) - ESMF_ERR_RETURN(RC,RC_RUN) + ESMF_ERR_RETURN(RC, RC_RUN) ! !----------------------------------------------------------------------- !*** Adjust the ESMF clock for the next run cycle. @@ -828,19 +812,19 @@ SUBROUTINE NEMS_RUN(NEMS_GRID_COMP & CALL ESMF_TimeIntervalGet(timeInterval = RUNDURATION & ,h = HH & ,rc = RC) - ESMF_ERR_RETURN(RC,RC_RUN) + ESMF_ERR_RETURN(RC, RC_RUN) ! HH = HH + HH_INCREASE ! CALL ESMF_TimeIntervalSet(timeInterval = RUNDURATION & ,h = hh & ,rc = RC) - ESMF_ERR_RETURN(RC,RC_RUN) + ESMF_ERR_RETURN(RC, RC_RUN) ! CALL ESMF_ClockSet(clock = CLOCK_NEMS & ,runDuration = RUNDURATION & ,rc = RC) - ESMF_ERR_RETURN(RC,RC_RUN) + ESMF_ERR_RETURN(RC, RC_RUN) ! !----------------------------------------------------------------------- !*** Execute the Run step of each element in the EARTH component @@ -848,7 +832,7 @@ SUBROUTINE NEMS_RUN(NEMS_GRID_COMP & !----------------------------------------------------------------------- ! ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ - MESSAGE_CHECK="Execute the Run step of the EARTH component" + MESSAGE_CHECK = "Execute the Run step of the EARTH component" ! CALL ESMF_LogWrite(MESSAGE_CHECK,ESMF_LOGMSG_INFO,rc=RC) ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ! @@ -862,8 +846,8 @@ SUBROUTINE NEMS_RUN(NEMS_GRID_COMP & ,phase = 1 & ,userRc = RC_USER & ,rc = RC) - ESMF_ERR_RETURN(RC,RC_RUN) - ESMF_ERR_RETURN(RC_USER,RC_RUN) + ESMF_ERR_RETURN(RC, RC_RUN) + ESMF_ERR_RETURN(RC_USER, RC_RUN) END IF ! END DO @@ -878,7 +862,7 @@ SUBROUTINE NEMS_RUN(NEMS_GRID_COMP & CALL ESMF_ClockGet(clock = CLOCK_NEMS & ,runDuration = RUNDURATION & ,rc = RC) - ESMF_ERR_RETURN(RC,RC_RUN) + ESMF_ERR_RETURN(RC, RC_RUN) ! !----------------------------------------------------------------------- ! @@ -892,11 +876,8 @@ END SUBROUTINE NEMS_RUN !####################################################################### !----------------------------------------------------------------------- ! - SUBROUTINE NEMS_FINALIZE(NEMS_GRID_COMP & - ,IMP_STATE & - ,EXP_STATE & - ,CLOCK_MAIN & - ,RC_FINALIZE) + SUBROUTINE NEMS_FINALIZE(NEMS_GRID_COMP, IMP_STATE, EXP_STATE, & + CLOCK_MAIN, RC_FINALIZE) ! !----------------------------------------------------------------------- ! @@ -906,10 +887,10 @@ SUBROUTINE NEMS_FINALIZE(NEMS_GRID_COMP & ! TYPE(ESMF_GridComp) :: NEMS_GRID_COMP !<-- The NEMS component ! - TYPE(ESMF_State) :: IMP_STATE & !<-- The NEMS import state - ,EXP_STATE !<-- The NEMS export state + TYPE(ESMF_State) :: IMP_STATE & !<-- The NEMS import state + ,EXP_STATE !<-- The NEMS export state ! - TYPE(ESMF_Clock) :: CLOCK_MAIN !<-- The main Clock + TYPE(ESMF_Clock) :: CLOCK_MAIN !<-- The main Clock ! INTEGER,INTENT(OUT) :: RC_FINALIZE !<-- Error return code ! @@ -917,7 +898,7 @@ SUBROUTINE NEMS_FINALIZE(NEMS_GRID_COMP & !*** Local Variables !--------------------- ! - INTEGER :: I,RC,RC_USER + INTEGER :: I, RC, RC_USER ! !----------------------------------------------------------------------- !*********************************************************************** @@ -931,7 +912,7 @@ SUBROUTINE NEMS_FINALIZE(NEMS_GRID_COMP & !----------------------------------------------------------------------- ! ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ - MESSAGE_CHECK="Execute the Finalize step of the EARTH component" + MESSAGE_CHECK = "Execute the Finalize step of the EARTH component" ! CALL ESMF_LogWrite(MESSAGE_CHECK,ESMF_LOGMSG_INFO,rc=RC) ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ! @@ -945,8 +926,8 @@ SUBROUTINE NEMS_FINALIZE(NEMS_GRID_COMP & ,phase = 1 & ,userRc = RC_USER & ,rc = RC) - ESMF_ERR_RETURN(RC,RC_FINALIZE) - ESMF_ERR_RETURN(RC_USER,RC_FINALIZE) + ESMF_ERR_RETURN(RC, RC_FINALIZE) + ESMF_ERR_RETURN(RC_USER, RC_FINALIZE) END IF ! END DO @@ -956,19 +937,19 @@ SUBROUTINE NEMS_FINALIZE(NEMS_GRID_COMP & IF(ENS_SPS) THEN ! ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ - MESSAGE_CHECK="Execute the Finalize step of the Ensemble Coupler component" + MESSAGE_CHECK = "Execute the Finalize step of the Ensemble Coupler component" ! CALL ESMF_LogWrite(MESSAGE_CHECK,ESMF_LOGMSG_INFO,rc=RC) ! ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ! - CALL ESMF_CplCompFinalize(cplcomp =ENS_CPL_COMP & - ,importState=ENS_CPL_IMP_STATE & - ,exportState=ENS_CPL_EXP_STATE & - ,clock =CLOCK_NEMS & - ,phase =1 & - ,userRc =RC_USER & - ,rc =RC) - ESMF_ERR_RETURN(RC,RC_FINALIZE) - ESMF_ERR_RETURN(RC_USER,RC_FINALIZE) + CALL ESMF_CplCompFinalize(cplcomp = ENS_CPL_COMP & + ,importState = ENS_CPL_IMP_STATE & + ,exportState = ENS_CPL_EXP_STATE & + ,clock = CLOCK_NEMS & + ,phase = 1 & + ,userRc = RC_USER & + ,rc = RC) + ESMF_ERR_RETURN(RC, RC_FINALIZE) + ESMF_ERR_RETURN(RC_USER, RC_FINALIZE) ! END IF ! diff --git a/tests/produtil/NCEPLIBS-pyprodutil b/tests/produtil/NCEPLIBS-pyprodutil index ca171b95..962cbd5a 160000 --- a/tests/produtil/NCEPLIBS-pyprodutil +++ b/tests/produtil/NCEPLIBS-pyprodutil @@ -1 +1 @@ -Subproject commit ca171b95095db4fcd0fc7b01c23d073d90becd99 +Subproject commit 962cbd5ab44c6bccdcda21776d9e4297ce443d6d