LMDZ
cosp_isccp_simulator.F90
Go to the documentation of this file.
1 ! (c) British Crown Copyright 2008, the Met Office.
2 ! All rights reserved.
3 !
4 ! Redistribution and use in source and binary forms, with or without modification, are permitted
5 ! provided that the following conditions are met:
6 !
7 ! * Redistributions of source code must retain the above copyright notice, this list
8 ! of conditions and the following disclaimer.
9 ! * Redistributions in binary form must reproduce the above copyright notice, this list
10 ! of conditions and the following disclaimer in the documentation and/or other materials
11 ! provided with the distribution.
12 ! * Neither the name of the Met Office nor the names of its contributors may be used
13 ! to endorse or promote products derived from this software without specific prior written
14 ! permission.
15 !
16 ! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
17 ! IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
18 ! FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
19 ! CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 ! DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 ! DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
22 ! IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
23 ! OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 
27  USE mod_cosp_types
28  IMPLICIT NONE
29 
30 CONTAINS
31 
32 
33 !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
34 !-------------- SUBROUTINE COSP_ISCCP_SIMULATOR -----------------
35 !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
36 SUBROUTINE cosp_isccp_simulator(gbx,sgx,y)
37 
38  ! Arguments
39  type(cosp_gridbox),intent(in) :: gbx ! Gridbox info
40  type(cosp_subgrid),intent(in) :: sgx ! Subgridbox info
41  type(cosp_isccp),intent(inout) :: y ! ISCCP simulator output
42 
43  ! Local variables
44  integer :: i,Nlevels,Npoints
45  real :: pfull(gbx%npoints, gbx%nlevels)
46  real :: phalf(gbx%npoints, gbx%nlevels + 1)
47  real :: qv(gbx%npoints, gbx%nlevels)
48  real :: cc(gbx%npoints, gbx%nlevels)
49  real :: conv(gbx%npoints, gbx%nlevels)
50  real :: dtau_s(gbx%npoints, gbx%nlevels)
51  real :: dtau_c(gbx%npoints, gbx%nlevels)
52  real :: at(gbx%npoints, gbx%nlevels)
53  real :: dem_s(gbx%npoints, gbx%nlevels)
54  real :: dem_c(gbx%npoints, gbx%nlevels)
55  real :: frac_out(gbx%npoints, gbx%ncolumns, gbx%nlevels)
56  integer :: sunlit(gbx%npoints)
57 
58  nlevels = gbx%Nlevels
59  npoints = gbx%Npoints
60  ! Flip inputs. Levels from TOA to surface
61  pfull = gbx%p(:,nlevels:1:-1)
62  phalf(:,1) = 0.0 ! Top level
63  phalf(:,2:nlevels+1) = gbx%ph(:,nlevels:1:-1)
64  qv = gbx%sh(:,nlevels:1:-1)
65  cc = 0.999999*gbx%tca(:,nlevels:1:-1)
66  conv = 0.999999*gbx%cca(:,nlevels:1:-1)
67  dtau_s = gbx%dtau_s(:,nlevels:1:-1)
68  dtau_c = gbx%dtau_c(:,nlevels:1:-1)
69  at = gbx%T(:,nlevels:1:-1)
70  dem_s = gbx%dem_s(:,nlevels:1:-1)
71  dem_c = gbx%dem_c(:,nlevels:1:-1)
72  frac_out(1:npoints,:,1:nlevels) = sgx%frac_out(1:npoints,:,nlevels:1:-1)
73  sunlit = int(gbx%sunlit)
74  call icarus(0,0,gbx%npoints,sunlit,gbx%nlevels,gbx%ncolumns, &
75  pfull,phalf,qv,cc,conv,dtau_s,dtau_c, &
76  gbx%isccp_top_height,gbx%isccp_top_height_direction, &
77  gbx%isccp_overlap,frac_out, &
78  gbx%skt,gbx%isccp_emsfc_lw,at,dem_s,dem_c,y%fq_isccp,y%totalcldarea, &
79  y%meanptop,y%meantaucld,y%meanalbedocld, &
80  y%meantb,y%meantbclr,y%boxtau,y%boxptop)
81 
82  ! Flip outputs. Levels from surface to TOA
83  ! --- (npoints,tau=7,pressure=7)
84  y%fq_isccp(:,:,:) = y%fq_isccp(:,:,7:1:-1)
85 
86  ! Change boxptop from hPa to Pa. This avoids using UDUNITS in CMOR
87 ! y%boxptop = y%boxptop*100.0
88 
89  ! Check if there is any value slightly greater than 1
90  where ((y%totalcldarea > 1.0-1.e-5) .and. (y%totalcldarea < 1.0+1.e-5))
91  y%totalcldarea = 1.0
92  endwhere
93 
94 END SUBROUTINE cosp_isccp_simulator
95 
96 END MODULE mod_cosp_isccp_simulator
subroutine cosp_isccp_simulator(gbx, sgx, y)
subroutine icarus(debug, debugcol, npoints, sunlit, nlev, ncol, pfull, phalf, qv, cc, conv, dtau_s, dtau_c, top_height, top_height_direction, overlap, frac_out, skt, emsfc_lw, at, dem_s, dem_c, fq_isccp, totalcldarea, meanptop, meantaucld, meanalbedocld, meantb, meantbclr, boxtau, boxptop)
Definition: icarus.F:34