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

Last change on this file since 5249 was 5249, checked in by abarral, 4 days ago

Replace uses of cpp key NC_DOUBLE

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