! program mksrc ! ! Read a 5 degree horizontal resolution tiegcm history file, ! interpolate to 2.5 degrees and rewrite new file for use ! by 2.5 degree model. ! Set desired new grid in grid.F. Old grid is read from input history. ! use input_module,only: input,mtimes,histfile_read,histfile_write, | msspath_read,msspath_write,interp_horizontal,interp_vertical use readhist_module,only: history,readhist,fminmax use writehist_module,only: writehist use newhist_module,only: newhist,horizontal_interp, | vertical_interp,grid3d_interp,allocdata use grid_module implicit none #include "mksrc.h" ! integer :: i,ihist_new,ier,iprint,n type(history) :: | h_orig, ! original history structure read from histfile_read | h_new ! new history structure written to histfile_write real :: fmin,fmax ! Debug ! ! Execute: write(6,"(/,'Enter mksrc')") ! ! Read user input: call input ! ! History read loop: ihist_new = 0 read_loop: do i=1,mxhist if (all(mtimes(:,i)==ispval)) cycle read_loop write(6,"(/,'History read loop: i=',i3,' mtime=',3i4)") | i,mtimes(:,i) ! ! Read input history: iprint = 1 call readhist(histfile_read,mtimes(:,i),h_orig,iprint,ier) ! ! Top level comes out slightly low because of round-off reading from netcdf: ! h_orig%lev(h_orig%nlev) = h_orig%lev(h_orig%nlev)+1.e-10 ! ! Set old grid from input history: call set_oldgrid(h_orig) ! ! Set new grid: call set_newgrid ! ! Set desired mss path for new file in h_new: ! may need to check lengths here: ! h_new%mss_path = msspath_write ! h_new%mss_source = msspath_read ! ! Make new history structure, including grid interpolation: ihist_new = ihist_new+1 call newhist(h_orig,h_new,ihist_new) ! ! Allocate data on h_new: call allocdata(h_new) ! ! Do interpolation: if (interp_horizontal==1.and.interp_vertical==1) then call grid3d_interp(h_orig,h_new) else if (interp_horizontal==1) call horizontal_interp(h_orig,h_new) if (interp_vertical ==1) call vertical_interp(h_orig,h_new) endif ! ! Write new history structure to new history file: ! subroutine writehist(file,mtime,h,iprint,error) ! iprint = 1 call writehist(histfile_write,mtimes(:,i),h_new,iprint,ier) enddo read_loop ! ! Dispose new file to mss: ! call putms(histfile_write,msspath_write) end program mksrc