401      character (len=*), 
intent(in) :: filename
 
  407      logical :: isdat, isyaml, connected, debug_write
 
  409      real(
dp) :: add_offset, scale
 
  411      integer, 
parameter :: 
iunit = 10
 
  412      integer :: idot, lstr, lvar, i, io_err
 
  414      character (len=40 ) :: smodel, tname
 
  415      character (len=100) :: cinfo(12)
 
  416      character (len=256) :: io_errmsg
 
  418      character (len=*), 
parameter :: myfile =                          &
 
  419     &  __FILE__//
", coupling_metadata" 
  431      lstr=len_trim(filename)
 
  432      idot=index(filename(1:lstr), char(46), back=.true.)
 
  434      SELECT CASE (
lowercase(filename(idot+1:lstr)))
 
  448     &                 
noerror, __line__, myfile)) 
THEN 
  457     &                 
noerror, __line__, myfile)) 
RETURN 
  462     &                 
noerror, __line__, myfile)) 
RETURN 
  466     &                   
noerror, __line__, myfile)) 
RETURN 
  470     &                 
noerror, __line__, myfile)) 
RETURN 
  474     &                 
noerror, __line__, myfile)) 
RETURN 
  478     &                 
noerror, __line__, myfile)) 
RETURN 
  482     &                 
noerror, __line__, myfile)) 
RETURN 
  486     &                 
noerror, __line__, myfile)) 
RETURN 
  490     &                 
noerror, __line__, myfile)) 
RETURN 
  494     &                 
noerror, __line__, myfile)) 
RETURN 
  498     &                 
noerror, __line__, myfile)) 
RETURN 
  504     &                 
noerror, __line__, myfile)) 
RETURN 
  510     &                 
noerror, __line__, myfile)) 
RETURN 
  516     &                 
noerror, __line__, myfile)) 
RETURN 
  521        OPEN (unit=
iunit, file=trim(filename), form=
'formatted',        &
 
  522     &        status=
'old', iostat=io_err, iomsg=io_errmsg)
 
  525          IF (
master) 
WRITE(
stdout,40) trim(filename), trim(io_errmsg)
 
  535        IF (.not.
allocated(s)) 
allocate ( s(
nentries) )
 
  539          s(i)%add_offset  = 
yreal1(i)
 
  544     &                   
noerror, __line__, myfile)) 
RETURN 
  548     &                   
noerror, __line__, myfile)) 
RETURN 
  552     &                   
noerror, __line__, myfile)) 
RETURN 
  556     &                   
noerror, __line__, myfile)) 
RETURN 
  560     &                   
noerror, __line__, myfile)) 
RETURN 
  564     &                   
noerror, __line__, myfile)) 
RETURN 
  568     &                   
noerror, __line__, myfile)) 
RETURN 
  572     &                   
noerror, __line__, myfile)) 
RETURN 
  576     &                   
noerror, __line__, myfile)) 
RETURN 
  580     &                   
noerror, __line__, myfile)) 
RETURN 
  581          IF (
lowercase(s(i)%connected_to).eq.
'false') 
THEN 
  582            s(i)%connected=.false.
 
  584            s(i)%connected=.true.
 
  589     &                   
noerror, __line__, myfile)) 
RETURN 
  593     &                   
noerror, __line__, myfile)) 
RETURN 
  624          READ (
iunit,*,
err=20,
END=10) Cinfo( 1)
 
  625          lvar=len_trim(cinfo(1))
 
  626          IF ((lvar.gt.0).and.(cinfo(1)(1:1).ne.char(33))) 
