mod_oasis_namcouple.F90 161 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982
  1. !> Reads the namcouple file for use in OASIS
  2. !> This code reads in the namcouple file and sets several variables
  3. !> that are available to the rest of OASIS. Some of this code
  4. !> is obsolete, and several input settings are deprecated.
  5. !> This code is based on the original Oasis3 version and
  6. !> will be rewritten at some point.
  7. MODULE mod_oasis_namcouple
  8. ! - - - - - - - - - - - - - - - - - - - - - - - - - - -
  9. USE mod_oasis_kinds
  10. USE mod_oasis_data
  11. USE mod_oasis_parameters
  12. USE mod_oasis_sys
  13. USE mod_oasis_mpi
  14. USE mod_oasis_string
  15. IMPLICIT NONE
  16. private
  17. public oasis_namcouple_init
  18. ! NAMCOUPLE PUBLIC DATA
  19. INTEGER (kind=ip_intwp_p),PARAMETER :: jpeighty = 5000 !< max number of characters to be read
  20. !< in each line of the file namcouple
  21. INTEGER(kind=ip_i4_p) ,public :: nnamcpl !< number of namcouple inputs
  22. INTEGER(kind=ip_i4_p) ,public :: namruntim !< namcouple runtime
  23. INTEGER(kind=ip_i4_p) ,public :: namlogprt !< namcouple nlogprt value
  24. INTEGER(kind=ip_i4_p) ,public :: namtlogprt !< namcouple ntlogprt value
  25. character(len=jpeighty) ,public,pointer :: namsrcfld(:) !< list of src fields
  26. character(len=jpeighty) ,public,pointer :: namdstfld(:) !< list of dst fields
  27. character(len=ic_lvar) ,public,pointer :: namsrcgrd(:) !< src grid name
  28. integer(kind=ip_i4_p) ,public,pointer :: namsrc_nx(:) !< src nx grid size
  29. integer(kind=ip_i4_p) ,public,pointer :: namsrc_ny(:) !< src ny grid size
  30. character(len=ic_lvar) ,public,pointer :: namdstgrd(:) !< dst grid name
  31. integer(kind=ip_i4_p) ,public,pointer :: namdst_nx(:) !< dst nx grid size
  32. integer(kind=ip_i4_p) ,public,pointer :: namdst_ny(:) !< dst ny grid size
  33. INTEGER(kind=ip_i4_p) ,public,pointer :: namfldseq(:) !< SEQ value
  34. INTEGER(kind=ip_i4_p) ,public,pointer :: namfldops(:) !< operation, ip_expout,...
  35. INTEGER(kind=ip_i4_p) ,public,pointer :: namflddti(:) !< coupling period (secs)
  36. INTEGER(kind=ip_i4_p) ,public,pointer :: namfldlag(:) !< coupling lag (secs)
  37. INTEGER(kind=ip_i4_p) ,public,pointer :: namfldtrn(:) !< fields transform, ip_instant,...
  38. integer(kind=ip_i4_p) ,public,pointer :: namfldcon(:) !< conserv fld operation
  39. character(len=ic_med) ,public,pointer :: namfldcoo(:) !< conserv fld option (bfb, opt)
  40. character(len=ic_long) ,public,pointer :: nammapfil(:) !< mapping file name
  41. character(len=ic_med) ,public,pointer :: nammaploc(:) !< mapping location (src or dst pes)
  42. character(len=ic_med) ,public,pointer :: nammapopt(:) !< mapping option (bfb, sum, or opt)
  43. character(len=ic_med) ,public,pointer :: namrstfil(:) !< restart file name
  44. character(len=ic_med) ,public,pointer :: naminpfil(:) !< input file name
  45. logical ,public,pointer :: namchecki(:) !< checkin flag
  46. logical ,public,pointer :: namchecko(:) !< checkout flag
  47. REAL (kind=ip_realwp_p) ,public,pointer :: namfldsmu(:) !< src multiplier term
  48. REAL (kind=ip_realwp_p) ,public,pointer :: namfldsad(:) !< src additive term
  49. REAL (kind=ip_realwp_p) ,public,pointer :: namflddmu(:) !< dst multipler term
  50. REAL (kind=ip_realwp_p) ,public,pointer :: namflddad(:) !< dst additive term
  51. character(len=ic_med) ,public,pointer :: namscrmet(:) !< scrip method (CONSERV, DISTWGT, BILINEAR, BICUBIC, GAUSWGT)
  52. character(len=ic_med) ,public,pointer :: namscrnor(:) !< scrip conserv normalization (FRACAREA, DESTAREA, FRACNNEI)
  53. character(len=ic_med) ,public,pointer :: namscrtyp(:) !< scrip mapping type (SCALAR, VECTOR)
  54. character(len=ic_med) ,public,pointer :: namscrord(:) !< scrip conserve order (FIRST, SECOND)
  55. character(len=ic_med) ,public,pointer :: namscrres(:) !< scrip search restriction (LATLON, LATITUDE)
  56. REAL (kind=ip_realwp_p) ,public,pointer :: namscrvam(:) !< scrip gauss weight distance weighting for GAUSWGT
  57. integer(kind=ip_i4_p) ,public,pointer :: namscrnbr(:) !< scrip number of neighbors for GAUSWGT and DISTWGT
  58. integer(kind=ip_i4_p) ,public,pointer :: namscrbin(:) !< script number of search bins
  59. !--- derived ---
  60. INTEGER(kind=ip_i4_p) ,public,pointer :: namsort2nn(:) !< sorted namcpl for sort, define nn order, computed later
  61. INTEGER(kind=ip_i4_p) ,public,pointer :: namnn2sort(:) !< sorted namcpl for nn, define sort number, computed later
  62. !----------------------------------------------------------------
  63. ! LOCAL ONLY BELOW HERE
  64. !----------------------------------------------------------------
  65. integer(kind=ip_i4_p) :: nulin ! namcouple IO unit number
  66. character(len=*),parameter :: cl_namcouple = 'namcouple'
  67. ! --- alloc_src
  68. INTEGER (kind=ip_intwp_p) :: il_err
  69. ! --- mod_unitncdf
  70. LOGICAL :: lncdfgrd
  71. LOGICAL :: lncdfrst
  72. ! --- mod_label
  73. CHARACTER(len=5), PARAMETER :: cgrdnam = 'grids'
  74. CHARACTER(len=5), PARAMETER :: cmsknam = 'masks'
  75. CHARACTER(len=5), PARAMETER :: csurnam = 'areas'
  76. CHARACTER(len=5), PARAMETER :: crednam = 'maskr'
  77. CHARACTER(len=4), PARAMETER :: cglonsuf = '.lon'
  78. CHARACTER(len=4), PARAMETER :: cglatsuf = '.lat'
  79. CHARACTER(len=4), PARAMETER :: crnlonsuf = '.clo'
  80. CHARACTER(len=4), PARAMETER :: crnlatsuf = '.cla'
  81. CHARACTER(len=4), PARAMETER :: cmsksuf = '.msk'
  82. CHARACTER(len=4), PARAMETER :: csursuf = '.srf'
  83. CHARACTER(len=4), PARAMETER :: cangsuf = '.ang'
  84. ! --- mod_rainbow
  85. LOGICAL,DIMENSION(:),ALLOCATABLE :: lmapp
  86. LOGICAL,DIMENSION(:),ALLOCATABLE :: lsubg
  87. ! --- mod_coast
  88. INTEGER (kind=ip_intwp_p) :: nfcoast
  89. LOGICAL :: lcoast
  90. ! --- mod_timestep
  91. INTEGER (kind=ip_intwp_p) :: ntime
  92. INTEGER (kind=ip_intwp_p) :: niter
  93. INTEGER (kind=ip_intwp_p) :: nitfn
  94. INTEGER (kind=ip_intwp_p) :: nstep
  95. ! --- mod_parameter
  96. INTEGER (kind=ip_intwp_p) :: ig_nfield ! number of oasis coupled fields
  97. INTEGER (kind=ip_intwp_p) :: ig_direct_nfield ! number of direct coupled fields
  98. INTEGER (kind=ip_intwp_p) :: ig_total_nfield ! estimate of total fields
  99. INTEGER (kind=ip_intwp_p) :: ig_final_nfield ! number of final fields
  100. LOGICAL :: lg_oasis_field
  101. INTEGER (kind=ip_intwp_p) :: ig_maxcomb
  102. INTEGER (kind=ip_intwp_p) :: ig_maxnoa
  103. INTEGER (kind=ip_intwp_p) :: ig_maxnfg
  104. ! --- mod_printing
  105. INTEGER(kind=ip_intwp_p) :: nlogprt
  106. !---- Time statistics level printing
  107. INTEGER(kind=ip_intwp_p) :: ntlogprt
  108. ! --- mod_string
  109. INTEGER (kind=ip_intwp_p),DIMENSION(:),ALLOCATABLE :: numlab
  110. INTEGER (kind=ip_intwp_p),DIMENSION(:),ALLOCATABLE :: ig_numlab
  111. INTEGER (kind=ip_intwp_p),DIMENSION(:),ALLOCATABLE :: nfexch
  112. INTEGER (kind=ip_intwp_p),DIMENSION(:),ALLOCATABLE :: ig_ntrans
  113. INTEGER (kind=ip_intwp_p),DIMENSION(:),ALLOCATABLE :: ig_total_ntrans
  114. INTEGER (kind=ip_intwp_p),DIMENSION(:),ALLOCATABLE :: nlonbf
  115. INTEGER (kind=ip_intwp_p),DIMENSION(:),ALLOCATABLE :: nlatbf
  116. INTEGER (kind=ip_intwp_p),DIMENSION(:),ALLOCATABLE :: nlonaf
  117. INTEGER (kind=ip_intwp_p),DIMENSION(:),ALLOCATABLE :: nlataf
  118. INTEGER (kind=ip_intwp_p),DIMENSION(:),ALLOCATABLE :: nseqn
  119. INTEGER (kind=ip_intwp_p),DIMENSION(:),ALLOCATABLE :: ig_total_nseqn
  120. INTEGER (kind=ip_intwp_p),DIMENSION(:),ALLOCATABLE :: ig_freq
  121. INTEGER (kind=ip_intwp_p),DIMENSION(:),ALLOCATABLE :: ig_lag
  122. INTEGER (kind=ip_intwp_p),DIMENSION(:),ALLOCATABLE :: nlagn
  123. INTEGER (kind=ip_intwp_p),DIMENSION(:),ALLOCATABLE :: ig_invert
  124. INTEGER (kind=ip_intwp_p),DIMENSION(:),ALLOCATABLE :: ig_reverse
  125. INTEGER (kind=ip_intwp_p),DIMENSION(:),ALLOCATABLE :: ig_number_field
  126. INTEGER (kind=ip_intwp_p),DIMENSION(:),ALLOCATABLE :: ig_no_rstfile
  127. INTEGER (kind=ip_intwp_p),DIMENSION(:),ALLOCATABLE :: ig_total_state
  128. INTEGER (kind=ip_intwp_p),DIMENSION(:),ALLOCATABLE :: ig_local_trans
  129. INTEGER (kind=ip_intwp_p),DIMENSION(:),ALLOCATABLE :: ig_grid_nbrbf
  130. INTEGER (kind=ip_intwp_p),DIMENSION(:),ALLOCATABLE :: ig_grid_nbraf
  131. INTEGER (kind=ip_intwp_p) :: ig_nbr_rstfile
  132. INTEGER (kind=ip_intwp_p) :: ig_total_frqmin
  133. LOGICAL ,DIMENSION(:),ALLOCATABLE :: lg_state
  134. CHARACTER(len=jpeighty) ,DIMENSION(:),ALLOCATABLE :: cnaminp
  135. CHARACTER(len=jpeighty) ,DIMENSION(:),ALLOCATABLE :: cnamout
  136. CHARACTER(len=8) ,DIMENSION(:,:),ALLOCATABLE :: canal
  137. CHARACTER(len=8) :: cg_c
  138. CHARACTER(len=32) ,DIMENSION(:),ALLOCATABLE :: cg_name_rstfile
  139. CHARACTER(len=32) ,DIMENSION(:),ALLOCATABLE :: cg_restart_file
  140. CHARACTER(len=32) ,DIMENSION(:),ALLOCATABLE :: cficinp
  141. CHARACTER(len=8) ,DIMENSION(:),ALLOCATABLE :: cficout
  142. CHARACTER(len=32) ,DIMENSION(:),ALLOCATABLE :: cg_input_file
  143. CHARACTER(len=jpeighty) ,DIMENSION(:),ALLOCATABLE :: cg_input_field
  144. CHARACTER(len=jpeighty) ,DIMENSION(:),ALLOCATABLE :: cg_output_field
  145. CHARACTER(len=8) ,DIMENSION(:),ALLOCATABLE :: cficbf
  146. CHARACTER(len=8) ,DIMENSION(:),ALLOCATABLE :: cficaf
  147. CHARACTER(len=8) ,DIMENSION(:),ALLOCATABLE :: cstate
  148. CHARACTER(len=4) ,DIMENSION(:),ALLOCATABLE :: cga_locatorbf
  149. CHARACTER(len=4) ,DIMENSION(:),ALLOCATABLE :: cga_locatoraf
  150. ! --- mod_analysis
  151. INTEGER (kind=ip_intwp_p), DIMENSION(:), ALLOCATABLE :: neighbor
  152. INTEGER (kind=ip_intwp_p), DIMENSION(:), ALLOCATABLE :: ntronca
  153. INTEGER (kind=ip_intwp_p), DIMENSION(:), ALLOCATABLE :: ncofld
  154. INTEGER (kind=ip_intwp_p), DIMENSION(:), ALLOCATABLE :: neighborg
  155. INTEGER (kind=ip_intwp_p), DIMENSION(:), ALLOCATABLE :: nbofld
  156. INTEGER (kind=ip_intwp_p), DIMENSION(:), ALLOCATABLE :: nbnfld
  157. INTEGER (kind=ip_intwp_p), DIMENSION(:,:), ALLOCATABLE :: nludat
  158. INTEGER (kind=ip_intwp_p), DIMENSION(:), ALLOCATABLE :: nlufil
  159. INTEGER (kind=ip_intwp_p), DIMENSION(:), ALLOCATABLE :: nlumap
  160. INTEGER (kind=ip_intwp_p), DIMENSION(:), ALLOCATABLE :: nmapfl
  161. INTEGER (kind=ip_intwp_p), DIMENSION(:), ALLOCATABLE :: nmapvoi
  162. INTEGER (kind=ip_intwp_p), DIMENSION(:), ALLOCATABLE :: nlusub
  163. INTEGER (kind=ip_intwp_p), DIMENSION(:), ALLOCATABLE :: nsubfl
  164. INTEGER (kind=ip_intwp_p), DIMENSION(:), ALLOCATABLE :: nsubvoi
  165. INTEGER (kind=ip_intwp_p), DIMENSION(:), ALLOCATABLE :: nluext
  166. INTEGER (kind=ip_intwp_p), DIMENSION(:), ALLOCATABLE :: nextfl
  167. INTEGER (kind=ip_intwp_p), DIMENSION(:), ALLOCATABLE :: nosper
  168. INTEGER (kind=ip_intwp_p), DIMENSION(:), ALLOCATABLE :: notper
  169. INTEGER (kind=ip_intwp_p), DIMENSION(:), ALLOCATABLE :: nbins
  170. INTEGER (kind=ip_intwp_p) :: nlucor
  171. INTEGER (kind=ip_intwp_p), DIMENSION(:), ALLOCATABLE :: nscripvoi
  172. REAL (kind=ip_realwp_p), DIMENSION(:), ALLOCATABLE :: amskval
  173. REAL (kind=ip_realwp_p), DIMENSION(:), ALLOCATABLE :: amskvalnew
  174. REAL (kind=ip_realwp_p), DIMENSION(:,:), ALLOCATABLE :: acocoef
  175. REAL (kind=ip_realwp_p), DIMENSION(:,:), ALLOCATABLE :: abocoef
  176. REAL (kind=ip_realwp_p), DIMENSION(:,:), ALLOCATABLE :: abncoef
  177. REAL (kind=ip_realwp_p), DIMENSION(:), ALLOCATABLE :: afldcoef
  178. REAL (kind=ip_realwp_p), DIMENSION(:), ALLOCATABLE :: afldcobo
  179. REAL (kind=ip_realwp_p), DIMENSION(:), ALLOCATABLE :: afldcobn
  180. CHARACTER(len=8), DIMENSION(:),ALLOCATABLE :: cxordbf
  181. CHARACTER(len=8), DIMENSION(:),ALLOCATABLE :: cyordbf
  182. CHARACTER(len=8), DIMENSION(:),ALLOCATABLE :: cxordaf
  183. CHARACTER(len=8), DIMENSION(:),ALLOCATABLE :: cyordaf
  184. CHARACTER(len=8), DIMENSION(:),ALLOCATABLE :: cextmet
  185. CHARACTER(len=8), DIMENSION(:),ALLOCATABLE :: cintmet
  186. CHARACTER(len=8), DIMENSION(:),ALLOCATABLE :: cgrdtyp
  187. CHARACTER(len=8), DIMENSION(:),ALLOCATABLE :: cfldtyp
  188. CHARACTER(len=8), DIMENSION(:),ALLOCATABLE :: cfilfic
  189. CHARACTER(len=8), DIMENSION(:),ALLOCATABLE :: cfilmet
  190. CHARACTER(len=8), DIMENSION(:),ALLOCATABLE :: cconmet
  191. CHARACTER(len=8), DIMENSION(:),ALLOCATABLE :: cconopt
  192. CHARACTER(len=8), DIMENSION(:),ALLOCATABLE :: cfldcoa
  193. CHARACTER(len=8), DIMENSION(:),ALLOCATABLE :: cfldfin
  194. CHARACTER(len=8), DIMENSION(:,:),ALLOCATABLE :: ccofld
  195. CHARACTER(len=8), DIMENSION(:,:),ALLOCATABLE :: cbofld
  196. CHARACTER(len=8), DIMENSION(:,:),ALLOCATABLE :: cbnfld
  197. CHARACTER(len=8), DIMENSION(:,:),ALLOCATABLE :: ccofic
  198. CHARACTER(len=8), DIMENSION(:),ALLOCATABLE :: cdqdt
  199. CHARACTER(len=8), DIMENSION(:),ALLOCATABLE :: cgrdmap
  200. CHARACTER(len=8), DIMENSION(:),ALLOCATABLE :: cmskrd
  201. CHARACTER(len=8), DIMENSION(:),ALLOCATABLE :: cgrdsub
  202. CHARACTER(len=8), DIMENSION(:),ALLOCATABLE :: ctypsub
  203. CHARACTER(len=8), DIMENSION(:),ALLOCATABLE :: cgrdext
  204. CHARACTER(len=8), DIMENSION(:),ALLOCATABLE :: csper
  205. CHARACTER(len=8), DIMENSION(:),ALLOCATABLE :: ctper
  206. CHARACTER(len=8), DIMENSION(:),ALLOCATABLE :: cmap_method
  207. CHARACTER(len=ic_long), DIMENSION(:),ALLOCATABLE :: cmap_file
  208. CHARACTER(len=8), DIMENSION(:),ALLOCATABLE :: cmaptyp
  209. CHARACTER(len=8), DIMENSION(:),ALLOCATABLE :: cmapopt
  210. CHARACTER(len=8), DIMENSION(:),ALLOCATABLE :: corder
  211. CHARACTER(len=8), DIMENSION(:),ALLOCATABLE :: cnorm_opt
  212. CHARACTER(len=8), DIMENSION(:),ALLOCATABLE :: cfldtype
  213. CHARACTER(len=8), DIMENSION(:),ALLOCATABLE :: crsttype
  214. CHARACTER(len=8) :: cfldcor
  215. LOGICAL, DIMENSION(:),ALLOCATABLE :: lsurf
  216. ! --- mod_anais
  217. INTEGER (kind=ip_intwp_p), DIMENSION(:), ALLOCATABLE :: naismfl
  218. INTEGER (kind=ip_intwp_p), DIMENSION(:), ALLOCATABLE :: naisgfl
  219. INTEGER (kind=ip_intwp_p), DIMENSION(:), ALLOCATABLE :: naismvoi
  220. INTEGER (kind=ip_intwp_p), DIMENSION(:), ALLOCATABLE :: naisgvoi
  221. INTEGER (kind=ip_intwp_p), DIMENSION(:), ALLOCATABLE :: niwtm
  222. INTEGER (kind=ip_intwp_p), DIMENSION(:), ALLOCATABLE :: niwtg
  223. REAL (kind=ip_realwp_p), DIMENSION(:), ALLOCATABLE :: varmul
  224. LOGICAL, DIMENSION(:), ALLOCATABLE :: linit
  225. ! --- mod extrapol
  226. INTEGER (kind=ip_intwp_p), DIMENSION(:), ALLOCATABLE :: niwtn
  227. INTEGER (kind=ip_intwp_p), DIMENSION(:), ALLOCATABLE :: nninnfl
  228. INTEGER (kind=ip_intwp_p), DIMENSION(:), ALLOCATABLE :: niwtng
  229. INTEGER (kind=ip_intwp_p), DIMENSION(:), ALLOCATABLE :: nninnflg
  230. LOGICAL, DIMENSION(:), ALLOCATABLE :: lextra
  231. LOGICAL, DIMENSION(:), ALLOCATABLE :: lweight
  232. !---------------------
  233. !------------------------------------------------------------
  234. CONTAINS
  235. !------------------------------------------------------------
  236. !> Reads the namcouple
  237. SUBROUTINE oasis_namcouple_init()
  238. IMPLICIT NONE
  239. !-----------------------------------------------------------
  240. integer(kind=ip_i4_p) :: n, nv, n1, n2, loc
  241. integer(kind=ip_i4_p) :: ja, jf, jc
  242. integer(kind=ip_i4_p) :: il_iost
  243. integer(kind=ip_i4_p) :: maxunit
  244. character(len=*),parameter :: subname='(oasis_namcouple_init)'
  245. !-----------------------------------------------------------
  246. CALL oasis_unitget(nulin)
  247. OPEN (UNIT = nulin,FILE =cl_namcouple,STATUS='OLD', &
  248. FORM ='FORMATTED', IOSTAT = il_iost)
  249. IF (mpi_rank_global == 0) THEN
  250. IF (il_iost .NE. 0) THEN
  251. WRITE(nulprt1,*) subname,' ERROR opening namcouple file ',TRIM(cl_namcouple),&
  252. ' with unit number ', nulin
  253. WRITE (nulprt,'(a,i4)') ' abort by model ',compid
  254. WRITE (nulprt,'(a)') ' error = ERROR opening namcouple file'
  255. CALL oasis_abort()
  256. ELSE
  257. WRITE(nulprt1,*) subname,' open namcouple file ',TRIM(cl_namcouple),' with unit number ', &
  258. nulin
  259. ENDIF
  260. ENDIF
  261. call inipar_alloc()
  262. call alloc()
  263. call inipar()
  264. !
  265. ! Close namcouple unit
  266. close(nulin)
  267. CALL oasis_unitfree(nulin)
  268. IF (mpi_rank_global == 0) THEN
  269. WRITE(nulprt1,*) subname,' allocating ig_final_nfield',ig_final_nfield
  270. CALL oasis_flush(nulprt1)
  271. ENDIF
  272. allocate(namsrcfld(ig_final_nfield), stat=il_err)
  273. IF (il_err.NE.0) CALL prtout('Error in "namsrcfld" allocation of experiment module',il_err,1)
  274. allocate(namdstfld(ig_final_nfield), stat=il_err)
  275. IF (il_err.NE.0) CALL prtout('Error in "namdstfld" allocation of experiment module',il_err,1)
  276. allocate(namsrcgrd(ig_final_nfield), stat=il_err)
  277. IF (il_err.NE.0) CALL prtout('Error in "namsrcgrd" allocation of experiment module',il_err,1)
  278. allocate(namsrc_nx(ig_final_nfield), stat=il_err)
  279. IF (il_err.NE.0) CALL prtout('Error in "namsrc_nx" allocation of experiment module',il_err,1)
  280. allocate(namsrc_ny(ig_final_nfield), stat=il_err)
  281. IF (il_err.NE.0) CALL prtout('Error in "namsrc_ny" allocation of experiment module',il_err,1)
  282. allocate(namdstgrd(ig_final_nfield), stat=il_err)
  283. IF (il_err.NE.0) CALL prtout('Error in "namdstgrd" allocation of experiment module',il_err,1)
  284. allocate(namdst_nx(ig_final_nfield), stat=il_err)
  285. IF (il_err.NE.0) CALL prtout('Error in "namdst_nx" allocation of experiment module',il_err,1)
  286. allocate(namdst_ny(ig_final_nfield), stat=il_err)
  287. IF (il_err.NE.0) CALL prtout('Error in "namdst_ny" allocation of experiment module',il_err,1)
  288. allocate(namfldseq(ig_final_nfield), stat=il_err)
  289. IF (il_err.NE.0) CALL prtout('Error in "namfldseq" allocation of experiment module',il_err,1)
  290. allocate(namfldops(ig_final_nfield), stat=il_err)
  291. IF (il_err.NE.0) CALL prtout('Error in "namfldops" allocation of experiment module',il_err,1)
  292. allocate(namfldtrn(ig_final_nfield), stat=il_err)
  293. IF (il_err.NE.0) CALL prtout('Error in "namfldtrn" allocation of experiment module',il_err,1)
  294. allocate(namfldcon(ig_final_nfield), stat=il_err)
  295. IF (il_err.NE.0) CALL prtout('Error in "namfldcon" allocation of experiment module',il_err,1)
  296. allocate(namfldcoo(ig_final_nfield), stat=il_err)
  297. IF (il_err.NE.0) CALL prtout('Error in "namfldcoo" allocation of experiment module',il_err,1)
  298. allocate(namflddti(ig_final_nfield), stat=il_err)
  299. IF (il_err.NE.0) CALL prtout('Error in "namflddti" allocation of experiment module',il_err,1)
  300. allocate(namfldlag(ig_final_nfield), stat=il_err)
  301. IF (il_err.NE.0) CALL prtout('Error in "namfldlag" allocation of experiment module',il_err,1)
  302. allocate(nammapfil(ig_final_nfield), stat=il_err)
  303. IF (il_err.NE.0) CALL prtout('Error in "nammapfil" allocation of experiment module',il_err,1)
  304. allocate(nammaploc(ig_final_nfield), stat=il_err)
  305. IF (il_err.NE.0) CALL prtout('Error in "nammaploc" allocation of experiment module',il_err,1)
  306. allocate(nammapopt(ig_final_nfield), stat=il_err)
  307. IF (il_err.NE.0) CALL prtout('Error in "nammapopt" allocation of experiment module',il_err,1)
  308. allocate(namrstfil(ig_final_nfield), stat=il_err)
  309. IF (il_err.NE.0) CALL prtout('Error in "namrstfil" allocation of experiment module',il_err,1)
  310. allocate(naminpfil(ig_final_nfield), stat=il_err)
  311. IF (il_err.NE.0) CALL prtout('Error in "naminpfil" allocation of experiment module',il_err,1)
  312. allocate(namsort2nn(ig_final_nfield), stat=il_err)
  313. IF (il_err.NE.0) CALL prtout('Error in "namsort2nn" allocation of experiment module',il_err,1)
  314. allocate(namnn2sort(ig_final_nfield), stat=il_err)
  315. IF (il_err.NE.0) CALL prtout('Error in "namnn2sort" allocation of experiment module',il_err,1)
  316. allocate(namchecki(ig_final_nfield), stat=il_err)
  317. IF (il_err.NE.0) CALL prtout('Error in "namchecki" allocation of experiment module',il_err,1)
  318. allocate(namchecko(ig_final_nfield), stat=il_err)
  319. IF (il_err.NE.0) CALL prtout('Error in "namchecko" allocation of experiment module',il_err,1)
  320. allocate(namfldsmu(ig_final_nfield), stat=il_err)
  321. IF (il_err.NE.0) CALL prtout('Error in "namfldsmu" allocation of experiment module',il_err,1)
  322. allocate(namfldsad(ig_final_nfield), stat=il_err)
  323. IF (il_err.NE.0) CALL prtout('Error in "namfldsad" allocation of experiment module',il_err,1)
  324. allocate(namflddmu(ig_final_nfield), stat=il_err)
  325. IF (il_err.NE.0) CALL prtout('Error in "namflddmu" allocation of experiment module',il_err,1)
  326. allocate(namflddad(ig_final_nfield), stat=il_err)
  327. IF (il_err.NE.0) CALL prtout('Error in "namflddad" allocation of experiment module',il_err,1)
  328. allocate(namscrmet(ig_final_nfield), stat=il_err)
  329. IF (il_err.NE.0) CALL prtout('Error in "namscrmet" allocation of experiment module',il_err,1)
  330. allocate(namscrnor(ig_final_nfield), stat=il_err)
  331. IF (il_err.NE.0) CALL prtout('Error in "namscrnor" allocation of experiment module',il_err,1)
  332. allocate(namscrtyp(ig_final_nfield), stat=il_err)
  333. IF (il_err.NE.0) CALL prtout('Error in "namscrtyp" allocation of experiment module',il_err,1)
  334. allocate(namscrord(ig_final_nfield), stat=il_err)
  335. IF (il_err.NE.0) CALL prtout('Error in "namscrord" allocation of experiment module',il_err,1)
  336. allocate(namscrres(ig_final_nfield), stat=il_err)
  337. IF (il_err.NE.0) CALL prtout('Error in "namscrres" allocation of experiment module',il_err,1)
  338. allocate(namscrvam(ig_final_nfield), stat=il_err)
  339. IF (il_err.NE.0) CALL prtout('Error in "namscrvam" allocation of experiment module',il_err,1)
  340. allocate(namscrnbr(ig_final_nfield), stat=il_err)
  341. IF (il_err.NE.0) CALL prtout('Error in "namscrnbr" allocation of experiment module',il_err,1)
  342. allocate(namscrbin(ig_final_nfield), stat=il_err)
  343. IF (il_err.NE.0) CALL prtout('Error in "namscrbin" allocation of experiment module',il_err,1)
  344. namsrcfld(:) = trim(cspval)
  345. namdstfld(:) = trim(cspval)
  346. namsrcgrd(:) = trim(cspval)
  347. namsrc_nx(:) = 0
  348. namsrc_ny(:) = 0
  349. namdstgrd(:) = trim(cspval)
  350. namdst_nx(:) = 0
  351. namdst_ny(:) = 0
  352. namfldseq(:) = -1
  353. namfldops(:) = -1
  354. namfldtrn(:) = ip_instant
  355. namfldcon(:) = ip_cnone
  356. namfldcoo(:) = "bfb"
  357. namflddti(:) = -1
  358. namfldlag(:) = 0
  359. nammapfil(:) = "idmap"
  360. nammaploc(:) = "src"
  361. nammapopt(:) = "bfb"
  362. namrstfil(:) = trim(cspval)
  363. naminpfil(:) = trim(cspval)
  364. namchecki(:) = .false.
  365. namchecko(:) = .false.
  366. namfldsmu(:) = 1.0_ip_realwp_p
  367. namfldsad(:) = 0.0_ip_realwp_p
  368. namflddmu(:) = 1.0_ip_realwp_p
  369. namflddad(:) = 0.0_ip_realwp_p
  370. namscrmet(:) = trim(cspval)
  371. namscrnor(:) = trim(cspval)
  372. namscrtyp(:) = trim(cspval)
  373. namscrord(:) = trim(cspval)
  374. namscrres(:) = trim(cspval)
  375. namscrvam(:) = 1.0_ip_realwp_p
  376. namscrnbr(:) = -1
  377. namscrbin(:) = -1
  378. ! maxunit = max(maxval(iga_unitmod),1024)
  379. maxunit = 1024
  380. IF (mpi_rank_global == 0) THEN
  381. WRITE(nulprt1,*) subname,' maximum unit number = ',maxunit
  382. CALL oasis_flush(nulprt1)
  383. ENDIF
  384. call oasis_unitsetmin(maxunit)
  385. nnamcpl = ig_final_nfield
  386. namruntim = ntime
  387. namlogprt = nlogprt
  388. namtlogprt = ntlogprt
  389. do jf = 1,ig_final_nfield
  390. namsrcfld(jf) = cg_input_field(jf)
  391. namdstfld(jf) = cg_output_field(jf)
  392. namfldseq(jf) = ig_total_nseqn(jf)
  393. namfldops(jf) = ig_total_state(jf)
  394. if (namfldops(jf) == ip_auxilary) then
  395. IF (mpi_rank_global == 0) THEN
  396. WRITE(nulprt1,*) subname,jf,'ERROR: AUXILARY NOT SUPPORTED'
  397. WRITE (nulprt1,'(a)') ' error = STOP in oasis_namcouple_init'
  398. CALL oasis_flush(nulprt1)
  399. ENDIF
  400. call oasis_abort()
  401. endif
  402. if (namfldops(jf) == ip_ignored) then
  403. namfldops(jf) = ip_exported
  404. IF (mpi_rank_global == 0) THEN
  405. WRITE(nulprt1,*) subname,jf,'WARNING: IGNORED converted to EXPORTED'
  406. CALL oasis_flush(nulprt1)
  407. ENDIF
  408. endif
  409. if (namfldops(jf) == ip_ignout) then
  410. namfldops(jf) = ip_expout
  411. IF (mpi_rank_global == 0) THEN
  412. WRITE(nulprt1,*) subname,jf,'WARNING: IGNOUT converted to EXPOUT'
  413. CALL oasis_flush(nulprt1)
  414. ENDIF
  415. endif
  416. namflddti(jf) = ig_freq(jf)
  417. namfldlag(jf) = ig_lag(jf)
  418. namfldtrn(jf) = ig_local_trans(jf)
  419. namrstfil(jf) = trim(cg_restart_file(jf))
  420. naminpfil(jf) = trim(cg_input_file(jf))
  421. if (ig_number_field(jf) > 0) then
  422. namsrcgrd(jf) = trim(cficbf(ig_number_field(jf)))
  423. namsrc_nx(jf) = nlonbf(ig_number_field(jf))
  424. namsrc_ny(jf) = nlatbf(ig_number_field(jf))
  425. namdstgrd(jf) = trim(cficaf(ig_number_field(jf)))
  426. namdst_nx(jf) = nlonaf(ig_number_field(jf))
  427. namdst_ny(jf) = nlataf(ig_number_field(jf))
  428. do ja = 1, ig_ntrans(ig_number_field(jf))
  429. if (canal(ja,ig_number_field(jf)) .EQ. 'SCRIPR') then
  430. namscrmet(jf) = trim(cmap_method(ig_number_field(jf)))
  431. namscrnor(jf) = trim(cnorm_opt (ig_number_field(jf)))
  432. namscrtyp(jf) = trim(cfldtype (ig_number_field(jf)))
  433. namscrord(jf) = trim(corder (ig_number_field(jf)))
  434. namscrres(jf) = trim(crsttype (ig_number_field(jf)))
  435. namscrvam(jf) = varmul (ig_number_field(jf))
  436. namscrnbr(jf) = nscripvoi (ig_number_field(jf))
  437. namscrbin(jf) = nbins (ig_number_field(jf))
  438. IF (TRIM(namscrtyp(jf)) /= 'SCALAR') THEN
  439. IF (mpi_rank_global == 0) THEN
  440. WRITE(nulprt1,*) subname,jf,'WARNING: SCRIPR weights generation &
  441. & supported only for SCALAR mapping, not '//TRIM(namscrtyp(jf))
  442. WRITE (nulprt1,'(a,i4)') ' abort by model ',compid
  443. WRITE (nulprt1,'(a)') ' error = ERROR in SCRIPR CFTYP option'
  444. CALL oasis_flush(nulprt1)
  445. ENDIF
  446. CALL oasis_abort()
  447. ENDIF
  448. elseif (canal(ja,ig_number_field(jf)) .EQ. 'MAPPING') then
  449. nammapfil(jf) = trim(cmap_file(ig_number_field(jf)))
  450. nammaploc(jf) = trim(cmaptyp(ig_number_field(jf)))
  451. nammapopt(jf) = trim(cmapopt(ig_number_field(jf)))
  452. elseif (canal(ja,ig_number_field(jf)) .EQ. 'CONSERV') then
  453. namfldcon(jf) = ip_cnone
  454. namfldcoo(jf) = trim(cconopt(ig_number_field(jf)))
  455. if (cconmet(ig_number_field(jf)) .EQ. 'GLOBAL') namfldcon(jf) = ip_cglobal
  456. if (cconmet(ig_number_field(jf)) .EQ. 'GLBPOS') namfldcon(jf) = ip_cglbpos
  457. if (cconmet(ig_number_field(jf)) .EQ. 'BASBAL') namfldcon(jf) = ip_cbasbal
  458. if (cconmet(ig_number_field(jf)) .EQ. 'BASPOS') namfldcon(jf) = ip_cbaspos
  459. if (namfldcon(jf) .EQ. ip_cnone) then
  460. IF (mpi_rank_global == 0) THEN
  461. WRITE(nulprt1,*) subname,jf,'WARNING: CONSERV option not supported: '//&
  462. &TRIM(cconmet(ig_number_field(jf)))
  463. WRITE (nulprt1,'(a,i4)') ' abort by model ',compid
  464. WRITE (nulprt1,'(a)') ' error = ERROR in CONSERV option'
  465. CALL oasis_flush(nulprt1)
  466. ENDIF
  467. CALL oasis_abort()
  468. endif
  469. elseif (canal(ja,ig_number_field(jf)) .EQ. 'CHECKIN' ) then
  470. namchecki(jf) = .true.
  471. elseif (canal(ja,ig_number_field(jf)) .EQ. 'CHECKOUT') then
  472. namchecko(jf) = .true.
  473. elseif (canal(ja,ig_number_field(jf)) .EQ. 'BLASOLD') then
  474. namfldsmu(jf) = afldcobo(ig_number_field(jf))
  475. do jc = 1, nbofld(ig_number_field(jf))
  476. if (trim(cbofld(jc,ig_number_field(jf))) == 'CONSTANT') then
  477. namfldsad(jf) = abocoef(jc,ig_number_field(jf))
  478. else
  479. IF (mpi_rank_global == 0) THEN
  480. WRITE(nulprt1,*) subname,jf,'ERROR: BLASOLD only supports CONSTANT: '//&
  481. &TRIM(cbofld(jc,ig_number_field(jf)))
  482. WRITE (nulprt1,'(a,i4)') ' abort by model ',compid
  483. WRITE (nulprt1,'(a)') ' error = ERROR in BLASOLD option'
  484. CALL oasis_flush(nulprt1)
  485. ENDIF
  486. call oasis_abort()
  487. endif
  488. enddo
  489. elseif (canal(ja,ig_number_field(jf)) .EQ. 'BLASNEW') then
  490. namflddmu(jf) = afldcobn(ig_number_field(jf))
  491. do jc = 1, nbnfld(ig_number_field(jf))
  492. if (trim(cbnfld(jc,ig_number_field(jf))) == 'CONSTANT') then
  493. namflddad(jf) = abncoef(jc,ig_number_field(jf))
  494. else
  495. IF (mpi_rank_global == 0) THEN
  496. WRITE(nulprt1,*) subname,jf,'ERROR: BLASNEW only supports CONSTANTS: '//&
  497. &TRIM(cbofld(jc,ig_number_field(jf)))
  498. WRITE (nulprt1,'(a,i4)') ' abort by model ',compid
  499. WRITE (nulprt1,'(a)') ' error = ERROR in BLASNEW option'
  500. CALL oasis_flush(nulprt1)
  501. ENDIF
  502. call oasis_abort()
  503. endif
  504. enddo
  505. endif ! canal
  506. enddo ! ig_ntrans
  507. endif ! ig_number_field
  508. enddo ! ig_final_nfield
  509. IF (mpi_rank_global == 0) THEN
  510. WRITE(nulprt1,*) ' '
  511. WRITE(nulprt1,*) subname,'namlogprt ',namlogprt
  512. WRITE(nulprt1,*) ' '
  513. DO n = 1,nnamcpl
  514. WRITE(nulprt1,*) subname,n,'namsrcfld ',TRIM(namsrcfld(n))
  515. WRITE(nulprt1,*) subname,n,'namdstfld ',TRIM(namdstfld(n))
  516. WRITE(nulprt1,*) subname,n,'namsrcgrd ',TRIM(namsrcgrd(n))
  517. WRITE(nulprt1,*) subname,n,'namsrc_nx ',namsrc_nx(n)
  518. WRITE(nulprt1,*) subname,n,'namsrc_ny ',namsrc_ny(n)
  519. WRITE(nulprt1,*) subname,n,'namdstgrd ',TRIM(namdstgrd(n))
  520. WRITE(nulprt1,*) subname,n,'namdst_nx ',namdst_nx(n)
  521. WRITE(nulprt1,*) subname,n,'namdst_ny ',namdst_ny(n)
  522. WRITE(nulprt1,*) subname,n,'namfldseq ',namfldseq(n)
  523. WRITE(nulprt1,*) subname,n,'namfldops ',namfldops(n)
  524. WRITE(nulprt1,*) subname,n,'namfldtrn ',namfldtrn(n)
  525. WRITE(nulprt1,*) subname,n,'namfldcon ',namfldcon(n)
  526. WRITE(nulprt1,*) subname,n,'namfldcoo ',TRIM(namfldcoo(n))
  527. WRITE(nulprt1,*) subname,n,'namflddti ',namflddti(n)
  528. WRITE(nulprt1,*) subname,n,'namfldlag ',namfldlag(n)
  529. WRITE(nulprt1,*) subname,n,'nammapfil ',TRIM(nammapfil(n))
  530. WRITE(nulprt1,*) subname,n,'nammaploc ',TRIM(nammaploc(n))
  531. WRITE(nulprt1,*) subname,n,'nammapopt ',TRIM(nammapopt(n))
  532. WRITE(nulprt1,*) subname,n,'namrstfil ',TRIM(namrstfil(n))
  533. WRITE(nulprt1,*) subname,n,'naminpfil ',TRIM(naminpfil(n))
  534. WRITE(nulprt1,*) subname,n,'namchecki ',namchecki(n)
  535. WRITE(nulprt1,*) subname,n,'namchecko ',namchecko(n)
  536. WRITE(nulprt1,*) subname,n,'namfldsmu ',namfldsmu(n)
  537. WRITE(nulprt1,*) subname,n,'namfldsad ',namfldsad(n)
  538. WRITE(nulprt1,*) subname,n,'namflddmu ',namflddmu(n)
  539. WRITE(nulprt1,*) subname,n,'namflddad ',namflddad(n)
  540. WRITE(nulprt1,*) subname,n,'namscrmet ',TRIM(namscrmet(n))
  541. WRITE(nulprt1,*) subname,n,'namscrnor ',TRIM(namscrnor(n))
  542. WRITE(nulprt1,*) subname,n,'namscrtyp ',TRIM(namscrtyp(n))
  543. WRITE(nulprt1,*) subname,n,'namscrord ',TRIM(namscrord(n))
  544. WRITE(nulprt1,*) subname,n,'namscrres ',TRIM(namscrres(n))
  545. WRITE(nulprt1,*) subname,n,'namscrvam ',namscrvam(n)
  546. WRITE(nulprt1,*) subname,n,'namscrnbr ',namscrnbr(n)
  547. WRITE(nulprt1,*) subname,n,'namscrbin ',namscrbin(n)
  548. WRITE(nulprt1,*) ' '
  549. CALL oasis_flush(nulprt1)
  550. ENDDO
  551. ENDIF
  552. !--- compute seq sort ---
  553. namsort2nn(:) = -1
  554. do nv = 1,nnamcpl
  555. loc = nv ! default at end
  556. n1 = 1
  557. do while (loc == nv .and. n1 < nv)
  558. if (namfldseq(nv) < namfldseq(namsort2nn(n1))) loc = n1
  559. n1 = n1 + 1
  560. enddo
  561. ! nv goes into loc location, shift then set
  562. do n1 = nv,loc+1,-1
  563. namsort2nn(n1) = namsort2nn(n1-1)
  564. enddo
  565. namsort2nn(loc) = nv
  566. enddo
  567. do nv = 1,nnamcpl
  568. namnn2sort(namsort2nn(nv)) = nv
  569. enddo
  570. IF (mpi_rank_global == 0) THEN
  571. DO nv = 1,nnamcpl
  572. n1 = namsort2nn(nv)
  573. n2 = namnn2sort(nv)
  574. WRITE(nulprt1,*) subname,' sort ',nv,n1,n2,namfldseq(n1)
  575. CALL oasis_flush(nulprt1)
  576. ENDDO
  577. ENDIF
  578. !--- check they are sorted ---
  579. do n = 2,nnamcpl
  580. if (namfldseq(namsort2nn(n)) < namfldseq(namsort2nn(n-1))) then
  581. IF (mpi_rank_global == 0) THEN
  582. WRITE(nulprt1,*) subname,' ERROR in seq sort'
  583. WRITE (nulprt1,'(a,i4)') ' abort by model ',compid
  584. WRITE (nulprt1,'(a)') ' error = ERROR in seq sort'
  585. CALL oasis_flush(nulprt1)
  586. ENDIF
  587. call oasis_abort()
  588. endif
  589. enddo
  590. call dealloc()
  591. ! call oasis_debug_exit(subname)
  592. END SUBROUTINE oasis_namcouple_init
  593. !===============================================================================
  594. SUBROUTINE inipar_alloc()
  595. !****
  596. ! *****************************
  597. ! * OASIS ROUTINE - LEVEL 0 *
  598. ! * ------------- ------- *
  599. ! *****************************
  600. !**** *inipar_alloc* - Get main run parameters to allocate arrays
  601. ! Purpose:
  602. ! -------
  603. ! Reads out run parameters.
  604. !** Interface:
  605. ! ---------
  606. ! *CALL* *inipar_alloc*
  607. ! Input:
  608. ! -----
  609. ! None
  610. ! Output:
  611. ! ------
  612. ! None
  613. !
  614. ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  615. IMPLICIT NONE
  616. !* ---------------------------- Local declarations --------------------
  617. CHARACTER*5000 clline, clline_aux, clvari
  618. CHARACTER*9 clword, clfield, clstring, clmod, clchan
  619. CHARACTER*3 clind
  620. CHARACTER*2 cldeb
  621. CHARACTER*1 clequa
  622. CHARACTER*8 clwork
  623. CHARACTER*8 clstrg
  624. CHARACTER*7 cl_bsend
  625. CHARACTER(len=32), DIMENSION(:), ALLOCATABLE :: cl_aux
  626. INTEGER (kind=ip_intwp_p) il_varid, il_len, il_err, il_maxanal
  627. INTEGER (kind=ip_intwp_p) nlonbf_notnc, nlatbf_notnc, &
  628. nlonaf_notnc, nlataf_notnc
  629. INTEGER (kind=ip_intwp_p) iind, il_redu, ib, il_aux, il_auxbf, &
  630. il_auxaf, istatus, il_id
  631. integer (kind=ip_intwp_p) :: ja,jz,jm,jf,ilen
  632. integer (kind=ip_intwp_p) :: ig_clim_maxport
  633. logical :: lg_bsend,endflag
  634. character(len=*),parameter :: subname='(mod_oasis_namcouple:inipar_alloc)'
  635. !* ---------------------------- Poema verses --------------------------
  636. ! call oasis_debug_enter(subname)
  637. ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  638. !* 1. Get basic info for the simulation
  639. ! ---------------------------------
  640. IF (mpi_rank_global == 0) THEN
  641. WRITE (UNIT = nulprt1,FMT = *)' '
  642. WRITE (UNIT = nulprt1,FMT = *)' ROUTINE inipar_alloc - Level 0'
  643. WRITE (UNIT = nulprt1,FMT = *)' ******************** *******'
  644. WRITE (UNIT = nulprt1,FMT = *)' '
  645. WRITE (UNIT = nulprt1,FMT = *)' Initialization of run parameters'
  646. WRITE (UNIT = nulprt1,FMT = *)' '
  647. WRITE (UNIT = nulprt1,FMT = *)' Reading input file namcouple'
  648. WRITE (UNIT = nulprt1,FMT = *)' '
  649. WRITE (UNIT = nulprt1,FMT = *)' '
  650. CALL oasis_flush(nulprt1)
  651. ENDIF
  652. !* Initialization
  653. ig_direct_nfield = 0
  654. ig_nfield = 0
  655. lg_oasis_field = .true.
  656. !* Initialize character keywords to locate appropriate input
  657. clfield = ' $NFIELDS'
  658. clchan = ' $CHANNEL'
  659. clstring = ' $STRINGS'
  660. clmod = ' $NBMODEL'
  661. !* Get number of models involved in this simulation
  662. REWIND nulin
  663. 100 CONTINUE
  664. READ (UNIT = nulin,FMT = 1001,END = 140) clword
  665. IF (clword .NE. clmod) GO TO 100
  666. IF (mpi_rank_global == 0) THEN
  667. WRITE (UNIT = nulprt1,FMT = *) ' ***WARNING***'
  668. WRITE (UNIT = nulprt1,FMT = *) 'Information below $NBMODEL'
  669. WRITE (UNIT = nulprt1,FMT = *) 'is obsolete in OASIS3-MCT'
  670. WRITE (UNIT = nulprt1,FMT = *) 'It will not be read and will not be used'
  671. CALL oasis_flush(nulprt1)
  672. ENDIF
  673. 140 CONTINUE
  674. ! --> Get the message passing technique we are using
  675. REWIND nulin
  676. 120 CONTINUE
  677. READ (UNIT = nulin,FMT = 1001,END = 130) clword
  678. IF (clword .NE. clchan) GO TO 120
  679. IF (mpi_rank_global == 0) THEN
  680. WRITE (UNIT = nulprt1,FMT = *) ' ***WARNING***'
  681. WRITE (UNIT = nulprt1,FMT = *) 'Information below $CHANNEL'
  682. WRITE (UNIT = nulprt1,FMT = *) 'is obsolete in OASIS3-MCT'
  683. WRITE (UNIT = nulprt1,FMT = *) 'It will not be read and will not be used'
  684. CALL oasis_flush(nulprt1)
  685. ENDIF
  686. 130 CONTINUE
  687. !* Formats
  688. 1001 FORMAT(A9)
  689. 1002 FORMAT(A5000)
  690. !* 2. Get field information
  691. ! --------------------
  692. !* Read total number of fields exchanged by this OASIS process
  693. REWIND nulin
  694. 200 CONTINUE
  695. READ (UNIT = nulin,FMT = 2001,END = 210) clword
  696. IF (clword .NE. clfield) GO TO 200
  697. READ (UNIT = nulin,FMT = 2002) clline
  698. CALL parse(clline, clvari, 1, jpeighty, ilen)
  699. IF (ilen .LE. 0) THEN
  700. IF (mpi_rank_global == 0) THEN
  701. WRITE (UNIT = nulprt1,FMT = *) ' ***WARNING***'
  702. WRITE (UNIT = nulprt1,FMT = *) &
  703. ' Nothing on input for $NFIELDS '
  704. WRITE (UNIT = nulprt1,FMT = *) ' Default value will be used '
  705. WRITE (UNIT = nulprt1,FMT = *) ' '
  706. CALL oasis_flush(nulprt1)
  707. ENDIF
  708. ELSE
  709. READ (clvari,FMT = 2003) ig_total_nfield
  710. ENDIF
  711. !* Print out the total number of fields exchanged by this OASIS process
  712. CALL prtout &
  713. ('The maximum number of exchanged fields set in namcouple is nfield =', &
  714. ig_total_nfield, 1)
  715. !* Alloc field number array
  716. ALLOCATE (ig_number_field(ig_total_nfield),stat=il_err)
  717. IF (il_err.NE.0) CALL prtout &
  718. ('Error: ig_number_field allocation of inipar_alloc',il_err,1)
  719. ig_number_field(:)=0
  720. !* Alloc field status array (logical indicating if the field goes through
  721. !* Oasis or not)
  722. ALLOCATE (lg_state(ig_total_nfield), stat=il_err)
  723. IF (il_err.NE.0) CALL prtout &
  724. ('Error: lg_state allocation of inipar_alloc',il_err,1)
  725. lg_state(:)=.false.
  726. !* Alloc status of all the fields
  727. ALLOCATE (ig_total_state(ig_total_nfield), stat=il_err)
  728. IF (il_err.NE.0) CALL prtout &
  729. ('Error: ig_total_state allocation of inipar_alloc',il_err,1)
  730. ig_total_state(:)=0
  731. !* Alloc input field name array
  732. ALLOCATE (cg_output_field(ig_total_nfield), stat=il_err)
  733. IF (il_err.NE.0) CALL prtout &
  734. ('Error: cg_output_field allocation of inipar_alloc',il_err,1)
  735. cg_output_field(:)=' '
  736. !* Alloc number of analyses array
  737. ALLOCATE (ig_total_ntrans(ig_total_nfield),stat=il_err)
  738. IF (il_err.NE.0) CALL prtout &
  739. ('Error: ig_total_ntrans"allocation of inipar_alloc',il_err,1)
  740. ig_total_ntrans (:) = 0
  741. !* Alloc array of restart file names, input and output file names
  742. ALLOCATE (cg_restart_file(ig_total_nfield),stat=il_err)
  743. IF (il_err.NE.0) CALL prtout &
  744. ('Error: cg_restart_FILE allocation of inipar_alloc',il_err,1)
  745. cg_restart_file(:)=' '
  746. ALLOCATE (cg_input_file(ig_total_nfield), stat=il_err)
  747. IF (il_err.NE.0) CALL prtout &
  748. ('Error in "cg_input_file"allocation of inipar_alloc',il_err,1)
  749. cg_input_file(:)=' '
  750. !* Alloc array of source and target locator prefix
  751. ALLOCATE (cga_locatorbf(ig_total_nfield),stat=il_err)
  752. IF (il_err.NE.0) CALL prtout &
  753. ('Error: cga_locatorbf allocation of inipar_alloc',il_err,1)
  754. cga_locatorbf(:)=' '
  755. ALLOCATE (cga_locatoraf(ig_total_nfield),stat=il_err)
  756. IF (il_err.NE.0) CALL prtout &
  757. ('Error: cga_locatoraf allocation of inipar_alloc',il_err,1)
  758. cga_locatoraf(:)=' '
  759. !* Get information for all fields
  760. REWIND nulin
  761. 220 CONTINUE
  762. READ (UNIT = nulin,FMT = 2001,END = 230) clword
  763. IF (clword .NE. clstring) GO TO 220
  764. !* Loop on total number of fields
  765. ig_final_nfield = 0
  766. DO 240 jf = 1, ig_total_nfield
  767. !* First line
  768. READ (UNIT = nulin,FMT = 2002, END=241) clline
  769. CALL parse(clline, clvari, 1, jpeighty, ilen, endflag=endflag)
  770. if (endflag .EQV. .true.) goto 241
  771. IF (TRIM(clvari) .EQ. " ") GOTO 232
  772. IF (trim(clvari) .eq. "$END") goto 241
  773. !* Get output field symbolic name
  774. IF (mpi_rank_global == 0) THEN
  775. write(nulprt1,*) 'parsing: ',trim(clline)
  776. CALL oasis_flush(nulprt1)
  777. ENDIF
  778. CALL parse(clline, clvari, 2, jpeighty, ilen)
  779. cg_output_field(jf) = clvari
  780. !* Get total number of analysis
  781. CALL parse(clline, clvari, 5, jpeighty, ilen)
  782. READ (clvari,FMT = 2003) ig_total_ntrans(jf)
  783. !* Get field STATUS for OUTPUT fields
  784. CALL parse(clline, clvari, 6, jpeighty, ilen)
  785. IF (clvari(1:6) .EQ. 'OUTPUT') THEN
  786. ig_direct_nfield = ig_direct_nfield + 1
  787. lg_state(jf) = .false.
  788. ig_total_state(jf) = ip_output
  789. ELSE
  790. !* Get field status (direct or through oasis) and the number
  791. !* of direct and indirect fields if not PIPE nor NONE
  792. CALL parse(clline, clvari, 7, jpeighty, ilen)
  793. IF (clvari(1:8).eq.'EXPORTED') THEN
  794. ig_nfield = ig_nfield + 1
  795. lg_state(jf) = .true.
  796. ig_number_field(jf) = ig_nfield
  797. ig_total_state(jf) = ip_exported
  798. CALL parse(clline, clvari, 6, jpeighty, ilen)
  799. !* Get restart file name
  800. cg_restart_file(jf) = clvari
  801. !* Get restart file name
  802. ELSEIF (clvari(1:6) .eq. 'OUTPUT' ) THEN
  803. ig_direct_nfield = ig_direct_nfield + 1
  804. lg_state(jf) = .false.
  805. ig_total_state(jf) = ip_output
  806. CALL parse(clline, clvari, 6, jpeighty, ilen)
  807. cg_restart_file(jf) = clvari
  808. ELSEIF (clvari(1:7) .eq. 'IGNORED' ) THEN
  809. ig_direct_nfield = ig_direct_nfield + 1
  810. lg_state(jf) = .false.
  811. ig_total_state(jf) = ip_ignored
  812. CALL parse(clline, clvari, 6, jpeighty, ilen)
  813. !* Get restart file name
  814. cg_restart_file(jf) = clvari
  815. ELSEIF (clvari(1:6) .eq. 'EXPOUT') THEN
  816. ig_nfield = ig_nfield + 1
  817. lg_state(jf) = .true.
  818. ig_number_field(jf) = ig_nfield
  819. ig_total_state(jf) = ip_expout
  820. CALL parse(clline, clvari, 6, jpeighty, ilen)
  821. !* Get restart file name
  822. cg_restart_file(jf) = clvari
  823. ELSEIF (clvari(1:6) .eq. 'IGNOUT' ) THEN
  824. ig_direct_nfield = ig_direct_nfield + 1
  825. lg_state(jf) = .false.
  826. ig_total_state(jf) = ip_ignout
  827. CALL parse(clline, clvari, 6, jpeighty, ilen)
  828. !* Get restart file name
  829. cg_restart_file(jf) = clvari
  830. ELSEIF (clvari(1:9).eq. 'AUXILARY') THEN
  831. ig_nfield = ig_nfield + 1
  832. lg_state(jf) = .true.
  833. ig_number_field(jf) = ig_nfield
  834. ig_total_state(jf) = ip_auxilary
  835. CALL parse(clline, clvari, 6, jpeighty, ilen)
  836. !* Get restart file name
  837. cg_restart_file(jf) = clvari
  838. ELSEIF (clvari(1:5) .eq. 'INPUT') THEN
  839. ig_direct_nfield = ig_direct_nfield + 1
  840. lg_state(jf) = .false.
  841. ig_total_state(jf) = ip_input
  842. CALL parse(clline, clvari, 6, jpeighty, ilen)
  843. !* Get input file name
  844. cg_input_file(jf) = clvari
  845. ENDIF
  846. ENDIF
  847. IF (lg_state(jf)) THEN
  848. IF (ig_total_ntrans(jf) .eq. 0) THEN
  849. IF (mpi_rank_global == 0) THEN
  850. WRITE (UNIT = nulprt1,FMT = *) &
  851. 'If there is no analysis for the field',jf, &
  852. 'then the status must not be "EXPORTED"'
  853. WRITE (UNIT = nulprt1,FMT = *)' "AUXILARY" or "EXPOUT" '
  854. WRITE (nulprt1,'(a,i4)') ' abort by model ',compid
  855. WRITE (nulprt1,'(a)') ' error = STOP in inipar_alloc'
  856. CALL oasis_flush(nulprt1)
  857. ENDIF
  858. CALL OASIS_ABORT()
  859. ENDIF
  860. READ (UNIT = nulin,FMT = 2002) clline
  861. CALL skip(clline, jpeighty)
  862. READ (UNIT = nulin,FMT = 2002) clline
  863. CALL skip(clline, jpeighty)
  864. READ (UNIT = nulin,FMT = 2002)clline_aux
  865. DO ja=1,ig_total_ntrans(jf)
  866. CALL parse(clline_aux, clvari, ja, jpeighty, ilen)
  867. IF (clvari.eq.'CORRECT'.or.clvari.eq.'BLASOLD'.or. &
  868. clvari.eq.'BLASNEW') THEN
  869. READ (UNIT = nulin,FMT = 2002) clline
  870. CALL parse(clline, clvari, 2, jpeighty, ilen)
  871. READ(clvari,FMT = 2003) il_aux
  872. DO ib = 1, il_aux
  873. READ (UNIT = nulin,FMT = 2002) clline
  874. CALL skip(clline, jpeighty)
  875. ENDDO
  876. ELSE IF (clvari.eq.'NOINTERP') THEN
  877. CONTINUE
  878. ELSE
  879. READ (UNIT = nulin,FMT = 2002) clline
  880. CALL skip(clline, jpeighty)
  881. ENDIF
  882. ENDDO
  883. ELSE
  884. IF (ig_total_state(jf) .ne. ip_input) THEN
  885. READ (UNIT = nulin,FMT = 2002) clline
  886. CALL skip(clline, jpeighty)
  887. ENDIF
  888. IF (ig_total_state(jf) .ne. ip_input .and. &
  889. ig_total_ntrans(jf) .gt. 0 ) THEN
  890. READ (UNIT = nulin,FMT = 2002) clline
  891. CALL parse(clline, clvari, 1, jpeighty, ilen)
  892. IF (clvari(1:8) .ne. 'LOCTRANS') THEN
  893. IF (mpi_rank_global == 0) THEN
  894. WRITE (UNIT = nulprt1,FMT = *) &
  895. 'You want a transformation which is not available !'
  896. WRITE (UNIT = nulprt1,FMT = *) &
  897. 'Only local transformations are available for '
  898. WRITE (UNIT = nulprt1,FMT = *) &
  899. 'fields exchanged directly or output fields '
  900. WRITE (nulprt1,'(a,i4)') ' abort by model ',compid
  901. WRITE (nulprt1,'(a)') ' error = STOP in inipar_alloc'
  902. CALL oasis_flush(nulprt1)
  903. ENDIF
  904. CALL OASIS_ABORT()
  905. ENDIF
  906. DO ja=1,ig_total_ntrans(jf)
  907. READ (UNIT = nulin,FMT = 2002) clline
  908. CALL skip(clline, jpeighty)
  909. ENDDO
  910. ENDIF
  911. ENDIF
  912. ig_final_nfield = ig_final_nfield + 1
  913. 240 CONTINUE
  914. !* Verify we're at the end of the namcouple, if not STOP (tcraig, june 2012)
  915. 243 READ (UNIT = nulin,FMT = 2002, END=242) clline
  916. CALL skip(clline, jpeighty,endflag=endflag)
  917. if (endflag .EQV. .true.) goto 242
  918. CALL parse(clline, clvari, 1, jpeighty, ilen)
  919. IF (trim(clvari) .eq. "$END") goto 243
  920. IF (mpi_rank_global == 0) THEN
  921. WRITE (UNIT = nulprt1,FMT = *) ' ***WARNING***'
  922. WRITE (UNIT = nulprt1,FMT = *) &
  923. ' NFIELDS too small, increase it in namcouple'
  924. WRITE (UNIT = nulprt1,FMT = *) ' '
  925. WRITE (UNIT = nulprt1,FMT = *) ' '
  926. WRITE (UNIT = nulprt1,FMT = *) &
  927. ' We STOP!!! Check the file namcouple'
  928. WRITE (UNIT = nulprt1,FMT = *) ' '
  929. WRITE (nulprt1,'(a,i4)') ' abort by model ',compid
  930. WRITE (nulprt1,'(a)') ' error = STOP in inipar_alloc'
  931. CALL oasis_flush(nulprt1)
  932. ENDIF
  933. CALL oasis_abort()
  934. 241 CONTINUE
  935. IF (mpi_rank_global == 0) then
  936. WRITE (nulprt1,'(a,i6)') ' found namcouple couplings = ',ig_final_nfield
  937. ENDIF
  938. 242 CONTINUE
  939. IF (ig_nfield.eq.0) THEN
  940. lg_oasis_field = .false.
  941. IF (mpi_rank_global == 0) THEN
  942. WRITE (nulprt1,*)'==> All the fields are exchanged directly'
  943. CALL oasis_flush(nulprt1)
  944. ENDIF
  945. ENDIF
  946. !* Number of different restart files
  947. allocate (cl_aux(ig_final_nfield))
  948. cl_aux(:)=' '
  949. DO jf = 1,ig_final_nfield
  950. IF (jf.eq.1) THEN
  951. cl_aux(1) = cg_restart_file(1)
  952. il_aux = 1
  953. ELSEIF (jf.gt.1) THEN
  954. IF (ALL(cl_aux.ne.cg_restart_file(jf))) THEN
  955. il_aux = il_aux + 1
  956. cl_aux(il_aux) = cg_restart_file(jf)
  957. ENDIF
  958. ENDIF
  959. ENDDO
  960. deallocate(cl_aux)
  961. ig_nbr_rstfile = il_aux
  962. IF (lg_oasis_field) THEN
  963. !* Alloc array needed for INTERP and initialize them
  964. ALLOCATE (cintmet(ig_nfield),stat=il_err)
  965. IF (il_err.NE.0) CALL prtout &
  966. ('Error: cintmet allocation of inipar_alloc',il_err,1)
  967. ALLOCATE (naismfl(ig_nfield),stat=il_err)
  968. IF (il_err.NE.0) CALL prtout &
  969. ('Error: naismfl allocation of inipar_alloc',il_err,1)
  970. ALLOCATE (naismvoi(ig_nfield),stat=il_err)
  971. IF (il_err.NE.0) CALL prtout &
  972. ('Error: naismvoi allocation of inipar_alloc',il_err,1)
  973. ALLOCATE (naisgfl(ig_nfield),stat=il_err)
  974. IF (il_err.NE.0) CALL prtout &
  975. ('Error: naisgfl allocation of inipar_alloc',il_err,1)
  976. ALLOCATE (naisgvoi(ig_nfield),stat=il_err)
  977. IF (il_err.NE.0) CALL prtout &
  978. ('Error: naisgvoi allocation of inipar_alloc',il_err,1)
  979. cintmet(:)=' '
  980. naismfl(:) = 1
  981. naismvoi(:) = 1
  982. naisgfl(:) = 1
  983. naisgvoi(:) = 1
  984. !
  985. !* Alloc arrays needed for EXTRAP and initialize them
  986. !
  987. ALLOCATE (cextmet(ig_nfield),stat=il_err)
  988. IF (il_err.NE.0) CALL prtout &
  989. ('Error: cextmet allocation of inipar_alloc',il_err,1)
  990. ALLOCATE (nninnfl(ig_nfield),stat=il_err)
  991. IF (il_err.NE.0) CALL prtout &
  992. ('Error: nninnfl allocation of inipar_alloc',il_err,1)
  993. ALLOCATE (nninnflg(ig_nfield),stat=il_err)
  994. IF (il_err.NE.0) CALL prtout &
  995. ('Error: nninnflg allocation of inipar_alloc',il_err,1)
  996. ALLOCATE (neighbor(ig_nfield), stat=il_err)
  997. IF (il_err.NE.0) CALL prtout &
  998. ('Error: neighbor allocation of inipar_alloc',il_err,1)
  999. ALLOCATE (nextfl(ig_nfield),stat=il_err)
  1000. IF (il_err.NE.0) CALL prtout &
  1001. ('Error: nextfl allocation of inipar_alloc',il_err,1)
  1002. cextmet(:)=' '
  1003. nninnfl(:) = 1
  1004. nninnflg(:) = 1
  1005. neighbor(:) = 1
  1006. nextfl(:) = 1
  1007. !
  1008. !* Alloc arrays needed for BLAS... analyses and initialize them
  1009. !
  1010. ALLOCATE (nbofld(ig_nfield), stat=il_err)
  1011. IF (il_err.NE.0) CALL prtout &
  1012. ('Error: nbofld allocation of inipar_alloc',il_err,1)
  1013. ALLOCATE (nbnfld(ig_nfield), stat=il_err)
  1014. IF (il_err.NE.0) CALL prtout &
  1015. ('Error: nbnfld allocation of inipar_alloc',il_err,1)
  1016. nbofld(:) = 1
  1017. nbnfld(:) = 1
  1018. !
  1019. !* Alloc arrays needed for MOZAIC and initialize them
  1020. !
  1021. ALLOCATE (nmapvoi(ig_nfield),stat=il_err)
  1022. IF (il_err.NE.0) CALL prtout &
  1023. ('Error: nmapvoi allocation of inipar_alloc',il_err,1)
  1024. ALLOCATE (nmapfl(ig_nfield),stat=il_err)
  1025. IF (il_err.NE.0) CALL prtout &
  1026. ('Error: nmapfl allocation of inipar_alloc',il_err,1)
  1027. nmapvoi(:) = 1
  1028. nmapfl(:) = 1
  1029. !
  1030. !* Alloc arrays needed for SUBGRID and initialize them
  1031. !
  1032. ALLOCATE (nsubfl(ig_nfield),stat=il_err)
  1033. IF (il_err.NE.0) CALL prtout &
  1034. ('Error: nsubfl allocation of inipar_alloc',il_err,1)
  1035. ALLOCATE (nsubvoi(ig_nfield),stat=il_err)
  1036. IF (il_err.NE.0) CALL prtout &
  1037. ('Error: nsubvoi allocation of inipar_alloc',il_err,1)
  1038. nsubfl(:) = 1
  1039. nsubvoi(:) = 1
  1040. !
  1041. !* Alloc arrays needed for GLORED and REDGLO and initialize them
  1042. !
  1043. ALLOCATE (ntronca(ig_nfield), stat=il_err)
  1044. IF (il_err.NE.0) CALL prtout &
  1045. ('Error: ntronca allocation of inipar_alloc',il_err,1)
  1046. ntronca(:) = 0
  1047. !
  1048. !* Alloc array needed for analyses parameters
  1049. !
  1050. ALLOCATE (cficbf(ig_nfield),stat=il_err)
  1051. IF (il_err.NE.0) CALL prtout &
  1052. ('Error: cficbf allocation of inipar_alloc',il_err,1)
  1053. cficbf(:)=' '
  1054. ALLOCATE (cficaf(ig_nfield),stat=il_err)
  1055. IF (il_err.NE.0) CALL prtout &
  1056. ('Error: cficaf allocation of inipar_alloc',il_err,1)
  1057. cficaf(:)=' '
  1058. !
  1059. !* Alloc arrays needed for grid dimensions of direct fields and
  1060. !* indirect fields
  1061. !
  1062. ALLOCATE (nlonbf(ig_nfield),stat=il_err)
  1063. IF (il_err.NE.0) CALL prtout &
  1064. ('Error: nlonbf allocation of inipar_alloc',il_err,1)
  1065. nlonbf(:)=0
  1066. ALLOCATE (nlatbf(ig_nfield),stat=il_err)
  1067. IF (il_err.NE.0) CALL prtout &
  1068. ('Error: nlatbf allocation of inipar_alloc',il_err,1)
  1069. nlatbf(:)=0
  1070. ALLOCATE (nlonaf(ig_nfield),stat=il_err)
  1071. IF (il_err.NE.0) CALL prtout &
  1072. ('Error: nlonaf allocation of inipar_alloc',il_err,1)
  1073. nlonaf(:)=0
  1074. ALLOCATE (nlataf(ig_nfield),stat=il_err)
  1075. IF (il_err.NE.0) CALL prtout &
  1076. ('Error: nlataf allocation of inipar_alloc',il_err,1)
  1077. nlataf(:)=0
  1078. !
  1079. !* Alloc arrays needed for grid number associated to each field
  1080. ALLOCATE (ig_grid_nbrbf(ig_nfield),stat=il_err)
  1081. IF (il_err.NE.0) CALL prtout &
  1082. ('Error: ig_grid_nbrbf allocation of inipar_alloc',il_err,1)
  1083. ig_grid_nbrbf(:)=0
  1084. ALLOCATE (ig_grid_nbraf(ig_nfield),stat=il_err)
  1085. IF (il_err.NE.0) CALL prtout &
  1086. ('Error: ig_grid_nbraf allocation of inipar_alloc',il_err,1)
  1087. ig_grid_nbraf(:)=0
  1088. !
  1089. !* Alloc number of analyses array
  1090. !
  1091. ALLOCATE (ig_ntrans(ig_nfield),stat=il_err)
  1092. IF (il_err.NE.0) CALL prtout &
  1093. ('Error: ig_ntrans allocation of inipar_alloc',il_err,1)
  1094. ig_ntrans(:)=0
  1095. DO ib = 1, ig_final_nfield
  1096. IF (lg_state(ib)) &
  1097. ig_ntrans(ig_number_field(ib))=ig_total_ntrans(ib)
  1098. ENDDO
  1099. !
  1100. !* Maximum number of analyses
  1101. !
  1102. il_maxanal = maxval(ig_ntrans)
  1103. !
  1104. !* Alloc array of restart file names
  1105. !
  1106. ALLOCATE (cficinp(ig_nfield), stat=il_err)
  1107. IF (il_err.NE.0) CALL prtout &
  1108. ('Error: cficinp allocation of inipar_alloc',il_err,1)
  1109. cficinp(:)=' '
  1110. DO ib = 1, ig_final_nfield
  1111. IF (lg_state(ib)) &
  1112. cficinp(ig_number_field(ib))=cg_restart_file(ib)
  1113. END DO
  1114. #ifdef use_netCDF
  1115. !tcx?
  1116. ! istatus=NF_OPEN(cg_restart_file(1), NF_NOWRITE, il_id)
  1117. ! IF (istatus .eq. NF_NOERR) THEN
  1118. ! lncdfrst = .true.
  1119. ! ELSE
  1120. #endif
  1121. lncdfrst = .false.
  1122. #ifdef use_netCDF
  1123. ! ENDIF
  1124. ! istatus=NF_CLOSE(il_id)
  1125. #endif
  1126. IF (mpi_rank_global == 0) THEN
  1127. WRITE(nulprt1, *) 'lncdfrst =', lncdfrst
  1128. CALL oasis_flush(nulprt1)
  1129. ENDIF
  1130. !
  1131. !* Alloc array needed to get analysis names
  1132. ALLOCATE (canal(il_maxanal,ig_nfield),stat=il_err)
  1133. IF (il_err.NE.0) CALL prtout &
  1134. ('Error: canal allocation of inipar_alloc',il_err,1)
  1135. canal(:,:)=' '
  1136. ENDIF
  1137. !* Get analysis parameters
  1138. REWIND nulin
  1139. 221 CONTINUE
  1140. READ (UNIT = nulin,FMT = 2001,END = 230) clword
  1141. IF (clword .NE. clstring) GO TO 221
  1142. !* Loop on total number of fields (NoF)
  1143. !
  1144. DO 250 jf=1,ig_final_nfield
  1145. !* Initialization
  1146. nlonbf_notnc = 0
  1147. nlatbf_notnc = 0
  1148. nlonaf_notnc = 0
  1149. nlataf_notnc = 0
  1150. !* Skip first line read before
  1151. READ (UNIT = nulin,FMT = 2002) clline
  1152. CALL skip(clline, jpeighty)
  1153. !
  1154. !* Second line
  1155. !* In the indirect case, reading of second, third, fourth line and analyses
  1156. !* lines
  1157. IF (ig_total_state(jf) .NE. ip_input) THEN
  1158. READ (UNIT = nulin,FMT = 2002) clline
  1159. !* First determine what information is on the line
  1160. CALL parse(clline, clvari, 3, jpeighty, ILEN)
  1161. IF (ILEN .LT. 0) THEN
  1162. !*
  1163. !* IF only two words on the line, then they are the locator
  1164. !* prefixes and the grids file must be in NetCDF format
  1165. CALL parse(clline, clvari, 1, jpeighty, ilen)
  1166. IF (lg_state(jf)) &
  1167. cficbf(ig_number_field(jf)) = clvari
  1168. cga_locatorbf(jf) = clvari(1:4)
  1169. CALL parse(clline, clvari, 2, jpeighty, ilen)
  1170. IF (lg_state(jf)) &
  1171. cficaf(ig_number_field(jf)) = clvari
  1172. cga_locatoraf(jf) = clvari(1:4)
  1173. lncdfgrd = .true.
  1174. ELSE
  1175. READ(clvari,FMT = 2010) clind, clequa, iind
  1176. IF (clind .EQ. 'SEQ' .OR. clind .EQ. 'LAG' .AND. &
  1177. clequa .EQ. '=') THEN
  1178. !* If 3rd word is an index, then first two words are
  1179. !* locator prefixes and grids file must be NetCDF format
  1180. CALL parse(clline, clvari, 1, jpeighty, ILEN)
  1181. IF (lg_state(jf)) &
  1182. cficbf(ig_number_field(jf)) = clvari
  1183. cga_locatorbf(jf) = clvari(1:4)
  1184. CALL parse(clline, clvari, 2, jpeighty, ILEN)
  1185. IF (lg_state(jf)) &
  1186. cficaf(ig_number_field(jf)) = clvari
  1187. cga_locatoraf(jf) = clvari(1:4)
  1188. lncdfgrd = .TRUE.
  1189. ELSE
  1190. !* If not, the first 4 words are grid dimensions and next
  1191. !* 2 words are locator prefixes, and grids file may be or
  1192. !* not in NetCDF format
  1193. CALL parse(clline, clvari, 1, jpeighty, ILEN)
  1194. !* Get number of longitudes for initial field
  1195. IF (mpi_rank_global == 0) THEN
  1196. WRITE(nulprt1,*)'CLVARI=',trim(clvari)
  1197. CALL oasis_flush(nulprt1)
  1198. ENDIF
  1199. READ(clvari,FMT = 2004) nlonbf_notnc
  1200. CALL parse(clline, clvari, 2, jpeighty, ilen)
  1201. !* Get number of latitudes for initial field
  1202. READ(clvari,FMT = 2004) nlatbf_notnc
  1203. CALL parse(clline, clvari, 3, jpeighty, ilen)
  1204. !* Get number of longitudes for final field
  1205. READ(clvari,FMT = 2004) nlonaf_notnc
  1206. CALL parse(clline, clvari, 4, jpeighty, ilen)
  1207. !* Get number of latitudes for final field
  1208. READ(clvari,FMT = 2004) nlataf_notnc
  1209. CALL parse(clline, clvari, 5, jpeighty, ilen)
  1210. !* Get root name grid-related files (initial field)
  1211. IF (lg_state(jf)) &
  1212. cficbf(ig_number_field(jf)) = clvari
  1213. cga_locatorbf(jf) = clvari(1:4)
  1214. CALL parse(clline, clvari, 6, jpeighty, ilen)
  1215. !* Get root name for grid-related files (final field)
  1216. IF (lg_state(jf)) &
  1217. cficaf(ig_number_field(jf)) = clvari
  1218. cga_locatoraf(jf) = clvari(1:4)
  1219. nlonbf(ig_number_field(jf)) = nlonbf_notnc
  1220. nlatbf(ig_number_field(jf)) = nlatbf_notnc
  1221. nlonaf(ig_number_field(jf)) = nlonaf_notnc
  1222. nlataf(ig_number_field(jf)) = nlataf_notnc
  1223. ENDIF
  1224. ENDIF
  1225. !* Read the P 2 P 0 line for exported, expout or auxilary
  1226. IF (lg_state(jf)) THEN
  1227. READ (UNIT = nulin,FMT = 2002) clline
  1228. CALL skip(clline, jpeighty)
  1229. ENDIF
  1230. !
  1231. !* Read next line of strings
  1232. ! --->>> Stuff related to field transformation
  1233. IF (ig_total_ntrans(jf) .GT. 0) THEN
  1234. READ (UNIT = nulin,FMT = 2002) clline
  1235. CALL skip(clline, jpeighty)
  1236. DO 260 ja = 1, ig_total_ntrans(jf)
  1237. CALL parse(clline, clvari, ja, jpeighty, ILEN)
  1238. !* Get the whole set of analysis to be performed
  1239. IF (lg_state(jf)) &
  1240. canal(ja,ig_number_field(jf)) = clvari
  1241. 260 CONTINUE
  1242. DO 270 ja = 1, ig_total_ntrans(jf)
  1243. !
  1244. IF (lg_state(jf)) THEN
  1245. cg_c=canal(ja,ig_number_field(jf))
  1246. IF (mpi_rank_global == 0) THEN
  1247. WRITE(nulprt1,*)'LG_STATE cg_c=', trim(clline)
  1248. CALL oasis_flush(nulprt1)
  1249. ENDIF
  1250. IF (cg_c .EQ. 'NOINTERP' .OR. cg_c .EQ. 'REDGLO' .OR. cg_c .EQ. 'INVERT' .OR. &
  1251. cg_c .EQ. 'MASK' .OR. cg_c .EQ. 'EXTRAP' .OR. cg_c .EQ. 'CORRECT' .OR. &
  1252. cg_c .EQ. 'REDGLO' .OR. cg_c .EQ. 'INTERP' .OR. cg_c .EQ. 'MOZAIC' .OR. &
  1253. cg_c .EQ. 'FILLING' .OR. cg_c .EQ. 'MASKP' .OR. cg_c .EQ. 'REVERSE' .OR. &
  1254. cg_c .EQ. 'GLORED') THEN
  1255. IF (mpi_rank_global == 0) THEN
  1256. WRITE(UNIT = nulprt1,FMT = *)' ***ERROR***'
  1257. WRITE(UNIT = nulprt1,FMT = *)' OBSOLETE OPERATION= ', cg_c
  1258. WRITE(UNIT = nulprt1,FMT = *)' SPECIFIED IN THE namcouple'
  1259. WRITE (nulprt1,'(a,i4)') ' abort by model ',compid
  1260. WRITE (nulprt1,'(a)') ' error = STOP in inipar'
  1261. CALL oasis_flush(nulprt1)
  1262. ENDIF
  1263. CALL OASIS_ABORT()
  1264. ENDIF
  1265. READ (UNIT = nulin,FMT = 2002) clline
  1266. CALL skip(clline, jpeighty)
  1267. IF (canal(ja,ig_number_field(jf)) .EQ. 'SCRIPR')THEN
  1268. !* Get field type (scalar/vector)
  1269. CALL parse(clline, clvari, 3, jpeighty, ILEN)
  1270. READ(clvari,FMT = 2009) clstrg
  1271. ELSE IF (canal(ja,ig_number_field(jf)) .EQ. 'BLASOLD') THEN
  1272. CALL parse(clline, clvari, 2, jpeighty, ILEN)
  1273. !* Get number of additional fields in linear formula
  1274. READ(clvari,FMT = 2003) nbofld (ig_number_field(jf))
  1275. DO ib = 1,nbofld (ig_number_field(jf))
  1276. READ (UNIT = nulin,FMT = 2002) clline
  1277. CALL skip(clline, jpeighty)
  1278. ENDDO
  1279. ELSE IF (canal(ja,ig_number_field(jf)) .EQ. 'BLASNEW') THEN
  1280. CALL parse(clline, clvari, 2, jpeighty, ILEN)
  1281. !* Get number of additional fields in linear formula
  1282. READ(clvari,FMT = 2003) nbnfld (ig_number_field(jf))
  1283. DO ib = 1,nbnfld (ig_number_field(jf))
  1284. READ (UNIT = nulin,FMT = 2002) clline
  1285. CALL skip(clline, jpeighty)
  1286. ENDDO
  1287. ENDIF
  1288. ELSE
  1289. ! For IGNORED, IGNOUT and OUTPUT, only one line for LOCTRANS
  1290. READ (UNIT = nulin,FMT = 2002) clline
  1291. IF (mpi_rank_global == 0) THEN
  1292. WRITE(nulprt1,*)'OUTPUT clline=', trim(clline)
  1293. CALL oasis_flush(nulprt1)
  1294. ENDIF
  1295. CALL skip(clline, jpeighty)
  1296. ENDIF
  1297. 270 CONTINUE
  1298. !
  1299. ENDIF ! IF (ig_total_ntrans(jf) .GT. 0) THEN
  1300. ENDIF !IF (ig_total_state(jf) .NE. ip_input) THEN
  1301. !
  1302. 250 CONTINUE
  1303. IF (lg_oasis_field) THEN
  1304. !
  1305. !* Search maximum number of fields to be combined in the BLASxxx analyses
  1306. !
  1307. ig_maxcomb = MAXVAL(nbofld)
  1308. IF (MAXVAL(nbnfld).GT.ig_maxcomb) &
  1309. ig_maxcomb = MAXVAL(nbnfld)
  1310. !
  1311. !* Search maximum number of neighbors for GAUSSIAN interpolation
  1312. !
  1313. ig_maxnoa = MAXVAL(naisgvoi)
  1314. IF (mpi_rank_global == 0) THEN
  1315. WRITE(nulprt1,*) &
  1316. 'Max number of neighbors for GAUSSIAN interp : ', &
  1317. ig_maxnoa
  1318. WRITE(nulprt1,*)' '
  1319. CALL oasis_flush(nulprt1)
  1320. ENDIF
  1321. !
  1322. !* Search maximum number of different GAUSSIAN interpolations
  1323. !
  1324. ig_maxnfg = MAXVAL(naisgfl)
  1325. IF (mpi_rank_global == 0) THEN
  1326. WRITE(nulprt1,*) &
  1327. 'Maximum number of different GAUSSIAN interpolations : ', &
  1328. ig_maxnfg
  1329. WRITE(nulprt1,*)' '
  1330. CALL oasis_flush(nulprt1)
  1331. ENDIF
  1332. !
  1333. ENDIF
  1334. !* Formats
  1335. 2001 FORMAT(A9)
  1336. 2002 FORMAT(A5000)
  1337. 2003 FORMAT(I4)
  1338. 2004 FORMAT(I8)
  1339. 2009 FORMAT(A8)
  1340. 2010 FORMAT(A3,A1,I2)
  1341. !* 3. End of routine
  1342. ! --------------
  1343. IF (mpi_rank_global == 0) THEN
  1344. WRITE(UNIT = nulprt1,FMT = *)' '
  1345. WRITE(UNIT = nulprt1,FMT = *)'-- End of ROUTINE inipar_alloc --'
  1346. CALL oasis_flush (nulprt1)
  1347. ENDIF
  1348. ! call oasis_debug_exit(subname)
  1349. RETURN
  1350. !* Error branch output
  1351. 110 CONTINUE
  1352. IF (mpi_rank_global == 0) THEN
  1353. WRITE (UNIT = nulprt1,FMT = *) ' ***WARNING***'
  1354. WRITE (UNIT = nulprt1,FMT = *) &
  1355. ' Problem with $NBMODEL in input file namcouple'
  1356. WRITE (UNIT = nulprt1,FMT = *) ' '
  1357. WRITE (UNIT = nulprt1,FMT = *) ' '
  1358. WRITE (UNIT = nulprt1,FMT = *) &
  1359. ' We STOP!!! Check the file namcouple'
  1360. WRITE (UNIT = nulprt1,FMT = *) ' '
  1361. WRITE (nulprt1,'(a,i4)') ' abort by model ',compid
  1362. WRITE (nulprt1,'(a)') ' error = STOP in inipar_alloc'
  1363. CALL oasis_flush(nulprt1)
  1364. ENDIF
  1365. CALL oasis_abort()
  1366. 210 CONTINUE
  1367. IF (mpi_rank_global == 0) THEN
  1368. WRITE (UNIT = nulprt1,FMT = *) ' ***WARNING***'
  1369. WRITE (UNIT = nulprt1,FMT = *) &
  1370. ' No active $FIELDS data found in input file namcouple'
  1371. WRITE (UNIT = nulprt1,FMT = *) ' '
  1372. WRITE (UNIT = nulprt1,FMT = *) ' '
  1373. WRITE (UNIT = nulprt1,FMT = *) &
  1374. ' We STOP!!! Check the file namcouple'
  1375. WRITE (UNIT = nulprt1,FMT = *) ' '
  1376. WRITE (nulprt1,'(a,i4)') ' abort by model ',compid
  1377. WRITE (nulprt1,'(a)') ' error = STOP in inipar_alloc'
  1378. CALL oasis_flush(nulprt1)
  1379. ENDIF
  1380. CALL oasis_abort()
  1381. 230 CONTINUE
  1382. IF (mpi_rank_global == 0) THEN
  1383. WRITE (UNIT = nulprt1,FMT = *) ' ***WARNING***'
  1384. WRITE (UNIT = nulprt1,FMT = *) &
  1385. ' No active $STRING data found in input file namcouple'
  1386. WRITE (UNIT = nulprt1,FMT = *) ' '
  1387. WRITE (UNIT = nulprt1,FMT = *) ' '
  1388. WRITE (UNIT = nulprt1,FMT = *) &
  1389. ' We STOP!!! Check the file namcouple'
  1390. WRITE (UNIT = nulprt1,FMT = *) ' '
  1391. WRITE (nulprt1,'(a,i4)') ' abort by model ',compid
  1392. WRITE (nulprt1,'(a)') ' error = STOP in inipar_alloc'
  1393. CALL oasis_flush(nulprt1)
  1394. ENDIF
  1395. CALL oasis_abort()
  1396. 232 CONTINUE
  1397. IF (mpi_rank_global == 0) THEN
  1398. WRITE (UNIT = nulprt1,FMT = *) subname,': ***WARNING***'
  1399. WRITE (UNIT = nulprt1,FMT = *) &
  1400. ' size clline smaller than the size of the names of the fields on the line'
  1401. WRITE (UNIT = nulprt1,FMT = *) &
  1402. ' increase jpeighty and change the associated format A(jpeighty) and cline'
  1403. WRITE (UNIT = nulprt1,FMT = *) ' '
  1404. WRITE (UNIT = nulprt1,FMT = *) ' '
  1405. WRITE (UNIT = nulprt1,FMT = *) &
  1406. ' We STOP!!! Check the file namcouple'
  1407. WRITE (UNIT = nulprt1,FMT = *) ' '
  1408. WRITE (nulprt1,'(a,i4)') ' abort by model ',compid
  1409. WRITE (nulprt1,'(a)') ' error = STOP in inipar_alloc'
  1410. CALL oasis_flush(nulprt1)
  1411. ENDIF
  1412. CALL oasis_abort()
  1413. END SUBROUTINE inipar_alloc
  1414. !===============================================================================
  1415. SUBROUTINE inipar
  1416. !****
  1417. ! *****************************
  1418. ! * OASIS ROUTINE - LEVEL 0 *
  1419. ! * ------------- ------- *
  1420. ! *****************************
  1421. !**** *inipar* - Get run parameters
  1422. ! Purpose:
  1423. ! -------
  1424. ! Reads and prints out run parameters.
  1425. !** Interface:
  1426. ! ---------
  1427. ! *CALL* *inipar*
  1428. ! Input:
  1429. ! -----
  1430. ! None
  1431. ! Output:
  1432. ! ------
  1433. ! None
  1434. !
  1435. ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1436. IMPLICIT NONE
  1437. !* ---------------------------- Local declarations --------------------
  1438. CHARACTER*5000 clline, clvari
  1439. CHARACTER*9 clword, clstring, clprint, clcal, clchan
  1440. CHARACTER*9 cljob, clmod, cltime, clseq, cldate, clhead
  1441. CHARACTER*8 cl_print_trans, cl_print_state
  1442. CHARACTER*3 clinfo, clind
  1443. CHARACTER*1 clequa
  1444. CHARACTER*64 cl_cfname,cl_cfunit
  1445. INTEGER (kind=ip_intwp_p) iind, il_aux
  1446. INTEGER (kind=ip_intwp_p) il_file_unit, id_error
  1447. INTEGER (kind=ip_intwp_p) il_max_entry_id, il_no_of_entries
  1448. INTEGER (kind=ip_intwp_p) il_i, il_pos
  1449. LOGICAL llseq, lllag, ll_exist
  1450. INTEGER lastplace
  1451. integer (kind=ip_intwp_p) :: ib,ilind1,ilind2,ilind
  1452. integer (kind=ip_intwp_p) :: ja,jf,jfn,jz,jm,ilen,idum
  1453. integer (kind=ip_intwp_p) :: ifca,ifcb,ilab,jff,jc
  1454. integer (kind=ip_intwp_p) :: icofld,imodel
  1455. character(len=*),parameter :: subname='(mod_oasis_namcouple:inipar)'
  1456. !* ---------------------------- Poema verses --------------------------
  1457. ! call oasis_debug_enter(subname)
  1458. ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1459. !* 1. Get basic info for the simulation
  1460. ! ---------------------------------
  1461. IF (mpi_rank_global == 0) THEN
  1462. WRITE (UNIT = nulprt1,FMT = *)' '
  1463. WRITE (UNIT = nulprt1,FMT = *)' ROUTINE inipar - Level 0'
  1464. WRITE (UNIT = nulprt1,FMT = *)' ************** *******'
  1465. WRITE (UNIT = nulprt1,FMT = *)' '
  1466. WRITE (UNIT = nulprt1,FMT = *)' Initialization of run parameters'
  1467. WRITE (UNIT = nulprt1,FMT = *)' Reading input file namcouple'
  1468. WRITE (UNIT = nulprt1,FMT = *)' '
  1469. CALL oasis_flush(nulprt1)
  1470. ENDIF
  1471. !* Initialize character keywords to locate appropriate input
  1472. clstring = ' $STRINGS'
  1473. cljob = ' $JOBNAME'
  1474. clchan = ' $CHANNEL'
  1475. clmod = ' $NBMODEL'
  1476. cltime = ' $RUNTIME'
  1477. clseq = ' $SEQMODE'
  1478. cldate = ' $INIDATE'
  1479. clhead = ' $MODINFO'
  1480. clprint = ' $NLOGPRT'
  1481. clcal = ' $CALTYPE'
  1482. !* Initialize some variables
  1483. ntime = 0 ; niter = 5
  1484. nstep = 86400 ; nitfn=4
  1485. !* First get experiment name
  1486. REWIND nulin
  1487. 100 CONTINUE
  1488. READ (UNIT = nulin,FMT = 1001,END = 110) clword
  1489. IF (clword .NE. cljob) GO TO 100
  1490. IF (mpi_rank_global == 0) THEN
  1491. WRITE (UNIT = nulprt1,FMT = *) ' ***WARNING***'
  1492. WRITE (UNIT = nulprt1,FMT = *) 'Information below $JOBNAME'
  1493. WRITE (UNIT = nulprt1,FMT = *) 'is obsolote in OASIS3-MCT'
  1494. WRITE (UNIT = nulprt1,FMT = *) 'It will not be read and will not be used'
  1495. CALL oasis_flush(nulprt1)
  1496. ENDIF
  1497. 110 CONTINUE
  1498. !* Get number of models involved in this simulation
  1499. REWIND nulin
  1500. 120 CONTINUE
  1501. READ (UNIT = nulin,FMT = 1001,END = 140) clword
  1502. IF (clword .NE. clmod) GO TO 120
  1503. IF (mpi_rank_global == 0) THEN
  1504. WRITE (UNIT = nulprt1,FMT = *) ' ***WARNING***'
  1505. WRITE (UNIT = nulprt1,FMT = *) 'Information below $NBMODEL'
  1506. WRITE (UNIT = nulprt1,FMT = *) 'is obsolete in OASIS3-MCT'
  1507. WRITE (UNIT = nulprt1,FMT = *) 'It will not be read and will not be used'
  1508. CALL oasis_flush(nulprt1)
  1509. ENDIF
  1510. 140 CONTINUE
  1511. !* Get hardware info for this OASIS simulation
  1512. REWIND nulin
  1513. 160 CONTINUE
  1514. READ (UNIT = nulin,FMT = 1001,END = 170) clword
  1515. IF (clword .NE. clchan) GO TO 160
  1516. IF (mpi_rank_global == 0) THEN
  1517. WRITE (UNIT = nulprt1,FMT = *) ' ***WARNING***'
  1518. WRITE (UNIT = nulprt1,FMT = *) 'Information below $CHANNEL'
  1519. WRITE (UNIT = nulprt1,FMT = *) 'is obsolote in OASIS3-MCT'
  1520. WRITE (UNIT = nulprt1,FMT = *) 'It will not be read and will not be used'
  1521. CALL oasis_flush(nulprt1)
  1522. ENDIF
  1523. 170 CONTINUE
  1524. !* Get total time for this simulation
  1525. REWIND nulin
  1526. 190 CONTINUE
  1527. READ (UNIT = nulin,FMT = 1001,END = 191) clword
  1528. IF (clword .NE. cltime) GO TO 190
  1529. READ (UNIT = nulin,FMT = 1002) clline
  1530. CALL parse (clline, clvari, 1, jpeighty, ilen)
  1531. IF (ilen .LE. 0) THEN
  1532. GOTO 191
  1533. ELSE
  1534. READ (clvari,FMT = 1004) ntime
  1535. ENDIF
  1536. !* Print out total time
  1537. CALL prtout &
  1538. ('The total time for this run is ntime =', ntime, 1)
  1539. !* Get initial date for this simulation
  1540. REWIND nulin
  1541. 192 CONTINUE
  1542. READ (UNIT = nulin,FMT = 1001,END = 193) clword
  1543. IF (clword .NE. cldate) GO TO 192
  1544. IF (mpi_rank_global == 0) THEN
  1545. WRITE (UNIT = nulprt1,FMT = *) ' ***WARNING***'
  1546. WRITE (UNIT = nulprt1,FMT = *) 'Information below $INIDATE'
  1547. WRITE (UNIT = nulprt1,FMT = *) 'is obsolete in OASIS3-MCT'
  1548. WRITE (UNIT = nulprt1,FMT = *) 'It will not be read and will not be used'
  1549. CALL oasis_flush(nulprt1)
  1550. ENDIF
  1551. 193 CONTINUE
  1552. !* Get number of sequential models involved in this simulation
  1553. REWIND nulin
  1554. 194 CONTINUE
  1555. READ (UNIT = nulin,FMT = 1001,END = 195) clword
  1556. IF (clword .NE. clseq) GO TO 194
  1557. IF (mpi_rank_global == 0) THEN
  1558. WRITE (UNIT = nulprt1,FMT = *) ' ***WARNING***'
  1559. WRITE (UNIT = nulprt1,FMT = *) 'Information below $SEQMODE'
  1560. WRITE (UNIT = nulprt1,FMT = *) 'is obsolete in OASIS3-MCT'
  1561. WRITE (UNIT = nulprt1,FMT = *) 'It will not be read and will not be used'
  1562. CALL oasis_flush(nulprt1)
  1563. ENDIF
  1564. 195 CONTINUE
  1565. !* Get the information mode for this simulation
  1566. REWIND nulin
  1567. 196 CONTINUE
  1568. READ (UNIT = nulin,FMT = 1001,END = 197) clword
  1569. IF (clword .NE. clhead) GO TO 196
  1570. IF (mpi_rank_global == 0) THEN
  1571. WRITE (UNIT = nulprt1,FMT = *) ' ***WARNING***'
  1572. WRITE (UNIT = nulprt1,FMT = *) 'Information below $MODINFO'
  1573. WRITE (UNIT = nulprt1,FMT = *) 'is obsolete in OASIS3-MCT'
  1574. WRITE (UNIT = nulprt1,FMT = *) 'It will not be read and will not be used'
  1575. CALL oasis_flush(nulprt1)
  1576. ENDIF
  1577. 197 CONTINUE
  1578. !* Print out the information mode
  1579. ! CALL prcout &
  1580. ! ('The information mode is activated ? ==>', clinfo, 1)
  1581. !* Get the printing level for this simulation
  1582. REWIND nulin
  1583. 198 CONTINUE
  1584. READ (UNIT = nulin,FMT = 1001,END = 199) clword
  1585. IF (clword .NE. clprint) GO TO 198
  1586. nlogprt = 2
  1587. READ (UNIT = nulin,FMT = 1002) clline
  1588. CALL parse (clline, clvari, 1, jpeighty, ilen)
  1589. IF (ilen .LE. 0) THEN
  1590. IF (mpi_rank_global == 0) THEN
  1591. WRITE (UNIT = nulprt1,FMT = *) ' ***WARNING***'
  1592. WRITE (UNIT = nulprt1,FMT = *) &
  1593. ' Nothing on input for $NLOGPRT '
  1594. WRITE (UNIT = nulprt1,FMT = *) ' Default value 2 will be used '
  1595. WRITE (UNIT = nulprt1,FMT = *) ' '
  1596. CALL oasis_flush(nulprt1)
  1597. ENDIF
  1598. ELSE IF (ilen .gt. 8) THEN
  1599. IF (mpi_rank_global == 0) THEN
  1600. WRITE (UNIT = nulprt1,FMT = *) ' ***WARNING***'
  1601. WRITE (UNIT = nulprt1,FMT = *) &
  1602. ' Input variable length is incorrect'
  1603. WRITE (UNIT = nulprt1,FMT = *) &
  1604. ' Printing level uncorrectly specified'
  1605. WRITE (UNIT = nulprt1,FMT = *) ' ilen = ', ILEN
  1606. WRITE (UNIT = nulprt1,FMT = *) &
  1607. ' Check $NLOGPRT variable spelling '
  1608. WRITE (UNIT = nulprt1,FMT = *) ' Default value will be used '
  1609. CALL oasis_flush(nulprt1)
  1610. ENDIF
  1611. ELSE
  1612. READ (clvari,FMT = 1004) nlogprt
  1613. ENDIF
  1614. ntlogprt=0
  1615. CALL parse (clline, clvari, 2, jpeighty, ilen)
  1616. IF (ILEN > 0) THEN
  1617. READ (clvari,FMT = 1004) ntlogprt
  1618. ELSE
  1619. IF (mpi_rank_global == 0) THEN
  1620. WRITE (UNIT = nulprt1,FMT = *) ' ***WARNING***'
  1621. WRITE (UNIT = nulprt1,FMT = *) &
  1622. ' Nothing on input for time statistic '
  1623. WRITE (UNIT = nulprt1,FMT = *) ' Default value 0 will be used '
  1624. WRITE (UNIT = nulprt1,FMT = *) ' '
  1625. CALL oasis_flush(nulprt1)
  1626. ENDIF
  1627. ENDIF
  1628. !* Print out the printing level
  1629. CALL prtout &
  1630. ('The printing level is nlogprt =', nlogprt, 1)
  1631. CALL prtout &
  1632. ('The time statistics level is ntlogprt =', ntlogprt, 1)
  1633. !* Get the calendar type for this simulation
  1634. REWIND nulin
  1635. 200 CONTINUE
  1636. READ (UNIT = nulin,FMT = 1001,END = 201) clword
  1637. IF (clword .NE. clcal) GO TO 200
  1638. IF (mpi_rank_global == 0) THEN
  1639. WRITE (UNIT = nulprt1,FMT = *) ' ***WARNING***'
  1640. WRITE (UNIT = nulprt1,FMT = *) 'Information below $CALTYPE'
  1641. WRITE (UNIT = nulprt1,FMT = *) 'is obsolete in OASIS3-MCT'
  1642. WRITE (UNIT = nulprt1,FMT = *) 'It will not be read and will not be used'
  1643. CALL oasis_flush(nulprt1)
  1644. ENDIF
  1645. 201 CONTINUE
  1646. !* Formats
  1647. 1001 FORMAT(A9)
  1648. 1002 FORMAT(A5000)
  1649. 1003 FORMAT(I3)
  1650. 1004 FORMAT(I12)
  1651. !* 2. Get field information
  1652. ! ---------------------
  1653. !* Init. array needed for local transformation
  1654. ig_local_trans(:) = ip_instant
  1655. !SV More cleaning is needed form here on.
  1656. !* Init. arrays needed for ANAIS(G-M),mapping and subgrid interpolation
  1657. IF (lg_oasis_field) THEN
  1658. lcoast = .TRUE.
  1659. DO 215 jz = 1, ig_nfield
  1660. linit(jz) = .TRUE.
  1661. lmapp(jz) = .TRUE.
  1662. lsubg(jz) = .TRUE.
  1663. lextra(jz) = .TRUE.
  1664. varmul(jz) = 1.
  1665. lsurf(jz) = .FALSE.
  1666. 215 CONTINUE
  1667. !
  1668. ENDIF
  1669. !* Get the SSCS for all fields
  1670. REWIND nulin
  1671. 220 CONTINUE
  1672. READ (UNIT = nulin,FMT = 2001,END = 230) clword
  1673. IF (clword .NE. clstring) GO TO 220
  1674. ! Initialize restart name index
  1675. il_aux = 0
  1676. !* Loop on total number of fields (NoF)
  1677. DO 240 jf = 1, ig_final_nfield
  1678. !* Read first two lines of strings for field n = 1,2...,ig_final_nfield
  1679. ! --->>> Main characteristics of fields
  1680. !* First line
  1681. READ (UNIT = nulin,FMT = 2002) clline
  1682. CALL parse(clline, clvari, 1, jpeighty, ilen)
  1683. !* Get output field symbolic name
  1684. cg_input_field(jf) = clvari
  1685. IF (lg_state(jf)) cnaminp(ig_number_field(jf)) = cg_input_field(jf)
  1686. IF (lg_state(jf)) cnamout(ig_number_field(jf)) = cg_output_field(jf)
  1687. CALL parse(clline, clvari, 3, jpeighty, ilen)
  1688. !* Get field label number
  1689. READ (clvari,FMT = 2003) ig_numlab(jf)
  1690. IF (lg_state(jf)) numlab(ig_number_field(jf)) = ig_numlab(jf)
  1691. CALL parse(clline, clvari, 4, jpeighty, ilen)
  1692. !* Get field exchange frequency
  1693. IF (clvari(1:4) .EQ. 'ONCE') THEN
  1694. !* The case 'ONCE' means that the coupling period will be equal to the
  1695. !* time of the simulation
  1696. ig_freq(jf) = ntime
  1697. ELSE
  1698. READ (clvari,FMT = 2004) ig_freq(jf)
  1699. IF (ig_freq(jf) .EQ. 0) THEN
  1700. GOTO 236
  1701. ELSEIF (ig_freq(jf) .gt. ntime) THEN
  1702. IF (mpi_rank_global == 0) THEN
  1703. WRITE (UNIT = nulprt1,FMT = *) ' ***WARNING***'
  1704. WRITE (UNIT = nulprt1,FMT = *) &
  1705. 'The coupling period of the field ',jf
  1706. WRITE (UNIT = nulprt1,FMT = *) &
  1707. 'is greater than the time of the simulation '
  1708. WRITE (UNIT = nulprt1,FMT = *) &
  1709. 'This field will not be exchanged !'
  1710. CALL oasis_flush(nulprt1)
  1711. ENDIF
  1712. ENDIF
  1713. ENDIF
  1714. IF (lg_state(jf)) nfexch(ig_number_field(jf)) = ig_freq(jf)
  1715. !* Fill up restart file number and restart file name arrays
  1716. IF (cg_restart_file(jf).ne.' ') THEN
  1717. IF (jf.eq.1) THEN
  1718. il_aux = il_aux + 1
  1719. ig_no_rstfile(jf) = il_aux
  1720. cg_name_rstfile (ig_no_rstfile(jf)) = &
  1721. cg_restart_file(jf)
  1722. ELSEIF (jf.gt.1) THEN
  1723. IF (ALL(cg_name_rstfile.ne.cg_restart_file(jf))) THEN
  1724. il_aux = il_aux + 1
  1725. ig_no_rstfile(jf) = il_aux
  1726. cg_name_rstfile (ig_no_rstfile(jf))= &
  1727. cg_restart_file(jf)
  1728. ELSE
  1729. DO ib = 1, jf - 1
  1730. IF(cg_name_rstfile(ig_no_rstfile(ib)).eq. &
  1731. cg_restart_file(jf)) THEN
  1732. ig_no_rstfile(jf) = ig_no_rstfile(ib)
  1733. ENDIF
  1734. ENDDO
  1735. ENDIF
  1736. ENDIF
  1737. ENDIF
  1738. CALL parse(clline, clvari, 7, jpeighty, ilen)
  1739. !*
  1740. !* Get the field STATUS
  1741. IF (clvari(1:8).eq.'EXPORTED' .or. &
  1742. clvari(1:8).eq.'AUXILARY') THEN
  1743. cstate(ig_number_field(jf)) = clvari
  1744. ELSEIF (clvari(1:6) .eq. 'EXPOUT') THEN
  1745. cstate(ig_number_field(jf)) = 'EXPORTED'
  1746. ENDIF
  1747. !*
  1748. !* Second line
  1749. ! XXX Modif Graham ?
  1750. IF (ig_total_state(jf) .ne. ip_input) THEN
  1751. READ (UNIT = nulin,FMT = 2002) clline
  1752. ! * First determine what information is on the line
  1753. CALL parse(clline, clvari, 3, jpeighty, ilen)
  1754. IF (ilen .lt. 0) THEN
  1755. ! * IF only two words on the line, then they are the locator
  1756. ! * prefixes and the grids file must be in NetCDF format
  1757. ig_lag(jf)=0
  1758. ig_total_nseqn(jf)=1
  1759. IF (lg_state(jf)) then
  1760. nseqn(ig_number_field(jf)) = 1
  1761. nlagn(ig_number_field(jf)) = 0
  1762. ENDIF
  1763. llseq=.FALSE.
  1764. lllag=.FALSE.
  1765. IF (mpi_rank_global == 0) THEN
  1766. WRITE (UNIT=nulprt1,FMT=3043) jf
  1767. ENDIF
  1768. ELSE
  1769. READ(clvari,FMT = 2011) clind, clequa, iind
  1770. IF (clind .EQ. 'SEQ' .or. clind .EQ. 'LAG' .and. &
  1771. clequa .EQ. '=') THEN
  1772. ! * If 3rd word is an index, then first two words are
  1773. ! * locator prefixes and grids file must be NetCDF format
  1774. ilind1=3
  1775. ilind2=6
  1776. ELSE
  1777. ! * If not, the first 4 words are grid dimensions and next
  1778. ! * 2 words are locator prefixes, and grids file may be or
  1779. ! * not in NetCDF FORMAT.
  1780. ilind1=7
  1781. ilind2=10
  1782. ENDIF
  1783. ! * Get possibly additional indices
  1784. ig_lag(jf)=0
  1785. ig_total_nseqn(jf)=1
  1786. IF (lg_state(jf)) then
  1787. nseqn(ig_number_field(jf)) = 1
  1788. nlagn(ig_number_field(jf)) = 0
  1789. ENDIF
  1790. llseq=.FALSE.
  1791. lllag=.FALSE.
  1792. !
  1793. DO 245 ilind=ilind1, ilind2
  1794. CALL parse(clline, clvari, ilind, jpeighty, ilen)
  1795. IF(ilen .eq. -1) THEN
  1796. IF (mpi_rank_global == 0) THEN
  1797. IF (nlogprt .GE. 0) THEN
  1798. IF(.NOT. lllag) WRITE (UNIT=nulprt1,FMT=3043) jf
  1799. ENDIF
  1800. ENDIF
  1801. GO TO 247
  1802. ELSE
  1803. READ(clvari,FMT = 2011) clind, clequa, iind
  1804. IF (clind .EQ. 'SEQ') THEN
  1805. ig_total_nseqn(jf)=iind
  1806. IF (lg_state(jf)) &
  1807. nseqn(ig_number_field(jf)) = iind
  1808. llseq=.TRUE.
  1809. ELSE IF (clind .eq. 'LAG') THEN
  1810. ig_lag(jf)=iind
  1811. IF (lg_state(jf)) &
  1812. nlagn(ig_number_field(jf)) = iind
  1813. lllag=.TRUE.
  1814. IF (mpi_rank_global == 0) THEN
  1815. WRITE (UNIT = nulprt1,FMT = 3044)jf,ig_lag(jf)
  1816. ENDIF
  1817. ENDIF
  1818. ENDIF
  1819. 245 CONTINUE
  1820. ENDIF
  1821. ENDIF
  1822. 247 CONTINUE
  1823. !* Third line
  1824. IF (lg_state(jf)) THEN
  1825. READ (UNIT = nulin,FMT = 2002) clline
  1826. CALL parse(clline, clvari, 1, jpeighty, ILEN)
  1827. ! * Get source grid periodicity type
  1828. csper(ig_number_field(jf)) = clvari
  1829. IF(csper(ig_number_field(jf)) .NE. 'P' .AND. &
  1830. csper(ig_number_field(jf)) .NE. 'R') THEN
  1831. CALL prtout &
  1832. ('ERROR in namcouple for source grid type of field', jf, 1)
  1833. IF (mpi_rank_global == 0) THEN
  1834. WRITE (UNIT = nulprt1,FMT = *) '==> must be P or R'
  1835. WRITE (nulprt1,'(a,i4)') ' abort by model ',compid
  1836. WRITE (nulprt1,'(a)') ' error = STOP in inipar'
  1837. CALL oasis_flush(nulprt1)
  1838. ENDIF
  1839. CALL OASIS_ABORT()
  1840. ENDIF
  1841. !
  1842. CALL parse(clline, clvari, 2, jpeighty, ilen)
  1843. ! * Get nbr of overlapped longitudes for the Periodic type source grid
  1844. READ(clvari,FMT = 2005) nosper(ig_number_field(jf))
  1845. CALL parse(clline, clvari, 3, jpeighty, ilen)
  1846. ! * Get target grid periodicity type
  1847. ctper(ig_number_field(jf)) = clvari
  1848. IF(ctper(ig_number_field(jf)) .NE. 'P' .AND. &
  1849. ctper(ig_number_field(jf)) .NE. 'R') THEN
  1850. CALL prtout &
  1851. ('ERROR in namcouple for target grid type of field', jf, 1)
  1852. IF (mpi_rank_global == 0) THEN
  1853. WRITE (UNIT = nulprt1,FMT = *) '==> must be P or R'
  1854. WRITE (nulprt1,'(a,i4)') ' abort by model ',compid
  1855. WRITE (nulprt1,'(a)') ' error = STOP in inipar'
  1856. CALL oasis_flush(nulprt1)
  1857. ENDIF
  1858. CALL OASIS_ABORT()
  1859. ENDIF
  1860. !
  1861. CALL parse(clline, clvari, 4, jpeighty, ilen)
  1862. ! * Get nbr of overlapped longitudes for the Periodic type target grid
  1863. READ(clvari,FMT = 2005) notper(ig_number_field(jf))
  1864. !
  1865. ENDIF
  1866. !* Get the local transformation
  1867. IF (.NOT. lg_state(jf)) THEN
  1868. IF (ig_total_state(jf) .ne. ip_input .and. &
  1869. ig_total_ntrans(jf) .gt. 0 ) THEN
  1870. READ (UNIT = nulin,FMT = 2002) clline
  1871. CALL skip(clline, jpeighty)
  1872. DO ja=1,ig_total_ntrans(jf)
  1873. READ (UNIT = nulin,FMT = 2002) clline
  1874. CALL parse(clline, clvari, 1, jpeighty, ilen)
  1875. IF (clvari(1:7) .eq. 'INSTANT') THEN
  1876. ig_local_trans(jf) = ip_instant
  1877. ELSEIF (clvari(1:7) .eq. 'AVERAGE') THEN
  1878. ig_local_trans(jf) = ip_average
  1879. ELSEIF (clvari(1:7) .eq. 'ACCUMUL') THEN
  1880. ig_local_trans(jf) = ip_accumul
  1881. ELSEIF (clvari(1:5) .eq. 'T_MIN') THEN
  1882. ig_local_trans(jf) = ip_min
  1883. ELSEIF (clvari(1:5) .eq. 'T_MAX') THEN
  1884. ig_local_trans(jf) = ip_max
  1885. ELSE
  1886. CALL prtout &
  1887. ('ERROR in namcouple for local transformations of field', jf, 1)
  1888. IF (mpi_rank_global == 0) THEN
  1889. WRITE (UNIT = nulprt1,FMT = *) &
  1890. '==> Must be INSTANT, AVERAGE, ACCUMUL, T_MIN or T_MAX'
  1891. WRITE (nulprt1,'(a,i4)') ' abort by model ',compid
  1892. WRITE (nulprt1,'(a)') ' error = STOP in inipar'
  1893. CALL oasis_flush(nulprt1)
  1894. ENDIF
  1895. CALL OASIS_ABORT()
  1896. ENDIF
  1897. ENDDO
  1898. ENDIF
  1899. ELSE
  1900. READ (UNIT = nulin,FMT = 2002) clline
  1901. CALL skip(clline, jpeighty)
  1902. !
  1903. ! * Now read specifics for each transformation
  1904. DO 270 ja = 1, ig_ntrans(ig_number_field(jf))
  1905. !
  1906. ! * Read next line unless if analysis is NOINTERP (no input)
  1907. !
  1908. READ (UNIT = nulin,FMT = 2002) clline
  1909. CALL skip(clline, jpeighty)
  1910. IF (canal(ja,ig_number_field(jf)) .EQ. 'LOCTRANS') THEN
  1911. CALL parse(clline, clvari, 1, jpeighty, ilen)
  1912. IF (clvari(1:7) .eq. 'INSTANT') THEN
  1913. ig_local_trans(jf) = ip_instant
  1914. ELSEIF (clvari(1:7) .eq. 'AVERAGE') THEN
  1915. ig_local_trans(jf) = ip_average
  1916. ELSEIF (clvari(1:7) .eq. 'ACCUMUL') THEN
  1917. ig_local_trans(jf) = ip_accumul
  1918. ELSEIF (clvari(1:5) .eq. 'T_MIN') THEN
  1919. ig_local_trans(jf) = ip_min
  1920. ELSEIF (clvari(1:5) .eq. 'T_MAX') THEN
  1921. ig_local_trans(jf) = ip_max
  1922. ELSE
  1923. CALL prtout &
  1924. ('ERROR in namcouple for local transformations of field', jf, 1)
  1925. IF (mpi_rank_global == 0) THEN
  1926. WRITE (UNIT = nulprt1,FMT = *) &
  1927. '==> Must be INSTANT, AVERAGE, ACCUMUL, T_MIN or T_MAX'
  1928. WRITE (nulprt1,'(a,i4)') ' abort by model ',compid
  1929. WRITE (nulprt1,'(a)') ' error = STOP in inipar'
  1930. CALL oasis_flush(nulprt1)
  1931. ENDIF
  1932. CALL OASIS_ABORT()
  1933. ENDIF
  1934. ELSE IF (canal(ja,ig_number_field(jf)) .EQ. 'CHECKIN')THEN
  1935. CALL parse(clline, clvari, 1, jpeighty, ILEN)
  1936. ELSE IF (canal(ja,ig_number_field(jf)) .EQ. 'CHECKOUT') THEN
  1937. CALL parse(clline, clvari, 1, jpeighty, ILEN)
  1938. ELSE IF (canal(ja,ig_number_field(jf)) .EQ. 'MAPPING') THEN
  1939. !* Get mapping filename
  1940. CALL parse(clline, clvari, 1, jpeighty, ilen)
  1941. cmap_file(ig_number_field(jf)) = trim(clvari)
  1942. !* Get mapping location and/or mapping optimization; src (default), dst; bfb (default), sum, opt
  1943. cmaptyp(ig_number_field(jf)) = 'src'
  1944. cmapopt(ig_number_field(jf)) = 'bfb'
  1945. do idum = 2,3
  1946. CALL parse(clline, clvari, idum, jpeighty, ilen)
  1947. if (ilen > 0) then
  1948. if (trim(clvari) == 'src' .or. trim(clvari) == 'dst') then
  1949. cmaptyp(ig_number_field(jf)) = trim(clvari)
  1950. elseif (trim(clvari) == 'opt' .or. trim(clvari) == 'bfb' &
  1951. .or. trim(clvari) == 'sum') then
  1952. cmapopt(ig_number_field(jf)) = trim(clvari)
  1953. else
  1954. call prtout ('ERROR in namcouple mapping argument',jf,1)
  1955. IF (mpi_rank_global == 0) THEN
  1956. WRITE(nulprt1,*) 'ERROR in namcouple mapping argument ',&
  1957. TRIM(clvari)
  1958. WRITE (nulprt1,'(a,i4)') ' abort by model ',compid
  1959. WRITE (nulprt1,'(a)') ' error = STOP in inipar cmaptyp or loc'
  1960. CALL oasis_flush(nulprt1)
  1961. ENDIF
  1962. call oasis_abort()
  1963. endif
  1964. endif
  1965. enddo
  1966. ELSE IF (canal(ja,ig_number_field(jf)) .EQ. 'SCRIPR') THEN
  1967. !* Get Scrip remapping method
  1968. CALL parse(clline, clvari, 1, jpeighty, ilen)
  1969. READ(clvari,FMT = 2009) cmap_method(ig_number_field(jf))
  1970. !* Get source grid type
  1971. CALL parse(clline, clvari, 2, jpeighty, ilen)
  1972. READ(clvari,FMT = 2009) cgrdtyp(ig_number_field(jf))
  1973. IF (cmap_method(ig_number_field(jf)) .eq. 'BICUBIC' &
  1974. .and. cgrdtyp(ig_number_field(jf)) .ne. 'LR' &
  1975. .and. cgrdtyp(ig_number_field(jf)) .ne. 'D') THEN
  1976. IF (mpi_rank_global == 0) THEN
  1977. WRITE (UNIT = nulprt1,FMT = *) ' '
  1978. ENDIF
  1979. CALL prtout &
  1980. ('ERROR in namcouple for type of field', jf, 1)
  1981. IF (mpi_rank_global == 0) THEN
  1982. WRITE (UNIT = nulprt1,FMT = *) &
  1983. 'BICUBIC interpolation cannot be used if grid is not LR or D'
  1984. WRITE (nulprt1,'(a,i4)') ' abort by model ',compid
  1985. WRITE (nulprt1,'(a)') ' error = STOP in inipar'
  1986. CALL oasis_flush(nulprt1)
  1987. ENDIF
  1988. CALL OASIS_ABORT()
  1989. ENDIF
  1990. IF (cmap_method(ig_number_field(jf)) .eq. 'BILINEAR' &
  1991. .and. cgrdtyp(ig_number_field(jf)) .ne. 'LR' &
  1992. .and. cgrdtyp(ig_number_field(jf)) .ne. 'D') THEN
  1993. IF (mpi_rank_global == 0) THEN
  1994. WRITE (UNIT = nulprt1,FMT = *) ' '
  1995. ENDIF
  1996. CALL prtout &
  1997. ('ERROR in namcouple for type of field', jf, 1)
  1998. IF (mpi_rank_global == 0) THEN
  1999. WRITE (UNIT = nulprt1,FMT = *) &
  2000. 'BILINEAR interpolation cannot be used if grid is not LR or D'
  2001. WRITE (nulprt1,'(a,i4)') ' abort by model ',compid
  2002. WRITE (nulprt1,'(a)') ' error = STOP in inipar'
  2003. CALL oasis_flush(nulprt1)
  2004. ENDIF
  2005. CALL OASIS_ABORT()
  2006. ENDIF
  2007. !* Get field type (scalar/vector)
  2008. CALL parse(clline, clvari, 3, jpeighty, ilen)
  2009. READ(clvari,FMT = 2009) cfldtype(ig_number_field(jf))
  2010. IF(cfldtype(ig_number_field(jf)) .EQ. 'VECTOR') &
  2011. cfldtype(ig_number_field(jf))='SCALAR'
  2012. IF(cfldtype(ig_number_field(jf)) .NE. 'SCALAR') THEN
  2013. IF (mpi_rank_global == 0) THEN
  2014. WRITE (UNIT = nulprt1,FMT = *) ' '
  2015. ENDIF
  2016. CALL prtout &
  2017. ('ERROR in namcouple for type of field', jf, 1)
  2018. IF (mpi_rank_global == 0) THEN
  2019. WRITE (UNIT = nulprt1,FMT = *) &
  2020. '==> must be SCALAR, VECTOR'
  2021. WRITE (nulprt1,'(a,i4)') ' abort by model ',compid
  2022. WRITE (nulprt1,'(a)') ' error = STOP in inipar'
  2023. CALL oasis_flush(nulprt1)
  2024. ENDIF
  2025. CALL OASIS_ABORT()
  2026. ENDIF
  2027. !* Get restriction type for SCRIP search
  2028. CALL parse(clline, clvari, 4, jpeighty, ilen)
  2029. READ(clvari,FMT = 2009) crsttype(ig_number_field(jf))
  2030. IF (cgrdtyp(ig_number_field(jf)) .EQ. 'D') THEN
  2031. IF (cmap_method(ig_number_field(jf)) .EQ. 'BILINEAR' .or. &
  2032. cmap_method(ig_number_field(jf)) .EQ. 'BICUBIC') THEN
  2033. IF (crsttype(ig_number_field(jf)) .NE. 'LATITUDE') THEN
  2034. IF (mpi_rank_global == 0) THEN
  2035. WRITE (UNIT = nulprt1,FMT = *) ' '
  2036. ENDIF
  2037. CALL prtout('ERROR in namcouple for restriction of field',jf,1)
  2038. IF (mpi_rank_global == 0) THEN
  2039. WRITE (UNIT = nulprt1,FMT = *) &
  2040. '==> LATITUDE must be chosen for reduced grids (D)'
  2041. WRITE (nulprt1,'(a,i4)') ' abort by model ',compid
  2042. WRITE (nulprt1,'(a)') ' error = STOP in inipar'
  2043. CALL oasis_flush(nulprt1)
  2044. ENDIF
  2045. CALL OASIS_ABORT()
  2046. ELSE
  2047. crsttype(ig_number_field(jf)) = 'REDUCED'
  2048. ENDIF
  2049. ENDIF
  2050. ENDIF
  2051. IF(crsttype(ig_number_field(jf)) .NE. 'LATITUDE' .AND. &
  2052. crsttype(ig_number_field(jf)) .NE. 'LATLON' .AND. &
  2053. crsttype(ig_number_field(jf)) .NE. 'REDUCED') THEN
  2054. IF (mpi_rank_global == 0) THEN
  2055. WRITE (UNIT = nulprt1,FMT = *) ' '
  2056. ENDIF
  2057. CALL prtout('ERROR in namcouple for restriction of field',jf,1)
  2058. IF (mpi_rank_global == 0) THEN
  2059. WRITE (UNIT = nulprt1,FMT = *) '==> must be LATITUDE or LATLON'
  2060. WRITE (nulprt1,'(a,i4)') ' abort by model ',compid
  2061. WRITE (nulprt1,'(a)') ' error = STOP in inipar'
  2062. CALL oasis_flush(nulprt1)
  2063. ENDIF
  2064. CALL OASIS_ABORT()
  2065. ENDIF
  2066. !*
  2067. !* Get number of search bins for SCRIP search
  2068. CALL parse(clline, clvari, 5, jpeighty, ilen)
  2069. READ(clvari,FMT = 2003) nbins(ig_number_field(jf))
  2070. !* Get normalize option for CONSERV
  2071. IF (cmap_method(ig_number_field(jf)) .EQ. 'CONSERV') THEN
  2072. CALL parse(clline, clvari, 6, jpeighty, ilen)
  2073. READ(clvari,FMT = 2009)cnorm_opt(ig_number_field(jf))
  2074. IF (cnorm_opt(ig_number_field(jf)) .NE. 'FRACAREA' .AND. &
  2075. cnorm_opt(ig_number_field(jf)) .NE. 'DESTAREA' .AND. &
  2076. cnorm_opt(ig_number_field(jf)) .NE. 'FRACNNEI') THEN
  2077. IF (mpi_rank_global == 0) THEN
  2078. WRITE (UNIT = nulprt1,FMT = *) ' '
  2079. ENDIF
  2080. CALL prtout &
  2081. ('ERROR in namcouple for normalize option of field',jf,1)
  2082. IF (mpi_rank_global == 0) THEN
  2083. WRITE (UNIT = nulprt1, FMT = *) &
  2084. '==> must be FRACAREA, DESTAREA, or FRACNNEI'
  2085. WRITE (nulprt1,'(a,i4)') ' abort by model ',compid
  2086. WRITE (nulprt1,'(a)') ' error = STOP in inipar'
  2087. CALL oasis_flush(nulprt1)
  2088. ENDIF
  2089. CALL OASIS_ABORT()
  2090. ENDIF
  2091. !* Get order of remapping for CONSERV
  2092. CALL parse(clline, clvari, 7, jpeighty, ilen)
  2093. IF (ilen .LE. 0) THEN
  2094. IF (mpi_rank_global == 0) THEN
  2095. WRITE (UNIT = nulprt1,FMT = *) ' '
  2096. ENDIF
  2097. CALL prtout ('ERROR in namcouple for CONSERV for field',jf,1)
  2098. IF (mpi_rank_global == 0) THEN
  2099. WRITE (UNIT = nulprt1,FMT = *) &
  2100. '==> FIRST must be indicated at end of line'
  2101. WRITE (nulprt1,'(a,i4)') ' abort by model ',compid
  2102. WRITE (nulprt1,'(a)') ' error = STOP in inipar'
  2103. CALL oasis_flush(nulprt1)
  2104. ENDIF
  2105. CALL OASIS_ABORT()
  2106. ENDIF
  2107. READ(clvari,FMT = 2009) corder(ig_number_field(jf))
  2108. ELSE
  2109. cnorm_opt(ig_number_field(jf))='NONORM'
  2110. ENDIF
  2111. !* Get number of neighbours for DISTWGT and GAUSWGT
  2112. IF (cmap_method(ig_number_field(jf)) .EQ. 'DISTWGT' .or. &
  2113. cmap_method(ig_number_field(jf)) .EQ. 'GAUSWGT') THEN
  2114. CALL parse(clline, clvari, 6, jpeighty, ilen)
  2115. IF (ilen .LE. 0) THEN
  2116. IF (mpi_rank_global == 0) THEN
  2117. WRITE (UNIT = nulprt1,FMT = *) ' '
  2118. ENDIF
  2119. CALL prtout('ERROR in namcouple for field',jf,1)
  2120. IF (mpi_rank_global == 0) THEN
  2121. WRITE (UNIT = nulprt1,FMT = *) &
  2122. '==> Number of neighbours must be indicated on the line'
  2123. WRITE (nulprt1,'(a,i4)') ' abort by model ',compid
  2124. WRITE (nulprt1,'(a)') ' error = STOP in inipar'
  2125. CALL oasis_flush(nulprt1)
  2126. ENDIF
  2127. CALL OASIS_ABORT()
  2128. ELSE
  2129. READ(clvari,FMT=2003)nscripvoi(ig_number_field(jf))
  2130. ENDIF
  2131. ENDIF
  2132. !* Get gaussian variance for GAUSWGT
  2133. IF (cmap_method(ig_number_field(jf)) .EQ. 'GAUSWGT') THEN
  2134. CALL parse(clline, clvari, 7, jpeighty, ilen)
  2135. IF (ilen .LE. 0) THEN
  2136. IF (mpi_rank_global == 0) THEN
  2137. WRITE (UNIT = nulprt1,FMT = *) ' '
  2138. ENDIF
  2139. CALL prtout('ERROR in namcouple for GAUSWGT for field',jf,1)
  2140. IF (mpi_rank_global == 0) THEN
  2141. WRITE (UNIT = nulprt1,FMT = *) &
  2142. '==> Variance must be indicated at end of line'
  2143. WRITE (nulprt1,'(a,i4)') ' abort by model ',compid
  2144. WRITE (nulprt1,'(a)') ' error = STOP in inipar'
  2145. CALL oasis_flush(nulprt1)
  2146. ENDIF
  2147. CALL OASIS_ABORT()
  2148. ELSE
  2149. READ(clvari,FMT=2006) varmul(ig_number_field(jf))
  2150. ENDIF
  2151. ENDIF
  2152. ELSE IF (canal(ja,ig_number_field(jf)) .EQ. 'FILLING') &
  2153. THEN
  2154. CALL parse(clline, clvari, 1, jpeighty, ilen)
  2155. ! * Get data file name (used to complete the initial field array)
  2156. cfilfic(ig_number_field(jf)) = clvari
  2157. CALL parse(clline, clvari, 2, jpeighty, ilen)
  2158. ! * Get logical unit connected to previous file
  2159. READ(clvari,FMT = 2005) nlufil(ig_number_field(jf))
  2160. CALL parse(clline, clvari, 3, jpeighty, ilen)
  2161. ! * Get filling method
  2162. cfilmet(ig_number_field(jf)) = clvari
  2163. ! * If current field is SST
  2164. IF(cfilmet(ig_number_field(jf))(4:6) .EQ. 'SST') THEN
  2165. CALL parse(clline, clvari, 4, jpeighty, ilen)
  2166. ! * Get flag for coast mismatch correction
  2167. READ(clvari,FMT = 2005) nfcoast
  2168. IF (cfilmet(ig_number_field(jf))(1:3) .EQ. 'SMO') &
  2169. THEN
  2170. CALL parse(clline, clvari, 5, jpeighty, ilen)
  2171. ! * Get field name for flux corrective term
  2172. cfldcor = clvari
  2173. CALL parse(clline, clvari, 6, jpeighty, ilen)
  2174. ! * Get logical unit used to write flux corrective term
  2175. READ(clvari,FMT = 2005) nlucor
  2176. ENDIF
  2177. ENDIF
  2178. ELSE IF (canal(ja,ig_number_field(jf)) .EQ. 'CONSERV') &
  2179. THEN
  2180. CALL parse(clline, clvari, 1, jpeighty, ilen)
  2181. ! * Get conservation method
  2182. cconmet(ig_number_field(jf)) = clvari
  2183. lsurf(ig_number_field(jf)) = .TRUE.
  2184. CALL parse(clline, clvari, 2, jpeighty, ilen)
  2185. cconopt(ig_number_field(jf)) = 'bfb'
  2186. if (ilen > 0) then
  2187. if (trim(clvari) == 'bfb' .or. trim(clvari) == 'opt') then
  2188. cconopt(ig_number_field(jf)) = clvari
  2189. else
  2190. call prtout ('ERROR in namcouple conserv argument',jf,1)
  2191. IF (mpi_rank_global == 0) THEN
  2192. WRITE(nulprt1,*) 'ERROR in namcouple conserv argument ',&
  2193. TRIM(clvari)
  2194. WRITE (nulprt1,'(a,i4)') ' abort by model ',compid
  2195. WRITE (nulprt1,'(a)') ' error = STOP in inipar cconopt'
  2196. CALL oasis_flush(nulprt1)
  2197. ENDIF
  2198. call oasis_abort()
  2199. endif
  2200. endif
  2201. ELSE IF (canal(ja,ig_number_field(jf)) .EQ. 'BLASOLD')THEN
  2202. ! * Get linear combination parameters for initial fields
  2203. CALL parse(clline, clvari, 1, jpeighty, ilen)
  2204. ! * Get main field multiplicative coefficient
  2205. READ(clvari,FMT = 2006) afldcobo(ig_number_field(jf))
  2206. DO 290 jc = 1, nbofld(ig_number_field(jf))
  2207. READ (UNIT = nulin,FMT = 2002) clline
  2208. CALL parse(clline, clvari, 1, jpeighty, ilen)
  2209. ! * Get symbolic names for additional fields
  2210. cbofld(jc,ig_number_field(jf)) = clvari
  2211. CALL parse(clline, clvari, 2, jpeighty, ilen)
  2212. ! * Get multiplicative coefficients for additional fields
  2213. READ(clvari,FMT = 2006) &
  2214. abocoef (jc,ig_number_field(jf))
  2215. 290 CONTINUE
  2216. ELSE IF (canal(ja,ig_number_field(jf)) .EQ. 'BLASNEW')THEN
  2217. ! * Get linear combination parameters for final fields
  2218. CALL parse(clline, clvari, 1, jpeighty, ilen)
  2219. ! * Get main field multiplicative coefficient
  2220. READ(clvari,FMT = 2006) afldcobn(ig_number_field(jf))
  2221. DO 291 jc = 1, nbnfld(ig_number_field(jf))
  2222. READ (UNIT = nulin,FMT = 2002) clline
  2223. CALL parse(clline, clvari, 1, jpeighty, ilen)
  2224. ! * Get symbolic names for additional fields
  2225. cbnfld(jc,ig_number_field(jf)) = clvari
  2226. CALL parse(clline, clvari, 2, jpeighty, ilen)
  2227. ! * Get multiplicative coefficients for additional fields
  2228. READ(clvari,FMT = 2006) &
  2229. abncoef (jc,ig_number_field(jf))
  2230. 291 CONTINUE
  2231. ELSE
  2232. IF (mpi_rank_global == 0) THEN
  2233. WRITE (UNIT = nulprt1,FMT = *) ' ***WARNING***'
  2234. WRITE (UNIT = nulprt1,FMT = *) &
  2235. ' Type of analysis not implemented yet '
  2236. WRITE (UNIT = nulprt1,FMT = *) &
  2237. ' The analysis required in OASIS is :'
  2238. WRITE (UNIT = nulprt1,FMT = *) ' canal = ', &
  2239. canal(ja,ig_number_field(jf))
  2240. WRITE (UNIT = nulprt1,FMT = *) &
  2241. ' with ja = ', ja, ' jf = ', jf
  2242. WRITE (UNIT = nulprt1,FMT = *) ' '
  2243. WRITE (nulprt1,'(a,i4)') ' abort by model ',compid
  2244. WRITE (nulprt1,'(a)') ' error = STOP in inipar'
  2245. CALL oasis_flush(nulprt1)
  2246. ENDIF
  2247. CALL oasis_abort()
  2248. ENDIF
  2249. 270 CONTINUE
  2250. ENDIF
  2251. !* End of loop on NoF
  2252. 240 CONTINUE
  2253. !* Minimum coupling period
  2254. ig_total_frqmin = minval(ig_freq)
  2255. !* Formats
  2256. 2001 FORMAT(A9)
  2257. 2002 FORMAT(A5000)
  2258. 2003 FORMAT(I4)
  2259. 2004 FORMAT(I8)
  2260. 2005 FORMAT(I2)
  2261. 2006 FORMAT(E15.6)
  2262. 2008 FORMAT(A2,I4)
  2263. 2009 FORMAT(A8)
  2264. 2010 FORMAT(A3,A1,I2)
  2265. 2011 FORMAT(A3,A1,I8)
  2266. !* 3. Printing
  2267. ! --------
  2268. IF (mpi_rank_global == 0) THEN
  2269. !* Warning: no indentation for the next if (nightmare ...)
  2270. IF (nlogprt .GE. 0) THEN
  2271. DO 310 jf = 1, ig_final_nfield
  2272. IF (ig_total_state(jf) .eq. ip_exported ) THEN
  2273. cl_print_state = 'EXPORTED'
  2274. ELSEIF (ig_total_state(jf) .eq. ip_ignored ) THEN
  2275. cl_print_state = 'IGNORED'
  2276. ELSEIF (ig_total_state(jf) .eq. ip_ignout ) THEN
  2277. cl_print_state = 'IGNOUT'
  2278. ELSEIF (ig_total_state(jf) .eq. ip_expout ) THEN
  2279. cl_print_state = 'EXPOUT'
  2280. ELSEIF (ig_total_state(jf) .eq. ip_input ) THEN
  2281. cl_print_state = 'INPUT'
  2282. ELSEIF (ig_total_state(jf) .eq. ip_output ) THEN
  2283. cl_print_state = 'OUTPUT'
  2284. ELSEIF (ig_total_state(jf) .eq. ip_auxilary ) THEN
  2285. cl_print_state = 'AUXILARY'
  2286. ENDIF
  2287. IF (ig_local_trans(jf) .eq. ip_instant) THEN
  2288. cl_print_trans = 'INSTANT'
  2289. ELSEIF (ig_local_trans(jf) .eq. ip_average) THEN
  2290. cl_print_trans = 'AVERAGE'
  2291. ELSEIF (ig_local_trans(jf) .eq. ip_accumul) THEN
  2292. cl_print_trans = 'ACCUMUL'
  2293. ELSEIF (ig_local_trans(jf) .eq. ip_min) THEN
  2294. cl_print_trans = 'T_MIN'
  2295. ELSEIF (ig_local_trans(jf) .eq. ip_max) THEN
  2296. cl_print_trans = 'T_MAX'
  2297. ENDIF
  2298. !* Local indexes
  2299. IF (.NOT. lg_state(jf)) THEN
  2300. ilab = ig_numlab(jf)
  2301. WRITE (UNIT = nulprt1,FMT = 3001) jf
  2302. WRITE (UNIT = nulprt1,FMT = 3002)
  2303. WRITE (UNIT = nulprt1,FMT = 3003)
  2304. WRITE (UNIT = nulprt1,FMT = 3004)
  2305. IF (ig_total_state(jf) .eq. ip_input .or. &
  2306. ig_total_state(jf) .eq. ip_output) THEN
  2307. WRITE (UNIT = nulprt1,FMT = 3121) &
  2308. cg_input_field(jf), cg_output_field(jf), &
  2309. ig_freq(jf), cl_print_trans, &
  2310. cl_print_state, ig_total_ntrans(jf)
  2311. ELSE
  2312. WRITE (UNIT = nulprt1,FMT = 3116) &
  2313. cg_input_field(jf), cg_output_field(jf), &
  2314. ig_freq(jf), cl_print_trans, ig_total_nseqn(jf), &
  2315. ig_lag(jf), cl_print_state, ig_total_ntrans(jf)
  2316. ENDIF
  2317. ELSE
  2318. ilab = numlab(ig_number_field(jf))
  2319. ifcb = len_trim(cficbf(ig_number_field(jf)))
  2320. ifca = len_trim(cficaf(ig_number_field(jf)))
  2321. WRITE (UNIT = nulprt1,FMT = 3001) jf
  2322. WRITE (UNIT = nulprt1,FMT = 3002)
  2323. WRITE (UNIT = nulprt1,FMT = 3003)
  2324. WRITE (UNIT = nulprt1,FMT = 3004)
  2325. WRITE (UNIT = nulprt1,FMT = 3005) &
  2326. TRIM(cnaminp(ig_number_field(jf))), &
  2327. TRIM(cnamout(ig_number_field(jf))), &
  2328. nfexch(ig_number_field(jf)), &
  2329. nseqn(ig_number_field(jf)), &
  2330. ig_lag(jf), &
  2331. cl_print_state, &
  2332. ig_ntrans(ig_number_field(jf))
  2333. ENDIF
  2334. !* Warning: no indentation for the next if (nightmare ...)
  2335. !* Warning: no indentation for the next if (nightmare ...)
  2336. IF (.not. lg_state(jf)) THEN
  2337. IF (ig_total_state(jf) .eq. ip_ignored .or. &
  2338. ig_total_state(jf) .eq. ip_ignout ) THEN
  2339. WRITE (UNIT = nulprt1,FMT = 3117) cg_restart_file(jf)
  2340. ELSEIF (ig_total_state(jf) .eq. ip_input) THEN
  2341. WRITE (UNIT = nulprt1,FMT = 3118) cg_input_file(jf)
  2342. ENDIF
  2343. ELSE
  2344. IF (ig_total_state(jf) .eq. ip_exported .or. &
  2345. ig_total_state(jf) .eq. ip_expout .or. &
  2346. ig_total_state(jf) .eq. ip_auxilary ) &
  2347. WRITE (UNIT = nulprt1,FMT = 3117) cg_restart_file(jf)
  2348. !* Warning: no indentation for the next if (nightmare ...)
  2349. WRITE (UNIT = nulprt1,FMT = 3007) &
  2350. csper(ig_number_field(jf)), nosper(ig_number_field(jf)), &
  2351. ctper(ig_number_field(jf)), notper(ig_number_field(jf))
  2352. WRITE (UNIT = nulprt1,FMT = 3008) &
  2353. cficbf(ig_number_field(jf))(1:ifcb)//cglonsuf, &
  2354. cficbf(ig_number_field(jf))(1:ifcb)//cglatsuf, &
  2355. cficbf(ig_number_field(jf))(1:ifcb)//cmsksuf, &
  2356. cficbf(ig_number_field(jf))(1:ifcb)//csursuf, &
  2357. cficaf(ig_number_field(jf))(1:ifca)//cglonsuf, &
  2358. cficaf(ig_number_field(jf))(1:ifca)//cglatsuf, &
  2359. cficaf(ig_number_field(jf))(1:ifca)//cmsksuf, &
  2360. cficaf(ig_number_field(jf))(1:ifca)//csursuf
  2361. WRITE (UNIT = nulprt1,FMT = 3009)
  2362. WRITE (UNIT = nulprt1,FMT = 3010)
  2363. DO 320 ja = 1, ig_ntrans(ig_number_field(jf))
  2364. WRITE (UNIT = nulprt1,FMT = 3011) ja, &
  2365. canal(ja,ig_number_field(jf))
  2366. IF (canal(ja,ig_number_field(jf)) .EQ. 'MAPPING') THEN
  2367. write(UNIT = nulprt1,FMT = 3048) &
  2368. trim(cmap_file(ig_number_field(jf))), &
  2369. trim(cmaptyp(ig_number_field(jf))), &
  2370. trim(cmapopt(ig_number_field(jf)))
  2371. ELSE IF (canal(ja,ig_number_field(jf)) .EQ. 'SCRIPR') THEN
  2372. WRITE(UNIT = nulprt1,FMT = 3045) &
  2373. cmap_method(ig_number_field(jf)), &
  2374. cfldtype(ig_number_field(jf)), &
  2375. cnorm_opt(ig_number_field(jf)), &
  2376. crsttype(ig_number_field(jf)), &
  2377. nbins(ig_number_field(jf))
  2378. IF (cmap_method(ig_number_field(jf)) .EQ. 'CONSERV') THEN
  2379. WRITE(UNIT = nulprt1,FMT = 3046) &
  2380. corder(ig_number_field(jf))
  2381. ENDIF
  2382. ELSE IF (canal(ja,ig_number_field(jf)) .EQ. 'CONSERV') THEN
  2383. WRITE(UNIT = nulprt1,FMT = 3025) &
  2384. cconmet(ig_number_field(jf)), &
  2385. cconopt(ig_number_field(jf))
  2386. ELSE IF (canal(ja,ig_number_field(jf)) .EQ. 'BLASOLD') THEN
  2387. WRITE(UNIT = nulprt1,FMT = 3027) &
  2388. trim(cnaminp(ig_number_field(jf))), &
  2389. afldcobo(ig_number_field(jf))
  2390. WRITE(UNIT = nulprt1,FMT=3028) nbofld(ig_number_field(jf))
  2391. DO 340 jc = 1, nbofld(ig_number_field(jf))
  2392. WRITE (UNIT = nulprt1,FMT = 3030) &
  2393. cbofld(jc,ig_number_field(jf)), &
  2394. abocoef (jc,ig_number_field(jf))
  2395. 340 CONTINUE
  2396. ELSE IF (canal(ja,ig_number_field(jf)) .EQ. 'BLASNEW') THEN
  2397. WRITE(UNIT = nulprt1,FMT = 3027) &
  2398. trim(cnamout(ig_number_field(jf))), &
  2399. afldcobn(ig_number_field(jf))
  2400. WRITE(UNIT = nulprt1,FMT=3028) nbnfld(ig_number_field(jf))
  2401. DO 350 jc = 1, nbnfld(ig_number_field(jf))
  2402. WRITE (UNIT = nulprt1,FMT = 3030) &
  2403. cbnfld(jc,ig_number_field(jf)), &
  2404. abncoef (jc,ig_number_field(jf))
  2405. 350 CONTINUE
  2406. ELSE IF (canal(ja,ig_number_field(jf)) .EQ. 'CHECKIN') THEN
  2407. WRITE(UNIT = nulprt1,FMT = *) ' '
  2408. ELSE IF (canal(ja,ig_number_field(jf)) .EQ. 'CHECKOUT') THEN
  2409. WRITE(UNIT = nulprt1,FMT = *) ' '
  2410. ELSE IF (canal(ja,ig_number_field(jf)) .EQ. 'LOCTRANS') THEN
  2411. WRITE(UNIT = nulprt1,FMT = 3047) cl_print_trans
  2412. ELSE
  2413. WRITE (UNIT = nulprt1,FMT = *) ' ***WARNING***'
  2414. WRITE (UNIT = nulprt1,FMT = *) &
  2415. ' Type of analysis not implemented yet '
  2416. WRITE (UNIT = nulprt1,FMT = *) &
  2417. ' The analysis required in OASIS is :'
  2418. WRITE (UNIT = nulprt1,FMT = *) ' canal = ', &
  2419. canal(ja,ig_number_field(jf))
  2420. WRITE (UNIT = nulprt1,FMT = *) &
  2421. ' with ja = ', ja, ' jf = ', jf
  2422. WRITE (UNIT = nulprt1,FMT = *) ' '
  2423. WRITE (nulprt1,'(a,i4)') ' abort by model ',compid
  2424. WRITE (nulprt1,'(a)') ' error = STOP in inipar'
  2425. CALL oasis_flush(nulprt1)
  2426. CALL oasis_abort()
  2427. ENDIF
  2428. 320 CONTINUE
  2429. ENDIF
  2430. 310 CONTINUE
  2431. ENDIF
  2432. ENDIF
  2433. !* Formats
  2434. 3001 FORMAT(//,15X,' FIELD NUMBER ',I3)
  2435. 3002 FORMAT(15X,' ************ ')
  2436. 3003 FORMAT(/,10X,' Field parameters ')
  2437. 3004 FORMAT(10X,' **************** ',/)
  2438. 3005 FORMAT(/,10X,' Input field symbolic name = ',A, &
  2439. /,10X,' Output field symbolic name = ',A, &
  2440. /,10X,' Field exchange frequency = ',I8, &
  2441. /,10X,' Model sequential index = ',I2, &
  2442. /,10X,' Field Lag = ',I8, &
  2443. /,10X,' Field I/O status = ',A8, &
  2444. /,10X,' Number of basic operations = ',I4, /)
  2445. 3116 FORMAT(/,10X,' Input field symbolic name = ',A8, &
  2446. /,10X,' Output field symbolic name = ',A8, &
  2447. /,10X,' Field exchange frequency = ',I8, &
  2448. /,10X,' Local transformation = ',A8, &
  2449. /,10X,' Model sequential index = ',I2, &
  2450. /,10X,' Field Lag = ',I8, &
  2451. /,10X,' Field I/O status = ',A8, &
  2452. /,10X,' Number of basic operations = ',I4,/)
  2453. 3117 FORMAT(/,10X,' Restart file name = ',A32,/)
  2454. 3118 FORMAT(/,10X,' Input file name = ',A32,/)
  2455. 3121 FORMAT(/,10X,' Input field symbolic name = ',A8, &
  2456. /,10X,' Output field symbolic name = ',A8, &
  2457. /,10X,' Field exchange frequency = ',I8, &
  2458. /,10X,' Local transformation = ',A8, &
  2459. /,10X,' Field I/O status = ',A8, &
  2460. /,10X,' Number of basic operations = ',I4,/)
  2461. 3007 FORMAT( &
  2462. /,10X,' Source grid periodicity type is = ',A8, &
  2463. /,10X,' Number of overlapped grid points is = ',I2, &
  2464. /,10X,' Target grid periodicity type is = ',A8, &
  2465. /,10X,' Number of overlapped grid points is = ',I2,/)
  2466. 3008 FORMAT(/,10X,' Source longitude file string = ',A8, &
  2467. /,10X,' Source latitude file string = ',A8, &
  2468. /,10X,' Source mask file string = ',A8, &
  2469. /,10X,' Source surface file string = ',A8, &
  2470. /,10X,' Target longitude file string = ',A8, &
  2471. /,10X,' Target latitude file string = ',A8, &
  2472. /,10X,' Target mask file string = ',A8, &
  2473. /,10X,' Target surface file string = ',A8,/)
  2474. 3009 FORMAT(/,10X,' ANALYSIS PARAMETERS ')
  2475. 3010 FORMAT(10X,' ******************* ',/)
  2476. 3011 FORMAT(/,5X,' ANALYSIS number ',I2,' is ',A8, &
  2477. /,5X,' *************** ',/)
  2478. 3025 FORMAT(5X,' Conservation method for field is = ',A8, &
  2479. /,5X,' Conservation option is = ',A8)
  2480. 3027 FORMAT(5X,' Field ',A,' is multiplied by Cst = ',E15.6)
  2481. 3028 FORMAT(5X,' It is combined with N fields N = ',I2)
  2482. 3030 FORMAT(5X,' With field ',A8,' coefficient = ',E15.6)
  2483. 3043 FORMAT(/,5X,'No lag in namcouple for the field', I3, &
  2484. /,5X,' Default value LAG=0 will be used ')
  2485. 3044 FORMAT(/,5X,'The lag for the field ',I3,3X,'is : ',I8)
  2486. 3045 FORMAT(5X,' Remapping method is = ',A8, &
  2487. /,5X,' Field type is = ',A8, &
  2488. /,5X,' Normalization option is = ',A8, &
  2489. /,5X,' Seach restriction type is = ',A8, &
  2490. /,5X,' Number of search bins is = ',I4)
  2491. 3046 FORMAT(5X,' Order of remapping is = ',A8)
  2492. 3047 FORMAT(5X,' Local transformation = ',A8)
  2493. 3048 FORMAT(5X,' Remapping filename is = ',A, &
  2494. /,5X,' Mapping location is = ',A8, &
  2495. /,5X,' Mapping optimization is = ',A8)
  2496. !* 4. End of routine
  2497. ! --------------
  2498. IF (mpi_rank_global == 0) THEN
  2499. IF (nlogprt .GE. 0) THEN
  2500. WRITE(UNIT = nulprt1,FMT = *)' '
  2501. WRITE(UNIT = nulprt1,FMT = *)'------ End of ROUTINE inipar ----'
  2502. CALL oasis_flush (nulprt1)
  2503. ENDIF
  2504. ENDIF
  2505. ! call oasis_debug_exit(subname)
  2506. RETURN
  2507. !* Error branch output
  2508. 130 CONTINUE
  2509. IF (mpi_rank_global == 0) THEN
  2510. WRITE (UNIT = nulprt1,FMT = *) ' ***WARNING***'
  2511. WRITE (UNIT = nulprt1,FMT = *) &
  2512. ' No active $NBMODEL data found in input file namcouple'
  2513. WRITE (UNIT = nulprt1,FMT = *) ' '
  2514. WRITE (UNIT = nulprt1,FMT = *) ' '
  2515. WRITE (UNIT = nulprt1,FMT = *) &
  2516. ' We STOP!!! Check the file namcouple'
  2517. WRITE (UNIT = nulprt1,FMT = *) ' '
  2518. WRITE (nulprt1,'(a,i4)') ' abort by model ',compid
  2519. WRITE (nulprt1,'(a)') ' error = STOP in inipar'
  2520. CALL oasis_flush(nulprt1)
  2521. ENDIF
  2522. CALL oasis_abort()
  2523. 191 CONTINUE
  2524. IF (mpi_rank_global == 0) THEN
  2525. WRITE (UNIT = nulprt1,FMT = *) ' ***WARNING***'
  2526. WRITE (UNIT = nulprt1,FMT = *) &
  2527. ' Problem with $RUNTIME in input file namcouple'
  2528. WRITE (UNIT = nulprt1,FMT = *) ' '
  2529. WRITE (UNIT = nulprt1,FMT = *) ' '
  2530. WRITE (UNIT = nulprt1,FMT = *) &
  2531. ' We STOP!!! Check the file namcouple'
  2532. WRITE (UNIT = nulprt1,FMT = *) ' '
  2533. WRITE (nulprt1,'(a,i4)') ' abort by model ',compid
  2534. WRITE (nulprt1,'(a)') ' error = STOP in inipar'
  2535. CALL oasis_flush(nulprt1)
  2536. ENDIF
  2537. CALL oasis_abort()
  2538. 199 CONTINUE
  2539. IF (mpi_rank_global == 0) THEN
  2540. WRITE (UNIT = nulprt1,FMT = *) ' ***WARNING***'
  2541. WRITE (UNIT = nulprt1,FMT = *) &
  2542. ' No active $NLOGPRT found in input file namcouple'
  2543. WRITE (UNIT = nulprt1,FMT = *) ' '
  2544. WRITE (UNIT = nulprt1,FMT = *) ' '
  2545. WRITE (UNIT = nulprt1,FMT = *) &
  2546. ' We STOP!!! Check the file namcouple'
  2547. WRITE (UNIT = nulprt1,FMT = *) ' '
  2548. WRITE (nulprt1,'(a,i4)') ' abort by model ',compid
  2549. WRITE (nulprt1,'(a)') ' error = STOP in inipar'
  2550. CALL oasis_flush(nulprt1)
  2551. ENDIF
  2552. CALL oasis_abort()
  2553. 210 CONTINUE
  2554. IF (mpi_rank_global == 0) THEN
  2555. WRITE (UNIT = nulprt1,FMT = *) ' ***WARNING***'
  2556. WRITE (UNIT = nulprt1,FMT = *) &
  2557. ' No active $FIELDS data found in input file namcouple'
  2558. WRITE (UNIT = nulprt1,FMT = *) ' '
  2559. WRITE (UNIT = nulprt1,FMT = *) ' '
  2560. WRITE (UNIT = nulprt1,FMT = *) &
  2561. ' We STOP!!! Check the file namcouple'
  2562. WRITE (UNIT = nulprt1,FMT = *) ' '
  2563. WRITE (nulprt1,'(a,i4)') ' abort by model ',compid
  2564. WRITE (nulprt1,'(a)') ' error = STOP in inipar'
  2565. CALL oasis_flush(nulprt1)
  2566. ENDIF
  2567. CALL oasis_abort()
  2568. 230 CONTINUE
  2569. IF (mpi_rank_global == 0) THEN
  2570. WRITE (UNIT = nulprt1,FMT = *) ' ***WARNING***'
  2571. WRITE (UNIT = nulprt1,FMT = *) &
  2572. ' No active $STRING data found in input file namcouple'
  2573. WRITE (UNIT = nulprt1,FMT = *) ' '
  2574. WRITE (UNIT = nulprt1,FMT = *) ' '
  2575. WRITE (UNIT = nulprt1,FMT = *) &
  2576. ' We STOP!!! Check the file namcouple'
  2577. WRITE (UNIT = nulprt1,FMT = *) ' '
  2578. WRITE (nulprt1,'(a,i4)') ' abort by model ',compid
  2579. WRITE (nulprt1,'(a)') ' error = STOP in inipar'
  2580. CALL oasis_flush(nulprt1)
  2581. ENDIF
  2582. CALL oasis_abort()
  2583. 233 CONTINUE
  2584. IF (mpi_rank_global == 0) THEN
  2585. WRITE (UNIT = nulprt1,FMT = *) ' '
  2586. ENDIF
  2587. CALL prtout ('ERROR in namcouple for field', jf, 1)
  2588. IF (mpi_rank_global == 0) THEN
  2589. WRITE (UNIT = nulprt1,FMT = *) &
  2590. 'Check the 2nd line for either the index of sequential position, &
  2591. & the delay flag, or the extra timestep flag.'
  2592. WRITE (nulprt1,'(a,i4)') ' abort by model ',compid
  2593. WRITE (nulprt1,'(a)') ' error = STOP in inipar.f'
  2594. CALL oasis_flush(nulprt1)
  2595. ENDIF
  2596. CALL oasis_abort()
  2597. 235 CONTINUE
  2598. IF (mpi_rank_global == 0) THEN
  2599. WRITE (UNIT = nulprt1,FMT = *) ' '
  2600. ENDIF
  2601. CALL prtout ('ERROR in namcouple for field', jf, 1)
  2602. IF (mpi_rank_global == 0) THEN
  2603. WRITE (UNIT = nulprt1,FMT = *) &
  2604. 'An input line with integral calculation flag'
  2605. WRITE (UNIT = nulprt1,FMT = *) &
  2606. '("INT=0" or "INT=1")'
  2607. WRITE (UNIT = nulprt1,FMT = *) &
  2608. 'is now required for analysis CHECKIN or CHECKOUT'
  2609. WRITE (nulprt1,'(a,i4)') ' abort by model ',compid
  2610. WRITE (nulprt1,'(a)') ' error = STOP in inipar.f'
  2611. CALL oasis_flush(nulprt1)
  2612. ENDIF
  2613. CALL oasis_abort()
  2614. 236 CONTINUE
  2615. IF (mpi_rank_global == 0) THEN
  2616. WRITE (UNIT = nulprt1,FMT = *) ' '
  2617. ENDIF
  2618. CALL prtout ('ERROR in namcouple for field', jf, 1)
  2619. IF (mpi_rank_global == 0) THEN
  2620. WRITE (UNIT = nulprt1,FMT = *) &
  2621. 'The coupling period must not be 0 !'
  2622. WRITE (UNIT = nulprt1,FMT = *) &
  2623. 'If you do not want to exchange this field at all'
  2624. WRITE (UNIT = nulprt1,FMT = *) &
  2625. 'give a coupling period longer than the total run time.'
  2626. WRITE (nulprt1,'(a,i4)') ' abort by model ',compid
  2627. WRITE (nulprt1,'(a)') ' error = STOP in inipar.f'
  2628. CALL oasis_flush(nulprt1)
  2629. ENDIF
  2630. CALL oasis_abort()
  2631. END SUBROUTINE inipar
  2632. !===============================================================================
  2633. SUBROUTINE alloc()
  2634. IMPLICIT NONE
  2635. character(len=*),parameter :: subname='(mod_oasis_namcouple:alloc)'
  2636. ! call oasis_debug_enter(subname)
  2637. !--- alloc_anais1
  2638. ALLOCATE (varmul(ig_nfield), stat=il_err)
  2639. IF (il_err.NE.0) CALL prtout ('Error in "varmul"allocation of anais module',il_err,1)
  2640. varmul(:)=0
  2641. ALLOCATE (niwtm(ig_nfield), stat=il_err)
  2642. IF (il_err.NE.0) CALL prtout ('Error in "niwtm"allocation of anais module',il_err,1)
  2643. niwtm(:)=0
  2644. ALLOCATE (niwtg(ig_nfield), stat=il_err)
  2645. IF (il_err.NE.0) CALL prtout ('Error in "niwtg"allocation of anais module',il_err,1)
  2646. niwtg(:)=0
  2647. allocate (linit(ig_nfield), stat=il_err)
  2648. if (il_err.ne.0) call prtout('error in "linit"allocation of anais module',il_err,1)
  2649. linit(:)=.false.
  2650. !--- alloc_analysis
  2651. ALLOCATE (ncofld(ig_nfield), stat=il_err)
  2652. IF (il_err.NE.0) CALL prtout ('Error in "ncofld"allocation of analysis module',il_err,1)
  2653. ncofld(:)=0
  2654. ALLOCATE (neighborg(ig_nfield), stat=il_err)
  2655. IF (il_err.NE.0) CALL prtout ('Error in "neighborg"allocation of analysis module',il_err,1)
  2656. neighborg(:)=0
  2657. ALLOCATE (nludat(ig_maxcomb,ig_nfield), stat=il_err)
  2658. IF (il_err.NE.0) CALL prtout ('Error in "nludat"allocation of analysis module',il_err,1)
  2659. nludat(:,:)=0
  2660. ALLOCATE (nlufil(ig_nfield), stat=il_err)
  2661. IF (il_err.NE.0) CALL prtout ('Error in "nlufil"allocation of analysis module',il_err,1)
  2662. nlufil(:)=0
  2663. ALLOCATE (nlumap(ig_nfield), stat=il_err)
  2664. IF (il_err.NE.0) CALL prtout ('Error in "nlumap"allocation of analysis module',il_err,1)
  2665. nlumap(:)=0
  2666. ALLOCATE (nlusub(ig_nfield), stat=il_err)
  2667. IF (il_err.NE.0) CALL prtout ('Error in "nlusub"allocation of analysis module',il_err,1)
  2668. nlusub(:)=0
  2669. ALLOCATE (nluext(ig_nfield), stat=il_err)
  2670. IF (il_err.NE.0) CALL prtout ('Error in "nluext"allocation of analysis module',il_err,1)
  2671. nluext(:)=0
  2672. ALLOCATE (nosper(ig_nfield), stat=il_err)
  2673. IF (il_err.NE.0) CALL prtout ('Error in "nosper"allocation of analysis module',il_err,1)
  2674. nosper(:)=0
  2675. ALLOCATE (notper(ig_nfield), stat=il_err)
  2676. IF (il_err.NE.0) CALL prtout ('Error in "notper"allocation of analysis module',il_err,1)
  2677. notper(:)=0
  2678. ALLOCATE (amskval(ig_nfield), stat=il_err)
  2679. IF (il_err.NE.0) CALL prtout ('Error in "amskval"allocation of analysis module',il_err,1)
  2680. amskval(:)=0
  2681. ALLOCATE (amskvalnew(ig_nfield), stat=il_err)
  2682. IF (il_err.NE.0) CALL prtout ('Error in "amskvalnew"allocation of analysis module',il_err,1)
  2683. amskvalnew(:)=0
  2684. ALLOCATE (acocoef(ig_maxcomb,ig_nfield), stat=il_err)
  2685. IF (il_err.NE.0) CALL prtout ('Error in "acocoef"allocation of analysis module',il_err,1)
  2686. acocoef(:,:)=0
  2687. ALLOCATE (abocoef(ig_maxcomb,ig_nfield), stat=il_err)
  2688. IF (il_err.NE.0) CALL prtout ('Error in "abocoef"allocation of analysis module',il_err,1)
  2689. abocoef(:,:)=0
  2690. ALLOCATE (abncoef(ig_maxcomb,ig_nfield), stat=il_err)
  2691. IF (il_err.NE.0) CALL prtout ('Error in "abncoef"allocation of analysis module',il_err,1)
  2692. abncoef(:,:)=0
  2693. ALLOCATE (afldcoef(ig_nfield), stat=il_err)
  2694. IF (il_err.NE.0) CALL prtout ('Error in "afldcoef"allocation of analysis module',il_err,1)
  2695. afldcoef(:)=0
  2696. ALLOCATE (afldcobo(ig_nfield), stat=il_err)
  2697. IF (il_err.NE.0) CALL prtout ('Error in "afldcobo"allocation of analysis module',il_err,1)
  2698. afldcobo(:)=0
  2699. ALLOCATE (afldcobn(ig_nfield), stat=il_err)
  2700. IF (il_err.NE.0) CALL prtout ('Error in "afldcobn"allocation of analysis module',il_err,1)
  2701. afldcobn(:)=0
  2702. ALLOCATE (cxordbf(ig_nfield), stat=il_err)
  2703. IF (il_err.NE.0) CALL prtout ('Error in "cxordbf"allocation of analysis module',il_err,1)
  2704. cxordbf(:)=' '
  2705. ALLOCATE (cyordbf(ig_nfield), stat=il_err)
  2706. IF (il_err.NE.0) CALL prtout ('Error in "cyordbf"allocation of analysis module',il_err,1)
  2707. cyordbf(:)=' '
  2708. ALLOCATE (cxordaf(ig_nfield), stat=il_err)
  2709. IF (il_err.NE.0) CALL prtout ('Error in "cxordaf"allocation of analysis module',il_err,1)
  2710. cxordaf(:)=' '
  2711. ALLOCATE (cyordaf(ig_nfield), stat=il_err)
  2712. IF (il_err.NE.0) CALL prtout ('Error in "cyordaf"allocation of analysis module',il_err,1)
  2713. cyordaf(:)=' '
  2714. ALLOCATE (cgrdtyp(ig_nfield), stat=il_err)
  2715. IF (il_err.NE.0) CALL prtout ('Error in "cgrdtyp"allocation of analysis module',il_err,1)
  2716. cgrdtyp(:)=' '
  2717. ALLOCATE (cfldtyp(ig_nfield), stat=il_err)
  2718. IF (il_err.NE.0) CALL prtout ('Error in "cfldtyp"allocation of analysis module',il_err,1)
  2719. cfldtyp(:)=' '
  2720. ALLOCATE (cfilfic(ig_nfield), stat=il_err)
  2721. IF (il_err.NE.0) CALL prtout ('Error in "cfilfic"allocation of analysis module',il_err,1)
  2722. cfilfic(:)=' '
  2723. ALLOCATE (cfilmet(ig_nfield), stat=il_err)
  2724. IF (il_err.NE.0) CALL prtout ('Error in "cfilmet"allocation of analysis module',il_err,1)
  2725. cfilmet(:)=' '
  2726. ALLOCATE (cconmet(ig_nfield), stat=il_err)
  2727. IF (il_err.NE.0) CALL prtout ('Error in "cconmet"allocation of analysis module',il_err,1)
  2728. cconmet(:)=' '
  2729. ALLOCATE (cconopt(ig_nfield), stat=il_err)
  2730. IF (il_err.NE.0) CALL prtout ('Error in "cconopt"allocation of analysis module',il_err,1)
  2731. cconopt(:)=' '
  2732. ALLOCATE (cfldcoa(ig_nfield), stat=il_err)
  2733. IF (il_err.NE.0) CALL prtout ('Error in "cfldcoa"allocation of analysis module',il_err,1)
  2734. cfldcoa(:)=' '
  2735. ALLOCATE (cfldfin(ig_nfield), stat=il_err)
  2736. IF (il_err.NE.0) CALL prtout ('Error in "cfldfin"allocation of analysis module',il_err,1)
  2737. cfldfin(:)=' '
  2738. ALLOCATE (ccofld(ig_maxcomb,ig_nfield), stat=il_err)
  2739. IF (il_err.NE.0) CALL prtout ('Error in "ccofld"allocation of analysis module',il_err,1)
  2740. ccofld(:,:)=' '
  2741. ALLOCATE (cbofld(ig_maxcomb,ig_nfield), stat=il_err)
  2742. IF (il_err.NE.0) CALL prtout ('Error in "cbofld"allocation of analysis module',il_err,1)
  2743. cbofld(:,:)=' '
  2744. ALLOCATE (cbnfld(ig_maxcomb,ig_nfield), stat=il_err)
  2745. IF (il_err.NE.0) CALL prtout ('Error in "cbnfld"allocation of analysis module',il_err,1)
  2746. cbnfld(:,:)=' '
  2747. ALLOCATE (ccofic(ig_maxcomb,ig_nfield), stat=il_err)
  2748. IF (il_err.NE.0) CALL prtout ('Error in "ccofic"allocation of analysis module',il_err,1)
  2749. ccofic(:,:)=' '
  2750. ALLOCATE (cdqdt(ig_nfield), stat=il_err)
  2751. IF (il_err.NE.0) CALL prtout ('Error in "cdqdt"allocation of analysis module',il_err,1)
  2752. cdqdt(:)=' '
  2753. ALLOCATE (cgrdmap(ig_nfield), stat=il_err)
  2754. IF (il_err.NE.0) CALL prtout ('Error in "cgrdmap"allocation of analysis module',il_err,1)
  2755. cgrdmap(:)=' '
  2756. ALLOCATE (cmskrd(ig_nfield), stat=il_err)
  2757. IF (il_err.NE.0) CALL prtout ('Error in "cmskrd"allocation of analysis module',il_err,1)
  2758. cmskrd(:)=' '
  2759. ALLOCATE (cgrdsub(ig_nfield), stat=il_err)
  2760. IF (il_err.NE.0) CALL prtout ('Error in "cgrdsub"allocation of analysis module',il_err,1)
  2761. cgrdsub(:)=' '
  2762. ALLOCATE (ctypsub(ig_nfield), stat=il_err)
  2763. IF (il_err.NE.0) CALL prtout ('Error in "ctypsub"allocation of analysis module',il_err,1)
  2764. ctypsub(:)=' '
  2765. ALLOCATE (cgrdext(ig_nfield), stat=il_err)
  2766. IF (il_err.NE.0) CALL prtout ('Error in "cgrdext"allocation of analysis module',il_err,1)
  2767. cgrdext(:)=' '
  2768. ALLOCATE (csper(ig_nfield), stat=il_err)
  2769. IF (il_err.NE.0) CALL prtout ('Error in "csper"allocation of analysis module',il_err,1)
  2770. csper(:)=' '
  2771. ALLOCATE (ctper(ig_nfield), stat=il_err)
  2772. IF (il_err.NE.0) CALL prtout ('Error in "ctper"allocation of analysis module',il_err,1)
  2773. ctper(:)=' '
  2774. ALLOCATE (lsurf(ig_nfield), stat=il_err)
  2775. IF (il_err.NE.0) CALL prtout ('Error in "lsurf"allocation of analysis module',il_err,1)
  2776. lsurf(:)=.false.
  2777. ALLOCATE (nscripvoi(ig_nfield), stat=il_err)
  2778. IF (il_err.NE.0) CALL prtout ('Error in nscripvoi allocation of analysis module',il_err,1)
  2779. nscripvoi(:)=0
  2780. !
  2781. !* Alloc array needed for SCRIP
  2782. !
  2783. ALLOCATE (cmap_method(ig_nfield),stat=il_err)
  2784. IF (il_err.NE.0) CALL prtout ('Error in "cmap_method" allocation of inipar_alloc',il_err,1)
  2785. cmap_method(:)=' '
  2786. ALLOCATE (cmap_file(ig_nfield),stat=il_err)
  2787. IF (il_err.NE.0) CALL prtout ('Error in "cmap_file" allocation of inipar_alloc',il_err,1)
  2788. cmap_file(:)=' '
  2789. ALLOCATE (cmaptyp(ig_nfield),stat=il_err)
  2790. IF (il_err.NE.0) CALL prtout ('Error in "cmaptyp" allocation of inipar_alloc',il_err,1)
  2791. cmaptyp(:)=' '
  2792. ALLOCATE (cmapopt(ig_nfield),stat=il_err)
  2793. IF (il_err.NE.0) CALL prtout ('Error in "cmapopt" allocation of inipar_alloc',il_err,1)
  2794. cmapopt(:)=' '
  2795. ALLOCATE (cfldtype(ig_nfield),stat=il_err)
  2796. IF (il_err.NE.0) CALL prtout ('Error in "cfldtype"allocation of inipar_alloc',il_err,1)
  2797. cfldtype(:)=' '
  2798. ALLOCATE (crsttype(ig_nfield),stat=il_err)
  2799. IF (il_err.NE.0) CALL prtout ('Error in "crsttype"allocation of inipar_alloc',il_err,1)
  2800. crsttype(:)=' '
  2801. ALLOCATE (nbins(ig_nfield),stat=il_err)
  2802. IF (il_err.NE.0) CALL prtout ('Error in "nbins"allocation of inipar_alloc',il_err,1)
  2803. nbins(:)=0
  2804. ALLOCATE (cnorm_opt(ig_nfield),stat=il_err)
  2805. IF (il_err.NE.0) CALL prtout ('Error in "cnorm_opt"allocation of inipar_alloc',il_err,1)
  2806. cnorm_opt(:)=' '
  2807. ALLOCATE (corder(ig_nfield),stat=il_err)
  2808. IF (il_err.NE.0) CALL prtout ('Error in "corder"allocation of inipar_alloc',il_err,1)
  2809. corder(:)=' '
  2810. !
  2811. !--- alloc_extrapol1
  2812. ALLOCATE (niwtn(ig_nfield), stat=il_err)
  2813. IF (il_err.NE.0) CALL prtout ('Error in "niwtn"allocation of extrapol module',il_err,1)
  2814. niwtn(:)=0
  2815. ALLOCATE (niwtng(ig_nfield), stat=il_err)
  2816. IF (il_err.NE.0) CALL prtout ('Error in "niwtng"allocation of extrapol module',il_err,1)
  2817. niwtng(:)=0
  2818. ALLOCATE (lextra(ig_nfield), stat=il_err)
  2819. IF (il_err.NE.0) CALL prtout ('Error in "lextra"allocation of extrapol module',il_err,1)
  2820. lextra(:)=.false.
  2821. ALLOCATE (lweight(ig_nfield), stat=il_err)
  2822. IF (il_err.NE.0) CALL prtout ('Error in "lweight"allocation of extrapol module',il_err,1)
  2823. lweight(:)=.false.
  2824. !--- alloc_rainbow1
  2825. ALLOCATE (lmapp(ig_nfield), stat=il_err)
  2826. IF (il_err.NE.0) CALL prtout ('Error in "lmapp"allocation of rainbow module',il_err,1)
  2827. lmapp(:)=.false.
  2828. ALLOCATE (lsubg(ig_nfield), stat=il_err)
  2829. IF (il_err.NE.0) CALL prtout ('Error in "lsubg"allocation of rainbow module',il_err,1)
  2830. lsubg(:)=.false.
  2831. !--- alloc_string
  2832. ALLOCATE (cg_name_rstfile(ig_nbr_rstfile), stat=il_err)
  2833. IF (il_err.NE.0) CALL prtout ('Error in "cg_name_rstfile"allocation of string module',il_err,1)
  2834. cg_name_rstfile(:)=' '
  2835. ALLOCATE (ig_lag(ig_total_nfield), stat=il_err)
  2836. IF (il_err.NE.0) CALL prtout ('Error in "ig_lag"allocation of string module',il_err,1)
  2837. ig_lag(:)=0
  2838. ALLOCATE (ig_no_rstfile(ig_total_nfield), stat=il_err)
  2839. IF (il_err.NE.0) CALL prtout ('Error in "ig_no_rstfile"allocation of string module',il_err,1)
  2840. ig_no_rstfile(:)=1
  2841. ALLOCATE (cg_input_field(ig_total_nfield), stat=il_err)
  2842. IF (il_err.NE.0) CALL prtout ('Error in "cg_input_field"allocation of string module',il_err,1)
  2843. cg_input_field(:)=' '
  2844. ALLOCATE (ig_numlab(ig_total_nfield), stat=il_err)
  2845. IF (il_err.NE.0) CALL prtout ('Error in "ig_numlab"allocation of string module',il_err,1)
  2846. ig_numlab(:)=0
  2847. ALLOCATE (ig_freq(ig_total_nfield), stat=il_err)
  2848. IF (il_err.NE.0) CALL prtout ('Error in "ig_freq"allocation of string module',il_err,1)
  2849. ig_freq(:)=0
  2850. ALLOCATE (ig_total_nseqn(ig_total_nfield), stat=il_err)
  2851. IF (il_err.NE.0) CALL prtout ('Error in "ig_total_nseqn"allocation of string module',il_err,1)
  2852. ig_total_nseqn(:)=0
  2853. ALLOCATE (ig_local_trans(ig_total_nfield), stat=il_err)
  2854. IF (il_err.NE.0) CALL prtout ('Error in "ig_local_trans"allocation of string module',il_err,1)
  2855. ig_local_trans(:)=0
  2856. ALLOCATE (ig_invert(ig_total_nfield), stat=il_err)
  2857. IF (il_err.NE.0) CALL prtout ('Error in "ig_invert" allocation of string module',il_err,1)
  2858. ig_invert(:)=0
  2859. ALLOCATE (ig_reverse(ig_total_nfield), stat=il_err)
  2860. IF (il_err.NE.0) CALL prtout ('Error in "ig_reverse" allocation of string module',il_err,1)
  2861. ig_reverse(:)=0
  2862. !
  2863. !** + Allocate following arrays only if one field (at least) goes
  2864. ! through Oasis
  2865. !
  2866. IF (lg_oasis_field) THEN
  2867. ALLOCATE (numlab(ig_nfield), stat=il_err)
  2868. IF (il_err.NE.0) CALL prtout ('Error in "numlab"allocation of string module',il_err,1)
  2869. numlab(:)=0
  2870. ALLOCATE (nfexch(ig_nfield), stat=il_err)
  2871. IF (il_err.NE.0) CALL prtout ('Error in "nfexch"allocation of string module',il_err,1)
  2872. nfexch(:)=0
  2873. ALLOCATE (nseqn(ig_nfield), stat=il_err)
  2874. IF (il_err.NE.0) CALL prtout ('Error in "nseqn"allocation of string module',il_err,1)
  2875. nseqn(:)=0
  2876. ALLOCATE (nlagn(ig_nfield), stat=il_err)
  2877. IF (il_err.NE.0) CALL prtout ('Error in "nlagn" allocation of string module',il_err,1)
  2878. nlagn(:)=0
  2879. ALLOCATE (cnaminp(ig_nfield), stat=il_err)
  2880. IF (il_err.NE.0) CALL prtout ('Error in "cnaminp"allocation of string module',il_err,1)
  2881. cnaminp(:)=' '
  2882. ALLOCATE (cnamout(ig_nfield), stat=il_err)
  2883. IF (il_err.NE.0) CALL prtout ('Error in "cnamout"allocation of string module',il_err,1)
  2884. cnamout(:)=' '
  2885. ALLOCATE (cficout(ig_nfield), stat=il_err)
  2886. IF (il_err.NE.0) CALL prtout ('Error in "cficout"allocation of string module',il_err,1)
  2887. cficout(:)=' '
  2888. ALLOCATE (cstate(ig_nfield), stat=il_err)
  2889. IF (il_err.NE.0) CALL prtout ('Error in "cstate"allocation of string module',il_err,1)
  2890. cstate(:)=' '
  2891. ENDIF
  2892. ! call oasis_debug_exit(subname)
  2893. END SUBROUTINE alloc
  2894. !===============================================================================
  2895. SUBROUTINE dealloc
  2896. IMPLICIT NONE
  2897. character(len=*),parameter :: subname='(mod_oasis_namcouple:dealloc)'
  2898. !--- alloc_anais1
  2899. DEALLOCATE (varmul, stat=il_err)
  2900. IF (il_err.NE.0) CALL prtout ('Error in "varmul"deallocation of anais module',il_err,1)
  2901. DEALLOCATE (niwtm, stat=il_err)
  2902. IF (il_err.NE.0) CALL prtout ('Error in "niwtm"deallocation of anais module',il_err,1)
  2903. DEALLOCATE (niwtg, stat=il_err)
  2904. IF (il_err.NE.0) CALL prtout ('Error in "niwtg"deallocation of anais module',il_err,1)
  2905. deallocate (linit, stat=il_err)
  2906. if (il_err.ne.0) call prtout('error in "linit"deallocation of anais module',il_err,1)
  2907. !--- alloc_analysis
  2908. DEALLOCATE (ncofld, stat=il_err)
  2909. IF (il_err.NE.0) CALL prtout ('Error in "ncofld"deallocation of analysis module',il_err,1)
  2910. DEALLOCATE (neighborg, stat=il_err)
  2911. IF (il_err.NE.0) CALL prtout ('Error in "neighborg"deallocation of analysis module',il_err,1)
  2912. DEALLOCATE (nludat, stat=il_err)
  2913. IF (il_err.NE.0) CALL prtout ('Error in "nludat"deallocation of analysis module',il_err,1)
  2914. DEALLOCATE (nlufil, stat=il_err)
  2915. IF (il_err.NE.0) CALL prtout ('Error in "nlufil"deallocation of analysis module',il_err,1)
  2916. DEALLOCATE (nlumap, stat=il_err)
  2917. IF (il_err.NE.0) CALL prtout ('Error in "nlumap"deallocation of analysis module',il_err,1)
  2918. DEALLOCATE (nlusub, stat=il_err)
  2919. IF (il_err.NE.0) CALL prtout ('Error in "nlusub"deallocation of analysis module',il_err,1)
  2920. DEALLOCATE (nluext, stat=il_err)
  2921. IF (il_err.NE.0) CALL prtout ('Error in "nluext"deallocation of analysis module',il_err,1)
  2922. DEALLOCATE (nosper, stat=il_err)
  2923. IF (il_err.NE.0) CALL prtout ('Error in "nosper"deallocation of analysis module',il_err,1)
  2924. DEALLOCATE (notper, stat=il_err)
  2925. IF (il_err.NE.0) CALL prtout ('Error in "notper"deallocation of analysis module',il_err,1)
  2926. DEALLOCATE (amskval, stat=il_err)
  2927. IF (il_err.NE.0) CALL prtout ('Error in "amskval"deallocation of analysis module',il_err,1)
  2928. DEALLOCATE (amskvalnew, stat=il_err)
  2929. IF (il_err.NE.0) CALL prtout ('Error in "amskvalnew"deallocation of analysis module',il_err,1)
  2930. DEALLOCATE (acocoef, stat=il_err)
  2931. IF (il_err.NE.0) CALL prtout ('Error in "acocoef"deallocation of analysis module',il_err,1)
  2932. DEALLOCATE (abocoef, stat=il_err)
  2933. IF (il_err.NE.0) CALL prtout ('Error in "abocoef"deallocation of analysis module',il_err,1)
  2934. DEALLOCATE (abncoef, stat=il_err)
  2935. IF (il_err.NE.0) CALL prtout ('Error in "abncoef"deallocation of analysis module',il_err,1)
  2936. DEALLOCATE (afldcoef, stat=il_err)
  2937. IF (il_err.NE.0) CALL prtout ('Error in "afldcoef"deallocation of analysis module',il_err,1)
  2938. DEALLOCATE (afldcobo, stat=il_err)
  2939. IF (il_err.NE.0) CALL prtout ('Error in "afldcobo"deallocation of analysis module',il_err,1)
  2940. DEALLOCATE (afldcobn, stat=il_err)
  2941. IF (il_err.NE.0) CALL prtout ('Error in "afldcobn"deallocation of analysis module',il_err,1)
  2942. DEALLOCATE (cxordbf, stat=il_err)
  2943. IF (il_err.NE.0) CALL prtout ('Error in "cxordbf"deallocation of analysis module',il_err,1)
  2944. DEALLOCATE (cyordbf, stat=il_err)
  2945. IF (il_err.NE.0) CALL prtout ('Error in "cyordbf"deallocation of analysis module',il_err,1)
  2946. DEALLOCATE (cxordaf, stat=il_err)
  2947. IF (il_err.NE.0) CALL prtout ('Error in "cxordaf"deallocation of analysis module',il_err,1)
  2948. DEALLOCATE (cyordaf, stat=il_err)
  2949. IF (il_err.NE.0) CALL prtout ('Error in "cyordaf"deallocation of analysis module',il_err,1)
  2950. DEALLOCATE (cgrdtyp, stat=il_err)
  2951. IF (il_err.NE.0) CALL prtout ('Error in "cgrdtyp"deallocation of analysis module',il_err,1)
  2952. DEALLOCATE (cfldtyp, stat=il_err)
  2953. IF (il_err.NE.0) CALL prtout ('Error in "cfldtyp"deallocation of analysis module',il_err,1)
  2954. DEALLOCATE (cfilfic, stat=il_err)
  2955. IF (il_err.NE.0) CALL prtout ('Error in "cfilfic"deallocation of analysis module',il_err,1)
  2956. DEALLOCATE (cfilmet, stat=il_err)
  2957. IF (il_err.NE.0) CALL prtout ('Error in "cfilmet"deallocation of analysis module',il_err,1)
  2958. DEALLOCATE (cconmet, stat=il_err)
  2959. IF (il_err.NE.0) CALL prtout ('Error in "cconmet"deallocation of analysis module',il_err,1)
  2960. DEALLOCATE (cconopt, stat=il_err)
  2961. IF (il_err.NE.0) CALL prtout ('Error in "cconopt"deallocation of analysis module',il_err,1)
  2962. DEALLOCATE (cfldcoa, stat=il_err)
  2963. IF (il_err.NE.0) CALL prtout ('Error in "cfldcoa"deallocation of analysis module',il_err,1)
  2964. DEALLOCATE (cfldfin, stat=il_err)
  2965. IF (il_err.NE.0) CALL prtout ('Error in "cfldfin"deallocation of analysis module',il_err,1)
  2966. DEALLOCATE (ccofld, stat=il_err)
  2967. IF (il_err.NE.0) CALL prtout ('Error in "ccofld"deallocation of analysis module',il_err,1)
  2968. DEALLOCATE (cbofld, stat=il_err)
  2969. IF (il_err.NE.0) CALL prtout ('Error in "cbofld"deallocation of analysis module',il_err,1)
  2970. DEALLOCATE (cbnfld, stat=il_err)
  2971. IF (il_err.NE.0) CALL prtout ('Error in "cbnfld"deallocation of analysis module',il_err,1)
  2972. DEALLOCATE (ccofic, stat=il_err)
  2973. IF (il_err.NE.0) CALL prtout ('Error in "ccofic"deallocation of analysis module',il_err,1)
  2974. DEALLOCATE (cdqdt, stat=il_err)
  2975. IF (il_err.NE.0) CALL prtout ('Error in "cdqdt"deallocation of analysis module',il_err,1)
  2976. DEALLOCATE (cgrdmap, stat=il_err)
  2977. IF (il_err.NE.0) CALL prtout ('Error in "cgrdmap"deallocation of analysis module',il_err,1)
  2978. DEALLOCATE (cmskrd, stat=il_err)
  2979. IF (il_err.NE.0) CALL prtout ('Error in "cmskrd"deallocation of analysis module',il_err,1)
  2980. DEALLOCATE (cgrdsub, stat=il_err)
  2981. IF (il_err.NE.0) CALL prtout ('Error in "cgrdsub"deallocation of analysis module',il_err,1)
  2982. DEALLOCATE (ctypsub, stat=il_err)
  2983. IF (il_err.NE.0) CALL prtout ('Error in "ctypsub"deallocation of analysis module',il_err,1)
  2984. DEALLOCATE (cgrdext, stat=il_err)
  2985. IF (il_err.NE.0) CALL prtout ('Error in "cgrdext"deallocation of analysis module',il_err,1)
  2986. DEALLOCATE (csper, stat=il_err)
  2987. IF (il_err.NE.0) CALL prtout ('Error in "csper"deallocation of analysis module',il_err,1)
  2988. DEALLOCATE (ctper, stat=il_err)
  2989. IF (il_err.NE.0) CALL prtout ('Error in "ctper"deallocation of analysis module',il_err,1)
  2990. DEALLOCATE (lsurf, stat=il_err)
  2991. IF (il_err.NE.0) CALL prtout ('Error in "lsurf"deallocation of analysis module',il_err,1)
  2992. DEALLOCATE (nscripvoi, stat=il_err)
  2993. IF (il_err.NE.0) CALL prtout ('Error in nscripvoi deallocation of analysis module',il_err,1)
  2994. !
  2995. !* Alloc array needed for SCRIP
  2996. !
  2997. DEALLOCATE (cmap_method,stat=il_err)
  2998. IF (il_err.NE.0) CALL prtout ('Error in "cmap_method" deallocation of inipar_alloc',il_err,1)
  2999. DEALLOCATE (cmap_file,stat=il_err)
  3000. IF (il_err.NE.0) CALL prtout ('Error in "cmap_file" deallocation of inipar_alloc',il_err,1)
  3001. DEALLOCATE (cmaptyp,stat=il_err)
  3002. IF (il_err.NE.0) CALL prtout ('Error in "cmaptyp" deallocation of inipar_alloc',il_err,1)
  3003. DEALLOCATE (cmapopt,stat=il_err)
  3004. IF (il_err.NE.0) CALL prtout ('Error in "cmapopt" deallocation of inipar_alloc',il_err,1)
  3005. DEALLOCATE (cfldtype,stat=il_err)
  3006. IF (il_err.NE.0) CALL prtout ('Error in "cfldtype"deallocation of inipar_alloc',il_err,1)
  3007. DEALLOCATE (crsttype,stat=il_err)
  3008. IF (il_err.NE.0) CALL prtout ('Error in "crsttype"deallocation of inipar_alloc',il_err,1)
  3009. DEALLOCATE (nbins,stat=il_err)
  3010. IF (il_err.NE.0) CALL prtout ('Error in "nbins"deallocation of inipar_alloc',il_err,1)
  3011. DEALLOCATE (cnorm_opt,stat=il_err)
  3012. IF (il_err.NE.0) CALL prtout ('Error in "cnorm_opt"deallocation of inipar_alloc',il_err,1)
  3013. DEALLOCATE (corder,stat=il_err)
  3014. IF (il_err.NE.0) CALL prtout ('Error in "corder"deallocation of inipar_alloc',il_err,1)
  3015. !
  3016. !--- alloc_extrapol1
  3017. DEALLOCATE (niwtn, stat=il_err)
  3018. IF (il_err.NE.0) CALL prtout ('Error in "niwtn"deallocation of extrapol module',il_err,1)
  3019. DEALLOCATE (niwtng, stat=il_err)
  3020. IF (il_err.NE.0) CALL prtout ('Error in "niwtng"deallocation of extrapol module',il_err,1)
  3021. DEALLOCATE (lextra, stat=il_err)
  3022. IF (il_err.NE.0) CALL prtout ('Error in "lextra"deallocation of extrapol module',il_err,1)
  3023. DEALLOCATE (lweight, stat=il_err)
  3024. IF (il_err.NE.0) CALL prtout ('Error in "lweight"deallocation of extrapol module',il_err,1)
  3025. !--- alloc_rainbow1
  3026. DEALLOCATE (lmapp, stat=il_err)
  3027. IF (il_err.NE.0) CALL prtout ('Error in "lmapp"deallocation of rainbow module',il_err,1)
  3028. DEALLOCATE (lsubg, stat=il_err)
  3029. IF (il_err.NE.0) CALL prtout ('Error in "lsubg"deallocation of rainbow module',il_err,1)
  3030. !--- alloc_string
  3031. DEALLOCATE (cg_name_rstfile, stat=il_err)
  3032. IF (il_err.NE.0) CALL prtout ('Error in "cg_name_rstfile"deallocation of string module',il_err,1)
  3033. DEALLOCATE (ig_lag, stat=il_err)
  3034. IF (il_err.NE.0) CALL prtout ('Error in "ig_lag"deallocation of string module',il_err,1)
  3035. DEALLOCATE (ig_no_rstfile, stat=il_err)
  3036. IF (il_err.NE.0) CALL prtout ('Error in "ig_no_rstfile"deallocation of string module',il_err,1)
  3037. DEALLOCATE (cg_input_field, stat=il_err)
  3038. IF (il_err.NE.0) CALL prtout ('Error in "cg_input_field"deallocation of string module',il_err,1)
  3039. DEALLOCATE (ig_numlab, stat=il_err)
  3040. IF (il_err.NE.0) CALL prtout ('Error in "ig_numlab"deallocation of string module',il_err,1)
  3041. DEALLOCATE (ig_freq, stat=il_err)
  3042. IF (il_err.NE.0) CALL prtout ('Error in "ig_freq"deallocation of string module',il_err,1)
  3043. DEALLOCATE (ig_total_nseqn, stat=il_err)
  3044. IF (il_err.NE.0) CALL prtout ('Error in "ig_total_nseqn"deallocation of string module',il_err,1)
  3045. DEALLOCATE (ig_local_trans, stat=il_err)
  3046. IF (il_err.NE.0) CALL prtout ('Error in "ig_local_trans"deallocation of string module',il_err,1)
  3047. DEALLOCATE (ig_invert, stat=il_err)
  3048. IF (il_err.NE.0) CALL prtout ('Error in "ig_invert" deallocation of string module',il_err,1)
  3049. DEALLOCATE (ig_reverse, stat=il_err)
  3050. IF (il_err.NE.0) CALL prtout ('Error in "ig_reverse" deallocation of string module',il_err,1)
  3051. !
  3052. !** + Deallocate following arrays only if one field (at least) goes
  3053. ! through Oasis
  3054. !
  3055. IF (lg_oasis_field) THEN
  3056. DEALLOCATE (numlab, stat=il_err)
  3057. IF (il_err.NE.0) CALL prtout ('Error in "numlab"deallocation of string module',il_err,1)
  3058. DEALLOCATE (nfexch, stat=il_err)
  3059. IF (il_err.NE.0) CALL prtout ('Error in "nfexch"deallocation of string module',il_err,1)
  3060. DEALLOCATE (nseqn, stat=il_err)
  3061. IF (il_err.NE.0) CALL prtout ('Error in "nseqn"deallocation of string module',il_err,1)
  3062. DEALLOCATE (nlagn, stat=il_err)
  3063. IF (il_err.NE.0) CALL prtout ('Error in "nlagn" deallocation of string module',il_err,1)
  3064. DEALLOCATE (cnaminp, stat=il_err)
  3065. IF (il_err.NE.0) CALL prtout ('Error in "cnaminp"deallocation of string module',il_err,1)
  3066. DEALLOCATE (cnamout, stat=il_err)
  3067. IF (il_err.NE.0) CALL prtout ('Error in "cnamout"deallocation of string module',il_err,1)
  3068. DEALLOCATE (cficout, stat=il_err)
  3069. IF (il_err.NE.0) CALL prtout ('Error in "cficout"deallocation of string module',il_err,1)
  3070. DEALLOCATE (cstate, stat=il_err)
  3071. IF (il_err.NE.0) CALL prtout ('Error in "cstate"deallocation of string module',il_err,1)
  3072. ENDIF
  3073. ! call oasis_debug_exit(subname)
  3074. END SUBROUTINE dealloc
  3075. !===============================================================================
  3076. SUBROUTINE prtout(cdtext, kvalue, kstyle)
  3077. !****
  3078. ! *****************************
  3079. ! * OASIS ROUTINE - LEVEL 1 *
  3080. ! * ------------- ------- *
  3081. ! *****************************
  3082. !
  3083. !**** *prtout* - Print output
  3084. !
  3085. ! Purpose:
  3086. ! -------
  3087. ! Print out character string and one integer value
  3088. !
  3089. !** Interface:
  3090. ! ---------
  3091. ! *CALL* *prtout (cdtext, kvalue, kstyle)*
  3092. !
  3093. ! Input:
  3094. ! -----
  3095. ! cdtext : character string to be printed
  3096. ! kvalue : integer variable to be printed
  3097. ! kstyle : printing style
  3098. !
  3099. ! Output:
  3100. ! ------
  3101. ! None
  3102. !
  3103. ! Workspace:
  3104. ! ---------
  3105. !
  3106. ! Externals:
  3107. ! ---------
  3108. ! None
  3109. !
  3110. ! Reference:
  3111. ! ---------
  3112. ! See OASIS manual (1995)
  3113. !
  3114. ! History:
  3115. ! -------
  3116. ! Version Programmer Date Description
  3117. ! ------- ---------- ---- -----------
  3118. ! 2.0 L. Terray 95/10/01 created
  3119. ! 2.3 L. Terray 99/02/24 modified: X format for NEC
  3120. !
  3121. ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  3122. IMPLICIT NONE
  3123. !
  3124. !* ---------------------------- Include files ---------------------------
  3125. !
  3126. !
  3127. !* ---------------------------- Argument declarations ----------------------
  3128. !
  3129. CHARACTER(len=*),intent(in) :: cdtext
  3130. INTEGER (kind=ip_intwp_p),intent(in) :: kvalue, kstyle
  3131. !* ---------------------------- Local declarations ----------------------
  3132. integer(kind=ip_intwp_p) :: ilen,jl
  3133. CHARACTER*69 cline
  3134. character(len=*),PARAMETER :: cbase = '-'
  3135. character(len=*),PARAMETER :: cprpt = '* ===>>> :'
  3136. character(len=*),PARAMETER :: cdots = ' ------ '
  3137. character(len=*),parameter :: subname='(mod_oasis_namcouple:prtout)'
  3138. !* ---------------------------- Poema verses ----------------------------
  3139. ! call oasis_debug_enter(subname)
  3140. ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  3141. !* 1. Print character string + integer value
  3142. ! --------------------------------------
  3143. IF (mpi_rank_global == 0) THEN
  3144. IF ( kstyle .EQ. 1 .OR. kstyle .EQ. 2) THEN
  3145. cline = ' '
  3146. ilen = len(cdtext)
  3147. DO 110 jl = 1, ILEN
  3148. cline(jl:jl) = cbase
  3149. 110 CONTINUE
  3150. IF ( kstyle .EQ. 2 ) THEN
  3151. WRITE(UNIT = nulprt1,FMT='(/,A,1X,A)') cdots, cline
  3152. ENDIF
  3153. WRITE(UNIT = nulprt1,FMT='(A,1X,A,1X,I18)') cprpt, cdtext, kvalue
  3154. WRITE(UNIT = nulprt1,FMT='(A,1X,A,/)') cdots, cline
  3155. ELSE
  3156. WRITE(UNIT = nulprt1,FMT='(/,A,1X,A,1X,I18,/)') cprpt, cdtext, kvalue
  3157. ENDIF
  3158. !* 2. End of routine
  3159. ! --------------
  3160. CALL oasis_flush(nulprt1)
  3161. ENDIF
  3162. ! call oasis_debug_exit(subname)
  3163. END SUBROUTINE prtout
  3164. !===============================================================================
  3165. SUBROUTINE prcout (cdtext, cdstring, kstyle)
  3166. !****
  3167. ! *****************************
  3168. ! * OASIS ROUTINE - LEVEL 1 *
  3169. ! * ------------- ------- *
  3170. ! *****************************
  3171. !
  3172. !**** *prcout* - Print output
  3173. !
  3174. ! Purpose:
  3175. ! -------
  3176. ! Print out character string and one character value
  3177. !
  3178. !** Interface:
  3179. ! ---------
  3180. ! *CALL* *prcout (cdtext, cdstring, kstyle)*
  3181. !
  3182. ! Input:
  3183. ! -----
  3184. ! cdtext : character string to be printed
  3185. ! cdstring : character variable to be printed
  3186. ! kstyle : printing style
  3187. !
  3188. ! Output:
  3189. ! ------
  3190. ! None
  3191. !
  3192. ! Workspace:
  3193. ! ---------
  3194. ! None
  3195. !
  3196. ! Externals:
  3197. ! ---------
  3198. ! None
  3199. !
  3200. ! Reference:
  3201. ! ---------
  3202. ! See OASIS manual (1995)
  3203. !
  3204. ! History:
  3205. ! -------
  3206. ! Version Programmer Date Description
  3207. ! ------- ---------- ---- -----------
  3208. ! 2.0 L. Terray 95/10/01 created
  3209. ! 2.3 L. Terray 99/02/24 modified: X format for NEC
  3210. !
  3211. ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  3212. !
  3213. IMPLICIT NONE
  3214. !
  3215. !* ---------------------------- Include files ---------------------------
  3216. !
  3217. !
  3218. !* ---------------------------- Argument declarations ----------------------
  3219. !
  3220. CHARACTER(len=*),intent(in) :: cdtext, cdstring
  3221. INTEGER (kind=ip_intwp_p),intent(in) :: kstyle
  3222. !
  3223. !* ---------------------------- Local declarations ----------------------
  3224. !
  3225. integer (kind=ip_intwp_p) :: ilen,jl
  3226. CHARACTER*69 cline
  3227. character(len=*), PARAMETER :: cpbase = '-'
  3228. character(len=*), PARAMETER :: cprpt = '* ===>>> :'
  3229. character(len=*), PARAMETER :: cpdots = ' ------ '
  3230. character(len=*),parameter :: subname='(mod_oasis_namcouple:prcout)'
  3231. !
  3232. !* ---------------------------- Poema verses ----------------------------
  3233. !
  3234. ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  3235. !
  3236. !* 1. Print character string + character value
  3237. ! ----------------------------------------
  3238. !
  3239. ! call oasis_debug_enter(subname)
  3240. IF (mpi_rank_global == 0) THEN
  3241. IF ( kstyle .EQ. 1 .OR. kstyle .EQ. 2) THEN
  3242. cline = ' '
  3243. ilen = len(cdtext)
  3244. DO 110 jl = 1, ilen
  3245. cline(jl:jl) = cpbase
  3246. 110 CONTINUE
  3247. IF ( kstyle .EQ. 2 ) THEN
  3248. WRITE(UNIT = nulprt1,FMT='(/,A,1X,A)') cpdots, cline
  3249. ENDIF
  3250. WRITE(UNIT = nulprt1,FMT='(A,1X,A,1X,A)') cprpt, cdtext, cdstring
  3251. WRITE(UNIT = nulprt1,FMT='(A,1X,A,/)') cpdots, cline
  3252. ELSE
  3253. WRITE(UNIT = nulprt1,FMT='(/,A,1X,A,1X,A,/)') cprpt, cdtext, cdstring
  3254. ENDIF
  3255. !
  3256. !
  3257. !* 3. End of routine
  3258. ! --------------
  3259. !
  3260. CALL oasis_flush(nulprt1)
  3261. ENDIF
  3262. ! call oasis_debug_exit(subname)
  3263. END SUBROUTINE prcout
  3264. !===============================================================================
  3265. SUBROUTINE parse (cdone, cdtwo, knumb, klen, kleng, endflag)
  3266. !****
  3267. ! *****************************
  3268. ! * OASIS ROUTINE - LEVEL T *
  3269. ! * ------------- ------- *
  3270. ! *****************************
  3271. !
  3272. !**** *parse* - Parsing routine
  3273. !
  3274. ! Purpose:
  3275. ! -------
  3276. ! Find the knumb'th string in cdone and put it in cdtwo.
  3277. ! A string is defined as a continuous set of non-blanks characters
  3278. !
  3279. !** Interface:
  3280. ! ---------
  3281. ! *CALL* *parse (cdone, cdtwo, knumb, klen, kleng)*
  3282. !
  3283. ! Input:
  3284. ! -----
  3285. ! cdone : line to be parsed (char string)
  3286. ! knumb : rank within the line of the extracted string (integer)
  3287. ! klen : length of the input line (integer)
  3288. !
  3289. ! Output:
  3290. ! ------
  3291. ! cdtwo : extracted character string (char string)
  3292. ! kleng : length of the extracted string (integer)
  3293. !
  3294. ! Workspace:
  3295. ! ---------
  3296. ! None
  3297. !
  3298. ! Externals:
  3299. ! ---------
  3300. !
  3301. ! Reference:
  3302. ! ---------
  3303. ! See OASIS manual (1995)
  3304. !
  3305. ! History:
  3306. ! -------
  3307. ! Version Programmer Date Description
  3308. ! ------- ---------- ---- -----------
  3309. ! 2.0 L. Terray 95/09/01 created
  3310. ! O. Marti 2000/11/08 simplify by using F90
  3311. ! CHARACTER functions
  3312. !
  3313. ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  3314. !
  3315. IMPLICIT NONE
  3316. !
  3317. !* ---------------------------- Include files ---------------------------
  3318. !
  3319. !
  3320. !* ---------------------------- Argument declarations -------------------
  3321. !
  3322. INTEGER (kind=ip_intwp_p), INTENT ( in) :: knumb, klen
  3323. CHARACTER (len=klen), INTENT ( inout) :: cdone
  3324. CHARACTER (len=klen), INTENT ( out) :: cdtwo
  3325. INTEGER (kind=ip_intwp_p), INTENT ( out) :: kleng
  3326. LOGICAL, optional, intent(inout) :: endflag
  3327. !
  3328. !* ---------------------------- Local declarations -------------------
  3329. !
  3330. integer(kind=ip_intwp_p) :: ii,jl
  3331. CHARACTER (len=klen) :: clline
  3332. CHARACTER (len=klen) :: clwork
  3333. CHARACTER (len=1), SAVE :: clblank = ' ', clcmt = '#'
  3334. character(len=*),parameter :: subname='(mod_oasis_namcouple:parse)'
  3335. !
  3336. !* ---------------------------- Poema verses ----------------------------
  3337. ! call oasis_debug_enter(subname)
  3338. !
  3339. ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  3340. !
  3341. !* 1. Skip line if it is a comment
  3342. ! ----------------------------
  3343. !
  3344. if (present(endflag)) endflag = .false.
  3345. 100 IF (cdone(1:1) .NE. clcmt) GO TO 120
  3346. READ (UNIT = nulin, FMT = 1001, END=249) clline
  3347. cdone(1:klen) = clline(1:klen)
  3348. GO TO 100
  3349. 120 CONTINUE
  3350. 1001 FORMAT(A5000)
  3351. !
  3352. !
  3353. !* 2. Do the extraction job
  3354. ! ---------------------
  3355. !
  3356. !* - Fill cdtwo with blanks
  3357. !
  3358. cdtwo = clblank
  3359. !
  3360. !* Fill temporary string and remove leading blanks
  3361. !
  3362. clwork = ADJUSTL ( cdone)
  3363. !
  3364. !* - If there are no more characters, kleng=-1
  3365. !
  3366. IF ( LEN_TRIM ( clwork) .LE. 0) THEN
  3367. kleng = -1
  3368. ! call oasis_debug_exit(subname)
  3369. RETURN
  3370. END IF
  3371. !
  3372. !* - If this is the one we're looking for, skip
  3373. ! otherwise go knumb-1 more sets of characters
  3374. !
  3375. IF (knumb .GE. 2) THEN
  3376. DO jl = 1, knumb-1
  3377. ii = INDEX ( clwork, clblank) - 1
  3378. clwork ( 1:ii) = clblank
  3379. clwork = ADJUSTL ( clwork)
  3380. !
  3381. !* - If there are no more characters, kleng=-1
  3382. !
  3383. IF (LEN_TRIM ( clwork) .LE. 0) THEN
  3384. kleng = -1
  3385. ! call oasis_debug_exit(subname)
  3386. RETURN
  3387. END IF
  3388. END DO
  3389. END IF
  3390. !
  3391. !* - Find the length of this set of characters
  3392. !
  3393. kleng = INDEX ( clwork, clblank) - 1
  3394. !
  3395. !* - Copy to cdtwo
  3396. !
  3397. cdtwo ( 1:kleng) = clwork ( 1: kleng)
  3398. !
  3399. !* 3. End of routine
  3400. ! --------------
  3401. !
  3402. ! call oasis_debug_exit(subname)
  3403. return
  3404. 249 CONTINUE
  3405. IF (present(endflag)) then
  3406. endflag = .true.
  3407. return
  3408. ELSE
  3409. IF (mpi_rank_global == 0) THEN
  3410. WRITE (UNIT = nulprt1,FMT = *) ' ***WARNING***'
  3411. WRITE (UNIT = nulprt1,FMT = *) &
  3412. ' mod_oasis_namcouple routine parse ran out of input '
  3413. WRITE (UNIT = nulprt1,FMT = *) ' '
  3414. WRITE (UNIT = nulprt1,FMT = *) ' '
  3415. WRITE (UNIT = nulprt1,FMT = *) &
  3416. ' We STOP!!! Check the file namcouple'
  3417. WRITE (UNIT = nulprt1,FMT = *) ' '
  3418. WRITE (nulprt1,'(a,i4)') ' abort by model ',compid
  3419. WRITE (nulprt1,'(a)') ' error = STOP in inipar_alloc'
  3420. CALL oasis_flush(nulprt1)
  3421. ENDIF
  3422. CALL oasis_abort()
  3423. ENDIF
  3424. END SUBROUTINE parse
  3425. !===============================================================================
  3426. SUBROUTINE parseblk (cdone, cdtwo, knumb, klen, kleng)
  3427. !****
  3428. ! *****************************
  3429. ! * OASIS ROUTINE - LEVEL T *
  3430. ! * ------------- ------- *
  3431. ! *****************************
  3432. !
  3433. !**** *parse* - Parsing routine
  3434. !
  3435. ! Purpose:
  3436. ! -------
  3437. ! Get the rest of the line starting at the knumb'th string.
  3438. ! A string is defined as a continuous set of non-blanks characters
  3439. !
  3440. !** Interface:
  3441. ! ---------
  3442. ! *CALL* *parseblk (cdone, cdtwo, knumb, klen, kleng)*
  3443. !
  3444. ! Input:
  3445. ! -----
  3446. ! cdone : line to be parsed (char string)
  3447. ! knumb : rank within the line of the starting string (integer)
  3448. ! klen : length of the input line (integer)
  3449. !
  3450. ! Output:
  3451. ! ------
  3452. ! cdtwo : extracted rest of line, including blanks (char string)
  3453. ! kleng : length of the extracted string (integer)
  3454. !
  3455. ! Workspace:
  3456. ! ---------
  3457. ! None
  3458. !
  3459. ! Externals:
  3460. ! ---------
  3461. !
  3462. ! History:
  3463. ! -------
  3464. ! Version Programmer Date Description
  3465. ! ------- ---------- ---- -----------
  3466. ! 2.5 S. Valcke 00/09/08 Adapted from parse.f
  3467. !
  3468. ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  3469. !
  3470. IMPLICIT NONE
  3471. !
  3472. !* ---------------------------- Include files ---------------------------
  3473. !
  3474. !
  3475. !* ---------------------------- Argument declarations -------------------
  3476. !
  3477. INTEGER (kind=ip_intwp_p), INTENT ( in) :: knumb, klen
  3478. CHARACTER (len=klen), INTENT ( inout) :: cdone
  3479. CHARACTER (len=klen), INTENT ( out) :: cdtwo
  3480. INTEGER (kind=ip_intwp_p), INTENT ( out) :: kleng
  3481. !
  3482. !* ---------------------------- Local declarations -------------------
  3483. !
  3484. INTEGER (kind=ip_intwp_p) :: ii,jl
  3485. INTEGER (kind=ip_intwp_p) :: il, kleng_aux
  3486. CHARACTER (len=klen) :: clline
  3487. CHARACTER (len=klen) :: clwork
  3488. CHARACTER (len=1), SAVE :: clblank = ' ', clcmt = '#'
  3489. character(len=*),parameter :: subname='(mod_oasis_namcouple:parseblk)'
  3490. !
  3491. !* ---------------------------- Poema verses ----------------------------
  3492. ! call oasis_debug_enter(subname)
  3493. !
  3494. ! %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  3495. !
  3496. !* 1. Skip line if it is a comment
  3497. ! ----------------------------
  3498. !
  3499. 100 IF (cdone(1:1) .NE. clcmt) GO TO 120
  3500. READ (UNIT = nulin, FMT = 1001) clline
  3501. cdone(1:klen) = clline(1:klen)
  3502. GO TO 100
  3503. 120 CONTINUE
  3504. 1001 FORMAT(A5000)
  3505. !
  3506. !
  3507. !* 2. Do the extraction job
  3508. ! ---------------------
  3509. !
  3510. !* - Fill cdtwo with blanks
  3511. !
  3512. cdtwo = clblank
  3513. !
  3514. !* Fill temporary string and remove leading blanks
  3515. !
  3516. il = INDEX ( cdone, clblank)
  3517. kleng_aux = 1
  3518. IF (INDEX ( cdone, clblank).EQ.1) THEN
  3519. DO WHILE (cdone(il+1:il+1).EQ.clblank)
  3520. kleng_aux = kleng_aux +1
  3521. il = il+1
  3522. IF (il+1.GT.klen) GO TO 130
  3523. ENDDO
  3524. ENDIF
  3525. 130 CONTINUE
  3526. clwork = ADJUSTL ( cdone)
  3527. !
  3528. !* - If there are no more characters, kleng=-1
  3529. !
  3530. IF ( LEN_TRIM ( clwork) .LE. 0) THEN
  3531. kleng = -1
  3532. ! call oasis_debug_exit(subname)
  3533. RETURN
  3534. END IF
  3535. !
  3536. !* - If this is the one we're looking for, skip
  3537. ! otherwise go knumb-1 more sets of characters
  3538. !
  3539. IF (knumb .GE. 2) THEN
  3540. DO jl = 1, knumb-1
  3541. ii = INDEX ( clwork, clblank) - 1
  3542. il = ii + 1
  3543. DO WHILE (clwork(il:il).EQ.clblank)
  3544. kleng_aux = kleng_aux +1
  3545. il = il + 1
  3546. IF (il.GT.klen) GO TO 140
  3547. ENDDO
  3548. 140 CONTINUE
  3549. kleng_aux = kleng_aux + ii
  3550. clwork ( 1:ii) = clblank
  3551. clwork = ADJUSTL ( clwork)
  3552. !
  3553. !* - If there are no more characters, kleng=-1
  3554. !
  3555. IF (LEN_TRIM ( clwork) .LE. 0) THEN
  3556. kleng = -1
  3557. ! call oasis_debug_exit(subname)
  3558. RETURN
  3559. END IF
  3560. END DO
  3561. END IF
  3562. !
  3563. !* - Find the length of the rest of the line
  3564. !
  3565. kleng = klen - kleng_aux
  3566. !
  3567. !* - Copy to cdtwo
  3568. !
  3569. cdtwo ( 1:kleng) = clwork ( 1: kleng)
  3570. !
  3571. !* 3. End of routine
  3572. ! --------------
  3573. !
  3574. ! call oasis_debug_exit(subname)
  3575. END SUBROUTINE parseblk
  3576. !===============================================================================
  3577. SUBROUTINE skip (cd_one, id_len, endflag)
  3578. !
  3579. !**** SKIP
  3580. !
  3581. ! Purpose:
  3582. ! Skip line if it is a comment
  3583. !
  3584. ! Interface:
  3585. ! Call skip (cl_one)
  3586. !
  3587. ! Method:
  3588. ! Read the first caracter of the line and skip line if
  3589. ! it is a comment
  3590. !
  3591. ! External:
  3592. ! none
  3593. !
  3594. ! Files:
  3595. ! none
  3596. !
  3597. ! References:
  3598. !
  3599. ! History:
  3600. ! --------
  3601. ! Version Programmer Date Description
  3602. ! ------------------------------------------------
  3603. ! 2.5 A.Caubel 2002/04/04 created
  3604. !
  3605. !*-----------------------------------------------------------------------
  3606. !
  3607. IMPLICIT NONE
  3608. !
  3609. !** + DECLARATIONS
  3610. !
  3611. !
  3612. !** ++ Include files
  3613. !
  3614. !** ++ Argument declarations
  3615. !
  3616. INTEGER (kind=ip_intwp_p),intent(in) :: id_len
  3617. CHARACTER(len=*),intent(inout) :: cd_one
  3618. LOGICAL, optional, intent(inout) :: endflag
  3619. !
  3620. !** ++ Local declarations
  3621. !
  3622. INTEGER (kind=ip_intwp_p) :: ib
  3623. CHARACTER(len=id_len) :: cl_line
  3624. CHARACTER(len=1) :: cl_two
  3625. character(len=*),parameter :: subname='(mod_oasis_namcouple:skip)'
  3626. !
  3627. !*-----------------------------------------------------------------------
  3628. !
  3629. ! call oasis_debug_enter(subname)
  3630. cl_two='#'
  3631. 100 IF (cd_one(1:1) .NE. cl_two) GO TO 120
  3632. if (present(endflag)) then
  3633. endflag = .false.
  3634. READ (UNIT = nulin, FMT = 1001, END=140) cl_line
  3635. else
  3636. READ (UNIT = nulin, FMT = 1001) cl_line
  3637. endif
  3638. cd_one = trim(cl_line)
  3639. GO TO 100
  3640. 120 CONTINUE
  3641. RETURN
  3642. 140 CONTINUE
  3643. ENDFLAG = .true.
  3644. RETURN
  3645. 1001 FORMAT(A5000)
  3646. !
  3647. !*-----------------------------------------------------------------------
  3648. !
  3649. ! call oasis_debug_exit(subname)
  3650. END SUBROUTINE skip
  3651. !
  3652. !*========================================================================
  3653. !===============================================================================
  3654. !===============================================================================
  3655. END MODULE mod_oasis_namcouple