ROMS
Loading...
Searching...
No Matches
mod_pio_netcdf::pio_netcdf_get_fatt Interface Reference

Public Member Functions

subroutine pio_netcdf_get_fatt_dp (ng, model, ncname, piovar, attname, attvalue, foundit, piofile)
 
subroutine pio_netcdf_get_fatt_r8 (ng, model, ncname, piovar, attname, attvalue, foundit, piofile)
 

Detailed Description

Definition at line 45 of file mod_pio_netcdf.F.

Member Function/Subroutine Documentation

◆ pio_netcdf_get_fatt_dp()

subroutine mod_pio_netcdf::pio_netcdf_get_fatt::pio_netcdf_get_fatt_dp ( integer, intent(in) ng,
integer, intent(in) model,
character (len=*), intent(in) ncname,
type (var_desc_t), intent(in) piovar,
character (len=*), dimension(:), intent(in) attname,
real(dp), dimension(:), intent(out) attvalue,
logical, dimension(:), intent(out) foundit,
type (file_desc_t), intent(in), optional piofile )

Definition at line 2439 of file mod_pio_netcdf.F.

2442!
2443!=======================================================================
2444! !
2445! This routine gets requested variable double-precision attribute(s). !
2446! !
2447! On Input: !
2448! !
2449! ng Nested grid number (integer) !
2450! model Calling model identifier (integer) !
2451! ncname NetCDF file name (string) !
2452! pioVar PIO variable descriptor, TYPE(Var_desc_t) !
2453! pioVar%varID Variable ID !
2454! pioVar%ncid File ID !
2455! AttName Attribute name to read (string array) !
2456! pioFile PIO file descriptor, TYPE(File_desc_t), OPTIONAL !
2457! pioFile%fh file handler !
2458! pioFile%iosystem IO system descriptor (struct) !
2459! !
2460! On Ouput: !
2461! !
2462! AttValue Attribute value (double precision array) !
2463! foundit Switch (T/F) activated when the requested !
2464! attribute is found (logical array) !
2465! !
2466!=======================================================================
2467!
2468! Imported variable declarations.
2469!
2470 integer, intent(in) :: ng, model
2471!
2472 character (len=*), intent(in) :: ncname
2473 character (len=*), intent(in) :: AttName(:)
2474!
2475 logical, intent(out) :: foundit(:)
2476!
2477 real(dp), intent(out) :: AttValue(:)
2478!
2479 TYPE (Var_desc_t), intent(in) :: pioVar
2480 TYPE (File_desc_t), intent(in), optional :: pioFile
2481!
2482! Local variable declarations.
2483!
2484 integer :: i, j, my_natts, natts, status
2485!
2486 character (len=40) :: my_Aname
2487 character (len=40) :: my_Vname
2488
2489 character (len=*), parameter :: MyFile = &
2490 & __FILE__//", pio_netcdf_get_fatt_dp"
2491!
2492 TYPE (File_desc_t) :: my_pioFile
2493!
2494!-----------------------------------------------------------------------
2495! Inquire ID of requested variable.
2496!-----------------------------------------------------------------------
2497!
2498! Get number of variable attributes to process and initialize.
2499!
2500 natts=ubound(attname, dim=1)
2501 DO i=1,natts
2502 foundit(i)=.false.
2503 attvalue(i)=0.0_dp
2504 END DO
2505!
2506! If appropriate, open file for reading.
2507!
2508 IF (.not.PRESENT(piofile)) THEN
2509 CALL pio_netcdf_open (ng, model, trim(ncname), 0, my_piofile)
2510 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
2511 ELSE
2512 my_piofile=piofile
2513 END IF
2514!
2515! Inquire about requested attribute value.
2516!
2517 IF (piovar%varID.eq.pio_global) THEN
2518 status=pio_inquire(my_piofile, &
2519 & nattributes = my_natts)
2520 ELSE
2521 status=pio_inquire_variable(my_piofile, piovar, &
2522 & name = my_vname, &
2523 & natts = my_natts)
2524 END IF
2525 IF (status.eq.pio_noerr) THEN
2526 DO j=1,my_natts
2527 status=pio_inq_attname(my_piofile, piovar, j, my_aname)
2528 IF (status.eq.pio_noerr) THEN
2529 DO i=1,natts
2530 IF (trim(my_aname).eq.trim(attname(i))) THEN
2531 status=pio_get_att(my_piofile, piovar, &
2532 & trim(attname(i)), attvalue(i))
2533 IF (founderror(status, pio_noerr, &
2534 & __line__, myfile)) THEN
2535 IF (master) WRITE (stdout,10) trim(attname(i)), &
2536 & trim(my_vname), &
2537 & trim(ncname), &
2538 & trim(sourcefile)
2539 exit_flag=2
2540 ioerror=status
2541 END IF
2542 foundit(i)=.true.
2543 EXIT
2544 END IF
2545 END DO
2546 ELSE
2547 IF (master) WRITE (stdout,20) j, &
2548 & trim(my_vname), &
2549 & trim(ncname), &
2550 & trim(sourcefile)
2551 exit_flag=2
2552 ioerror=status
2553 EXIT
2554 END IF
2555 END DO
2556 ELSE
2557 IF (master) WRITE (stdout,30) trim(my_vname), &
2558 & trim(ncname), &
2559 & trim(sourcefile)
2560 exit_flag=2
2561 ioerror=status
2562 END IF
2563!
2564! If applicable, close input NetCDF file.
2565!
2566 IF (.not.PRESENT(piofile)) THEN
2567 CALL pio_netcdf_close (ng, model, my_piofile, ncname, .false.)
2568 END IF
2569!
2570 10 FORMAT (/,' PIO_NETCDF_GET_FATT_DP - error while reading ', &
2571 & 'attribute:',1x,a,'for variable',1x,a, &
2572 & /,26x,'in input file:',2x,a,/,26x,'call from:',2x,a)
2573 20 FORMAT (/,' PIO_NETCDF_GET_FATT_DP - error while inquiring ', &
2574 & 'attribute:',1x,i2.2,'for variable',1x,a, &
2575 & /,26x,'in input file:',2x,a,/,26x,'call from:',2x,a)
2576 30 FORMAT (/,' PIO_NETCDF_GET_FATT_DP - error while inquiring ', &
2577 & 'number of attributes for variable:',1x,a, &
2578 & /,26x,'in input file:',2x,a,/,26x,'call from:',2x,a)
2579!
2580 RETURN

