Possible IO bug in close_io.F

Bug reports, work arounds and fixes

Moderators: arango, robertson

Post Reply
Message
Author
leon
Posts: 78
Joined: Mon Mar 03, 2008 4:14 am

Possible IO bug in close_io.F

#1 Unread post by leon »

In close_io.F line 69

Code: Select all

 45       DO i=1,nFfiles(ng)
 46         IF ((FRC(i,ng)%Nfiles.gt.1).and.(FRC(i,ng)%ncid.ge.0)) THEN
 47           FRCids(i,ng)=-1
 48           DO j=1,NV
 49             IF (ncFRCid(j,ng).eq.FRC(i,ng)%ncid) THEN
 50               ncFRCid(j,ng)=-1
 51             END IF
 52           END DO
 53           IF (model.eq.iADM) THEN
 54             DO j=1,FRC(i,ng)%Nfiles
 55               IF ((FRC(i,ng)%time_min(j).le.tdays(ng)).and.              &
 56      &            (tdays(ng).le.FRC(i,ng)%time_max(j))) THEN
 57                 Fcount=j
 58                 EXIT
 59               END IF
 60             END DO
 61           ELSE
 62             Fcount=1
 63           END IF
 64           FRC(i,ng)%Fcount=Fcount
 65           FRC(i,ng)%name=TRIM(FRC(i,ng)%files(Fcount))
 66           lstr=LEN_TRIM(FRC(i,ng)%name)
 67           FRC(i,ng)%base=FRC(i,ng)%name(1:lstr-3)
 68           CALL netcdf_close (ng, model, FRC(i,ng)%ncid,                 &
 69      &                       FRC(i,ng)%files(i), .FALSE.)
 70           IF (exit_flag.ne.NoError) RETURN
 71         END IF
 72       END DO
Here, it should not be

Code: Select all

files(i)
. It causes IO errors when use multi forcing files like

Code: Select all

    FRCNAME == my_tides.nc       \                                           !
!               my_lwrad_year1.nc |                                           !
!               my_lwrad_year2.nc \                                           !
!               my_swrad_year1.nc |                                           !
!               my_swrad_year2.nc \                                           !
!               my_winds_year1.nc |                                           !
!               my_winds_year2.nc \                                           !
!               my_Pair_year1.nc  |                                           !
!               my_Pair_year2.nc  \                                           !
!               my_Qair_year1.nc  |                                           !
!               my_Qair_year2.nc  \                                           !
!               my_Tair_year1.nc  |                                           !
!               my_Tair_year2.nc                                              !
However, I'm not sure how to fix it. Change

Code: Select all

files(i)
to

Code: Select all

files(Fcount)
?

I'm not sure whether other places in close_oi.F, like line 95

Code: Select all

BRY(ng)%files(i),  .FALSE.)
, can cause problems or not.

User avatar
arango
Site Admin
Posts: 1367
Joined: Wed Feb 26, 2003 4:41 pm
Location: DMCS, Rutgers University
Contact:

Re: Possible IO bug in close_io.F

#2 Unread post by arango »

This is weird because close_inp is used in the adjoint-based algorithms to facilitate the iterations in the propagators and 4D-Var algorithms. This means that these files were already processed when reading input forcing fields. In the example that you provide above, which is exactly what I wrote in the input script preamble description, we cannot have comments in the FRCNAME keyword for ocean.in. Using my example, we need to have instead:

Code: Select all

    FRCNAME == my_tides.nc       \
               my_lwrad_year1.nc |
               my_lwrad_year2.nc \
               my_swrad_year1.nc |
               my_swrad_year2.nc \
               my_winds_year1.nc |
               my_winds_year2.nc \
               my_Pair_year1.nc  |
               my_Pair_year2.nc  \
               my_Qair_year1.nc  |
               my_Qair_year2.nc  \
               my_Tair_year1.nc  |
               my_Tair_year2.nc 
We cannot have hidden characters or tabs in the file list. We can only have continuation (\) and multi-file (|) symbols. Also the value(s) of NFFILES is crucial. In this case we need:

Code: Select all

     NFFILES == 7                          ! number of forcing files
It seems to me that something is not correct in your ocean.in. Notice that the TYPE(T_IO) structure always have the file field as a vector of size 1 or larger:

Code: Select all

      TYPE T_IO
        integer :: Nfiles                        ! number of multi-files
        integer :: Fcount                        ! multi-file counter
        integer :: Rindex                        ! NetCDF record index
        integer :: ncid                          ! NetCDF file ID
        integer,  pointer :: Nrec(:)             ! NetCDF record size
        integer,  pointer :: Vid(:)              ! NetCDF variables IDs
        integer,  pointer :: Tid(:)              ! NetCDF tracers IDs
        real(r8), pointer :: time_min(:)         ! starting time
        real(r8), pointer :: time_max(:)         ! ending time
        character (len=50 ) :: label             ! structure label
        character (len=256) :: base              ! base file name
        character (len=256) :: name              ! current name
        character (len=256), pointer :: files(:) ! multi-file names
      END TYPE T_IO
So I don't see any problems in the code. We have been using this logic for long time. It is a generic logic!

If you are not 100 percent sure about a bug in the code, I will appreciate if you use this forum instead of issuing a ticket in the ROMS trac system. Your trac ticket 672 was deleted!

Post Reply