/[lmdze]/trunk/dyn3d/grilles_gcm_netcdf_sub.f
ViewVC logotype

Contents of /trunk/dyn3d/grilles_gcm_netcdf_sub.f

Parent Directory Parent Directory | Revision Log Revision Log


Revision 107 - (show annotations)
Thu Sep 11 15:09:15 2014 UTC (9 years, 8 months ago) by guez
File size: 4308 byte(s)
Imported procedure grilles_gcm_sub from LMDZ. Had then to transform
local variable phis of etat to argument.

Replaced calls to lnblnk by calls to trim.

Removed arguments nlat, klevel and griscal of filtreg. Replaced
integer arguments ifiltre and iaire by logical arguments direct and
intensive.

Changed default values of guide_t and guide_q to false.

1 module grilles_gcm_netcdf_sub_m
2
3 IMPLICIT NONE
4
5 contains
6
7 SUBROUTINE grilles_gcm_netcdf_sub(phis)
8
9 ! This subroutine creates the file grilles_gcm.nc containg
10 ! longitudes and latitudes in degrees for grids u and v.
11
12 USE comconst, ONLY: g
13 USE comgeom, ONLY: aire_2d, rlatu, rlatv, rlonu, rlonv
14 USE dimens_m, ONLY: iim, jjm, llm
15 USE disvert_m, ONLY: presnivs
16 USE netcdf, ONLY: nf90_clobber, nf90_float, nf90_int
17 USE netcdf95, ONLY: nf95_close, nf95_create, nf95_def_dim, nf95_def_var, &
18 nf95_enddef, nf95_put_att, nf95_put_var, nf95_redef
19 USE nr_util, ONLY: pi
20 USE start_init_orog_m, ONLY: mask
21
22 REAL, INTENT(IN):: phis(:, :) ! (iim + 1, jjm + 1) geopotentiel au sol
23
24 ! Local:
25
26 REAL temp(iim+1, jjm+1)
27 INTEGER i, j
28
29 ! For Netcdf:
30 INTEGER ncid
31 INTEGER dimid_lonu, dimid_lonv, dimid_latu, dimid_latv, dimid_lev
32 INTEGER varid_lonu, varid_lonv, varid_latu, varid_latv
33 INTEGER varid
34 INTEGER varid_phis, varid_area, varid_mask, varid_presnivs
35
36 !-----------------------------------------------------------------
37
38 print *, "Call sequence information: grilles_gcm_netcdf_sub"
39
40 call NF95_CREATE('grilles_gcm.nc', NF90_CLOBBER, ncid)
41 call NF95_DEF_DIM(ncid, 'lonu', iim+1, dimid_lonu)
42 call NF95_DEF_DIM(ncid, 'lonv', iim+1, dimid_lonv)
43 call NF95_DEF_DIM(ncid, 'latu', jjm+1, dimid_latu)
44 call NF95_DEF_DIM(ncid, 'latv', jjm, dimid_latv)
45
46 ! Longitudes en u
47 call NF95_DEF_VAR(ncid, 'lonu', NF90_FLOAT, dimid_lonu, varid_lonu)
48 call NF95_PUT_ATT(ncid, varid_lonu, 'units', 'degrees_east')
49 call NF95_PUT_ATT(ncid, varid_lonu, 'long_name', 'Longitude en u')
50
51 ! Longitudes en v
52 call NF95_DEF_VAR(ncid, 'lonv', NF90_FLOAT, dimid_lonv, varid_lonv)
53 call NF95_PUT_ATT(ncid, varid_lonv, 'units', 'degrees_east')
54 call NF95_PUT_ATT(ncid, varid_lonv, 'long_name', 'Longitude en v')
55
56 ! Latitude en u
57 call NF95_DEF_VAR(ncid, 'latu', NF90_FLOAT, dimid_latu, varid_latu)
58 call NF95_PUT_ATT(ncid, varid_latu, 'units', 'degrees_north')
59 call NF95_PUT_ATT(ncid, varid_latu, 'long_name', 'Latitude en u')
60
61 ! Latitude en v
62 call NF95_DEF_VAR(ncid, 'latv', NF90_FLOAT, dimid_latv, varid_latv)
63 call NF95_PUT_ATT(ncid, varid_latv, 'units', 'degrees_north')
64 call NF95_PUT_ATT(ncid, varid_latv, 'long_name', 'Latitude en v')
65
66 ! ecriture de la grille u
67 call NF95_DEF_VAR(ncid, 'grille_u', NF90_FLOAT, (/dimid_lonu, &
68 dimid_latu/), varid)
69 call NF95_PUT_ATT(ncid, varid, 'units', 'Kelvin')
70 call NF95_PUT_ATT(ncid, varid, 'long_name', 'Grille aux points u')
71
72 ! ecriture de la grille v
73 call NF95_DEF_VAR(ncid, 'grille_v', NF90_FLOAT, (/dimid_lonv, &
74 dimid_latv/), varid)
75 call NF95_PUT_ATT(ncid, varid, 'units', 'Kelvin')
76 call NF95_PUT_ATT(ncid, varid, 'long_name', 'Grille aux points v')
77
78 call NF95_DEF_VAR(ncid, 'grille_s', NF90_FLOAT, (/dimid_lonv, &
79 dimid_latu/), varid)
80 call NF95_PUT_ATT(ncid, varid, 'units', 'Kelvin')
81 call NF95_PUT_ATT(ncid, varid, 'long_name', &
82 'Grille aux points scalaires')
83
84 call NF95_DEF_DIM(ncid, 'lev', llm, dimid_lev)
85 call NF95_DEF_VAR(ncid, 'presnivs', NF90_FLOAT, dimid_lev, varid_presnivs)
86
87 ! fields
88
89 call NF95_DEF_VAR(ncid, 'phis', NF90_FLOAT, (/dimid_lonv, &
90 dimid_latu/), varid_phis)
91 call NF95_DEF_VAR(ncid, 'aire', NF90_FLOAT, (/dimid_lonv, &
92 dimid_latu/), varid_area)
93 call NF95_DEF_VAR(ncid, 'mask', NF90_INT, (/dimid_lonv, dimid_latu/), &
94 varid_mask)
95
96 call NF95_ENDDEF(ncid)
97
98 ! 3-b- Ecriture de la grille pour la sortie
99
100 call NF95_PUT_VAR(ncid, varid_lonu, rlonu*180./pi)
101 call NF95_PUT_VAR(ncid, varid_lonv, rlonv*180./pi)
102 call NF95_PUT_VAR(ncid, varid_latu, rlatu*180./pi)
103 call NF95_PUT_VAR(ncid, varid_latv, rlatv*180./pi)
104
105 DO j=1, jjm+1
106 DO i=1, iim+1
107 temp(i, j)=MOD(i, 2)+MOD(j, 2)
108 ENDDO
109 ENDDO
110
111 call NF95_PUT_VAR(ncid, varid, temp)
112 call NF95_PUT_VAR(ncid, varid_presnivs, presnivs)
113 call NF95_PUT_VAR(ncid, varid_phis, phis/g)
114 call NF95_PUT_VAR(ncid, varid_area, aire_2d)
115 call NF95_PUT_VAR(ncid, varid_mask, nINT(mask))
116
117 CALL nf95_close(ncid)
118
119 END SUBROUTINE grilles_gcm_netcdf_sub
120
121 end module grilles_gcm_netcdf_sub_m

  ViewVC Help
Powered by ViewVC 1.1.21