25 use mpp_io_mod,
only: mpp_io_init, mpp_open, mpp_ascii, &
26 mpp_overwr, mpp_sequential, &
31 close_file, open_namelist_file, &
32 stdlog, write_version_number
57 #include<file_version.h> 89 namelist / column_diagnostics_nml / &
124 integer :: unit, ierr, io
151 #ifdef INTERNAL_FILE_NML 155 if (file_exist(
'input.nml'))
then 156 unit = open_namelist_file( )
157 ierr=1;
do while (ierr /= 0)
158 read (unit, nml=column_diagnostics_nml, iostat=io, end=10)
161 10
call close_file (unit)
167 call write_version_number(
"COLUMN_DIAGNOSTICS_MOD", version)
168 if (mpp_pe() == mpp_root_pe())
then 170 write (unit, nml=column_diagnostics_nml)
184 (module, num_diag_pts_latlon, num_diag_pts_ij, &
185 global_i , global_j , global_lat_latlon, &
186 global_lon_latlon, lonb_in, latb_in, &
187 do_column_diagnostics, &
188 diag_lon, diag_lat, diag_i, diag_j, diag_units)
197 character(len=*),
intent(in) :: module
198 integer,
intent(in) :: num_diag_pts_latlon, &
200 integer,
dimension(:),
intent(in) :: global_i, global_j
201 real ,
dimension(:),
intent(in) :: global_lat_latlon, &
203 real,
dimension(:,:),
intent(in) :: lonb_in, latb_in
204 logical,
dimension(:,:),
intent(out) :: do_column_diagnostics
205 integer,
dimension(:),
intent(inout) :: diag_i, diag_j
206 real ,
dimension(:),
intent(out) :: diag_lat, diag_lon
207 integer,
dimension(:),
intent(out) :: diag_units
239 real,
dimension(size(diag_i,1)) :: global_lat, global_lon
240 real,
dimension(size(latb_in,1)-1, size(latb_in,2)-1) :: &
241 distance, distance_x, distance_y, &
242 distance_x2, distance2
243 real,
dimension(size(latb_in,1), size(latb_in,2)) :: latb_deg
244 real,
dimension(size(lonb_in,1), size(lonb_in,2)) :: lonb_deg
245 real :: dellat, dellon
246 real :: latb_max, latb_min, lonb_max, lonb_min
248 integer :: num_diag_pts
251 real :: current_distance
252 character(len=8) :: char
253 character(len=32) :: filename
254 logical :: allow_ij_input
278 dellat = latb_in(1,2) - latb_in(1,1)
279 dellon = lonb_in(2,1) - lonb_in(1,1)
280 latb_max = maxval(latb_deg(:,:))
281 latb_min = minval(latb_deg(:,:))
282 lonb_max = maxval(lonb_deg(:,:))
283 lonb_min = minval(lonb_deg(:,:))
284 if (lonb_min < 10.0 .or. lonb_max > 350.)
then 289 allow_ij_input = .true.
290 ref_lat = latb_in(1,1)
291 do i =2,
size(latb_in,1)
292 if (latb_in(i,1) /= ref_lat)
then 293 allow_ij_input = .false.
298 if ( .not. allow_ij_input .and. num_diag_pts_ij /= 0)
then 300 'cannot specify column diagnostics column with (i,j) & 301 &coordinates when using cubed sphere -- must specify & 302 & lat/lon coordinates', fatal)
309 do_column_diagnostics = .false.
315 num_diag_pts =
size(diag_i(:))
320 do nn = 1, num_diag_pts_latlon
321 global_lat(nn) = global_lat_latlon(nn)
322 global_lon(nn) = global_lon_latlon(nn)
325 do nn = 1, num_diag_pts_ij
326 global_lat(nn+num_diag_pts_latlon) = &
327 ((-0.5*acos(-1.0) + 0.5*dellat) + &
328 (global_j(nn)-1) *dellat)*
radian 329 global_lon(nn+num_diag_pts_latlon) = (0.5*dellon + &
330 (global_i(nn)-1)*dellon)*
radian 343 if (global_lon(nn) >= 0. .and. global_lon(nn) <= 360.0)
then 346 ' invalid longitude', fatal)
348 if (global_lat(nn) >= -90.0 .and. global_lat(nn) <= 90.0)
then 351 ' invalid latitude', fatal)
360 if (global_lat(nn) .ge. latb_min .and. &
361 global_lat(nn) .le. latb_max)
then 362 if (global_lon(nn) .ge. lonb_min .and.&
363 global_lon(nn) .le. lonb_max)
then 364 do j=1,
size(latb_deg,2) - 1
365 do i=1,
size(lonb_deg,1) - 1
366 distance_y(i,j) = abs(global_lat(nn) - latb_deg(i,j))
367 distance_x(i,j) = abs(global_lon(nn) - lonb_deg(i,j))
368 distance_x2(i,j) = abs((global_lon(nn)-360.) - &
370 distance(i,j) = (global_lat(nn) - latb_deg(i,j))**2 + &
371 (global_lon(nn) - lonb_deg(i,j))**2
372 distance2(i,j) = (global_lat(nn) - latb_deg(i,j))**2 + &
373 ((global_lon(nn)-360.) - &
385 current_distance = distance(1,1)
386 do j=1,
size(latb_deg,2) - 1
387 do i=1,
size(lonb_deg,1) - 1
390 if (distance(i,j) < current_distance)
then 391 current_distance = distance(i,j)
392 do_column_diagnostics(i,j) = .true.
395 diag_lon(nn) = lonb_deg(i,j)
396 diag_lat(nn) = latb_deg(i,j)
406 if (distance2(i,j) < current_distance)
then 407 current_distance = distance2(i,j)
408 do_column_diagnostics(i,j) = .true.
411 diag_lon(nn) = lonb_deg(i,j)
412 diag_lat(nn) = latb_deg(i,j)
424 write (char,
'(i2)') nn
425 filename = trim(module) //
'_point' // &
426 trim(adjustl(char)) //
'.out' 427 call mpp_open (diag_units(nn), filename, &
430 access=mpp_sequential, &
431 threading=mpp_multi, nohdrs=.true.)
448 (module, diag_unit, time, nn, diag_lon, &
449 diag_lat, diag_i, diag_j)
458 character(len=*),
intent(in) :: module
460 integer,
intent(in) :: diag_unit
461 integer,
intent(in) :: nn
462 real,
dimension(:),
intent(in) :: diag_lon, diag_lat
463 integer,
dimension(:),
intent(in) :: diag_i, diag_j
482 integer :: year, month, day, hour, minute, second
483 character(len=8) :: mon
484 character(len=64) :: header
502 call get_date (time, year, month, day, hour, minute, second)
509 write (diag_unit,
'(a)')
' ' 510 write (diag_unit,
'(a)')
' ' 511 write (diag_unit,
'(a)') &
512 '======================================================' 513 write (diag_unit,
'(a)')
' ' 514 header =
' PRINTING ' //
module //
' DIAGNOSTICS' 515 write (diag_unit,
'(a)') header
516 write (diag_unit,
'(a)')
' ' 517 write (diag_unit,
'(a, i6,2x, a,i4,i4,i4,i4)')
' time stamp:', &
518 year, trim(mon), day, &
520 write (diag_unit,
'(a, i4)') &
521 ' DIAGNOSTIC POINT COORDINATES, point #', nn
522 write (diag_unit,
'(a)')
' ' 523 write (diag_unit,
'(a,f8.3,a,f8.3)')
' longitude = ', &
524 diag_lon(nn),
' latitude = ', diag_lat(nn)
525 write (diag_unit,
'(a, i6, a,i6,a,i6)') &
526 ' on processor # ', mpp_pe(), &
527 ' : processor i =', diag_i(nn), &
528 ' , processor j =', diag_j(nn)
529 write (diag_unit,
'(a)')
' ' 535 end subroutine column_diagnostics_header
541 subroutine close_column_diagnostics_units (diag_units)
549 integer,
dimension(:),
intent(in) :: diag_units
567 do nn=1,
size(diag_units(:))
568 if (diag_units(nn) /= -1)
then 569 call mpp_close (diag_units(nn))
576 end subroutine close_column_diagnostics_units
subroutine, public get_date(time, year, month, day, hour, minute, second, tick, err_msg)
subroutine, public column_diagnostics_header(module, diag_unit, Time, nn, diag_lon, diag_lat, diag_i, diag_j)
subroutine, public initialize_diagnostic_columns(module, num_diag_pts_latlon, num_diag_pts_ij, global_i, global_j, global_lat_latlon, global_lon_latlon, lonb_in, latb_in, do_column_diagnostics, diag_lon, diag_lat, diag_i, diag_j, diag_units)
character(len=9) function, public month_name(n)
integer function, public check_nml_error(IOSTAT, NML_NAME)
character(len=input_str_length), dimension(:), allocatable, target, public input_nml_file
real, parameter, public pi
Ratio of circle circumference to diameter [N/A].
real, parameter, public radian
Equal to RAD_TO_DEG for backward compatability. [rad/deg].
subroutine, public fms_init(localcomm)
subroutine, public column_diagnostics_init
subroutine, public time_manager_init()
subroutine, public close_column_diagnostics_units(diag_units)
logical module_is_initialized
subroutine, public error_mesg(routine, message, level)
subroutine, public constants_init
dummy routine.