geoschem / geos-chem

GEOS-Chem "Science Codebase" repository. Contains GEOS-Chem science routines, run directory generation scripts, and interface code. This repository is used as a submodule within the GCClassic and GCHP wrappers, as well as in other modeling contexts (external ESMs).
http://geos-chem.org
Other
161 stars 155 forks source link

[Feature Request] Retire Fortran goto #1416

Open lizziel opened 1 year ago

lizziel commented 1 year ago

Use of goto is discouraged as it is confusing and very old fortran. Still, it is present is many places in GEOS-Chem. We should retire it.

yantosca commented 1 year ago

Here is a list of all GOTOs in the GEOS-Chem source code. Many of these are in 3rd-party code (such as ISORROPIA). Other instances are used as a way to exit during file I/O (e.g. in species_database_mod.F90) -- this is in code that only gets done once so this is less egregious.

geos-chem-goto-list.txt

Tagging @lizziel @msulprizio @Jourdan-He @SaptSinha

yantosca commented 1 year ago

I think it'd be almost impossible to remove the GOTOs in ISORROPIA without potentially messing things up. The best solution would be to replace ISORROPIA as @sdeastham has been advocating for.

lizziel commented 1 year ago

We could focus on the in-house code that is in GeosCore, Headers, and GeosUtil. I agree best not to touch the 3rd part code given it'll eventually be replaced with new versions anyway.

yantosca commented 1 month ago

@lizziel: We can now revisit this now that HETP has replaced ISORROPIA.

yantosca commented 1 month ago

This instance in GeosCore/carbon_mod.F90 (for TOMAS):

      IF ( SUM( EMISMASS(I,J,:) ) == 0.e+0_fp ) GOTO 100

can be replaced with

 IF ( SUM( EMISMASS(I,J,:) ) == 0.e+0_fp ) CYCLE