130 #include "sll_errors.h"
131 #include "sll_memory.h"
132 #include "sll_working_precision.h"
148 sll_int32 :: num_cells
149 sll_real64 :: eta_min
150 sll_real64 :: eta_max
151 sll_real64 :: eta_in_min
152 sll_real64 :: eta_in_max
153 sll_real64 :: density_out_min
154 sll_real64 :: density_in
155 sll_real64 :: density_out_max
156 character(len=256) :: label
158 procedure, pass(self) :: init => init_nml_mesh_1d_two_grid_cart
159 procedure, pass(self) :: init_1 => init_nml_mesh_1d_two_grid_cart_1
160 procedure, pass(self) :: init_2 => init_nml_mesh_1d_two_grid_cart_2
161 procedure, pass(self) :: init_3 => init_nml_mesh_1d_two_grid_cart_3
162 procedure, pass(self) :: init_4 => init_nml_mesh_1d_two_grid_cart_4
163 procedure, pass(self) :: init_clone => init_clone_nml_mesh_1d_two_grid_cart
192 character(len=*),
intent(in) :: filename
193 sll_real64,
pointer,
intent(out) :: array(:)
194 character(len=*),
intent(in),
optional :: clone
195 sll_int32,
intent(in),
optional :: proc_id
200 sll_int32 :: num_cells
201 sll_real64 :: eta_min
202 sll_real64 :: eta_max
203 sll_real64 :: bloc_coord(2)
204 sll_int32 :: bloc_index(3)
206 if (
present(clone))
then
207 call self%init_clone(clone, filename, proc_id)
209 call self%init(filename, proc_id)
212 num_cells = self%num_cells
213 eta_min = self%eta_min
214 eta_max = self%eta_max
215 sll_allocate(array(num_cells + 1), ierr)
216 bloc_coord(1) = (self%eta_in_max - self%eta_in_min)/(eta_max - eta_min)
217 bloc_coord(2) = (self%eta_in_max - self%eta_in_min)/(eta_max - eta_min)
218 bloc_index(1) = floor(self%density_out_min)
219 bloc_index(2) = floor(self%density_in)
220 bloc_index(3) = floor(self%density_out_max)
224 array = eta_min + array*(eta_max - eta_min)
237 character(len=*),
intent(in) :: filename
238 character(len=*),
intent(in),
optional :: clone
239 sll_int32,
intent(in),
optional :: proc_id
242 sll_int32 :: proc_id_loc
244 if (
present(clone))
then
245 call self%init_clone(clone, filename, proc_id)
247 call self%init(filename, proc_id)
250 if (
present(proc_id))
then
251 proc_id_loc = proc_id
256 if (proc_id_loc == 0)
then
257 print *,
'#nml_mesh_1d_two_grid_cart:'
259 print *,
'#label=', trim(self%label)
260 print *,
'#num_cells=', self%num_cells
261 print *,
'#eta_min=', self%eta_min
262 print *,
'#eta_max=', self%eta_max
263 print *,
'#eta_in_min=', self%eta_in_min
264 print *,
'#eta_in_max=', self%eta_in_max
265 print *,
'#density_out_min=', self%density_out_min
266 print *,
'#density_in=', self%density_in
267 print *,
'#density_out_max=', self%density_out_max
272 #ifndef DOXYGEN_SHOULD_SKIP_THIS
274 subroutine init_clone_nml_mesh_1d_two_grid_cart( &
280 character(len=*),
intent(in) :: clone
281 character(len=*),
intent(in) :: filename
282 sll_int32,
intent(in),
optional :: proc_id
284 character(len=256) :: err_msg
285 character(len=256) :: caller
287 caller =
'init_clone_nml_mesh_1d_two_grid_cart'
290 call self%init_1(filename, proc_id)
292 call self%init_2(filename, proc_id)
294 call self%init_3(filename, proc_id)
296 call self%init_4(filename, proc_id)
298 err_msg =
'bad value for clone'
299 sll_error(trim(caller), trim(err_msg))
302 end subroutine init_clone_nml_mesh_1d_two_grid_cart
304 subroutine init_nml_mesh_1d_two_grid_cart( &
309 character(len=*),
intent(in) :: filename
310 sll_int32,
intent(in),
optional :: proc_id
312 sll_int32 :: namelist_id
315 character(len=256) :: err_msg
316 character(len=256) :: caller
317 sll_int32 :: num_cells
318 sll_real64 :: eta_min
319 sll_real64 :: eta_max
320 sll_real64 :: eta_in_min
321 sll_real64 :: eta_in_max
322 sll_real64 :: density_out_min
323 sll_real64 :: density_in
324 sll_real64 :: density_out_max
325 sll_int32 :: proc_id_loc
327 namelist /mesh_1d_two_grid_cart/ &
336 caller =
'init_nml_mesh_1d_two_grid_cart'
337 if (
present(proc_id))
then
338 proc_id_loc = proc_id
343 call set_default_values( &
356 file=trim(filename)//
'.nml', &
358 if (io_stat /= 0)
then
360 'failed to open first file '//trim(filename)//
'.nml'
361 sll_error(trim(caller), trim(err_msg))
364 read (namelist_id, mesh_1d_two_grid_cart)
365 self%label =
"no_label"
366 self%num_cells = num_cells
367 self%eta_min = eta_min
368 self%eta_max = eta_max
369 self%eta_in_min = eta_in_min
370 self%eta_in_max = eta_in_max
371 self%density_out_min = density_out_min
372 self%density_in = density_in
373 self%density_out_max = density_out_max
376 end subroutine init_nml_mesh_1d_two_grid_cart
378 subroutine init_nml_mesh_1d_two_grid_cart_1( &
383 character(len=*),
intent(in) :: filename
384 sll_int32,
intent(in),
optional :: proc_id
386 sll_int32 :: namelist_id
389 character(len=256) :: err_msg
390 character(len=256) :: caller
391 sll_int32 :: num_cells_1
392 sll_real64 :: eta_min_1
393 sll_real64 :: eta_max_1
394 sll_real64 :: eta_in_min_1
395 sll_real64 :: eta_in_max_1
396 sll_real64 :: density_out_min_1
397 sll_real64 :: density_in_1
398 sll_real64 :: density_out_max_1
399 sll_int32 :: proc_id_loc
401 namelist /mesh_1d_two_grid_cart_1/ &
411 caller =
'init_nml_mesh_1d_two_grid_cart_1'
412 if (
present(proc_id))
then
413 proc_id_loc = proc_id
418 call set_default_values( &
431 file=trim(filename)//
'.nml', &
433 if (io_stat /= 0)
then
435 'failed to open first file '//trim(filename)//
'.nml'
436 sll_error(trim(caller), trim(err_msg))
439 read (namelist_id, mesh_1d_two_grid_cart_1)
441 self%num_cells = num_cells_1
442 self%eta_min = eta_min_1
443 self%eta_max = eta_max_1
444 self%eta_in_min = eta_in_min_1
445 self%eta_in_max = eta_in_max_1
446 self%density_out_min = density_out_min_1
447 self%density_in = density_in_1
448 self%density_out_max = density_out_max_1
451 end subroutine init_nml_mesh_1d_two_grid_cart_1
453 subroutine init_nml_mesh_1d_two_grid_cart_2( &
458 character(len=*),
intent(in) :: filename
459 sll_int32,
intent(in),
optional :: proc_id
461 sll_int32 :: namelist_id
464 character(len=256) :: err_msg
465 character(len=256) :: caller
466 sll_int32 :: num_cells_2
467 sll_real64 :: eta_min_2
468 sll_real64 :: eta_max_2
469 sll_real64 :: eta_in_min_2
470 sll_real64 :: eta_in_max_2
471 sll_real64 :: density_out_min_2
472 sll_real64 :: density_in_2
473 sll_real64 :: density_out_max_2
474 sll_int32 :: proc_id_loc
476 namelist /mesh_1d_two_grid_cart_2/ &
486 caller =
'init_nml_mesh_1d_two_grid_cart_2'
487 if (
present(proc_id))
then
488 proc_id_loc = proc_id
493 call set_default_values( &
506 file=trim(filename)//
'.nml', &
508 if (io_stat /= 0)
then
510 'failed to open first file '//trim(filename)//
'.nml'
511 sll_error(trim(caller), trim(err_msg))
514 read (namelist_id, mesh_1d_two_grid_cart_2)
516 self%num_cells = num_cells_2
517 self%eta_min = eta_min_2
518 self%eta_max = eta_max_2
519 self%eta_in_min = eta_in_min_2
520 self%eta_in_max = eta_in_max_2
521 self%density_out_min = density_out_min_2
522 self%density_in = density_in_2
523 self%density_out_max = density_out_max_2
526 end subroutine init_nml_mesh_1d_two_grid_cart_2
528 subroutine init_nml_mesh_1d_two_grid_cart_3( &
533 character(len=*),
intent(in) :: filename
534 sll_int32,
intent(in),
optional :: proc_id
536 sll_int32 :: namelist_id
539 character(len=256) :: err_msg
540 character(len=256) :: caller
541 sll_int32 :: num_cells_3
542 sll_real64 :: eta_min_3
543 sll_real64 :: eta_max_3
544 sll_real64 :: eta_in_min_3
545 sll_real64 :: eta_in_max_3
546 sll_real64 :: density_out_min_3
547 sll_real64 :: density_in_3
548 sll_real64 :: density_out_max_3
549 sll_int32 :: proc_id_loc
551 namelist /mesh_1d_two_grid_cart_3/ &
561 caller =
'init_nml_mesh_1d_two_grid_cart_3'
562 if (
present(proc_id))
then
563 proc_id_loc = proc_id
568 call set_default_values( &
581 file=trim(filename)//
'.nml', &
583 if (io_stat /= 0)
then
585 'failed to open first file '//trim(filename)//
'.nml'
586 sll_error(trim(caller), trim(err_msg))
589 read (namelist_id, mesh_1d_two_grid_cart_3)
591 self%num_cells = num_cells_3
592 self%eta_min = eta_min_3
593 self%eta_max = eta_max_3
594 self%eta_in_min = eta_in_min_3
595 self%eta_in_max = eta_in_max_3
596 self%density_out_min = density_out_min_3
597 self%density_in = density_in_3
598 self%density_out_max = density_out_max_3
601 end subroutine init_nml_mesh_1d_two_grid_cart_3
603 subroutine init_nml_mesh_1d_two_grid_cart_4( &
608 character(len=*),
intent(in) :: filename
609 sll_int32,
intent(in),
optional :: proc_id
611 sll_int32 :: namelist_id
614 character(len=256) :: err_msg
615 character(len=256) :: caller
616 sll_int32 :: num_cells_4
617 sll_real64 :: eta_min_4
618 sll_real64 :: eta_max_4
619 sll_real64 :: eta_in_min_4
620 sll_real64 :: eta_in_max_4
621 sll_real64 :: density_out_min_4
622 sll_real64 :: density_in_4
623 sll_real64 :: density_out_max_4
624 sll_int32 :: proc_id_loc
626 namelist /mesh_1d_two_grid_cart_4/ &
636 caller =
'init_nml_mesh_1d_two_grid_cart_4'
637 if (
present(proc_id))
then
638 proc_id_loc = proc_id
643 call set_default_values( &
656 file=trim(filename)//
'.nml', &
658 if (io_stat /= 0)
then
660 'failed to open first file '//trim(filename)//
'.nml'
661 sll_error(trim(caller), trim(err_msg))
664 read (namelist_id, mesh_1d_two_grid_cart_4)
666 self%num_cells = num_cells_4
667 self%eta_min = eta_min_4
668 self%eta_max = eta_max_4
669 self%eta_in_min = eta_in_min_4
670 self%eta_in_max = eta_in_max_4
671 self%density_out_min = density_out_min_4
672 self%density_in = density_in_4
673 self%density_out_max = density_out_max_4
676 end subroutine init_nml_mesh_1d_two_grid_cart_4
678 subroutine set_default_values( &
687 sll_int32,
intent(inout) :: num_cells
688 sll_real64,
intent(inout) :: eta_min
689 sll_real64,
intent(inout) :: eta_max
690 sll_real64,
intent(inout) :: eta_in_min
691 sll_real64,
intent(inout) :: eta_in_max
692 sll_real64,
intent(inout) :: density_out_min
693 sll_real64,
intent(inout) :: density_in
694 sll_real64,
intent(inout) :: density_out_max
701 density_out_min = 1._f64
703 density_out_max = 1._f64
705 end subroutine set_default_values
707 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
initialization of 1d two grid cartesian mesh from namelist
subroutine s_nml_mesh_1d_two_grid_cart_array(filename, array, clone, proc_id)
create 1d array from namelist
subroutine s_nml_mesh_1d_two_grid_cart_print(filename, clone, proc_id)
print namelist info
Some common numerical utilities.
subroutine, public sll_s_compute_mesh_from_bloc(bloc_coord, bloc_index, node_positions)
subroutine, public sll_s_compute_bloc(bloc_coord, bloc_index, N)
subroutine, public sll_s_new_file_id(file_id, error)
Get a file unit number free before creating a file.