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