2016-02-01 69 views
0

不可分類的聲明好吧,這一個讓我難住。我合併了兩個不同的Fortran代碼,並且讓所有編譯的代碼都想先編譯一個,然後將其鏈接到另一個。我敢肯定,我已經想通大多認爲,除了當我嘗試編譯此作爲一個對象,我得到Fortran錯誤:在子程序

 subroutine snowpacrm(calday,ps,pmidm1,tm1,qm1,o3mmr,cld,clwp,pmln1,pintm1 
     1 
Error: Unclassifiable statement at (1) 

我與gfortran編譯,指定固定的形式,固定形式132線長,與C預處理等下面是代碼中的相關片段:

#include <misc.h> 
#include <params.h> 
#define crmoutput 0 

c  The following block allows the entire CRM to compile with a simple command 
c  Using this command also checks that all needed files are in the CRM 
#ifdef SINGLE_SOURCE_FILE 
#include <aermix.F> 
#include <albocean.F> 
#include <blkdat.F> 
#include <cldefr.F> 
#include <cldems.F> 
#include <endrun.F> 
#include <freemem.F> 
#include <getmem.F> 
#include <fmrgrid.F> 
#include <orb.F> 
#include <radabs.F> 
#include <radclr.F> 
#include <radclw.F> 
#include <radcsw.F> 
#include <radctl.F> 
#include <radded.F> 
#include <radems.F> 
#include <radini.F> 
#include <radinp.F> 
#include <radoz2.F> 
#include <radtpl.F> 
#include <resetr.F> 
#include <torgrid.F> 
#include <trcab.F> 
#include <trcabn.F> 
#include <trcems.F> 
#include <trcmix.F> 
#include <trcplk.F> 
#include <trcpth.F> 
#include <zenith.F> 
#include <netcdf.F> 
#ifndef CRAY 
#include <intmax.F> 
#include <isrchfgt.F> 
#include <isrchfle.F> 
#include <wheneq.F> 
#include <whenfgt.F> 
#include <whenflt.F> 
#include <whenne.F> 
#endif /* CRAY */ 
#endif /* not SINGLE_SOURCE_FILE */ 


#include <implicit.h> 
c  Parameters 
#include <prgrid.h> 
c  Commons 
#include <comtim.h> /* calday */ 
#include <comvmr.h> /* co2vmr, n2ovmr, ch4vmr, f11vmr, f12vmr */ 
#include <comsol.h> /* scon, tauvis, eccen, obliq, mvelp, iyear_AD, obliqr, lambm0, mvelpp */ 
#include <comctl.h> /* anncyc,iradsw,iradlw,iradae */ 
#ifdef CRM_SRB 
#include <crmsrb.h> /* Surface radiation budget diagnostics */ 
#endif 

     subroutine snowpacrm(calday,ps,pmidm1,tm1,qm1,o3mmr,cld,clwp,pmln1,pintm1,pilnm1,   
    &      ts,tg,oro,snowh,gsol0,iyear_AD,loctim,pie,clat,clon,eccen,obliq,  
    &      mvelp,obliqr,lambm0,mvelpp,o3vmr,asdir,asdif,aldir,aldif,tauvis,  
    &      co2vmr,n2ovmr,ch4vmr,f11vmr,f12vmr,         
    &      flswn,fllwn,flswu,flswd,fllwu,fllwd,flnet) !outputs 


     real clon(plon)   ! Centered longitude (radians) 
     real clat     ! Current centered latitude (radians) 
     real cld(plond,plevp)  ! fractional cloud cover 
     real clwp(plond,plev)  ! cloud liquid water path 
     real coslat    ! cosine latitude 
     real gsol0 


c  NB: o3mmr and o3vmr should be dimensioned (plond,plevr) if a different 
c  size radiation grid is used. Clashes between prgrid.h and ptrrgrid.h 
c  (they both define plngbuf) prevent us from dimensioning anything by 
c  plevr in this top level crm() routine. 
     real o3mmr(plond,plev) ! Ozone mass mixing ratio 
     real o3vmr(plond,plev) ! Ozone volume mixing ratio 

     real aldif(plond)   ! Albedo: longwave, diffuse 
     real aldir(plond)   ! Albedo: longwave, direct 
     real asdif(plond)   ! Albedo: shortwave, diffuse 
     real asdir(plond)   ! Albedo: shortwave, direct 
     real oro(plond)   ! Land/ocean/sea ice flag 
     real pilnm1(plond,plevp) ! natural log of pintm1 
     real pintm1(plond,plevp) ! model interface pressures 
     real pmidm1(plond,plev) ! model level pressures 
     real pmlnm1(plond,plev) ! natural log of pmidm1 
     real ps(plond)   ! surface pressure 
     real qm1(plond,plev)  ! model level specific humidity 
     real snowh(plond)   ! snow depth (liquid water equivalent) 
     real tg(plond)   ! surface (skin) temperature 
     real tm1(plond,plev)  ! model level temperatures 
     real ts(plond)   ! surface air temperature 

c  Fields computed from user input 
     real coszrs(plond)  ! cosine solar zenith angle 
     real eccf     ! earth/sun distance factor 
     real effcld(plond,plevp) ! effective cloud=cld*emis 
     real emis(plond,plev)  ! cloud emissivity 
     real fice(plond,plev)  ! fractional amount of ice 
     real loctim(plond)  ! local time of solar computation 
     real lwup(plond)   ! Longwave up flux at surface 
     real rei(plond,plev)  ! ice particle size 
     real rel(plond,plev)  ! liquid effective drop size (microns) 
     real srfrad(plond)  ! srf radiative heat flux 

c  Fields output to PLASIM 
     real flswn(1,plevp) ! Net shortwave flux 
     real fllwn(1,plevp) ! Net longwave flux 
     real flswu(1,plevp) ! Shortwave flux up 
     real flswd(1,plevp) ! Shortwave flux down 
     real fllwu(1,plevp) ! Longwave flux up 
     real fllwd(1,plevp) ! Longwave flux down 
     real flnet(1,plevp) ! Net flux 

c  Output longwave arguments from radctl() 
     real flwds(plond)   ! Surface down longwave flux 
     real qrl(plond,plev)  ! Longwave cooling rate 

c  Output shortwave arguments from radctl() 
     real fsns(plond)   ! Surface absorbed solar flux 
     real qrs(plond,plev)  ! Solar heating rate 
     real soll(plond)   ! Downward solar rad onto surface (lw direct) 
     real solld(plond)   ! Downward solar rad onto surface (lw diffuse) 
     real sols(plond)   ! Downward solar rad onto surface (sw direct) 
     real solsd(plond)   ! Downward solar rad onto surface (sw diffuse) 

c  Additional CRM diagnostic output from radctl() 
     real flns(plond)   ! srf longwave cooling (up-dwn) flux 
     real flnsc(plond)   ! clr sky lw flx at srf (up-dwn) 
     real flnt(plond)   ! net outgoing lw flx at model top 
     real flntc(plond)   ! clr sky lw flx at model top 
     real fsnsc(plond)   ! clr sky surface abs solar flux 
     real fsds(plond)   ! [W m-2] Flux Shortwave Downwelling Surface 
     real fsnt(plond)   ! total column absorbed solar flux 
     real fsntc(plond)   ! clr sky total column abs solar flux 
     real solin(plond)   ! solar incident flux 
     real fsnirt(plond)  ! [W m-2] Near-IR flux absorbed at TOA 
     real fsnirtsq(plond)  ! [W m-2] Near-IR flux absorbed at TOA>= 0.7 microns 
     real fsnrtc(plond)  ! [W m-2] Clear sky near-IR flux absorbed at TOA 

c  Local workspace: These variables are not saved 
     real hbuf     ! history buffer 
     real pie     ! 3.14159... 
     integer i     ! longitude index 
     integer k     ! level index 
     integer lat    ! latitude row index 

c  Fundamental constants needed by radini() 
     real cpair    ! heat capacity dry air at constant prs (J/kg/K) 
     real epsilo    ! ratio mean mol weight h2o to dry air 
     real gravit    ! gravitational acceleration (m/s**2) 
     real stebol    ! Stefan-Boltzmann constant (W/m**2/K**4) 

c  Externals 
     external blkdat 

c  Main Code 

注意,這主要是別人的代碼 - 有可能是更好的方法的代碼可以寫,但主要目標就是讓它能夠編譯並與其他代碼一起玩。據我所知,子程序定義中的每個參數都是在子程序本身或#include'd文件中聲明的(implicit none在implicit.h中設置)。任何想法可能會導致這個錯誤?

編輯:解決(見評論)。錯誤是將子例程聲明放在一些包含像implicit none和公共塊之類的include語句之後。子程序聲明需要在這些之前。

+0

什麼是所包含的文件?那些包含使子程序聲明不允許出現在那個地方的東西是很有可能的。特別是如果「隱含無」是一回事,那麼就表明某種形式的程序單元已經出現。 – francescalus

+1

最好看一下[mcve]。 – francescalus

+0

是否有正式參數列表的右括號?原來如此。你是否使用了支持這種形式的'&'續行的編譯器? – wallyk

回答

0

正如評論和原創文章中指出,代碼的子程序需要聲明出現相對於包括語句,例如:

 subroutine snowpacrm(dcalday,ps,pmidm1,tm1,qm1,o3mmr,cld,clwp,pmlnm1,pintm1,pilnm1,   
    &      ts,tg,oro,snowh,gsol0,diyear_AD,loctim,pie,clat,clon,deccen,dobliq,  
    &      dmvelp,dobliqr,dlambm0,dmvelpp,o3vmr,asdir,asdif,aldir,aldif,dtauvis,  
    &      dco2vmr,dn2ovmr,dch4vmr,df11vmr,df12vmr,         
    &      flswn,fllwn,flswu,flswd,fllwu,fllwd,flnet) !outputs 



#include <implicit.h> 
c  Parameters 
#include <prgrid.h> 
c  Commons 
#include <comtim.h> /* calday */ 
#include <comvmr.h> /* co2vmr, n2ovmr, ch4vmr, f11vmr, f12vmr */ 
#include <comsol.h> /* scon, tauvis, eccen, obliq, mvelp, iyear_AD, obliqr, lambm0, mvelpp */ 
#include <comctl.h> /* anncyc,iradsw,iradlw,iradae */ 
#ifdef CRM_SRB 
#include <crmsrb.h> /* Surface radiation budget diagnostics */ 
#endif 
-2

對於續行,&應放在舊行行,而不是新行。

+1

這個問題有固定的形式來源。 – francescalus