source: LMDZ6/trunk/libf/phylmdiso/phyaqua_mod.F90 @ 5786

Last change on this file since 5786 was 5662, checked in by Laurent Fairhead, 6 months ago

Ajout du modèle thermodynamique de glace de mer interactive améliorant les flux échangés à la surface de la banquise (Doctorat de Nicolas Michalezyk, Contact : Nicolas Michaleyk, Guillaume Gastineau)

File size: 30.6 KB
Line 
1!
2! $Id: phyaqua_mod.F90 3579 2019-10-09 13:11:07Z fairhead $
3!
4MODULE phyaqua_mod
5  ! Routines complementaires pour la physique planetaire.
6  IMPLICIT NONE
7
8CONTAINS
9
10  SUBROUTINE iniaqua(nlon,year_len,iflag_phys)
11
12    ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
13    ! Creation d'un etat initial et de conditions aux limites
14    ! (resp startphy.nc et limit.nc) pour des configurations idealisees
15    ! du modele LMDZ dans sa version terrestre.
16    ! iflag_phys est un parametre qui controle
17    ! iflag_phys = N
18    ! de 100 a 199 : aqua planetes avec SST forcees
19    ! N-100 determine le type de SSTs
20    ! de 200 a 299 : terra planetes avec Ts calcule
21
22    ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
23
24    USE dimphy, ONLY: klon
25    USE geometry_mod, ONLY : latitude
26    USE surface_data, ONLY: type_ocean, ok_veget
27    USE pbl_surface_mod, ONLY: pbl_surface_init
28    USE fonte_neige_mod, ONLY: fonte_neige_init
29#ifdef ISO
30  USE fonte_neige_mod,  ONLY : fonte_neige_init_iso
31  USE pbl_surface_mod,  ONLY : pbl_surface_init_iso
32#endif
33    USE phys_state_var_mod
34    USE time_phylmdz_mod, ONLY: day_ref, ndays, pdtphys, &
35                                day_ini,day_end
36    USE indice_sol_mod
37    USE nrtype, ONLY: pi
38!    USE ioipsl
39    USE mod_phys_lmdz_para, ONLY: is_master
40    USE mod_phys_lmdz_transfert_para, ONLY: bcast
41    USE mod_grid_phy_lmdz
42    USE ioipsl_getin_p_mod, ONLY : getin_p
43    USE phys_cal_mod , ONLY: calend, year_len_phy => year_len
44#ifdef ISO
45  USE infotrac_phy, ONLY: niso
46#endif
47    USE clesphys_mod_h
48    USE dimsoil_mod_h, ONLY: nsoilmx
49
50    USE yomcst_mod_h
51IMPLICIT NONE
52
53
54
55    INTEGER, INTENT (IN) :: nlon, year_len, iflag_phys
56    ! IM ajout latfi, lonfi
57!    REAL, INTENT (IN) :: lonfi(nlon), latfi(nlon)
58
59    INTEGER type_profil, type_aqua
60
61    ! Ajouts initialisation des surfaces
62    REAL :: run_off_lic_0(nlon)
63    REAL :: qsolsrf(nlon, nbsrf), snsrf(nlon, nbsrf)
64    REAL :: tsoil(nlon, nsoilmx, nbsrf)
65    REAL :: tslab(nlon), seaice(nlon)
66    REAL fder(nlon)
67
68#ifdef ISO
69    REAL :: xtrun_off_lic_0(niso,nlon)
70    REAL :: xtsolsrf(niso,nlon, nbsrf), xtsnsrf(niso,nlon, nbsrf)
71    REAL :: Rland_ice(niso,nlon)
72#endif
73
74
75
76    ! Arguments :
77    ! -----------
78
79    ! integer radpas
80    INTEGER it, unit, i, k, itap
81
82    REAL rugos, albedo
83    REAL tsurf
84    REAL time, timestep, day, day0
85    REAL qsol_f
86    REAL rugsrel(nlon)
87    LOGICAL alb_ocean
88
89    CHARACTER *80 ans, file_forctl, file_fordat, file_start
90    CHARACTER *100 file, var
91    CHARACTER *2 cnbl
92
93    REAL phy_nat(nlon, year_len)
94    REAL phy_alb(nlon, year_len)
95    REAL phy_sst(nlon, year_len)
96    REAL phy_bil(nlon, year_len)
97    REAL phy_rug(nlon, year_len)
98    REAL phy_ice(nlon, year_len)
99    REAL phy_fter(nlon, year_len)
100    REAL phy_foce(nlon, year_len)
101    REAL phy_fsic(nlon, year_len)
102    REAL phy_flic(nlon, year_len)
103
104    INTEGER, SAVE :: read_climoz = 0 ! read ozone climatology
105!$OMP THREADPRIVATE(read_climoz)
106
107    ! -------------------------------------------------------------------------
108    ! declaration pour l'appel a phyredem
109    ! -------------------------------------------------------------------------
110
111    ! real pctsrf(nlon,nbsrf),ftsol(nlon,nbsrf)
112    REAL falbe(nlon, nbsrf), falblw(nlon, nbsrf)
113    ! real pbl_tke(nlon,llm,nbsrf)
114    ! real rain_fall(nlon),snow_fall(nlon)
115    ! real solsw(nlon), sollw(nlon),radsol(nlon)
116    ! real t_ancien(nlon,llm),q_ancien(nlon,llm),rnebcon(nlon,llm)
117    ! real ratqs(nlon,llm)
118    ! real clwcon(nlon,llm)
119
120    INTEGER longcles
121    PARAMETER (longcles=20)
122    REAL clesphy0(longcles)
123
124
125    ! -----------------------------------------------------------------------
126    ! dynamial tendencies :
127    ! ---------------------
128
129    INTEGER l, ierr, aslun
130
131    REAL paire
132
133    ! Local
134    CHARACTER (LEN=20) :: modname='phyaqua'
135    CHARACTER (LEN=80) :: abort_message
136
137
138    ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
139    ! INITIALISATIONS
140    ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
141
142    ! -----------------------------------------------------------------------
143    ! Initialisations  des constantes
144    ! -------------------------------
145
146    !IF (calend .EQ. "earth_360d") Then
147      year_len_phy = year_len
148    !END IF
149   
150    if (year_len.ne.360) then
151      write (*,*) year_len
152      write (*,*) 'iniaqua: 360 day calendar is required !'
153      stop
154    endif
155
156    type_aqua = iflag_phys/100
157    type_profil = iflag_phys - type_aqua*100
158    PRINT *, 'iniaqua:type_aqua, type_profil', type_aqua, type_profil
159
160    IF (klon/=nlon) THEN
161      WRITE (*, *) 'iniaqua: klon=', klon, ' nlon=', nlon
162      abort_message= 'probleme de dimensions dans iniaqua'
163      CALL abort_physic(modname,abort_message,1)
164    END IF
165    CALL phys_state_var_init(read_climoz)
166
167
168    read_climoz = 0
169    day0 = 217.
170    day = day0
171    it = 0
172    time = 0.
173
174    ! -----------------------------------------------------------------------
175    ! initialisations de la physique
176    ! -----------------------------------------------------------------------
177
178    day_ini = day_ref
179    day_end = day_ini + ndays
180
181    nbapp_rad = 24
182    CALL getin_p('nbapp_rad', nbapp_rad)
183
184    ! ---------------------------------------------------------------------
185    ! Creation des conditions aux limites:
186    ! ------------------------------------
187    ! Initialisations des constantes
188    ! Ajouter les manquants dans planete.def... (albedo etc)
189    co2_ppm = 348.
190    CALL getin_p('co2_ppm', co2_ppm)
191
192    solaire = 1365.
193    CALL getin_p('solaire', solaire)
194 
195    ! CALL getin('albedo',albedo) ! albedo is set below, depending on
196    ! type_aqua
197    alb_ocean = .TRUE.
198    CALL getin_p('alb_ocean', alb_ocean)
199
200    WRITE (*, *) 'iniaqua: co2_ppm=', co2_ppm
201    WRITE (*, *) 'iniaqua: solaire=', solaire
202    WRITE (*, *) 'iniaqua: alb_ocean=', alb_ocean
203
204    radsol = 0.
205    qsol_f = 10.
206
207    ! Conditions aux limites:
208    ! -----------------------
209
210    qsol(:) = qsol_f
211    rugsrel = 0.0 ! (rugsrel = rugoro)
212    rugoro = 0.0
213    u_ancien = 0.0
214    v_ancien = 0.0
215    agesno = 50.0
216    ! Relief plat
217    zmea = 0.
218    zstd = 0.
219    zsig = 0.
220    zgam = 0.
221    zthe = 0.
222    zpic = 0.
223    zval = 0.
224
225    ! Une seule surface
226    pctsrf = 0.
227    IF (type_aqua==1) THEN
228      rugos = 1.E-4
229      albedo = 0.19
230      pctsrf(:, is_oce) = 1.
231    ELSE IF (type_aqua==2) THEN
232      rugos = 0.03
233      albedo = 0.1
234      pctsrf(:, is_ter) = 1.
235    END IF
236
237    CALL getin_p('rugos', rugos)
238
239    WRITE (*, *) 'iniaqua: rugos=', rugos
240    zmasq(:) = pctsrf(:, is_ter)
241
242    ! pctsrf_pot(:,is_oce) = 1. - zmasq(:)
243    ! pctsrf_pot(:,is_sic) = 1. - zmasq(:)
244
245    ! Si alb_ocean on calcule un albedo oceanique moyen
246    ! if (alb_ocean) then
247    ! Voir pourquoi on avait ca.
248    ! CALL ini_alb_oce(phy_alb)
249    ! else
250    phy_alb(:, :) = albedo ! albedo land only (old value condsurf_jyg=0.3)
251    ! endif !alb_ocean
252
253    DO i = 1, year_len
254      ! IM Terraplanete   phy_sst(:,i) = 260.+50.*cos(rlatd(:))**2
255      ! IM ajout calcul profil sst selon le cas considere (cf. FBr)
256
257      phy_nat(:, i) = 1.0 ! 0=ocean libre, 1=land, 2=glacier, 3=banquise
258      phy_bil(:, i) = 1.0 ! ne sert que pour les slab_ocean
259      phy_rug(:, i) = rugos ! longueur rugosite utilisee sur land only
260      phy_ice(:, i) = 0.0 ! fraction de glace (?)
261      phy_fter(:, i) = pctsrf(:, is_ter) ! fraction de glace (?)
262      phy_foce(:, i) = pctsrf(:, is_oce) ! fraction de glace (?)
263      phy_fsic(:, i) = pctsrf(:, is_sic) ! fraction de glace (?)
264      phy_flic(:, i) = pctsrf(:, is_lic) ! fraction de glace (?)
265    END DO
266    ! IM calcul profil sst
267    CALL profil_sst(nlon, latitude, type_profil, phy_sst)
268
269    IF (grid_type==unstructured) THEN
270      CALL writelim_unstruct(klon, phy_nat, phy_alb, phy_sst, phy_bil, phy_rug, phy_ice, &
271                             phy_fter, phy_foce, phy_flic, phy_fsic)
272    ELSE
273     
274       CALL writelim(klon, phy_nat, phy_alb, phy_sst, phy_bil, phy_rug, phy_ice, &
275                     phy_fter, phy_foce, phy_flic, phy_fsic)
276    ENDIF
277
278    ! ---------------------------------------------------------------------
279    ! Ecriture de l'etat initial:
280    ! ---------------------------
281
282
283    ! Ecriture etat initial physique
284
285    timestep = pdtphys
286    radpas = nint(rday/timestep/float(nbapp_rad))
287
288    DO i = 1, longcles
289      clesphy0(i) = 0.
290    END DO
291    clesphy0(1) = float(iflag_con)
292    clesphy0(2) = float(nbapp_rad)
293    ! IF( cycle_diurne  ) clesphy0(3) =  1.
294    clesphy0(3) = 1. ! cycle_diurne
295    clesphy0(4) = 1. ! soil_model
296    clesphy0(5) = 1. ! liqice_in_radocond
297    clesphy0(6) = 0. ! ok_orodr
298    clesphy0(7) = 0. ! ok_orolf
299    clesphy0(8) = 0. ! ok_limitvrai
300
301
302    ! =======================================================================
303    ! Profils initiaux
304    ! =======================================================================
305
306    ! On initialise les temperatures de surfaces comme les sst
307    DO i = 1, nlon
308      ftsol(i, :) = phy_sst(i, 1)
309      tsoil(i, :, :) = phy_sst(i, 1)
310      tslab(i) = phy_sst(i, 1)
311    END DO
312
313    falbe(:, :) = albedo
314    falblw(:, :) = albedo
315    rain_fall(:) = 0.
316    snow_fall(:) = 0.
317    solsw(:) = 0.
318    sollw(:) = 0.
319    radsol(:) = 0.
320
321    ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
322    ! intialisation bidon mais pas grave
323    t_ancien(:, :) = 0.
324    q_ancien(:, :) = 0.
325    ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
326    rnebcon = 0.
327    ratqs = 0.
328    clwcon = 0.
329    pbl_tke = 1.E-8
330
331    ! variables supplementaires pour appel a plb_surface_init
332    fder(:) = 0.
333    seaice(:) = 0.
334    run_off_lic_0 = 0.
335    fevap = 0.
336#ifdef ISO
337    xtrun_off_lic_0 = 0.
338#endif
339
340
341    ! Initialisations necessaires avant phyredem
342    type_ocean = 'force'
343    CALL fonte_neige_init(run_off_lic_0)
344#ifdef ISO
345   CALL fonte_neige_init_iso(xtrun_off_lic_0)
346#endif
347    qsolsrf(:, :) = qsol(1) ! humidite du sol des sous surface
348    snsrf(:, :) = 0. ! couverture de neige des sous surface
349    z0m(:, :) = rugos ! couverture de neige des sous surface
350    z0h=z0m
351
352
353!GG
354    CALL pbl_surface_init(fder, snsrf, qsolsrf, tsoil, hice, tice, bilg_cumul)
355!    CALL pbl_surface_init(fder, snsrf, qsolsrf, tsoil)
356!GG
357#ifdef ISO
358  CALL pbl_surface_init_iso(xtsnsrf,Rland_ice)
359#endif
360
361    PRINT *, 'iniaqua: before phyredem'
362
363    pbl_tke(:,:,:) = 1.e-8
364    falb1 = albedo
365    falb2 = albedo
366    zmax0 = 0.
367    f0 = 0.
368    sig1 = 0.
369    w01 = 0.
370    wake_deltat = 0.
371    wake_deltaq = 0.
372    wake_s = 0.
373    wake_dens = 0.
374    wake_cstar = 0.
375    wake_pe = 0.
376    wake_fip = 0.
377    fm_therm = 0.
378    entr_therm = 0.
379    detr_therm = 0.
380    ale_bl = 0.
381    ale_bl_trig =0.
382    alp_bl =0.
383    treedrg(:,:,:)=0.
384
385    u10m = 0.
386    v10m = 0.
387
388    ql_ancien   = 0.
389    qs_ancien   = 0.
390    u_ancien    = 0.
391    v_ancien    = 0.
392    prw_ancien  = 0.
393    prlw_ancien = 0.
394    prsw_ancien = 0. 
395
396    ale_wake    = 0.
397    ale_bl_stat = 0. 
398
399
400!ym error : the sub surface dimension is the third not second : forgotten for iniaqua
401!    falb_dir(:,is_ter,:)=0.08; falb_dir(:,is_lic,:)=0.6
402!    falb_dir(:,is_oce,:)=0.5;  falb_dir(:,is_sic,:)=0.6
403    falb_dir(:,:,is_ter)=0.08; falb_dir(:,:,is_lic)=0.6
404    falb_dir(:,:,is_oce)=0.5;  falb_dir(:,:,is_sic)=0.6
405
406!ym falb_dif has been forgotten, initialize with defaukt value found in phyetat0 or 0 ?
407!ym probably the uninitialized value was 0 for standard (regular grid) case
408    falb_dif(:,:,:)=0
409
410
411    CALL phyredem('startphy.nc')
412
413    PRINT *, 'iniaqua: after phyredem'
414    CALL phys_state_var_end
415
416    RETURN
417  END SUBROUTINE iniaqua
418
419
420  ! ====================================================================
421  ! ====================================================================
422  SUBROUTINE zenang_an(cycle_diurne, gmtime, rlat, rlon, rmu0, fract)
423    USE yomcst_mod_h
424    USE dimphy
425    IMPLICIT NONE
426    ! ====================================================================
427    ! =============================================================
428    ! CALL zenang(cycle_diurne,gmtime,rlat,rlon,rmu0,fract)
429    ! Auteur : A. Campoy et F. Hourdin
430    ! Objet  : calculer les valeurs moyennes du cos de l'angle zenithal
431    ! et l'ensoleillement moyen entre gmtime1 et gmtime2
432    ! connaissant la declinaison, la latitude et la longitude.
433
434    ! Dans cette version particuliere, on calcule le rayonnement
435    ! moyen sur l'année à chaque latitude.
436    ! angle zenithal calculé pour obtenir un
437    ! Fit polynomial de  l'ensoleillement moyen au sommet de l'atmosphere
438    ! en moyenne annuelle.
439    ! Spécifique de la terre. Utilisé pour les aqua planetes.
440
441    ! Rque   : Different de la routine angle en ce sens que zenang
442    ! fournit des moyennes de pmu0 et non des valeurs
443    ! instantanees, du coup frac prend toutes les valeurs
444    ! entre 0 et 1.
445    ! Date   : premiere version le 13 decembre 1994
446    ! revu pour  GCM  le 30 septembre 1996
447    ! ===============================================================
448    ! longi----INPUT : la longitude vraie de la terre dans son plan
449    ! solaire a partir de l'equinoxe de printemps (degre)
450    ! gmtime---INPUT : temps universel en fraction de jour
451    ! pdtrad---INPUT : pas de temps du rayonnement (secondes)
452    ! lat------INPUT : latitude en degres
453    ! long-----INPUT : longitude en degres
454    ! pmu0-----OUTPUT: angle zenithal moyen entre gmtime et gmtime+pdtrad
455    ! frac-----OUTPUT: ensoleillement moyen entre gmtime et gmtime+pdtrad
456    ! ================================================================
457    ! ================================================================
458    LOGICAL cycle_diurne
459    REAL gmtime
460    REAL rlat(klon), rlon(klon), rmu0(klon), fract(klon)
461    ! ================================================================
462    INTEGER i
463    REAL gmtime1, gmtime2
464    REAL pi_local
465
466
467    REAL rmu0m(klon), rmu0a(klon)
468
469
470    pi_local = 4.0*atan(1.0)
471
472    ! ================================================================
473    ! Calcul de l'angle zenithal moyen sur la journee
474    ! ================================================================
475
476    DO i = 1, klon
477      fract(i) = 1.
478      ! Calcule du flux moyen
479      IF (abs(rlat(i))<=28.75) THEN
480        rmu0m(i) = (210.1924+206.6059*cos(0.0174533*rlat(i))**2)/1365.
481      ELSE IF (abs(rlat(i))<=43.75) THEN
482        rmu0m(i) = (187.4562+236.1853*cos(0.0174533*rlat(i))**2)/1365.
483      ELSE IF (abs(rlat(i))<=71.25) THEN
484        rmu0m(i) = (162.4439+284.1192*cos(0.0174533*rlat(i))**2)/1365.
485      ELSE
486        rmu0m(i) = (172.8125+183.7673*cos(0.0174533*rlat(i))**2)/1365.
487      END IF
488    END DO
489
490    ! ================================================================
491    ! Avec ou sans cycle diurne
492    ! ================================================================
493
494    IF (cycle_diurne) THEN
495
496      ! On redecompose flux  au sommet suivant un cycle diurne idealise
497      ! identique a toutes les latitudes.
498
499      DO i = 1, klon
500        rmu0a(i) = 2.*rmu0m(i)*sqrt(2.)*pi_local/(4.-pi_local)
501        rmu0(i) = rmu0a(i)*abs(sin(pi_local*gmtime+pi_local*rlon(i)/360.)) - &
502          rmu0a(i)/sqrt(2.)
503      END DO
504
505      DO i = 1, klon
506        IF (rmu0(i)<=0.) THEN
507          rmu0(i) = 0.
508          fract(i) = 0.
509        ELSE
510          fract(i) = 1.
511        END IF
512      END DO
513
514      ! Affichage de l'angel zenitale
515      ! print*,'************************************'
516      ! print*,'************************************'
517      ! print*,'************************************'
518      ! print*,'latitude=',rlat(i),'longitude=',rlon(i)
519      ! print*,'rmu0m=',rmu0m(i)
520      ! print*,'rmu0a=',rmu0a(i)
521      ! print*,'rmu0=',rmu0(i)
522
523    ELSE
524
525      DO i = 1, klon
526        fract(i) = 0.5
527        rmu0(i) = rmu0m(i)*2.
528      END DO
529
530    END IF
531
532    RETURN
533  END SUBROUTINE zenang_an
534
535  ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
536
537  SUBROUTINE writelim_unstruct(klon, phy_nat, phy_alb, phy_sst, phy_bil, phy_rug, &
538      phy_ice, phy_fter, phy_foce, phy_flic, phy_fsic)
539
540    USE mod_phys_lmdz_para, ONLY: is_omp_master, klon_mpi
541    USE mod_phys_lmdz_transfert_para, ONLY: gather_omp
542    USE lmdz_xios
543    IMPLICIT NONE
544
545    INTEGER, INTENT (IN) :: klon
546    REAL, INTENT (IN) :: phy_nat(klon, 360)
547    REAL, INTENT (IN) :: phy_alb(klon, 360)
548    REAL, INTENT (IN) :: phy_sst(klon, 360)
549    REAL, INTENT (IN) :: phy_bil(klon, 360)
550    REAL, INTENT (IN) :: phy_rug(klon, 360)
551    REAL, INTENT (IN) :: phy_ice(klon, 360)
552    REAL, INTENT (IN) :: phy_fter(klon, 360)
553    REAL, INTENT (IN) :: phy_foce(klon, 360)
554    REAL, INTENT (IN) :: phy_flic(klon, 360)
555    REAL, INTENT (IN) :: phy_fsic(klon, 360)
556
557    REAL :: phy_mpi(klon_mpi, 360) ! temporary variable, to store phy_***(:)
558      ! on the whole physics grid
559 
560    PRINT *, 'writelim: Ecriture du fichier limit'
561
562    CALL gather_omp(phy_foce, phy_mpi)
563    IF (is_omp_master) CALL xios_send_field('foce_limout',phy_mpi)
564
565    CALL gather_omp(phy_fsic, phy_mpi)
566    IF (is_omp_master) CALL xios_send_field('fsic_limout',phy_mpi)
567     
568    CALL gather_omp(phy_fter, phy_mpi)
569    IF (is_omp_master) CALL xios_send_field('fter_limout',phy_mpi)
570     
571    CALL gather_omp(phy_flic, phy_mpi)
572    IF (is_omp_master) CALL xios_send_field('flic_limout',phy_mpi)
573
574    CALL gather_omp(phy_sst, phy_mpi)
575    IF (is_omp_master) CALL xios_send_field('sst_limout',phy_mpi)
576
577    CALL gather_omp(phy_bil, phy_mpi)
578    IF (is_omp_master) CALL xios_send_field('bils_limout',phy_mpi)
579
580    CALL gather_omp(phy_alb, phy_mpi)
581    IF (is_omp_master) CALL xios_send_field('alb_limout',phy_mpi)
582
583    CALL gather_omp(phy_rug, phy_mpi)
584    IF (is_omp_master) CALL xios_send_field('rug_limout',phy_mpi)
585
586  END SUBROUTINE writelim_unstruct
587
588
589
590  SUBROUTINE writelim(klon, phy_nat, phy_alb, phy_sst, phy_bil, phy_rug, &
591      phy_ice, phy_fter, phy_foce, phy_flic, phy_fsic)
592
593    USE mod_phys_lmdz_para, ONLY: is_master
594    USE mod_grid_phy_lmdz, ONLY: klon_glo
595    USE mod_phys_lmdz_transfert_para, ONLY: gather
596    USE phys_cal_mod, ONLY: year_len
597    USE netcdf, ONLY: nf90_clobber, nf90_close, nf90_noerr, nf90_strerror, nf90_put_att, nf90_def_var, &
598            nf90_def_dim, nf90_create, nf90_put_var, nf90_unlimited, nf90_global, nf90_64bit_offset, &
599            nf90_enddef
600    USE lmdz_cppkeys_wrapper, ONLY: nf90_format
601    IMPLICIT NONE
602
603    INTEGER, INTENT (IN) :: klon
604    REAL, INTENT (IN) :: phy_nat(klon, year_len)
605    REAL, INTENT (IN) :: phy_alb(klon, year_len)
606    REAL, INTENT (IN) :: phy_sst(klon, year_len)
607    REAL, INTENT (IN) :: phy_bil(klon, year_len)
608    REAL, INTENT (IN) :: phy_rug(klon, year_len)
609    REAL, INTENT (IN) :: phy_ice(klon, year_len)
610    REAL, INTENT (IN) :: phy_fter(klon, year_len)
611    REAL, INTENT (IN) :: phy_foce(klon, year_len)
612    REAL, INTENT (IN) :: phy_flic(klon, year_len)
613    REAL, INTENT (IN) :: phy_fsic(klon, year_len)
614
615    REAL :: phy_glo(klon_glo, year_len) ! temporary variable, to store phy_***(:)
616      ! on the whole physics grid
617    INTEGER :: k
618    INTEGER ierr
619    INTEGER dimfirst(3)
620    INTEGER dimlast(3)
621
622    INTEGER nid, ndim, ntim
623    INTEGER dims(2), debut(2), epais(2)
624    INTEGER id_tim
625    INTEGER id_nat, id_sst, id_bils, id_rug, id_alb
626    INTEGER id_fter, id_foce, id_fsic, id_flic
627
628    IF (is_master) THEN
629
630      PRINT *, 'writelim: Ecriture du fichier limit'
631
632      ierr = nf90_create('limit.nc', IOR(nf90_clobber,nf90_64bit_offset), nid)
633
634      ierr = nf90_put_att(nid, nf90_global, 'title', 'Fichier conditions aux limites')
635      ! !        ierr = nf90_def_dim (nid, "points_physiques", klon, ndim)
636      ierr = nf90_def_dim(nid, 'points_physiques', klon_glo, ndim)
637      ierr = nf90_def_dim(nid, 'time', nf90_unlimited, ntim)
638
639      dims(1) = ndim
640      dims(2) = ntim
641
642      ierr = nf90_def_var(nid, 'TEMPS', nf90_format, ntim, id_tim)
643      ierr = nf90_put_att(nid, id_tim, 'title', 'Jour dans l annee')
644
645      ierr = nf90_def_var(nid, 'NAT', nf90_format, dims, id_nat)
646      ierr = nf90_put_att(nid, id_nat, 'title', 'Nature du sol (0,1,2,3)')
647
648      ierr = nf90_def_var(nid, 'SST', nf90_format, dims, id_sst)
649      ierr = nf90_put_att(nid, id_sst, 'title', 'Temperature superficielle de la mer')
650
651      ierr = nf90_def_var(nid, 'BILS', nf90_format, dims, id_bils)
652      ierr = nf90_put_att(nid, id_bils, 'title', 'Reference flux de chaleur au sol')
653
654      ierr = nf90_def_var(nid, 'ALB', nf90_format, dims, id_alb)
655      ierr = nf90_put_att(nid, id_alb, 'title', 'Albedo a la surface')
656
657      ierr = nf90_def_var(nid, 'RUG', nf90_format, dims, id_rug)
658      ierr = nf90_put_att(nid, id_rug, 'title', 'Rugosite')
659
660      ierr = nf90_def_var(nid, 'FTER', nf90_format, dims, id_fter)
661      ierr = nf90_put_att(nid, id_fter, 'title','Frac. Land')
662      ierr = nf90_def_var(nid, 'FOCE', nf90_format, dims, id_foce)
663      ierr = nf90_put_att(nid, id_foce, 'title','Frac. Ocean')
664      ierr = nf90_def_var(nid, 'FSIC', nf90_format, dims, id_fsic)
665      ierr = nf90_put_att(nid, id_fsic, 'title','Frac. Sea Ice')
666      ierr = nf90_def_var(nid, 'FLIC', nf90_format, dims, id_flic)
667      ierr = nf90_put_att(nid, id_flic, 'title','Frac. Land Ice')
668
669      ierr = nf90_enddef(nid)
670      IF (ierr/=nf90_noerr) THEN
671        WRITE (*, *) 'writelim error: failed to end define mode'
672        WRITE (*, *) nf90_strerror(ierr)
673      END IF
674
675
676      ! write the 'times'
677      DO k = 1, year_len
678        ierr = nf90_put_var(nid, id_tim, k, [k])
679        IF (ierr/=nf90_noerr) THEN
680          WRITE (*, *) 'writelim error with temps(k),k=', k
681          WRITE (*, *) nf90_strerror(ierr)
682        END IF
683      END DO
684
685    END IF ! of if (is_master)
686
687    ! write the fields, after having collected them on master
688
689    CALL gather(phy_nat, phy_glo)
690    IF (is_master) THEN
691      ierr = nf90_put_var(nid, id_nat, phy_glo)
692      IF (ierr/=nf90_noerr) THEN
693        WRITE (*, *) 'writelim error with phy_nat'
694        WRITE (*, *) nf90_strerror(ierr)
695      END IF
696    END IF
697
698    CALL gather(phy_sst, phy_glo)
699    IF (is_master) THEN
700      ierr = nf90_put_var(nid, id_sst, phy_glo)
701      IF (ierr/=nf90_noerr) THEN
702        WRITE (*, *) 'writelim error with phy_sst'
703        WRITE (*, *) nf90_strerror(ierr)
704      END IF
705    END IF
706
707    CALL gather(phy_bil, phy_glo)
708    IF (is_master) THEN
709      ierr = nf90_put_var(nid, id_bils, phy_glo)
710      IF (ierr/=nf90_noerr) THEN
711        WRITE (*, *) 'writelim error with phy_bil'
712        WRITE (*, *) nf90_strerror(ierr)
713      END IF
714    END IF
715
716    CALL gather(phy_alb, phy_glo)
717    IF (is_master) THEN
718      ierr = nf90_put_var(nid, id_alb, phy_glo)
719      IF (ierr/=nf90_noerr) THEN
720        WRITE (*, *) 'writelim error with phy_alb'
721        WRITE (*, *) nf90_strerror(ierr)
722      END IF
723    END IF
724
725    CALL gather(phy_rug, phy_glo)
726    IF (is_master) THEN
727      ierr = nf90_put_var(nid, id_rug, phy_glo)
728      IF (ierr/=nf90_noerr) THEN
729        WRITE (*, *) 'writelim error with phy_rug'
730        WRITE (*, *) nf90_strerror(ierr)
731      END IF
732    END IF
733
734    CALL gather(phy_fter, phy_glo)
735    IF (is_master) THEN
736      ierr = nf90_put_var(nid, id_fter, phy_glo)
737      IF (ierr/=nf90_noerr) THEN
738        WRITE (*, *) 'writelim error with phy_fter'
739        WRITE (*, *) nf90_strerror(ierr)
740      END IF
741    END IF
742
743    CALL gather(phy_foce, phy_glo)
744    IF (is_master) THEN
745      ierr = nf90_put_var(nid, id_foce, phy_glo)
746      IF (ierr/=nf90_noerr) THEN
747        WRITE (*, *) 'writelim error with phy_foce'
748        WRITE (*, *) nf90_strerror(ierr)
749      END IF
750    END IF
751
752    CALL gather(phy_fsic, phy_glo)
753    IF (is_master) THEN
754      ierr = nf90_put_var(nid, id_fsic, phy_glo)
755      IF (ierr/=nf90_noerr) THEN
756        WRITE (*, *) 'writelim error with phy_fsic'
757        WRITE (*, *) nf90_strerror(ierr)
758      END IF
759    END IF
760
761    CALL gather(phy_flic, phy_glo)
762    IF (is_master) THEN
763      ierr = nf90_put_var(nid, id_flic, phy_glo)
764      IF (ierr/=nf90_noerr) THEN
765        WRITE (*, *) 'writelim error with phy_flic'
766        WRITE (*, *) nf90_strerror(ierr)
767      END IF
768    END IF
769
770    ! close file:
771    IF (is_master) THEN
772      ierr = nf90_close(nid)
773    END IF
774
775  END SUBROUTINE writelim
776
777  ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
778
779  SUBROUTINE profil_sst(nlon, rlatd, type_profil, phy_sst)
780    USE dimphy
781    USE phys_cal_mod , ONLY: year_len
782    IMPLICIT NONE
783
784    INTEGER nlon, type_profil, i, k, j
785    REAL :: rlatd(nlon), phy_sst(nlon, year_len)
786    INTEGER imn, imx, amn, amx, kmn, kmx
787    INTEGER p, pplus, nlat_max
788    PARAMETER (nlat_max=72)
789    REAL x_anom_sst(nlat_max)
790    CHARACTER (LEN=20) :: modname='profil_sst'
791    CHARACTER (LEN=80) :: abort_message
792
793    IF (klon/=nlon) THEN
794       abort_message='probleme de dimensions dans profil_sst'
795       CALL abort_physic(modname,abort_message,1)
796    ENDIF
797    WRITE (*, *) ' profil_sst: type_profil=', type_profil
798    DO i = 1, year_len
799      ! phy_sst(:,i) = 260.+50.*cos(rlatd(:))**2
800
801      ! Rajout fbrlmd
802
803      IF (type_profil==1) THEN
804        ! Méthode 1 "Control" faible plateau à l'Equateur
805        DO j = 1, klon
806          phy_sst(j, i) = 273. + 27.*(1-sin(1.5*rlatd(j))**2)
807          ! PI/3=1.047197551
808          IF ((rlatd(j)>1.0471975) .OR. (rlatd(j)<-1.0471975)) THEN
809            phy_sst(j, i) = 273.
810          END IF
811        END DO
812      END IF
813      IF (type_profil==2) THEN
814        ! Méthode 2 "Flat" fort plateau à l'Equateur
815        DO j = 1, klon
816          phy_sst(j, i) = 273. + 27.*(1-sin(1.5*rlatd(j))**4)
817          IF ((rlatd(j)>1.0471975) .OR. (rlatd(j)<-1.0471975)) THEN
818            phy_sst(j, i) = 273.
819          END IF
820        END DO
821      END IF
822
823
824      IF (type_profil==3) THEN
825        ! Méthode 3 "Qobs" plateau réel à l'Equateur
826        DO j = 1, klon
827          phy_sst(j, i) = 273. + 0.5*27.*(2-sin(1.5*rlatd(j))**2-sin(1.5* &
828            rlatd(j))**4)
829          IF ((rlatd(j)>1.0471975) .OR. (rlatd(j)<-1.0471975)) THEN
830            phy_sst(j, i) = 273.
831          END IF
832        END DO
833      END IF
834
835      IF (type_profil==4) THEN
836        ! Méthode 4 : Méthode 3 + SST+2 "Qobs" plateau réel à l'Equateur
837        DO j = 1, klon
838          phy_sst(j, i) = 273. + 0.5*29.*(2-sin(1.5*rlatd(j))**2-sin(1.5* &
839            rlatd(j))**4)
840          IF ((rlatd(j)>1.0471975) .OR. (rlatd(j)<-1.0471975)) THEN
841            phy_sst(j, i) = 273.
842          END IF
843        END DO
844      END IF
845
846      IF (type_profil==5) THEN
847        ! Méthode 5 : Méthode 3 + +2K "Qobs" plateau réel à l'Equateur
848        DO j = 1, klon
849          phy_sst(j, i) = 273. + 2. + 0.5*27.*(2-sin(1.5*rlatd(j))**2-sin(1.5 &
850            *rlatd(j))**4)
851          IF ((rlatd(j)>1.0471975) .OR. (rlatd(j)<-1.0471975)) THEN
852            phy_sst(j, i) = 273. + 2.
853          END IF
854
855        END DO
856      END IF
857
858      IF (type_profil==6) THEN
859        ! Méthode 6 "cst" valeur constante de SST
860        DO j = 1, klon
861          phy_sst(j, i) = 288.
862        END DO
863      END IF
864
865
866      IF (type_profil==7) THEN
867        ! Méthode 7 "cst" valeur constante de SST +2
868        DO j = 1, klon
869          phy_sst(j, i) = 288. + 2.
870        END DO
871      END IF
872
873      p = 0
874      IF (type_profil==8) THEN
875        ! Méthode 8 profil anomalies SST du modèle couplé AR4
876        DO j = 1, klon
877          IF (rlatd(j)==rlatd(j-1)) THEN
878            phy_sst(j, i) = 273. + x_anom_sst(pplus) + &
879              0.5*27.*(2-sin(1.5*rlatd(j))**2-sin(1.5*rlatd(j))**4)
880            IF ((rlatd(j)>1.0471975) .OR. (rlatd(j)<-1.0471975)) THEN
881              phy_sst(j, i) = 273. + x_anom_sst(pplus)
882            END IF
883          ELSE
884            p = p + 1
885            pplus = 73 - p
886            phy_sst(j, i) = 273. + x_anom_sst(pplus) + &
887              0.5*27.*(2-sin(1.5*rlatd(j))**2-sin(1.5*rlatd(j))**4)
888            IF ((rlatd(j)>1.0471975) .OR. (rlatd(j)<-1.0471975)) THEN
889              phy_sst(j, i) = 273. + x_anom_sst(pplus)
890            END IF
891            WRITE (*, *) rlatd(j), x_anom_sst(pplus), phy_sst(j, i)
892          END IF
893        END DO
894      END IF
895
896      IF (type_profil==9) THEN
897        ! Méthode 5 : Méthode 3 + -2K "Qobs" plateau réel à l'Equateur
898        DO j = 1, klon
899          phy_sst(j, i) = 273. - 2. + 0.5*27.*(2-sin(1.5*rlatd(j))**2-sin(1.5 &
900            *rlatd(j))**4)
901          IF ((rlatd(j)>1.0471975) .OR. (rlatd(j)<-1.0471975)) THEN
902            phy_sst(j, i) = 273. - 2.
903          END IF
904        END DO
905      END IF
906
907
908      IF (type_profil==10) THEN
909        ! Méthode 10 : Méthode 3 + +4K "Qobs" plateau réel à l'Equateur
910        DO j = 1, klon
911          phy_sst(j, i) = 273. + 4. + 0.5*27.*(2-sin(1.5*rlatd(j))**2-sin(1.5 &
912            *rlatd(j))**4)
913          IF ((rlatd(j)>1.0471975) .OR. (rlatd(j)<-1.0471975)) THEN
914            phy_sst(j, i) = 273. + 4.
915          END IF
916        END DO
917      END IF
918
919      IF (type_profil==11) THEN
920        ! Méthode 11 : Méthode 3 + 4CO2 "Qobs" plateau réel à l'Equateur
921        DO j = 1, klon
922          phy_sst(j, i) = 273. + 0.5*27.*(2-sin(1.5*rlatd(j))**2-sin(1.5* &
923            rlatd(j))**4)
924          IF ((rlatd(j)>1.0471975) .OR. (rlatd(j)<-1.0471975)) THEN
925            phy_sst(j, i) = 273.
926          END IF
927        END DO
928      END IF
929
930      IF (type_profil==12) THEN
931        ! Méthode 12 : Méthode 10 + 4CO2 "Qobs" plateau réel à l'Equateur
932        DO j = 1, klon
933          phy_sst(j, i) = 273. + 4. + 0.5*27.*(2-sin(1.5*rlatd(j))**2-sin(1.5 &
934            *rlatd(j))**4)
935          IF ((rlatd(j)>1.0471975) .OR. (rlatd(j)<-1.0471975)) THEN
936            phy_sst(j, i) = 273. + 4.
937          END IF
938        END DO
939      END IF
940
941      IF (type_profil==13) THEN
942        ! Méthode 13 "Qmax" plateau réel à l'Equateur augmenté !
943        DO j = 1, klon
944          phy_sst(j, i) = 273. + 0.5*29.*(2-sin(1.5*rlatd(j))**2-sin(1.5* &
945            rlatd(j))**4)
946          IF ((rlatd(j)>1.0471975) .OR. (rlatd(j)<-1.0471975)) THEN
947            phy_sst(j, i) = 273.
948          END IF
949        END DO
950      END IF
951
952      IF (type_profil==14) THEN
953        ! Méthode 13 "Qmax2K" plateau réel à l'Equateur augmenté +2K !
954        DO j = 1, klon
955          phy_sst(j, i) = 273. + 2. + 0.5*29.*(2-sin(1.5*rlatd(j))**2-sin(1.5 &
956            *rlatd(j))**4)
957          IF ((rlatd(j)>1.0471975) .OR. (rlatd(j)<-1.0471975)) THEN
958            phy_sst(j, i) = 273.
959          END IF
960        END DO
961      END IF
962
963      if (type_profil.EQ.20) then
964      print*,'Profile SST 20'
965!     Méthode 13 "Qmax2K" plateau réel �|  l'Equateur augmenté +2K
966
967      do j=1,klon
968        phy_sst(j,i)=248.+55.*(1-sin(rlatd(j))**2)
969      enddo
970      endif
971
972      if (type_profil.EQ.21) then
973      print*,'Profile SST 21'
974!     Méthode 13 "Qmax2K" plateau réel �|  l'Equateur augmenté +2K
975      do j=1,klon
976        phy_sst(j,i)=252.+55.*(1-sin(rlatd(j))**2)
977      enddo
978      endif
979
980
981
982    END DO
983
984    ! IM beg : verif profil SST: phy_sst
985    amn = min(phy_sst(1,1), 1000.)
986    amx = max(phy_sst(1,1), -1000.)
987    imn = 1
988    kmn = 1
989    imx = 1
990    kmx = 1
991    DO k = 1, year_len
992      DO i = 2, nlon
993        IF (phy_sst(i,k)<amn) THEN
994          amn = phy_sst(i, k)
995          imn = i
996          kmn = k
997        END IF
998        IF (phy_sst(i,k)>amx) THEN
999          amx = phy_sst(i, k)
1000          imx = i
1001          kmx = k
1002        END IF
1003      END DO
1004    END DO
1005
1006    PRINT *, 'profil_sst: imn, kmn, phy_sst(imn,kmn) ', imn, kmn, amn
1007    PRINT *, 'profil_sst: imx, kmx, phy_sst(imx,kmx) ', imx, kmx, amx
1008    ! IM end : verif profil SST: phy_sst
1009
1010    RETURN
1011  END SUBROUTINE profil_sst
1012
1013END MODULE phyaqua_mod
Note: See TracBrowser for help on using the repository browser.