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