1 | !************************************************************************ |
---|
2 | ! Fortran 95 OPA Nesting tools * |
---|
3 | ! * |
---|
4 | ! Copyright (C) 2005 Florian Lemarié (Florian.Lemarie@imag.fr) * |
---|
5 | ! * |
---|
6 | !************************************************************************ |
---|
7 | ! |
---|
8 | MODULE agrif_types |
---|
9 | ! |
---|
10 | PUBLIC |
---|
11 | ! |
---|
12 | !***************************** |
---|
13 | ! Coordinates type definition |
---|
14 | !***************************** |
---|
15 | TYPE Coordinates |
---|
16 | ! |
---|
17 | REAL*8, DIMENSION(:,:), POINTER :: nav_lon,nav_lat => NULL() |
---|
18 | REAL*8, DIMENSION(:,:), POINTER :: glamv, glamu, glamt, glamf => NULL() |
---|
19 | REAL*8, DIMENSION(:,:), POINTER :: gphit, gphiu, gphiv, gphif => NULL() |
---|
20 | REAL*8, DIMENSION(:,:), POINTER :: e1t, e1u, e1v, e1f => NULL() |
---|
21 | REAL*8, DIMENSION(:,:), POINTER :: e2t, e2u, e2v, e2f => NULL() |
---|
22 | REAL*8, DIMENSION(:,:), POINTER :: bathy_level => NULL() |
---|
23 | REAL*8, DIMENSION(:,:), POINTER :: bathy_meter => NULL() |
---|
24 | REAL*8, DIMENSION(:,:,:),POINTER :: fmask,umask,vmask,tmask => NULL() |
---|
25 | REAL*8, DIMENSION(:,:,:),POINTER :: e3t_ps,e3w_ps,gdept_ps,gdepwps => NULL() |
---|
26 | REAL*8, DIMENSION(:,:),POINTER :: gdepw_ps => NULL() |
---|
27 | REAL*8, DIMENSION(:), POINTER :: gdeptht => NULL() |
---|
28 | INTEGER, DIMENSION(:) , POINTER :: time_steps => NULL() |
---|
29 | ! |
---|
30 | END TYPE Coordinates |
---|
31 | ! |
---|
32 | ! |
---|
33 | ! |
---|
34 | CHARACTER*8,DIMENSION(10) :: flxtab = (/'socliot1','socliot2','socliopl',& |
---|
35 | 'socliocl','socliohu','socliowi','soshfldo','sohefldo','sowaflup','sofbt '/) |
---|
36 | ! |
---|
37 | ! |
---|
38 | !************************************************************** |
---|
39 | ! Declaration of various input file variables (namelist.input) |
---|
40 | !************************************************************** |
---|
41 | ! |
---|
42 | INTEGER irafx,irafy |
---|
43 | INTEGER nxfin,nyfin |
---|
44 | INTEGER, PARAMETER :: nbghostcellsfine = 2 |
---|
45 | INTEGER, PARAMETER :: nbghostcellscoarse = 1 |
---|
46 | ! |
---|
47 | INTEGER imin,jmin,imax,jmax,rho,rhot |
---|
48 | INTEGER shlat |
---|
49 | INTEGER N,type_bathy_interp |
---|
50 | ! |
---|
51 | INTEGER jpizoom,jpjzoom,nb_connection_pts |
---|
52 | ! |
---|
53 | REAL*8 rn_hmin |
---|
54 | REAL*8 ppkth2, ppacr2, ppkth,ppacr,ppdzmin,pphmax,smoothing_factor,e3zps_min,e3zps_rat |
---|
55 | REAL*8 psur,pa0,pa1,pa2,adatrj |
---|
56 | ! |
---|
57 | LOGICAL ldbletanh,ln_e3_dep |
---|
58 | LOGICAL partial_steps,smoothing,bathy_update |
---|
59 | LOGICAL new_topo,removeclosedseas,dimg,iom_activated |
---|
60 | ! |
---|
61 | CHARACTER*100 parent_meshmask_file,elevation_database,parent_bathy_meter |
---|
62 | CHARACTER*100 elevation_name,parent_batmet_name |
---|
63 | CHARACTER*100 parent_coordinate_file,restart_file,updated_parent_file,restart_trc_file |
---|
64 | CHARACTER*100 dimg_output_file,interp_type |
---|
65 | ! |
---|
66 | CHARACTER(len=80),DIMENSION(20) :: flx_Files, u_files, v_files |
---|
67 | CHARACTER(len=255),DIMENSION(20) :: VAR_INTERP |
---|
68 | ! |
---|
69 | NAMELIST /input_output/iom_activated |
---|
70 | ! |
---|
71 | NAMELIST /coarse_grid_files/parent_coordinate_file,parent_meshmask_file |
---|
72 | ! |
---|
73 | NAMELIST /bathymetry/new_topo,elevation_database,elevation_name,smoothing,smoothing_factor, & |
---|
74 | nb_connection_pts,removeclosedseas,type_bathy_interp,rn_hmin |
---|
75 | ! |
---|
76 | NAMELIST /nesting/imin,imax,jmin,jmax,rho,rhot,bathy_update,updated_parent_file |
---|
77 | ! |
---|
78 | NAMELIST /vertical_grid/ppkth,ppacr,ppdzmin,pphmax,psur,pa0,pa1,N,ldbletanh,ln_e3_dep,pa2,ppkth2,ppacr2 |
---|
79 | ! |
---|
80 | NAMELIST /partial_cells/partial_steps,parent_bathy_meter,parent_batmet_name,e3zps_min,e3zps_rat |
---|
81 | ! |
---|
82 | NAMELIST /nemo_coarse_grid/ jpizoom,jpjzoom |
---|
83 | ! |
---|
84 | NAMELIST /forcing_files/ flx_files, u_files, v_files |
---|
85 | ! |
---|
86 | NAMELIST /interp/ VAR_INTERP |
---|
87 | ! |
---|
88 | NAMELIST /restart/ restart_file,shlat,dimg,dimg_output_file,adatrj,interp_type |
---|
89 | |
---|
90 | NAMELIST /restart_trc/ restart_trc_file,interp_type |
---|
91 | |
---|
92 | INTEGER :: connectionsize = 2 |
---|
93 | ! |
---|
94 | CONTAINS |
---|
95 | ! |
---|
96 | !******************************************************** |
---|
97 | !subroutine agrif_grid_allocate * |
---|
98 | ! * |
---|
99 | !allocation of grid type elements * |
---|
100 | ! according to nx and ny * |
---|
101 | ! * |
---|
102 | ! * |
---|
103 | !******************************************************** |
---|
104 | ! |
---|
105 | SUBROUTINE agrif_grid_allocate(Grid,nx,ny) |
---|
106 | ! |
---|
107 | TYPE(Coordinates) :: Grid |
---|
108 | INTEGER :: nx,ny |
---|
109 | ! |
---|
110 | ALLOCATE(Grid%nav_lon(nx,ny),Grid%nav_lat(nx,ny)) |
---|
111 | ! |
---|
112 | ALLOCATE(Grid%glamt(nx,ny),Grid%glamu(nx,ny),Grid%glamv(nx,ny),Grid%glamf(nx,ny)) |
---|
113 | ALLOCATE(Grid%gphit(nx,ny),Grid%gphiu(nx,ny),Grid%gphiv(nx,ny),Grid%gphif(nx,ny)) |
---|
114 | ! |
---|
115 | ALLOCATE(Grid%e1t(nx,ny),Grid%e1u(nx,ny),Grid%e1v(nx,ny),Grid%e1f(nx,ny)) |
---|
116 | ALLOCATE(Grid%e2t(nx,ny),Grid%e2u(nx,ny),Grid%e2v(nx,ny),Grid%e2f(nx,ny)) |
---|
117 | ! |
---|
118 | ALLOCATE(Grid%bathy_level(nx,ny)) |
---|
119 | ! |
---|
120 | END SUBROUTINE agrif_grid_allocate |
---|
121 | ! |
---|
122 | ! |
---|
123 | !************************************************************************ |
---|
124 | ! * |
---|
125 | ! subroutine read_namelist * |
---|
126 | ! * |
---|
127 | ! read variables contained in namelist.input file * |
---|
128 | ! filled in by user * |
---|
129 | ! * |
---|
130 | !************************************************************************ |
---|
131 | ! |
---|
132 | SUBROUTINE read_namelist(namelistname) |
---|
133 | ! |
---|
134 | IMPLICIT NONE |
---|
135 | CHARACTER(len=80) :: namelistname |
---|
136 | CHARACTER*255 :: output |
---|
137 | LOGICAL :: is_it_there |
---|
138 | INTEGER unit_nml |
---|
139 | ! |
---|
140 | FLX_FILES = '/NULL' |
---|
141 | U_FILES = '/NULL' |
---|
142 | V_FILES = '/NULL' |
---|
143 | VAR_INTERP = 'NULL' |
---|
144 | unit_nml = Agrif_Get_Unit() |
---|
145 | ! |
---|
146 | INQUIRE ( FILE = namelistname , EXIST = is_it_there ) |
---|
147 | ! |
---|
148 | IF ( is_it_there ) THEN |
---|
149 | ! |
---|
150 | OPEN ( FILE = namelistname , & |
---|
151 | UNIT = unit_nml , & |
---|
152 | STATUS = 'OLD' , & |
---|
153 | FORM = 'FORMATTED' , & |
---|
154 | ACTION = 'READ' , & |
---|
155 | ACCESS = 'SEQUENTIAL' ) |
---|
156 | ! |
---|
157 | REWIND(unit_nml) |
---|
158 | READ (unit_nml , NML = input_output) |
---|
159 | READ (unit_nml , NML = coarse_grid_files) |
---|
160 | READ (unit_nml , NML = bathymetry) |
---|
161 | READ (unit_nml , NML = nesting) |
---|
162 | READ (unit_nml , NML = vertical_grid) |
---|
163 | READ (unit_nml , NML = partial_cells) |
---|
164 | READ (unit_nml , NML = nemo_coarse_grid ) |
---|
165 | READ (unit_nml , NML = forcing_files ) |
---|
166 | READ (unit_nml , NML = interp ) |
---|
167 | READ (unit_nml , NML = restart ) |
---|
168 | READ (unit_nml , NML = restart_trc ) |
---|
169 | CLOSE(unit_nml) |
---|
170 | ! |
---|
171 | irafx = rho |
---|
172 | irafy = rho |
---|
173 | imin = imin + jpizoom - 1 |
---|
174 | imax = imax + jpizoom - 1 |
---|
175 | jmin = jmin + jpjzoom - 1 |
---|
176 | jmax = jmax + jpjzoom - 1 |
---|
177 | ! |
---|
178 | nxfin = (imax-imin)*irafx+nbghostcellsfine*2 |
---|
179 | nyfin = (jmax-jmin)*irafy+nbghostcellsfine*2 |
---|
180 | ! |
---|
181 | ELSE |
---|
182 | ! |
---|
183 | PRINT *,'namelist file ''',TRIM(namelistname),''' not found' |
---|
184 | STOP |
---|
185 | ! |
---|
186 | END IF |
---|
187 | ! |
---|
188 | ! |
---|
189 | END SUBROUTINE read_namelist |
---|
190 | |
---|
191 | INTEGER FUNCTION agrif_int(x) |
---|
192 | |
---|
193 | REAL :: x |
---|
194 | INTEGER ::i |
---|
195 | |
---|
196 | i = FLOOR(x) + 1 |
---|
197 | |
---|
198 | IF( ABS(x - i).LE.0.0001 )THEN |
---|
199 | agrif_int = i |
---|
200 | ELSE |
---|
201 | agrif_int = i-1 |
---|
202 | ENDIF |
---|
203 | |
---|
204 | END FUNCTION agrif_int |
---|
205 | ! |
---|
206 | !************************************************* |
---|
207 | ! function Agrif_Get_Unit |
---|
208 | !************************************************* |
---|
209 | ! |
---|
210 | |
---|
211 | INTEGER FUNCTION Agrif_Get_Unit() |
---|
212 | ! |
---|
213 | INTEGER n |
---|
214 | LOGICAL op |
---|
215 | INTEGER :: nunit |
---|
216 | INTEGER :: iii,out,iiimax |
---|
217 | ! |
---|
218 | DO n = 7,1000 |
---|
219 | ! |
---|
220 | INQUIRE(Unit=n,Opened=op) |
---|
221 | ! |
---|
222 | IF (.NOT.op) EXIT |
---|
223 | ! |
---|
224 | ENDDO |
---|
225 | ! |
---|
226 | Agrif_Get_Unit=n |
---|
227 | ! |
---|
228 | ! |
---|
229 | END FUNCTION Agrif_Get_Unit |
---|
230 | ! |
---|
231 | END MODULE agrif_types |
---|