THEN 
  628            READ (
iunit,*,
err=20,
END=10) Cinfo( 2)
 
  629            READ (iunit,*,err=20,
END=10) Cinfo( 3)
 
  630            READ (iunit,*,err=20,
END=10) Cinfo( 4)
 
  631            READ (iunit,*,err=20,
END=10) Cinfo( 5)
 
  632            READ (iunit,*,err=20,
END=10) Cinfo( 6)
 
  633            READ (iunit,*,err=20,
END=10) Cinfo( 7)
 
  634            READ (iunit,*,err=20,
END=10) Cinfo( 8)
 
  635            READ (iunit,*,err=20,
END=10) Cinfo( 9)
 
  636            READ (iunit,*,err=20,
END=10) Cinfo(10)
 
  637            READ (iunit,*,err=20,
END=10) Cinfo(11)
 
  638            READ (iunit,*,err=20,
END=10) Cinfo(12)
 
  639            READ (iunit,*,err=20,
END=10) connected
 
  640            READ (iunit,*,err=20,
END=10) debug_write
 
  641            READ (iunit,*,err=20,
END=10) add_offset
 
  642            READ (iunit,*,err=20,
END=10) scale
 
  650        IF (.not.
allocated(s)) 
allocate ( s(
nentries) )
 
  658          READ (iunit,*,err=20) cinfo( 1)           
 
  659          lvar=len_trim(cinfo(1))
 
  660          IF ((lvar.gt.0).and.                                          &
 
  661              (cinfo(1)(1:1).ne.char(33))) 
THEN 
  662            READ (iunit,*,err=20) cinfo( 2)         
 
  663            READ (iunit,*,err=20) cinfo( 3)         
 
  664            READ (iunit,*,err=20) cinfo( 4), smodel 
 
  665            READ (iunit,*,err=20) cinfo( 5)         
 
  666            READ (iunit,*,err=20) cinfo( 6)         
 
  667            READ (iunit,*,err=20) cinfo( 7)         
 
  668            READ (iunit,*,err=20) cinfo( 8)         
 
  669            READ (iunit,*,err=20) cinfo( 9)         
 
  670            READ (iunit,*,err=20) cinfo(10), tname  
 
  671            READ (iunit,*,err=20) cinfo(11)         
 
  672            READ (iunit,*,err=20) cinfo(12)         
 
  673            READ (iunit,*,err=20) connected
 
  674            READ (iunit,*,err=20) debug_write
 
  675            READ (iunit,*,err=20) add_offset
 
  676            READ (iunit,*,err=20) scale
 
  681            s(
ientry)%connected   = connected
 
  682            s(
ientry)%debug_write = debug_write
 
  683            s(
ientry)%add_offset  = add_offset
 
  686            IF (founderror(assign_string(s(
ientry)%short_name,          &
 
  687     &                                   trim(adjustl(cinfo(1)))),      &
 
  688     &                     noerror, __line__, myfile)) 
RETURN 
  690            IF (founderror(assign_string(s(
ientry)%standard_name,       &
 
  691     &                                   trim(adjustl(cinfo(2)))),      &
 
  692     &                     noerror, __line__, myfile)) 
RETURN 
  694            IF (founderror(assign_string(s(
ientry)%long_name,           &
 
  695     &                                   trim(adjustl(cinfo(3)))),      &
 
  696     &                     noerror, __line__, myfile)) 
RETURN 
  698            IF (founderror(assign_string(s(
ientry)%connected_to,        &
 
  699     &                                   trim(adjustl(smodel))),        &
 
  700     &                     noerror, __line__, myfile)) 
RETURN 
  702            IF (founderror(assign_string(s(
ientry)%source_units,        &
 
  703     &                                   trim(adjustl(cinfo(5)))),      &
 
  704     &                     noerror, __line__, myfile)) 
RETURN 
  706            IF (founderror(assign_string(s(
ientry)%source_grid,         &
 
  707     &                                   trim(adjustl(cinfo(6)))),      &
 
  708     &                     noerror, __line__, myfile)) 
RETURN 
  710            IF (founderror(assign_string(s(
ientry)%destination_units,   &
 
  711     &                                   trim(adjustl(cinfo(8)))),      &
 
  712     &                     noerror, __line__, myfile)) 
RETURN 
  714            IF (founderror(assign_string(s(
ientry)%destination_grid,    &
 
  715     &                                   trim(adjustl(cinfo(9)))),      &
 
  716     &                     noerror, __line__, myfile)) 
RETURN 
  718            IF (founderror(assign_string(s(
ientry)%data_netcdf_vname,   &
 
  719     &                                   trim(adjustl(cinfo(10)))),     &
 
  720     &                     noerror, __line__, myfile)) 
RETURN 
  722            IF (founderror(assign_string(s(
ientry)%data_netcdf_tname,   &
 
  723     &                                   trim(adjustl(tname))),         &
 
  724     &                     noerror, __line__, myfile)) 
