libsim Versione 7.2.4

◆ grid_dim_display()

subroutine, private grid_dim_display ( type(grid_dim), intent(in) this)
private

Display on the screen a brief content of the object.

Parametri
[in]thisobject to display

Definizione alla linea 410 del file grid_dim_class.F90.

411! Copyright (C) 2010 ARPA-SIM <urpsim@smr.arpa.emr.it>
412! authors:
413! Davide Cesari <dcesari@arpa.emr.it>
414! Paolo Patruno <ppatruno@arpa.emr.it>
415
416! This program is free software; you can redistribute it and/or
417! modify it under the terms of the GNU General Public License as
418! published by the Free Software Foundation; either version 2 of
419! the License, or (at your option) any later version.
420
421! This program is distributed in the hope that it will be useful,
422! but WITHOUT ANY WARRANTY; without even the implied warranty of
423! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
424! GNU General Public License for more details.
425
426! You should have received a copy of the GNU General Public License
427! along with this program. If not, see <http://www.gnu.org/licenses/>.
428#include "config.h"
429
433MODULE grid_dim_class
437USE err_handling
438IMPLICIT NONE
439
443TYPE grid_dim
444 INTEGER :: nx
445 INTEGER :: ny
446 DOUBLE PRECISION,POINTER :: lat(:,:)
447 DOUBLE PRECISION,POINTER :: lon(:,:)
448END TYPE grid_dim
449
450INTERFACE delete
451 MODULE PROCEDURE grid_dim_delete
452END INTERFACE
453
454INTERFACE copy
455 MODULE PROCEDURE grid_dim_copy
456END INTERFACE
457
458INTERFACE alloc
459 MODULE PROCEDURE grid_dim_alloc
460END INTERFACE
461
462INTERFACE dealloc
463 MODULE PROCEDURE grid_dim_dealloc
464END INTERFACE
465
466INTERFACE OPERATOR (==)
467 MODULE PROCEDURE grid_dim_eq
468END INTERFACE
469
470INTERFACE write_unit
471 MODULE PROCEDURE grid_dim_write_unit
472END INTERFACE
473
474INTERFACE read_unit
475 MODULE PROCEDURE grid_dim_read_unit
476END INTERFACE
477
478INTERFACE display
479 MODULE PROCEDURE grid_dim_display
480END INTERFACE
481
482PRIVATE grid_dim_delete, grid_dim_copy, grid_dim_alloc, grid_dim_dealloc, &
483 grid_dim_eq, grid_dim_read_unit, grid_dim_write_unit, grid_dim_display
484
485CONTAINS
486
487FUNCTION grid_dim_new(nx, ny) RESULT(this)
488INTEGER, INTENT(in), OPTIONAL :: nx, ny
489
490TYPE(grid_dim) :: this
491
492this%nx = optio_l(nx)
493this%ny = optio_l(ny)
494NULLIFY(this%lat, this%lon)
495
496END FUNCTION grid_dim_new
497
498
499SUBROUTINE grid_dim_delete(this)
500TYPE(grid_dim), INTENT(inout) :: this
501
502CALL dealloc(this)
503this%nx = imiss
504this%ny = imiss
505
506END SUBROUTINE grid_dim_delete
507
508
509SUBROUTINE grid_dim_alloc(this)
510TYPE(grid_dim),INTENT(inout) :: this
511
512IF (ASSOCIATED(this%lon) .AND. ASSOCIATED(this%lat)) THEN
513 IF (SIZE(this%lon, 1) == this%nx .AND. SIZE(this%lon, 2) == this%ny .AND. &
514 SIZE(this%lat, 1) == this%nx .AND. SIZE(this%lat, 2) == this%ny) RETURN
515ENDIF
516CALL dealloc(this)
517IF (c_e(this%nx) .AND. c_e(this%ny)) THEN
518 ALLOCATE(this%lon(this%nx, this%ny), this%lat(this%nx, this%ny))
519ENDIF
520
521END SUBROUTINE grid_dim_alloc
522
523
524SUBROUTINE grid_dim_dealloc(this)
525TYPE(grid_dim),INTENT(inout) :: this
526
527IF (ASSOCIATED(this%lon)) DEALLOCATE(this%lon)
528IF (ASSOCIATED(this%lat)) DEALLOCATE(this%lat)
529
530END SUBROUTINE grid_dim_dealloc
531
532
533SUBROUTINE grid_dim_copy(this, that)
534TYPE(grid_dim),INTENT(in) :: this
535TYPE(grid_dim),INTENT(out) :: that
536
537that = grid_dim_new(this%nx, this%ny)
538
539IF (ASSOCIATED(this%lon) .AND. ASSOCIATED(this%lat))THEN
540 CALL alloc(that)
541
542#ifdef DEBUG
543 IF (SIZE(this%lon,1) /= this%nx .OR. SIZE(this%lon,2) /= this%ny) THEN
544 CALL raise_error('grid_dim_copy, dimensioni non valide: '// &
545 trim(to_char(SIZE(this%lon,1)))//' '//trim(to_char(this%nx))// &
546 trim(to_char(SIZE(this%lon,2)))//' '//trim(to_char(this%ny)))
547 ENDIF
548 IF (SIZE(this%lat,1) /= this%nx .OR. SIZE(this%lat,2) /= this%ny) THEN
549 CALL raise_error('grid_dim_copy, dimensioni non valide: '// &
550 trim(to_char(SIZE(this%lat,1)))//' '//trim(to_char(this%nx))// &
551 trim(to_char(SIZE(this%lat,2)))//' '//trim(to_char(this%ny)))
552 ENDIF
553#endif
554
555 that%lon(:,:) = this%lon(:,:)
556 that%lat(:,:) = this%lat(:,:)
557ENDIF
558
559END SUBROUTINE grid_dim_copy
560
561
562ELEMENTAL FUNCTION grid_dim_eq(this, that) RESULT(res)
563TYPE(grid_dim),INTENT(IN) :: this, that
564LOGICAL :: res
565
566res = this%nx == that%nx .and. &
567 this%ny == that%ny
568
569END FUNCTION grid_dim_eq
570
571
576SUBROUTINE grid_dim_read_unit(this, unit)
577TYPE(grid_dim),INTENT(out) :: this
578INTEGER, INTENT(in) :: unit
579
580CHARACTER(len=40) :: form
581LOGICAL :: is_all
582
583INQUIRE(unit, form=form)
584IF (form == 'FORMATTED') THEN
585 READ(unit,*)this%nx,this%ny
586 READ(unit,*)is_all
587 IF (is_all) THEN
588 CALL alloc(this)
589 READ(unit,*)this%lon,this%lat
590 ELSE
591 READ(unit,*)
592 ENDIF
593ELSE
594 READ(unit)this%nx,this%ny
595 READ(unit)is_all
596 IF (is_all) THEN
597 CALL alloc(this)
598 READ(unit)this%lon,this%lat
599 ELSE
600 READ(unit)
601 ENDIF
602ENDIF
603
604END SUBROUTINE grid_dim_read_unit
605
606
611SUBROUTINE grid_dim_write_unit(this, unit)
612TYPE(grid_dim),INTENT(in) :: this
613INTEGER, INTENT(in) :: unit
614
615CHARACTER(len=40) :: form
616LOGICAL :: is_all
617
618INQUIRE(unit, form=form)
619IF (form == 'FORMATTED') THEN
620 WRITE(unit,*)this%nx,this%ny
621 is_all = (ASSOCIATED(this%lon) .AND. ASSOCIATED(this%lat))
622 WRITE(unit,*)is_all
623 IF (is_all) THEN
624 WRITE(unit,*)this%lon,this%lat
625 ELSE
626 WRITE(unit,*)
627 ENDIF
628ELSE
629 WRITE(unit)this%nx,this%ny
630 is_all = (ASSOCIATED(this%lon) .AND. ASSOCIATED(this%lat))
631 WRITE(unit)is_all
632 IF (is_all) THEN
633 WRITE(unit)this%lon,this%lat
634 ELSE
635 WRITE(unit)
636 ENDIF
637ENDIF
638
639END SUBROUTINE grid_dim_write_unit
640
641
643SUBROUTINE grid_dim_display(this)
644TYPE(grid_dim),INTENT(in) :: this
645
646print*,'Number of points along x direction',this%nx
647print*,'Number of points along y direction',this%ny
648
649END SUBROUTINE grid_dim_display
650
651END MODULE grid_dim_class
Set of functions that return a CHARACTER representation of the input variable.
Function to check whether a value is missing or not.
Utilities for CHARACTER variables.
Gestione degli errori.
Module for defining the extension and coordinates of a rectangular georeferenced grid.
Definitions of constants and functions for working with missing values.
Module for quickly interpreting the OPTIONAL parameters passed to a subprogram.
Derived type describing the extension of a grid and the geographical coordinates of each point.

Generated with Doxygen.