limwri_dimg.h90 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. SUBROUTINE lim_wri
  2. !!----------------------------------------------------------------------
  3. !! NEMO/LIM3 3.3 , UCL - NEMO Consortium (2010)
  4. !! $Id: limwri_dimg.h90 4688 2014-06-24 23:39:59Z clem $
  5. !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
  6. !!----------------------------------------------------------------------
  7. !!-------------------------------------------------------------------
  8. !! This routine computes the average of some variables and write it
  9. !! on the ouput files.
  10. !! ATTENTION cette routine n'est valable que si le pas de temps est
  11. !! egale a une fraction entiere de 1 jours.
  12. !! Diff 1-D 3-D : suppress common also included in etat
  13. !! suppress cmoymo 11-18
  14. !! modif : 03/06/98
  15. !!-------------------------------------------------------------------
  16. USE diawri, ONLY : dia_wri_dimg
  17. USE lib_fortran ! Fortran utilities (allows no signed zero when 'key_nosignedzero' defined)
  18. REAL(wp),DIMENSION(1) :: zdept
  19. REAL(wp) :: zsto, zsec, zjulian,zout, &
  20. REAL(wp) :: zindh,zinda,zindb, ztmu
  21. REAL(wp), DIMENSION(jpi,jpj,jpnoumax) :: zcmo
  22. REAL(wp), DIMENSION(jpi,jpj) :: zfield
  23. INTEGER, SAVE :: nmoyice !: counter for averaging
  24. INTEGER, SAVE :: nwf !: number of fields to write on disk
  25. INTEGER, SAVE,DIMENSION (:), ALLOCATABLE :: nsubindex !: subindex to be saved
  26. ! according to namelist
  27. REAL(wp), SAVE, DIMENSION(jpi,jpj,jpnoumax) :: rcmoy
  28. #if ! defined key_diainstant
  29. LOGICAL, PARAMETER :: ll_dia_inst=.false. ! local logical variable
  30. #else
  31. LOGICAL, PARAMETER :: ll_dia_inst=.true.
  32. #endif
  33. INTEGER :: ji, jj, jf, ii ! dummy loop indices and array index
  34. INTEGER :: iyear, iday, imon !
  35. CHARACTER(LEN=80) :: clname, cltext, clmode
  36. INTEGER , SAVE :: nice, nhorid, ndim, niter, ndepid
  37. INTEGER , DIMENSION( jpij ) , SAVE :: ndex51
  38. !!-------------------------------------------------------------------
  39. IF ( numit == nstart ) THEN
  40. CALL lim_wri_init
  41. nwf = 0
  42. ii = 0
  43. IF (lwp ) THEN
  44. WRITE(numout,*) 'lim_wri : Write ice outputs in dimg'
  45. WRITE(numout,*) '~~~~~~~~'
  46. WRITE(numout,*) ' According to namelist_ice, following fields saved:'
  47. DO jf =1, noumef
  48. IF (nc(jf) == 1 ) THEN
  49. WRITE(numout,* ) ' -',titn(jf), nam(jf), uni(jf)
  50. ENDIF
  51. END DO
  52. ENDIF
  53. DO jf = 1, noumef
  54. IF (nc(jf) == 1 ) nwf = nwf + 1
  55. END DO
  56. ALLOCATE( nsubindex (nwf) )
  57. DO jf = 1, noumef
  58. IF (nc(jf) == 1 ) THEN
  59. ii = ii +1
  60. nsubindex(ii) = jf
  61. END IF
  62. END DO
  63. zsto = rdt_ice
  64. zout = nwrite * rdt_ice / nn_fsbc
  65. zsec = 0.
  66. niter = 0
  67. zdept(1) = 0.
  68. nmoyice = 0
  69. ENDIF
  70. #if ! defined key_diainstant
  71. !-- calculs des valeurs instantanees
  72. zcmo(:,:, 1:jpnoumax ) = 0.e0
  73. DO jj = 2 , jpjm1
  74. DO ji = 2 , jpim1 ! NO vector opt.
  75. zindh = MAX( 0._wp , SIGN( 1._wp , ht_i(ji,jj,1) * (1.0 - frld(ji,jj) ) - 0.10 ) )
  76. zinda = MAX( 0._wp , SIGN( 1._wp , ( 1.0 - frld(ji,jj) ) - 0.10 ) )
  77. zindb = zindh * zinda
  78. ztmu = MAX( 0.5 * 1._wp , ( umask(ji,jj,1) + umask(ji+1,jj,1) + umask(ji,jj+1,1) + umask(ji+1,jj+1,1) ) )
  79. zcmo(ji,jj,1) = ht_s (ji,jj,1)
  80. zcmo(ji,jj,2) = ht_i (ji,jj,1)
  81. zcmo(ji,jj,3) = 0.
  82. zcmo(ji,jj,4) = frld (ji,jj)
  83. zcmo(ji,jj,5) = sist (ji,jj)
  84. zcmo(ji,jj,6) = fhtur (ji,jj)
  85. zcmo(ji,jj,7) = zindb * ( u_ice(ji,jj ) * umask(ji,jj,1) + u_ice(ji+1,jj ) * umask(ji+1,jj,1) &
  86. + u_ice(ji,jj+1) * umask(ji,jj+1,1) + u_ice(ji+1,jj+1) * umask(ji+1,jj+1,1) ) &
  87. / ztmu
  88. zcmo(ji,jj,8) = zindb * ( v_ice(ji,jj ) * umask(ji,jj,1) + v_ice(ji+1,jj ) * umask(ji+1,jj,1) &
  89. + v_ice(ji,jj+1) * umask(ji,jj+1,1) + v_ice(ji+1,jj+1) * umask(ji+1,jj+1,1) ) &
  90. / ztmu
  91. zcmo(ji,jj,9) = sst_m(ji,jj)
  92. zcmo(ji,jj,10) = sss_m(ji,jj)
  93. zcmo(ji,jj,11) = qns(ji,jj) + qsr(ji,jj)
  94. zcmo(ji,jj,12) = qsr(ji,jj)
  95. zcmo(ji,jj,13) = qns(ji,jj)
  96. ! See thersf for the coefficient
  97. zcmo(ji,jj,14) = - sfx (ji,jj) * rday ! converted in Kg/m2/day = mm/day
  98. zcmo(ji,jj,15) = utau_ice(ji,jj)
  99. zcmo(ji,jj,16) = vtau_ice(ji,jj)
  100. zcmo(ji,jj,17) = qsr (ji,jj)
  101. zcmo(ji,jj,18) = qns(ji,jj)
  102. zcmo(ji,jj,19) = sprecip(ji,jj)
  103. END DO
  104. END DO
  105. ! Cumulates values between outputs
  106. rcmoy(:,:,:)= rcmoy(:,:,:) + zcmo(:,:,:)
  107. nmoyice = nmoyice + 1
  108. ! compute mean value if it is time to write on file
  109. IF ( MOD(numit,nwrite) == 0 ) THEN
  110. rcmoy(:,:,:) = rcmoy(:,:,:) / FLOAT(nmoyice)
  111. #else
  112. IF ( MOD(numit,nwrite) == 0 ) THEN
  113. ! case of instantaneaous output rcmoy(:,:, 1:jpnoumax ) = 0.e0
  114. DO jj = 2 , jpjm1
  115. DO ji = 2 , jpim1 ! NO vector opt.
  116. zindh = MAX( 0._wp , SIGN( 1._wp , ht_i(ji,jj,1) * (1.0 - frld(ji,jj) ) - 0.10 ) )
  117. zinda = MAX( 0._wp , SIGN( 1._wp , ( 1.0 - frld(ji,jj) ) - 0.10 ) )
  118. zindb = zindh * zinda
  119. ztmu = MAX( 0.5 * 1._wp , ( umask(ji,jj,1) + umask(ji+1,jj,1) + umask(ji,jj+1,1) + umask(ji+1,jj+1,1) ) )
  120. rcmoy(ji,jj,1) = ht_s (ji,jj,1)
  121. rcmoy(ji,jj,2) = ht_i (ji,jj,1)
  122. rcmoy(ji,jj,3) = 0.
  123. rcmoy(ji,jj,4) = frld (ji,jj)
  124. rcmoy(ji,jj,5) = sist (ji,jj)
  125. rcmoy(ji,jj,6) = fhtur (ji,jj)
  126. rcmoy(ji,jj,7) = zindb * ( u_ice(ji,jj ) * umask(ji,jj,1) + u_ice(ji+1,jj ) * umask(ji+1,jj,1) &
  127. + u_ice(ji,jj+1) * umask(ji,jj+1,1) + u_ice(ji+1,jj+1) * umask(ji+1,jj+1,1) ) &
  128. / ztmu
  129. rcmoy(ji,jj,8) = zindb * ( v_ice(ji,jj ) * umask(ji,jj,1) + v_ice(ji+1,jj ) * umask(ji+1,jj,1) &
  130. + v_ice(ji,jj+1) * umask(ji,jj+1,1) + v_ice(ji+1,jj+1) * umask(ji+1,jj+1,1) ) &
  131. / ztmu
  132. rcmoy(ji,jj,9) = sst_m(ji,jj)
  133. rcmoy(ji,jj,10) = sss_m(ji,jj)
  134. rcmoy(ji,jj,11) = qns(ji,jj) + qsr(ji,jj)
  135. rcmoy(ji,jj,12) = qsr(ji,jj)
  136. rcmoy(ji,jj,13) = qns(ji,jj)
  137. ! See thersf for the coefficient
  138. rcmoy(ji,jj,14) = - sfx (ji,jj) * rday ! converted in mm/day
  139. rcmoy(ji,jj,15) = utau_ice(ji,jj)
  140. rcmoy(ji,jj,16) = vtau_ice(ji,jj)
  141. rcmoy(ji,jj,17) = qsr(ji,jj)
  142. rcmoy(ji,jj,18) = qns(ji,jj)
  143. rcmoy(ji,jj,19) = sprecip(ji,jj)
  144. END DO
  145. END DO
  146. #endif
  147. !
  148. niter = niter + 1
  149. DO jf = 1 , noumef
  150. zfield(:,:) = (rcmoy(:,:,jf) * cmulti(jf) + cadd(jf)) * tmask(:,:,1)
  151. IF ( jf == 7 .OR. jf == 8 .OR. jf == 15 .OR. jf == 16 ) THEN
  152. CALL lbc_lnk( zfield, 'T', -1. )
  153. ELSE
  154. CALL lbc_lnk( zfield, 'T', 1. )
  155. ENDIF
  156. rcmoy(:,:,jf) = zfield(:,:)
  157. END DO
  158. IF (ll_dia_inst) THEN
  159. clmode='instantaneous'
  160. ELSE
  161. WRITE(clmode,'(f5.1,a)' ) nwrite*rdt/86400.,' days average'
  162. END IF
  163. iyear = ndastp/10000
  164. imon = (ndastp-iyear*10000)/100
  165. iday = ndastp - imon*100 - iyear*10000
  166. WRITE(clname,9000) TRIM(cexper),'ICEMOD',iyear,imon,iday
  167. cltext=TRIM(cexper)//' ice modele output'//TRIM(clmode)
  168. CALL dia_wri_dimg (clname, cltext, rcmoy, nwf , 'I', nsubindex)
  169. 9000 FORMAT(a,"_",a,"_y",i4.4,"m",i2.2,"d",i2.2,".dimgproc")
  170. rcmoy(:,:,:) = 0.0
  171. nmoyice = 0
  172. END IF ! MOD(numit, nwrite == 0 ) !
  173. END SUBROUTINE lim_wri