RETURN 
  726            IF (founderror(assign_string(s(
ientry)%regrid_method,       &
 
  727     &                                   trim(adjustl(cinfo(11)))),     &
 
  728     &                     noerror, __line__, myfile)) 
RETURN 
  730            IF (founderror(assign_string(s(
ientry)%extrapolate_method,  &
 
  731     &                                   trim(adjustl(cinfo(12)))),     &
 
  732     &                     noerror, __line__, myfile)) 
RETURN 
  741        WRITE (stdout,
'(/,2a,/,a)')                                     &
 
  742     &        
'Coupling Metadata Dictionary, File: ',                   &
 
  743     &        trim(filename), repeat(
'=',28)
 
  745          WRITE (stdout,
'(/,a,a)')      
'  - standard_name:        ',   &
 
  746     &                                  trim(s(i)%standard_name)
 
  747          WRITE (stdout,
'(a,a)')        
'    long_name:            ',   &
 
  748     &                                  trim(s(i)%long_name)
 
  749          WRITE (stdout,
'(a,a)')        
'    short_name:           ',   &
 
  750     &                                  trim(s(i)%short_name)
 
  751          WRITE (stdout,
'(a,a)')        
'    data_netcdf_variable: ',   &
 
  752     &                                  trim(s(i)%data_netcdf_vname)
 
  753          WRITE (stdout,
'(a,a)')        
'    data_netcdf_time:     ',   &
 
  754     &                                  trim(s(i)%data_netcdf_tname)
 
  755          WRITE (stdout,
'(a,a)')        
'    source_units:         ',   &
 
  756     &                                  trim(s(i)%source_units)
 
  757          WRITE (stdout,
'(a,a)')        
'    destination_units:    ',   &
 
  758     &                                  trim(s(i)%destination_units)
 
  759          WRITE (stdout,
'(a,a)')        
'    source_grid:          ',   &
 
  760     &                                  trim(s(i)%source_grid)
 
  761          WRITE (stdout,
'(a,a)')        
'    destination_grid:     ',   &
 
  762     &                                  trim(s(i)%destination_grid)
 
  763          WRITE (stdout,
'(a,1p,e15.8)') 
'    add_offset:           ',   &
 
  765          WRITE (stdout,
'(a,1p,e15.8)') 
'    scale:                ',   &
 
  767          WRITE (stdout,
'(a,l1)')       
'    debug_write:          ',   &
 
  769          WRITE (stdout,
'(a,l1)')       
'    connected:            ',   &
 
  771          WRITE (stdout,
'(a,a)')        
'    connected_to:         ',   &
 
  772     &                                  trim(s(i)%connected_to)
 
  773          WRITE (stdout,
'(a,a)')        
'    regrid_method:        ',   &
 
  774     &                                  trim(s(i)%regrid_method)
 
  775          WRITE (stdout,
'(a,a)')        
'    extrapolate_method:   ',   &
 
  776     &                                  trim(s(i)%extrapolate_method)
 
  782  20  
IF (master) 
WRITE (stdout,50) trim(adjustl(cinfo(1))),            &
 
  785  30  
FORMAT (/,
' COUPLING_METADATA - Unable to create YAML object',    &
 
  786     &        
' for ROMS I/O metadata file: ',/,21x,a,/,                &
 
  787     &        21x,
'Default file is located in source directory.')
 
  788  40  
FORMAT (/,
' COUPLING_METADATA - Unable to open ROMS coupling',    &
 
  789     &        
' coupling file:',/,21x,a,/,21x,
'ERROR: ',a,/,            &
 
  790     &        21x,
'Default file is located in source directory.')
 
  791  50  
FORMAT (/,
' COUPLING_METADATA - Error while reading information', &
 
  792     &        
'for metadata variable: ',a,/,21x,
'File: ',a)
 
 
  841      logical, 
intent(inout) :: firstpass
 
  843      real(dp), 
intent(out) :: offset, scale
 
  845      character (len=*), 
intent(out) :: vinfo(:)
 
  849      logical, 
save :: isdat     = .false.
 
  850      logical, 
save :: isyaml    = .false.
 
  853      integer, 
