Skip to content

Commit

Permalink
Add option to specify history and inline post files output directory (N…
Browse files Browse the repository at this point in the history
…OAA-EMC#826)

* Add model_configure option to specify history file output directory (fv3atm_output_dir)

* Update workflows/GCC.yml

* Move reading of 'fv3atm_output_dir' config option to module_wrt_grid_comp

* Update upp
  • Loading branch information
DusanJovic-NOAA authored May 9, 2024
1 parent 683061b commit 7147dac
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 78 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/GCC.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
submodules: recursive

- name: install-cmake
run: |
run: |
cd ${{ github.workspace }}
curl -f -s -S -R -L https://github.com/Kitware/CMake/releases/download/v3.29.2/cmake-3.29.2-Linux-x86_64.tar.gz | tar -zx
echo "${{ github.workspace }}/cmake-3.29.2-linux-x86_64/bin" >> $GITHUB_PATH
Expand Down Expand Up @@ -78,7 +78,7 @@ jobs:
sudo apt-get install doxygen graphviz
- name: install-cmake
run: |
run: |
cd ${{ github.workspace }}
curl -f -s -S -R -L https://github.com/Kitware/CMake/releases/download/v3.29.2/cmake-3.29.2-Linux-x86_64.tar.gz | tar -zx
echo "${{ github.workspace }}/cmake-3.29.2-linux-x86_64/bin" >> $GITHUB_PATH
Expand All @@ -105,7 +105,6 @@ jobs:
git clone https://github.com/NOAA-EMC/CMakeModules
git clone --recurse-submodules https://github.com/NOAA-PSL/stochastic_physics stochastic_physics_repo
mkdir ${GITHUB_WORKSPACE}/build
sed -i 's/doc /upp_doc /' upp/docs/CMakeLists.txt
cd ${GITHUB_WORKSPACE}/build
export CC=mpicc
export CXX=mpicxx
Expand Down
60 changes: 31 additions & 29 deletions io/module_fv3_io_def.F90
Original file line number Diff line number Diff line change
Expand Up @@ -12,89 +12,91 @@ module module_fv3_io_def
!> Number of processors used in the forecast grid component
integer :: num_pes_fcst

!> Number of write tasks per write group.
!> Number of write tasks per write group.
integer :: wrttasks_per_group

!> Number of the write groups
integer :: write_groups
integer :: write_groups

!> Current write group
integer :: n_group
!> Current write group
integer :: n_group

!> Number of history files
integer :: num_files
integer :: num_files

!> Number of the ESMF field bundles for physics fields
integer :: nbdlphys
integer :: nbdlphys

!> IAU running window length
integer :: iau_offset
integer :: iau_offset

!> Logical variable to decide if full time (HH.MM.SS) is used in the history
!! file names
logical :: lflname_fulltime
logical :: lflname_fulltime

!> Logical variable to decide if unlimited time dimension is used
logical :: time_unlimited
logical :: time_unlimited

!> Directory name for model history output files
character(len=esmf_maxstr) :: fv3atm_output_dir

!> Base names for model history output files
character(len=esmf_maxstr),dimension(:),allocatable :: filename_base
character(len=esmf_maxstr),dimension(:),allocatable :: filename_base

!> Output file format
character(len=esmf_maxstr),dimension(:),allocatable :: output_file
!> Output file format
character(len=esmf_maxstr),dimension(:),allocatable :: output_file


!> The first write task in a write group
integer,dimension(:),allocatable :: lead_wrttask
integer,dimension(:),allocatable :: lead_wrttask

!> The last write task in a write group
integer,dimension(:),allocatable :: last_wrttask
integer,dimension(:),allocatable :: last_wrttask

!> Output grid type, e.g. "gaussian_grid"
character(len=esmf_maxstr),dimension(:),allocatable :: output_grid
character(len=esmf_maxstr),dimension(:),allocatable :: output_grid

!> The i-dimension in the output grid
integer,dimension(:),allocatable :: imo
integer,dimension(:),allocatable :: imo

!> The j-dimension in the output grid
integer,dimension(:),allocatable :: jmo
integer,dimension(:),allocatable :: jmo

!> Longitude of the center point in the output grid
real,dimension(:),allocatable :: cen_lon
real,dimension(:),allocatable :: cen_lon

!> Latitude of the center pointer in the output grid
real,dimension(:),allocatable :: cen_lat
real,dimension(:),allocatable :: cen_lat

!> Longitude of the first grid point in the output grid
real,dimension(:),allocatable :: lon1
real,dimension(:),allocatable :: lon1

!> Latitude of the first pointer in the output grid
real,dimension(:),allocatable :: lat1
real,dimension(:),allocatable :: lat1

!> Longitude of the last grid point in the output grid
real,dimension(:),allocatable :: lon2
real,dimension(:),allocatable :: lon2

!> Latitude of the last pointer in the output grid
real,dimension(:),allocatable :: lat2
real,dimension(:),allocatable :: lat2

!> Longitude increment
real,dimension(:),allocatable :: dlon
real,dimension(:),allocatable :: dlon

!> Latitude increment
real,dimension(:),allocatable :: dlat
real,dimension(:),allocatable :: dlat

!> The first latitude from the pole at which the secant cone cuts the sphere
real,dimension(:),allocatable :: stdlat1
real,dimension(:),allocatable :: stdlat1

!> The second latitude from the pole at which the secant cone cuts the sphere
real,dimension(:),allocatable :: stdlat2
real,dimension(:),allocatable :: stdlat2

!> x-direction grid length
real,dimension(:),allocatable :: dx
real,dimension(:),allocatable :: dx

!> y-direction grid length
real,dimension(:),allocatable :: dy
real,dimension(:),allocatable :: dy

!> Deflate level to use, 0 means no deflate.
integer,dimension(:),allocatable :: ideflate
Expand Down
21 changes: 15 additions & 6 deletions io/module_wrt_grid_comp.F90
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ module module_wrt_grid_comp
!
use mpi_f08
use esmf
use fms_mod, only : uppercase
use fms
use mpp_mod, only : mpp_init, mpp_error
use fms, only : fms_init, fms_end, fms_mpp_uppercase, fms_mpp_error, FATAL
use fms, only : NO_CALENDAR, JULIAN, GREGORIAN, THIRTY_DAY_MONTHS, NOLEAP

use write_internal_state
use module_fv3_io_def, only : num_pes_fcst, &
n_group, num_files, &
fv3atm_output_dir, &
filename_base, output_grid, output_file, &
imo,jmo,ichunk2d,jchunk2d, &
ichunk3d,jchunk3d,kchunk3d, &
Expand Down Expand Up @@ -282,6 +282,15 @@ subroutine wrt_initialize_p1(wrt_comp, imp_state_write, exp_state_write, clock,
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, &
line=__LINE__, file=__FILE__)) return

