|
| 1 | +#define ESMF_ERR_RETURN(rc) if (ESMF_LogFoundError( \ |
| 2 | + rcToCheck=rc, \ |
| 3 | + msg=ESMF_LOGERR_PASSTHRU, \ |
| 4 | + line=__LINE__, \ |
| 5 | + file=__FILE__) \ |
| 6 | + ) return |
| 7 | + |
| 8 | +module mpas_nuopc_atm |
| 9 | + !> MPAS NUOPC Cap for Atmosphere |
| 10 | + |
| 11 | + use ESMF |
| 12 | + use NUOPC |
| 13 | + use NUOPC_Model, & |
| 14 | + modelSS => SetServices |
| 15 | + |
| 16 | + implicit none |
| 17 | + |
| 18 | + private |
| 19 | + |
| 20 | + public SetVM, SetServices |
| 21 | + |
| 22 | + !----------------------------------------------------------------------------- |
| 23 | + contains |
| 24 | + !----------------------------------------------------------------------------- |
| 25 | + |
| 26 | + subroutine SetServices(model, rc) |
| 27 | + !> Register model entry points: |
| 28 | + !> Advertise: advertise import and export fields |
| 29 | + !> Realize: realize connected fields |
| 30 | + !> SetClock: initialize model clock |
| 31 | + !> DataInitialize: initialize data in import and export states |
| 32 | + !> Advance: advance model by a single time step |
| 33 | + !> Finalize: finalize model and cleanup memory |
| 34 | + |
| 35 | + ! arguments |
| 36 | + type(ESMF_GridComp) :: model |
| 37 | + integer, intent(out) :: rc |
| 38 | + |
| 39 | + rc = ESMF_SUCCESS |
| 40 | + |
| 41 | + ! derive from NUOPC_Model |
| 42 | + call NUOPC_CompDerive(model, modelSS, rc=rc) |
| 43 | + ESMF_ERR_RETURN(rc) |
| 44 | + |
| 45 | + ! specialize model entry points |
| 46 | + call NUOPC_CompSpecialize(model, specLabel=label_Advertise, & |
| 47 | + specRoutine=Advertise, rc=rc) |
| 48 | + ESMF_ERR_RETURN(rc) |
| 49 | + call NUOPC_CompSpecialize(model, specLabel=label_RealizeProvided, & |
| 50 | + specRoutine=Realize, rc=rc) |
| 51 | + ESMF_ERR_RETURN(rc) |
| 52 | + call NUOPC_CompSpecialize(model, specLabel=label_SetClock, & |
| 53 | + specRoutine=SetClock, rc=rc) |
| 54 | + ESMF_ERR_RETURN(rc) |
| 55 | + call NUOPC_CompSpecialize(model, specLabel=label_DataInitialize, & |
| 56 | + specRoutine=DataInitialize, rc=rc) |
| 57 | + ESMF_ERR_RETURN(rc) |
| 58 | + call NUOPC_CompSpecialize(model, specLabel=label_Advance, & |
| 59 | + specRoutine=Advance, rc=rc) |
| 60 | + ESMF_ERR_RETURN(rc) |
| 61 | + call NUOPC_CompSpecialize(model, specLabel=label_Finalize, & |
| 62 | + specRoutine=Finalize, rc=rc) |
| 63 | + ESMF_ERR_RETURN(rc) |
| 64 | + |
| 65 | + end subroutine SetServices |
| 66 | + |
| 67 | + !----------------------------------------------------------------------------- |
| 68 | + |
| 69 | + subroutine Advertise(model, rc) |
| 70 | + !> Advertise available export fields and desired import fields |
| 71 | + |
| 72 | + ! arguments |
| 73 | + type(ESMF_GridComp) :: model |
| 74 | + integer, intent(out) :: rc |
| 75 | + |
| 76 | + ! local variables |
| 77 | + type(ESMF_State) :: importState, exportState |
| 78 | + |
| 79 | + rc = ESMF_SUCCESS |
| 80 | + |
| 81 | + call NUOPC_ModelGet(model, importState=importState, & |
| 82 | + exportState=exportState, rc=rc) |
| 83 | + ESMF_ERR_RETURN(rc) |
| 84 | + |
| 85 | + call ESMF_LogWrite(logmsgFlag=ESMF_LOGMSG_ERROR, & |
| 86 | + msg="MPAS NUOPC ATM - Advertise has not been implemented", & |
| 87 | + line=__LINE__, & |
| 88 | + file=__FILE__) |
| 89 | + |
| 90 | + end subroutine Advertise |
| 91 | + |
| 92 | + !----------------------------------------------------------------------------- |
| 93 | + |
| 94 | + subroutine Realize(model, rc) |
| 95 | + !> Check field connections and realize connected fields |
| 96 | + |
| 97 | + ! arguments |
| 98 | + type(ESMF_GridComp) :: model |
| 99 | + integer, intent(out) :: rc |
| 100 | + |
| 101 | + ! local variables |
| 102 | + type(ESMF_State) :: importState, exportState |
| 103 | + |
| 104 | + rc = ESMF_SUCCESS |
| 105 | + |
| 106 | + call NUOPC_ModelGet(model, importState=importState, & |
| 107 | + exportState=exportState, rc=rc) |
| 108 | + ESMF_ERR_RETURN(rc) |
| 109 | + |
| 110 | + call ESMF_LogWrite(logmsgFlag=ESMF_LOGMSG_ERROR, & |
| 111 | + msg="MPAS NUOPC ATM - Realize has not been implemented", & |
| 112 | + line=__LINE__, & |
| 113 | + file=__FILE__) |
| 114 | + |
| 115 | + end subroutine Realize |
| 116 | + |
| 117 | + !----------------------------------------------------------------------------- |
| 118 | + |
| 119 | + subroutine SetClock(model, rc) |
| 120 | + !> Adjust model clock and time step during initialization |
| 121 | + |
| 122 | + ! arguments |
| 123 | + type(ESMF_GridComp) :: model |
| 124 | + integer, intent(out) :: rc |
| 125 | + |
| 126 | + ! local variables |
| 127 | + type(ESMF_Clock) :: clock |
| 128 | + type(ESMF_State) :: importState, exportState |
| 129 | + |
| 130 | + rc = ESMF_SUCCESS |
| 131 | + |
| 132 | + call NUOPC_ModelGet(model, modelClock=clock, & |
| 133 | + importState=importState, & |
| 134 | + exportState=exportState, rc=rc) |
| 135 | + ESMF_ERR_RETURN(rc) |
| 136 | + |
| 137 | + call ESMF_LogWrite(logmsgFlag=ESMF_LOGMSG_ERROR, & |
| 138 | + msg="MPAS NUOPC ATM - SetClock has not been implemented", & |
| 139 | + line=__LINE__, & |
| 140 | + file=__FILE__) |
| 141 | + |
| 142 | + end subroutine SetClock |
| 143 | + |
| 144 | + !----------------------------------------------------------------------------- |
| 145 | + |
| 146 | + subroutine DataInitialize(model, rc) |
| 147 | + !> Initialize data in import and export states |
| 148 | + |
| 149 | + ! arguments |
| 150 | + type(ESMF_GridComp) :: model |
| 151 | + integer, intent(out) :: rc |
| 152 | + |
| 153 | + ! local variables |
| 154 | + type(ESMF_Clock) :: clock |
| 155 | + type(ESMF_State) :: importState, exportState |
| 156 | + |
| 157 | + rc = ESMF_SUCCESS |
| 158 | + |
| 159 | + call NUOPC_ModelGet(model, modelClock=clock, & |
| 160 | + importState=importState, & |
| 161 | + exportState=exportState, rc=rc) |
| 162 | + ESMF_ERR_RETURN(rc) |
| 163 | + |
| 164 | + call NUOPC_CompAttributeSet(model, & |
| 165 | + name="InitializeDataComplete", value="true", rc=rc) |
| 166 | + ESMF_ERR_RETURN(rc) |
| 167 | + |
| 168 | + call ESMF_LogWrite(logmsgFlag=ESMF_LOGMSG_ERROR, & |
| 169 | + msg="MPAS NUOPC ATM - DataInitialize has not been implemented", & |
| 170 | + line=__LINE__, & |
| 171 | + file=__FILE__) |
| 172 | + |
| 173 | + end subroutine DataInitialize |
| 174 | + |
| 175 | + !----------------------------------------------------------------------------- |
| 176 | + |
| 177 | + subroutine Advance(model, rc) |
| 178 | + !> Advance model by a single time step |
| 179 | + |
| 180 | + ! arguments |
| 181 | + type(ESMF_GridComp) :: model |
| 182 | + integer, intent(out) :: rc |
| 183 | + |
| 184 | + ! local variables |
| 185 | + type(ESMF_Clock) :: clock |
| 186 | + type(ESMF_State) :: importState, exportState |
| 187 | + |
| 188 | + rc = ESMF_SUCCESS |
| 189 | + |
| 190 | + call NUOPC_ModelGet(model, modelClock=clock, & |
| 191 | + importState=importState, & |
| 192 | + exportState=exportState, rc=rc) |
| 193 | + ESMF_ERR_RETURN(rc) |
| 194 | + |
| 195 | + call ESMF_LogWrite(logmsgFlag=ESMF_LOGMSG_ERROR, & |
| 196 | + msg="MPAS NUOPC ATM - Advance has not been implemented", & |
| 197 | + line=__LINE__, & |
| 198 | + file=__FILE__) |
| 199 | + |
| 200 | + end subroutine Advance |
| 201 | + |
| 202 | + !----------------------------------------------------------------------------- |
| 203 | + |
| 204 | + subroutine Finalize(model, rc) |
| 205 | + !> Finalize model and cleanup memory allocations |
| 206 | + |
| 207 | + ! arguments |
| 208 | + type(ESMF_GridComp) :: model |
| 209 | + integer, intent(out) :: rc |
| 210 | + |
| 211 | + ! local variables |
| 212 | + type(ESMF_State) :: importState, exportState |
| 213 | + |
| 214 | + rc = ESMF_SUCCESS |
| 215 | + |
| 216 | + call NUOPC_ModelGet(model, importState=importState, & |
| 217 | + exportState=exportState, rc=rc) |
| 218 | + ESMF_ERR_RETURN(rc) |
| 219 | + |
| 220 | + call ESMF_LogWrite(logmsgFlag=ESMF_LOGMSG_ERROR, & |
| 221 | + msg="MPAS NUOPC ATM - Finalize has not been implemented", & |
| 222 | + line=__LINE__, & |
| 223 | + file=__FILE__) |
| 224 | + |
| 225 | + end subroutine Finalize |
| 226 | + |
| 227 | + !----------------------------------------------------------------------------- |
| 228 | + |
| 229 | +end module mpas_nuopc_atm |
0 commit comments