From e119908b51ca50959337b837e20847be18bdfdb6 Mon Sep 17 00:00:00 2001
From: Joe Wallwork <jw2423@cam.ac.uk>
Date: Tue, 22 Oct 2024 10:08:31 +0100
Subject: [PATCH] Formatting and TODOs

---
 model/ATM_DRV.f                   | 15 ++++-----------
 model/CHEM_COM.F90                | 23 ++++++++++++++++++++++-
 model/CHEM_DRV.F90                | 12 ++++++------
 model/shared/AbstractCalendar.F90 |  1 +
 4 files changed, 33 insertions(+), 18 deletions(-)

diff --git a/model/ATM_DRV.f b/model/ATM_DRV.f
index 472d9bb..459d344 100644
--- a/model/ATM_DRV.f
+++ b/model/ATM_DRV.f
@@ -293,7 +293,7 @@ subroutine atm_phase1
 #endif
 
       call atm_phase1_exports
-      
+
       return
       end subroutine atm_phase1
 
@@ -820,7 +820,7 @@ subroutine alloc_drv_atm()
 #endif
 #if defined( TRACERS_GC )
       use CHEM_DRV, only : init_chem
-      !use CHEM_COM, only : alloc_chem_com
+      use CHEM_COM, only : alloc_chem_com
 #endif
 #if (defined TRACERS_ON) || (defined TRACERS_OCEAN)
       use TRACER_COM, only: initTracerCom, alloc_tracer_com
@@ -1032,6 +1032,7 @@ subroutine new_io_atmvars(fid,iorw)
          call tracerIO(fid, 'write_dist')
       end select
 #endif
+
 #if defined( TRACERS_GC ) && ! defined( NEW_IO )
       select case (iorw)
       case (ioread)
@@ -1040,15 +1041,7 @@ subroutine new_io_atmvars(fid,iorw)
          call IO_CHEM(fid, 'write_dist')
       end select
 #endif
-#ifdef TRACERS_GC
-      select case (iorw)
-      case (ioread)
-         call IO_CHEM(fid, 'read_dist')
-      case (iowrite)
-         call IO_CHEM(fid, 'write_dist')
-      end select
-#endif
-      
+
       call new_io_subdd  (fid,iorw)
       call new_io_fluxes (fid,iorw)
       return
diff --git a/model/CHEM_COM.F90 b/model/CHEM_COM.F90
index d2c49da..30225b2 100644
--- a/model/CHEM_COM.F90
+++ b/model/CHEM_COM.F90
@@ -76,6 +76,7 @@ module CHEM_COM
 
 end module CHEM_COM
 
+! TODO: Uncomment or drop
 !      subroutine write_src_dist_data(fid, def)
 !      use pario, only: defvar, write_dist_data, write_data
 !      use domain_decomp_atm, only : grid
@@ -141,6 +142,7 @@ subroutine def_rsf_gcdiag(fid,r4_on_disk)
   use chem_com, only : GCIJLN=>GCIJLN_loc
   use chem_com, only : GCIJLS=>GCIJLS_loc
   use chem_com, only : GCIJL=>GCIJL_out
+  ! TODO: Uncomment or drop
   !     &     GCIJN=>GCIJN_loc,
   !     &     GCIJS=>GCIJS_loc,
   !     &     GCJLN,
@@ -154,6 +156,7 @@ subroutine def_rsf_gcdiag(fid,r4_on_disk)
   logical :: r4_on_disk !@var r4_on_disk if true, real*8 stored as real*4
   if(r4_on_disk) then ! acc file
      call defvar(grid,fid,gcijl,'gcijl(dist_im,dist_jm,lm,kgcijl)',r4_on_disk=.true.)
