Skip to content

Commit 0641a5d

Browse files
merged develop
2 parents e6788da + a2c9176 commit 0641a5d

File tree

2 files changed

+109
-55
lines changed

2 files changed

+109
-55
lines changed

io/module_write_internal_state.F90

Lines changed: 57 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
1-
!-----------------------------------------------------------------------
2-
module write_internal_state
3-
!
4-
!-----------------------------------------------------------------------
5-
!*** the internal state of the write component.
6-
!-----------------------------------------------------------------------
7-
!***
8-
!*** revision history
9-
!***
10-
! Feb 2017: J. Wang - Initial code
11-
!
12-
!-----------------------------------------------------------------------
13-
!
1+
!> @file
2+
!> @brief The internal state of the write component.
3+
!> @author Jun Wang @date Feb, 2017
4+
5+
!> @brief The internal state of the write component.
6+
!> @author Jun Wang @date Feb, 2017
7+
module write_internal_state
148
use esmf
159
!
1610
!-----------------------------------------------------------------------
@@ -20,12 +14,27 @@ module write_internal_state
2014
!-----------------------------------------------------------------------
2115
!
2216
type output_grid_info
23-
integer :: im, jm, lm
24-
integer :: i_start,i_end, j_start,j_end
25-
real,dimension(:,:),allocatable :: lonPtr, latPtr
26-
integer,dimension(:),allocatable :: i_start_wrtgrp, i_end_wrtgrp, j_start_wrtgrp, j_end_wrtgrp
27-
real :: latse, latnw, lonse, lonnw
28-
real :: latstart, latlast, lonstart, lonlast
17+
integer :: im !< Output grid global I dimension size.
18+
integer :: jm !< Output grid global J dimension size.
19+
integer :: lm !< Output grid global L dimension size.
20+
integer :: i_start !< Output grid lower bound of I dimension on current PE.
21+
integer :: i_end !< Output grid upper bound of I dimension on current PE.
22+
integer :: j_start !< Output grid lower bound of J dimension on current PE.
23+
integer :: j_end !< Output grid upper bound of J dimension on current PE.
24+
real,dimension(:,:),allocatable :: lonPtr !< Output grid longitudes.
25+
real,dimension(:,:),allocatable :: latPtr !< Output grid latitudes.
26+
integer,dimension(:),allocatable :: i_start_wrtgrp !< I dimension lower bound of all wrire groups.
27+
integer,dimension(:),allocatable :: i_end_wrtgrp !< I dimension upper bound of all wrire groups.
28+
integer,dimension(:),allocatable :: j_start_wrtgrp !< J dimension lower bound of all wrire groups.
29+
integer,dimension(:),allocatable :: j_end_wrtgrp !< J dimension upper bound of all wrire groups.
30+
real :: latse !< Output grid South East corner latitude.
31+
real :: latnw !< Output grid North West corner latitude.
32+
real :: lonse !< Output grid South East corner longitude.
33+
real :: lonnw !< Output grid North West corner longitude.
34+
real :: latstart !< Output grid start latitude.
35+
real :: latlast !< Output grid last latitude.
36+
real :: lonstart !< Output grid start logitude.
37+
real :: lonlast !< Output grid last longitude.
2938
end type output_grid_info
3039

3140
type wrt_internal_state
@@ -34,72 +43,73 @@ module write_internal_state
3443
! pe information and task layout
3544
!--------------------------------
3645
!
37-
integer :: mype
38-
integer :: petcount
46+
integer :: mype !< MPI rank.
47+
integer :: petcount !< Number of PEs.
3948
!
4049
!--------------------
4150
!*** grid information
4251
!--------------------
43-
type(esmf_grid) :: wrtgrid
52+
type(esmf_grid) :: wrtgrid !< ESMF output grid.
4453

