appl-tm5.F90 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. !#################################################################
  2. !
  3. !**** Global Atmospheric Tracer Model TM5
  4. !
  5. ! purpose
  6. ! -------
  7. ! Solves the tracer continuitiy equation on an eulerian grid for
  8. ! an arbitrary no. of tracers.
  9. ! Perform advection, vertical transport, emissions, chemistry, deposition, ....
  10. !
  11. ! interface
  12. ! ---------
  13. ! main program, which interfaces with OASIS3_MCT
  14. !
  15. ! reference
  16. ! ---------
  17. ! See the main website : www.phys.uu.nl/~tm5/
  18. !
  19. !#################################################################
  20. !
  21. #define TRACEBACK write (gol,'("in ",a," (",a,", line",i5,")")') rname, __FILE__, __LINE__; call goErr
  22. !
  23. #include "tm5.inc"
  24. !
  25. PROGRAM APPL_TM5
  26. use mod_oasis
  27. use GO, only : gol, goPr, goErr
  28. use TM5, only : TM5_Comm_Init, TM5_Comm_Done
  29. use TM5, only : TM5_Model_Init, TM5_Model_Run, TM5_Model_Done
  30. use TM5, only : comp_name, comp_id
  31. use partools, only : isRoot
  32. use mpi
  33. implicit none
  34. ! --- const ---------------------------------------
  35. character(len=*), parameter :: rname = 'appl_tm5'
  36. ! --- local ---------------------------------------
  37. integer :: status, icpl
  38. integer :: localComm, couplComm
  39. character(len=256) :: error_message
  40. ! --- begin ---------------------------------------
  41. !
  42. ! Initialise coupling
  43. !
  44. call oasis_init_comp( comp_id, comp_name, status )
  45. if (status/=OASIS_OK) then
  46. write (gol,'("from OASIS_INIT_COMP : ",i6)') status; call goErr
  47. TRACEBACK; call exit(1)
  48. end if
  49. !
  50. ! Setup communication
  51. !
  52. call oasis_get_localcomm( localComm, status )
  53. if (status/=OASIS_OK) then
  54. write (error_message,'("from OASIS_GET_LOCALCOMM : ",i6)') status; call goErr
  55. call oasis_abort( comp_id, rname, error_message )
  56. end if
  57. ! Init tm5 internal communciation
  58. call TM5_Comm_Init( status, comm=localComm )
  59. if (status/=0) then
  60. write (error_message,'("from TM5_Comm_Init : ",i6)') status; call goErr
  61. call oasis_abort( comp_id, rname, error_message )
  62. end if
  63. ! Coupling ommunicator
  64. !#ifdef parallel_cplng
  65. icpl=1
  66. !#else
  67. ! icpl=MPI_UNDEFINED
  68. ! if ( isRoot ) icpl=1
  69. !#endif
  70. call oasis_create_couplcomm(icpl, localComm, couplComm, status)
  71. if (status/=OASIS_OK) then
  72. write (error_message,'("from OASIS_CREATE_COUPLCOMM : ",i6)') status; call goErr
  73. call oasis_abort( comp_id, rname, error_message )
  74. end if
  75. !
  76. ! Run model
  77. !
  78. call TM5_Model_Init( status )
  79. if (status/=0) then
  80. write (error_message,'("from TM5_Model_Init : ",i6)') status; call goErr
  81. call oasis_abort( comp_id, rname, error_message )
  82. end if
  83. call TM5_Model_Run( status )
  84. if (status/=0) then
  85. write (error_message,'("from TM5_Model_Run : ",i6)') status; call goErr
  86. call oasis_abort( comp_id, rname, error_message )
  87. end if
  88. call TM5_Model_Done( status )
  89. if (status/=0) then
  90. write (error_message,'("from TM5_Model_Done : ",i6)') status; call goErr
  91. call oasis_abort( comp_id, rname, error_message )
  92. end if
  93. !
  94. ! End communication
  95. !
  96. call TM5_Comm_Done( status, comm=localComm )
  97. if (status/=0) then
  98. write (error_message,'("from TM5_Comm_Done : ",i6)') status; call goErr
  99. call oasis_abort( comp_id, rname, error_message )
  100. end if
  101. !
  102. ! End coupling
  103. !
  104. call oasis_terminate( status )
  105. if (status/=OASIS_OK) then
  106. write (gol,'("from OASIS_TERMINATE : ",i6)') status; call goErr
  107. TRACEBACK; call exit(1)
  108. end if
  109. end program appl_tm5