file_cariolle.F90 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. #define TRACEBACK write (gol,'("in ",a," (",a,i6,")")') rname, __FILE__, __LINE__ ; call goErr
  2. #define IF_NOTOK_RETURN(action) if (status/=0) then; TRACEBACK; action; return; end if
  3. #define IF_ERROR_RETURN(action) if (status> 0) then; TRACEBACK; action; return; end if
  4. !
  5. #include "tm5.inc"
  6. !
  7. !----------------------------------------------------------------------
  8. ! READ_CAR reads the 7 coefficients for the ozone photochemistry
  9. ! linear parametrisation for each month and put it on a
  10. ! grid (regular along the latitudes)
  11. !
  12. ! Parametrisation of the ozone photochemistry
  13. !
  14. ! d r
  15. ! --- = < P - L > +
  16. ! dt
  17. ! d (P - L)
  18. ! < --------- > ( r - < r > ) +
  19. ! d r
  20. !
  21. ! d (P - L)
  22. ! < --------- > ( T - < T > ) +
  23. ! d T
  24. !
  25. ! d (P - L)
  26. ! < --------- > ( S - < S > )
  27. ! d S
  28. !
  29. ! with r : volumic ozone mixing ratio
  30. ! T : temperature
  31. ! S : ozone column above a point
  32. ! P : photochemical production of ozone
  33. ! L : photochemical destruction of ozone
  34. !
  35. ! Terms between < > denote two-dimensional variables at photochemical
  36. ! equilibrium (from the 2D photochemical model). Other terms are
  37. ! three-dimensional variables (from the General Circulation Model)
  38. !
  39. !
  40. ! coefficient 1 : < P - L > units : s-1
  41. !
  42. ! d (P - L)
  43. ! coefficient 2 : < --------- > units : kg kg-1 s-1
  44. ! d r
  45. !
  46. ! coefficient 3 : < r > units : kg kg-1
  47. !
  48. ! d (P - L)
  49. ! coefficient 4 : < --------- > units : kg kg-1 s-1 K-1
  50. ! d T
  51. !
  52. ! coefficient 5 : < T > units : K
  53. !
  54. ! d (P - L)
  55. ! coefficient 6 : < --------- > units : kg cm2 kg-1 s-1 molecule-1
  56. ! d S
  57. !
  58. ! coefficient 7 : < S > units : molecule cm-2
  59. !
  60. ! output : PHI (64) array containing latitudes of the grid
  61. ! PRES (64x26/45x12) array containing pressures of the grid
  62. ! COEFF(64x26/45x7x12) array containing the coefficients on the
  63. ! grid
  64. !----------------------------------------------------------------------
  65. module file_cariolle
  66. implicit none
  67. ! --- in/out ---------------------------------
  68. private
  69. public :: Cariolle_Info
  70. public :: Cariolle_Read
  71. ! --- const -----------------------------
  72. character(len=*), parameter :: mname = 'file_cariolle'
  73. ! dimensions
  74. integer, parameter :: nlat = 64
  75. integer, parameter :: nlev = 45 ! 45 = v2.1 ! 26 = v1.0
  76. integer, parameter :: nc = 7
  77. integer, parameter :: nt = 12
  78. contains
  79. ! =====================================================================
  80. subroutine Cariolle_Info( status, nlats, nlevs, ncs )
  81. ! --- in/out -------------------------
  82. integer, intent(inout) :: status
  83. integer, intent(out), optional :: nlats
  84. integer, intent(out), optional :: nlevs
  85. integer, intent(out), optional :: ncs
  86. ! --- const ---------------------------------
  87. character(len=*), parameter :: rname = mname//'/Cariolle_Info'
  88. ! --- begin ---------------------------
  89. ! trap previous errors:
  90. if (status>0) return
  91. ! return info:
  92. if ( present(nlats) ) nlats = nlat
  93. if ( present(nlevs) ) nlevs = nlev
  94. if ( present(ncs ) ) ncs = nc
  95. ! ok
  96. status = 0
  97. end subroutine Cariolle_Info
  98. ! ***
  99. subroutine Cariolle_Read( fname, imonth, phi, pres, coeff, status )
  100. use GO , only : gol, goErr
  101. use Binas, only : Dobs
  102. ! --- in/out ---------------------------------
  103. character(len=*), intent(in) :: fname
  104. integer, intent(in) :: imonth
  105. real, intent(out) :: phi(nlat) ! deg
  106. real, intent(out) :: pres(nlat,nlev) ! Pa , top->surf
  107. real, intent(out) :: coeff(nlat,nlev,nc)
  108. integer, intent(inout) :: status
  109. ! --- const ---------------------------------
  110. character(len=*), parameter :: rname = mname//'/Cariolle_Read'
  111. ! --- local -----------------------------------
  112. integer :: fu
  113. logical :: opened
  114. integer :: k
  115. integer :: ic, it
  116. ! --- begin -----------------------------------
  117. ! trap previous errors:
  118. if (status>0) return
  119. ! select free file unit:
  120. fu = 123
  121. do
  122. inquire( unit=fu, opened=opened )
  123. if ( .not. opened ) exit
  124. fu = fu + 1
  125. end do
  126. !
  127. ! open file:
  128. !
  129. open( fu, file=trim(fname), form='formatted', &
  130. status='old', iostat=status )
  131. if ( status /= 0 ) then
  132. write (gol,'("from open Cariolle coeff file:")'); call goErr
  133. write (gol,'(" ",a)') trim( fname); call goErr
  134. write (gol,'("in ",a)') rname; call goErr; status=1; return
  135. end if
  136. !
  137. ! read the header
  138. !
  139. ! 98 ==> CARIOLLE V1.0
  140. ! 122 ==> CARIOLLE V2.1
  141. !
  142. do k = 1, 122
  143. read (fu,*,iostat=status)
  144. if ( status /= 0 ) then
  145. write (gol,'("reading from Cariolle coeff file:")'); call goErr
  146. write (gol,'(" file : ",a)') trim( fname); call goErr
  147. write (gol,'(" line : ",i4)') k; call goErr
  148. write (gol,'("in ",a)') rname; call goErr; status=1; return
  149. end if
  150. end do
  151. !
  152. ! read the latitudes
  153. !
  154. read (fu,*)
  155. read (fu,'(10f7.2)',iostat=status) phi
  156. if ( status /= 0 ) then
  157. write (gol,'("reading latitudes Cariolle coeff file:")'); call goErr
  158. write (gol,'(" file : ",a)') trim( fname); call goErr
  159. write (gol,'("in ",a)') rname; call goErr; status=1; return
  160. end if
  161. !
  162. ! read the data (pressure + 7 coefficients)
  163. !
  164. ! loop for each month of the year
  165. do it = 1, imonth
  166. !
  167. read (fu,*)
  168. read (fu,*)
  169. read (fu,'(10f9.2)',iostat=status) pres ! hPa
  170. if ( status /= 0 ) then
  171. write (gol,'("reading pressures from Cariolle coeff file:")'); call goErr
  172. write (gol,'(" file : ", a)') trim( fname); call goErr
  173. write (gol,'(" month : ",i2)') it ; call goErr
  174. write (gol,'("in ",a)') rname; call goErr; status=1; return
  175. end if
  176. !
  177. do ic = 1, nc
  178. !
  179. ! loop on the 7 coefficients
  180. read (fu,*)
  181. read (fu,'(10e13.5)',iostat=status) coeff(:,:,ic)
  182. if ( status /= 0 ) then
  183. write (gol,'("reading Cariolle coeffs:")'); call goErr
  184. write (gol,'(" file : ",a )') trim( fname); call goErr
  185. write (gol,'(" month : ",i2)') it ; call goErr
  186. write (gol,'(" coef : ",i2)') ic ; call goErr
  187. write (gol,'("in ",a)') rname; call goErr; status=1; return
  188. end if
  189. end do
  190. !
  191. end do
  192. !
  193. ! close file
  194. !
  195. close( fu, iostat=status )
  196. if ( status /= 0 ) then
  197. write (gol,'("closing Cariolle coeff file:")'); call goErr
  198. write (gol,'(" file : ",a)') trim( fname); call goErr
  199. write (gol,'("in ",a)') rname; call goErr; status=1; return
  200. end if
  201. !
  202. ! unit conversion
  203. !
  204. ! pressures from hPa to Pa :
  205. pres = pres * 1.0e2
  206. !
  207. ! done
  208. !
  209. ! ok
  210. status = 0
  211. end subroutine Cariolle_Read
  212. end module file_cariolle