References mod_scalars::exit_flag, strings_mod::founderror(), mod_iounits::ioerror, mod_parallel::master, mod_scalars::noerror, mod_pio_netcdf::pio_netcdf_close(), mod_pio_netcdf::pio_netcdf_open(), mod_iounits::sourcefile, and mod_iounits::stdout.

Here is the call graph for this function:

◆ pio_netcdf_get_fatt_r8()

subroutine mod_pio_netcdf::pio_netcdf_get_fatt::pio_netcdf_get_fatt_r8 ( integer, intent(in) ng,
integer, intent(in) model,
character (len=*), intent(in) ncname,
type (var_desc_t), intent(in) piovar,
character (len=*), dimension(:), intent(in) attname,
real(r8), dimension(:), intent(out) attvalue,
logical, dimension(:), intent(out) foundit,
type (file_desc_t), intent(in), optional piofile )

Definition at line 2584 of file mod_pio_netcdf.F.

2587!
2588!=======================================================================
2589! !
2590! This routine gets requested variable floating-point attribute(s). !
2591! !
2592! On Input: !
2593! !
2594! ng Nested grid number (integer) !
2595! model Calling model identifier (integer) !
2596! ncname NetCDF file name (string) !
2597! pioVar PIO variable descriptor, TYPE(Var_desc_t) !
2598! pioVar%varID Variable ID !
2599! pioVar%ncid File ID !
2600! AttName Attribute name to read (string array) !
2601! pioFile PIO file descriptor, TYPE(File_desc_t), OPTIONAL !
2602! pioFile%fh file handler !
2603! pioFile%iosystem IO system descriptor (struct) !
2604! !
2605! On Ouput: !
2606! !
2607! AttValue Attribute value (real array) !
2608! foundit Switch (T/F) activated when the requested !
2609! attribute is found (logical array) !
2610! !
2611!=======================================================================
2612!
2613! Imported variable declarations.
2614!
2615 integer, intent(in) :: ng, model
2616!
2617 character (len=*), intent(in) :: ncname
2618 character (len=*), intent(in) :: AttName(:)
2619!
2620 logical, intent(out) :: foundit(:)
2621!
2622 real(r8), intent(out) :: AttValue(:)
2623!
2624 TYPE (Var_desc_t), intent(in) :: pioVar
2625 TYPE (File_desc_t), intent(in), optional :: pioFile
2626!
2627! Local variable declarations.
2628!
2629 integer :: i, j, my_natts, natts, status
2630!
2631 character (len=40) :: my_Aname
2632 character (len=40) :: my_Vname
2633
2634 character (len=*), parameter :: MyFile = &
2635 & __FILE__//", pio_netcdf_get_fatt"
2636!
2637 TYPE (File_desc_t) :: my_pioFile
2638!
2639!-----------------------------------------------------------------------
2640! Inquire ID of requested variable.
2641!-----------------------------------------------------------------------
2642!
2643! Get number of variable attributes to process and initialize.
2644!
2645 natts=ubound(attname, dim=1)
2646 DO i=1,natts
2647 foundit(i)=.false.
2648 attvalue(i)=0.0_r8
2649 END DO
2650!
2651! If appropriate, open file for reading.
2652!
2653 IF (.not.PRESENT(piofile)) THEN
2654 CALL pio_netcdf_open (ng, model, trim(ncname), 0, my_piofile)
2655 IF (founderror(exit_flag, noerror, __line__, myfile)) RETURN
2656 ELSE
2657 my_piofile=piofile
2658 END IF
2659!
2660! Inquire about requested attribute value.
2661!
2662 IF (piovar%varID.eq.pio_global) THEN
2663 status=pio_inquire(my_piofile, &
2664 & nattributes = my_natts)
2665 ELSE
2666 status=pio_inquire_variable(my_piofile, piovar, &
2667 & name = my_vname, &
2668 & natts = my_natts)
2669 END IF
2670 IF (status.eq.pio_noerr) THEN
2671 DO j=1,my_natts
2672 status=pio_inq_attname(my_piofile, piovar, j, my_aname)
2673 IF (status.eq.pio_noerr) THEN
2674 DO i=1,natts
2675 IF (trim(my_aname).eq.trim(attname(i))) THEN
2676 status=pio_get_att(my_piofile, piovar, &
2677 & trim(attname(i)), attvalue(i))
2678 IF (founderror(status, pio_noerr, &
2679 & __line__, myfile)) THEN
2680 IF (master) WRITE (stdout,10) trim(attname(i)), &
2681 & trim(my_vname), &
2682 & trim(ncname), &
2683 & trim(sourcefile)
2684 exit_flag=2
2685 ioerror=status
2686 END IF
2687 foundit(i)=.true.
2688 EXIT
2689 END IF
2690 END DO
2691 ELSE
2692 IF (master) WRITE (stdout,20) j, &
2693 & trim(my_vname), &
2694 & trim(ncname), &
2695 & trim(sourcefile)
2696 exit_flag=2
2697 ioerror=status
2698 EXIT
2699 END IF
2700 END DO
2701 ELSE
2702 IF (master) WRITE (stdout,30) trim(my_vname), &
2703 & trim(ncname), &
2704 & trim(sourcefile)
2705 exit_flag=2
2706 ioerror=status
2707 END IF
2708!
2709! If applicable, close input NetCDF file.
2710!
2711 IF (.not.PRESENT(piofile)) THEN
2712 CALL pio_netcdf_close (ng, model, my_piofile, ncname, .false.)
2713 END IF
2714!
2715 10 FORMAT (/,' PIO_NETCDF_GET_FATT_R8 - error while reading ', &
2716 & 'attribute:',1x,a,'for variable',1x,a, &
2717 & /,26x,'in input file:',2x,a,/,26x,'call from:',2x,a)
2718 20 FORMAT (/,' PIO_NETCDF_GET_FATT_R8 - error while inquiring ', &
2719 & 'attribute:',1x,i2.2,'for variable',1x,a, &
2720 & /,26x,'in input file:',2x,a,/,26x,'call from:',2x,a)
2721 30 FORMAT (/,' PIO_NETCDF_GET_FATT_R8 - error while inquiring ', &
2722 & 'number of attributes for variable:',1x,a, &
2723 & /,26x,'in input file:',2x,a,/,26x,'call from:',2x,a)
2724!
2725 RETURN

References mod_scalars::exit_flag, strings_mod::founderror(), mod_iounits::ioerror, mod_parallel::master, mod_scalars::noerror, mod_pio_netcdf::pio_netcdf_close(), mod_pio_netcdf::pio_netcdf_open(), mod_iounits::sourcefile, and mod_iounits::stdout.

Here is the call graph for this function:

The documentation for this interface was generated from the following file: