﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
893	IMPORTANT: Removed I/O related GOTOs	arango		"Currently, there are '''68''' I/O flow control '''GOTO'''s 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 '''GOTO'''s 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 '''GOTO'''s 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 '''GOTO'''s 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."	upgrade	closed	major	Release ROMS/TOMS 4.0	Nonlinear	3.9	Done		
