prtctl_trc.F90 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  1. MODULE prtctl_trc
  2. !!======================================================================
  3. !! *** MODULE prtctl_trc ***
  4. !! TOP : print all SUM trends for each processor domain
  5. !!======================================================================
  6. !! History : - ! 2005-07 (C. Talandier) original code for OPA
  7. !! 1.0 ! 2005-10 (C. Ethe ) adapted to passive tracer
  8. !!----------------------------------------------------------------------
  9. #if defined key_top
  10. !!----------------------------------------------------------------------
  11. !! 'key_top' TOP models
  12. !!----------------------------------------------------------------------
  13. !! prt_ctl_trc : control print in mpp for passive tracers
  14. !! prt_ctl_trc_info : ???
  15. !! prt_ctl_trc_init : ???
  16. !!----------------------------------------------------------------------
  17. USE par_trc ! TOP parameters
  18. USE oce_trc ! ocean space and time domain variables
  19. USE prtctl ! print control for OPA
  20. IMPLICIT NONE
  21. PRIVATE
  22. INTEGER , DIMENSION(:), ALLOCATABLE :: numid_trc !: logical unit
  23. INTEGER , DIMENSION(:), ALLOCATABLE :: nlditl , nldjtl !: first, last indoor index for each i-domain
  24. INTEGER , DIMENSION(:), ALLOCATABLE :: nleitl , nlejtl !: first, last indoor index for each j-domain
  25. INTEGER , DIMENSION(:), ALLOCATABLE :: nimpptl, njmpptl !: i-, j-indexes for each processor
  26. INTEGER , DIMENSION(:), ALLOCATABLE :: nlcitl , nlcjtl !: dimensions of every subdomain
  27. INTEGER , DIMENSION(:), ALLOCATABLE :: ibonitl, ibonjtl
  28. REAL(wp), DIMENSION(:,:), ALLOCATABLE :: tra_ctl !: previous trend values
  29. PUBLIC prt_ctl_trc ! called by all subroutines
  30. PUBLIC prt_ctl_trc_info !
  31. PUBLIC prt_ctl_trc_init ! called by opa.F90
  32. CONTAINS
  33. SUBROUTINE prt_ctl_trc( tab4d, mask, clinfo, ovlap, kdim, clinfo2 )
  34. !!----------------------------------------------------------------------
  35. !! *** ROUTINE prt_ctl ***
  36. !!
  37. !! ** Purpose : - print sum control 3D arrays over the same area
  38. !! in mono and mpp case. This way can be usefull when
  39. !! debugging a new parametrization in mono or mpp.
  40. !!
  41. !! ** Method : 2 possibilities exist when setting the ln_ctl parameter to
  42. !! .true. in the ocean namelist:
  43. !! - to debug a MPI run .vs. a mono-processor one;
  44. !! the control print will be done over each sub-domain.
  45. !! The nictl[se] and njctl[se] parameters in the namelist must
  46. !! be set to zero and [ij]splt to the corresponding splitted
  47. !! domain in MPI along respectively i-, j- directions.
  48. !! - to debug a mono-processor run over the whole domain/a specific area;
  49. !! in the first case the nictl[se] and njctl[se] parameters must be set
  50. !! to zero else to the indices of the area to be controled. In both cases
  51. !! isplt and jsplt must be set to 1.
  52. !! - All arguments of the above calling sequence are optional so their
  53. !! name must be explicitly typed if used. For instance if the mask
  54. !! array tmask(:,:,:) must be passed through the prt_ctl subroutine,
  55. !! it must looks like: CALL prt_ctl( mask=tmask ).
  56. !!----------------------------------------------------------------------
  57. REAL(wp) , DIMENSION(:,:,:,:), INTENT(in), OPTIONAL :: tab4d ! 4D array
  58. REAL(wp) , DIMENSION(:,:,:) , INTENT(in), OPTIONAL :: mask ! 3D mask to apply to the tab4d array
  59. CHARACTER (len=*), DIMENSION(:) , INTENT(in), OPTIONAL :: clinfo ! information about the tab3d array
  60. CHARACTER (len=*) , INTENT(in), OPTIONAL :: clinfo2 ! ???
  61. INTEGER , INTENT(in), OPTIONAL :: ovlap ! overlap value
  62. INTEGER , INTENT(in), OPTIONAL :: kdim ! k- direction for 4D arrays
  63. !!
  64. INTEGER :: overlap, jn, js, sind, eind, kdir, j_id
  65. REAL(wp) :: zsum, zvctl
  66. CHARACTER (len=20), DIMENSION(jptra) :: cl
  67. CHARACTER (len=10) :: cl2
  68. REAL(wp), POINTER, DIMENSION(:,:,:) :: zmask, ztab3d
  69. !!----------------------------------------------------------------------
  70. CALL wrk_alloc( jpi, jpj, jpk, zmask, ztab3d )
  71. ! ! Arrays, scalars initialization
  72. overlap = 0
  73. kdir = jpkm1
  74. zsum = 0.e0
  75. zvctl = 0.e0
  76. cl(:) = ''
  77. cl2 = ''
  78. ztab3d(:,:,:) = 0.e0
  79. zmask (:,:,:) = 1.e0
  80. ! ! Control of optional arguments
  81. IF( PRESENT(ovlap) ) overlap = ovlap
  82. IF( PRESENT(kdim) ) kdir = kdim
  83. IF( PRESENT(clinfo ) ) cl(:) = clinfo(:)
  84. IF( PRESENT(clinfo2) ) cl2 = clinfo2
  85. IF( PRESENT(mask) ) zmask (:,:,:) = mask(:,:,:)
  86. IF( lk_mpp ) THEN ! processor number
  87. sind = narea
  88. eind = narea
  89. ELSE ! processors total number
  90. sind = 1
  91. eind = ijsplt
  92. ENDIF
  93. ! Loop over each sub-domain, i.e. the total number of processors ijsplt
  94. DO js = sind, eind
  95. !
  96. ! Set logical unit
  97. j_id = numid_trc( js - narea + 1 )
  98. ! Set indices for the SUM control
  99. IF( .NOT. lsp_area ) THEN
  100. IF (lk_mpp ) THEN
  101. nictls = MAX( 1, nlditl(js) - overlap )
  102. nictle = nleitl(js) + overlap * MIN( 1, nlcitl(js) - nleitl(js))
  103. njctls = MAX( 1, nldjtl(js) - overlap )
  104. njctle = nlejtl(js) + overlap * MIN( 1, nlcjtl(js) - nlejtl(js))
  105. ! Do not take into account the bound of the domain
  106. IF( ibonitl(js) == -1 .OR. ibonitl(js) == 2 ) nictls = MAX( 2, nictls )
  107. IF( ibonitl(js) == 1 .OR. ibonitl(js) == 2 ) nictle = MIN( nictle, nleitl(js) - 1 )
  108. IF( ibonjtl(js) == -1 .OR. ibonjtl(js) == 2 ) njctls = MAX( 2, njctls )
  109. IF( ibonjtl(js) == 1 .OR. ibonjtl(js) == 2 ) njctle = MIN( njctle, nlejtl(js) - 1 )
  110. ELSE
  111. nictls = MAX( 1, nimpptl(js) + nlditl(js) - 1 - overlap )
  112. nictle = nimpptl(js) + nleitl(js) - 1 + overlap * MIN( 1, nlcitl(js) - nleitl(js) )
  113. njctls = MAX( 1, njmpptl(js) + nldjtl(js) - 1 - overlap )
  114. njctle = njmpptl(js) + nlejtl(js) - 1 + overlap * MIN( 1, nlcjtl(js) - nlejtl(js) )
  115. ! Do not take into account the bound of the domain
  116. IF( ibonitl(js) == -1 .OR. ibonitl(js) == 2 ) nictls = MAX( 2, nictls )
  117. IF( ibonjtl(js) == -1 .OR. ibonjtl(js) == 2 ) njctls = MAX( 2, njctls )
  118. IF( ibonitl(js) == 1 .OR. ibonitl(js) == 2 ) nictle = MIN( nictle, nimpptl(js) + nleitl(js) - 2 )
  119. IF( ibonjtl(js) == 1 .OR. ibonjtl(js) == 2 ) njctle = MIN( njctle, njmpptl(js) + nlejtl(js) - 2 )
  120. ENDIF
  121. ENDIF
  122. !
  123. IF( PRESENT(clinfo2) ) THEN
  124. DO jn = 1, jptra
  125. zvctl = tra_ctl(jn,js)
  126. ztab3d(:,:,:) = tab4d(:,:,:,jn)
  127. zsum = SUM( ztab3d(nictls:nictle,njctls:njctle,1:kdir) &
  128. & * zmask(nictls:nictle,njctls:njctle,1:kdir) )
  129. WRITE(j_id,FMT="(3x,a,' : ',D23.16)") cl(jn), zsum-zvctl
  130. tra_ctl(jn,js) = zsum
  131. END DO
  132. ELSE
  133. DO jn = 1, jptra
  134. ztab3d(:,:,:) = tab4d(:,:,:,jn)
  135. zsum = SUM( ztab3d(nictls:nictle,njctls:njctle,1:kdir) &
  136. & * zmask(nictls:nictle,njctls:njctle,1:kdir) )
  137. WRITE(j_id,FMT="(3x,a,' : ',D23.16)") cl(jn), zsum
  138. END DO
  139. ENDIF
  140. !
  141. END DO
  142. !
  143. CALL wrk_dealloc( jpi, jpj, jpk, zmask, ztab3d )
  144. !
  145. END SUBROUTINE prt_ctl_trc
  146. SUBROUTINE prt_ctl_trc_info( clinfo )
  147. !!----------------------------------------------------------------------
  148. !! *** ROUTINE prt_ctl_trc_info ***
  149. !!
  150. !! ** Purpose : - print information without any computation
  151. !!----------------------------------------------------------------------
  152. CHARACTER (len=*), INTENT(in) :: clinfo ! information to print
  153. !!
  154. INTEGER :: js, sind, eind, j_id
  155. !!----------------------------------------------------------------------
  156. IF( lk_mpp ) THEN ! processor number
  157. sind = narea
  158. eind = narea
  159. ELSE ! total number of processors
  160. sind = 1
  161. eind = ijsplt
  162. ENDIF
  163. ! Loop over each sub-domain, i.e. number of processors ijsplt
  164. DO js = sind, eind
  165. j_id = numid_trc(js - narea + 1)
  166. WRITE(j_id,*) clinfo
  167. END DO
  168. !
  169. END SUBROUTINE prt_ctl_trc_info
  170. SUBROUTINE prt_ctl_trc_init
  171. !!----------------------------------------------------------------------
  172. !! *** ROUTINE prt_ctl_trc_init ***
  173. !!
  174. !! ** Purpose : open ASCII files & compute indices
  175. !!----------------------------------------------------------------------
  176. INTEGER :: js, sind, eind, j_id
  177. CHARACTER (len=31) :: clfile_out
  178. CHARACTER (len=27) :: clb_name
  179. CHARACTER (len=19) :: cl_run
  180. !!----------------------------------------------------------------------
  181. ! ! Allocate arrays
  182. ALLOCATE( nlditl (ijsplt) )
  183. ALLOCATE( nldjtl (ijsplt) )
  184. ALLOCATE( nleitl (ijsplt) )
  185. ALLOCATE( nlejtl (ijsplt) )
  186. ALLOCATE( nimpptl(ijsplt) )
  187. ALLOCATE( njmpptl(ijsplt) )
  188. ALLOCATE( nlcitl (ijsplt) )
  189. ALLOCATE( nlcjtl (ijsplt) )
  190. ALLOCATE( tra_ctl(jptra,ijsplt) )
  191. ALLOCATE( ibonitl(ijsplt) )
  192. ALLOCATE( ibonjtl(ijsplt) )
  193. tra_ctl(:,:) = 0.e0 ! Initialization to zero
  194. IF( lk_mpp ) THEN
  195. sind = narea
  196. eind = narea
  197. clb_name = "('mpp.top.output_',I3.3)"
  198. cl_run = 'MULTI processor run'
  199. ! use indices for each area computed by mpp_init subroutine
  200. nlditl(1:jpnij) = nldit(:)
  201. nleitl(1:jpnij) = nleit(:)
  202. nldjtl(1:jpnij) = nldjt(:)
  203. nlejtl(1:jpnij) = nlejt(:)
  204. !
  205. nimpptl(1:jpnij) = nimppt(:)
  206. njmpptl(1:jpnij) = njmppt(:)
  207. !
  208. nlcitl(1:jpnij) = nlcit(:)
  209. nlcjtl(1:jpnij) = nlcjt(:)
  210. !
  211. ibonitl(1:jpnij) = ibonit(:)
  212. ibonjtl(1:jpnij) = ibonjt(:)
  213. ELSE
  214. sind = 1
  215. eind = ijsplt
  216. clb_name = "('mono.top.output_',I3.3)"
  217. cl_run = 'MONO processor run '
  218. ! compute indices for each area as done in mpp_init subroutine
  219. CALL sub_dom
  220. ENDIF
  221. ALLOCATE( numid_trc(eind-sind+1) )
  222. DO js = sind, eind
  223. WRITE(clfile_out,FMT=clb_name) js-1
  224. CALL ctl_opn( numid_trc(js -narea + 1), clfile_out, 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, .FALSE. )
  225. j_id = numid_trc(js -narea + 1)
  226. WRITE(j_id,*)
  227. WRITE(j_id,*) ' L O D Y C - I P S L'
  228. WRITE(j_id,*) ' N E M 0 '
  229. WRITE(j_id,*) ' Ocean General Circulation Model'
  230. WRITE(j_id,*) ' version TOP 1.0 (2005) '
  231. WRITE(j_id,*)
  232. WRITE(j_id,*) ' PROC number: ', js
  233. WRITE(j_id,*)
  234. WRITE(j_id,FMT="(19x,a20)") cl_run
  235. ! Print the SUM control indices
  236. IF( .NOT. lsp_area ) THEN
  237. IF ( lk_mpp ) THEN
  238. nictls = nlditl(js)
  239. nictle = nleitl(js)
  240. njctls = nldjtl(js)
  241. njctle = nlejtl(js)
  242. ELSE
  243. nictls = nimpptl(js) + nlditl(js) - 1
  244. nictle = nimpptl(js) + nleitl(js) - 1
  245. njctls = njmpptl(js) + nldjtl(js) - 1
  246. njctle = njmpptl(js) + nlejtl(js) - 1
  247. ENDIF
  248. ENDIF
  249. WRITE(j_id,*)
  250. WRITE(j_id,*) 'prt_tra_ctl : Sum control indices'
  251. WRITE(j_id,*) '~~~~~~~'
  252. WRITE(j_id,*)
  253. WRITE(j_id,9000)' nlej = ', nlejtl(js), ' '
  254. WRITE(j_id,9000)' ------------- njctle = ', njctle, ' -------------'
  255. WRITE(j_id,9001)' | |'
  256. WRITE(j_id,9001)' | |'
  257. WRITE(j_id,9001)' | |'
  258. WRITE(j_id,9002)' nictls = ', nictls, ' nictle = ', nictle
  259. WRITE(j_id,9002)' nldi = ', nlditl(js), ' nlei = ', nleitl(js)
  260. WRITE(j_id,9001)' | |'
  261. WRITE(j_id,9001)' | |'
  262. WRITE(j_id,9001)' | |'
  263. WRITE(j_id,9004)' njmpp = ',njmpptl(js),' ------------- njctls = ', njctls, ' -------------'
  264. WRITE(j_id,9003)' nimpp = ', nimpptl(js), ' nldj = ', nldjtl(js), ' '
  265. WRITE(j_id,*)
  266. WRITE(j_id,*)
  267. 9000 FORMAT(a41,i4.4,a14)
  268. 9001 FORMAT(a59)
  269. 9002 FORMAT(a20,i4.4,a36,i3.3)
  270. 9003 FORMAT(a20,i4.4,a17,i4.4)
  271. 9004 FORMAT(a11,i4.4,a26,i4.4,a14)
  272. END DO
  273. !
  274. END SUBROUTINE prt_ctl_trc_init
  275. #else
  276. !!----------------------------------------------------------------------
  277. !! Dummy module : NO passive tracer
  278. !!----------------------------------------------------------------------
  279. #endif
  280. !!----------------------------------------------------------------------
  281. !! NEMO/TOP 3.3 , NEMO Consortium (2010)
  282. !! $Id: prtctl_trc.F90 4520 2014-02-28 11:44:02Z acc $
  283. !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
  284. !!======================================================================
  285. END MODULE prtctl_trc