45-
type(output_grid_info) ,dimension(:), allocatable :: out_grid_info
54+
!> Array of output_grid_info for all domains.
55+
type(output_grid_info) ,dimension(:), allocatable :: out_grid_info
4656
!
4757
!--------------------------
4858
!*** file bundle for output
4959
!--------------------------
50-
integer :: FBCount
60+
integer :: FBCount !< Numebr of output ESMF field bundles.
5161
!
5262
!-----------------------------------------------------------------------
5363
!*** THE OUTPUT FILE
5464
!-----------------------------------------------------------------------
5565
!
56-
integer :: num_files
66+
integer :: num_files !< Number of output files.
5767
!
5868
!-----------------------------------------------------------------------
5969
!*** THE OUTPUT FILE
6070
!-----------------------------------------------------------------------
6171
!
62-
type(ESMF_FieldBundle),dimension(:),allocatable :: wrtFB
72+
!> ESMF write field bundles.
73+
type(ESMF_FieldBundle),dimension(:),allocatable :: wrtFB
6374
!
6475
!-------------------------------------
6576
!*** Times used in history filenames
6677
!-------------------------------------
6778
!
68-
type(ESMF_Time) :: io_basetime
69-
integer :: idate(7)
70-
integer :: fdate(7)
79+
type(ESMF_Time) :: io_basetime !< ESMF clock's starting time.
80+
integer :: idate(7) !< Forecast initial time.
81+
integer :: fdate(7) !< Forecast current time.
7182
!
7283
!-----------------------------------------
7384
!*** I/O direction flags (Read or Write)
7485
!-----------------------------------------
7586
!
76-
logical :: output_history
87+
logical :: output_history !< True if history output is requested.
7788
!
7889
!-----------------------------------------
7990
!*** POST flags and required variables
8091
!-----------------------------------------
8192
!
82-
logical :: write_dopost
83-
character(80) :: post_namelist
84-
!
85-
integer :: fhzero
86-
integer :: ntrac
87-
integer :: ncld
88-
integer :: nsoil
89-
integer :: imp_physics
90-
integer :: dtp
91-
real,dimension(:),allocatable :: ak,bk
93+
logical :: write_dopost !< True if inline post is requested.
94+
character(80) :: post_namelist !< File name of the inline post namelist.
95+
!
96+
integer :: fhzero !< Hours between clearing of diagnostic buckets.
97+
integer :: ntrac !< Number of tracers.
98+
integer :: ncld !< Number of hydrometeors.
99+
integer :: nsoil !< Number of soil layers.
100+
integer :: imp_physics !< Choice of microphysics scheme.
101+
integer :: dtp !< Physics timestep.
102+
real,dimension(:),allocatable :: ak !< a parameter for sigma pressure level calculations.
103+
real,dimension(:),allocatable :: bk !< b parameter for sigma pressure level calculations.
92104
!-----------------------------------------------------------------------
93105
!
94106
end type wrt_internal_state
95-
!
96-
!-----------------------------------------------------------------------
97-
!*** THIS STATE IS SUPPORTED BY C POINTERS BUT NOT F90 POINTERS
98-
!*** THEREFORE WE NEED THIS WRAP.
99-
!-----------------------------------------------------------
100-
!
107+
108+
!> This state is supported by c pointers but not f90 pointers
109+
!> therefore we need this wrap.
101110
type write_wrap
102-
type(wrt_internal_state),pointer :: write_int_state
111+
!> Write grid component internal state.
112+
type(wrt_internal_state),pointer :: write_int_state
103113
end type write_wrap
104114

105115
!-----------------------------------------------------------

io/module_write_netcdf.F90

Lines changed: 52 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,19 @@
1+
!> @file
2+
!> @brief Module containing history files output routines.
3+
!> @author Dusan Jovic @date Nov 1, 2017
4+
5+
!> Return error to ESMF and finalize it.
16
#define ESMF_ERR_RETURN(rc) \
27
if (ESMF_LogFoundError(rc, msg="Breaking out of subroutine", line=__LINE__, file=__FILE__)) call ESMF_Finalize(endflag=ESMF_END_ABORT)
38

9+
!> Return error to ESMF and finalize it.
410
#define NC_ERR_STOP(status) \
511
if (status /= nf90_noerr) write(0,*) "file: ", __FILE__, " line: ", __LINE__, trim(nf90_strerror(status)); \
612
if (status /= nf90_noerr) call ESMF_Finalize(endflag=ESMF_END_ABORT)
713

