FV3 Bundle
FitCoeff_WriteFile.inc
Go to the documentation of this file.
1  ! Function variables
2  CHARACTER(ML) :: msg
3  CHARACTER(ML) :: io_msg
4  LOGICAL :: close_file
5  LOGICAL :: noisy
6  INTEGER :: io_stat
7  INTEGER :: fid
8 
9 
10  ! Setup
11  err_stat = SUCCESS
12  ! ...Check No_Close argument
13  close_file = .TRUE.
14  IF ( PRESENT(No_Close) ) close_file = .NOT. No_Close
15  ! ...Check Quiet argument
16  noisy = .TRUE.
17  IF ( PRESENT(Quiet) ) noisy = .NOT. Quiet
18  ! ...Override Quiet settings if debug set.
19  IF ( PRESENT(Debug) ) THEN
20  IF ( Debug ) noisy = .TRUE.
21  END IF
22  ! ...Check there is data to write
23  IF ( .NOT. FitCoeff_Associated( FitCoeff ) ) THEN
24  msg = 'FitCoeff object is empty.'
25  CALL Write_Cleanup(); RETURN
26  END IF
27 
28 
29  ! Check if the file is open.
30  IF ( File_Open( FileName ) ) THEN
31  ! ...Inquire for the logical unit number
32  INQUIRE( FILE=Filename, NUMBER=fid )
33  ! ...Ensure it's valid
34  IF ( fid < 0 ) THEN
35  msg = 'Error inquiring '//TRIM(Filename)//' for its FileID'
36  CALL Write_CleanUp(); RETURN
37  END IF
38  ELSE
39  ! ...Open the file for output
40  err_stat = Open_Binary_File( Filename, fid, For_Output=.TRUE. )
41  IF ( err_Stat /= SUCCESS ) THEN
42  msg = 'Error opening '//TRIM(Filename)
43  CALL Write_CleanUp(); RETURN
44  END IF
45  END IF
46 
47 
48  ! Write the release and version
49  WRITE( fid, IOSTAT=io_stat, IOMSG=io_msg ) &
50  FitCoeff%Release, &
51  FitCoeff%Version
52  IF ( io_stat /= 0 ) THEN
53  msg = 'Error writing Release/Version - '//TRIM(io_msg)
54  CALL Write_Cleanup(); RETURN
55  END IF
56 
57 
58  ! Write the dimension data
59  ! ...The number of dimensions
60  WRITE( fid, IOSTAT=io_stat, IOMSG=io_msg ) &
61  SIZE(FitCoeff%Dimensions)
62  IF ( io_stat /= 0 ) THEN
63  msg = 'Error writing number of dimensions to '//TRIM(Filename)//' - '//TRIM(io_msg)
64  CALL Write_Cleanup(); RETURN
65  END IF
66  ! ...The dimension values
67  WRITE( fid, IOSTAT=io_stat, IOMSG=io_msg ) &
68  FitCoeff%Dimensions
69  IF ( io_stat /= 0 ) THEN
70  msg = 'Error writing dimension values to '//TRIM(Filename)//' - '//TRIM(io_msg)
71  CALL Write_Cleanup(); RETURN
72  END IF
73 
74 
75  ! Write the global attributes
76  err_stat = WriteGAtts_Binary_File( &
77  fid, &
78  Write_Module = MODULE_VERSION_ID, &
79  Title = Title , &
80  History = History, &
81  Comment = Comment )
82  IF ( err_stat /= SUCCESS ) THEN
83  msg = 'Error writing global attributes'
84  CALL Write_Cleanup(); RETURN
85  END IF
86 
87 
88  ! Write the coefficient data
89  WRITE( fid, IOSTAT=io_stat, IOMSG=io_msg ) &
90  FitCoeff%C
91  IF ( io_stat /= 0 ) THEN
92  msg = 'Error writing coefficient data - '//TRIM(io_msg)
93  CALL Write_Cleanup(); RETURN
94  END IF
95 
96 
97  ! Close the file
98  IF ( close_file ) THEN
99  CLOSE( fid, IOSTAT=io_stat, IOMSG=io_msg )
100  IF ( io_stat /= 0 ) THEN
101  msg = 'Error closing '//TRIM(Filename)//' - '//TRIM(io_msg)
102  CALL Write_Cleanup(); RETURN
103  END IF
104  END IF
105 
106 
107  ! Output an info message
108  IF ( noisy ) THEN
109  CALL FitCoeff_Info( FitCoeff, msg )
110  CALL Display_Message( ROUTINE_NAME, 'FILE: '//TRIM(Filename)//'; '//TRIM(msg), INFORMATION )
111  END IF
112 
113  CONTAINS
114 
115  SUBROUTINE Write_Cleanup()
116  IF ( File_Open(Filename) ) THEN
117  CLOSE( fid, STATUS=WRITE_ERROR_STATUS, IOSTAT=io_stat, IOMSG=io_msg )
118  IF ( io_stat /= 0 ) &
119  msg = TRIM(msg)//'; Error closing output file during error cleanup - '//TRIM(io_msg)
120  END IF
121  err_stat = FAILURE
122  CALL Display_Message( ROUTINE_NAME, msg, err_stat )
123  END SUBROUTINE Write_Cleanup
************************************************************************GNU Lesser General Public License **This file is part of the GFDL Flexible Modeling System(FMS). ! *! *FMS is free software without even the implied warranty of MERCHANTABILITY or *FITNESS FOR A PARTICULAR PURPOSE See the GNU General Public License *for more details **You should have received a copy of the GNU Lesser General Public *License along with FMS If see< http:! ***********************************************************************subroutine READ_RECORD_CORE_(unit, field, nwords, data, start, axsiz) integer, intent(in) ::unit type(fieldtype), intent(in) ::field integer, intent(in) ::nwords MPP_TYPE_, intent(inout) ::data(nwords) integer, intent(in) ::start(:), axsiz(:) integer(SHORT_KIND) ::i2vals(nwords)!rab used in conjunction with transfer intrinsic to determine size of a variable integer(KIND=1) ::one_byte(8) integer ::word_sz!#ifdef __sgi integer(INT_KIND) ::ivals(nwords) real(FLOAT_KIND) ::rvals(nwords)!#else! integer ::ivals(nwords)! real ::rvals(nwords)!#endif real(DOUBLE_KIND) ::r8vals(nwords) pointer(ptr1, i2vals) pointer(ptr2, ivals) pointer(ptr3, rvals) pointer(ptr4, r8vals) if(mpp_io_stack_size< nwords) call mpp_io_set_stack_size(nwords) call mpp_error(FATAL, 'MPP_READ currently requires use_netCDF option') end subroutine READ_RECORD_CORE_ subroutine READ_RECORD_(unit, field, nwords, data, time_level, domain, position, tile_count, start_in, axsiz_in)!routine that is finally called by all mpp_read routines to perform the read!a non-netCDF record contains:! field ID! a set of 4 coordinates(is:ie, js:je) giving the data subdomain! a timelevel and a timestamp(=NULLTIME if field is static)! 3D real data(stored as 1D)!if you are using direct access I/O, the RECL argument to OPEN must be large enough for the above!in a global direct access file, record position on PE is given by %record.!Treatment of timestamp:! We assume that static fields have been passed without a timestamp.! Here that is converted into a timestamp of NULLTIME.! For non-netCDF fields, field is treated no differently, but is written! with a timestamp of NULLTIME. There is no check in the code to prevent! the user from repeatedly writing a static field. integer, intent(in) ::unit, nwords type(fieldtype), intent(in) ::field MPP_TYPE_, intent(inout) ::data(nwords) integer, intent(in), optional ::time_level type(domain2D), intent(in), optional ::domain integer, intent(in), optional ::position, tile_count integer, intent(in), optional ::start_in(:), axsiz_in(:) integer, dimension(size(field%axes(:))) ::start, axsiz integer ::tlevel !, subdomain(4) integer ::i, error, is, ie, js, je, isg, ieg, jsg, jeg type(domain2d), pointer ::io_domain=> unit
dictionary attributes
Definition: plotDiffs.py:16
subroutine cleanup()
integer, parameter set
l_size ! loop over number of fields ke do je do ie to je n if(.NOT. d_comm%R_do_buf(list)) cycle from_pe
logical debug
Definition: mpp.F90:1297
l_size ! loop over number of fields ke do je do ie to is
output
Definition: c2f.py:20
integer, parameter, public global
integer error
Definition: mpp.F90:1310
def Error(filename, linenum, category, confidence, message)
*f90 *************************************************************************GNU Lesser General Public License **This file is part of the GFDL Flexible Modeling System(FMS). ! *! *FMS is free software without even the implied warranty of MERCHANTABILITY or *FITNESS FOR A PARTICULAR PURPOSE See the GNU General Public License *for more details **You should have received a copy of the GNU Lesser General Public *License along with FMS If see< http:! ***********************************************************************subroutine MPP_UPDATE_NEST_FINE_2D_(field, nest_domain, wbuffer, ebuffer, sbuffer, nbuffer, &flags, complete, position, extra_halo, name, tile_count) MPP_TYPE_, intent(in) ::field(:,:) type(nest_domain_type), intent(inout) ::nest_domain MPP_TYPE_, intent(inout) ::wbuffer(:,:) MPP_TYPE_, intent(inout) ::ebuffer(:,:) MPP_TYPE_, intent(inout) ::sbuffer(:,:) MPP_TYPE_, intent(inout) ::nbuffer(:,:) integer, intent(in), optional ::flags logical, intent(in), optional ::complete integer, intent(in), optional ::position integer, intent(in), optional ::extra_halo character(len= *), intent(in), optional ::name integer, intent(in), optional ::tile_count MPP_TYPE_ ::field3D(size(field, 1), size(field, 2), 1) MPP_TYPE_ ::wbuffer3D(size(wbuffer, 1), size(wbuffer, 2), 1) MPP_TYPE_ ::ebuffer3D(size(ebuffer, 1), size(ebuffer, 2), 1) MPP_TYPE_ ::sbuffer3D(size(sbuffer, 1), size(sbuffer, 2), 1) MPP_TYPE_ ::nbuffer3D(size(nbuffer, 1), size(nbuffer, 2), 1) pointer(ptr, field3D) pointer(ptr_w, wbuffer3D) pointer(ptr_e, ebuffer3D) pointer(ptr_s, sbuffer3D) pointer(ptr_n, nbuffer3D) ptr=LOC(field) ptr_w=LOC(wbuffer) ptr_e=LOC(ebuffer) ptr_s=LOC(sbuffer) ptr_n=LOC(nbuffer) call mpp_update_nest_fine(field3D, nest_domain, wbuffer3D, ebuffer3D, sbuffer3D, nbuffer3D, &flags, complete, position, extra_halo, name, tile_count) returnend subroutine MPP_UPDATE_NEST_FINE_2D_subroutine MPP_UPDATE_NEST_FINE_3D_(field, nest_domain, wbuffer, sbuffer, ebuffer, nbuffer, &flags, complete, position, extra_halo, name, tile_count) MPP_TYPE_, intent(in) ::field(:,:,:) type(nest_domain_type), intent(inout) ::nest_domain MPP_TYPE_, intent(inout) ::wbuffer(:,:,:) MPP_TYPE_, intent(inout) ::ebuffer(:,:,:) MPP_TYPE_, intent(inout) ::sbuffer(:,:,:) MPP_TYPE_, intent(inout) ::nbuffer(:,:,:) integer, intent(in), optional ::flags logical, intent(in), optional ::complete integer, intent(in), optional ::position integer, intent(in), optional ::extra_halo character(len= *), intent(in), optional ::name integer, intent(in), optional ::tile_count MPP_TYPE_ ::d_type type(nestSpec), pointer ::update=> dimension(MAX_DOMAIN_FIELDS)
subroutine, public close_file(unit, status, dist)
Definition: fms_io.F90:7363