modelIntegration.F90 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880
  1. !
  2. #define TRACEBACK write (gol,'("in ",a," (",a,", line",i5,")")') rname, __FILE__, __LINE__; call goErr
  3. #define IF_NOTOK_RETURN(action) if (status/=0) then; TRACEBACK; action; return; end if
  4. #define IF_ERROR_RETURN(action) if (status> 0) then; TRACEBACK; action; return; end if
  5. !
  6. #include "tm5.inc"
  7. !
  8. !-----------------------------------------------------------------------------
  9. ! TM5 !
  10. !-----------------------------------------------------------------------------
  11. !BOP
  12. !
  13. ! !MODULE: MODELINTEGRATION
  14. !
  15. ! !DESCRIPTION: handles time ordering of model processes
  16. !\\
  17. !\\
  18. ! !INTERFACE:
  19. !
  20. MODULE MODELINTEGRATION
  21. !
  22. ! !USES:
  23. !
  24. use GO, only : gol, goPr, goErr, goLabel
  25. IMPLICIT NONE
  26. PRIVATE
  27. !
  28. ! !PUBLIC MEMBER FUNCTIONS:
  29. !
  30. public :: Proces_Init, Proces_Done, Proces_Update
  31. public :: Proces_Region
  32. !
  33. ! !PRIVATE DATA MEMBERS:
  34. !
  35. character(len=1) :: output_after_step
  36. character(len=*), parameter :: mname = 'ModelIntegration' ! module name
  37. !
  38. ! timer handles
  39. integer :: itim_advectx, itim_advecty, itim_advectz
  40. integer :: itim_vertical, itim_chemistry, itim_source_sink
  41. !
  42. !
  43. ! !REMARKS:
  44. !
  45. !EOP
  46. !------------------------------------------------------------------------
  47. CONTAINS
  48. !--------------------------------------------------------------------------
  49. ! TM5 !
  50. !--------------------------------------------------------------------------
  51. !BOP
  52. !
  53. ! !IROUTINE: PROCES_INIT
  54. !
  55. ! !DESCRIPTION:
  56. !\\
  57. !\\
  58. ! !INTERFACE:
  59. !
  60. SUBROUTINE PROCES_INIT( status )
  61. !
  62. ! !USES:
  63. !
  64. use GO, only : GO_Timer_Def
  65. use GO, only : TrcFile, Init, Done, ReadRc
  66. use user_output, only : User_output_Init
  67. use Binas, only : p_global
  68. use dims, only : nregions, nregions_all, iglbsfc
  69. use global_data, only : rcfile
  70. use Meteodata, only : sp_dat, phlb_dat, m_dat
  71. use Meteodata, only : sp1_dat, sp2_dat, tsp_dat, spm_dat
  72. use Meteodata, only : mfu_dat, mfv_dat, mfw_dat
  73. use Meteodata, only : temper_dat, humid_dat
  74. use Meteodata, only : entu_dat, entd_dat, detu_dat, detd_dat
  75. use Meteodata, only : lwc_dat, iwc_dat, cc_dat, cco_dat, ccu_dat
  76. use Meteodata, only : gph_dat, omega_dat
  77. use Meteodata, only : oro_dat, lsmask_dat
  78. use Meteodata, only : Set
  79. use Meteo, only : Meteo_Alloc
  80. #ifndef without_advection
  81. use Advect, only : Advect_Init
  82. #endif
  83. #ifndef without_convection
  84. use Convection, only : Convection_Init
  85. #ifndef without_diffusion
  86. use Diffusion, only : Diffusion_Init
  87. #endif
  88. #endif
  89. #ifndef without_chemistry
  90. use Chemistry, only : Chemistry_Init
  91. #endif
  92. use Sources_Sinks, only : Sources_Sinks_Init
  93. #ifndef without_dry_deposition
  94. use Dry_Deposition, only : Dry_Deposition_Init
  95. #endif
  96. #ifndef without_wet_deposition
  97. use Wet_Deposition, only : Wet_Deposition_Init
  98. #endif
  99. !
  100. ! !OUTPUT PARAMETERS:
  101. !
  102. integer, intent(out) :: status
  103. !
  104. ! !REMARKS:
  105. !
  106. !EOP
  107. !------------------------------------------------------------------------
  108. !BOC
  109. character(len=*), parameter :: rname = mname//'/Proces_Init'
  110. type(TrcFile) :: rcF
  111. integer :: n
  112. ! --- BEGIN ---------------------------------
  113. call goLabel(rname)
  114. !
  115. ! (1) meteo always used
  116. !
  117. do n = 1, nregions
  118. ! current (surface) pressure and mass:
  119. call Set( sp_dat(n), status, used=.true. )
  120. call Set( m_dat(n), status, used=.true. )
  121. call Set( phlb_dat(n), status, used=.true. )
  122. ! surface pressures, tendency, and average (mid)
  123. call Set( sp1_dat(n), status, used=.true. )
  124. call Set( sp2_dat(n), status, used=.true. )
  125. call Set( tsp_dat(n), status, used=.true. )
  126. call Set( spm_dat(n), status, used=.true. )
  127. end do
  128. !
  129. ! (2) Init processes (these inits should select the appropriate meteo to use)
  130. !
  131. #ifndef without_advection
  132. call Advect_Init( status )
  133. IF_NOTOK_RETURN(status=1)
  134. #endif
  135. #ifndef without_convection
  136. call Convection_Init( status )
  137. IF_NOTOK_RETURN(status=1)
  138. #ifndef without_diffusion
  139. call Diffusion_Init( status )
  140. IF_NOTOK_RETURN(status=1)
  141. #endif
  142. #endif
  143. #ifndef without_chemistry
  144. call Chemistry_Init( status )
  145. IF_NOTOK_RETURN(status=1)
  146. #endif
  147. call Sources_Sinks_Init( status )
  148. IF_NOTOK_RETURN(status=1)
  149. #ifndef without_dry_deposition
  150. call Dry_Deposition_Init( status )
  151. IF_NOTOK_RETURN(status=1)
  152. #endif
  153. #ifndef without_wet_deposition
  154. call Wet_Deposition_Init( status )
  155. IF_NOTOK_RETURN(status=1)
  156. #endif
  157. call user_output_init( status )
  158. IF_NOTOK_RETURN(status=1)
  159. !
  160. ! (3) Check for (and set-to-use) required meteo
  161. !
  162. do n = 1, nregions_all
  163. ! convec requires gph and omega:
  164. if ( entu_dat(n)%used ) then
  165. call Set( gph_dat(n), status, used=.true. )
  166. call Set( omega_dat(n), status, used=.true. )
  167. end if
  168. ! omega (Pa/s) is computed form mfw (kg/s):
  169. if ( omega_dat(n)%used ) then
  170. call Set( mfw_dat(n), status, used=.true. )
  171. end if
  172. ! gph is computed from oro/sp/temper/humid
  173. if ( gph_dat(n)%used ) then
  174. call Set( oro_dat(n), status, used=.true. )
  175. call Set( sp_dat(n), status, used=.true. )
  176. call Set( temper_dat(n), status, used=.true. )
  177. call Set( humid_dat(n), status, used=.true. )
  178. end if
  179. ! sp is interpolated in time between sp1 and sp2:
  180. if ( sp_dat(n)%used ) then
  181. call Set( sp1_dat(n), status, used=.true. )
  182. call Set( sp2_dat(n), status, used=.true. )
  183. end if
  184. ! cloud covers and overhead/underfeet cloud covers
  185. if ( cc_dat(n)%used ) then
  186. call Set( cco_dat(n), status, used=.true. )
  187. call Set( ccu_dat(n), status, used=.true. )
  188. end if
  189. end do
  190. ! !>>> Please use obscure meteo fields only if you really need them ...
  191. ! ! If too many fields are used by default, even a simple meteo production run
  192. ! ! of an extra surface field will request fields that are not used anyway ...
  193. ! !
  194. ! write (gol,'("WARNING - ")'); call goPr
  195. ! write (gol,'("WARNING - global orography not in use by default anymore;")'); call goPr
  196. ! write (gol,'("WARNING - see the comment in ",a)') rname; call goPr
  197. ! write (gol,'("WARNING - ")'); call goPr
  198. ! !
  199. ! ! always store also the orography on 1x1: not here - set it in process init that really need it
  200. ! ! call Set( oro_dat(iglbsfc), status, used=.true. )
  201. ! !
  202. ! !<<<
  203. !
  204. ! (4) Allocate used meteo
  205. !
  206. call Meteo_Alloc( status )
  207. IF_NOTOK_RETURN(status=1)
  208. !
  209. ! (5) default values for surface pressure (might be required for mass fields used in init routines)
  210. !
  211. do n = 1, nregions_all
  212. if ( sp_dat(n)%used ) sp_dat(n)%data = p_global
  213. if ( spm_dat(n)%used ) spm_dat(n)%data = p_global
  214. end do
  215. !
  216. ! (6) When do we sample/accumulate output?
  217. !
  218. ! - x,y,z,c,v,e : always after this process
  219. ! - a : after all steps (testing, not recommended)
  220. ! - d : the 'old' way (after all, outside do_steps)
  221. ! - Recommended value: 'v' (default)
  222. !
  223. call Init( rcF, rcfile, status )
  224. IF_NOTOK_RETURN(status=1)
  225. call ReadRc( rcF, 'output.after.step', output_after_step, status, default = 'v' )
  226. IF_ERROR_RETURN(status=1)
  227. if (output_after_step == 'd') then
  228. write(gol, *) ' **********************************************' ; call goPr
  229. write(gol, *) ' Output will be collected in the OLD way' ; call goPr
  230. write(gol, *) ' consider to include e.g. output.after.step : v' ; call goPr
  231. write(gol, *) ' **********************************************' ; call goPr
  232. else
  233. write(gol, *) ' ****************************************' ; call goPr
  234. write(gol, *) ' Output will be collected after step : ',output_after_step ; call goPr
  235. write(gol, *) ' ****************************************' ; call goPr
  236. endif
  237. call Done( rcF, status )
  238. IF_NOTOK_RETURN(status=1)
  239. !
  240. ! (7) timing
  241. !
  242. call GO_Timer_Def( itim_advectx , 'advectx' , status )
  243. IF_NOTOK_RETURN(status=1)
  244. call GO_Timer_Def( itim_advecty , 'advecty' , status )
  245. IF_NOTOK_RETURN(status=1)
  246. call GO_Timer_Def( itim_advectz , 'advectz' , status )
  247. IF_NOTOK_RETURN(status=1)
  248. call GO_Timer_Def( itim_vertical , 'vertical' , status )
  249. IF_NOTOK_RETURN(status=1)
  250. call GO_Timer_Def( itim_chemistry , 'chemistry' , status )
  251. IF_NOTOK_RETURN(status=1)
  252. call GO_Timer_Def( itim_source_sink, 'source_sink' , status )
  253. IF_NOTOK_RETURN(status=1)
  254. !
  255. ! (8) done
  256. !
  257. call goLabel()
  258. status = 0
  259. END SUBROUTINE PROCES_INIT
  260. !EOC
  261. !--------------------------------------------------------------------------
  262. ! TM5 !
  263. !--------------------------------------------------------------------------
  264. !BOP
  265. !
  266. ! !IROUTINE: PROCES_DONE
  267. !
  268. ! !DESCRIPTION:
  269. !\\
  270. !\\
  271. ! !INTERFACE:
  272. !
  273. SUBROUTINE PROCES_DONE( status )
  274. !
  275. ! !USES:
  276. !
  277. #ifndef without_chemistry
  278. use Chemistry , only : Chemistry_Done
  279. #endif
  280. #ifndef without_advection
  281. use Advect , only : Advect_Done
  282. #endif
  283. #ifndef without_convection
  284. use Convection , only : Convection_Done
  285. #ifndef without_diffusion
  286. use Diffusion , only : Diffusion_Done
  287. #endif
  288. #endif
  289. use Sources_Sinks , only : Sources_Sinks_Done
  290. #ifndef without_dry_deposition
  291. use Dry_Deposition, only : Dry_Deposition_Done
  292. #endif
  293. #ifndef without_wet_deposition
  294. use Wet_Deposition, only : Wet_Deposition_Done
  295. #endif
  296. !
  297. ! !OUTPUT PARAMETERS:
  298. !
  299. integer, intent(out) :: status
  300. !
  301. ! !REMARKS:
  302. !
  303. !EOP
  304. !------------------------------------------------------------------------
  305. !BOC
  306. character(len=*), parameter :: rname = mname//'/Proces_Done'
  307. ! --- BEGIN ---------------------------------
  308. #ifndef without_advection
  309. call Advect_Done( status )
  310. IF_NOTOK_RETURN(status=1)
  311. #endif
  312. #ifndef without_convection
  313. call Convection_Done( status )
  314. IF_NOTOK_RETURN(status=1)
  315. #ifndef without_diffusion
  316. call Diffusion_Done( status )
  317. IF_NOTOK_RETURN(status=1)
  318. #endif
  319. #endif
  320. #ifndef without_chemistry
  321. call Chemistry_Done( status )
  322. IF_NOTOK_RETURN(status=1)
  323. #endif
  324. call Sources_Sinks_Done( status )
  325. IF_NOTOK_RETURN(status=1)
  326. #ifndef without_dry_deposition
  327. call Dry_Deposition_Done( status )
  328. IF_NOTOK_RETURN(status=1)
  329. #endif
  330. #ifndef without_wet_deposition
  331. call Wet_Deposition_Done( status )
  332. IF_NOTOK_RETURN(status=1)
  333. #endif
  334. status = 0
  335. END SUBROUTINE PROCES_DONE
  336. !EOC
  337. !--------------------------------------------------------------------------
  338. ! TM5 !
  339. !--------------------------------------------------------------------------
  340. !BOP
  341. !
  342. ! !IROUTINE: PROCES_UPDATE
  343. !
  344. ! !DESCRIPTION: update process fields, for example because meteo has been changed
  345. !\\
  346. !\\
  347. ! !INTERFACE:
  348. !
  349. SUBROUTINE PROCES_UPDATE( status )
  350. !
  351. ! !USES:
  352. !
  353. use dims , only : nregions
  354. #ifndef without_diffusion
  355. use Diffusion , only : Calc_Kzz, diffusion_write, read_diffusion, write_diffusion
  356. #endif
  357. use sources_sinks , only : ss_after_read_meteo_update
  358. #ifndef without_dry_deposition
  359. use dry_deposition, only : dd_surface_fields
  360. #endif
  361. #ifndef without_wet_deposition
  362. use wet_deposition, only : calculate_lsp_scav
  363. #endif
  364. !
  365. ! !OUTPUT PARAMETERS:
  366. !
  367. integer, intent(out) :: status
  368. !
  369. ! !REMARKS:
  370. !
  371. !EOP
  372. !------------------------------------------------------------------------
  373. !BOC
  374. character(len=*), parameter :: rname = mname//'/Proces_Update'
  375. integer :: region
  376. ! --- BEGIN ---------------------------------
  377. #ifndef without_diffusion
  378. ! Read or recalculate diffusion coefficients if necessary
  379. ! If diffusion_write, then read existing DKG file or
  380. ! write it if it does not already exist.
  381. if (diffusion_write) then
  382. call read_diffusion( status )
  383. IF_ERROR_RETURN(status=1) ! if error reading
  384. ! else if dkg file could not be found --> calculate and write
  385. if (status < 0) then
  386. call Calc_Kzz(status)
  387. IF_NOTOK_RETURN(status=1)
  388. call write_diffusion( status )
  389. IF_NOTOK_RETURN(status=1)
  390. end if
  391. else
  392. call Calc_Kzz(status)
  393. IF_NOTOK_RETURN(status=1)
  394. end if
  395. #endif
  396. #ifndef without_dry_deposition
  397. ! calculate the dry_deposition fields from stuff in fsurf file (will coarsen...)
  398. call dd_surface_fields( status )
  399. IF_NOTOK_RETURN(status=1)
  400. #endif
  401. #ifndef without_wet_deposition
  402. ! pre-calculate the lsp scavenging rloss1, rloss2, rloss3
  403. do region = 1, nregions
  404. call calculate_lsp_scav(region)
  405. end do
  406. #endif
  407. ! update sources and sinks that depends on meteo
  408. call ss_after_read_meteo_update( status )
  409. IF_NOTOK_RETURN(status=1)
  410. ! ok
  411. status = 0
  412. END SUBROUTINE PROCES_UPDATE
  413. !EOC
  414. !--------------------------------------------------------------------------
  415. ! TM5 !
  416. !--------------------------------------------------------------------------
  417. !BOP
  418. !
  419. ! !IROUTINE: PROCES_REGION
  420. !
  421. ! !DESCRIPTION: for a given region, performs tref(region)/tref(parent(region)) steps.
  422. !
  423. !
  424. !example (cmk)
  425. ! XYZ ECCEZYX
  426. ! xyz eccezyx cezyx xyz ec
  427. ! xyzeccezyx ecxyzzyxec cezyxxyzec zyxeccexyz
  428. ! in this case the operations e and c should be executed in the
  429. ! interface region
  430. ! but not in the core of the zoom region (otherwise double counting)
  431. ! This results in the most simple algorithm, because you should leave
  432. ! the DO_STEPS routine AFTER
  433. ! (1) finishing all the steps...
  434. ! (2) XYZ
  435. !
  436. !\\
  437. !\\
  438. ! !INTERFACE:
  439. !
  440. SUBROUTINE PROCES_REGION( region, tr, status )
  441. !
  442. ! !USES:
  443. !
  444. use GO, only : TDate, NewDate
  445. use dims, only : tref, revert, ndyn, itaur, parent
  446. use dims, only : statusr => status
  447. use dims, only : n_operators
  448. use datetime, only : tau2date
  449. use user_output, only : user_output_step
  450. use advect_tools, only : m2phlb1
  451. !
  452. ! !INPUT PARAMETERS:
  453. !
  454. integer, intent(in) :: region
  455. type(TDate) :: tr(2)
  456. !
  457. ! !OUTPUT PARAMETERS:
  458. !
  459. integer, intent(out) :: status
  460. !
  461. ! !REMARKS:
  462. !
  463. !EOP
  464. !------------------------------------------------------------------------
  465. !BOC
  466. character(len=*), parameter :: rname = mname//'/proces_region'
  467. integer :: i, tref_, dtime
  468. integer :: time6(6)
  469. type(TDate) :: tri(2)
  470. ! --- BEGIN ----------------------------------
  471. ! determine refinement factor with respect to the parent
  472. tref_ = tref(region)/tref(parent(region))
  473. ! main time step for all processes. note that all timesteps are default/2
  474. dtime = revert*ndyn/(2*tref(region))
  475. do i = 1, tref_
  476. ! time step: itaur(region)+[0,dtime]
  477. call tau2date( itaur(region), time6 )
  478. tri(1) = NewDate( time6=time6 )
  479. call tau2date( itaur(region)+dtime, time6 )
  480. tri(2) = NewDate( time6=time6 )
  481. call do_steps( region, tri, status )
  482. IF_NOTOK_RETURN(status=1)
  483. ! do the remaining steps if necessary
  484. if ( mod(statusr(region),n_operators) /= 0 ) then
  485. call do_steps( region, tri, status )
  486. IF_NOTOK_RETURN(status=1)
  487. end if
  488. ! update region time.....
  489. itaur(region) = itaur(region) + dtime
  490. ! Accumulate or Sample various output (note: used to be the default output_after_step)
  491. if (output_after_step == 'd') then
  492. call user_output_step( region, status )
  493. IF_NOTOK_RETURN(status=1)
  494. endif
  495. end do
  496. ! compute pressure grid from (changed) air mass:
  497. call m2phlb1
  498. ! ok
  499. status = 0
  500. END SUBROUTINE PROCES_REGION
  501. !EOC
  502. !--------------------------------------------------------------------------
  503. ! TM5 !
  504. !--------------------------------------------------------------------------
  505. !BOP
  506. !
  507. ! !IROUTINE: DO_STEPS
  508. !
  509. ! !DESCRIPTION:
  510. !\\
  511. !\\
  512. ! !INTERFACE:
  513. !
  514. SUBROUTINE DO_STEPS( region, tr, status )
  515. !
  516. ! !USES:
  517. !
  518. use GO, only : TDate
  519. use GO, only : GO_Timer_Start, GO_Timer_End
  520. use dims, only : statusr => status
  521. use dims, only : okdebug, splitorderzoom, n_operators
  522. #ifndef without_chemistry
  523. use chemistry, only : chemie
  524. #endif
  525. use sources_sinks, only : sources_sinks_apply
  526. #ifdef with_budgets
  527. use budget_global, only : budget_transportg
  528. #endif
  529. use chem_param, only : names, ntracet
  530. #ifndef without_convection
  531. use convection, only : convec
  532. #endif
  533. #ifndef without_advection
  534. use advectx, only : advectxzoom
  535. use advecty, only : advectyzoom
  536. use advectz, only : dynamw
  537. #endif
  538. #ifndef without_wet_deposition
  539. use wet_deposition, only : lspscav
  540. #endif
  541. use user_output, only : user_output_step
  542. !DBG ! DEBUG STATEMENT
  543. !DBG use ParTools, only : isRoot
  544. !DBG use tracer_data, only : Par_Check_mass, tracer_print ! debug
  545. !DBG ! use restart, only : Restart_Write ! debug
  546. !
  547. ! !INPUT PARAMETERS:
  548. !
  549. integer, intent(in) :: region
  550. type(TDate) :: tr(2)
  551. !
  552. ! !OUTPUT PARAMETERS:
  553. !
  554. integer, intent(out) :: status
  555. !
  556. ! !REMARKS:
  557. !
  558. !EOP
  559. !------------------------------------------------------------------------
  560. !BOC
  561. character(len=*), parameter :: rname = mname//'/do_steps'
  562. integer :: i123, reg, rgi
  563. character :: tobedone
  564. character(len=1) :: next_step, prev_step !cmk
  565. integer :: start_x, stop_x, start_y, stop_y, n !CMKTEMP
  566. ! --- BEGIN -----------------------------------
  567. !example (cmk)
  568. ! XYZ EC CEX
  569. ! xyzeccezyx cexyzzyxec
  570. ! in this case the operations e and c should be executed in
  571. ! the interface region but not in the core of the zoom region
  572. ! (otherwise double counting)
  573. ! This results in the most simple algorithm, because you should leave
  574. ! the DO_STEPS routine AFTER a Z OR after finishing all steps...
  575. ! note that the parent is responsible for the interface with the children
  576. ! this means that the interface may not be 'update' in case of (e.g.)
  577. ! xyz a
  578. ! xyzaazyx
  579. ! in this case, the edges of the child are not updated with the proces a.
  580. ! this has consequences for the mmix and save output....
  581. ! THE INTERFACE IS PART OF THE PARENT, NOT THE CHILD.....
  582. do i123=1,n_operators
  583. next_step = splitorderzoom(region,statusr(region)+1)
  584. if ( statusr(region) /= 0 ) then
  585. prev_step = splitorderzoom(region,statusr(region))
  586. else
  587. prev_step = ' '
  588. end if
  589. !DBG ! DEBUG STATEMENT
  590. !DBG if ( okdebug ) then
  591. !DBG if (isRoot) then
  592. !DBG ! print current step with capital letter (X,Y or Z)
  593. !DBG do reg=1,region
  594. !DBG tobedone = ' '
  595. !DBG if ( reg == region ) tobedone = upper(next_step)
  596. !DBG write(gol,*) ' do_steps: ',reg,': ', splitorderzoom(reg,1:statusr(reg)),tobedone
  597. !DBG call goPr
  598. !DBG end do
  599. !DBG end if
  600. !DBG
  601. !DBG call tracer_print(region, "do_steps befor "//next_step, status)
  602. !DBG IF_NOTOK_RETURN(status=1)
  603. !DBG call Par_Check_mass(region, "bef_"//next_step, debug=.true.)
  604. !DBG end if
  605. SELECT CASE(next_step)
  606. CASE ( 'v' )
  607. call GO_Timer_Start( itim_vertical, status )
  608. IF_NOTOK_RETURN(status=1)
  609. #ifndef without_convection
  610. #ifdef with_budgets
  611. call budget_transportg(region,0,'conv',prev_step)
  612. #endif
  613. call convec(region, status )
  614. IF_NOTOK_RETURN(status=1)
  615. #ifdef with_budgets
  616. call budget_transportg(region,1,'conv',prev_step)
  617. #endif
  618. #endif
  619. call GO_Timer_End( itim_vertical, status )
  620. IF_NOTOK_RETURN(status=1)
  621. CASE ( 'c' )
  622. call GO_Timer_Start( itim_chemistry, status )
  623. IF_NOTOK_RETURN(status=1)
  624. #ifndef without_chemistry
  625. CALL CHEMIE( region, tr, status )
  626. IF_NOTOK_RETURN(status=1)
  627. #endif
  628. call GO_Timer_End( itim_chemistry, status )
  629. IF_NOTOK_RETURN(status=1)
  630. CASE( 's' )
  631. call GO_Timer_Start( itim_source_sink, status )
  632. IF_NOTOK_RETURN(status=1)
  633. call sources_sinks_apply( region, tr, status )
  634. IF_NOTOK_RETURN(status=1)
  635. #ifndef without_wet_deposition
  636. ! wet removal by lsp (dry deposition is applied in chemistry)
  637. call lspscav( region )
  638. #endif
  639. call GO_Timer_End( itim_source_sink, status )
  640. IF_NOTOK_RETURN(status=1)
  641. CASE( 'x' )
  642. call GO_Timer_Start( itim_advectx, status )
  643. IF_NOTOK_RETURN(status=1)
  644. #ifndef without_advection
  645. #ifdef with_budgets
  646. call budget_transportg(region,0,'advx',prev_step)
  647. #endif
  648. CALL ADVECTXZOOM(region, status)
  649. IF_NOTOK_RETURN(status=1)
  650. #ifdef with_budgets
  651. call budget_transportg(region,1,'advx',prev_step)
  652. #endif
  653. #endif /* ADVECTX*/
  654. call GO_Timer_End( itim_advectx, status )
  655. IF_NOTOK_RETURN(status=1)
  656. CASE( 'y' )
  657. call GO_Timer_Start( itim_advecty, status )
  658. IF_NOTOK_RETURN(status=1)
  659. #ifndef without_advection
  660. #ifdef with_budgets
  661. call budget_transportg(region,0,'advy',prev_step)
  662. #endif
  663. CALL ADVECTYZOOM(region)
  664. #ifdef with_budgets
  665. call budget_transportg(region,1,'advy',prev_step)
  666. #endif
  667. #endif
  668. call GO_Timer_End( itim_advecty, status )
  669. IF_NOTOK_RETURN(status=1)
  670. CASE( 'z' )
  671. call GO_Timer_Start( itim_advectz, status )
  672. IF_NOTOK_RETURN(status=1)
  673. #ifndef without_advection
  674. #ifdef with_budgets
  675. call budget_transportg(region,0,'advz',prev_step)
  676. #endif
  677. CALL DYNAMW
  678. #ifdef with_budgets
  679. call budget_transportg(region,1,'advz',prev_step)
  680. #endif
  681. #endif
  682. call GO_Timer_End( itim_advectz, status )
  683. IF_NOTOK_RETURN(status=1)
  684. CASE default
  685. write(gol,*)'do_steps: strange value in splitorderzoom: ', next_step ; call goErr
  686. write(gol,*)'do_steps: (must be c, e, v, x, y or z)' ; call goErr
  687. TRACEBACK
  688. status=1; return
  689. END SELECT
  690. !DBG ! DEBUG STATEMENT
  691. !DBG if (okdebug) then
  692. !DBG call tracer_print(region, "do_steps after "//next_step, status)
  693. !DBG IF_NOTOK_RETURN(status=1)
  694. !DBG call Par_Check_mass(region, "aft_"//next_step, debug=.true.)
  695. !DBG ! call Restart_Write( status, key="aft_"//next_step )
  696. !DBG ! IF_NOTOK_RETURN(status=1)
  697. !DBG end if
  698. statusr(region) = statusr(region)+1
  699. ! e.g. xyzvec...........cevzyx
  700. ! exit after xyz or vec of cevzyx....
  701. if ( mod(statusr(region),n_operators) == 0 ) then
  702. exit
  703. end if
  704. ! flexible sample scheme ('a' means after all steps), d = old 'default',
  705. ! output_after_step = v,c,e,x,y,z,d,a
  706. if ((output_after_step == next_step) .or. (output_after_step == 'a')) then
  707. call user_output_step( region, status )
  708. IF_NOTOK_RETURN(status=1)
  709. endif
  710. !exit after 'yz' sequence to proces xyz children
  711. if ( next_step == 'z' ) then
  712. prev_step = splitorderzoom(region,statusr(region)-1)
  713. if ( prev_step == 'y' ) exit
  714. end if
  715. end do
  716. ! ok
  717. status = 0
  718. END SUBROUTINE DO_STEPS
  719. !EOC
  720. !--------------------------------------------------------------------------
  721. ! TM5 !
  722. !--------------------------------------------------------------------------
  723. !BOP
  724. !
  725. ! !FUNCTION: UPPER
  726. !
  727. ! !DESCRIPTION:
  728. !\\
  729. !\\
  730. ! !INTERFACE:
  731. !
  732. CHARACTER FUNCTION UPPER(xyz)
  733. !
  734. ! !INPUT PARAMETERS:
  735. !
  736. character(1),intent(in) :: xyz
  737. !
  738. !EOP
  739. !------------------------------------------------------------------------
  740. !BOC
  741. if (xyz=='x') then
  742. upper = 'X'
  743. else if (xyz=='y') then
  744. upper = 'Y'
  745. else if (xyz=='z') then
  746. upper = 'Z'
  747. else if (xyz=='c') then
  748. upper = 'C'
  749. else if (xyz=='s') then
  750. upper = 'S'
  751. else if (xyz=='v') then
  752. upper = 'V'
  753. else
  754. upper = '_'
  755. end if
  756. END FUNCTION UPPER
  757. !EOC
  758. END MODULE MODELINTEGRATION