14+
!> @brief Output routines for writing history files.
15+
!>
16+
!> @author Dusan Jovic @date Nov 1, 2017
817
module module_write_netcdf
918

1019
use mpi
@@ -19,11 +28,21 @@ module module_write_netcdf
1928
private
2029
public write_netcdf
2130

22-
logical :: par
23-
24-
contains
25-
26-
!----------------------------------------------------------------------------------------
31+
logical :: par !< True if parallel I/O should be used.
32+
33+
contains
34+
35+
!> Write netCDF file.
36+
!>
37+
!> @param[in] wrtfb ESMF write field bundle.
38+
!> @param[in] filename NetCDF filename.
39+
!> @param[in] use_parallel_netcdf True if parallel I/O should be used.
40+
!> @param[in] mpi_comm MPI communicator for parallel I/O.
41+
!> @param[in] mype MPI rank.
42+
!> @param[in] grid_id Output grid identifier.
43+
!> @param[out] rc Return code - 0 for success, ESMF error code otherwise.
44+
!>
45+
!> @author Dusan Jovic @date Nov 1, 2017
2746
subroutine write_netcdf(wrtfb, filename, &
2847
use_parallel_netcdf, mpi_comm, mype, &
2948
grid_id, rc)
@@ -716,7 +735,14 @@ subroutine write_netcdf(wrtfb, filename, &
716735

717736
end subroutine write_netcdf
718737

719-
!----------------------------------------------------------------------------------------
738+
!> Get global attribute.
739+
!>
740+
!> @param[in] fldbundle ESMF field bundle.
741+
!> @param[in] ncid NetCDF file ID.
742+
!> @param[in] mype MPI rank.
743+
!> @param[out] rc Return code - 0 for success, ESMF error code otherwise.
744+
!>
745+
!> @author Dusan Jovic @date Nov 1, 2017
720746
subroutine get_global_attr(fldbundle, ncid, mype, rc)
721747
type(ESMF_FieldBundle), intent(in) :: fldbundle
722748
integer, intent(in) :: ncid
@@ -785,7 +811,15 @@ subroutine get_global_attr(fldbundle, ncid, mype, rc)
785811

786812
end subroutine get_global_attr
787813

788-
!----------------------------------------------------------------------------------------
814+
!> Get grid attribute.
815+
!>
816+
!> @param[in] grid ESMF output grid.
817+
!> @param[in] prefix grid attribute prefix.
818+
!> @param[in] ncid NetCDF file ID.
819+
!> @param[in] varid NetCDF variable ID.
820+
!> @param[out] rc Return code - 0 for success, ESMF error code otherwise.
821+
!>
822+
!> @author Dusan Jovic @date Nov 1, 2017
789823
subroutine get_grid_attr(grid, prefix, ncid, varid, rc)
790824
type(ESMF_Grid), intent(in) :: grid
791825
character(len=*), intent(in) :: prefix
@@ -849,7 +883,17 @@ subroutine get_grid_attr(grid, prefix, ncid, varid, rc)
849883

850884
end subroutine get_grid_attr
851885

852-
!----------------------------------------------------------------------------------------
886+
!> Add a dimension.
887+
!>
888+
!> @param[in] ncid NetCDF file ID.
889+
!> @param[in] dim_name Dimension name.
890+
!> @param[in] dimid Dimension ID.
891+
!> @param[in] grpid Group ID.
892+
!> @param[in] grid ESMF output grid.
893+
!> @param[in] mype MPI rank.
894+
!> @param[out] rc Return code - 0 for success, ESMF error code otherwise.
895+
!>
896+
!> @author Dusan Jovic @date Nov 1, 2017
853897
subroutine add_dim(ncid, dim_name, dimid, grid, mype, rc)
854898
integer, intent(in) :: ncid
855899
character(len=*), intent(in) :: dim_name

0 commit comments

Comments
 (0)