FV3 Bundle
FitCoeff_ReadFile.inc
Go to the documentation of this file.
1  CHARACTER(ML) :: msg
2  CHARACTER(ML) :: io_msg
3  LOGICAL :: close_file
4  LOGICAL :: noisy
5  INTEGER :: io_stat
6  INTEGER :: fid
7  INTEGER :: release
8  INTEGER :: version
9  INTEGER :: n_dims
10  INTEGER :: dims(FITCOEFF_MAX_N_DIMENSIONS)
11 
12 
13  ! Setup
14  err_stat = SUCCESS
15  ! ...Check No_Close argument
16  close_file = .TRUE.
17  IF ( PRESENT(No_Close) ) close_file = .NOT. No_Close
18  ! ...Check Quiet argument
19  noisy = .TRUE.
20  IF ( PRESENT(Quiet) ) noisy = .NOT. Quiet
21  ! ...Override Quiet settings if debug set.
22  IF ( PRESENT(Debug) ) THEN
23  IF ( Debug ) noisy = .TRUE.
24  END IF
25 
26 
27  ! Check if the file is open.
28  IF ( File_Open( Filename ) ) THEN
29  ! ...Inquire for the logical unit number
30  INQUIRE( FILE=Filename, NUMBER=fid )
31  ! ...Ensure it's valid
32  IF ( fid < 0 ) THEN
33  msg = 'Error inquiring '//TRIM(Filename)//' for its FileID'
34  CALL Read_CleanUp(); RETURN
35  END IF
36  ELSE
37  ! ...Open the file if it exists
38  IF ( File_Exists( Filename ) ) THEN
39  err_stat = Open_Binary_File( Filename, fid )
40  IF ( err_Stat /= SUCCESS ) THEN
41  msg = 'Error opening '//TRIM(Filename)
42  CALL Read_CleanUp(); RETURN
43  END IF
44  ELSE
45  msg = 'File '//TRIM(Filename)//' not found.'
46  CALL Read_CleanUp(); RETURN
47  END IF
48  END IF
49 
50 
51  ! Read the release and version
52  READ( fid, IOSTAT=io_stat, IOMSG=io_msg ) &
53  release, &
54  version
55  IF ( io_stat /= 0 ) THEN
56  msg = 'Error reading Release/Version - '//TRIM(io_msg)
57  CALL Read_Cleanup(); RETURN
58  END IF
59  IF ( .NOT. ValidRelease( release ) ) THEN
60  msg = 'FitCoeff Release check failed.'
61  CALL Read_Cleanup(); RETURN
62  END IF
63 
64 
65  ! Read the dimension data
66  ! ...The number of dimensions
67  READ( fid, IOSTAT=io_stat, IOMSG=io_msg ) &
68  n_dims
69  IF ( io_stat /= 0 ) THEN
70  msg = 'Error reading number of dimensions from '//TRIM(Filename)//' - '//TRIM(io_msg)
71  CALL Read_Cleanup(); RETURN
72  END IF
73  ! ...Check the value
74  IF ( n_dims > SIZE(dummy%Dimensions) .OR. &
75  n_dims > FITCOEFF_MAX_N_DIMENSIONS ) THEN
76  WRITE( msg,'("Number of dimensions (",i0,") in ",a," is greater than allowed for datatype (",i0,")")' ) &
77  n_dims, TRIM(Filename), MIN(SIZE(dummy%Dimensions),FITCOEFF_MAX_N_DIMENSIONS)
78  CALL Read_Cleanup(); RETURN
79  END IF
80  ! ...The dimension values
81  READ( fid, IOSTAT=io_stat, IOMSG=io_msg ) &
82  dims(1:n_dims)
83  IF ( io_stat /= 0 ) THEN
84  msg = 'Error reading dimension values from '//TRIM(Filename)//' - '//TRIM(io_msg)
85  CALL Read_Cleanup(); RETURN
86  END IF
87  ! ...Allocate the object
88  CALL FitCoeff_Create( &
89  FitCoeff, &
90  dims(1:n_dims) )
91  IF ( .NOT. FitCoeff_Associated( FitCoeff ) ) THEN
92  msg = 'FitCoeff object allocation failed.'
93  CALL Read_Cleanup(); RETURN
94  END IF
95  ! ...Explicitly assign the version number
96  FitCoeff%Version = version
97 
98 
99  ! Read the global attributes
100  err_stat = ReadGAtts_Binary_File( &
101  fid, &
102  Title = Title , &
103  History = History, &
104  Comment = Comment )
105  IF ( err_stat /= SUCCESS ) THEN
106  msg = 'Error reading global attributes'
107  CALL Read_Cleanup(); RETURN
108  END IF
109 
110 
111  ! Read the coefficient data
112  READ( fid, IOSTAT=io_stat, IOMSG=io_msg ) &
113  FitCoeff%C
114  IF ( io_stat /= 0 ) THEN
115  msg = 'Error reading coefficient data - '//TRIM(io_msg)
116  CALL Read_Cleanup(); RETURN
117  END IF
118 
119 
120  ! Close the file
121  IF ( close_file ) THEN
122  CLOSE( fid, IOSTAT=io_stat, IOMSG=io_msg )
123  IF ( io_stat /= 0 ) THEN
124  msg = 'Error closing '//TRIM(Filename)//' - '//TRIM(io_msg)
125  CALL Read_Cleanup(); RETURN
126  END IF
127  END IF
128 
129 
130  ! Output an info message
131  IF ( noisy ) THEN
132  CALL FitCoeff_Info( FitCoeff, msg )
133  CALL Display_Message( ROUTINE_NAME, 'FILE: '//TRIM(Filename)//'; '//TRIM(msg), INFORMATION )
134  END IF
135 
136  CONTAINS
137 
138  SUBROUTINE Read_CleanUp()
139  IF ( File_Open(Filename) ) THEN
140  CLOSE( fid, IOSTAT=io_stat, IOMSG=io_msg )
141  IF ( io_stat /= 0 ) &
142  msg = TRIM(msg)//'; Error closing input file during error cleanup - '//TRIM(io_msg)
143  END IF
144  CALL FitCoeff_Destroy( FitCoeff )
145  err_stat = FAILURE
146  CALL Display_Message( ROUTINE_NAME, msg, err_stat )
147  END SUBROUTINE Read_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
character(len=128) version
logical debug
Definition: mpp.F90:1297
l_size ! loop over number of fields ke do je do ie to is
integer, parameter, public global
integer error
Definition: mpp.F90:1310
def Error(filename, linenum, category, confidence, message)
string release
Definition: conf.py:67
************************************************************************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:! ***********************************************************************!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! MPP_TRANSMIT !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! subroutine MPP_TRANSMIT_(put_data, put_len, to_pe, get_data, get_len, from_pe, block, tag, recv_request, send_request)!a message-passing routine intended to be reminiscent equally of both MPI and SHMEM!put_data and get_data are contiguous MPP_TYPE_ arrays!at each call, your put_data array is put to to_pe 's get_data! your get_data array is got from from_pe 's put_data!i.e we assume that typically(e.g updating halo regions) each PE performs a put _and_ a get!special PE designations:! NULL_PE:to disable a put or a get(e.g at boundaries)! ANY_PE:if remote PE for the put or get is to be unspecific! ALL_PES:broadcast and collect operations(collect not yet implemented)!ideally we would not pass length, but this f77-style call performs better(arrays passed by address, not descriptor)!further, this permits< length > contiguous words from an array of any rank to be passed(avoiding f90 rank conformance check)!caller is responsible for completion checks(mpp_sync_self) before and after integer, intent(in) ::put_len, to_pe, get_len, from_pe MPP_TYPE_, intent(in) ::put_data(*) MPP_TYPE_, intent(out) ::get_data(*) logical, intent(in), optional ::block integer, intent(in), optional ::tag integer, intent(out), optional ::recv_request, send_request logical ::block_comm integer ::i MPP_TYPE_, allocatable, save ::local_data(:) !local copy used by non-parallel code(no SHMEM or MPI) integer ::comm_tag integer ::rsize if(.NOT.module_is_initialized) call mpp_error(FATAL, 'MPP_TRANSMIT:You must first call mpp_init.') if(to_pe.EQ.NULL_PE .AND. from_pe.EQ.NULL_PE) return block_comm=.true. if(PRESENT(block)) block_comm=block if(debug) then call SYSTEM_CLOCK(tick) write(stdout_unit,'(a, i18, a, i6, a, 2i6, 2i8)')&'T=', tick, ' PE=', pe, ' MPP_TRANSMIT begin:to_pe, from_pe, put_len, get_len=', to_pe, from_pe, put_len, get_len end if comm_tag=DEFAULT_TAG if(present(tag)) comm_tag=tag!do put first and then get if(to_pe.GE.0 .AND. to_pe.LT.npes) then!use non-blocking sends if(debug .and.(current_clock.NE.0)) call SYSTEM_CLOCK(start_tick)!z1l:truly non-blocking send.! if(request(to_pe).NE.MPI_REQUEST_NULL) then !only one message from pe-> to_pe in queue *PE waiting for to_pe ! call error else get_len so only do gets but you cannot have a pure get with MPI call a get means do a wait to ensure put on remote PE is complete error call increase mpp_nml request_multiply call MPP_TRANSMIT get_len end if return end subroutine MPP_TRANSMIT_ ! MPP_BROADCAST ! subroutine but that doesn t allow !broadcast to a subset of PEs This version and mpp_transmit will remain !backward compatible intent(inout) a
*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)
*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 not
subroutine, public close_file(unit, status, dist)
Definition: fms_io.F90:7363