! First include the set of model-wide compiler flags #include "tm5.inc" module MTAmf ! ! Module containing the structure that stores the AMF lookup table and description ! Henk Eskes, KNMI, Sept 2015 ! implicit none private public :: TAmfLut public :: AllocateAmfLut, DeAllocateAmfLut ! ------------------------------------------------------------- ! type definition for memory block containing ! the lookup table for the air-mass factors: ! amf ( mu, mu0, dphi, p, p_surf, albedo ) ! ------------------------------------------------------------- type TAmfLut integer :: mmu ! dimension of mu integer :: mmu0 ! dimension of mu0 integer :: mazi ! dimension of azi integer :: mpres ! dimension of pres integer :: mspres ! dimension of spres integer :: malbedo ! dimension of albedo real, dimension(:), allocatable :: mu ! cosine viewing angles, increasing [0.3,1] real, dimension(:), allocatable :: mu0 ! cosine solar zenith angles, increasing [0.05,1] real, dimension(:), allocatable :: azi ! azimuth angles, increasing [0,180] real, dimension(:), allocatable :: pres ! pressure levels, decreasing [1055,0.0003] real, dimension(:), allocatable :: spres ! surface pressure, decreasing [1048,130] real, dimension(:), allocatable :: albedo ! albedos, increasing [0,1] real, dimension(:,:,:,:,:,:), allocatable :: amf ! the lookup table ! amf ( mu, mu0, dphi, p, p_surf, albedo ) end type TAmfLut contains subroutine AllocateAmfLut ( mmu, mmu0, mazi, mpres, mspres, malbedo, amfLut ) !======================================================================= ! ! AllocateAmfLut: allocate storage for the AMF table ! Henk Eskes, KNMI, sept 2015 ! input: ! mmu = number of cosine viewing angles ! mmu0 = number of cosine solar zenith angles ! mazi = number of azimuth angles ! mpres = number of pressures ! mspres = number of surface pressures ! malbedo = number of albedos ! output: ! amfLut : structure with arrays allocated ! !======================================================================= implicit none integer, intent(in) :: mmu, mmu0, mazi, mpres, mspres, malbedo type(TAmfLut), intent(inout) :: amfLut ! begin code amfLut%mmu = mmu amfLut%mmu0 = mmu0 amfLut%mazi = mazi amfLut%mpres = mpres amfLut%mspres = mspres amfLut%malbedo = malbedo allocate ( amfLut%mu(mmu) ) allocate ( amfLut%mu0(mmu0) ) allocate ( amfLut%azi(mazi) ) allocate ( amfLut%pres(mpres) ) allocate ( amfLut%spres(mspres) ) allocate ( amfLut%albedo(malbedo) ) allocate ( amfLut%amf(mmu, mmu0, mazi, mpres, mspres, malbedo) ) end subroutine AllocateAmfLut subroutine DeAllocateAmfLut ( amfLut ) !======================================================================= ! ! DeAllocateAmfLut: deallocate storage of the AMF table ! Henk Eskes, KNMI, sept 2015 ! !======================================================================= implicit none type(TAmfLut), intent(inout) :: amfLut ! begin code amfLut%mmu = 0 amfLut%mmu0 = 0 amfLut%mazi = 0 amfLut%mpres = 0 amfLut%mspres = 0 amfLut%malbedo = 0 if ( allocated ( amfLut%mu ) ) deallocate ( amfLut%mu ) if ( allocated ( amfLut%mu0 ) ) deallocate ( amfLut%mu0 ) if ( allocated ( amfLut%azi ) ) deallocate ( amfLut%azi ) if ( allocated ( amfLut%pres ) ) deallocate ( amfLut%pres ) if ( allocated ( amfLut%spres ) ) deallocate ( amfLut%spres ) if ( allocated ( amfLut%albedo ) ) deallocate ( amfLut%albedo ) if ( allocated ( amfLut%amf ) ) deallocate ( amfLut%amf ) end subroutine DeAllocateAmfLut end module MTAmf