program p_argocmp use mod_year_info use mod_levitus use mod_confmap use mod_hycomfile_io use netcdf use mod_grid use mod_xc use mod_za use mod_spline_calc use m_read_coriolis use m_dump_coriolis implicit none #if defined (IARGC) integer*4, external :: iargc #endif ! Version info of this program character(len=*), parameter :: cver = 'V0.2' ! Input file with days character(len=80) :: hyc_file integer :: year,day,hour,find,ios,ifile, & counter, refyear logical :: ex real, allocatable, dimension(:,: ) :: dp, pres, presold, saln, temp logical, allocatable, dimension(:) :: valid_profile character(len=8), dimension(:), pointer :: floatid character(len=8) :: cdate character(len=80) :: modcorfile,corfile ! Name of new netcdf file character(len=80) :: cprof character(len=40) :: tmpchar,vartitle,fname character(len= 4) :: char_fac character(len=3) :: cgg,cii character(len=12) :: clon, clat, cjuld character(len=4) :: cyear character(len=2) :: cmonth character(len=40) :: fulldir,ftype type(hycomfile) :: hfile integer :: i, i2, i3,ilon,jlat,k ,k2 real, pointer, dimension(:,:) :: csaln, cspres, ctemp, ctpres real, pointer, dimension(:,:) :: msaln , mtemp, msaln1, mtemp1, mpres1 real, pointer, dimension(:,:) :: mpresd, msalnd, mtempd real, pointer, dimension(:,:) :: levsaln, levtemp ! Error flags - used locally by nersc logical, pointer, dimension(:,:) :: errorflag_sal,errorflag_temp ! invalid profile - per mersea definitions logical, pointer, dimension(:) :: invalid_sal,invalid_temp real, pointer, dimension(:) :: cslon,ctlon,cslat,ctlat,csjuld,ctjuld real :: lat_n,lon_n integer :: iprof, izlev, nprof, nzlev integer :: ipiv,jpiv integer :: validk integer :: iyear, imonth, iday logical :: l_ncdump=.false. integer :: fid_num, kdm character(len=10) :: cfid_num real, parameter :: undef999=-999 ! Process input arguments if (iargc()/=2 .and. iargc()/=3 ) then print *,'Usage:' print *,' argocmp argo-file hycom-file [ncdump]' stop else call getarg(1,corfile) call getarg(2,hyc_file) if (iargc()==3) then call getarg(3,tmpchar) if (trim(tmpchar)=='-ncdump') then l_ncdump=.true. else print *,'Usage:' print *,' argocmp argo-file hycom-file [-ncdump]' stop end if end if end if ! Get bathymetry - lon/lat fields call xcspmd() call zaiost() call initconfmap(idm,jdm) call get_grid ! What file is this? (daily? weekly? restart? pak?) ftype=getfiletype(trim(hyc_file)) ! Initialize the hycomfile module - and retrieve vertical levels call initHF(hfile,trim(hyc_file),trim(ftype)) kdm=vdim(hfile) ! Get the coriolis schtuff - for now we can deal with one input file only call read_coriolis(trim(corfile),csaln,cspres,cslon,cslat,csjuld,floatid, & errorflag_sal, invalid_sal, 'PSAL',undef999) call read_coriolis(trim(corfile),ctemp,ctpres,ctlon,ctlat,ctjuld,floatid, & errorflag_temp,invalid_temp,'TEMP',undef999) if (any(cspres/=ctpres)) then print *,'Temperature and salinity is defined at different levels. Fix me.' stop end if nzlev = size(csaln,1) nprof = size(csaln,2) ! Start working with hycom data file write (6,'(a)',advance='yes') 'Reading from '//trim(hyc_file) ! Start allocating fields now.. allocate(dp (idm,jdm)) ! Holds 2D vars on original grid allocate(pres (idm,jdm)) ! Holds 2D vars on original grid allocate(presold (idm,jdm)) ! Holds 2D vars on original grid allocate(temp (idm,jdm)) ! Holds 2D vars on original grid allocate(saln (idm,jdm)) ! Holds 2D vars on original grid allocate(msaln1(kdm,nprof)) ! Holds 2D vars on orig vertical grid pr station allocate(mtemp1(kdm,nprof)) ! Holds 2D vars on orig vertical grid pr station allocate(mpres1(kdm,nprof)) ! Holds 2D vars on orig vertical grid pr station allocate(msalnd(nzlev,nprof)) ! Holds 2D vars on argo vertical grid pr station allocate(mtempd(nzlev,nprof)) ! Holds 2D vars on argo vertical grid pr station allocate(mpresd(nzlev,nprof)) ! Holds 2D vars on argo vertical grid pr station allocate(msaln (nzlev,nprof)) ! Holds 2D vars on argo vertical grid pr station allocate(mtemp (nzlev,nprof)) ! Holds 2D vars on argo vertical grid pr station !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ! Start working through the original vertical model grid mpres1=0. pres=0. presold=0. allocate(valid_profile(nprof)) valid_profile=.true. do k=1,kdm call HFReadDPField(hfile,dp,idm,jdm,k,1) call HFReadField(hfile,saln,idm,jdm,'saln ',k,1) call HFReadField(hfile,temp,idm,jdm,'temp ',k,1) pres=presold+dp/onem ! Put into model profile array 1. Same vertical levels as model ! Go through coriolis profiles -- find corresponding points in model do iprof=1,nprof ! Get closest point in model call oldtonew(cslat(iprof),cslon(iprof),lat_n,lon_n) call pivotp(lon_n,lat_n,ipiv,jpiv) ! Data point on grid if ( ipiv>1 .and. ipiv < idm .and. jpiv > 1 .and. jpiv < jdm .and. & depths(ipiv,jpiv)>1.) then if (k==1) then print *,'model / obs point :',plon(ipiv,jpiv),plat(ipiv,jpiv), & cslon(iprof),cslat(iprof) end if mtemp1(k,iprof)=temp(ipiv,jpiv) msaln1(k,iprof)=saln(ipiv,jpiv) mpres1(k,iprof)=pres(ipiv,jpiv) else if (.not.(ipiv>1.and.ipiv1.and.jpivcspres(k,iprof)) then mtempd(k,iprof)=mtemp1(k2,iprof) msalnd(k,iprof)=msaln1(k2,iprof) mpresd(k,iprof)=mpres1(k2,iprof)*.5 end if else if ( mpres1(k2,iprof)>cspres(k,iprof) .and. mpres1(k2-1,iprof)