+     ! TODO: Uncomment or drop
      !        call defvar(grid,fid,gcij,
      !     &       'gcij(dist_im,dist_jm,kgcij)',r4_on_disk=.true.)
      !        call defvar(grid,fid,gcjl,
@@ -162,6 +165,7 @@ subroutine def_rsf_gcdiag(fid,r4_on_disk)
   else
      call defvar(grid,fid,gcijln,'gcijln(dist_im,dist_jm,lm,ntm)')
      call defvar(grid,fid,gcijls,'gcijls(dist_im,dist_jm,lm,kgcijl)')
+     ! TODO: Uncomment or drop
      !        call defvar(grid,fid,gcijs,'gcijs(dist_im,dist_jm,kgcijs)')
      !        call defvar(grid,fid,gcijn,'gcijn(dist_im,dist_jm,kgcij,ntm)')
      !        call defvar(grid,fid,gcjln,'gcjln(jm_budg,lm,ktajlx,ntm)')
@@ -181,6 +185,7 @@ subroutine new_io_gcdiag(fid,iaction)
   use chem_com, only : GCIJLN=>GCIJLN_loc
   use chem_com, only : GCIJLS=>GCIJLS_loc
   use chem_com, only : GCIJL=>GCIJL_out
+  ! TODO: Uncomment or drop
   !     &     GCIJN=>GCIJN_loc,
   !     &     GCIJS=>GCIJS_loc,
   !     &     GCJLN,
@@ -195,13 +200,16 @@ subroutine new_io_gcdiag(fid,iaction)
   select case (iaction)
   case (iowrite_single)     ! output to acc file
      call write_dist_data(grid,fid,'gcijl',gcijl)
+     ! TODO: Uncomment or drop
      !call write_dist_data(grid,fid,'gcij',gcij)
      !call write_data(grid,fid,'gcjl',gcjl)
      !call write_src_dist_data(fid, .false.)
   case (iowrite)            ! output to restart file
+     ! TODO: Uncomment or drop
      !call gather_zonal_gcdiag
      call write_dist_data(grid,fid,'gcijln',gcijln)
      call write_dist_data(grid,fid,'gcijls',gcijls)
+     ! TODO: Uncomment or drop
      !call write_dist_data(grid,fid,'gcijs',gcijs)
      !call write_dist_data(grid,fid,'gcijn',gcijn)
      !call write_data(grid,fid,'gcjln',gcjln)
@@ -209,6 +217,7 @@ subroutine new_io_gcdiag(fid,iaction)
   case (ioread)            ! input from restart file
      call read_dist_data(grid,fid,'gcijln',gcijln)
      call read_dist_data(grid,fid,'gcijls',gcijls)
+     ! TODO: Uncomment or drop
      !call read_dist_data(grid,fid,'gcijs',gcijs)
      !call read_dist_data(grid,fid,'gcijn',gcijn)
      !call read_data(grid,fid,'gcjln',gcjln)
@@ -216,6 +225,7 @@ subroutine new_io_gcdiag(fid,iaction)
      !call scatter_zonal_gcdiag
   end select
 
+  ! TODO: Uncomment or drop
   !call new_io_tcons(fid,iaction)
 
   return
@@ -232,6 +242,7 @@ subroutine def_meta_gcdiag(fid)
   implicit none
   integer :: fid         !@var fid file id
   
+  ! TODO: Uncomment or drop
   !      call write_attr(grid,fid,'gcij','reduction','sum')
   !      call write_attr(grid,fid,'gcij','split_dim',3)
   !      call defvar(grid,fid,ia_gcij(1:kgcij_out),
@@ -263,6 +274,7 @@ subroutine def_meta_gcdiag(fid)
   call defvar_cdl(grid,fid,cdl_gcijl_latlon,'cdl_gcijl_latlon(cdl_strlen,kcdl_gcijl_latlon)')
 #endif
 
+  ! TODO: Uncomment or drop
   !     call write_attr(grid,fid,'gcjl','reduction','sum')
   !     call write_attr(grid,fid,'gcjl','split_dim',3)
   !     call defvar(grid,fid,ia_gcjl(1:ktajl_out),
@@ -297,6 +309,7 @@ subroutine write_meta_gcdiag(fid)
   implicit none
   integer :: fid         !@var fid file id
 
+  ! TODO: Uncomment or drop
   !      call write_data(grid,fid,'hemis_gcij',hemis_gcij)
   !      call write_data(grid,fid,'ia_gcij',ia_gcij(1:kgcij_out))
   !      call write_data(grid,fid,'denom_gcij',denom_gcij(1:kgcij_out))
@@ -316,6 +329,7 @@ subroutine write_meta_gcdiag(fid)
   call write_cdl(grid,fid,'cdl_gcijl_latlon',cdl_gcijl_latlon)
 #endif
 
+  ! TODO: Uncomment or drop
   !      call write_data(grid,fid,'hemis_gcjl',hemis_gcjl)
   !      call write_data(grid,fid,'vmean_gcjl',vmean_gcjl)
   !      call write_data(grid,fid,'ia_gcjl',ia_gcjl(1:ktajl_out))
@@ -323,12 +337,12 @@ subroutine write_meta_gcdiag(fid)
   !      call write_data(grid,fid,'scale_gcjl',scale_gcjl(1:ktajl_out))
   !      call write_data(grid,fid,'sname_gcjl',sname_gcjl(1:ktajl_out))
   !      call write_cdl(grid,fid,'cdl_gcjl',cdl_gcjl)
-
   !      call write_meta_tcons(fid)
 
   return
 end subroutine write_meta_gcdiag
 
+! TODO: Uncomment or drop
 !      subroutine def_rsf_tcons(fid,r4_on_disk)
 !!@sum  def_rsf_tcons defines tracer diag array structure in restart+acc files
 !!@auth M. Kelley
@@ -472,6 +486,7 @@ SUBROUTINE ALLOC_CHEM_COM
   RETURN
 END SUBROUTINE ALLOC_CHEM_COM
 
+! TODO: Uncomment or drop
 !      subroutine reset_tcons
 !        USE CHEM_COM, only: TCONSRV_loc, TCONSRV
 !        USE DOMAIN_DECOMP_ATM, only : am_i_root
@@ -537,10 +552,12 @@ subroutine reset_gcdiag
   USE DOMAIN_DECOMP_ATM, only : am_i_root
   implicit none
 
+  ! TODO: Uncomment or drop
   !TAJLN_loc=0.
   !TAJLS_loc=0. 
   GCIJLN_loc=0.
   GCIJLS_loc=0.
+  ! TODO: Uncomment or drop
   !TAIJN_loc=0.
   !TAIJS_loc=0.
   !if(am_i_root()) then
@@ -559,6 +576,7 @@ subroutine gather_gcdiag
 
   CALL PACK_DATA (GRID, GCIJLN_loc, GCIJLN)
   CALL PACK_DATA (GRID, GCIJLS_loc, GCIJLS)
+  ! TODO: Uncomment or drop
   !CALL PACK_DATA (GRID, GCIJN_loc , GCIJN)
   !CALL PACK_DATA (GRID, GCIJS_loc , GCIJS)
   !call gather_zonal_gcdiag
@@ -567,6 +585,7 @@ subroutine gather_gcdiag
   return
 end subroutine gather_gcdiag
 
+! TODO: Uncomment or drop
 !subroutine gather_zonal_gcdiag
 !  USE CHEM_COM, only : GCJLN , GCJLN_loc, GCJLS, GCJLS_loc
 !  USE DOMAIN_DECOMP_ATM, ONLY : GRID
@@ -584,6 +603,7 @@ subroutine scatter_gcdiag
   implicit none
   CALL UNPACK_DATA (GRID, GCIJLN, GCIJLN_loc)
   CALL UNPACK_DATA (GRID, GCIJLS, GCIJLS_loc)
+  ! TODO: Uncomment or drop
   !CALL UNPACK_DATA (GRID, GCIJN , GCIJN_loc)
   !CALL UNPACK_DATA (GRID, GCIJS , GCIJS_loc)
   !call scatter_zonal_gcdiag
@@ -591,6 +611,7 @@ subroutine scatter_gcdiag
   return
 end subroutine scatter_gcdiag
 
+! TODO: Uncomment or drop
 !subroutine scatter_zonal_gcdiag
 !  USE CHEM_COM, only : GCJLN , GCJLN_loc, GCJLS, GCJLS_loc
 !  USE DOMAIN_DECOMP_ATM, ONLY : GRID
diff --git a/model/CHEM_DRV.F90 b/model/CHEM_DRV.F90
index ce2845d..31b5b11 100644
--- a/model/CHEM_DRV.F90
+++ b/model/CHEM_DRV.F90
@@ -78,17 +78,17 @@ module CHEM_DRV
 
   ! Ap [hPa] for 40 levels (41 edges)
   REAL(fp), PARAMETER :: AP(41) = (/                  &
-       0.000000,   3.597122,   7.553957,  12.050360, &
+        0.000000,   3.597122,   7.553957,  12.050360, &
        16.906475,  22.302158,  28.597122,  35.791367, &
        43.884892,  52.517986,  61.510791,  70.683453, &
        80.035971,  89.028777,  97.661871, 105.755396, &
-       113.309353, 120.143885, 126.258993, 131.834532, &
-       136.870504, 141.546763, 145.863309, 150.000000, &
-       128.000000, 108.000000,  90.000000,  73.000000, &
+      113.309353, 120.143885, 126.258993, 131.834532, &
+      136.870504, 141.546763, 145.863309, 150.000000, &
+      128.000000, 108.000000,  90.000000,  73.000000, &
        57.000000,  43.000000,  31.000000,  20.000000, &
        10.000000,   5.620000,   3.160000,   1.780000, &
-       1.000000,   0.562000,   0.316000,   0.178000, &
-       0.100000                                       /)
+        1.000000,   0.562000,   0.316000,   0.178000, &
+        0.100000                                       /)
 
   ! Bp [unitless] for 40 levels (41 edges)
   REAL(fp), PARAMETER :: BP(41) = (/                   &
diff --git a/model/shared/AbstractCalendar.F90 b/model/shared/AbstractCalendar.F90
index 0b58377..b6a99e5 100644
--- a/model/shared/AbstractCalendar.F90
+++ b/model/shared/AbstractCalendar.F90
@@ -363,6 +363,7 @@ subroutine printTransitionDates(this, unit)
     class (AbstractTimeStamp), pointer :: p
     character(len=24) :: fmt
 
+! FIXME: This code causes a segfault with recent gfortran
 !    iter = this%transitionDates%begin()
 !    do while(iter /= this%transitionDates%last())
 !       p => iter%value()