New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
agrif_types.f90 in utils/tools/NESTING/src – NEMO

source: utils/tools/NESTING/src/agrif_types.f90 @ 12253

Last change on this file since 12253 was 11206, checked in by clem, 5 years ago

solve ticket #2280 by adding a new namelist parameter in the NESTING namelist to account for jperio of the parent grid

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