parameter :: iunit = 10
 
  854      integer :: idot, lstr, lvar
 
  855      integer :: i, j, io_err
 
  857      character (len=256) :: io_errmsg
 
  859      character (len=*), 
parameter :: myfile =                          &
 
  860     &  __FILE__//
", io_metadata" 
  876        lstr=len_trim(varname)
 
  877        idot=index(varname(1:lstr), char(46), back=.true.)
 
  878        SELECT CASE (lowercase(varname(idot+1:lstr)))
 
  890          IF (founderror(yaml_initialize(
yml, trim(varname),            &
 
  892     &                   noerror, __line__, myfile)) 
THEN 
  894            IF (master) 
WRITE (stdout,30) trim(varname)
 
  898          IF (founderror(yaml_get(
yml, 
'metadata.variable',             &
 
  900     &                   noerror, __line__, myfile)) 
RETURN 
  903          IF (founderror(yaml_get(
yml, 
'metadata.long_name',            &
 
  905     &                   noerror, __line__, myfile)) 
RETURN 
  907          IF (founderror(yaml_get(
yml, 
'metadata.units',                &
 
  909     &                   noerror, __line__, myfile)) 
RETURN 
  911          IF (founderror(yaml_get(
yml, 
'metadata.field',                &
 
  913     &                   noerror, __line__, myfile)) 
RETURN 
  915          IF (founderror(yaml_get(
yml, 
'metadata.time',                 &
 
  917     &                   noerror, __line__, myfile)) 
RETURN 
  919          IF (founderror(yaml_get(
yml, 
'metadata.standard_name',        &
 
  921     &                   noerror, __line__, myfile)) 
RETURN 
  923          IF (founderror(yaml_get(
yml, 
'metadata.type',                 &
 
  925     &                   noerror, __line__, myfile)) 
RETURN 
  927          IF (founderror(yaml_get(
yml, 
'metadata.index_code',           &
 
  929     &                   noerror, __line__, myfile)) 
RETURN 
  933          IF (founderror(yaml_get(
yml, 
'metadata.add_offset',           &
 
  935     &                   noerror, __line__, myfile)) 
RETURN 
  939          IF (founderror(yaml_get(
yml, 
'metadata.scale',                &
 
  941     &                   noerror, __line__, myfile)) 
RETURN 
  946          OPEN (unit=iunit, file=trim(varname), form=
'formatted',       &
 
  947     &          status=
'old', iostat=io_err, iomsg=io_errmsg)
 
  948          IF (founderror(io_err, noerror, __line__, myfile)) 
THEN 
  951            IF (master) 
WRITE(stdout,40) trim(varname), trim(io_errmsg)
 
  963          vinfo(j)(i:i)=char(32)
 
 1001      ELSE IF (isdat) 
THEN 
 1003          READ (iunit,*,err=10,
END=20) Vinfo(1)  
 
 1004          lvar=len_trim(vinfo(1))
 
 1005          IF ((lvar.gt.0).and.(vinfo(1)(1:1).ne.char(33)).and.          &
 
 1006     &                        (vinfo(1)(1:1).ne.char(36))) 
THEN 
 1007            READ (iunit,*,err=10) vinfo(2)       
 
 1008            READ (iunit,*,err=10) vinfo(3)       
 
 1009            READ (iunit,*,err=10) vinfo(4)       
 
 1010            READ (iunit,*,err=10) vinfo(5)       
 
 1012            READ (iunit,*,err=10) vinfo(8)       
 
 1013            READ (iunit,*,err=10) vinfo(7)       
 
 1014            READ (iunit,*,err=10) scale
 
 1020  10    
WRITE (stdout,50) trim(adjustl(vinfo(1)))
 
 1026  30  
FORMAT (/,
' IO_METADATA - Unable to create YAML object for',      &
 
 1027     &        
' ROMS I/O metadata file: ',/,15x,a,/,                    &
 
 1028     &        15x,
'Default file is located in source directory.')
 
 1029  40  
FORMAT (/,
' IO_METADATA - Unable to open ROMS I/O metadata ',     &
 
 1030     &        
'file:',/,15x,a,/,15x,
'ERROR: ',a,/,                      &
 
 1031     &        15x,
'Default file is located in source directory.')
 
 1032  50  
FORMAT (/,
' IO_METADATA - Error while reading information for ',  &