file_fortkeld.F90 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  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 Fortuin-Kelder ozone climatology
  9. !
  10. module file_fortkeld
  11. implicit none
  12. ! --- in/out --------------------------
  13. private
  14. public :: FortuinKelder_Info
  15. public :: FortuinKelder_Read
  16. ! --- const -----------------------------
  17. character(len=*), parameter :: mname = 'file_fortkeld'
  18. ! latitudes -80,-70,...,70,80
  19. integer, parameter :: nlat = 17
  20. ! fixed pressure levels:
  21. integer, parameter :: nlev = 19
  22. real, parameter :: pclim(nlev) = &
  23. (/1000.0, 700.0, 500.0, 300.0, 200.0, 150.0, &
  24. 100.0, 70.0, 50.0, 30.0, 20.0, 10.0, &
  25. 7.0, 5.0, 3.0, 2.0, 1.0, 0.5, 0.3 /)
  26. ! number of months:
  27. integer, parameter :: nmonth = 12
  28. contains
  29. ! =====================================================================
  30. subroutine FortuinKelder_Info( status, nlats, nlevs )
  31. ! --- in/out -------------------------
  32. integer, intent(inout) :: status
  33. integer, intent(out), optional :: nlats
  34. integer, intent(out), optional :: nlevs
  35. ! --- const ---------------------------------
  36. character(len=*), parameter :: rname = mname//'/FortuinKelder_Info'
  37. ! --- begin ---------------------------
  38. ! trap previous errors:
  39. if (status>0) return
  40. ! return info:
  41. if ( present(nlats) ) nlats = nlat
  42. if ( present(nlevs) ) nlevs = nlev
  43. ! ok
  44. status = 0
  45. end subroutine FortuinKelder_Info
  46. ! ***
  47. subroutine FortuinKelder_Read( fname, imonth, lats_deg, pres_Pa, o3_ppmv, status )
  48. use GO, only : gol, goErr, goPr
  49. use GO, only : goGetFU
  50. ! --- in/out --------------------------------------
  51. character(len=*), intent(in) :: fname
  52. integer, intent(in) :: imonth
  53. real, intent(out) :: lats_deg(nlat) ! deg
  54. real, intent(out) :: pres_Pa(nlev) ! Pa
  55. real, intent(out) :: o3_ppmv(nlat,nlev) ! o3 volume mixing ratio
  56. integer, intent(inout) :: status
  57. ! --- const -------------------------------------
  58. character(len=*), parameter :: rname = mname//'/FortuinKelder_Read'
  59. ! --- local --------------------------------------
  60. integer :: j, l, imon
  61. logical :: exist
  62. integer :: fu
  63. real :: row(nlat)
  64. ! --- begin --------------------------------------
  65. ! trap previous errors:
  66. if (status>0) return
  67. write (gol,'("read ozone climat for month ",i2)') imonth; call goPr
  68. ! fill latitudes
  69. do j = 1, nlat
  70. lats_deg(j) = -80.0 + (j-1)*10.0 ! deg
  71. end do
  72. ! pressure levels
  73. pres_Pa = pclim * 100.0 ! hPa -> Pa
  74. ! file exist ?
  75. inquire( file=fname, exist=exist )
  76. if ( .not. exist ) then
  77. write (gol,'("file not found : ")'); call goErr
  78. write (gol,'(" ",a)') fname; call goErr
  79. write (gol,'("in ",a)') rname; call goErr; status=1; return
  80. end if
  81. ! select free file unit:
  82. call goGetFU( fu , status )
  83. ! open file:
  84. open( fu, file=fname, iostat=status )
  85. if ( status /= 0 ) then
  86. write (gol,'("while opening Fortuin climatology file:")'); call goErr
  87. write (gol,'(" ",a)') fname; call goErr
  88. write (gol,'("in ",a)') rname; call goErr; status=1; return
  89. end if
  90. ! read original fortuin data - ozone mixing ratios
  91. ! loop over months:
  92. do imon = 1, imonth
  93. ! skip empty line:
  94. read (fu,*)
  95. ! loop over pressure levels:
  96. do l = 1, nlev
  97. ! read row for this pressure level:
  98. read (fu,'(17f9.4)',iostat=status) row
  99. if ( status /= 0 ) then
  100. write (gol,'("reading from climatology file:")'); call goErr
  101. write (gol,'(" name : ",a)') fname; call goErr
  102. write (gol,'(" month : ",i2)') imon; call goErr
  103. write (gol,'(" level : ",i2)') l; call goErr
  104. write (gol,'("in ",a)') rname; call goErr; status=1; return
  105. end if
  106. ! store ?
  107. if ( imon == imonth ) o3_ppmv(:,l) = row
  108. end do
  109. end do
  110. ! close file:
  111. close( fu, iostat=status )
  112. if ( status /= 0 ) then
  113. write (gol,'("while closing Fortuin climatology file:")'); call goErr
  114. write (gol,'(" ",a)') fname; call goErr
  115. write (gol,'("in ",a)') rname; call goErr; status=1; return
  116. end if
  117. ! ok
  118. status = 0
  119. end subroutine FortuinKelder_Read
  120. end module file_fortkeld