Opened 3 years ago

Closed 3 years ago

#893 closed upgrade (Done)

IMPORTANT: Removed I/O related GOTOs — at Version 1

Reported by: arango Owned by:
Priority: major Milestone: Release ROMS/TOMS 4.0
Component: Nonlinear Version: 3.9
Keywords: Cc:

Description (last modified by arango)

Currently, there are 68 I/O flow control GOTOs in ROMS. In this update, it has been reduced to 6.

  • Using additional features of the 2003 Fortran standard, it is possible to remove the GOTOs associated with the ERR option in the OPEN statement. The new feature to the OPEN command gives more flexibility when opening files with flow control and error information.

For example, in inp_par.F we now have:

     OPEN (inp, FILE=TRIM(Iname), FORM='formatted', STATUS='old',      &
    &      IOSTAT=io_err, IOMSG=io_errmsg)
     IF (io_err.ne.0) THEN
       IF (Master) WRITE (stdout,30) TRIM(io_errmsg)
       exit_flag=5
       RETURN
30     FORMAT (/,' INP_PAR - Unable to open ROMS/TOMS input script ',  &
    &              'file.',/,11x,'ERROR: ',a)
     END IF

Using IOSTAT and IOMSG options is an elegant way to check for errors instead of old ERR option when opening files.

  • In routines read_asspar.F, read_fltpar.F, and read_phypar.F, the GOTOs are eliminated and the error control is moved inside the find_file function. For example, in read_phypar.F we now have:
    #ifndef ANA_GRID
              fname=GRD(ng)%name
              IF (.not.find_file(ng, out, fname, 'GRDNAME')) THEN
                IF (FoundError(exit_flag, NoError, __LINE__, MyFile)) RETURN
              ELSE
                WRITE (out,230) '                 Input Grid File:  ',      &
         &                      TRIM(fname)
              END IF
    #endif
    
  • The remaining six GOTOs are in the 4D-Var conjugate gradient routines congrad.F and rpcg_lanczos.F:
    ROMS/Utility/congrad.F:            GO TO 10
    ROMS/Utility/congrad.F:              GO TO 10
    ROMS/Utility/congrad.F:                GO TO 10
    ROMS/Utility/rpcg_lanczos.F:            GO TO 10
    ROMS/Utility/rpcg_lanczos.F:              GO TO 10
    ROMS/Utility/rpcg_lanczos.F:                GO TO 10
    
    They are used for parallel error flow control to inform the user about a fatal algorithm result in the 4D-Var dual formulation minimization. Here, the algorithm is only executed by the master process and we need to communicate to the other processes about such an error.

Change History (1)

comment:1 by arango, 3 years ago

Description: modified (diff)
Resolution: Done
Status: newclosed
Note: See TracTickets for help on using tickets.