trdmxl_trc_rst.F90 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. MODULE trdmxl_trc_rst
  2. !!======================================================================
  3. !! *** MODULE trdmxl_rst ***
  4. !! Ocean dynamic : Input/Output files for restart on mixed-layer diagnostics
  5. !!======================================================================
  6. !! History : 9.0 ! 07-03 (C. Deltel) Original code
  7. !!----------------------------------------------------------------------
  8. #if defined key_top && defined key_trdmxl_trc
  9. !!----------------------------------------------------------------------
  10. USE in_out_manager ! I/O manager
  11. USE iom ! I/O module
  12. USE trc ! for nn_dttrc ctrcnm
  13. USE trdmxl_trc_oce ! for lk_trdmxl_trc
  14. IMPLICIT NONE
  15. PRIVATE
  16. PUBLIC trd_mxl_trc_rst_read ! routine called by trd_mxl_init
  17. PUBLIC trd_mxl_trc_rst_write ! routine called by step.F90
  18. INTEGER :: nummldw_trc ! logical unit for mld restart
  19. !!---------------------------------------------------------------------------------
  20. !! NEMO/TOP 3.3 , NEMO Consortium (2010)
  21. !! $Id: trdmxl_trc_rst.F90 2422 2015-06-05 12:04:13Z ufla $
  22. !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
  23. !!---------------------------------------------------------------------------------
  24. CONTAINS
  25. SUBROUTINE trd_mxl_trc_rst_write( kt )
  26. !!--------------------------------------------------------------------------------
  27. !! *** SUBROUTINE trd_mxl_rst_wri ***
  28. !!
  29. !! ** Purpose : Write mixed-layer diagnostics restart fields.
  30. !!--------------------------------------------------------------------------------
  31. INTEGER, INTENT( in ) :: kt ! ocean time-step index
  32. !
  33. CHARACTER(LEN=20) :: clkt ! ocean time-step deine as a character
  34. CHARACTER(LEN=50) :: clname ! output restart file name
  35. CHARACTER(LEN=256) :: clpath ! full path to restart file
  36. CHARACTER (len=35) :: charout
  37. INTEGER :: jl, jk, jn ! loop indice
  38. !!--------------------------------------------------------------------------------
  39. IF( kt == nitrst - nn_dttrc .OR. nitend - nit000 + 1 < 2 * nn_dttrc ) THEN ! idem trcrst.F90
  40. IF( nitrst > 1.0e9 ) THEN
  41. WRITE(clkt,*) nitrst
  42. ELSE
  43. WRITE(clkt,'(i8.8)') nitrst
  44. ENDIF
  45. clname = TRIM(cexper)//"_"//TRIM(ADJUSTL(clkt))//"_"//TRIM(cn_trdrst_trc_out)
  46. clpath = TRIM(cn_trcrst_outdir)
  47. IF( clpath(LEN_TRIM(clpath):) /= '/' ) clpath = TRIM(clpath) // '/'
  48. IF(lwp) WRITE(numout,*) ' open ocean restart_mld_trc NetCDF 'TRIM(clpath)//TRIM(clname)
  49. CALL iom_open( TRIM(clpath)//TRIM(clname), nummldw_trc, ldwrt = .TRUE., kiolib = jprstlib )
  50. ENDIF
  51. IF( kt == nitend .AND. lk_trdmxl_trc ) THEN
  52. IF( kt == nitend .AND. lwp ) THEN
  53. WRITE(numout,*)
  54. WRITE(numout,*) 'trdmxl_trc_rst: output for ML diags. restart, with trd_mxl_trc_rst_write routine'
  55. WRITE(numout,*) '~~~~~~~~~~~~~~'
  56. WRITE(numout,*)
  57. ENDIF
  58. IF( ln_trdmxl_trc_instant ) THEN
  59. !
  60. DO jn = 1, jptra
  61. CALL iom_rstput( kt, nitrst, nummldw_trc, 'tmlbb_trc_' //ctrcnm(jn), tmlbb_trc (:,:,jn) )
  62. CALL iom_rstput( kt, nitrst, nummldw_trc, 'tmlbn_trc_' //ctrcnm(jn), tmlbn_trc (:,:,jn) )
  63. CALL iom_rstput( kt, nitrst, nummldw_trc, 'tmlatfb_trc_'//ctrcnm(jn), tmlatfb_trc(:,:,jn) )
  64. CALL iom_rstput( kt, nitrst, nummldw_trc, 'tmlradb_trc_'//ctrcnm(jn), tmlradb_trc(:,:,jn) )
  65. END DO
  66. !
  67. ELSE
  68. !
  69. CALL iom_rstput( kt, nitrst, nummldw_trc, 'rmldbn_trc', rmldbn_trc ) ! 2D x 1
  70. ! ! ===========
  71. DO jn = 1, jptra ! tracer loop
  72. ! ! ===========
  73. CALL iom_rstput( kt, nitrst, nummldw_trc, 'tmlatfb_trc_' //ctrcnm(jn), tmlatfb_trc (:,:,jn) ) ! 2D x jptra
  74. CALL iom_rstput( kt, nitrst, nummldw_trc, 'tmlbb_trc_' //ctrcnm(jn), tmlbb_trc (:,:,jn) ) ! 2D x jptra
  75. CALL iom_rstput( kt, nitrst, nummldw_trc, 'tmlradb_trc_' //ctrcnm(jn), tmlradb_trc (:,:,jn) ) ! 2D x jptra
  76. CALL iom_rstput( kt, nitrst, nummldw_trc, 'tmlbn_trc_' //ctrcnm(jn), tmlbn_trc (:,:,jn) ) ! 2D x jptra
  77. CALL iom_rstput( kt, nitrst, nummldw_trc, 'tml_sumb_trc_'//ctrcnm(jn), tml_sumb_trc(:,:,jn) ) ! 2D x jptra
  78. DO jk = 1, jpltrd_trc
  79. IF( jk < 10 ) THEN
  80. WRITE(charout,FMT="('tmltrd_csum_ub_trc_', A3, '_', I1)") ctrcnm(jn), jk
  81. ELSE
  82. WRITE(charout,FMT="('tmltrd_csum_ub_trc_', A3, '_', I2)") ctrcnm(jn), jk
  83. ENDIF
  84. CALL iom_rstput( kt, nitrst, nummldw_trc, charout, tmltrd_csum_ub_trc(:,:,jk,jn) )
  85. END DO
  86. CALL iom_rstput( kt, nitrst, nummldw_trc, 'tmltrd_atf_sumb_trc_'//ctrcnm(jn) , &
  87. & tmltrd_atf_sumb_trc(:,:,jn) ) ! 2D x jptra
  88. CALL iom_rstput( kt, nitrst, nummldw_trc, 'tmltrd_rad_sumb_trc_'//ctrcnm(jn) , &
  89. & tmltrd_rad_sumb_trc(:,:,jn) ) ! 2D x jptra
  90. ! ! ===========
  91. END DO ! tracer loop
  92. ! ! ===========
  93. #if defined key_pisces_reduced
  94. DO jl = 1, jp_pisces_trd
  95. CALL iom_rstput( kt, nitrst, nummldw_trc, 'tmltrd_csum_ub_bio'//ctrd_bio(jl,2), tmltrd_csum_ub_bio(:,:,jl) )
  96. ENDDO
  97. #endif
  98. ENDIF
  99. CALL iom_close( nummldw_trc )
  100. lrst_trc = .TRUE.
  101. ENDIF
  102. END SUBROUTINE trd_mxl_trc_rst_write
  103. SUBROUTINE trd_mxl_trc_rst_read
  104. !!----------------------------------------------------------------------------
  105. !! *** SUBROUTINE trd_mxl_rst_lec ***
  106. !!
  107. !! ** Purpose : Read file for mixed-layer diagnostics restart.
  108. !!----------------------------------------------------------------------------
  109. INTEGER :: inum ! temporary logical unit
  110. !
  111. CHARACTER (len=35) :: charout
  112. INTEGER :: jk, jn, jl ! loop indice
  113. INTEGER :: jlibalt = jprstlib
  114. LOGICAL :: llok
  115. CHARACTER(LEN=256) :: clpath ! full path to restart file
  116. !!-----------------------------------------------------------------------------
  117. IF(lwp) THEN
  118. WRITE(numout,*)
  119. WRITE(numout,*) ' trd_mxl_trc_rst_read : read the NetCDF MLD restart file'
  120. WRITE(numout,*) ' ~~~~~~~~~~~~~~~~~~~~'
  121. ENDIF
  122. clpath = TRIM(cn_trcrst_indir)
  123. IF( clpath(LEN_TRIM(clpath):) /= '/' ) clpath = TRIM(clpath) // '/'
  124. IF ( jprstlib == jprstdimg ) THEN
  125. ! eventually read netcdf file (monobloc) for restarting on different number of processors
  126. ! if {cn_trdrst_trc_in}.nc exists, then set jlibalt to jpnf90
  127. INQUIRE( FILE = TRIM(clpath)//TRIM(cn_trdrst_trc_in)//'.nc', EXIST = llok )
  128. IF ( llok ) THEN ; jlibalt = jpnf90 ; ELSE ; jlibalt = jprstlib ; ENDIF
  129. ENDIF
  130. CALL iom_open( TRIM(clpath)//TRIM(cn_trdrst_trc_in), inum, kiolib = jlibalt )
  131. IF( ln_trdmxl_trc_instant ) THEN
  132. DO jn = 1, jptra
  133. CALL iom_get( inum, jpdom_autoglo, 'tmlbb_trc_' //ctrcnm(jn), tmlbb_trc (:,:,jn) )
  134. CALL iom_get( inum, jpdom_autoglo, 'tmlbn_trc_' //ctrcnm(jn), tmlbn_trc (:,:,jn) )
  135. CALL iom_get( inum, jpdom_autoglo, 'tmlatfb_trc_'//ctrcnm(jn), tmlatfb_trc(:,:,jn) )
  136. CALL iom_get( inum, jpdom_autoglo, 'tmlradb_trc_'//ctrcnm(jn), tmlradb_trc(:,:,jn) )
  137. END DO
  138. ELSE
  139. CALL iom_get( inum, jpdom_autoglo, 'rmldbn_trc', rmldbn_trc ) ! needed for rmld_sum
  140. ! ! ===========
  141. DO jn = 1, jptra ! tracer loop
  142. ! ! ===========
  143. CALL iom_get( inum, jpdom_autoglo, 'tmlatfb_trc_' //ctrcnm(jn), tmlatfb_trc(:,:,jn) )
  144. CALL iom_get( inum, jpdom_autoglo, 'tmlbb_trc_' //ctrcnm(jn), tmlbb_trc (:,:,jn) )
  145. CALL iom_get( inum, jpdom_autoglo, 'tmlradb_trc_' //ctrcnm(jn), tmlradb_trc(:,:,jn) )
  146. CALL iom_get( inum, jpdom_autoglo, 'tmlbn_trc_' //ctrcnm(jn), tmlbn_trc (:,:,jn) ) ! needed for tml_sum
  147. CALL iom_get( inum, jpdom_autoglo, 'tml_sumb_trc_'//ctrcnm(jn), tml_sumb_trc(:,:,jn) )
  148. DO jk = 1, jpltrd_trc
  149. IF( jk < 10 ) THEN
  150. WRITE(charout,FMT="('tmltrd_csum_ub_trc_', A3, '_', I1)") ctrcnm(jn), jk
  151. ELSE
  152. WRITE(charout,FMT="('tmltrd_csum_ub_trc_', A3, '_', I2)") ctrcnm(jn), jk
  153. ENDIF
  154. CALL iom_get( inum, jpdom_autoglo, charout, tmltrd_csum_ub_trc(:,:,jk,jn) )
  155. END DO
  156. CALL iom_get( inum, jpdom_autoglo, 'tmltrd_atf_sumb_trc_'//ctrcnm(jn) , &
  157. & tmltrd_atf_sumb_trc(:,:,jn) )
  158. CALL iom_get( inum, jpdom_autoglo, 'tmltrd_rad_sumb_trc_'//ctrcnm(jn) , &
  159. & tmltrd_rad_sumb_trc(:,:,jn) )
  160. ! ! ===========
  161. END DO ! tracer loop
  162. ! ! ===========
  163. #if defined key_pisces_reduced
  164. DO jl = 1, jp_pisces_trd
  165. CALL iom_get( inum, jpdom_autoglo, 'tmltrd_csum_ub_bio'//ctrd_bio(jl,2), tmltrd_csum_ub_bio(:,:,jl) )
  166. ENDDO
  167. #endif
  168. CALL iom_close( inum )
  169. ENDIF
  170. END SUBROUTINE trd_mxl_trc_rst_read
  171. #else
  172. !!=================================================================================
  173. !! *** MODULE trdmxl_rst ***
  174. !! Ocean dynamic : Input/Output files for restart on mixed-layer diagnostics
  175. !!=================================================================================
  176. CONTAINS
  177. SUBROUTINE trd_mxl_trc_rst_opn( kt )
  178. WRITE(*,*) 'trd_mxl_trc_rst_opn: You should not have seen this print! error?', kt
  179. END SUBROUTINE trd_mxl_trc_rst_opn
  180. SUBROUTINE trd_mxl_trc_rst_write( kt ) ! No ML diags ==> empty routine
  181. WRITE(*,*) 'trd_mxl_trc_rst_wri: You should not have seen this print! error?', kt
  182. END SUBROUTINE trd_mxl_trc_rst_write
  183. SUBROUTINE trd_mxl_trc_rst_read ! No ML Diags ==> empty routine
  184. END SUBROUTINE trd_mxl_trc_rst_read
  185. #endif
  186. !!=================================================================================
  187. END MODULE trdmxl_trc_rst