MTAmf.F90 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. ! First include the set of model-wide compiler flags
  2. #include "tm5.inc"
  3. module MTAmf
  4. !
  5. ! Module containing the structure that stores the AMF lookup table and description
  6. ! Henk Eskes, KNMI, Sept 2015
  7. !
  8. implicit none
  9. private
  10. public :: TAmfLut
  11. public :: AllocateAmfLut, DeAllocateAmfLut
  12. ! -------------------------------------------------------------
  13. ! type definition for memory block containing
  14. ! the lookup table for the air-mass factors:
  15. ! amf ( mu, mu0, dphi, p, p_surf, albedo )
  16. ! -------------------------------------------------------------
  17. type TAmfLut
  18. integer :: mmu ! dimension of mu
  19. integer :: mmu0 ! dimension of mu0
  20. integer :: mazi ! dimension of azi
  21. integer :: mpres ! dimension of pres
  22. integer :: mspres ! dimension of spres
  23. integer :: malbedo ! dimension of albedo
  24. real, dimension(:), allocatable :: mu ! cosine viewing angles, increasing [0.3,1]
  25. real, dimension(:), allocatable :: mu0 ! cosine solar zenith angles, increasing [0.05,1]
  26. real, dimension(:), allocatable :: azi ! azimuth angles, increasing [0,180]
  27. real, dimension(:), allocatable :: pres ! pressure levels, decreasing [1055,0.0003]
  28. real, dimension(:), allocatable :: spres ! surface pressure, decreasing [1048,130]
  29. real, dimension(:), allocatable :: albedo ! albedos, increasing [0,1]
  30. real, dimension(:,:,:,:,:,:), allocatable :: amf ! the lookup table
  31. ! amf ( mu, mu0, dphi, p, p_surf, albedo )
  32. end type TAmfLut
  33. contains
  34. subroutine AllocateAmfLut ( mmu, mmu0, mazi, mpres, mspres, malbedo, amfLut )
  35. !=======================================================================
  36. !
  37. ! AllocateAmfLut: allocate storage for the AMF table
  38. ! Henk Eskes, KNMI, sept 2015
  39. ! input:
  40. ! mmu = number of cosine viewing angles
  41. ! mmu0 = number of cosine solar zenith angles
  42. ! mazi = number of azimuth angles
  43. ! mpres = number of pressures
  44. ! mspres = number of surface pressures
  45. ! malbedo = number of albedos
  46. ! output:
  47. ! amfLut : structure with arrays allocated
  48. !
  49. !=======================================================================
  50. implicit none
  51. integer, intent(in) :: mmu, mmu0, mazi, mpres, mspres, malbedo
  52. type(TAmfLut), intent(inout) :: amfLut
  53. ! begin code
  54. amfLut%mmu = mmu
  55. amfLut%mmu0 = mmu0
  56. amfLut%mazi = mazi
  57. amfLut%mpres = mpres
  58. amfLut%mspres = mspres
  59. amfLut%malbedo = malbedo
  60. allocate ( amfLut%mu(mmu) )
  61. allocate ( amfLut%mu0(mmu0) )
  62. allocate ( amfLut%azi(mazi) )
  63. allocate ( amfLut%pres(mpres) )
  64. allocate ( amfLut%spres(mspres) )
  65. allocate ( amfLut%albedo(malbedo) )
  66. allocate ( amfLut%amf(mmu, mmu0, mazi, mpres, mspres, malbedo) )
  67. end subroutine AllocateAmfLut
  68. subroutine DeAllocateAmfLut ( amfLut )
  69. !=======================================================================
  70. !
  71. ! DeAllocateAmfLut: deallocate storage of the AMF table
  72. ! Henk Eskes, KNMI, sept 2015
  73. !
  74. !=======================================================================
  75. implicit none
  76. type(TAmfLut), intent(inout) :: amfLut
  77. ! begin code
  78. amfLut%mmu = 0
  79. amfLut%mmu0 = 0
  80. amfLut%mazi = 0
  81. amfLut%mpres = 0
  82. amfLut%mspres = 0
  83. amfLut%malbedo = 0
  84. if ( allocated ( amfLut%mu ) ) deallocate ( amfLut%mu )
  85. if ( allocated ( amfLut%mu0 ) ) deallocate ( amfLut%mu0 )
  86. if ( allocated ( amfLut%azi ) ) deallocate ( amfLut%azi )
  87. if ( allocated ( amfLut%pres ) ) deallocate ( amfLut%pres )
  88. if ( allocated ( amfLut%spres ) ) deallocate ( amfLut%spres )
  89. if ( allocated ( amfLut%albedo ) ) deallocate ( amfLut%albedo )
  90. if ( allocated ( amfLut%amf ) ) deallocate ( amfLut%amf )
  91. end subroutine DeAllocateAmfLut
  92. end module MTAmf