1 |
guez |
54 |
module interfoce_lim_m |
2 |
|
|
|
3 |
|
|
implicit none |
4 |
|
|
|
5 |
|
|
contains |
6 |
|
|
|
7 |
guez |
191 |
SUBROUTINE interfoce_lim(dtime, jour, knindex, debut, lmt_sst, pctsrf_new) |
8 |
guez |
54 |
|
9 |
guez |
175 |
! lecture conditions limites |
10 |
guez |
104 |
! Cette routine sert d'interface entre le modèle atmosphérique et |
11 |
|
|
! un fichier de conditions aux limites. |
12 |
guez |
54 |
|
13 |
guez |
104 |
! Laurent FAIRHEAD, February 2000 |
14 |
guez |
54 |
|
15 |
guez |
106 |
USE dimphy, ONLY: klon |
16 |
guez |
104 |
USE indicesol, ONLY: is_lic, is_oce, is_sic, is_ter, nbsrf |
17 |
guez |
178 |
USE netcdf, ONLY: nf90_nowrite |
18 |
guez |
104 |
use netcdf95, only: NF95_CLOSE, nf95_get_var, NF95_INQ_VARID, nf95_open |
19 |
guez |
178 |
use nr_util, only: assert |
20 |
guez |
191 |
use time_phylmdz, only: itap |
21 |
guez |
54 |
|
22 |
guez |
104 |
real, intent(IN):: dtime ! pas de temps de la physique (en s) |
23 |
|
|
integer, intent(IN):: jour ! jour a lire dans l'annee |
24 |
guez |
54 |
|
25 |
guez |
106 |
integer, intent(in):: knindex(:) ! (knon) |
26 |
guez |
104 |
! index des points de la surface a traiter |
27 |
guez |
54 |
|
28 |
guez |
104 |
logical, intent(IN):: debut ! 1er appel a la physique (initialisation) |
29 |
|
|
|
30 |
guez |
106 |
real, intent(out):: lmt_sst(:) ! (knon) |
31 |
|
|
! SST lues dans le fichier de conditions aux limites |
32 |
guez |
104 |
|
33 |
guez |
106 |
real, intent(out):: pctsrf_new(:, :) ! (klon, nbsrf) |
34 |
guez |
104 |
! sous-maille fractionnelle |
35 |
|
|
|
36 |
|
|
! Local: |
37 |
|
|
|
38 |
|
|
INTEGER, save:: lmt_pas ! frequence de lecture des conditions limites |
39 |
guez |
54 |
! (en pas de physique) |
40 |
guez |
104 |
|
41 |
guez |
106 |
logical, save:: deja_lu |
42 |
|
|
! pour indiquer que le jour à lire a déjà été lu pour une surface |
43 |
|
|
! précédente |
44 |
guez |
54 |
|
45 |
guez |
104 |
integer, save:: jour_lu |
46 |
guez |
54 |
|
47 |
guez |
104 |
! Champs lus dans le fichier de conditions aux limites : |
48 |
guez |
106 |
real, allocatable, save:: sst_lu(:) |
49 |
|
|
real, allocatable, save:: pct_tmp(:, :) |
50 |
guez |
54 |
|
51 |
guez |
106 |
integer ncid, varid ! pour NetCDF |
52 |
guez |
104 |
|
53 |
guez |
54 |
! -------------------------------------------------- |
54 |
|
|
|
55 |
guez |
178 |
call assert(size(knindex) == size(lmt_sst), "interfoce_lim knon") |
56 |
guez |
106 |
|
57 |
guez |
54 |
if (debut .and. .not. allocated(sst_lu)) then |
58 |
guez |
106 |
lmt_pas = nint(86400. / dtime) ! pour une lecture une fois par jour |
59 |
guez |
54 |
jour_lu = jour - 1 |
60 |
|
|
allocate(sst_lu(klon)) |
61 |
|
|
allocate(pct_tmp(klon, nbsrf)) |
62 |
|
|
endif |
63 |
|
|
|
64 |
|
|
if ((jour - jour_lu) /= 0) deja_lu = .false. |
65 |
|
|
|
66 |
|
|
! Tester d'abord si c'est le moment de lire le fichier |
67 |
guez |
191 |
if (mod(itap - 1, lmt_pas) == 0 .and. .not. deja_lu) then |
68 |
guez |
106 |
call NF95_OPEN ('limit.nc', NF90_NOWRITE, ncid) |
69 |
guez |
54 |
|
70 |
guez |
104 |
! Fraction "ocean" |
71 |
guez |
106 |
call NF95_INQ_VARID(ncid, 'FOCE', varid) |
72 |
|
|
call NF95_GET_VAR(ncid, varid, pct_tmp(:, is_oce), start = (/1, jour/)) |
73 |
guez |
54 |
|
74 |
guez |
104 |
! Fraction "glace de mer" |
75 |
guez |
106 |
call NF95_INQ_VARID(ncid, 'FSIC', varid) |
76 |
|
|
call NF95_GET_VAR(ncid, varid, pct_tmp(:, is_sic), start = (/1, jour/)) |
77 |
guez |
54 |
|
78 |
guez |
104 |
! Fraction "terre" |
79 |
guez |
106 |
call NF95_INQ_VARID(ncid, 'FTER', varid) |
80 |
|
|
call NF95_GET_VAR(ncid, varid, pct_tmp(:, is_ter), start = (/1, jour/)) |
81 |
guez |
54 |
|
82 |
guez |
104 |
! Fraction "glacier terre" |
83 |
guez |
106 |
call NF95_INQ_VARID(ncid, 'FLIC', varid) |
84 |
|
|
call NF95_GET_VAR(ncid, varid, pct_tmp(:, is_lic), start = (/1, jour/)) |
85 |
guez |
54 |
|
86 |
guez |
106 |
call NF95_INQ_VARID(ncid, 'SST', varid) |
87 |
|
|
call NF95_GET_VAR(ncid, varid, sst_lu, start = (/1, jour/)) |
88 |
guez |
54 |
|
89 |
guez |
106 |
call NF95_CLOSE(ncid) |
90 |
guez |
54 |
deja_lu = .true. |
91 |
|
|
jour_lu = jour |
92 |
|
|
endif |
93 |
|
|
|
94 |
|
|
! Recopie des variables dans les champs de sortie |
95 |
guez |
106 |
lmt_sst = sst_lu(knindex) |
96 |
guez |
54 |
pctsrf_new(:, is_oce) = pct_tmp(:, is_oce) |
97 |
|
|
pctsrf_new(:, is_sic) = pct_tmp(:, is_sic) |
98 |
|
|
|
99 |
|
|
END SUBROUTINE interfoce_lim |
100 |
|
|
|
101 |
|
|
end module interfoce_lim_m |