source: trunk/LMDZ.MARS/libf/phymars/swmain.F @ 1972

Last change on this file since 1972 was 1266, checked in by aslmd, 11 years ago

LMDZ.MARS
IMPORTANT CHANGE

  • Remove all reference/use of nlayermx and dimphys.h
  • Made use of automatic arrays whenever arrays are needed with dimension nlayer
  • Remove lots of obsolete reference to dimensions.h
  • Converted iono.h and param_v4.h into corresponding modules

(with embedded subroutine to allocate arrays)
(no arrays allocated if thermosphere not used)

  • Deleted param.h and put contents into module param_v4_h
  • Adapted testphys1d, newstart, etc...
  • Made DATA arrays in param_read to be initialized by subroutine

fill_data_thermos in module param_v4_h

  • Optimized computations in paramfoto_compact (twice less dlog10 calculations)
  • Checked consistency before/after modification in debug mode
  • Checked performance is not impacted (same as before)
File size: 6.3 KB
Line 
1      SUBROUTINE SWMAIN ( KDLON, KFLEV,
2     $                PCST, albedo,
3     $                PRMU0, PDP, PPLEV, aerosol,PFRACT,
4     $                PHEAT, PFLUXD,PFLUXU,
5     &                QVISsQREF3d,omegaVIS3d,gVIS3d)
6
7      use dimradmars_mod, only: ndlo2, ndlon, nflev,
8     &                          nsun,naerkind
9      use yomlw_h, only: nlaylte, gcp
10      IMPLICIT NONE
11     
12#include "callkeys.h"
13c     
14c     PURPOSE.
15c     --------
16c     
17c     This routine computes the shortwave (solar wavelength)
18c     radiation fluxes in two spectral intervals
19c     and heating rate on the first "nlaylte" layers.
20C     
21c     Francois Forget (2000), adapted from
22C     Fouquart and Bonnel's ECMWF program
23c
24C     IMPLICIT ARGUMENTS :
25C     --------------------
26C     
27C     ==== INPUTS ===
28c
29c    KDLON :  number of horizontal grid points
30c    PCST  :  Solar constant on Mars (W.m-2)
31c    albedo   hemispheric surface albedo
32c                         albedo (i,1) : mean albedo for solar band#1
33c                                        (see below)
34c                         albedo (i,2) : mean albedo for solar band#2
35c                                        (see below)
36c    PRMU0 :         cos of solar zenith angle (=1 when sun at zenith)
37c    PDP :           Layer thickness (Pa)
38c    PPLEV           pressure (Pa) at boundaries of each layer
39c   aerosol               aerosol extinction optical depth
40c                         at reference wavelength "longrefvis" set
41c                         in dimradmars_mod , in each layer, for one of
42c                         the "naerkind" kind of aerosol optical properties.
43c    Pfract :        day fraction of the time interval
44c                          =1 during the full day ; =0 during the night
45c    QVISsQREF3d,omegaVIS3d,gVIS3d Aerosol optical properties
46c
47C     ==== OUTPUTS ===
48c    PHEAT :         Heating rate (K/s)
49c    PFLUXD :        SW downward flux at boundaries of each layer (W.m-2)
50c    PFLUXU :        SW upward flux at boundaries of each layer (W.m-2)
51C     
52C     ----------
53C     
54C-----------------------------------------------------------------------
55C     
56C     
57C-----------------------------------------------------------------------
58C     
59C     ARGUMENTS
60C     ---------
61     
62      INTEGER KDLON, KFLEV
63      REAL ZPSOL(NDLO2), aerosol(NDLO2,KFLEV,naerkind),PRMU0(NDLO2)
64      real PCST
65      REAL albedo(NDLO2,2)
66      REAL PDP(NDLO2,KFLEV)
67      REAL PPLEV(NDLO2,KFLEV+1)
68      REAL PHEAT(NDLO2,KFLEV)
69      REAL PFRACT(NDLO2)
70      real PFLUXD(NDLON,NFLEV+1,2)
71      real PFLUXU(NDLON,NFLEV+1,2)
72      REAL :: QVISsQREF3d(NDLO2,KFLEV,nsun,naerkind)
73      REAL :: omegaVIS3d(NDLO2,KFLEV,nsun,naerkind)
74      REAL :: gVIS3d(NDLO2,KFLEV,nsun,naerkind)
75     
76C     LOCAL ARRAYS
77C     ------------
78     
79      REAL ZDSIG(NDLON,NFLEV), ZFACT(NDLON)
80     S     ,  ZFD(NDLON,NFLEV+1)
81     S     ,  ZFU(NDLON,NFLEV+1)
82     S     ,  ZRMU(NDLON), ZSEC(NDLON)
83     S     ,  ZUD(NDLON,3,NFLEV+1), ZUM(NDLON,NFLEV+1)
84      REAL ZSIGN(NDLON),  ZSIGO(NDLON)
85
86c following line has been changed, kflev--->nflev (to avoid error message
87c when compiling on NASA Ames Sun)
88      REAL ZFDOWN(NDLO2,NFLEV+1),ZFUP(NDLO2,NFLEV+1)
89
90      integer jl, jk, jkp1, jkl
91      integer INU
92      real  zdfnet
93
94C     ------------------------------------------------------------------
95C     Initializations :
96C     ------------------------------------------------------------------
97
98c     Incident Solar flux and corrected angle in the atmosphere
99c     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
100      DO JL = 1 , KDLON
101c        Incident Flux at the top of the atmosphere
102         ZFACT(JL)= PRMU0(JL) * PCST * PFRACT(JL)
103
104c        Cos of solar zenith angle CORRECTED for high zenith angle
105       if (PRMU0(JL).GT.0) then
106         ZRMU(JL)=SQRT(1224.* PRMU0(JL) * PRMU0(JL) + 1.) / 35.
107       else
108         ZRMU(JL)= 1. / 35.
109       endif
110         ZSEC(JL)=1./ZRMU(JL)
111      END DO
112
113c     Calcul of ZDSIG  (thickness of layers in sigma coordinates)
114c     ~~~~~~~~~~~~~~~
115      DO JL = 1 , KDLON
116         ZSIGO(JL) = 1.0
117         ZPSOL(JL) = PPLEV(JL,1)
118      END DO
119      DO JK = 1 , nlaylte
120         JKP1 = JK + 1
121         JKL = nlaylte+1 - JK
122         DO  JL = 1 , KDLON
123            ZSIGN(JL) = PPLEV(JL,JKP1) / PPLEV(JL,1)
124            ZDSIG(JL,JK) = ZSIGO(JL) - ZSIGN(JL)
125            ZSIGO(JL) = ZSIGN(JL)
126         END DO
127      END DO
128
129C------------------------------------------------------------------
130C          LOOP ON SPECTRAL INTERVAL in solar spectrum
131C------------------------------------------------------------------
132c  2 spectral interval in solar spectrum :
133c  - INU=1: between wavelength "long1vis" and "long2vis" set in dimradmars_mod
134c  - INU=2: between wavelength "long2vis" and "long3vis" set in dimradmars_mod
135
136      DO INU = 1,2
137
138! NB: swrtype is set in callkeys.h
139        if (swrtype.eq.1) then ! Fouquart
140          CALL SWR_FOUQUART( KDLON, kflev, INU
141     &     ,  aerosol,QVISsQREF3d,omegaVIS3d,gVIS3d
142     &     ,  albedo,ZDSIG,ZPSOL,ZRMU,ZSEC
143     &     ,  ZFD,ZFU )
144        else
145          if (swrtype.eq.2) then ! Toon
146            CALL SWR_TOON( KDLON, kflev, INU
147     &       ,  aerosol,QVISsQREF3d,omegaVIS3d,gVIS3d
148     &       ,  albedo,ZDSIG,ZPSOL,ZRMU,ZSEC
149     &       ,  ZFD,ZFU )
150          else
151            write(*,*) "swmain: invalid swrtype value !!"
152            stop
153          endif ! of if (swrtype.eq.2)
154        endif ! of if (swrtype.eq.1)
155       
156         DO JK = 1 , nlaylte+1
157            DO  JL = 1 , KDLON
158              PFLUXD(JL,JK,INU)=ZFD(JL,JK)*ZFACT(JL)
159              PFLUXU(JL,JK,INU)=ZFU(JL,JK)*ZFACT(JL)
160            END DO
161         END DO
162      END DO ! of DO INU=1,2
163
164C     ------------------------------------------------------
165C     HEATING RATES
166C     ------------------------------------------------------
167
168      DO JK = 1 , nlaylte+1
169         DO  JL = 1 , KDLON
170c           wavelength integrated flux at every level:
171            ZFUP(JL,JK)= (PFLUXU(JL,JK,1)+ PFLUXU(JL,JK,2))
172            ZFDOWN(JL,JK)= (PFLUXD(JL,JK,1)+ PFLUXD(JL,JK,2))
173         END DO
174      END DO
175     
176      DO JK = 1 , nlaylte
177         DO  JL = 1 , KDLON
178            ZDFNET = ZFUP (JL,JK  ) - ZFDOWN(JL,JK  )
179     S              -ZFUP (JL,JK+1) + ZFDOWN(JL,JK+1)
180c           Heating rate
181            PHEAT(JL,JK) = gcp * ZDFNET / PDP(JL,JK)
182         END DO
183      END DO
184
185      RETURN
186      END
Note: See TracBrowser for help on using the repository browser.