9 use fckit_configuration_module,
only: fckit_configuration
19 use fckit_mpi_module,
only: fckit_mpi_comm, fckit_mpi_sum
22 use nuopc_comp,
only: nuopc_compsetclock
23 use nuopc_driver,
only: nuopc_drivergetcomp
24 use nuopc_model,
only: nuopc_modelget
43 type(esmf_gridcomp) :: esmcomp
55 type(c_ptr),
intent(in) :: c_conf
61 character(len=20) :: ststep
62 type(duration) :: dtstep
63 character(len=20) :: cdate_start
64 character(len=20) :: cdate_final
66 type(fckit_mpi_comm) :: f_comm
67 type(fckit_configuration) :: f_conf
68 character(len=:),
allocatable :: str
73 f_conf = fckit_configuration(c_conf)
79 call esmf_initialize(logkindflag=esmf_logkind_multi, &
80 defaultcalkind=esmf_calkind_gregorian, mpicommunicator=f_comm%communicator(), rc=rc)
81 if (esmf_logfounderror(rctocheck=rc, msg=esmf_logerr_passthru, &
84 call esmf_finalize(endflag=esmf_end_abort)
86 call esmf_logwrite(
"esm-JEDI STARTING", esmf_logmsg_info, rc=rc)
87 if (esmf_logfounderror(rctocheck=rc, msg=esmf_logerr_passthru, &
90 call esmf_finalize(endflag=esmf_end_abort)
93 self%esmComp = esmf_gridcompcreate(name=
"esm", rc=rc)
94 if (esmf_logfounderror(rctocheck=rc, msg=esmf_logerr_passthru, &
97 call esmf_finalize(endflag=esmf_end_abort)
100 call esmf_gridcompsetservices(self%esmComp, esmss, userrc=self%urc, rc=rc)
101 if (esmf_logfounderror(rctocheck=rc, msg=esmf_logerr_passthru, &
104 call esmf_finalize(endflag=esmf_end_abort)
105 if (esmf_logfounderror(rctocheck=self%urc, msg=esmf_logerr_passthru, &
108 call esmf_finalize(endflag=esmf_end_abort)
114 call f_conf%get_or_die(
"tstep",str)
117 dtstep = trim(ststep)
118 self%dt = int(duration_seconds(dtstep))
120 cdate_start =
'2018-04-14T21:00:00Z'
121 cdate_final =
'2018-04-15T03:00:00Z'
127 call esmf_gridcompinitialize(self%esmComp, userrc=self%urc, rc=rc)
128 if (esmf_logfounderror(rctocheck=rc, msg=esmf_logerr_passthru, &
131 call esmf_finalize(endflag=esmf_end_abort)
132 if (esmf_logfounderror(rctocheck=self%urc, msg=esmf_logerr_passthru, &
135 call esmf_finalize(endflag=esmf_end_abort)
149 call esmf_gridcompfinalize(self%esmComp, userrc=self%urc, rc=rc)
150 if (esmf_logfounderror(rctocheck=rc, msg=esmf_logerr_passthru, &
153 call esmf_finalize(endflag=esmf_end_abort)
154 if (esmf_logfounderror(rctocheck=self%urc, msg=esmf_logerr_passthru, &
157 call esmf_finalize(endflag=esmf_end_abort)
160 call esmf_gridcompdestroy(self%esmComp, rc=rc)
161 if (esmf_logfounderror(rctocheck=rc, msg=esmf_logerr_passthru, &
164 call esmf_finalize(endflag=esmf_end_abort)
166 call esmf_logwrite(
"esm-JEDI FINISHED", esmf_logmsg_info, rc=rc)
167 if (esmf_logfounderror(rctocheck=rc, msg=esmf_logerr_passthru, &
170 call esmf_finalize(endflag=esmf_end_abort)
173 call esmf_finalize(endflag=esmf_end_keepmpi,rc=rc)
184 type(datetime),
intent(in) :: vdate
200 type(datetime),
intent(in) :: vdate1
201 type(datetime),
intent(in) :: vdate2
204 character(len=20) :: vdatec1, vdatec2
207 call datetime_to_string(vdate1, vdatec1)
208 call datetime_to_string(vdate2, vdatec2)
217 call esmf_gridcomprun(self%esmComp, userrc=self%urc, rc=rc)
218 if (esmf_logfounderror(rctocheck=rc, msg=esmf_logerr_passthru, &
221 call esmf_finalize(endflag=esmf_end_abort)
222 if (esmf_logfounderror(rctocheck=self%urc, msg=esmf_logerr_passthru, &
225 call esmf_finalize(endflag=esmf_end_abort)
239 type(datetime),
intent(in) :: vdate
256 type(esmf_gridcomp) :: atmComp
257 type(esmf_clock) :: clock
258 type(esmf_state) :: importState, exportState
260 type (ESMF_FieldBundle) :: bundle
261 type (ESMF_Field) :: field
263 real(kind_real),
pointer :: sst(:,:), pmsl(:,:)
264 type(esmf_fieldstatus_flag) :: fieldStatus
266 integer :: LB(2), UB(2)
268 integer,
save :: init = 0
271 call nuopc_drivergetcomp(self%esmComp,
"ATM", comp=atmcomp, rc=rc)
274 call nuopc_modelget(atmcomp, modelclock=clock, importstate=importstate, rc=rc)
277 call esmf_stateget(importstate,
"sst", field, rc=rc)
278 if (esmf_logfounderror(rctocheck=rc, msg=esmf_logerr_passthru, &
281 call esmf_finalize(endflag=esmf_end_abort)
284 call esmf_fieldget(field, status=fieldstatus, rc=rc)
285 if (esmf_logfounderror(rctocheck=rc, msg=esmf_logerr_passthru, &
288 call esmf_finalize(endflag=esmf_end_abort)
290 call esmf_fieldget(field, 0, sst, computationallbound=lb, computationalubound=ub, rc=rc)
291 if (esmf_logfounderror(rctocheck=rc, msg=esmf_logerr_passthru, &
294 call esmf_finalize(endflag=esmf_end_abort)
296 print*,
"JED-DATA sst", sst(lb(1),lb(2))
298 if (
associated(sst))
nullify(sst)
299 if (
associated(pmsl))
nullify(pmsl)
312 type(esmf_gridcomp) :: atmComp
313 type(esmf_clock) :: clock
314 type(esmf_state) :: importState, exportState
318 call nuopc_drivergetcomp(self%esmComp,
"ATM", comp=atmcomp, rc=rc)
327 type(esmf_gridcomp),
intent(inout) :: driver
328 integer,
intent(in) :: dt
329 character(len=20),
intent(in) :: cdate_start
330 character(len=20),
intent(in) :: cdate_final
332 type(esmf_time) :: startTime
333 type(esmf_time) :: stopTime
334 type(esmf_timeinterval) :: timeStep
335 type(esmf_clock) :: externalClock
339 integer yy1,mm1,dd1,hh1,mn1
340 integer yy2,mm2,dd2,hh2,mn2
343 read(cdate_start(1:4),
'(i)') yy1
344 read(cdate_final(1:4),
'(i)') yy2
345 read(cdate_start(6:7),
'(i)') mm1
346 read(cdate_final(6:7),
'(i)') mm2
347 read(cdate_start(9:10),
'(i)') dd1
348 read(cdate_final(9:10),
'(i)') dd2
349 read(cdate_start(12:13),
'(i)') hh1
350 read(cdate_final(12:13),
'(i)') hh2
351 read(cdate_start(15:16),
'(i)') mn1
352 read(cdate_final(15:16),
'(i)') mn2
354 call esmf_timeintervalset(timestep, s=dt, rc=rc)
355 if (esmf_logfounderror(rctocheck=rc, msg=esmf_logerr_passthru, &
358 call esmf_finalize(endflag=esmf_end_abort)
360 call esmf_timeset(starttime, yy=yy1, mm=mm1, dd=dd1, h=hh1, m=mn1, rc=rc)
361 if (esmf_logfounderror(rctocheck=rc, msg=esmf_logerr_passthru, &
364 call esmf_finalize(endflag=esmf_end_abort)
366 call esmf_timeset(stoptime, yy=yy2, mm=mm2, dd=dd2, h=hh2, m=mn2, rc=rc)
367 if (esmf_logfounderror(rctocheck=rc, msg=esmf_logerr_passthru, &
370 call esmf_finalize(endflag=esmf_end_abort)
372 externalclock = esmf_clockcreate(name=
"Application Clock", &
373 timestep=timestep, starttime=starttime, stoptime=stoptime, rc=rc)
374 if (esmf_logfounderror(rctocheck=rc, msg=esmf_logerr_passthru, &
377 call esmf_finalize(endflag=esmf_end_abort)
379 call nuopc_compsetclock(driver, externalclock=externalclock, rc=rc)
380 if (esmf_logfounderror(rctocheck=rc, msg=esmf_logerr_passthru, &
383 call esmf_finalize(endflag=esmf_end_abort)