call ESMF_ConfigGetAttribute(config=CF,value=fv3atm_output_dir, &
label ='fv3atm_output_dir:', default='./', rc=rc)
if (ESMF_LogFoundError(rcToCheck=rc, msg=ESMF_LOGERR_PASSTHRU, line=__LINE__, file=__FILE__)) return

! Make sure fv3atm_output_dir ends with '/'
if (fv3atm_output_dir(len(trim(fv3atm_output_dir)):len(trim(fv3atm_output_dir))) /= '/') then
fv3atm_output_dir = trim(fv3atm_output_dir) // '/'
end if

if( wrt_int_state%write_dopost ) then
#ifdef INLINE_POST
call ESMF_ConfigGetAttribute(config=CF,value=wrt_int_state%post_namelist,default='itag', &
Expand Down Expand Up @@ -2140,7 +2149,7 @@ subroutine wrt_run(wrt_comp, imp_state_write, exp_state_write,clock,rc)
wend = MPI_Wtime()
if (mype == lead_write_task) then
!** write out inline post log file
open(newunit=nolog,file='log.atm.inlinepost.f'//trim(cfhour),form='FORMATTED')
open(newunit=nolog,file=trim(fv3atm_output_dir)//'log.atm.inlinepost.f'//trim(cfhour),form='FORMATTED')
write(nolog,"('completed: fv3atm')")
write(nolog,"('forecast hour: ',f10.3)") nfhour
write(nolog,"('valid time: ',6(i4,2x))") wrt_int_state%fdate(1:6)
Expand Down Expand Up @@ -2313,7 +2322,7 @@ subroutine wrt_run(wrt_comp, imp_state_write, exp_state_write,clock,rc)
endif

else ! history bundle
filename = trim(wrtFBName)//'f'//trim(cfhour)//'.nc'
filename = trim(fv3atm_output_dir)//trim(wrtFBName)//'f'//trim(cfhour)//'.nc'
endif
if(mype == lead_write_task) print *,'in wrt run,filename= ',nbdl,trim(filename)

Expand Down Expand Up @@ -2444,7 +2453,7 @@ subroutine wrt_run(wrt_comp, imp_state_write, exp_state_write,clock,rc)

if (out_phase == 1 .and. mype == lead_write_task) then
!** write history log file
open(newunit=nolog, file='log.atm.f'//trim(cfhour))
open(newunit=nolog, file=trim(fv3atm_output_dir)//'log.atm.f'//trim(cfhour))
write(nolog,"('completed: fv3atm')")
write(nolog,"('forecast hour: ',f10.3)") nfhour
write(nolog,"('valid time: ',6(i4,2x))") wrt_int_state%fdate(1:6)
Expand Down
Loading

0 comments on commit 7147dac

Please sign in to comment.