lib_print.f90 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. MODULE lib_print
  2. !!======================================================================
  3. !! *** MODULE lib_print ***
  4. !! print librairy : formated real and integer array print
  5. !!=====================================================================
  6. !!----------------------------------------------------------------------
  7. !! prihin : print an integer 2D horizontal field
  8. !! prihre : print an real 2D horizontal field
  9. !! prizre : print an real 2D vertical field
  10. !!----------------------------------------------------------------------
  11. USE par_kind ! kind parameters
  12. IMPLICIT NONE
  13. PRIVATE
  14. PUBLIC prihin, prihre, prizre
  15. !!----------------------------------------------------------------------
  16. !! NEMO/OPA 3.3 , NEMO Consortium (2010)
  17. !! $Id: lib_print.f90 2715 2011-03-30 15:58:35Z rblod $
  18. !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
  19. !!----------------------------------------------------------------------
  20. CONTAINS
  21. SUBROUTINE prihin( ktab, ki , kj , kideb, kifin , &
  22. kind, kjdeb, kjfin, kjnd , kscale, kumout )
  23. !!----------------------------------------------------------------------
  24. !! *** SUBROUTINE prihre ***
  25. !!
  26. !! ** purpose : Print an integer field
  27. !!
  28. !! ** method : format of print is selected with the dummy argument kscale
  29. !!
  30. !! History :
  31. !! ! 90-04 (0. Marti) Original code
  32. !! ! 92-02 (M. Imbard)
  33. !! ! 03-07 (G. Madec) F90, free form
  34. !!----------------------------------------------------------------------
  35. INTEGER, INTENT( in ) :: &
  36. ki, kj, & ! array dimensions
  37. kideb, kifin, kind, & ! first and last index, increment for i
  38. kjdeb, kjfin, kjnd, & ! first and last index, increment for j
  39. kscale, & ! kscale=0 or > 5 print ktab with format i8
  40. ! ! kscale=1 print ktab with format i1
  41. ! ! kscale=2 print ktab with format i2
  42. ! ! kscale=3 print ktab with format i3
  43. ! ! kscale=4 print ktab with format i4
  44. ! ! kscale=5 print ktab with format i5
  45. kumout ! unit in which print
  46. INTEGER, DIMENSION(ki,kj), INTENT( in ) :: &
  47. ktab ! integer 2D array to be print
  48. !! * local declarations
  49. INTEGER :: ji, jj, jn ! dummy loop indices
  50. INTEGER :: isca, il1, il2 ! temporary integers
  51. INTEGER :: iind, ijnd ! temporary integers
  52. isca = 10
  53. IF( kscale == 0 ) isca = 10
  54. IF( kscale == 1 ) isca = 100
  55. IF( kscale == 2 ) isca = 60
  56. IF( kscale == 3 ) isca = 40
  57. IF( kscale == 4 ) isca = 30
  58. IF( kscale == 5 ) isca = 20
  59. iind = MAX( 1, kind )
  60. ijnd = MAX( 1, kjnd )
  61. il1 = kideb
  62. DO jn = 1, (kifin-kideb+1)/(iind*isca) + 1
  63. IF( il1 > kifin ) RETURN
  64. WRITE(kumout,'(/)')
  65. il2 = il1+iind*(isca-1)
  66. IF( il2 > kifin ) il2 = kifin
  67. IF( kscale == 1 ) THEN
  68. WRITE(kumout,'(4x,i14," to ",1i4," each ",1i4,/)') il1, il2, iind
  69. DO jj = kjfin, kjdeb, -ijnd
  70. WRITE (kumout,'(1x,i3,100i1)') jj, ( ktab(ji,jj), ji = il1, il2, iind )
  71. END DO
  72. ELSEIF( kscale == 2 ) THEN
  73. WRITE(kumout,'(4x,i14," to ",1i4," each ",1i4,/)')il1, il2, iind
  74. DO jj = kjfin, kjdeb, -ijnd
  75. WRITE (kumout,'(1x,i3,60i2)') jj, ( ktab(ji,jj), ji = il1, il2, iind )
  76. END DO
  77. ELSEIF( kscale == 3 ) THEN
  78. WRITE(kumout,'(4x,i14," to ",1i4," each ",1i4,/)')il1, il2, iind
  79. DO jj = kjfin, kjdeb, -ijnd
  80. WRITE (kumout,'(1x,i3,40i3)') jj, ( ktab(ji,jj), ji = il1, il2, iind )
  81. END DO
  82. ELSEIF( kscale == 4 ) THEN
  83. WRITE(kumout,'(4x,30i4,/)') ( ji, ji = il1, il2, iind )
  84. DO jj = kjfin, kjdeb, -ijnd
  85. WRITE (kumout,'(1x,i3,30i4)') jj, ( ktab(ji,jj), ji = il1, il2, iind )
  86. END DO
  87. ELSEIF( kscale == 5 ) THEN
  88. WRITE(kumout,'(4x,20i5,/)') ( ji, ji = il1, il2, iind )
  89. DO jj = kjfin, kjdeb, -ijnd
  90. WRITE (kumout,'(1x,i3,20i5)') jj, ( ktab(ji,jj), ji = il1, il2, iind )
  91. END DO
  92. ELSE
  93. WRITE(kumout,'(4x,10i8,/)') ( ji, ji = il1, il2, iind )
  94. DO jj = kjfin, kjdeb, -ijnd
  95. WRITE (kumout,'(1x,i3,10i8)') jj, ( ktab(ji,jj), ji = il1, il2, iind )
  96. END DO
  97. ENDIF
  98. il1 = il1 + iind * isca
  99. END DO
  100. END SUBROUTINE prihin
  101. SUBROUTINE prihre( ptab, ki , kj , kideb, kifin , &
  102. kind, kjdeb, kjfin, kjnd , pscale, kumout )
  103. !!----------------------------------------------------------------------
  104. !! *** ROUTINE prihre ***
  105. !!
  106. !! ** purpose : Print a real field with the format 10e12.4 or 20f6.2
  107. !!
  108. !! ** method : the print format is selected with the pscale argument
  109. !!
  110. !! History :
  111. !! 1.0 ! 86-01 (P. Andrich) Original code
  112. !! ! 89-11 (C. Levy)
  113. !! ! 92-02 (M. Imbard)
  114. !! ! 92-06 (M. Imbard)
  115. !!----------------------------------------------------------------------
  116. !! * Arguments
  117. INTEGER, INTENT( in ) :: &
  118. ki, kj, & ! array dimensions
  119. kideb, kifin, kind, & ! first and last index, increment for i
  120. kjdeb, kjfin, kjnd, & ! first and last index, increment for j
  121. kumout ! unit in which print
  122. REAL(wp), INTENT( in ) :: &
  123. pscale ! = 0 print ptab with e13.5 format
  124. ! ! else print pscale*ptab with f6.2 format
  125. REAL(wp), DIMENSION(ki,kj), INTENT( in ) :: &
  126. ptab ! integer 2D array to be print
  127. !! * Local variables
  128. INTEGER :: ji, jj, jn ! dummy loop indices
  129. INTEGER :: isca, il1, il2 ! temporary integers
  130. isca = 10
  131. IF( pscale /= 0. ) isca=20
  132. il1 = kideb
  133. DO jn = 1, (kifin-kideb+1)/(kind*isca) + 1
  134. IF( il1 > kifin ) RETURN
  135. WRITE(kumout,9100)
  136. il2 = il1+kind*(isca-1)
  137. IF(il2 > kifin) il2 = kifin
  138. IF( pscale == 0.) THEN
  139. WRITE(kumout,9101) ( ji, ji = il1, il2, kind )
  140. DO jj = kjfin, kjdeb, -kjnd
  141. WRITE(kumout,9102) jj, ( ptab(ji,jj), ji = il1, il2, kind )
  142. END DO
  143. ELSE
  144. WRITE(kumout,9103) ( ji, ji = il1, il2, kind )
  145. DO jj = kjfin, kjdeb, -kjnd
  146. WRITE(kumout,9104) jj, ( pscale*ptab(ji,jj), ji = il1, il2, kind )
  147. END DO
  148. ENDIF
  149. il1 = il1+kind*isca
  150. END DO
  151. ! formats
  152. 9100 FORMAT(/)
  153. 9101 FORMAT(10i12, /)
  154. 9102 FORMAT(1x, i3, 10(1pe12.4))
  155. 9103 FORMAT(3x, 20i6, /)
  156. 9104 FORMAT(1x, i3, 1x, 20f6.2)
  157. END SUBROUTINE prihre
  158. SUBROUTINE prizre( ptab , ki , kj , kk , kjcut , &
  159. kideb, kifin, kid , kkdeb, kkfin , &
  160. kkd , pscale, kumout )
  161. !!----------------------------------------------------------------------
  162. !! *** ROUTINE prizre ***
  163. !!
  164. !! ** purpose : Print a vertical slab from a tridimentional real field
  165. !!
  166. !! METHOD :
  167. !! ** method : the print format is selected with the argument pscale
  168. !!
  169. !! History :
  170. !! original : 86-01 (o. Marti)
  171. !! addition : 92-02 (M. Imbard)
  172. !! addition : 92-06 (M. Imbard)
  173. !!----------------------------------------------------------------------
  174. !! * Arguments
  175. INTEGER, INTENT( in ) :: &
  176. ki, kj, kk, & ! array dimensions
  177. kjcut, & ! index j for the vertical slab
  178. kideb, kifin, kid, & ! first and last index, increment for i
  179. kkdeb, kkfin, kkd, & ! first and last index, increment for k
  180. kumout ! unit in which print
  181. REAL(wp), INTENT( in ) :: &
  182. pscale ! = 0 print ptab with e12.4 format
  183. ! ! else print pscale*ptab with f6.2 format
  184. REAL(wp), DIMENSION(ki,kj,kk), INTENT( in ) :: &
  185. ptab ! integer 3D array to be print
  186. !! * Local variables
  187. INTEGER :: ji, jn, jk ! dummy loop indices
  188. INTEGER :: isca, il1, il2 ! temporary integers
  189. INTEGER :: iind, iknd ! " "
  190. iind = kid
  191. iknd = kkd
  192. isca = 10
  193. IF( pscale /= 0.) isca = 20
  194. IF (iind == 0) iind = 1
  195. IF (iknd == 0) iknd = 1
  196. il1 = kideb
  197. DO jn = 1, (kifin-kideb+1)/(iind*isca) + 1
  198. IF(il1 > kifin) RETURN
  199. WRITE(kumout,9100)
  200. il2 = il1+iind*(isca-1)
  201. IF(il2 > kifin) il2 = kifin
  202. IF( pscale == 0.) THEN
  203. WRITE(kumout,9101) ( ji, ji = il1, il2, iind )
  204. DO jk = kkdeb, kkfin, iknd
  205. WRITE (kumout,9102) jk, ( ptab(ji,kjcut,jk), ji = il1, il2, iind )
  206. END DO
  207. ELSE
  208. WRITE (kumout,9103) ( ji, ji = il1, il2, iind )
  209. DO jk = kkdeb, kkfin, iknd
  210. WRITE(kumout,9104)jk, ( pscale*ptab(ji,kjcut,jk), ji = il1, il2, iind )
  211. END DO
  212. ENDIF
  213. il1 = il1+iind*isca
  214. END DO
  215. 9100 FORMAT(/)
  216. 9101 FORMAT(10i12, /)
  217. 9102 FORMAT(1x, i3, 10(1pe12.4))
  218. 9103 FORMAT(3x, 20i6, /)
  219. 9104 FORMAT(1x, i3, 1x, 20f6.1)
  220. END SUBROUTINE prizre
  221. !!======================================================================
  222. END MODULE lib_print